qatools-cli 1.2.13 → 1.2.15
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.
- package/package.json +4 -5
- package/qatools.js +98 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qatools-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
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",
|
|
@@ -21,10 +21,9 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"firebase": "^
|
|
24
|
+
"@firebase/app": "^0.13.2",
|
|
25
|
+
"@firebase/auth": "^1.10.8",
|
|
26
|
+
"@firebase/functions": "^0.12.9",
|
|
25
27
|
"commander": "^12.0.0"
|
|
26
|
-
},
|
|
27
|
-
"overrides": {
|
|
28
|
-
"@grpc/grpc-js": "^1.14.6"
|
|
29
28
|
}
|
|
30
29
|
}
|
package/qatools.js
CHANGED
|
@@ -1,13 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { program } = require("commander");
|
|
4
|
-
const { initializeApp } = require("firebase/app");
|
|
5
|
-
const { getAuth, signInWithEmailAndPassword, signInWithCustomToken } = require("firebase/auth");
|
|
6
|
-
const { getFunctions, httpsCallable, connectFunctionsEmulator } = require("firebase/functions");
|
|
4
|
+
const { initializeApp } = require("@firebase/app");
|
|
5
|
+
const { getAuth, signInWithEmailAndPassword, signInWithCustomToken } = require("@firebase/auth");
|
|
6
|
+
const { getFunctions, httpsCallable, connectFunctionsEmulator } = require("@firebase/functions");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const http = require("http");
|
|
10
10
|
|
|
11
|
+
// cli.stale-agent-warning: agents must not run on old rules without noticing.
|
|
12
|
+
const CLI_VERSION = require("./package.json").version;
|
|
13
|
+
const SKILLS_MARKER = ".qatools-skills-version";
|
|
14
|
+
const UPDATE_CHECK_FILE = ".qatools-update-check";
|
|
15
|
+
function versionLess(a, b) {
|
|
16
|
+
const pa = String(a).split(".").map(n => parseInt(n, 10) || 0), pb = String(b).split(".").map(n => parseInt(n, 10) || 0);
|
|
17
|
+
for (let i = 0; i < 3; i++) { if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) < (pb[i] || 0); }
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// The repo's qa-tools skills: the nearest .claude/skills (from cwd upwards) that holds qa-*.md files.
|
|
21
|
+
function findQaSkillsDir(start = process.cwd()) {
|
|
22
|
+
let dir = path.resolve(start);
|
|
23
|
+
for (;;) {
|
|
24
|
+
const d = path.join(dir, ".claude", "skills");
|
|
25
|
+
try { if (fs.readdirSync(d).some(f => /^qa-.*\.md$/.test(f))) return d; } catch {}
|
|
26
|
+
const up = path.dirname(dir);
|
|
27
|
+
if (up === dir) return null;
|
|
28
|
+
dir = up;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function latestPublishedVersion() {
|
|
32
|
+
const file = path.join(process.env.HOME || process.env.USERPROFILE || ".", UPDATE_CHECK_FILE);
|
|
33
|
+
try {
|
|
34
|
+
const c = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
35
|
+
if (c.latest && Date.now() - c.checkedAt < 24 * 3600 * 1000) return c.latest;
|
|
36
|
+
} catch {}
|
|
37
|
+
try {
|
|
38
|
+
const ctrl = new AbortController();
|
|
39
|
+
const timer = setTimeout(() => ctrl.abort(), 2000);
|
|
40
|
+
const res = await fetch(process.env.QATOOLS_UPDATE_URL || "https://registry.npmjs.org/qatools-cli/latest", { signal: ctrl.signal });
|
|
41
|
+
clearTimeout(timer);
|
|
42
|
+
const latest = (await res.json()).version;
|
|
43
|
+
if (latest) try { fs.writeFileSync(file, JSON.stringify({ checkedAt: Date.now(), latest })); } catch {}
|
|
44
|
+
return latest || null;
|
|
45
|
+
} catch { return null; }
|
|
46
|
+
}
|
|
47
|
+
async function staleWarnings({ skipSkills = false } = {}) {
|
|
48
|
+
if (process.env.QATOOLS_NO_UPDATE_CHECK) return [];
|
|
49
|
+
const out = [];
|
|
50
|
+
const latest = await latestPublishedVersion();
|
|
51
|
+
if (latest && versionLess(CLI_VERSION, latest)) {
|
|
52
|
+
out.push(`qatools-cli ${CLI_VERSION} is out of date — ${latest} is available. Update: npm install -g qatools-cli@latest`);
|
|
53
|
+
}
|
|
54
|
+
const dir = skipSkills ? null : findQaSkillsDir();
|
|
55
|
+
if (dir) {
|
|
56
|
+
let written = "";
|
|
57
|
+
try { written = fs.readFileSync(path.join(dir, SKILLS_MARKER), "utf8").trim(); } catch {}
|
|
58
|
+
if (!written || versionLess(written, CLI_VERSION)) {
|
|
59
|
+
out.push(`The qa-tools skills in ${dir} were written by ${written ? `CLI ${written}` : "an unknown CLI version"}, older than ${CLI_VERSION}. Run: qatools init`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
let mcpWarnings = [];
|
|
65
|
+
|
|
66
|
+
// testing.evidence-commit: the commit evidence was verified on — the working directory's HEAD, or null outside git.
|
|
67
|
+
function currentGitCommit(cwd = process.cwd()) {
|
|
68
|
+
try {
|
|
69
|
+
const out = require("child_process").execFileSync("git", ["rev-parse", "HEAD"], { cwd, stdio: ["ignore", "pipe", "ignore"], timeout: 3000 });
|
|
70
|
+
const sha = String(out).trim();
|
|
71
|
+
return /^[0-9a-f]{40}$/i.test(sha) ? sha : null;
|
|
72
|
+
} catch { return null; }
|
|
73
|
+
}
|
|
74
|
+
|
|
11
75
|
const firebaseConfig = {
|
|
12
76
|
projectId: "qatools-app",
|
|
13
77
|
appId: "1:818706206429:web:647fe512fdba662cb4d534",
|
|
@@ -86,7 +150,7 @@ async function authenticate(options) {
|
|
|
86
150
|
if (!data.id_token) throw new Error("Refresh failed");
|
|
87
151
|
|
|
88
152
|
// Sign in with the ID token via signInWithCredential
|
|
89
|
-
const { GoogleAuthProvider, signInWithCredential } = require('firebase/auth');
|
|
153
|
+
const { GoogleAuthProvider, signInWithCredential } = require('@firebase/auth');
|
|
90
154
|
// First try: sign in directly by minting custom token via REST with proper callable format
|
|
91
155
|
const mintRes = await fetch(`https://us-central1-qatools-app.cloudfunctions.net/mintCliToken`, {
|
|
92
156
|
method: 'POST',
|
|
@@ -697,6 +761,7 @@ program
|
|
|
697
761
|
for (const [k, rs] of Object.entries(byKey)) console.log(` ${k}: ${rs.map(r => `${r.status === "pass" ? "✓" : r.status === "fail" ? "✗" : "–"} ${r.name}`).join(", ")}`);
|
|
698
762
|
if (tagged.length < results.length) console.log(` (untagged: ${results.length - tagged.length})`);
|
|
699
763
|
console.log(`Run: ${meta.source} ${meta.commit ? meta.commit.slice(0, 8) : "(no commit)"} ${meta.branch || ""}`);
|
|
764
|
+
console.log("Dry run — nothing was uploaded. Without --dry-run, success ends with \"Uploaded run <id>\" and any failure exits with code 1.");
|
|
700
765
|
process.exit(0);
|
|
701
766
|
}
|
|
702
767
|
|
|
@@ -1467,6 +1532,8 @@ program
|
|
|
1467
1532
|
.option("--assigned <email>", "Set assignee: a member's email, 'me' (you, or the Claude account for an API key), or empty string to clear")
|
|
1468
1533
|
.option("--evidence <text>", "REQUIRED when status=implemented or tested. Cite test output, file:line, expected vs actual, or 'no test applies because <reason>'.")
|
|
1469
1534
|
.option("--attach <files...>", "Image file(s) as evidence (png/jpg/webp/gif, max 4 MB each)")
|
|
1535
|
+
.option("--commit <sha>", "Commit the evidence was verified on (default: git HEAD of the current directory)")
|
|
1536
|
+
.option("--no-commit", "Do not record a commit with the evidence")
|
|
1470
1537
|
.option("--epic <key>", "Set epicKey")
|
|
1471
1538
|
.option("--sprint <id>", "Set sprintId (use empty string to clear)")
|
|
1472
1539
|
.option("--type <type>", "Set type (functional/non-functional)")
|
|
@@ -1541,7 +1608,11 @@ program
|
|
|
1541
1608
|
if (!evidenceById[requirementId]) throw new Error("--attach needs --evidence (images belong to an evidence entry)");
|
|
1542
1609
|
payload.attachments = await uploadEvidenceFiles(projectId, options.attach);
|
|
1543
1610
|
}
|
|
1544
|
-
if (evidenceById[requirementId])
|
|
1611
|
+
if (evidenceById[requirementId]) {
|
|
1612
|
+
payload.evidence = evidenceById[requirementId];
|
|
1613
|
+
const commit = options.commit === false ? null : (typeof options.commit === "string" ? options.commit : currentGitCommit());
|
|
1614
|
+
if (commit) payload.commit = commit;
|
|
1615
|
+
}
|
|
1545
1616
|
await updateReq(payload);
|
|
1546
1617
|
ok++;
|
|
1547
1618
|
process.stdout.write(`\r Updated ${ok}, failed ${failed} / ${Object.keys(updates).length}`);
|
|
@@ -2268,8 +2339,8 @@ program
|
|
|
2268
2339
|
});
|
|
2269
2340
|
const authData = await authRes.json();
|
|
2270
2341
|
if (authData.result?.customToken) {
|
|
2271
|
-
const { signInWithCustomToken } = require("firebase/auth");
|
|
2272
|
-
const { getAuth } = require("firebase/auth");
|
|
2342
|
+
const { signInWithCustomToken } = require("@firebase/auth");
|
|
2343
|
+
const { getAuth } = require("@firebase/auth");
|
|
2273
2344
|
await signInWithCustomToken(getAuth(), authData.result.customToken);
|
|
2274
2345
|
const configPath = path.join(process.env.HOME || process.env.USERPROFILE, ".qatools");
|
|
2275
2346
|
const config = { apiKey: options.apiKey, projectId: authData.result.projectId, projectName: authData.result.projectName, email: authData.result.email };
|
|
@@ -2849,6 +2920,7 @@ If the verification fails: do NOT mark tested. Go back to step 1, find the discr
|
|
|
2849
2920
|
for (const [filename, content] of Object.entries(skills)) {
|
|
2850
2921
|
fs.writeFileSync(path.join(skillsDir, filename), content);
|
|
2851
2922
|
}
|
|
2923
|
+
fs.writeFileSync(path.join(skillsDir, SKILLS_MARKER), CLI_VERSION + "\n");
|
|
2852
2924
|
console.log(" ✓ qa-purpose.md (READ FIRST)");
|
|
2853
2925
|
console.log(" ✓ qa-loop.md");
|
|
2854
2926
|
console.log(" ✓ qa-requirement-analyst.md");
|
|
@@ -3570,7 +3642,10 @@ const mcpTools = [
|
|
|
3570
3642
|
name: "get_agenda",
|
|
3571
3643
|
description: "What to work on next in the project (same data as `qatools next`): open signals, requirements awaiting work, sessions awaiting analysis.",
|
|
3572
3644
|
inputSchema: mcpSchema(),
|
|
3573
|
-
run: async (a) =>
|
|
3645
|
+
run: async (a) => {
|
|
3646
|
+
const agenda = await mcpCall("getProjectAgenda", { projectId: a.projectId });
|
|
3647
|
+
return mcpWarnings.length ? { warnings: mcpWarnings, ...agenda } : agenda;
|
|
3648
|
+
},
|
|
3574
3649
|
},
|
|
3575
3650
|
{
|
|
3576
3651
|
name: "get_app_context",
|
|
@@ -3631,6 +3706,7 @@ const mcpTools = [
|
|
|
3631
3706
|
description: mcpStr("Description"),
|
|
3632
3707
|
acceptanceCriteria: mcpStr("Acceptance criteria"),
|
|
3633
3708
|
attachments: mcpStrArray("Local image file paths (png/jpg/webp/gif, max 4 MB) to attach to the evidence, e.g. screenshots"),
|
|
3709
|
+
commit: mcpStr("Commit the evidence was verified on. Default: git HEAD of the server's working directory; empty string to leave it out"),
|
|
3634
3710
|
}, ["requirementId"]),
|
|
3635
3711
|
run: async (a) => {
|
|
3636
3712
|
const updates = mcpPick(a, ["status", "assignedTo", "epicKey", "sprintId", "type", "title", "description", "acceptanceCriteria"]);
|
|
@@ -3640,7 +3716,11 @@ const mcpTools = [
|
|
|
3640
3716
|
throw new McpToolError(`Refusing status=${updates.status} without evidence (min 10 chars). Cite the verification, or use a status that does not claim done.`);
|
|
3641
3717
|
}
|
|
3642
3718
|
const payload = { projectId: a.projectId, requirementId: a.requirementId, updates };
|
|
3643
|
-
if (a.evidence)
|
|
3719
|
+
if (a.evidence) {
|
|
3720
|
+
payload.evidence = a.evidence;
|
|
3721
|
+
const commit = a.commit !== undefined ? a.commit : currentGitCommit();
|
|
3722
|
+
if (commit) payload.commit = commit;
|
|
3723
|
+
}
|
|
3644
3724
|
if (a.attachments?.length) {
|
|
3645
3725
|
if (!a.evidence) throw new McpToolError("attachments need evidence — images belong to an evidence entry");
|
|
3646
3726
|
payload.attachments = await uploadEvidenceFiles(a.projectId, a.attachments);
|
|
@@ -4117,7 +4197,7 @@ async function mcpHandle(msg, defaultProjectId) {
|
|
|
4117
4197
|
protocolVersion: MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : MCP_PROTOCOL_VERSIONS[0],
|
|
4118
4198
|
capabilities: { tools: { listChanged: false }, prompts: { listChanged: false } },
|
|
4119
4199
|
serverInfo: { name: "qatools", version: require("./package.json").version },
|
|
4120
|
-
instructions: MCP_INSTRUCTIONS,
|
|
4200
|
+
instructions: MCP_INSTRUCTIONS + (mcpWarnings.length ? "\n- OUT OF DATE — tell the user before anything else: " + mcpWarnings.join(" ") : ""),
|
|
4121
4201
|
};
|
|
4122
4202
|
}
|
|
4123
4203
|
if (method === "ping") return {};
|
|
@@ -4166,6 +4246,8 @@ program
|
|
|
4166
4246
|
console.info = (...a) => console.error(...a);
|
|
4167
4247
|
|
|
4168
4248
|
await authenticate(options);
|
|
4249
|
+
mcpWarnings = await staleWarnings();
|
|
4250
|
+
for (const w of mcpWarnings) console.error(`⚠ ${w}`);
|
|
4169
4251
|
const defaultProjectId = options.project || getCredentials()?.projectId || null;
|
|
4170
4252
|
console.error(`qatools MCP server ready${defaultProjectId ? ` (default project ${defaultProjectId})` : ""}`);
|
|
4171
4253
|
|
|
@@ -4190,4 +4272,9 @@ program
|
|
|
4190
4272
|
rl.on("close", () => process.exit(0));
|
|
4191
4273
|
});
|
|
4192
4274
|
|
|
4193
|
-
program.
|
|
4275
|
+
program.hook("preAction", async (_root, cmd) => {
|
|
4276
|
+
if (cmd.name() === "mcp") return; // the MCP server reports through instructions and get_agenda
|
|
4277
|
+
for (const w of await staleWarnings({ skipSkills: cmd.name() === "init" })) console.error(`⚠ ${w}`);
|
|
4278
|
+
});
|
|
4279
|
+
|
|
4280
|
+
program.parseAsync();
|