MCPcopy
hub / github.com/EveryInc/compound-engineering-plugin / run

Function run

src/commands/cleanup.ts:106–142  ·  view source on GitHub ↗
({ args })

Source from the content-addressed store, hash-verified

104 },
105 },
106 async run({ args }) {
107 const pluginPath = await resolveCleanupPluginPath(args.plugin ? String(args.plugin) : "compound-engineering")
108 const plugin = await loadClaudePlugin(pluginPath)
109 if (plugin.manifest.name !== "compound-engineering") {
110 throw new Error("Cleanup currently supports only the compound-engineering plugin.")
111 }
112 const targetNames = resolveCleanupTargets(String(args.target))
113 const outputRoot = resolveWorkspaceRoot(args.output)
114 const hasExplicitOpenCodeHome = hasExplicitValue(args.opencodeHome)
115 const roots = {
116 codexHome: resolveCodexHome(args.codexHome),
117 piHome: resolveTargetHome(args.piHome, path.join(os.homedir(), ".pi", "agent")),
118 // Mirror install: respect OPENCODE_CONFIG_DIR before falling back to the
119 // XDG default so cleanup scans the same directory install wrote to.
120 opencodeHome: resolveTargetHome(args.opencodeHome, resolveOpenCodeGlobalRoot()),
121 kiroHome: resolveTargetHome(args.kiroHome, path.join(outputRoot, ".kiro")),
122 copilotHome: resolveTargetHome(args.copilotHome, path.join(os.homedir(), ".copilot")),
123 droidHome: resolveTargetHome(args.droidHome, path.join(os.homedir(), ".factory")),
124 qwenHome: resolveTargetHome(args.qwenHome, path.join(os.homedir(), ".qwen")),
125 windsurfHome: resolveTargetHome(args.windsurfHome, path.join(os.homedir(), ".codeium", "windsurf")),
126 agentsHome: resolveTargetHome(args.agentsHome, path.join(os.homedir(), ".agents")),
127 workspaceRoot: outputRoot,
128 hasExplicitOutput: hasExplicitValue(args.output),
129 hasExplicitOpenCodeHome,
130 }
131
132 const results: CleanupResult[] = []
133 for (const target of targetNames) {
134 results.push(...await cleanupTarget(target, plugin, roots))
135 }
136
137 const total = results.reduce((sum, result) => sum + result.moved, 0)
138 for (const result of results) {
139 console.log(`Cleaned ${result.target} at ${result.root}: backed up ${result.moved} artifact(s)`)
140 }
141 console.log(`Cleanup complete for ${plugin.manifest.name}: backed up ${total} artifact(s).`)
142 },
143})
144
145async function cleanupTarget(

Callers

nothing calls this directly

Calls 9

loadClaudePluginFunction · 0.90
resolveCodexHomeFunction · 0.90
resolveTargetHomeFunction · 0.90
resolveCleanupPluginPathFunction · 0.85
resolveCleanupTargetsFunction · 0.85
resolveWorkspaceRootFunction · 0.85
hasExplicitValueFunction · 0.85
cleanupTargetFunction · 0.85

Tested by

no test coverage detected