shoplazza-ai-dev-cli 0.1.18 → 0.1.19

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.
@@ -1,5 +1,5 @@
1
1
  import { loadConfig, runLogin } from "../cli.mjs";
2
- import { readFileSync } from "fs";
2
+ import { readFileSync, readSync } from "fs";
3
3
  function parseGlobalFlags(args) {
4
4
  const flags = { json: false };
5
5
  const rest = [];
@@ -58,6 +58,30 @@ function parseNamedArgs(args) {
58
58
  named
59
59
  };
60
60
  }
61
+ const STDIN_READ_CHUNK_BYTES = 64 * 1024;
62
+ const STDIN_EAGAIN_WAIT_MS = 5;
63
+ function readAllFd(fd = 0) {
64
+ const chunks = [];
65
+ const buf = Buffer.allocUnsafe(STDIN_READ_CHUNK_BYTES);
66
+ const idle = new Int32Array(new SharedArrayBuffer(4));
67
+ for (;;) {
68
+ let bytesRead;
69
+ try {
70
+ bytesRead = readSync(fd, buf, 0, buf.length, null);
71
+ } catch (err) {
72
+ const code = err.code;
73
+ if (code === "EAGAIN" || code === "EWOULDBLOCK") {
74
+ Atomics.wait(idle, 0, 0, STDIN_EAGAIN_WAIT_MS);
75
+ continue;
76
+ }
77
+ if (code === "EOF") break;
78
+ throw err;
79
+ }
80
+ if (bytesRead === 0) break;
81
+ chunks.push(Buffer.from(buf.subarray(0, bytesRead)));
82
+ }
83
+ return Buffer.concat(chunks).toString("utf-8");
84
+ }
61
85
  function readFileInput(filePath) {
62
86
  if (filePath === "-") {
63
87
  if (process.stdin.isTTY) {
@@ -65,8 +89,7 @@ function readFileInput(filePath) {
65
89
  process.exitCode = 2;
66
90
  throw new Error("missing --file");
67
91
  }
68
- const raw = readFileSync(0, "utf-8");
69
- return JSON.parse(raw);
92
+ return JSON.parse(readAllFd());
70
93
  }
71
94
  const raw = readFileSync(filePath, "utf-8");
72
95
  return JSON.parse(raw);
@@ -519,22 +542,80 @@ const VALID_USER_KINDS = [
519
542
  "baseline",
520
543
  "custom"
521
544
  ];
522
- async function list$1(client, args, json) {
523
- const { named } = parseNamedArgs(args);
545
+ function buildListParams(named) {
524
546
  const params = {};
525
547
  for (const k of [
526
548
  "q",
527
549
  "module-id",
528
550
  "type",
529
551
  "priority",
552
+ "automation-status",
530
553
  "page",
531
554
  "size"
532
555
  ]) {
533
- const apiKey = k === "module-id" ? "module_id" : k === "type" ? "case_type" : k;
556
+ const apiKey = k === "module-id" ? "module_id" : k === "type" ? "case_type" : k === "automation-status" ? "automation_status" : k;
534
557
  const v = named[k];
535
558
  const val = Array.isArray(v) ? v[v.length - 1] : v;
536
559
  if (typeof val === "string") params[apiKey] = val;
537
560
  }
561
+ return params;
562
+ }
563
+ const LIST_PAGE_CAP = 200;
564
+ async function list$1(client, args, json) {
565
+ const { named } = parseNamedArgs(args);
566
+ const params = buildListParams(named);
567
+ if (named["all"] === "true") {
568
+ delete params["page"];
569
+ delete params["size"];
570
+ const items = [];
571
+ let total = 0;
572
+ for (let page = 1;; page++) {
573
+ const data = await client.get("/api/test/cases", {
574
+ ...params,
575
+ page: String(page),
576
+ size: String(LIST_PAGE_CAP)
577
+ });
578
+ const batch = data.items ?? [];
579
+ items.push(...batch);
580
+ total = data.total;
581
+ if (items.length >= total || batch.length === 0) break;
582
+ }
583
+ const merged = {
584
+ items,
585
+ total
586
+ };
587
+ if (json) {
588
+ printJson(merged);
589
+ return;
590
+ }
591
+ printTable(items, [
592
+ {
593
+ key: "case_id",
594
+ label: "Case ID"
595
+ },
596
+ {
597
+ key: "title",
598
+ label: "Title"
599
+ },
600
+ {
601
+ key: "case_type",
602
+ label: "Type",
603
+ width: 5
604
+ },
605
+ {
606
+ key: "priority",
607
+ label: "Pri",
608
+ width: 4
609
+ },
610
+ {
611
+ key: "automation_status",
612
+ label: "Auto",
613
+ width: 10
614
+ }
615
+ ]);
616
+ printPagination(total);
617
+ return;
618
+ }
538
619
  const data = await client.get("/api/test/cases", params);
539
620
  if (json) {
540
621
  printJson(data);
@@ -761,7 +842,7 @@ async function runCases(client, args, json) {
761
842
  case "--help":
762
843
  case "-h":
763
844
  case void 0:
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])`);
845
+ console.log(`cases commands:\n list List cases with filters (--q --module-id --type --priority --automation-status --page --size; --all to fetch every page)\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])`);
765
846
  return;
766
847
  default:
767
848
  printError(`Unknown cases action: ${action}`);
@@ -975,7 +1056,7 @@ function validatePlanCreateMatrix(planType, src) {
975
1056
  if (!src.reqId || !src.caseIds || src.fromSet) return "type=smoke 必须同时提供 --req-id 与 --case-ids(测试员手选),不接受 --from-set";
976
1057
  return null;
977
1058
  case "regression":
978
- if (!src.fromSet || src.reqId) return "type=regression 只接受 --from-set(全局用例集),可选 --case-ids 建子集回归,不接受 --req-id";
1059
+ if (!src.fromSet || src.reqId) return "type=regression 只接受 --from-set(全局集,或需求规范集配 --case-ids),可选 --case-ids 建子集回归,不接受 --req-id";
979
1060
  return null;
980
1061
  default: return `Invalid type "${planType}"`;
981
1062
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shoplazza-ai-dev-cli",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Shoplazza AI Dev CLI: install, publish and manage AI agent skills/rules",
5
5
  "type": "module",
6
6
  "bin": {