qatools-cli 1.2.4 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/qatools.js +92 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qatools-cli",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "CLI for QA Tools — requirements, epics, sprints, sessions, App Context sync, project agenda. The companion to qa-tools.com.",
5
5
  "scripts": {
6
6
  "release": "npm version patch --no-git-tag-version && npm publish",
package/qatools.js CHANGED
@@ -703,6 +703,79 @@ program
703
703
  }
704
704
  });
705
705
 
706
+ // ─── Compliance per sprint (compliance.sprint-verification-via-cli) ─────────
707
+
708
+ // Commits and changed files since a date, from the git repo in the current directory ("" if none).
709
+ function gitChangesSince(date) {
710
+ if (!date) return { commits: [], files: [] };
711
+ const git = (args) => { try { return require("child_process").execSync(`git ${args}`, { stdio: ["ignore", "pipe", "ignore"], maxBuffer: 32 * 1024 * 1024 }).toString(); } catch { return ""; } };
712
+ const commits = git(`log --since=${date} --pretty=format:%h%x09%s`).split("\n").filter(Boolean);
713
+ const files = [...new Set(git(`log --since=${date} --name-only --pretty=format:`).split("\n").map(s => s.trim()).filter(Boolean))].sort();
714
+ return { commits, files };
715
+ }
716
+
717
+ program
718
+ .command("compliance-check")
719
+ .description("List the sprint's continuous compliance requirements, their verification status and the git changes since the sprint started (run in the repo)")
720
+ .option("--sprint <id>", "Sprint ID (default: the active sprint)")
721
+ .option("--json", "Output JSON (for Claude / CI)")
722
+ .option("--project <id>", "Target project ID (overrides default)")
723
+ .option("-e, --email <email>", "Login email")
724
+ .option("-p, --password <password>", "Login password")
725
+ .action(async (options) => {
726
+ await authenticate(options);
727
+ const creds = getCredentials();
728
+ const projectId = options.project || creds?.projectId;
729
+ if (!projectId) { console.error("No project configured. Run: qatools setup, or pass --project <id>"); process.exit(1); }
730
+ try {
731
+ const res = (await httpsCallable(functions, "listComplianceDue")({ projectId, sprintId: options.sprint || null })).data;
732
+ const changes = gitChangesSince(res.sprint.startDate);
733
+ if (options.json) { console.log(JSON.stringify({ ...res, changes }, null, 2)); process.exit(0); }
734
+ const done = res.requirements.filter(r => r.verification).length;
735
+ console.log(`Sprint ${res.sprint.name} [${res.sprint.status}] ${res.sprint.startDate || "?"} → ${res.sprint.releaseDate || "?"}: ${done}/${res.requirements.length} compliance requirement(s) verified\n`);
736
+ for (const r of res.requirements) {
737
+ const st = r.verification ? (r.verification.result === "passed" ? "✓ passed" : "✗ failed") : "… to verify";
738
+ console.log(` ${st.padEnd(13)} [${r.key}] ${r.title}`);
739
+ }
740
+ console.log(`\nChanges since ${res.sprint.startDate || "(no start date)"}: ${changes.commits.length} commit(s), ${changes.files.length} file(s)${changes.files.length ? "" : " — run inside the repo to see them"}.`);
741
+ for (const f of changes.files.slice(0, 40)) console.log(` ${f}`);
742
+ if (changes.files.length > 40) console.log(` … (+${changes.files.length - 40}, use --json for all)`);
743
+ console.log(`\nRecord each result: qatools compliance-record --key <key> --result passed|failed --evidence "<what you checked, file:line>"`);
744
+ } catch (e) {
745
+ console.error("Failed:", e.message);
746
+ process.exit(1);
747
+ }
748
+ process.exit(0);
749
+ });
750
+
751
+ program
752
+ .command("compliance-record")
753
+ .description("Record a compliance requirement's verification for the sprint (evidence required). failed creates an AVV signal.")
754
+ .requiredOption("--key <requirementKey>", "Compliance requirement key")
755
+ .requiredOption("--result <result>", "passed or failed")
756
+ .requiredOption("--evidence <text>", "What was checked in the sprint's diff and what was found (file:line), min 10 chars")
757
+ .option("--sprint <id>", "Sprint ID (default: the active sprint)")
758
+ .option("--commit <sha>", "Commit checked (default: git HEAD)")
759
+ .option("--project <id>", "Target project ID (overrides default)")
760
+ .option("-e, --email <email>", "Login email")
761
+ .option("-p, --password <password>", "Login password")
762
+ .action(async (options) => {
763
+ await authenticate(options);
764
+ const creds = getCredentials();
765
+ const projectId = options.project || creds?.projectId;
766
+ if (!projectId) { console.error("No project configured. Run: qatools setup, or pass --project <id>"); process.exit(1); }
767
+ let commit = options.commit || "";
768
+ if (!commit) { try { commit = require("child_process").execSync("git rev-parse HEAD", { stdio: ["ignore", "pipe", "ignore"] }).toString().trim(); } catch { /* not a repo */ } }
769
+ try {
770
+ const res = (await httpsCallable(functions, "recordSprintVerification")({ projectId, sprintId: options.sprint || null, requirementKey: options.key, result: options.result, evidence: options.evidence, commit })).data;
771
+ console.log(`Recorded ${res.requirementKey}: ${res.result} for sprint ${res.sprintName}${res.signal ? ` — signal ${res.signal}` : ""}.`);
772
+ } catch (e) {
773
+ console.error("Failed:", e.message);
774
+ process.exit(1);
775
+ }
776
+ process.exit(0);
777
+ });
778
+
706
779
  program
707
780
  .command("agenda-run-prompt")
708
781
  .description("Print the unattended daily-agenda-run instructions, for: claude -p \"$(qatools agenda-run-prompt)\"")
@@ -3644,6 +3717,24 @@ const mcpTools = [
3644
3717
  inputSchema: mcpSchema({ status: mcpStr("Filter by status", { enum: ["pending", "approved", "rejected"] }) }),
3645
3718
  run: async (a) => (await mcpCall("listPlanProposals", { projectId: a.projectId, status: a.status || null })).proposals,
3646
3719
  },
3720
+ {
3721
+ name: "list_compliance_due",
3722
+ description: "The sprint's continuous compliance requirements (non-functional, active epic) with their verification status for the sprint, including acceptance criteria / verification method. Check each against the sprint's diff (git log --since <startDate> in the repo), then record_compliance_verification.",
3723
+ inputSchema: mcpSchema({ sprintId: mcpStr("Sprint ID (default: the active sprint)") }),
3724
+ run: async (a) => mcpCall("listComplianceDue", { projectId: a.projectId, sprintId: a.sprintId || null }),
3725
+ },
3726
+ {
3727
+ name: "record_compliance_verification",
3728
+ description: "Record the result of checking a compliance requirement against the sprint's diff. Evidence is required (what was checked, file:line). failed creates an AVV signal (deduplicated). Not available to propose-only keys.",
3729
+ inputSchema: mcpSchema({
3730
+ requirementKey: mcpStr("Compliance requirement key"),
3731
+ result: mcpStr("passed or failed", { enum: ["passed", "failed"] }),
3732
+ evidence: mcpStr("What was checked in the sprint's diff and what was found (file:line), min 10 chars"),
3733
+ sprintId: mcpStr("Sprint ID (default: the active sprint)"),
3734
+ commit: mcpStr("Commit checked"),
3735
+ }, ["requirementKey", "result", "evidence"]),
3736
+ run: async (a) => mcpCall("recordSprintVerification", { projectId: a.projectId, ...mcpPick(a, ["requirementKey", "result", "evidence", "sprintId", "commit"]) }),
3737
+ },
3647
3738
  {
3648
3739
  name: "notify_owner",
3649
3740
  description: "Email the project owner (respects their opt-out). Used for the summary at the end of a scheduled agenda run. Plain text.",
@@ -3805,7 +3896,7 @@ Work through these steps, then stop:
3805
3896
  1. get_agenda. This is your task list.
3806
3897
  2. Sessions awaiting analysis: for each, read_session and compare every FEL result against its requirement (list_requirements). Upload your analysis with upload_analysis — backlogUpdates may only contain comments. For a real deviation not already on the backlog (check list_backlog by requirementKey), create_backlog_item with type bug (AVV), requirement_gap (GAP) or technical_defect (DEF) and the requirementKey. Cite the test and expected vs actual; never speculate.
3807
3898
  3. Planning: list_plan_proposals with status pending. If one created by Claude is already pending, do NOT create another — mention it in the summary. Otherwise, if there are approved functional requirements without a sprint and sprints that are not completed, follow the plan_sprints procedure (sprint_velocity, epic dependsOn, priority) and save the result with propose_sprint_plan.
3808
- 4. Approved requirements without tests and continuous requirements due this sprint: do not act, just count them for the summary.
3899
+ 4. Approved requirements without tests (from the agenda) and compliance requirements still unverified this sprint (list_compliance_due): do not act — a propose-only key can't record verifications — just count them and name the unverified compliance keys in the summary.
3809
3900
  5. Finish with notify_owner. Subject: "qa-tools daily run: <project> — <n> to review". Body, plain text, short:
3810
3901
  - what you analysed and which signals you created (labels),
3811
3902
  - the plan proposal you saved (or why none),