qatools-cli 1.2.13 → 1.2.14
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 +97 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qatools-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
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',
|
|
@@ -1467,6 +1531,8 @@ program
|
|
|
1467
1531
|
.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
1532
|
.option("--evidence <text>", "REQUIRED when status=implemented or tested. Cite test output, file:line, expected vs actual, or 'no test applies because <reason>'.")
|
|
1469
1533
|
.option("--attach <files...>", "Image file(s) as evidence (png/jpg/webp/gif, max 4 MB each)")
|
|
1534
|
+
.option("--commit <sha>", "Commit the evidence was verified on (default: git HEAD of the current directory)")
|
|
1535
|
+
.option("--no-commit", "Do not record a commit with the evidence")
|
|
1470
1536
|
.option("--epic <key>", "Set epicKey")
|
|
1471
1537
|
.option("--sprint <id>", "Set sprintId (use empty string to clear)")
|
|
1472
1538
|
.option("--type <type>", "Set type (functional/non-functional)")
|
|
@@ -1541,7 +1607,11 @@ program
|
|
|
1541
1607
|
if (!evidenceById[requirementId]) throw new Error("--attach needs --evidence (images belong to an evidence entry)");
|
|
1542
1608
|
payload.attachments = await uploadEvidenceFiles(projectId, options.attach);
|
|
1543
1609
|
}
|
|
1544
|
-
if (evidenceById[requirementId])
|
|
1610
|
+
if (evidenceById[requirementId]) {
|
|
1611
|
+
payload.evidence = evidenceById[requirementId];
|
|
1612
|
+
const commit = options.commit === false ? null : (typeof options.commit === "string" ? options.commit : currentGitCommit());
|
|
1613
|
+
if (commit) payload.commit = commit;
|
|
1614
|
+
}
|
|
1545
1615
|
await updateReq(payload);
|
|
1546
1616
|
ok++;
|
|
1547
1617
|
process.stdout.write(`\r Updated ${ok}, failed ${failed} / ${Object.keys(updates).length}`);
|
|
@@ -2268,8 +2338,8 @@ program
|
|
|
2268
2338
|
});
|
|
2269
2339
|
const authData = await authRes.json();
|
|
2270
2340
|
if (authData.result?.customToken) {
|
|
2271
|
-
const { signInWithCustomToken } = require("firebase/auth");
|
|
2272
|
-
const { getAuth } = require("firebase/auth");
|
|
2341
|
+
const { signInWithCustomToken } = require("@firebase/auth");
|
|
2342
|
+
const { getAuth } = require("@firebase/auth");
|
|
2273
2343
|
await signInWithCustomToken(getAuth(), authData.result.customToken);
|
|
2274
2344
|
const configPath = path.join(process.env.HOME || process.env.USERPROFILE, ".qatools");
|
|
2275
2345
|
const config = { apiKey: options.apiKey, projectId: authData.result.projectId, projectName: authData.result.projectName, email: authData.result.email };
|
|
@@ -2849,6 +2919,7 @@ If the verification fails: do NOT mark tested. Go back to step 1, find the discr
|
|
|
2849
2919
|
for (const [filename, content] of Object.entries(skills)) {
|
|
2850
2920
|
fs.writeFileSync(path.join(skillsDir, filename), content);
|
|
2851
2921
|
}
|
|
2922
|
+
fs.writeFileSync(path.join(skillsDir, SKILLS_MARKER), CLI_VERSION + "\n");
|
|
2852
2923
|
console.log(" ✓ qa-purpose.md (READ FIRST)");
|
|
2853
2924
|
console.log(" ✓ qa-loop.md");
|
|
2854
2925
|
console.log(" ✓ qa-requirement-analyst.md");
|
|
@@ -3570,7 +3641,10 @@ const mcpTools = [
|
|
|
3570
3641
|
name: "get_agenda",
|
|
3571
3642
|
description: "What to work on next in the project (same data as `qatools next`): open signals, requirements awaiting work, sessions awaiting analysis.",
|
|
3572
3643
|
inputSchema: mcpSchema(),
|
|
3573
|
-
run: async (a) =>
|
|
3644
|
+
run: async (a) => {
|
|
3645
|
+
const agenda = await mcpCall("getProjectAgenda", { projectId: a.projectId });
|
|
3646
|
+
return mcpWarnings.length ? { warnings: mcpWarnings, ...agenda } : agenda;
|
|
3647
|
+
},
|
|
3574
3648
|
},
|
|
3575
3649
|
{
|
|
3576
3650
|
name: "get_app_context",
|
|
@@ -3631,6 +3705,7 @@ const mcpTools = [
|
|
|
3631
3705
|
description: mcpStr("Description"),
|
|
3632
3706
|
acceptanceCriteria: mcpStr("Acceptance criteria"),
|
|
3633
3707
|
attachments: mcpStrArray("Local image file paths (png/jpg/webp/gif, max 4 MB) to attach to the evidence, e.g. screenshots"),
|
|
3708
|
+
commit: mcpStr("Commit the evidence was verified on. Default: git HEAD of the server's working directory; empty string to leave it out"),
|
|
3634
3709
|
}, ["requirementId"]),
|
|
3635
3710
|
run: async (a) => {
|
|
3636
3711
|
const updates = mcpPick(a, ["status", "assignedTo", "epicKey", "sprintId", "type", "title", "description", "acceptanceCriteria"]);
|
|
@@ -3640,7 +3715,11 @@ const mcpTools = [
|
|
|
3640
3715
|
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
3716
|
}
|
|
3642
3717
|
const payload = { projectId: a.projectId, requirementId: a.requirementId, updates };
|
|
3643
|
-
if (a.evidence)
|
|
3718
|
+
if (a.evidence) {
|
|
3719
|
+
payload.evidence = a.evidence;
|
|
3720
|
+
const commit = a.commit !== undefined ? a.commit : currentGitCommit();
|
|
3721
|
+
if (commit) payload.commit = commit;
|
|
3722
|
+
}
|
|
3644
3723
|
if (a.attachments?.length) {
|
|
3645
3724
|
if (!a.evidence) throw new McpToolError("attachments need evidence — images belong to an evidence entry");
|
|
3646
3725
|
payload.attachments = await uploadEvidenceFiles(a.projectId, a.attachments);
|
|
@@ -4117,7 +4196,7 @@ async function mcpHandle(msg, defaultProjectId) {
|
|
|
4117
4196
|
protocolVersion: MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : MCP_PROTOCOL_VERSIONS[0],
|
|
4118
4197
|
capabilities: { tools: { listChanged: false }, prompts: { listChanged: false } },
|
|
4119
4198
|
serverInfo: { name: "qatools", version: require("./package.json").version },
|
|
4120
|
-
instructions: MCP_INSTRUCTIONS,
|
|
4199
|
+
instructions: MCP_INSTRUCTIONS + (mcpWarnings.length ? "\n- OUT OF DATE — tell the user before anything else: " + mcpWarnings.join(" ") : ""),
|
|
4121
4200
|
};
|
|
4122
4201
|
}
|
|
4123
4202
|
if (method === "ping") return {};
|
|
@@ -4166,6 +4245,8 @@ program
|
|
|
4166
4245
|
console.info = (...a) => console.error(...a);
|
|
4167
4246
|
|
|
4168
4247
|
await authenticate(options);
|
|
4248
|
+
mcpWarnings = await staleWarnings();
|
|
4249
|
+
for (const w of mcpWarnings) console.error(`⚠ ${w}`);
|
|
4169
4250
|
const defaultProjectId = options.project || getCredentials()?.projectId || null;
|
|
4170
4251
|
console.error(`qatools MCP server ready${defaultProjectId ? ` (default project ${defaultProjectId})` : ""}`);
|
|
4171
4252
|
|
|
@@ -4190,4 +4271,9 @@ program
|
|
|
4190
4271
|
rl.on("close", () => process.exit(0));
|
|
4191
4272
|
});
|
|
4192
4273
|
|
|
4193
|
-
program.
|
|
4274
|
+
program.hook("preAction", async (_root, cmd) => {
|
|
4275
|
+
if (cmd.name() === "mcp") return; // the MCP server reports through instructions and get_agenda
|
|
4276
|
+
for (const w of await staleWarnings({ skipSkills: cmd.name() === "init" })) console.error(`⚠ ${w}`);
|
|
4277
|
+
});
|
|
4278
|
+
|
|
4279
|
+
program.parseAsync();
|