shoplazza-ai-dev-cli 0.1.6-snapshot.5 → 0.1.6
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/cli.mjs +79 -44
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { pD, require_picocolors } from "./_chunks/libs/@clack/core.mjs";
|
|
|
4
4
|
import { Ie, M, Me, Se, Y, be, fe, ve, xe, ye } from "./_chunks/libs/@clack/prompts.mjs";
|
|
5
5
|
import { esm_default } from "./_chunks/libs/simple-git.mjs";
|
|
6
6
|
import { require_lib } from "./_chunks/libs/jszip.mjs";
|
|
7
|
-
import { exec, execSync, spawnSync } from "child_process";
|
|
7
|
+
import { exec, execFileSync, execSync, spawnSync } from "child_process";
|
|
8
8
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "fs";
|
|
9
9
|
import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
|
|
10
10
|
import { URL as URL$1, fileURLToPath } from "url";
|
|
@@ -2111,11 +2111,20 @@ async function copyDirRecursive$1(src, dest, opts) {
|
|
|
2111
2111
|
if (!entry.isDirectory() && skipFilesSet.has(entry.name)) continue;
|
|
2112
2112
|
const s = join(src, entry.name);
|
|
2113
2113
|
const d = join(dest, entry.name);
|
|
2114
|
-
|
|
2114
|
+
let isDir = entry.isDirectory();
|
|
2115
|
+
let isFile = entry.isFile();
|
|
2116
|
+
if (entry.isSymbolicLink()) try {
|
|
2117
|
+
const target = await stat(s);
|
|
2118
|
+
isDir = target.isDirectory();
|
|
2119
|
+
isFile = target.isFile();
|
|
2120
|
+
} catch {
|
|
2121
|
+
continue;
|
|
2122
|
+
}
|
|
2123
|
+
if (isDir) await copyDirRecursive$1(s, d, {
|
|
2115
2124
|
skip: opts?.skip,
|
|
2116
2125
|
skipFiles: opts?.skipFiles
|
|
2117
2126
|
});
|
|
2118
|
-
else if (
|
|
2127
|
+
else if (isFile) {
|
|
2119
2128
|
await writeFile(d, await readFile(s));
|
|
2120
2129
|
const srcStat = await stat(s);
|
|
2121
2130
|
if (srcStat.mode & 73) await chmod(d, srcStat.mode & 511);
|
|
@@ -2229,6 +2238,8 @@ async function upsertMarketplaceEntry(home, pluginName) {
|
|
|
2229
2238
|
await writeJson(mJsonPath, manifest);
|
|
2230
2239
|
}
|
|
2231
2240
|
async function registerClaudePlugin(params) {
|
|
2241
|
+
if (params.scope === "project" && !params.cwd) throw new Error("registerClaudePlugin: 'cwd' is required when scope is 'project'");
|
|
2242
|
+
const cwd = params.cwd ? resolve(params.cwd) : void 0;
|
|
2232
2243
|
const home = getAgentHome("claude-code");
|
|
2233
2244
|
await ensureMarketplace(home);
|
|
2234
2245
|
const version = params.version ?? "0.0.0";
|
|
@@ -2263,23 +2274,29 @@ async function registerClaudePlugin(params) {
|
|
|
2263
2274
|
});
|
|
2264
2275
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2265
2276
|
const entry = {
|
|
2266
|
-
scope: "user",
|
|
2277
|
+
scope: params.scope ?? "user",
|
|
2267
2278
|
installPath,
|
|
2268
2279
|
version,
|
|
2269
2280
|
installedAt: now,
|
|
2270
2281
|
lastUpdated: now
|
|
2271
2282
|
};
|
|
2272
2283
|
if (params.gitSha) entry.gitCommitSha = params.gitSha;
|
|
2284
|
+
if (params.scope === "project" && cwd) entry.projectPath = cwd;
|
|
2285
|
+
const warnings = [];
|
|
2286
|
+
const previous = installed.plugins[pluginKey$1(params.pluginName)]?.[0];
|
|
2287
|
+
if (previous?.projectPath && previous.projectPath !== entry.projectPath) warnings.push(`overwriting previous project-scope registration for ${previous.projectPath}; its .claude/settings.json may keep a stale enabledPlugins entry`);
|
|
2273
2288
|
installed.plugins[pluginKey$1(params.pluginName)] = [entry];
|
|
2274
2289
|
await writeJson(installedPath, installed);
|
|
2275
|
-
const settingsPath = join(home, "settings.json");
|
|
2290
|
+
const settingsPath = params.scope === "project" && cwd ? join(cwd, ".claude", "settings.json") : join(home, "settings.json");
|
|
2276
2291
|
const settings = await readJson(settingsPath, {});
|
|
2277
2292
|
if (!settings.enabledPlugins) settings.enabledPlugins = {};
|
|
2278
2293
|
settings.enabledPlugins[pluginKey$1(params.pluginName)] = true;
|
|
2279
2294
|
await writeJson(settingsPath, settings);
|
|
2295
|
+
return warnings;
|
|
2280
2296
|
}
|
|
2281
|
-
async function unregisterClaudePlugin(pluginName,
|
|
2297
|
+
async function unregisterClaudePlugin(pluginName, opts) {
|
|
2282
2298
|
const home = getAgentHome("claude-code");
|
|
2299
|
+
let projectPath;
|
|
2283
2300
|
try {
|
|
2284
2301
|
const installedPath = join(home, "plugins", "installed_plugins.json");
|
|
2285
2302
|
const installed = await readJson(installedPath, {
|
|
@@ -2287,7 +2304,8 @@ async function unregisterClaudePlugin(pluginName, installPath) {
|
|
|
2287
2304
|
plugins: {}
|
|
2288
2305
|
});
|
|
2289
2306
|
const entry = installed.plugins[pluginKey$1(pluginName)]?.[0];
|
|
2290
|
-
const cachePath = installPath ?? entry?.installPath;
|
|
2307
|
+
const cachePath = opts?.installPath ?? entry?.installPath;
|
|
2308
|
+
if (entry?.scope === "project") projectPath = entry.projectPath;
|
|
2291
2309
|
delete installed.plugins[pluginKey$1(pluginName)];
|
|
2292
2310
|
await writeJson(installedPath, installed);
|
|
2293
2311
|
if (cachePath && existsSync(cachePath)) await rm(cachePath, {
|
|
@@ -2303,6 +2321,17 @@ async function unregisterClaudePlugin(pluginName, installPath) {
|
|
|
2303
2321
|
await writeJson(settingsPath, settings);
|
|
2304
2322
|
}
|
|
2305
2323
|
} catch {}
|
|
2324
|
+
const projectDirs = /* @__PURE__ */ new Set();
|
|
2325
|
+
if (projectPath) projectDirs.add(projectPath);
|
|
2326
|
+
if (opts?.cwd) projectDirs.add(resolve(opts.cwd));
|
|
2327
|
+
for (const dir of projectDirs) try {
|
|
2328
|
+
const projSettingsPath = join(dir, ".claude", "settings.json");
|
|
2329
|
+
const settings = await readJson(projSettingsPath, {});
|
|
2330
|
+
if (settings.enabledPlugins) {
|
|
2331
|
+
delete settings.enabledPlugins[pluginKey$1(pluginName)];
|
|
2332
|
+
await writeJson(projSettingsPath, settings);
|
|
2333
|
+
}
|
|
2334
|
+
} catch {}
|
|
2306
2335
|
}
|
|
2307
2336
|
const LOCAL_MARKETPLACE = "ai-dev-hub-local";
|
|
2308
2337
|
function localPluginsRoot$1(codexHome) {
|
|
@@ -2402,26 +2431,17 @@ function clearCursorSkillCache() {
|
|
|
2402
2431
|
const db = cursorStateDbPath();
|
|
2403
2432
|
if (!db) return;
|
|
2404
2433
|
try {
|
|
2405
|
-
|
|
2434
|
+
execFileSync("sqlite3", [db, "DELETE FROM ItemTable WHERE key LIKE 'agentData.cacheStorage.agentEnvironment.slashMenuItems%';"], { stdio: "pipe" });
|
|
2406
2435
|
} catch {}
|
|
2407
2436
|
}
|
|
2408
2437
|
async function registerCursorPlugin(params) {
|
|
2409
2438
|
const dest = join(localPluginsRoot(getAgentHome("cursor")), params.pluginName);
|
|
2410
|
-
const claudeInstalledPath = join(getAgentHome("claude-code"), "plugins", "installed_plugins.json");
|
|
2411
|
-
let claudeHasPlugin = false;
|
|
2412
|
-
try {
|
|
2413
|
-
claudeHasPlugin = (JSON.parse(await readFile(claudeInstalledPath, "utf-8"))?.plugins?.[`${params.pluginName}@ai-dev-hub`]?.length ?? 0) > 0;
|
|
2414
|
-
} catch {}
|
|
2415
2439
|
await rm(dest, {
|
|
2416
2440
|
recursive: true,
|
|
2417
2441
|
force: true
|
|
2418
2442
|
});
|
|
2419
2443
|
await copyDirRecursive$1(params.installPath, dest, {
|
|
2420
|
-
skip: [
|
|
2421
|
-
".claude-plugin",
|
|
2422
|
-
".codex-plugin",
|
|
2423
|
-
...claudeHasPlugin ? ["skills"] : []
|
|
2424
|
-
],
|
|
2444
|
+
skip: [".claude-plugin", ".codex-plugin"],
|
|
2425
2445
|
skipFiles: ["hooks-claude.json", "hooks-codex.json"]
|
|
2426
2446
|
});
|
|
2427
2447
|
clearCursorSkillCache();
|
|
@@ -2499,21 +2519,22 @@ async function installFromExtracted(ref, extractedDir, opts, commitSha) {
|
|
|
2499
2519
|
force: opts.force
|
|
2500
2520
|
})) throw new Error(`aborted: ${foreignConflicts.length} foreign conflicts at plugin entry paths`);
|
|
2501
2521
|
}
|
|
2522
|
+
const { ledger, warnings } = await commitPluginInstall({
|
|
2523
|
+
ref,
|
|
2524
|
+
scopeNamespace,
|
|
2525
|
+
pluginName,
|
|
2526
|
+
pluginCanonical,
|
|
2527
|
+
extractedDir,
|
|
2528
|
+
components,
|
|
2529
|
+
preflight,
|
|
2530
|
+
statuses,
|
|
2531
|
+
opts,
|
|
2532
|
+
commitSha
|
|
2533
|
+
});
|
|
2502
2534
|
return {
|
|
2503
2535
|
pluginRef: ref,
|
|
2504
2536
|
pluginCanonical,
|
|
2505
|
-
installedComponents:
|
|
2506
|
-
ref,
|
|
2507
|
-
scopeNamespace,
|
|
2508
|
-
pluginName,
|
|
2509
|
-
pluginCanonical,
|
|
2510
|
-
extractedDir,
|
|
2511
|
-
components,
|
|
2512
|
-
preflight,
|
|
2513
|
-
statuses,
|
|
2514
|
-
opts,
|
|
2515
|
-
commitSha
|
|
2516
|
-
}),
|
|
2537
|
+
installedComponents: ledger,
|
|
2517
2538
|
installedEntries: preflight.map((pe) => ({
|
|
2518
2539
|
agent: pe.agent,
|
|
2519
2540
|
kind: componentLedgerKind(pe.component.kind),
|
|
@@ -2521,7 +2542,8 @@ async function installFromExtracted(ref, extractedDir, opts, commitSha) {
|
|
|
2521
2542
|
entryPath: pe.entryPath
|
|
2522
2543
|
})),
|
|
2523
2544
|
forgeOtherReplacements,
|
|
2524
|
-
ignoredComponents
|
|
2545
|
+
ignoredComponents,
|
|
2546
|
+
warnings
|
|
2525
2547
|
};
|
|
2526
2548
|
}
|
|
2527
2549
|
function componentLedgerKind(kind) {
|
|
@@ -2681,7 +2703,7 @@ async function commitPluginInstall(params) {
|
|
|
2681
2703
|
force: true
|
|
2682
2704
|
});
|
|
2683
2705
|
await mkdir(pluginCanonical, { recursive: true });
|
|
2684
|
-
await copyDirRecursive(extractedDir, pluginCanonical,
|
|
2706
|
+
await copyDirRecursive(extractedDir, pluginCanonical, false);
|
|
2685
2707
|
for (const skillName of components.skills) {
|
|
2686
2708
|
const sidecarPath = join(pluginCanonical, "skills", skillName, ".forge-source.json");
|
|
2687
2709
|
await mkdir(dirname(sidecarPath), { recursive: true });
|
|
@@ -2760,27 +2782,37 @@ async function commitPluginInstall(params) {
|
|
|
2760
2782
|
});
|
|
2761
2783
|
if (components.skills.length > 0) for (const agent of opts.agents) await ensureForgeHooks(agent);
|
|
2762
2784
|
let version = "0.0.0";
|
|
2763
|
-
try {
|
|
2764
|
-
|
|
2785
|
+
for (const manifestPath of [join(pluginCanonical, "plugin.json"), join(pluginCanonical, ".claude-plugin", "plugin.json")]) try {
|
|
2786
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
|
|
2787
|
+
if (manifest.version) {
|
|
2788
|
+
version = manifest.version;
|
|
2789
|
+
break;
|
|
2790
|
+
}
|
|
2765
2791
|
} catch {}
|
|
2766
|
-
const
|
|
2792
|
+
const warnings = [];
|
|
2793
|
+
const warn = (msg) => warnings.push(msg);
|
|
2767
2794
|
if (opts.agents.includes("claude-code") || opts.agents.includes("cursor")) await registerClaudePlugin({
|
|
2768
2795
|
pluginName,
|
|
2769
2796
|
version,
|
|
2770
2797
|
sourcePath: pluginCanonical,
|
|
2771
|
-
gitSha: commitSha
|
|
2772
|
-
|
|
2798
|
+
gitSha: commitSha,
|
|
2799
|
+
scope: opts.scope === "project" ? "project" : "user",
|
|
2800
|
+
cwd: opts.cwd
|
|
2801
|
+
}).then((ws) => ws.forEach(warn)).catch((e) => warn(`claude-code plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
2773
2802
|
if (opts.agents.includes("codex")) await registerCodexPlugin({
|
|
2774
2803
|
pluginName,
|
|
2775
2804
|
installPath: pluginCanonical,
|
|
2776
2805
|
version
|
|
2777
2806
|
}).catch((e) => warn(`codex plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
2778
|
-
if (opts.agents.includes("cursor")
|
|
2807
|
+
if (opts.agents.includes("cursor")) await registerCursorPlugin({
|
|
2779
2808
|
pluginName,
|
|
2780
2809
|
installPath: pluginCanonical
|
|
2781
2810
|
}).catch((e) => warn(`cursor plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
2782
2811
|
await ensureForgeCliWrapper().catch((e) => warn(`forge-cli.sh wrapper generation failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
2783
|
-
return
|
|
2812
|
+
return {
|
|
2813
|
+
ledger,
|
|
2814
|
+
warnings
|
|
2815
|
+
};
|
|
2784
2816
|
}
|
|
2785
2817
|
async function copyDirRecursive(src, dest, skipDotClaudePlugin, extraSkip) {
|
|
2786
2818
|
await mkdir(dest, { recursive: true });
|
|
@@ -4381,6 +4413,7 @@ async function runAdd(args, options = {}) {
|
|
|
4381
4413
|
throw err;
|
|
4382
4414
|
}
|
|
4383
4415
|
spinner.stop(import_picocolors.default.green("Plugin installed"));
|
|
4416
|
+
if (pluginResult.warnings.length > 0) for (const w of pluginResult.warnings) M.warn(w);
|
|
4384
4417
|
if (pluginResult.installedEntries.length > 0) {
|
|
4385
4418
|
const grouped = /* @__PURE__ */ new Map();
|
|
4386
4419
|
for (const e of pluginResult.installedEntries) {
|
|
@@ -4444,6 +4477,7 @@ async function runAdd(args, options = {}) {
|
|
|
4444
4477
|
agent: "cli",
|
|
4445
4478
|
install_mode: "cli"
|
|
4446
4479
|
});
|
|
4480
|
+
M.info(import_picocolors.default.dim("Restart Claude Code / Cursor to activate plugin changes."));
|
|
4447
4481
|
Se(import_picocolors.default.green(`Plugin ${import_picocolors.default.bold(resolvedPluginRef)} installed successfully`));
|
|
4448
4482
|
return;
|
|
4449
4483
|
}
|
|
@@ -5208,8 +5242,8 @@ async function runReportEvent(args) {
|
|
|
5208
5242
|
const body = {
|
|
5209
5243
|
event_type: "hook_event",
|
|
5210
5244
|
metadata: {
|
|
5211
|
-
|
|
5212
|
-
|
|
5245
|
+
...opts.data,
|
|
5246
|
+
hook_type: opts.type
|
|
5213
5247
|
}
|
|
5214
5248
|
};
|
|
5215
5249
|
if (opts.ref) body.asset_ref = opts.ref;
|
|
@@ -6326,9 +6360,10 @@ async function uninstallPlugin(plugin, cwd, agentFilter) {
|
|
|
6326
6360
|
}
|
|
6327
6361
|
}
|
|
6328
6362
|
if (installModes.includes("codex")) for (const scope of ["project", "global"]) await cleanupCodexConfigToml(ledger, scope, cwd);
|
|
6329
|
-
|
|
6330
|
-
if (installModes.includes("cursor")) await
|
|
6331
|
-
if (installModes.includes("
|
|
6363
|
+
const warnUnregister = (agent) => (e) => M.warn(`${agent} plugin unregistration failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
6364
|
+
if (installModes.includes("claude-code") || installModes.includes("cursor")) await unregisterClaudePlugin(plugin.name, { cwd }).catch(warnUnregister("claude-code"));
|
|
6365
|
+
if (installModes.includes("cursor")) await unregisterCursorPlugin(plugin.name).catch(warnUnregister("cursor"));
|
|
6366
|
+
if (installModes.includes("codex")) await unregisterCodexPlugin(plugin.name).catch(warnUnregister("codex"));
|
|
6332
6367
|
await rm(plugin.canonical, {
|
|
6333
6368
|
recursive: true,
|
|
6334
6369
|
force: true
|