Features: - 30+ Custom Skills (cognitive, development, UI/UX, autonomous agents) - RalphLoop autonomous agent integration - Multi-AI consultation (Qwen) - Agent management system with sync capabilities - Custom hooks for session management - MCP servers integration - Plugin marketplace setup - Comprehensive installation script Components: - Skills: always-use-superpowers, ralph, brainstorming, ui-ux-pro-max, etc. - Agents: 100+ agents across engineering, marketing, product, etc. - Hooks: session-start-superpowers, qwen-consult, ralph-auto-trigger - Commands: /brainstorm, /write-plan, /execute-plan - MCP Servers: zai-mcp-server, web-search-prime, web-reader, zread - Binaries: ralphloop wrapper Installation: ./supercharge.sh
88 lines
2.5 KiB
TypeScript
88 lines
2.5 KiB
TypeScript
/**
|
|
* Branch Cleanup Command
|
|
* Removes merged branches locally and remotely
|
|
*/
|
|
|
|
import { exec } from 'child_process'
|
|
import { promisify } from 'util'
|
|
|
|
const execAsync = promisify(exec)
|
|
|
|
export interface BranchCleanupOptions {
|
|
local?: boolean
|
|
remote?: boolean
|
|
exclude?: string[]
|
|
dryRun?: boolean
|
|
}
|
|
|
|
export async function handle(
|
|
args: BranchCleanupOptions,
|
|
context: any
|
|
): Promise<string> {
|
|
const { local = true, remote = true, exclude = ['main', 'master', 'develop'], dryRun = false } = args
|
|
|
|
const results: string[] = []
|
|
|
|
try {
|
|
// Get current branch
|
|
const { stdout: currentBranch } = await execAsync('git rev-parse --abbrev-ref HEAD')
|
|
|
|
if (local) {
|
|
// Get merged local branches
|
|
const { stdout: mergedBranches } = await execAsync('git branch --merged')
|
|
|
|
const branchesToDelete = mergedBranches
|
|
.split('\n')
|
|
.map((b) => b.trim().replace('*', '').trim())
|
|
.filter(
|
|
(branch) =>
|
|
branch &&
|
|
branch !== currentBranch.trim() &&
|
|
!exclude.includes(branch)
|
|
)
|
|
|
|
if (branchesToDelete.length > 0) {
|
|
if (dryRun) {
|
|
results.push(`Would delete local branches: ${branchesToDelete.join(', ')}`)
|
|
} else {
|
|
for (const branch of branchesToDelete) {
|
|
await execAsync(`git branch -d ${branch}`)
|
|
results.push(`✓ Deleted local branch: ${branch}`)
|
|
}
|
|
}
|
|
} else {
|
|
results.push('No local branches to clean up')
|
|
}
|
|
}
|
|
|
|
if (remote) {
|
|
// Get merged remote branches
|
|
const { stdout: remoteBranches } = await execAsync('git branch -r --merged')
|
|
|
|
const branchesToDelete = remoteBranches
|
|
.split('\n')
|
|
.map((b) => b.trim().replace('origin/', '').trim())
|
|
.filter((branch) => branch && branch !== 'HEAD' && !exclude.includes(branch))
|
|
|
|
if (branchesToDelete.length > 0) {
|
|
if (dryRun) {
|
|
results.push(`Would delete remote branches: ${branchesToDelete.join(', ')}`)
|
|
} else {
|
|
for (const branch of branchesToDelete) {
|
|
await execAsync(`git push origin --delete ${branch}`)
|
|
results.push(`✓ Deleted remote branch: ${branch}`)
|
|
}
|
|
}
|
|
} else {
|
|
results.push('No remote branches to clean up')
|
|
}
|
|
}
|
|
|
|
return results.join('\n')
|
|
} catch (error: any) {
|
|
throw new Error(`Branch cleanup failed: ${error.message}`)
|
|
}
|
|
}
|
|
|
|
export default { handle }
|