shoplazza-ai-dev-cli 0.1.17 → 0.1.18

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.
@@ -344,6 +344,13 @@ async function create$2(client, args, json) {
344
344
  ["Case Set ID", data["case_set_id"] ?? "—"]
345
345
  ]);
346
346
  } else console.log(`ℹ Requirement already exists: ${data["req_id"]} (not modified)`);
347
+ printFeishuSyncWarning(data);
348
+ }
349
+ function printFeishuSyncWarning(data) {
350
+ const failed = (data["feishu_sync"]?.fields ?? []).filter((f) => f.status === "failed");
351
+ if (failed.length === 0) return;
352
+ printError("飞书工单回写失败(需求本身已入库;下次对同一工单执行 create 会自动补写):");
353
+ for (const f of failed) console.error(` - ${f.label ?? ""}(${f.field_key ?? "?"}) reason=${f.reason ?? "?"} err_code=${f.err_code ?? 0} err_msg=${f.err_msg ?? ""} expect=${f.expect ?? ""} actual=${f.actual ?? ""}`);
347
354
  }
348
355
  async function sync$1(client, args, json) {
349
356
  const { positional, named } = parseNamedArgs(args);
@@ -697,16 +704,64 @@ async function update(client, args, json) {
697
704
  process.exitCode = 1;
698
705
  }
699
706
  }
707
+ async function batchStatus(client, args, json) {
708
+ const { named } = parseNamedArgs(args);
709
+ const idsRaw = named["ids"];
710
+ const idsVal = Array.isArray(idsRaw) ? idsRaw.join(",") : idsRaw;
711
+ if (typeof idsVal !== "string" || idsVal.trim() === "") {
712
+ printError("Usage: cases batch-status --ids TC-000001,TC-000002 [--include-content]");
713
+ process.exitCode = 2;
714
+ return;
715
+ }
716
+ const body = { case_ids: idsVal.split(",").map((s) => s.trim()).filter((s) => s !== "") };
717
+ if (named["include-content"] !== void 0) body["include_content"] = true;
718
+ const data = await client.post("/api/test/cases:batch-status", body);
719
+ if (json) {
720
+ printJson(data);
721
+ return;
722
+ }
723
+ printTable(data.items, [
724
+ {
725
+ key: "case_id",
726
+ label: "Case ID"
727
+ },
728
+ {
729
+ key: "exists",
730
+ label: "Exists",
731
+ width: 6
732
+ },
733
+ {
734
+ key: "deleted",
735
+ label: "Deleted",
736
+ width: 7
737
+ },
738
+ {
739
+ key: "status",
740
+ label: "Status",
741
+ width: 10
742
+ },
743
+ {
744
+ key: "version",
745
+ label: "Ver",
746
+ width: 4
747
+ },
748
+ {
749
+ key: "title",
750
+ label: "Title"
751
+ }
752
+ ]);
753
+ }
700
754
  async function runCases(client, args, json) {
701
755
  const action = args[0];
702
756
  const subArgs = args.slice(1);
703
757
  switch (action) {
704
758
  case "list": return list$1(client, subArgs, json);
705
759
  case "update": return update(client, subArgs, json);
760
+ case "batch-status": return batchStatus(client, subArgs, json);
706
761
  case "--help":
707
762
  case "-h":
708
763
  case void 0:
709
- console.log(`cases commands:\n list List cases with filters\n update Patch a case by id (pointer semantics: only pass fields to change; --file <path|-> for JSON body)`);
764
+ console.log(`cases commands:\n list List cases with filters\n update Patch a case by id (pointer semantics: only pass fields to change; --file <path|-> for JSON body)\n batch-status Batch read existence/deleted/status/version by case ids (--ids a,b,c [--include-content])`);
710
765
  return;
711
766
  default:
712
767
  printError(`Unknown cases action: ${action}`);
@@ -1029,7 +1084,7 @@ async function list(client, args, json) {
1029
1084
  ]);
1030
1085
  printPagination(data.total);
1031
1086
  }
1032
- async function add(client, args, json) {
1087
+ async function add$1(client, args, json) {
1033
1088
  const { positional } = parseNamedArgs(args);
1034
1089
  const [planId, ...caseIDs] = positional;
1035
1090
  if (!planId || caseIDs.length === 0) {
@@ -1061,7 +1116,7 @@ async function runPlans(client, args, json) {
1061
1116
  case "create": return create(client, subArgs, json);
1062
1117
  case "get": return get(client, subArgs, json);
1063
1118
  case "list": return list(client, subArgs, json);
1064
- case "add": return add(client, subArgs, json);
1119
+ case "add": return add$1(client, subArgs, json);
1065
1120
  case "--help":
1066
1121
  case "-h":
1067
1122
  case void 0:
@@ -1108,13 +1163,60 @@ async function runResults(client, args, json) {
1108
1163
  process.exitCode = 2;
1109
1164
  }
1110
1165
  }
1166
+ const ADD_USAGE = "Usage: test kb-mrs add (--set <set_id> | --plan <PLAN-id>) --urls <u1,u2>";
1167
+ function buildKBMRsRequest(named) {
1168
+ const set = typeof named["set"] === "string" ? named["set"] : void 0;
1169
+ const plan = typeof named["plan"] === "string" ? named["plan"] : void 0;
1170
+ const urlsRaw = typeof named["urls"] === "string" ? named["urls"] : void 0;
1171
+ if (set && plan || !set && !plan) return { error: `exactly one of --set or --plan is required\n${ADD_USAGE}` };
1172
+ if (!urlsRaw) return { error: `missing --urls\n${ADD_USAGE}` };
1173
+ const urls = urlsRaw.split(",").map((s) => s.trim()).filter(Boolean);
1174
+ if (urls.length === 0) return { error: `--urls must contain at least one URL\n${ADD_USAGE}` };
1175
+ return {
1176
+ path: plan ? `/api/test/test-plans/${encodeURIComponent(plan)}/kb-mrs` : `/api/test/case-sets/${encodeURIComponent(set)}/kb-mrs`,
1177
+ body: { urls }
1178
+ };
1179
+ }
1180
+ async function add(client, args, json) {
1181
+ const { named } = parseNamedArgs(args);
1182
+ const req = buildKBMRsRequest(named);
1183
+ if ("error" in req) {
1184
+ printError(req.error);
1185
+ process.exitCode = 2;
1186
+ return;
1187
+ }
1188
+ const data = await client.post(req.path, req.body);
1189
+ if (json) {
1190
+ printJson(data);
1191
+ return;
1192
+ }
1193
+ const all = data["kb_mr_urls"] ?? [];
1194
+ printSuccess(`KB MRs recorded: ${data["added"]} added (total ${all.length})`);
1195
+ for (const u of all) console.log(` ${u}`);
1196
+ }
1197
+ async function runKBMRs(client, args, json) {
1198
+ const action = args[0];
1199
+ const subArgs = args.slice(1);
1200
+ switch (action) {
1201
+ case "add": return add(client, subArgs, json);
1202
+ case "--help":
1203
+ case "-h":
1204
+ case void 0:
1205
+ console.log(`kb-mrs commands:\n add Record knowledge-base MR links on a case set (--set) or plan (--plan)\n\n${ADD_USAGE}`);
1206
+ return;
1207
+ default:
1208
+ printError(`Unknown kb-mrs action: ${action}`);
1209
+ process.exitCode = 2;
1210
+ }
1211
+ }
1111
1212
  const RESOURCES = {
1112
1213
  taxonomy: runTaxonomy,
1113
1214
  requirements: runRequirements,
1114
1215
  cases: runCases,
1115
1216
  "case-sets": runCaseSets,
1116
1217
  plans: runPlans,
1117
- results: runResults
1218
+ results: runResults,
1219
+ "kb-mrs": runKBMRs
1118
1220
  };
1119
1221
  const HELP = `Testing platform commands (Scenario A & B).
1120
1222
 
@@ -1125,6 +1227,7 @@ Resources:
1125
1227
  case-sets Case set member management
1126
1228
  plans Test plans & execution
1127
1229
  results Test results (batch)
1230
+ kb-mrs Knowledge-base MR links (case set / plan)
1128
1231
 
1129
1232
  Run: shoplazza-ai-dev-cli test <resource> --help`;
1130
1233
  async function runTest(rawArgs) {
package/dist/cli.mjs CHANGED
@@ -2481,6 +2481,11 @@ async function withInstallLock(lockDir, fn) {
2481
2481
  }
2482
2482
  }
2483
2483
  async function installPlugin(ref, opts) {
2484
+ if (opts.fromDir !== void 0) {
2485
+ if (!existsSync(opts.fromDir)) throw new Error(`--from-dir directory not found: ${opts.fromDir}`);
2486
+ if (!existsSync(join(opts.fromDir, "plugin.json")) && !existsSync(join(opts.fromDir, ".claude-plugin", "plugin.json"))) throw new Error(`--from-dir directory has no plugin root (missing plugin.json or .claude-plugin/plugin.json): ${opts.fromDir}`);
2487
+ return await installFromExtracted(ref, opts.fromDir, opts, void 0);
2488
+ }
2484
2489
  const cfg = loadConfig();
2485
2490
  const { buffer: tarball, commitSha } = await fetchPluginArchive(ref, cfg.portal, cfg.token);
2486
2491
  const tmp = await mkdtemp(join(tmpdir(), "plugin-"));
@@ -2722,6 +2727,13 @@ function componentSubRef$1(c) {
2722
2727
  case "plugin-rule-deps-dir": return `rules/${c.dirname}`;
2723
2728
  }
2724
2729
  }
2730
+ async function resolvePluginVersion(pluginCanonical, pluginName) {
2731
+ for (const manifestPath of [join(pluginCanonical, "plugin.json"), join(pluginCanonical, ".claude-plugin", "plugin.json")]) try {
2732
+ const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
2733
+ if (manifest.name && manifest.description) return manifest.version || "0.0.0";
2734
+ } catch {}
2735
+ throw new Error(`refusing to register ${pluginName}: no valid plugin.json (with name/description) in canonical store ${pluginCanonical} (partial/corrupt install?)`);
2736
+ }
2725
2737
  async function commitPluginInstall(params) {
2726
2738
  const { ref, scopeNamespace, pluginName, pluginCanonical, extractedDir, components, preflight, statuses, opts, commitSha } = params;
2727
2739
  await rm(pluginCanonical, {
@@ -2807,15 +2819,7 @@ async function commitPluginInstall(params) {
2807
2819
  cwd: opts.cwd
2808
2820
  });
2809
2821
  if (components.skills.length > 0) for (const agent of opts.agents) await ensureForgeHooks(agent);
2810
- let version;
2811
- for (const manifestPath of [join(pluginCanonical, "plugin.json"), join(pluginCanonical, ".claude-plugin", "plugin.json")]) try {
2812
- const manifest = JSON.parse(await readFile(manifestPath, "utf-8"));
2813
- if (manifest.version) {
2814
- version = manifest.version;
2815
- break;
2816
- }
2817
- } catch {}
2818
- if (!version) throw new Error(`refusing to register ${pluginName}: no plugin.json version in canonical store ${pluginCanonical} (partial/corrupt install?)`);
2822
+ const version = await resolvePluginVersion(pluginCanonical, pluginName);
2819
2823
  const warnings = [];
2820
2824
  const warn = (msg) => warnings.push(msg);
2821
2825
  let registrationFailed = false;
@@ -3154,16 +3158,19 @@ async function fetchAuditData(source, skillSlugs, timeoutMs = 3e3) {
3154
3158
  const pendingTelemetry = [];
3155
3159
  function track(data) {
3156
3160
  if (!isTelemetryEnabled()) return;
3157
- if (!portalUrl) portalUrl = loadConfig().portal;
3161
+ const cfg = loadConfig();
3162
+ if (!portalUrl) portalUrl = cfg.portal;
3158
3163
  try {
3159
3164
  const bodyPayload = {};
3160
3165
  for (const [key, value] of Object.entries(data)) if (value !== void 0 && value !== null) bodyPayload[key] = value;
3166
+ const headers = {
3167
+ "Content-Type": "application/json",
3168
+ "User-Agent": "shoplazza-ai-dev-cli"
3169
+ };
3170
+ if (cfg.token) headers.Authorization = `Bearer ${cfg.token}`;
3161
3171
  const p = fetch(`${portalUrl}${TELEMETRY_URL_SUFFIX}`, {
3162
3172
  method: "POST",
3163
- headers: {
3164
- "Content-Type": "application/json",
3165
- "User-Agent": "shoplazza-ai-dev-cli"
3166
- },
3173
+ headers,
3167
3174
  body: JSON.stringify(bodyPayload)
3168
3175
  }).catch(() => {}).then(() => {});
3169
3176
  pendingTelemetry.push(p);
@@ -4265,6 +4272,16 @@ async function runTeamBatchAdd(teamScope, options) {
4265
4272
  }
4266
4273
  await promptForFindSkills(options, targetAgents);
4267
4274
  }
4275
+ function isPluginPortalRef(ref) {
4276
+ return /^(?:@public|@teams\/[^/]+)\/plugins(?:\/.+)?$/.test(ref);
4277
+ }
4278
+ function resolvePluginItemRef(portalRef, pluginOpt) {
4279
+ const pluginsDirRe = /^(?:@public|@teams\/[^/]+)\/plugins$/;
4280
+ const pluginsItemRe = /^(?:@public|@teams\/[^/]+)\/plugins\/[^/]+/;
4281
+ if (pluginsDirRe.test(portalRef) && pluginOpt && pluginOpt.length === 1) return `${portalRef}/${pluginOpt[0]}`;
4282
+ if (pluginsItemRe.test(portalRef)) return portalRef;
4283
+ return null;
4284
+ }
4268
4285
  async function runAdd(args, options = {}) {
4269
4286
  const source = args[0];
4270
4287
  let installTipShown = false;
@@ -4315,6 +4332,11 @@ async function runAdd(args, options = {}) {
4315
4332
  const parsed = parseSource(source);
4316
4333
  const sourceLabel = parsed.type === "local" ? parsed.localPath : parsed.type === "portal" ? parsed.portalRef : parsed.url;
4317
4334
  spinner.stop(`Source: ${sourceLabel}${parsed.ref ? ` @ ${import_picocolors.default.yellow(parsed.ref)}` : ""}${parsed.subpath ? ` (${parsed.subpath})` : ""}${parsed.skillFilter ? ` ${import_picocolors.default.dim("@")}${import_picocolors.default.cyan(parsed.skillFilter)}` : ""}`);
4335
+ const isFromDirAllowed = parsed.type === "portal" && !!parsed.portalRef && isPluginPortalRef(parsed.portalRef);
4336
+ if (options.fromDir && !isFromDirAllowed) {
4337
+ Se(import_picocolors.default.red("--from-dir is only supported for plugin refs (e.g. @public/plugins/<name> or @teams/<scope>/plugins/<name>)"));
4338
+ process.exit(1);
4339
+ }
4318
4340
  const ownerRepoRaw = getOwnerRepo(parsed);
4319
4341
  const repoPrivacyPromise = (() => {
4320
4342
  if (!ownerRepoRaw) return Promise.resolve(null);
@@ -4342,11 +4364,7 @@ async function runAdd(args, options = {}) {
4342
4364
  }
4343
4365
  if (parsed.type === "portal" && parsed.portalRef) {
4344
4366
  const portalRef = parsed.portalRef;
4345
- const pluginsDirRe = /^(?:@public|@teams\/[^/]+)\/plugins$/;
4346
- const pluginsItemRe = /^(?:@public|@teams\/[^/]+)\/plugins\/[^/]+/;
4347
- let resolvedPluginRef = null;
4348
- if (pluginsDirRe.test(portalRef) && options.plugin && options.plugin.length === 1) resolvedPluginRef = `${portalRef}/${options.plugin[0]}`;
4349
- else if (pluginsItemRe.test(portalRef)) resolvedPluginRef = portalRef;
4367
+ const resolvedPluginRef = resolvePluginItemRef(portalRef, options.plugin);
4350
4368
  if (resolvedPluginRef !== null) {
4351
4369
  const isTeam = resolvedPluginRef.startsWith("@teams/");
4352
4370
  const teamMatch = isTeam ? resolvedPluginRef.match(/^@teams\/([^/]+)/) : null;
@@ -4434,7 +4452,8 @@ async function runAdd(args, options = {}) {
4434
4452
  agents: targetAgents,
4435
4453
  cwd: process.cwd(),
4436
4454
  yes: options.yes,
4437
- force: options.force
4455
+ force: options.force,
4456
+ fromDir: options.fromDir
4438
4457
  });
4439
4458
  } catch (err) {
4440
4459
  spinner.stop(import_picocolors.default.red("Plugin installation failed"));
@@ -4543,7 +4562,7 @@ async function runAdd(args, options = {}) {
4543
4562
  spinner.start("Downloading from portal...");
4544
4563
  const cfg = loadConfig();
4545
4564
  const portalUrl = cfg.portal;
4546
- const token = parsed.portalRef.startsWith("@teams/") ? cfg.token : void 0;
4565
+ const token = cfg.token;
4547
4566
  let archive;
4548
4567
  try {
4549
4568
  archive = await fetchSkillArchive(parsed.portalRef, portalUrl, token);
@@ -5227,7 +5246,10 @@ function parseAddOptions(args) {
5227
5246
  }
5228
5247
  i--;
5229
5248
  } else if (arg === "--full-depth") options.fullDepth = true;
5230
- else if (arg === "--team") {
5249
+ else if (arg === "--from-dir") {
5250
+ i++;
5251
+ options.fromDir = args[i];
5252
+ } else if (arg === "--team") {
5231
5253
  i++;
5232
5254
  options.team = args[i];
5233
5255
  } else if (arg === "--dangerously-accept-openclaw-risks") options.dangerouslyAcceptOpenclawRisks = true;
@@ -6865,6 +6887,8 @@ ${BOLD}Add Options:${RESET}
6865
6887
  (no positional source; mutually exclusive with <source>)
6866
6888
  --all Shorthand for --skill '*' --agent '*' -y
6867
6889
  --full-depth Search all subdirectories even when a root SKILL.md exists
6890
+ --from-dir <path> Install a plugin from an already-extracted local directory
6891
+ instead of downloading it from the portal (plugin refs only)
6868
6892
 
6869
6893
  ${BOLD}Remove Options:${RESET}
6870
6894
  -a, --agent <agents> Restrict cleanup to specific agents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-ai-dev-cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
5
5
  "type": "module",
6
6
  "bin": {