shoplazza-ai-dev-cli 0.1.6-snapshot.5 → 0.1.7-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.
@@ -0,0 +1,831 @@
1
+ import { loadConfig, runLogin } from "../cli.mjs";
2
+ import { readFileSync } from "fs";
3
+ function parseGlobalFlags(args) {
4
+ const flags = { json: false };
5
+ const rest = [];
6
+ for (let i = 0; i < args.length; i++) {
7
+ const a = args[i];
8
+ if (a === "--json") {
9
+ flags.json = true;
10
+ continue;
11
+ }
12
+ if (a === "--portal" && args[i + 1]) {
13
+ flags.portal = args[++i];
14
+ continue;
15
+ }
16
+ if (a === "--file" && args[i + 1]) {
17
+ flags.file = args[++i];
18
+ continue;
19
+ }
20
+ if (a === "--page" && args[i + 1]) {
21
+ flags.page = Number(args[++i]);
22
+ continue;
23
+ }
24
+ if (a === "--size" && args[i + 1]) {
25
+ flags.size = Number(args[++i]);
26
+ continue;
27
+ }
28
+ rest.push(a);
29
+ }
30
+ return {
31
+ flags,
32
+ rest
33
+ };
34
+ }
35
+ function parseNamedArgs(args) {
36
+ const positional = [];
37
+ const named = {};
38
+ for (let i = 0; i < args.length; i++) {
39
+ const a = args[i];
40
+ if (a.startsWith("--") && a.includes("=")) {
41
+ const eqIdx = a.indexOf("=");
42
+ const key = a.slice(2, eqIdx);
43
+ const val = a.slice(eqIdx + 1);
44
+ const existing = named[key];
45
+ if (existing !== void 0) named[key] = Array.isArray(existing) ? [...existing, val] : [existing, val];
46
+ else named[key] = val;
47
+ } else if (a.startsWith("--") && args[i + 1] && !args[i + 1].startsWith("--")) {
48
+ const key = a.slice(2);
49
+ const val = args[++i];
50
+ const existing = named[key];
51
+ if (existing !== void 0) named[key] = Array.isArray(existing) ? [...existing, val] : [existing, val];
52
+ else named[key] = val;
53
+ } else if (a.startsWith("--")) named[a.slice(2)] = "true";
54
+ else positional.push(a);
55
+ }
56
+ return {
57
+ positional,
58
+ named
59
+ };
60
+ }
61
+ function readFileInput(filePath) {
62
+ if (filePath === "-") {
63
+ if (process.stdin.isTTY) {
64
+ console.error("✗ --file - requires piped input (e.g., echo '...' | cli test ...)");
65
+ process.exitCode = 2;
66
+ throw new Error("missing --file");
67
+ }
68
+ const raw = readFileSync(0, "utf-8");
69
+ return JSON.parse(raw);
70
+ }
71
+ const raw = readFileSync(filePath, "utf-8");
72
+ return JSON.parse(raw);
73
+ }
74
+ function requireArg(named, key, label) {
75
+ const v = named[key];
76
+ if (!v || Array.isArray(v)) {
77
+ console.error(`✗ Missing required flag: --${key} <${label}>`);
78
+ process.exitCode = 2;
79
+ throw new Error(`missing --${key}`);
80
+ }
81
+ return v;
82
+ }
83
+ function asArray(v) {
84
+ if (!v) return [];
85
+ return Array.isArray(v) ? v : v.split(",").map((s) => s.trim()).filter(Boolean);
86
+ }
87
+ const RESET = "\x1B[0m";
88
+ const GREEN = "\x1B[32m";
89
+ const RED = "\x1B[31m";
90
+ const DIM = "\x1B[38;5;102m";
91
+ function printJson(data) {
92
+ console.log(JSON.stringify(data, null, 2));
93
+ }
94
+ function printSuccess(msg) {
95
+ console.log(`${GREEN}✓${RESET} ${msg}`);
96
+ }
97
+ function printError(msg) {
98
+ console.error(`${RED}✗${RESET} ${msg}`);
99
+ }
100
+ function printKV(pairs) {
101
+ for (const [k, v] of pairs) console.log(` ${DIM}${k}:${RESET} ${v}`);
102
+ }
103
+ function printTable(rows, cols) {
104
+ if (rows.length === 0) {
105
+ console.log(" (no items)");
106
+ return;
107
+ }
108
+ const widths = cols.map((c) => Math.max(c.label.length, ...rows.map((r) => String(r[c.key] ?? "").length), c.width ?? 0));
109
+ console.log(cols.map((c, i) => c.label.padEnd(widths[i])).join(" "));
110
+ console.log(cols.map((_, i) => "─".repeat(widths[i])).join(" "));
111
+ for (const r of rows) console.log(cols.map((c, i) => String(r[c.key] ?? "").padEnd(widths[i])).join(" "));
112
+ }
113
+ function printPagination(total) {
114
+ console.log(`${DIM}(${total} items)${RESET}`);
115
+ }
116
+ var ApiError = class extends Error {
117
+ status;
118
+ code;
119
+ data;
120
+ constructor(status, code, message, data) {
121
+ super(message);
122
+ this.status = status;
123
+ this.code = code;
124
+ this.data = data;
125
+ }
126
+ };
127
+ var TestPlatformClient = class TestPlatformClient {
128
+ baseUrl;
129
+ token;
130
+ interactive;
131
+ constructor(baseUrl, token, interactive) {
132
+ this.baseUrl = baseUrl;
133
+ this.token = token;
134
+ this.interactive = interactive;
135
+ }
136
+ static fromConfig(portalOverride, jsonMode = false) {
137
+ const cfg = loadConfig();
138
+ return new TestPlatformClient((portalOverride ?? cfg.portal).replace(/\/$/, ""), cfg.token ?? "", !jsonMode && (process.stdout.isTTY ?? false));
139
+ }
140
+ async get(path, params) {
141
+ let url = `${this.baseUrl}${path}`;
142
+ if (params) {
143
+ const qs = Object.entries(params).filter(([, v]) => v).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join("&");
144
+ if (qs) url += `?${qs}`;
145
+ }
146
+ return this.request("GET", url);
147
+ }
148
+ async post(path, body) {
149
+ return this.request("POST", `${this.baseUrl}${path}`, body);
150
+ }
151
+ async patch(path, body) {
152
+ return this.request("PATCH", `${this.baseUrl}${path}`, body);
153
+ }
154
+ async delete(path) {
155
+ return this.request("DELETE", `${this.baseUrl}${path}`);
156
+ }
157
+ async request(method, url, body) {
158
+ const headers = {
159
+ "Authorization": `Bearer ${this.token}`,
160
+ "Accept": "application/json"
161
+ };
162
+ if (body !== void 0) headers["Content-Type"] = "application/json";
163
+ let resp = await fetch(url, {
164
+ method,
165
+ headers,
166
+ body: body !== void 0 ? JSON.stringify(body) : void 0
167
+ });
168
+ if (resp.status === 401 && this.interactive) {
169
+ await resp.arrayBuffer().catch(() => void 0);
170
+ await runLogin({ force: true });
171
+ const refreshed = loadConfig().token;
172
+ if (refreshed) {
173
+ this.token = refreshed;
174
+ headers["Authorization"] = `Bearer ${refreshed}`;
175
+ resp = await fetch(url, {
176
+ method,
177
+ headers,
178
+ body: body !== void 0 ? JSON.stringify(body) : void 0
179
+ });
180
+ }
181
+ }
182
+ if (resp.status === 204) return void 0;
183
+ const contentType = resp.headers.get("Content-Type") ?? "";
184
+ let payload = null;
185
+ if (contentType.includes("application/json")) try {
186
+ payload = await resp.json();
187
+ } catch {
188
+ payload = null;
189
+ }
190
+ if (!resp.ok) {
191
+ if (payload === null) {
192
+ const preview = (await resp.text().catch(() => "")).slice(0, 200);
193
+ throw new ApiError(resp.status, `HTTP_${resp.status}`, preview || `HTTP ${resp.status}`);
194
+ }
195
+ const errObj = payload && typeof payload === "object" && payload !== null && "error" in payload ? payload.error : null;
196
+ const code = errObj && typeof errObj === "object" && errObj !== null && "code" in errObj ? String(errObj.code) : `HTTP_${resp.status}`;
197
+ const message = errObj && typeof errObj === "object" && errObj !== null && "message" in errObj ? String(errObj.message) : typeof errObj === "string" ? errObj : `HTTP ${resp.status}`;
198
+ throw new ApiError(resp.status, code, message, payload);
199
+ }
200
+ return payload;
201
+ }
202
+ };
203
+ function ensureLoggedIn() {
204
+ if (!loadConfig().token) {
205
+ printError("Not logged in. Run `shoplazza-ai-dev-cli login` first.");
206
+ process.exitCode = 1;
207
+ throw new Error("not logged in");
208
+ }
209
+ }
210
+ async function listBL(client, json) {
211
+ const data = await client.get("/org/business-lines");
212
+ if (json) {
213
+ printJson(data);
214
+ return;
215
+ }
216
+ printTable(data.items, [{
217
+ key: "id",
218
+ label: "ID",
219
+ width: 4
220
+ }, {
221
+ key: "name",
222
+ label: "Name"
223
+ }]);
224
+ printPagination(data.total);
225
+ }
226
+ async function listModules(client, args, json) {
227
+ const { named } = parseNamedArgs(args);
228
+ const blId = requireArg(named, "bl", "business_line_id");
229
+ const q = typeof named["q"] === "string" ? named["q"] : void 0;
230
+ const params = {};
231
+ if (q) params["q"] = q;
232
+ const data = await client.get(`/org/business-lines/${blId}/modules`, params);
233
+ if (json) {
234
+ printJson(data);
235
+ return;
236
+ }
237
+ printTable(data.items, [
238
+ {
239
+ key: "id",
240
+ label: "ID",
241
+ width: 4
242
+ },
243
+ {
244
+ key: "name",
245
+ label: "Name"
246
+ },
247
+ {
248
+ key: "full_path",
249
+ label: "Full Path"
250
+ },
251
+ {
252
+ key: "depth",
253
+ label: "Depth",
254
+ width: 5
255
+ }
256
+ ]);
257
+ printPagination(data.total);
258
+ }
259
+ async function runTaxonomy(client, args, json) {
260
+ const action = args[0];
261
+ const subArgs = args.slice(1);
262
+ switch (action) {
263
+ case "list-bl": return listBL(client, json);
264
+ case "list-modules": return listModules(client, subArgs, json);
265
+ case "--help":
266
+ case "-h":
267
+ case void 0:
268
+ console.log(`taxonomy commands:\n list-bl List product lines\n list-modules List modules (--bl <id> [--q <keyword>])`);
269
+ return;
270
+ default:
271
+ printError(`Unknown taxonomy action: ${action}`);
272
+ process.exitCode = 2;
273
+ }
274
+ }
275
+ async function create$4(client, args, json) {
276
+ const { named } = parseNamedArgs(args);
277
+ const reqId = requireArg(named, "req-id", "req_id");
278
+ const title = requireArg(named, "title", "title");
279
+ const bl = typeof named["bl"] === "string" ? named["bl"] : void 0;
280
+ const modulePaths = asArray(named["module-paths"]);
281
+ const feishuUrl = typeof named["feishu-url"] === "string" ? named["feishu-url"] : void 0;
282
+ const body = {
283
+ req_id: reqId,
284
+ title
285
+ };
286
+ if (bl) body["business_line"] = bl;
287
+ if (modulePaths.length) body["module_paths"] = modulePaths;
288
+ if (feishuUrl) body["feishu_ticket_url"] = feishuUrl;
289
+ const data = await client.post("/api/test/requirements", body);
290
+ if (json) {
291
+ printJson(data);
292
+ return;
293
+ }
294
+ if (data["created"]) {
295
+ printSuccess(`Requirement created: ${data["req_id"]}`);
296
+ printKV([["Title", data["title"]], ["Status", data["status"]]]);
297
+ console.log(" (case set auto-created)");
298
+ } else console.log(`ℹ Requirement already exists: ${data["req_id"]} (not modified)`);
299
+ }
300
+ async function sync(client, args, json) {
301
+ const { positional, named } = parseNamedArgs(args);
302
+ const reqId = positional[0];
303
+ if (!reqId) {
304
+ printError("Usage: test requirements sync <req_id> --file <path>");
305
+ process.exitCode = 2;
306
+ return;
307
+ }
308
+ const payload = readFileInput(requireArg(named, "file", "path"));
309
+ const data = await client.post(`/api/test/requirements/${encodeURIComponent(reqId)}/cases:sync`, payload);
310
+ if (json) {
311
+ printJson(data);
312
+ return;
313
+ }
314
+ const s = data.summary;
315
+ printSuccess(`Synced ${(s["created"] ?? 0) + (s["referenced"] ?? 0) + (s["updated"] ?? 0)} cases to ${reqId}`);
316
+ printKV([
317
+ ["Created", `${s["created"] ?? 0}${data.results.filter((r) => r.action === "created").map((r) => ` (${r.case_id})`).join("")}`],
318
+ ["Referenced", s["referenced"] ?? 0],
319
+ ["Updated", s["updated"] ?? 0],
320
+ ["Unlinked", s["unlinked"] ?? 0],
321
+ ["Failed", s["failed"] ?? 0]
322
+ ]);
323
+ for (const r of data.results.filter((r) => r.action === "failed")) printError(` ${r.client_ref}: ${(r.errors ?? []).join(", ")}`);
324
+ }
325
+ async function list$2(client, args, json) {
326
+ const { named } = parseNamedArgs(args);
327
+ const params = {};
328
+ for (const k of [
329
+ "q",
330
+ "status",
331
+ "page",
332
+ "size"
333
+ ]) {
334
+ const v = named[k];
335
+ const val = Array.isArray(v) ? v[v.length - 1] : v;
336
+ if (typeof val === "string") params[k] = val;
337
+ }
338
+ const data = await client.get("/api/test/requirements", params);
339
+ if (json) {
340
+ printJson(data);
341
+ return;
342
+ }
343
+ printTable(data.items, [
344
+ {
345
+ key: "req_id",
346
+ label: "Req ID"
347
+ },
348
+ {
349
+ key: "title",
350
+ label: "Title"
351
+ },
352
+ {
353
+ key: "status",
354
+ label: "Status",
355
+ width: 8
356
+ }
357
+ ]);
358
+ printPagination(data.total);
359
+ }
360
+ async function runRequirements(client, args, json) {
361
+ const action = args[0];
362
+ const subArgs = args.slice(1);
363
+ switch (action) {
364
+ case "create": return create$4(client, subArgs, json);
365
+ case "sync": return sync(client, subArgs, json);
366
+ case "list": return list$2(client, subArgs, json);
367
+ case "--help":
368
+ case "-h":
369
+ case void 0:
370
+ console.log(`requirements commands:\n create Create a requirement\n sync Sync cases to requirement (channel 1)\n list List requirements`);
371
+ return;
372
+ default:
373
+ printError(`Unknown requirements action: ${action}`);
374
+ process.exitCode = 2;
375
+ }
376
+ }
377
+ async function create$3(client, args, json) {
378
+ const { named } = parseNamedArgs(args);
379
+ const body = {
380
+ title: requireArg(named, "title", "title"),
381
+ business_line: requireArg(named, "bl", "business_line"),
382
+ module_path: requireArg(named, "module-path", "module_path"),
383
+ case_type: requireArg(named, "type", "case_type"),
384
+ expected: requireArg(named, "expected", "expected"),
385
+ steps: Array.isArray(named["steps"]) ? named["steps"] : named["steps"] ? [named["steps"]] : []
386
+ };
387
+ if (typeof named["priority"] === "string") body["priority"] = named["priority"];
388
+ if (typeof named["precondition"] === "string") body["precondition"] = named["precondition"];
389
+ if (typeof named["source"] === "string") body["source"] = named["source"];
390
+ const tags = asArray(named["tags"]);
391
+ if (tags.length) body["tags"] = tags;
392
+ if (!body["steps"] || body["steps"].length === 0) {
393
+ printError("At least one --steps required");
394
+ process.exitCode = 2;
395
+ return;
396
+ }
397
+ const data = await client.post("/api/test/cases", body);
398
+ if (json) {
399
+ printJson(data);
400
+ return;
401
+ }
402
+ printSuccess(`Case created: ${data["case_id"]}`);
403
+ printKV([
404
+ ["Title", data["title"]],
405
+ ["Module", `${data["module_path"] ?? `id=${data["module_id"]}`}`],
406
+ ["Type", data["case_type"]],
407
+ ["Priority", data["priority"] || "—"]
408
+ ]);
409
+ }
410
+ async function list$1(client, args, json) {
411
+ const { named } = parseNamedArgs(args);
412
+ const params = {};
413
+ for (const k of [
414
+ "q",
415
+ "module-id",
416
+ "type",
417
+ "priority",
418
+ "page",
419
+ "size"
420
+ ]) {
421
+ const apiKey = k === "module-id" ? "module_id" : k === "type" ? "case_type" : k;
422
+ const v = named[k];
423
+ const val = Array.isArray(v) ? v[v.length - 1] : v;
424
+ if (typeof val === "string") params[apiKey] = val;
425
+ }
426
+ const data = await client.get("/api/test/cases", params);
427
+ if (json) {
428
+ printJson(data);
429
+ return;
430
+ }
431
+ printTable(data.items, [
432
+ {
433
+ key: "case_id",
434
+ label: "Case ID"
435
+ },
436
+ {
437
+ key: "title",
438
+ label: "Title"
439
+ },
440
+ {
441
+ key: "case_type",
442
+ label: "Type",
443
+ width: 5
444
+ },
445
+ {
446
+ key: "priority",
447
+ label: "Pri",
448
+ width: 4
449
+ },
450
+ {
451
+ key: "automation_status",
452
+ label: "Auto",
453
+ width: 10
454
+ }
455
+ ]);
456
+ printPagination(data.total);
457
+ }
458
+ async function runCases(client, args, json) {
459
+ const action = args[0];
460
+ const subArgs = args.slice(1);
461
+ switch (action) {
462
+ case "create": return create$3(client, subArgs, json);
463
+ case "list": return list$1(client, subArgs, json);
464
+ case "--help":
465
+ case "-h":
466
+ case void 0:
467
+ console.log(`cases commands:\n create Create a standalone case\n list List cases with filters`);
468
+ return;
469
+ default:
470
+ printError(`Unknown cases action: ${action}`);
471
+ process.exitCode = 2;
472
+ }
473
+ }
474
+ async function create$2(client, args, json) {
475
+ const { named } = parseNamedArgs(args);
476
+ const body = {
477
+ name: requireArg(named, "name", "name"),
478
+ kind: requireArg(named, "kind", "regression|smoke|flow|baseline|custom|curated"),
479
+ selection_mode: "manual"
480
+ };
481
+ const data = await client.post("/api/test/case-sets", body);
482
+ if (json) {
483
+ printJson(data);
484
+ return;
485
+ }
486
+ printSuccess(`Case set created: ${data["id"]}`);
487
+ printKV([["Name", data["name"]], ["Kind", data["kind"]]]);
488
+ }
489
+ async function members(client, args, json) {
490
+ const { positional, named } = parseNamedArgs(args);
491
+ const setId = positional[0];
492
+ if (!setId) {
493
+ printError("Usage: test case-sets members <set_id> [--add ...] [--remove ...]");
494
+ process.exitCode = 2;
495
+ return;
496
+ }
497
+ const add = asArray(named["add"]);
498
+ const remove = asArray(named["remove"]);
499
+ if (!add.length && !remove.length) {
500
+ printError("Provide --add or --remove");
501
+ process.exitCode = 2;
502
+ return;
503
+ }
504
+ const body = {};
505
+ if (add.length) body["add"] = add;
506
+ if (remove.length) body["remove"] = remove;
507
+ const data = await client.post(`/api/test/case-sets/${setId}/members:batch`, body);
508
+ if (json) {
509
+ printJson(data);
510
+ return;
511
+ }
512
+ printSuccess(`Added ${data.added}, removed ${data.removed}, invalid: ${(data.invalid ?? []).length}`);
513
+ }
514
+ async function runCaseSets(client, args, json) {
515
+ const action = args[0];
516
+ const subArgs = args.slice(1);
517
+ switch (action) {
518
+ case "create": return create$2(client, subArgs, json);
519
+ case "members": return members(client, subArgs, json);
520
+ case "--help":
521
+ case "-h":
522
+ case void 0:
523
+ console.log(`case-sets commands:\n create Create a case set (--name, --kind)\n members Batch add/remove members (--add/--remove)`);
524
+ return;
525
+ default:
526
+ printError(`Unknown case-sets action: ${action}`);
527
+ process.exitCode = 2;
528
+ }
529
+ }
530
+ async function create$1(client, args, json) {
531
+ const { named } = parseNamedArgs(args);
532
+ const body = { type: requireArg(named, "type", "requirement|regression|smoke") };
533
+ if (typeof named["title"] === "string") body["title"] = named["title"];
534
+ if (typeof named["from-set"] === "string") body["from_case_set"] = Number(named["from-set"]);
535
+ if (typeof named["case-ids"] === "string") body["case_ids"] = named["case-ids"].split(",").map((s) => s.trim());
536
+ if (typeof named["req-id"] === "string") body["req_id"] = named["req-id"];
537
+ if (typeof named["env"] === "string") body["env"] = named["env"];
538
+ const tags = asArray(named["tags"]);
539
+ if (tags.length) body["tags"] = tags;
540
+ if (body["from_case_set"] !== void 0 && body["case_ids"]) {
541
+ printError("--from-set and --case-ids are mutually exclusive");
542
+ process.exitCode = 2;
543
+ return;
544
+ }
545
+ const data = await client.post("/api/test/test-plans", body);
546
+ if (json) {
547
+ printJson(data);
548
+ return;
549
+ }
550
+ printSuccess(`Plan created: ${data["plan_id"]}`);
551
+ printKV([
552
+ ["Title", data["title"]],
553
+ ["Type", data["type"]],
554
+ ["Env", data["env"]],
555
+ ["Cases", data["case_count"]],
556
+ ["Status", data["status"]]
557
+ ]);
558
+ }
559
+ async function get(client, args, json) {
560
+ const { positional } = parseNamedArgs(args);
561
+ const planId = positional[0];
562
+ if (!planId) {
563
+ printError("Usage: test plans get <plan_id>");
564
+ process.exitCode = 2;
565
+ return;
566
+ }
567
+ const data = await client.get(`/api/test/test-plans/${encodeURIComponent(planId)}`);
568
+ if (json) {
569
+ printJson(data);
570
+ return;
571
+ }
572
+ printKV([
573
+ ["Plan ID", data["plan_id"]],
574
+ ["Title", data["title"]],
575
+ ["Type", data["type"]],
576
+ ["Env", data["env"]],
577
+ ["Status", data["status"]]
578
+ ]);
579
+ const progress = data["progress"];
580
+ if (progress) console.log(` Progress: ${progress["passed"]}p / ${progress["failed"]}f / ${progress["pending"]} pending (total ${progress["total"]})`);
581
+ const cases = data["cases"];
582
+ if (cases && cases.length) {
583
+ console.log(`\n Cases (${cases.length}):`);
584
+ for (const c of cases) console.log(` [${c["case_id"]}] ${c["title"]} (${c["priority"] || "—"})`);
585
+ }
586
+ }
587
+ async function list(client, args, json) {
588
+ const { named } = parseNamedArgs(args);
589
+ const params = {};
590
+ for (const k of [
591
+ "q",
592
+ "type",
593
+ "status",
594
+ "env",
595
+ "req-id",
596
+ "page",
597
+ "size"
598
+ ]) {
599
+ const apiKey = k === "req-id" ? "req_id" : k;
600
+ const v = named[k];
601
+ const val = Array.isArray(v) ? v[v.length - 1] : v;
602
+ if (typeof val === "string") params[apiKey] = val;
603
+ }
604
+ const data = await client.get("/api/test/test-plans", params);
605
+ if (json) {
606
+ printJson(data);
607
+ return;
608
+ }
609
+ printTable(data.items, [
610
+ {
611
+ key: "plan_id",
612
+ label: "Plan ID"
613
+ },
614
+ {
615
+ key: "title",
616
+ label: "Title"
617
+ },
618
+ {
619
+ key: "type",
620
+ label: "Type",
621
+ width: 12
622
+ },
623
+ {
624
+ key: "status",
625
+ label: "Status",
626
+ width: 6
627
+ },
628
+ {
629
+ key: "case_count",
630
+ label: "Cases",
631
+ width: 5
632
+ }
633
+ ]);
634
+ printPagination(data.total);
635
+ }
636
+ async function runPlans(client, args, json) {
637
+ const action = args[0];
638
+ const subArgs = args.slice(1);
639
+ switch (action) {
640
+ case "create": return create$1(client, subArgs, json);
641
+ case "get": return get(client, subArgs, json);
642
+ case "list": return list(client, subArgs, json);
643
+ case "--help":
644
+ case "-h":
645
+ case void 0:
646
+ console.log(`plans commands:\n create Create a test plan\n get Get plan detail (--json for full case content)\n list List plans`);
647
+ return;
648
+ default:
649
+ printError(`Unknown plans action: ${action}`);
650
+ process.exitCode = 2;
651
+ }
652
+ }
653
+ async function mark(client, args, json) {
654
+ const { positional, named } = parseNamedArgs(args);
655
+ const planId = positional[0];
656
+ const caseId = positional[1];
657
+ if (!planId || !caseId) {
658
+ printError("Usage: test results mark <plan_id> <case_id> --status <status>");
659
+ process.exitCode = 2;
660
+ return;
661
+ }
662
+ const body = {
663
+ plan_id: planId,
664
+ case_id: caseId,
665
+ status: requireArg(named, "status", "passed|failed|skipped|blocked")
666
+ };
667
+ if (typeof named["remark"] === "string") body["remark"] = named["remark"];
668
+ if (typeof named["evidence-url"] === "string") body["evidence_url"] = named["evidence-url"];
669
+ if (typeof named["duration-ms"] === "string") {
670
+ const n = Number(named["duration-ms"]);
671
+ if (Number.isNaN(n)) {
672
+ printError("--duration-ms must be a number");
673
+ process.exitCode = 2;
674
+ return;
675
+ }
676
+ body["duration_ms"] = n;
677
+ }
678
+ if (typeof named["executor"] === "string") body["executor"] = named["executor"];
679
+ const data = await client.post("/api/test/case-results", body);
680
+ if (json) {
681
+ printJson(data);
682
+ return;
683
+ }
684
+ printSuccess(`Marked ${caseId} as ${body["status"]} in ${planId}`);
685
+ const p = data["progress"];
686
+ if (p) console.log(` Progress: ${p["passed"]}/${p["total"]} passed, ${p["failed"]} failed, ${p["pending"]} pending`);
687
+ console.log(` Plan status: ${data["plan_status"]}`);
688
+ }
689
+ async function batch(client, args, json) {
690
+ const { positional, named } = parseNamedArgs(args);
691
+ const planId = positional[0];
692
+ if (!planId) {
693
+ printError("Usage: test results batch <plan_id> --file <path>");
694
+ process.exitCode = 2;
695
+ return;
696
+ }
697
+ const payload = readFileInput(requireArg(named, "file", "path"));
698
+ payload["plan_id"] = planId;
699
+ if (typeof named["executor"] === "string") payload["executor"] = named["executor"];
700
+ const data = await client.post("/api/test/case-results:batch", payload);
701
+ if (json) {
702
+ printJson(data);
703
+ return;
704
+ }
705
+ const invalid = data["invalid"];
706
+ printSuccess(`Batch submitted: ${data["marked"]} marked, ${(invalid ?? []).length} invalid`);
707
+ console.log(` Plan status: ${data["plan_status"]}`);
708
+ const p = data["progress"];
709
+ if (p) console.log(` Progress: ${p["passed"]} passed, ${p["failed"]} failed, ${p["pending"]} pending`);
710
+ }
711
+ async function runResults(client, args, json) {
712
+ const action = args[0];
713
+ const subArgs = args.slice(1);
714
+ switch (action) {
715
+ case "mark": return mark(client, subArgs, json);
716
+ case "batch": return batch(client, subArgs, json);
717
+ case "--help":
718
+ case "-h":
719
+ case void 0:
720
+ console.log(`results commands:\n mark Mark a single case result (Scenario A)\n batch Batch submit results from file (Scenario B)`);
721
+ return;
722
+ default:
723
+ printError(`Unknown results action: ${action}`);
724
+ process.exitCode = 2;
725
+ }
726
+ }
727
+ async function create(client, args, json) {
728
+ const { positional, named } = parseNamedArgs(args);
729
+ const planId = positional[0];
730
+ if (!planId) {
731
+ printError("Usage: test reports create <plan_id> [--conclusion <text>]");
732
+ process.exitCode = 2;
733
+ return;
734
+ }
735
+ const body = { plan_id: planId };
736
+ if (typeof named["type"] === "string") body["type"] = named["type"];
737
+ if (typeof named["conclusion"] === "string") body["conclusion"] = named["conclusion"];
738
+ if (typeof named["risk-notes"] === "string") body["risk_notes"] = named["risk-notes"];
739
+ const data = await client.post("/api/test/reports", body);
740
+ if (json) {
741
+ printJson(data);
742
+ return;
743
+ }
744
+ printSuccess(`Report issued: ${data["report_id"]} (version ${data["version"]})`);
745
+ console.log(` Plan: ${data["plan_id"]}`);
746
+ const snap = data["summary_snapshot"];
747
+ if (snap) {
748
+ const counts = snap["counts"];
749
+ if (counts) console.log(` Summary: ${counts["passed"]} passed, ${counts["failed"]} failed (total ${counts["total"]})`);
750
+ }
751
+ }
752
+ async function runReports(client, args, json) {
753
+ const action = args[0];
754
+ const subArgs = args.slice(1);
755
+ switch (action) {
756
+ case "create": return create(client, subArgs, json);
757
+ case "--help":
758
+ case "-h":
759
+ case void 0:
760
+ console.log(`reports commands:\n create Issue a report for a plan`);
761
+ return;
762
+ default:
763
+ printError(`Unknown reports action: ${action}`);
764
+ process.exitCode = 2;
765
+ }
766
+ }
767
+ const RESOURCES = {
768
+ taxonomy: runTaxonomy,
769
+ requirements: runRequirements,
770
+ cases: runCases,
771
+ "case-sets": runCaseSets,
772
+ plans: runPlans,
773
+ results: runResults,
774
+ reports: runReports
775
+ };
776
+ const HELP = `Testing platform commands (Scenario A & B).
777
+
778
+ Resources:
779
+ taxonomy Product lines & modules
780
+ cases Test case assets
781
+ requirements Requirements & channel 1 sync
782
+ case-sets Case set member management
783
+ plans Test plans & execution
784
+ results Test results (mark / batch)
785
+ reports Test reports
786
+
787
+ Run: shoplazza-ai-dev-cli test <resource> --help`;
788
+ async function runTest(rawArgs) {
789
+ const { flags, rest } = parseGlobalFlags(rawArgs);
790
+ const resource = rest[0];
791
+ const subArgs = rest.slice(1);
792
+ if (!resource || resource === "--help" || resource === "-h") {
793
+ console.log(HELP);
794
+ return;
795
+ }
796
+ ensureLoggedIn();
797
+ const client = TestPlatformClient.fromConfig(flags.portal, flags.json);
798
+ const handler = RESOURCES[resource];
799
+ if (!handler) {
800
+ printError(`Unknown resource: ${resource}`);
801
+ console.log(HELP);
802
+ process.exitCode = 2;
803
+ return;
804
+ }
805
+ try {
806
+ const passthrough = [];
807
+ if (flags.json) passthrough.push("--json");
808
+ if (flags.file) passthrough.push("--file", flags.file);
809
+ if (flags.page !== void 0) passthrough.push("--page", String(flags.page));
810
+ if (flags.size !== void 0) passthrough.push("--size", String(flags.size));
811
+ await handler(client, [...subArgs, ...passthrough], flags.json);
812
+ } catch (err) {
813
+ if (err && typeof err === "object" && "status" in err) {
814
+ const apiErr = err;
815
+ if (flags.json) console.log(JSON.stringify(apiErr.data ?? { error: {
816
+ code: apiErr.code,
817
+ message: apiErr.message
818
+ } }, null, 2));
819
+ else printError(`${apiErr.message}`);
820
+ process.exitCode = 1;
821
+ } else if (err instanceof Error && (err.message.startsWith("missing --") || err.message === "not logged in")) {} else if (err instanceof TypeError) {
822
+ if (flags.json) printJson({ error: {
823
+ code: "NETWORK_ERROR",
824
+ message: err.message
825
+ } });
826
+ else printError(`Network error: ${err.message}`);
827
+ process.exitCode = 1;
828
+ } else throw err;
829
+ }
830
+ }
831
+ export { runTest };
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
- if (entry.isDirectory()) await copyDirRecursive$1(s, d, {
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 (entry.isFile()) {
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, installPath) {
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
- execSync(`sqlite3 ${JSON.stringify(db)} "DELETE FROM ItemTable WHERE key LIKE 'agentData.cacheStorage.agentEnvironment.slashMenuItems%';"`, { stdio: "pipe" });
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: await commitPluginInstall({
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, true);
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
- version = JSON.parse(await readFile(join(pluginCanonical, "plugin.json"), "utf-8")).version ?? "0.0.0";
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 warn = (msg) => console.warn(`[forge] warning: ${msg}`);
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
- }).catch((e) => warn(`claude-code plugin registration failed: ${e instanceof Error ? e.message : String(e)}`));
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") && !opts.agents.includes("claude-code")) await registerCursorPlugin({
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 ledger;
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
- hook_type: opts.type,
5212
- ...opts.data
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
- 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(() => {});
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
@@ -6749,6 +6784,8 @@ function showBanner() {
6749
6784
  console.log();
6750
6785
  console.log(` ${DIM}$${RESET} ${TEXT}npx shoplazza-ai-dev-cli init ${DIM}[name]${RESET} ${DIM}Initialize a skill${RESET}`);
6751
6786
  console.log();
6787
+ console.log(` ${DIM}$${RESET} ${TEXT}npx shoplazza-ai-dev-cli test ${DIM}<resource> <action>${RESET} ${DIM}Testing platform commands${RESET}`);
6788
+ console.log();
6752
6789
  console.log(`${DIM}try:${RESET} npx shoplazza-ai-dev-cli add @public/skills --skill <name>`);
6753
6790
  console.log();
6754
6791
  }
@@ -6776,6 +6813,9 @@ ${BOLD}Project:${RESET}
6776
6813
  ${BOLD}Publishing:${RESET}
6777
6814
  publish <paths...> Publish skills to the forge portal
6778
6815
 
6816
+ ${BOLD}Testing:${RESET}
6817
+ test <resource> <action> Testing platform commands (Scenario A & B)
6818
+
6779
6819
  ${BOLD}Auth:${RESET}
6780
6820
  login Authenticate with the forge portal (browser OAuth)
6781
6821
 
@@ -7137,6 +7177,11 @@ async function main() {
7137
7177
  await runPublish(paths, publishOptions);
7138
7178
  break;
7139
7179
  }
7180
+ case "test": {
7181
+ const { runTest } = await import("./_chunks/test.mjs");
7182
+ await runTest(restArgs);
7183
+ break;
7184
+ }
7140
7185
  case "report-event":
7141
7186
  await runReportEvent(restArgs);
7142
7187
  break;
@@ -7158,4 +7203,4 @@ main().catch((err) => {
7158
7203
  console.error(`\n${BOLD}✗${RESET} ${msg}`);
7159
7204
  process.exitCode = 1;
7160
7205
  }).finally(() => flushTelemetry().then(() => process.exit(process.exitCode ?? 0)));
7161
- export {};
7206
+ export { loadConfig, runLogin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-ai-dev-cli",
3
- "version": "0.1.6-snapshot.5",
3
+ "version": "0.1.7-snapshot.0",
4
4
  "description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
5
5
  "type": "module",
6
6
  "bin": {