shoplazza-ai-dev-cli 0.1.19 → 0.1.21-snapshot.0

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.
@@ -1109,6 +1109,7 @@ async function get(client, args, json) {
1109
1109
  console.log(`\n Cases (${cases.length}):`);
1110
1110
  for (const c of cases) {
1111
1111
  const marks = [];
1112
+ if (c["status"] === "deprecated") marks.push("已废弃 · 不计入进度");
1112
1113
  if (c["in_source_set"] === false) marks.push("已离开来源集");
1113
1114
  if (c["content_updated"] === true) marks.push(`正文已更新 v${c["case_version_at_add"]}→v${c["current_version"]}`);
1114
1115
  const suffix = marks.length ? ` [${marks.join(" · ")}]` : "";
@@ -1290,6 +1291,59 @@ async function runKBMRs(client, args, json) {
1290
1291
  process.exitCode = 2;
1291
1292
  }
1292
1293
  }
1294
+ const STATUS_OUTDATED = "outdated";
1295
+ const STATUS_UP_TO_DATE = "up_to_date";
1296
+ const REASON_TEXT = {
1297
+ no_source_case_set: "这个计划没有来源用例集(回归计划 / 历史计划),核对不了",
1298
+ no_requirement: "来源用例集没关联需求,核对不了",
1299
+ no_feishu_ticket: "关联需求没挂飞书工单,对不上集中仓里的任何工单",
1300
+ not_in_api_docs: "集中仓里还没有这个工单的接口文档",
1301
+ never_synced: "这个用例集从没同步过用例,平台没记过它照的是第几版",
1302
+ lookup_failed: "读集中仓失败(权限或网络),这次没核对上",
1303
+ unspecified: "核对不成,原因未知"
1304
+ };
1305
+ async function runAPIDocStatus(client, args, json) {
1306
+ const { positional } = parseNamedArgs(args);
1307
+ const target = positional[0];
1308
+ const id = positional[1];
1309
+ if (!id) {
1310
+ printError("Usage: test api-doc-status plan <plan_id> | test api-doc-status case-set <set_id>");
1311
+ process.exitCode = 2;
1312
+ return;
1313
+ }
1314
+ let path;
1315
+ if (target === "plan") path = `/api/test/plans/${encodeURIComponent(id)}/api-doc-status`;
1316
+ else if (target === "case-set") path = `/api/test/case-sets/${encodeURIComponent(id)}/api-doc-status`;
1317
+ else {
1318
+ printError(`Unknown target "${target}": must be plan|case-set`);
1319
+ process.exitCode = 2;
1320
+ return;
1321
+ }
1322
+ const data = await client.get(path);
1323
+ const status = String(data["status"] ?? "");
1324
+ if (json) printJson(data);
1325
+ else printStatus(data, status);
1326
+ if (status === STATUS_OUTDATED) process.exitCode = 1;
1327
+ }
1328
+ function printStatus(data, status) {
1329
+ const latest = data["latest_version"];
1330
+ const synced = data["synced_version"];
1331
+ if (status === STATUS_OUTDATED) {
1332
+ printError(`接口文档已更新到 v${String(latest)},本用例集是照 v${String(synced)} 写的——用例可能已过时`);
1333
+ printKV([
1334
+ ["工单", data["ticket"] ?? "—"],
1335
+ ["产品线", data["product_line"] ?? "—"],
1336
+ ["改了什么", data["changes_path"] ?? "—"]
1337
+ ]);
1338
+ return;
1339
+ }
1340
+ if (status === STATUS_UP_TO_DATE) {
1341
+ printSuccess(`接口文档是最新的(v${String(latest)})`);
1342
+ return;
1343
+ }
1344
+ const reason = String(data["reason"] ?? "unspecified");
1345
+ printKV([["状态", `unknown(未核对上,不代表没问题)`], ["原因", `${REASON_TEXT[reason] ?? reason}(${reason})`]]);
1346
+ }
1293
1347
  const RESOURCES = {
1294
1348
  taxonomy: runTaxonomy,
1295
1349
  requirements: runRequirements,
@@ -1297,7 +1351,8 @@ const RESOURCES = {
1297
1351
  "case-sets": runCaseSets,
1298
1352
  plans: runPlans,
1299
1353
  results: runResults,
1300
- "kb-mrs": runKBMRs
1354
+ "kb-mrs": runKBMRs,
1355
+ "api-doc-status": runAPIDocStatus
1301
1356
  };
1302
1357
  const HELP = `Testing platform commands (Scenario A & B).
1303
1358
 
@@ -1309,6 +1364,7 @@ Resources:
1309
1364
  plans Test plans & execution
1310
1365
  results Test results (batch)
1311
1366
  kb-mrs Knowledge-base MR links (case set / plan)
1367
+ api-doc-status Whether the cases were written against the latest API docs
1312
1368
 
1313
1369
  Run: shoplazza-ai-dev-cli test <resource> --help`;
1314
1370
  async function runTest(rawArgs) {
package/dist/cli.mjs CHANGED
@@ -2521,6 +2521,28 @@ async function installFromExtracted(ref, extractedDir, opts, commitSha) {
2521
2521
  const pluginCanonical = join(storeRoot, "plugins", `${scopeNamespace}__${pluginName}`);
2522
2522
  const components = await classifyExtracted(extractedDir);
2523
2523
  const ignoredComponents = await collectIgnoredTopLevel(extractedDir);
2524
+ if (opts.agents.length > 0 && opts.agents.every((a) => a === "claude-code")) {
2525
+ const unchanged = await findUnchangedInstall({
2526
+ ref,
2527
+ pluginName,
2528
+ extractedDir,
2529
+ pluginCanonical,
2530
+ claudeHome: getAgentHome("claude-code"),
2531
+ commitSha,
2532
+ force: opts.force
2533
+ });
2534
+ if (unchanged) return {
2535
+ pluginRef: ref,
2536
+ pluginCanonical,
2537
+ installedComponents: unchanged.installedComponents,
2538
+ installedEntries: [],
2539
+ forgeOtherReplacements: [],
2540
+ ignoredComponents,
2541
+ warnings: [],
2542
+ registrationFailed: false,
2543
+ unchanged: true
2544
+ };
2545
+ }
2524
2546
  const preflight = buildPreflightList(pluginCanonical, components, opts);
2525
2547
  const foreignConflicts = [];
2526
2548
  const forgeOtherReplacements = [];
@@ -2727,6 +2749,53 @@ function componentSubRef$1(c) {
2727
2749
  case "plugin-rule-deps-dir": return `rules/${c.dirname}`;
2728
2750
  }
2729
2751
  }
2752
+ async function findUnchangedInstall(params) {
2753
+ if (params.force) return null;
2754
+ let version;
2755
+ try {
2756
+ version = await resolvePluginVersion(params.extractedDir, params.pluginName);
2757
+ } catch {
2758
+ return null;
2759
+ }
2760
+ const entry = (await readJsonOrNull(join(params.claudeHome, "plugins", "installed_plugins.json")))?.plugins?.[`${params.pluginName}@${MARKETPLACE}`]?.[0];
2761
+ if (!entry?.installPath || entry.version !== version) return null;
2762
+ if (params.commitSha && entry.gitCommitSha && params.commitSha !== entry.gitCommitSha) return null;
2763
+ const ledger = await readJsonOrNull(join(params.pluginCanonical, ".forge-plugin.json"));
2764
+ if (!ledger || ledger.ref !== params.ref) return null;
2765
+ if (!await cacheDirIntact(params.extractedDir, entry.installPath)) return null;
2766
+ return {
2767
+ version,
2768
+ installPath: entry.installPath,
2769
+ installedComponents: ledger.installed_components ?? []
2770
+ };
2771
+ }
2772
+ const CACHE_SKIPPED_TOP_LEVEL = new Set([
2773
+ ".cursor-plugin",
2774
+ ".codex-plugin",
2775
+ "hooks-cursor.json",
2776
+ "hooks-codex.json"
2777
+ ]);
2778
+ async function cacheDirIntact(extractedDir, installPath) {
2779
+ if (!existsSync(installPath)) return false;
2780
+ let entries;
2781
+ try {
2782
+ entries = await readdir(extractedDir);
2783
+ } catch {
2784
+ return false;
2785
+ }
2786
+ for (const name of entries) {
2787
+ if (CACHE_SKIPPED_TOP_LEVEL.has(name)) continue;
2788
+ if (!existsSync(join(installPath, name))) return false;
2789
+ }
2790
+ return true;
2791
+ }
2792
+ async function readJsonOrNull(path) {
2793
+ try {
2794
+ return JSON.parse(await readFile(path, "utf-8"));
2795
+ } catch {
2796
+ return null;
2797
+ }
2798
+ }
2730
2799
  async function resolvePluginVersion(pluginCanonical, pluginName) {
2731
2800
  for (const manifestPath of [join(pluginCanonical, "plugin.json"), join(pluginCanonical, ".claude-plugin", "plugin.json")]) try {
2732
2801
  const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
@@ -4459,7 +4528,7 @@ async function runAdd(args, options = {}) {
4459
4528
  spinner.stop(import_picocolors.default.red("Plugin installation failed"));
4460
4529
  throw err;
4461
4530
  }
4462
- spinner.stop(import_picocolors.default.green("Plugin installed"));
4531
+ spinner.stop(pluginResult.unchanged ? import_picocolors.default.green("Plugin already up to date (same version installed, nothing rewritten)") : import_picocolors.default.green("Plugin installed"));
4463
4532
  if (pluginResult.warnings.length > 0) for (const w of pluginResult.warnings) M.warn(w);
4464
4533
  if (pluginResult.registrationFailed) {
4465
4534
  M.error(import_picocolors.default.red("Claude native plugin registration failed"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-ai-dev-cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.21-snapshot.0",
4
4
  "description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
5
5
  "type": "module",
6
6
  "bin": {