shoplazza-ai-dev-cli 0.1.4 → 0.1.6-snapshot.5

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 CHANGED
@@ -1,15 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { r as __toESM } from "./_chunks/rolldown-runtime.mjs";
3
- import { l as pD, u as require_picocolors } from "./_chunks/libs/@clack/core.mjs";
4
- import { a as Y, c as ve, i as Se, l as xe, n as M, o as be, r as Me, s as fe, t as Ie, u as ye } from "./_chunks/libs/@clack/prompts.mjs";
5
- import "./_chunks/libs/@kwsites/file-exists.mjs";
6
- import "./_chunks/libs/@kwsites/promise-deferred.mjs";
7
- import { t as esm_default } from "./_chunks/libs/simple-git.mjs";
8
- import { t as require_lib } from "./_chunks/libs/jszip.mjs";
9
- import "./_chunks/libs/isarray.mjs";
10
- import "./_chunks/libs/core-util-is.mjs";
11
- import "./_chunks/libs/inherits.mjs";
12
- import "./_chunks/libs/immediate.mjs";
2
+ import { __toESM } from "./_chunks/rolldown-runtime.mjs";
3
+ import { pD, require_picocolors } from "./_chunks/libs/@clack/core.mjs";
4
+ import { Ie, M, Me, Se, Y, be, fe, ve, xe, ye } from "./_chunks/libs/@clack/prompts.mjs";
5
+ import { esm_default } from "./_chunks/libs/simple-git.mjs";
6
+ import { require_lib } from "./_chunks/libs/jszip.mjs";
13
7
  import { exec, execSync, spawnSync } from "child_process";
14
8
  import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "fs";
15
9
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "path";
@@ -641,7 +635,7 @@ process.stdin.on('end', () => {
641
635
  }
642
636
  function isForgeOwnedCommand(command) {
643
637
  if (typeof command !== "string") return false;
644
- return command.includes(CURSOR_HOOK_SCRIPT_BASENAME) || command.includes(LEGACY_CURSOR_HOOK_BASENAME);
638
+ return command.includes("track-skill-cursor.mjs") || command.includes(LEGACY_CURSOR_HOOK_BASENAME);
645
639
  }
646
640
  function isFlatEntry(e) {
647
641
  return !!e && typeof e === "object" && typeof e.command === "string";
@@ -905,10 +899,23 @@ process.stdin.on('end', () => {
905
899
  });
906
900
  `;
907
901
  }
902
+ async function ensureForgeCliWrapper() {
903
+ const nodePath = process.execPath;
904
+ const cliScript = process.argv[1];
905
+ if (!cliScript || cliScript.includes("vitest") || cliScript.includes("jest")) return;
906
+ const wrapperPath = join(homedir(), ".ai-dev-cli", "bin", "forge-cli.sh");
907
+ let content;
908
+ if (cliScript.endsWith(".mjs") || cliScript.endsWith(".js")) content = `#!/bin/bash\nexec ${shellEscape(nodePath)} ${shellEscape(cliScript)} "$@"\n`;
909
+ else {
910
+ const tsxLoader = join(dirname(cliScript), "..", "node_modules", "tsx", "dist", "loader.mjs");
911
+ content = `#!/bin/bash\nexec ${shellEscape(nodePath)} --import ${shellEscape(tsxLoader)} ${shellEscape(cliScript)} "$@"\n`;
912
+ }
913
+ await writeScriptIfChanged(wrapperPath, content);
914
+ }
908
915
  async function ensureForgeHooks(agent) {
909
916
  const warnings = [];
910
917
  try {
911
- const portal = loadConfig().portal || DEFAULT_PORTAL;
918
+ const portal = loadConfig().portal || "https://forge.shoplazza.site";
912
919
  const home = getAgentHome(agent);
913
920
  if (agent === "claude-code") {
914
921
  const scriptPath = join(home, HOOK_DIRNAME, HOOK_SCRIPT_BASENAME);
@@ -1315,7 +1322,10 @@ async function fetchPluginArchive(ref, portalUrl, bearerToken) {
1315
1322
  const body = await resp.text().catch(() => "");
1316
1323
  throw new Error(`Portal returned ${resp.status} ${resp.statusText}${body ? `: ${body}` : ""}`);
1317
1324
  }
1318
- return Buffer.from(await resp.arrayBuffer());
1325
+ return {
1326
+ buffer: Buffer.from(await resp.arrayBuffer()),
1327
+ commitSha: resp.headers.get("x-forge-commit-sha") ?? null
1328
+ };
1319
1329
  }
1320
1330
  function extractTarGz(gz, dest) {
1321
1331
  const tar = gunzipSync(gz);
@@ -2092,13 +2102,347 @@ async function installBlobSkillForAgent(skill, agentType, options = {}) {
2092
2102
  };
2093
2103
  }
2094
2104
  }
2105
+ async function copyDirRecursive$1(src, dest, opts) {
2106
+ const skipSet = new Set([".git", ...opts?.skip ?? []]);
2107
+ const skipFilesSet = new Set(opts?.skipFiles ?? []);
2108
+ await mkdir(dest, { recursive: true });
2109
+ for (const entry of await readdir(src, { withFileTypes: true })) {
2110
+ if (skipSet.has(entry.name)) continue;
2111
+ if (!entry.isDirectory() && skipFilesSet.has(entry.name)) continue;
2112
+ const s = join(src, entry.name);
2113
+ const d = join(dest, entry.name);
2114
+ if (entry.isDirectory()) await copyDirRecursive$1(s, d, {
2115
+ skip: opts?.skip,
2116
+ skipFiles: opts?.skipFiles
2117
+ });
2118
+ else if (entry.isFile()) {
2119
+ await writeFile(d, await readFile(s));
2120
+ const srcStat = await stat(s);
2121
+ if (srcStat.mode & 73) await chmod(d, srcStat.mode & 511);
2122
+ }
2123
+ }
2124
+ }
2125
+ const MARKETPLACE = "ai-dev-hub";
2126
+ function pluginKey$1(pluginName) {
2127
+ return `${pluginName}@${MARKETPLACE}`;
2128
+ }
2129
+ function marketplaceDir(home) {
2130
+ return join(home, "plugins", "marketplaces", MARKETPLACE);
2131
+ }
2132
+ function pluginCacheBase(home, pluginName) {
2133
+ return join(home, "plugins", "cache", MARKETPLACE, pluginName);
2134
+ }
2135
+ async function readJson(path, fallback) {
2136
+ try {
2137
+ return JSON.parse(await readFile(path, "utf-8"));
2138
+ } catch {
2139
+ return fallback;
2140
+ }
2141
+ }
2142
+ async function writeJson(path, data) {
2143
+ await mkdir(dirname(path), { recursive: true });
2144
+ await writeFile(path, JSON.stringify(data, null, 2) + "\n", "utf-8");
2145
+ }
2146
+ function ensureGitRepo(dir) {
2147
+ const env = {
2148
+ ...process.env,
2149
+ GIT_AUTHOR_NAME: "forge",
2150
+ GIT_AUTHOR_EMAIL: "forge@shoplazza.com",
2151
+ GIT_COMMITTER_NAME: "forge",
2152
+ GIT_COMMITTER_EMAIL: "forge@shoplazza.com"
2153
+ };
2154
+ try {
2155
+ execSync("git rev-parse HEAD", {
2156
+ cwd: dir,
2157
+ stdio: "pipe"
2158
+ });
2159
+ } catch {
2160
+ execSync("git init -q && git add . && git commit -q -m \"init\"", {
2161
+ cwd: dir,
2162
+ env,
2163
+ shell: "/bin/bash",
2164
+ stdio: "pipe"
2165
+ });
2166
+ }
2167
+ }
2168
+ function commitMarketplaceChanges(dir) {
2169
+ const env = {
2170
+ ...process.env,
2171
+ GIT_AUTHOR_NAME: "forge",
2172
+ GIT_AUTHOR_EMAIL: "forge@shoplazza.com",
2173
+ GIT_COMMITTER_NAME: "forge",
2174
+ GIT_COMMITTER_EMAIL: "forge@shoplazza.com"
2175
+ };
2176
+ try {
2177
+ execSync("git add . && git diff --cached --quiet || git commit -q -m \"update\"", {
2178
+ cwd: dir,
2179
+ env,
2180
+ shell: "/bin/bash",
2181
+ stdio: "pipe"
2182
+ });
2183
+ } catch {}
2184
+ }
2185
+ async function ensureMarketplace(home) {
2186
+ const mDir = marketplaceDir(home);
2187
+ const mJsonPath = join(mDir, ".claude-plugin", "marketplace.json");
2188
+ if (!existsSync(mJsonPath)) {
2189
+ await mkdir(dirname(mJsonPath), { recursive: true });
2190
+ await writeJson(mJsonPath, {
2191
+ name: MARKETPLACE,
2192
+ owner: { name: "Shoplazza" },
2193
+ plugins: []
2194
+ });
2195
+ await ensureGitRepo(mDir);
2196
+ }
2197
+ const source = {
2198
+ source: "git",
2199
+ url: `file://${mDir}`
2200
+ };
2201
+ const settingsPath = join(home, "settings.json");
2202
+ const settings = await readJson(settingsPath, {});
2203
+ if (!settings.extraKnownMarketplaces) settings.extraKnownMarketplaces = {};
2204
+ settings.extraKnownMarketplaces[MARKETPLACE] = { source };
2205
+ await writeJson(settingsPath, settings);
2206
+ const kmPath = join(home, "plugins", "known_marketplaces.json");
2207
+ const km = await readJson(kmPath, {});
2208
+ km[MARKETPLACE] = {
2209
+ source,
2210
+ installLocation: mDir,
2211
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
2212
+ };
2213
+ await writeJson(kmPath, km);
2214
+ }
2215
+ async function upsertMarketplaceEntry(home, pluginName) {
2216
+ const mJsonPath = join(marketplaceDir(home), ".claude-plugin", "marketplace.json");
2217
+ const manifest = await readJson(mJsonPath, {
2218
+ name: MARKETPLACE,
2219
+ owner: { name: "Shoplazza" },
2220
+ plugins: []
2221
+ });
2222
+ const entry = {
2223
+ name: pluginName,
2224
+ source: `./plugins/${pluginName}`
2225
+ };
2226
+ const idx = manifest.plugins.findIndex((p) => p.name === pluginName);
2227
+ if (idx >= 0) manifest.plugins[idx] = entry;
2228
+ else manifest.plugins.push(entry);
2229
+ await writeJson(mJsonPath, manifest);
2230
+ }
2231
+ async function registerClaudePlugin(params) {
2232
+ const home = getAgentHome("claude-code");
2233
+ await ensureMarketplace(home);
2234
+ const version = params.version ?? "0.0.0";
2235
+ const installPath = join(pluginCacheBase(home, params.pluginName), version);
2236
+ await rm(installPath, {
2237
+ recursive: true,
2238
+ force: true
2239
+ });
2240
+ await copyDirRecursive$1(params.sourcePath, installPath, {
2241
+ skip: [".cursor-plugin", ".codex-plugin"],
2242
+ skipFiles: ["hooks-cursor.json", "hooks-codex.json"]
2243
+ });
2244
+ const mPluginDir = join(marketplaceDir(home), "plugins", params.pluginName, ".claude-plugin");
2245
+ await mkdir(mPluginDir, { recursive: true });
2246
+ const srcManifest = join(params.sourcePath, ".claude-plugin", "plugin.json");
2247
+ if (existsSync(srcManifest)) {
2248
+ const full = JSON.parse(await readFile(srcManifest, "utf-8"));
2249
+ const minimal = {
2250
+ name: full["name"],
2251
+ description: full["description"]
2252
+ };
2253
+ if (version !== "0.0.0") minimal["version"] = version;
2254
+ if (full["author"]) minimal["author"] = full["author"];
2255
+ await writeFile(join(mPluginDir, "plugin.json"), JSON.stringify(minimal, null, 2) + "\n", "utf-8");
2256
+ }
2257
+ await upsertMarketplaceEntry(home, params.pluginName);
2258
+ commitMarketplaceChanges(marketplaceDir(home));
2259
+ const installedPath = join(home, "plugins", "installed_plugins.json");
2260
+ const installed = await readJson(installedPath, {
2261
+ version: 2,
2262
+ plugins: {}
2263
+ });
2264
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2265
+ const entry = {
2266
+ scope: "user",
2267
+ installPath,
2268
+ version,
2269
+ installedAt: now,
2270
+ lastUpdated: now
2271
+ };
2272
+ if (params.gitSha) entry.gitCommitSha = params.gitSha;
2273
+ installed.plugins[pluginKey$1(params.pluginName)] = [entry];
2274
+ await writeJson(installedPath, installed);
2275
+ const settingsPath = join(home, "settings.json");
2276
+ const settings = await readJson(settingsPath, {});
2277
+ if (!settings.enabledPlugins) settings.enabledPlugins = {};
2278
+ settings.enabledPlugins[pluginKey$1(params.pluginName)] = true;
2279
+ await writeJson(settingsPath, settings);
2280
+ }
2281
+ async function unregisterClaudePlugin(pluginName, installPath) {
2282
+ const home = getAgentHome("claude-code");
2283
+ try {
2284
+ const installedPath = join(home, "plugins", "installed_plugins.json");
2285
+ const installed = await readJson(installedPath, {
2286
+ version: 2,
2287
+ plugins: {}
2288
+ });
2289
+ const entry = installed.plugins[pluginKey$1(pluginName)]?.[0];
2290
+ const cachePath = installPath ?? entry?.installPath;
2291
+ delete installed.plugins[pluginKey$1(pluginName)];
2292
+ await writeJson(installedPath, installed);
2293
+ if (cachePath && existsSync(cachePath)) await rm(cachePath, {
2294
+ recursive: true,
2295
+ force: true
2296
+ });
2297
+ } catch {}
2298
+ try {
2299
+ const settingsPath = join(home, "settings.json");
2300
+ const settings = await readJson(settingsPath, {});
2301
+ if (settings.enabledPlugins) {
2302
+ delete settings.enabledPlugins[pluginKey$1(pluginName)];
2303
+ await writeJson(settingsPath, settings);
2304
+ }
2305
+ } catch {}
2306
+ }
2307
+ const LOCAL_MARKETPLACE = "ai-dev-hub-local";
2308
+ function localPluginsRoot$1(codexHome) {
2309
+ return join(codexHome, "plugin-marketplaces", "local", "plugins");
2310
+ }
2311
+ function pluginKey(pluginName) {
2312
+ return `${pluginName}@${LOCAL_MARKETPLACE}`;
2313
+ }
2314
+ async function registerCodexPlugin(params) {
2315
+ const home = getAgentHome("codex");
2316
+ const version = params.version ?? "1.0.0";
2317
+ const copyOpts = {
2318
+ skip: [".claude-plugin", ".cursor-plugin"],
2319
+ skipFiles: ["hooks-claude.json", "hooks-cursor.json"]
2320
+ };
2321
+ const dest = join(localPluginsRoot$1(home), params.pluginName);
2322
+ await rm(dest, {
2323
+ recursive: true,
2324
+ force: true
2325
+ });
2326
+ await copyDirRecursive$1(params.installPath, dest, copyOpts);
2327
+ const cacheDest = join(home, "plugins", "cache", LOCAL_MARKETPLACE, params.pluginName, version);
2328
+ await rm(cacheDest, {
2329
+ recursive: true,
2330
+ force: true
2331
+ });
2332
+ await copyDirRecursive$1(params.installPath, cacheDest, copyOpts);
2333
+ const configPath = join(home, "config.toml");
2334
+ let toml = "";
2335
+ try {
2336
+ toml = await readFile(configPath, "utf-8");
2337
+ } catch {}
2338
+ const marketplaceSource = join(home, "plugin-marketplaces", "local");
2339
+ const marketplaceBlock = `[marketplaces.${LOCAL_MARKETPLACE}]\nsource_type = "local"\nsource = ${JSON.stringify(marketplaceSource)}\n`;
2340
+ toml = upsertSection(toml, `[marketplaces.${LOCAL_MARKETPLACE}]`, marketplaceBlock);
2341
+ const key = pluginKey(params.pluginName);
2342
+ const pluginBlock = `[plugins.${JSON.stringify(key)}]\nenabled = true\n`;
2343
+ toml = upsertSection(toml, `[plugins."${key}"]`, pluginBlock);
2344
+ await mkdir(dirname(configPath), { recursive: true });
2345
+ await writeFile(configPath, toml, "utf-8");
2346
+ await upsertCodexMarketplaceIndex(home, params.pluginName);
2347
+ }
2348
+ async function upsertCodexMarketplaceIndex(codexHome, pluginName) {
2349
+ const indexPath = join(codexHome, "plugin-marketplaces", "local", ".agents", "plugins", "marketplace.json");
2350
+ let manifest;
2351
+ try {
2352
+ manifest = JSON.parse(await readFile(indexPath, "utf-8"));
2353
+ } catch {
2354
+ manifest = {
2355
+ name: LOCAL_MARKETPLACE,
2356
+ plugins: []
2357
+ };
2358
+ }
2359
+ if (!manifest.plugins.some((p) => p.name === pluginName)) {
2360
+ manifest.plugins.push({
2361
+ name: pluginName,
2362
+ source: {
2363
+ source: "local",
2364
+ path: `./plugins/${pluginName}`
2365
+ },
2366
+ policy: {
2367
+ installation: "AVAILABLE",
2368
+ authentication: "ON_INSTALL"
2369
+ },
2370
+ category: "Developer Tools"
2371
+ });
2372
+ await mkdir(dirname(indexPath), { recursive: true });
2373
+ await writeFile(indexPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
2374
+ }
2375
+ }
2376
+ async function unregisterCodexPlugin(pluginName) {
2377
+ const home = getAgentHome("codex");
2378
+ const dest = join(localPluginsRoot$1(home), pluginName);
2379
+ await Promise.allSettled([rm(dest, {
2380
+ recursive: true,
2381
+ force: true
2382
+ }), rm(join(home, "plugins", "cache", LOCAL_MARKETPLACE, pluginName), {
2383
+ recursive: true,
2384
+ force: true
2385
+ })]);
2386
+ const configPath = join(home, "config.toml");
2387
+ try {
2388
+ let toml = await readFile(configPath, "utf-8");
2389
+ const key = pluginKey(pluginName);
2390
+ toml = removeSection(toml, `[plugins."${key}"]`);
2391
+ await writeFile(configPath, toml, "utf-8");
2392
+ } catch {}
2393
+ }
2394
+ function localPluginsRoot(cursorHome) {
2395
+ return join(cursorHome, "plugins", "local");
2396
+ }
2397
+ function cursorStateDbPath() {
2398
+ const base = platform() === "darwin" ? join(homedir(), "Library", "Application Support", "Cursor", "User", "globalStorage", "state.vscdb") : join(homedir(), ".config", "Cursor", "User", "globalStorage", "state.vscdb");
2399
+ return existsSync(base) ? base : null;
2400
+ }
2401
+ function clearCursorSkillCache() {
2402
+ const db = cursorStateDbPath();
2403
+ if (!db) return;
2404
+ try {
2405
+ execSync(`sqlite3 ${JSON.stringify(db)} "DELETE FROM ItemTable WHERE key LIKE 'agentData.cacheStorage.agentEnvironment.slashMenuItems%';"`, { stdio: "pipe" });
2406
+ } catch {}
2407
+ }
2408
+ async function registerCursorPlugin(params) {
2409
+ 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
+ await rm(dest, {
2416
+ recursive: true,
2417
+ force: true
2418
+ });
2419
+ await copyDirRecursive$1(params.installPath, dest, {
2420
+ skip: [
2421
+ ".claude-plugin",
2422
+ ".codex-plugin",
2423
+ ...claudeHasPlugin ? ["skills"] : []
2424
+ ],
2425
+ skipFiles: ["hooks-claude.json", "hooks-codex.json"]
2426
+ });
2427
+ clearCursorSkillCache();
2428
+ }
2429
+ async function unregisterCursorPlugin(pluginName) {
2430
+ const dest = join(localPluginsRoot(getAgentHome("cursor")), pluginName);
2431
+ try {
2432
+ await rm(dest, {
2433
+ recursive: true,
2434
+ force: true
2435
+ });
2436
+ } catch {}
2437
+ clearCursorSkillCache();
2438
+ }
2095
2439
  async function installPlugin(ref, opts) {
2096
2440
  const cfg = loadConfig();
2097
- const tarball = await fetchPluginArchive(ref, cfg.portal, cfg.token);
2441
+ const { buffer: tarball, commitSha } = await fetchPluginArchive(ref, cfg.portal, cfg.token);
2098
2442
  const tmp = await mkdtemp(join(tmpdir(), "plugin-"));
2099
2443
  try {
2100
2444
  extractTarGz(tarball, tmp);
2101
- return await installFromExtracted(ref, await findPluginRoot(tmp), opts);
2445
+ return await installFromExtracted(ref, await findPluginRoot(tmp), opts, commitSha ?? void 0);
2102
2446
  } finally {
2103
2447
  await rm(tmp, {
2104
2448
  recursive: true,
@@ -2122,7 +2466,7 @@ async function findPluginRoot(start) {
2122
2466
  }
2123
2467
  throw new Error(`plugin.json not found under ${start} (corrupt archive?)`);
2124
2468
  }
2125
- async function installFromExtracted(ref, extractedDir, opts) {
2469
+ async function installFromExtracted(ref, extractedDir, opts, commitSha) {
2126
2470
  const { scopeNamespace, pluginName } = parsePluginRef$1(ref);
2127
2471
  const storeRoot = getStoreRoot(opts.scope, opts.cwd);
2128
2472
  const pluginCanonical = join(storeRoot, "plugins", `${scopeNamespace}__${pluginName}`);
@@ -2167,7 +2511,8 @@ async function installFromExtracted(ref, extractedDir, opts) {
2167
2511
  components,
2168
2512
  preflight,
2169
2513
  statuses,
2170
- opts
2514
+ opts,
2515
+ commitSha
2171
2516
  }),
2172
2517
  installedEntries: preflight.map((pe) => ({
2173
2518
  agent: pe.agent,
@@ -2330,7 +2675,7 @@ function componentSubRef$1(c) {
2330
2675
  }
2331
2676
  }
2332
2677
  async function commitPluginInstall(params) {
2333
- const { ref, scopeNamespace, pluginName, pluginCanonical, extractedDir, components, preflight, statuses, opts } = params;
2678
+ const { ref, scopeNamespace, pluginName, pluginCanonical, extractedDir, components, preflight, statuses, opts, commitSha } = params;
2334
2679
  await rm(pluginCanonical, {
2335
2680
  recursive: true,
2336
2681
  force: true
@@ -2414,16 +2759,44 @@ async function commitPluginInstall(params) {
2414
2759
  cwd: opts.cwd
2415
2760
  });
2416
2761
  if (components.skills.length > 0) for (const agent of opts.agents) await ensureForgeHooks(agent);
2762
+ let version = "0.0.0";
2763
+ try {
2764
+ version = JSON.parse(await readFile(join(pluginCanonical, "plugin.json"), "utf-8")).version ?? "0.0.0";
2765
+ } catch {}
2766
+ const warn = (msg) => console.warn(`[forge] warning: ${msg}`);
2767
+ if (opts.agents.includes("claude-code") || opts.agents.includes("cursor")) await registerClaudePlugin({
2768
+ pluginName,
2769
+ version,
2770
+ sourcePath: pluginCanonical,
2771
+ gitSha: commitSha
2772
+ }).catch((e) => warn(`claude-code plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
2773
+ if (opts.agents.includes("codex")) await registerCodexPlugin({
2774
+ pluginName,
2775
+ installPath: pluginCanonical,
2776
+ version
2777
+ }).catch((e) => warn(`codex plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
2778
+ if (opts.agents.includes("cursor") && !opts.agents.includes("claude-code")) await registerCursorPlugin({
2779
+ pluginName,
2780
+ installPath: pluginCanonical
2781
+ }).catch((e) => warn(`cursor plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
2782
+ await ensureForgeCliWrapper().catch((e) => warn(`forge-cli.sh wrapper generation failed: ${e instanceof Error ? e.message : String(e)}`));
2417
2783
  return ledger;
2418
2784
  }
2419
- async function copyDirRecursive(src, dest, skipDotClaudePlugin) {
2785
+ async function copyDirRecursive(src, dest, skipDotClaudePlugin, extraSkip) {
2420
2786
  await mkdir(dest, { recursive: true });
2421
2787
  for (const e of await readdir(src, { withFileTypes: true })) {
2422
2788
  if (skipDotClaudePlugin && e.name === ".claude-plugin") continue;
2789
+ if (extraSkip?.has(e.name)) continue;
2423
2790
  const s = join(src, e.name);
2424
2791
  const d = join(dest, e.name);
2425
2792
  if (e.isDirectory()) await copyDirRecursive(s, d, false);
2426
- else if (e.isFile()) await writeFile(d, await readFile(s));
2793
+ else if (e.isFile()) {
2794
+ await writeFile(d, await readFile(s));
2795
+ try {
2796
+ const srcStat = await stat(s);
2797
+ if (srcStat.mode & 73) await chmod(d, srcStat.mode & 511);
2798
+ } catch {}
2799
+ }
2427
2800
  }
2428
2801
  }
2429
2802
  async function copyFileShallow(src, dest) {
@@ -3319,7 +3692,6 @@ async function isSourcePrivate(source) {
3319
3692
  if (!ownerRepo) return false;
3320
3693
  return isRepoPrivate(ownerRepo.owner, ownerRepo.repo);
3321
3694
  }
3322
- function initTelemetry(version) {}
3323
3695
  function riskLabel(risk) {
3324
3696
  switch (risk) {
3325
3697
  case "critical": return import_picocolors.default.red(import_picocolors.default.bold("Critical Risk"));
@@ -4799,6 +5171,65 @@ function parseAddOptions(args) {
4799
5171
  options
4800
5172
  };
4801
5173
  }
5174
+ function parseReportEventOptions(args) {
5175
+ let type;
5176
+ let ref;
5177
+ let agent;
5178
+ let data;
5179
+ for (let i = 0; i < args.length; i++) {
5180
+ const arg = args[i];
5181
+ if ((arg === "--type" || arg === "-t") && args[i + 1]) type = args[++i];
5182
+ else if ((arg === "--ref" || arg === "-r") && args[i + 1]) ref = args[++i];
5183
+ else if ((arg === "--agent" || arg === "-a") && args[i + 1]) agent = args[++i];
5184
+ else if ((arg === "--data" || arg === "-d") && args[i + 1]) {
5185
+ const raw = args[++i];
5186
+ try {
5187
+ data = JSON.parse(raw);
5188
+ } catch {}
5189
+ }
5190
+ }
5191
+ if (!type) return null;
5192
+ return {
5193
+ type,
5194
+ ref,
5195
+ agent,
5196
+ data
5197
+ };
5198
+ }
5199
+ async function runReportEvent(args) {
5200
+ const opts = parseReportEventOptions(args);
5201
+ if (!opts) return;
5202
+ let cfg;
5203
+ try {
5204
+ cfg = loadConfig();
5205
+ } catch {
5206
+ return;
5207
+ }
5208
+ const body = {
5209
+ event_type: "hook_event",
5210
+ metadata: {
5211
+ hook_type: opts.type,
5212
+ ...opts.data
5213
+ }
5214
+ };
5215
+ if (opts.ref) body.asset_ref = opts.ref;
5216
+ if (opts.agent) body.install_mode = opts.agent;
5217
+ const token = process.env["SHOPLAZZA_FORGE_TOKEN"] ?? cfg.token;
5218
+ const headers = { "Content-Type": "application/json" };
5219
+ if (token) headers["Authorization"] = `Bearer ${token}`;
5220
+ const controller = new AbortController();
5221
+ const timeoutId = setTimeout(() => controller.abort(), 2e3);
5222
+ try {
5223
+ await fetch(`${cfg.portal}/events`, {
5224
+ method: "POST",
5225
+ headers,
5226
+ body: JSON.stringify(body),
5227
+ signal: controller.signal
5228
+ });
5229
+ } catch {} finally {
5230
+ clearTimeout(timeoutId);
5231
+ }
5232
+ }
4802
5233
  const RESET$2 = "\x1B[0m";
4803
5234
  const BOLD$2 = "\x1B[1m";
4804
5235
  const DIM$2 = "\x1B[38;5;102m";
@@ -5895,6 +6326,9 @@ async function uninstallPlugin(plugin, cwd, agentFilter) {
5895
6326
  }
5896
6327
  }
5897
6328
  if (installModes.includes("codex")) for (const scope of ["project", "global"]) await cleanupCodexConfigToml(ledger, scope, cwd);
6329
+ if (installModes.includes("claude-code") || installModes.includes("cursor")) await unregisterClaudePlugin(plugin.name).catch(() => {});
6330
+ if (installModes.includes("cursor")) await unregisterCursorPlugin(plugin.name).catch(() => {});
6331
+ if (installModes.includes("codex")) await unregisterCodexPlugin(plugin.name).catch(() => {});
5898
6332
  await rm(plugin.canonical, {
5899
6333
  recursive: true,
5900
6334
  force: true
@@ -6275,7 +6709,6 @@ function getVersion() {
6275
6709
  }
6276
6710
  }
6277
6711
  const VERSION = getVersion();
6278
- initTelemetry(VERSION);
6279
6712
  const RESET = "\x1B[0m";
6280
6713
  const BOLD = "\x1B[1m";
6281
6714
  const DIM = "\x1B[38;5;102m";
@@ -6340,6 +6773,12 @@ ${BOLD}Updates:${RESET}
6340
6773
  ${BOLD}Project:${RESET}
6341
6774
  init [name] Initialize a skill (creates <name>/SKILL.md or ./SKILL.md)
6342
6775
 
6776
+ ${BOLD}Publishing:${RESET}
6777
+ publish <paths...> Publish skills to the forge portal
6778
+
6779
+ ${BOLD}Auth:${RESET}
6780
+ login Authenticate with the forge portal (browser OAuth)
6781
+
6343
6782
  ${BOLD}Add Options:${RESET}
6344
6783
  -g, --global Install at global scope (entry symlinks under ~/)
6345
6784
  -a, --agent <agents> Specify agents to install to (use '*' for all agents)
@@ -6364,6 +6803,11 @@ ${BOLD}Update Options:${RESET}
6364
6803
  -y, --yes Skip confirmation prompts
6365
6804
  --json Machine-readable summary
6366
6805
 
6806
+ ${BOLD}Publish Options:${RESET}
6807
+ -s, --scope <scope> Team scope (e.g. team:test)
6808
+ -t, --type <type> Asset type: skill or rule (default: skill)
6809
+ -v, --visibility <v> Visibility: public or team (auto-detected from --scope)
6810
+
6367
6811
  ${BOLD}Options:${RESET}
6368
6812
  --help, -h Show this help message
6369
6813
  --version, -v Show version number
@@ -6380,6 +6824,8 @@ ${BOLD}Examples:${RESET}
6380
6824
  ${DIM}$${RESET} shoplazza-ai-dev-cli update
6381
6825
  ${DIM}$${RESET} shoplazza-ai-dev-cli update some-skill
6382
6826
  ${DIM}$${RESET} shoplazza-ai-dev-cli init my-skill
6827
+ ${DIM}$${RESET} shoplazza-ai-dev-cli login
6828
+ ${DIM}$${RESET} shoplazza-ai-dev-cli publish ./my-skill --scope team:test
6383
6829
  `);
6384
6830
  }
6385
6831
  function showRemoveHelp() {
@@ -6508,12 +6954,14 @@ async function runUpdate(args = []) {
6508
6954
  name: pl.name,
6509
6955
  ref: pl.ref,
6510
6956
  canonical: pl.canonical,
6957
+ agents: pl.agents,
6511
6958
  hasProjectEntry: hasProjectEntryFor(pl.canonical, cwd)
6512
6959
  })), ...inventory.skills.filter((s) => Boolean(s.ref)).map((s) => ({
6513
6960
  kind: "skill",
6514
6961
  name: s.name,
6515
6962
  ref: s.ref,
6516
6963
  canonical: s.canonical,
6964
+ agents: s.agents,
6517
6965
  hasProjectEntry: hasProjectEntryFor(s.canonical, cwd)
6518
6966
  }))];
6519
6967
  if (options.names && options.names.length > 0) {
@@ -6555,12 +7003,23 @@ async function runUpdate(args = []) {
6555
7003
  for (const t of targets) {
6556
7004
  const safeName = sanitizeMetadata(t.name);
6557
7005
  if (!options.json) console.log(`${TEXT}Updating ${safeName}...${RESET} ${DIM}(${t.ref})${RESET}`);
7006
+ if (t.agents.length === 0) {
7007
+ fail++;
7008
+ if (!options.json) console.log(` ${DIM}✗ skipped ${safeName} — no IDE entries point at this canonical${RESET}`);
7009
+ results.push({
7010
+ name: t.name,
7011
+ kind: t.kind,
7012
+ ok: false
7013
+ });
7014
+ continue;
7015
+ }
6558
7016
  const passthrough = [
6559
7017
  "add",
6560
7018
  t.ref,
6561
7019
  "-y"
6562
7020
  ];
6563
7021
  if (!t.hasProjectEntry) passthrough.push("-g");
7022
+ passthrough.push("-a", ...t.agents);
6564
7023
  const ok = spawnSync(process.execPath, [cliEntry, ...passthrough], {
6565
7024
  stdio: options.json ? [
6566
7025
  "ignore",
@@ -6678,6 +7137,9 @@ async function main() {
6678
7137
  await runPublish(paths, publishOptions);
6679
7138
  break;
6680
7139
  }
7140
+ case "report-event":
7141
+ await runReportEvent(restArgs);
7142
+ break;
6681
7143
  case "--help":
6682
7144
  case "-h":
6683
7145
  showHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-ai-dev-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6-snapshot.5",
4
4
  "description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
5
5
  "type": "module",
6
6
  "bin": {