cclaw-cli 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/doctor.js +1 -1
- package/dist/install.js +44 -9
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -177,7 +177,7 @@ async function opencodeRegistrationCheck(projectRoot) {
|
|
|
177
177
|
if (!parsed) {
|
|
178
178
|
continue;
|
|
179
179
|
}
|
|
180
|
-
const plugins = Array.isArray(parsed.
|
|
180
|
+
const plugins = Array.isArray(parsed.plugin) ? parsed.plugin : [];
|
|
181
181
|
const registered = plugins.some((entry) => normalizeOpenCodePluginEntry(entry) === expected);
|
|
182
182
|
if (registered) {
|
|
183
183
|
return { ok: true, details: `${path.relative(projectRoot, configPath)} registers ${expected}` };
|
package/dist/install.js
CHANGED
|
@@ -306,16 +306,16 @@ function normalizeOpenCodePluginEntry(entry) {
|
|
|
306
306
|
}
|
|
307
307
|
function mergeOpenCodePluginConfig(existingDoc, pluginRelPath) {
|
|
308
308
|
const root = toObject(existingDoc) ?? {};
|
|
309
|
-
const pluginsRaw = Array.isArray(root.
|
|
309
|
+
const pluginsRaw = Array.isArray(root.plugin) ? [...root.plugin] : [];
|
|
310
310
|
const normalized = new Set(pluginsRaw.map((entry) => normalizeOpenCodePluginEntry(entry)).filter(Boolean));
|
|
311
311
|
if (!normalized.has(pluginRelPath)) {
|
|
312
312
|
pluginsRaw.push(pluginRelPath);
|
|
313
313
|
}
|
|
314
|
-
const changed = !normalized.has(pluginRelPath) || !Array.isArray(root.
|
|
314
|
+
const changed = !normalized.has(pluginRelPath) || !Array.isArray(root.plugin);
|
|
315
315
|
return {
|
|
316
316
|
merged: {
|
|
317
317
|
...root,
|
|
318
|
-
|
|
318
|
+
plugin: pluginsRaw
|
|
319
319
|
},
|
|
320
320
|
changed
|
|
321
321
|
};
|
|
@@ -360,14 +360,23 @@ async function removeManagedOpenCodePluginConfig(projectRoot, pluginRelPath) {
|
|
|
360
360
|
parsed = null;
|
|
361
361
|
}
|
|
362
362
|
const root = toObject(parsed);
|
|
363
|
-
if (!root || !Array.isArray(root.
|
|
363
|
+
if (!root || !Array.isArray(root.plugin))
|
|
364
364
|
continue;
|
|
365
|
-
const filtered = root.
|
|
366
|
-
if (filtered.length === root.
|
|
365
|
+
const filtered = root.plugin.filter((entry) => normalizeOpenCodePluginEntry(entry) !== pluginRelPath);
|
|
366
|
+
if (filtered.length === root.plugin.length) {
|
|
367
367
|
continue;
|
|
368
368
|
}
|
|
369
|
-
root.
|
|
370
|
-
|
|
369
|
+
root.plugin = filtered;
|
|
370
|
+
const remainingKeys = Object.keys(root).filter((k) => k !== "plugin" || filtered.length > 0);
|
|
371
|
+
if (remainingKeys.length === 0 || (remainingKeys.length === 1 && remainingKeys[0] === "plugin" && filtered.length === 0)) {
|
|
372
|
+
await fs.rm(configPath, { force: true });
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
if (filtered.length === 0) {
|
|
376
|
+
delete root.plugin;
|
|
377
|
+
}
|
|
378
|
+
await writeFileSafe(configPath, `${JSON.stringify(root, null, 2)}\n`);
|
|
379
|
+
}
|
|
371
380
|
}
|
|
372
381
|
}
|
|
373
382
|
function backupFileNameForHook(projectRoot, hookFilePath) {
|
|
@@ -880,6 +889,17 @@ async function removeManagedHookEntries(hookFilePath) {
|
|
|
880
889
|
}
|
|
881
890
|
await writeFileSafe(hookFilePath, `${JSON.stringify(root, null, 2)}\n`);
|
|
882
891
|
}
|
|
892
|
+
async function removeIfEmpty(dirPath) {
|
|
893
|
+
try {
|
|
894
|
+
const entries = await fs.readdir(dirPath);
|
|
895
|
+
if (entries.length === 0) {
|
|
896
|
+
await fs.rmdir(dirPath);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
catch {
|
|
900
|
+
// directory not present or not removable
|
|
901
|
+
}
|
|
902
|
+
}
|
|
883
903
|
export async function uninstallCclaw(projectRoot) {
|
|
884
904
|
const fullRuntimePath = path.join(projectRoot, RUNTIME_ROOT);
|
|
885
905
|
try {
|
|
@@ -891,7 +911,6 @@ export async function uninstallCclaw(projectRoot) {
|
|
|
891
911
|
await removeCclawFromAgentsMd(projectRoot);
|
|
892
912
|
await removeGitignorePatterns(projectRoot);
|
|
893
913
|
await removeManagedGitHookRelays(projectRoot);
|
|
894
|
-
// Clean hook files
|
|
895
914
|
const hookFiles = [
|
|
896
915
|
".claude/hooks/hooks.json",
|
|
897
916
|
".cursor/hooks.json",
|
|
@@ -939,4 +958,20 @@ export async function uninstallCclaw(projectRoot) {
|
|
|
939
958
|
catch {
|
|
940
959
|
// best-effort cleanup
|
|
941
960
|
}
|
|
961
|
+
const managedDirs = [
|
|
962
|
+
".claude/hooks",
|
|
963
|
+
".claude/commands",
|
|
964
|
+
".claude",
|
|
965
|
+
".cursor/rules",
|
|
966
|
+
".cursor/commands",
|
|
967
|
+
".cursor",
|
|
968
|
+
".codex/commands",
|
|
969
|
+
".codex",
|
|
970
|
+
".opencode/plugins",
|
|
971
|
+
".opencode/commands",
|
|
972
|
+
".opencode"
|
|
973
|
+
];
|
|
974
|
+
for (const relDir of managedDirs) {
|
|
975
|
+
await removeIfEmpty(path.join(projectRoot, relDir));
|
|
976
|
+
}
|
|
942
977
|
}
|