qatools-cli 1.2.41 → 1.2.43
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/brief.js +3 -1
- package/mcp-core.js +1 -1
- package/package.json +1 -1
- package/qatools.js +47 -16
package/brief.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// context.session-brief: the short brief a Claude session starts with. Pure: data in, text out (at most 30 lines).
|
|
2
2
|
const MAX_LINES = 30;
|
|
3
3
|
|
|
4
|
-
function renderBrief({ projectName = "", requirements = [], agenda = null, requests = [], branch = "", branchKeys = [], main = "" }) {
|
|
4
|
+
function renderBrief({ projectName = "", requirements = [], agenda = null, requests = [], branch = "", branchKeys = [], main = "", warnings = [] }) {
|
|
5
5
|
const lines = [`qa-tools brief${projectName ? ` — ${projectName}` : ""} (read this before you start)`];
|
|
6
|
+
// cli.self-upgrade: out of date first — upgrade yourself (qa-purpose skill: Keeping qa-tools current)
|
|
7
|
+
for (const w of warnings.slice(0, 2)) lines.push(`⚠ ${w} Upgrade yourself, then tell the person in one line.`);
|
|
6
8
|
const verified = (r) => r.status === "implemented" || r.status === "tested";
|
|
7
9
|
const who = (e) => /^claude@[^@]+\.qatools$/i.test(String(e || "")) ? "Claude" : (e || "nobody");
|
|
8
10
|
|
package/mcp-core.js
CHANGED
|
@@ -1080,7 +1080,7 @@ async function mcpHandle(msg, defaultProjectId) {
|
|
|
1080
1080
|
protocolVersion: MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : MCP_PROTOCOL_VERSIONS[0],
|
|
1081
1081
|
capabilities: { tools: { listChanged: false }, prompts: { listChanged: false } },
|
|
1082
1082
|
serverInfo: { name: "qatools", version: env.version || "" },
|
|
1083
|
-
instructions: instructions + (warnings().length ? "\n- OUT OF DATE
|
|
1083
|
+
instructions: instructions + (warnings().length ? "\n- OUT OF DATE: " + warnings().join(" ") + " Upgrade yourself (npm install -g qatools-cli@latest, then qatools init in the repo, commit the .claude changes) and tell the user in one line — unless this is an unattended run, which never upgrades mid-run." : ""),
|
|
1084
1084
|
};
|
|
1085
1085
|
}
|
|
1086
1086
|
if (method === "ping") return {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qatools-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.43",
|
|
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
|
@@ -70,6 +70,17 @@ When \`qatools\` says "No credentials" or that the repo needs Claude's own login
|
|
|
70
70
|
|
|
71
71
|
Never ask for the key in the chat, never print or \`cat\` the file, never put it in the repo. Use it only as an environment variable (\`$env:QATOOLS_API_KEY = (Get-Content <file> -Raw).Trim()\`), or log a project-own home folder in with it for the MCP server (\`$env:HOME = <folder>; qatools login --api-key (Get-Content <file> -Raw).Trim()\`) and point the repo's MCP config at that folder. Then \`qatools brief\` must show the project and Claude.
|
|
72
72
|
|
|
73
|
+
## Keeping qa-tools current
|
|
74
|
+
|
|
75
|
+
When the brief, a \`qatools\` command or the MCP server says qatools-cli or this repo's qa-tools skills are out of date, upgrade yourself — the person should not have to tell you:
|
|
76
|
+
|
|
77
|
+
1. \`npm install -g qatools-cli@latest\`
|
|
78
|
+
2. \`qatools init\` in the repo (updates .claude/skills and the hooks; with the repo's own Claude login it changes nothing else).
|
|
79
|
+
3. Commit only the updated .claude files (chore: qa-tools skills <version>), following the repo's branch rules.
|
|
80
|
+
4. Tell the person in one line: "Upgraded qatools-cli to <version>."
|
|
81
|
+
|
|
82
|
+
Never upgrade in an unattended run (nobody at the keyboard, e.g. a scheduled loop run): it must not change versions mid-run. Mention it in the run's summary instead.
|
|
83
|
+
|
|
73
84
|
That standard rules out:
|
|
74
85
|
- Guessing when verification is possible
|
|
75
86
|
- "Looks right" without numbers
|
|
@@ -627,7 +638,7 @@ async function latestPublishedVersion() {
|
|
|
627
638
|
const file = path.join(process.env.HOME || process.env.USERPROFILE || ".", UPDATE_CHECK_FILE);
|
|
628
639
|
try {
|
|
629
640
|
const c = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
630
|
-
if (c.latest && Date.now() - c.checkedAt <
|
|
641
|
+
if (c.latest && Date.now() - c.checkedAt < 3600 * 1000) return c.latest; // cli.self-upgrade: a new version is noticed within the hour
|
|
631
642
|
} catch {}
|
|
632
643
|
try {
|
|
633
644
|
const ctrl = new AbortController();
|
|
@@ -1568,8 +1579,9 @@ program
|
|
|
1568
1579
|
}
|
|
1569
1580
|
} catch {}
|
|
1570
1581
|
const { renderBrief } = require("./brief");
|
|
1582
|
+
const warnings = await staleWarnings().catch(() => []); // cli.self-upgrade: the session sees it first thing
|
|
1571
1583
|
console.log(renderBrief({ projectName: creds?.projectName || "", requirements, agenda: agendaRes?.agenda || null,
|
|
1572
|
-
requests: reqsRes?.requests || [], branch, main, branchKeys }));
|
|
1584
|
+
requests: reqsRes?.requests || [], branch, main, branchKeys, warnings }));
|
|
1573
1585
|
process.exit(0);
|
|
1574
1586
|
} catch (e) {
|
|
1575
1587
|
quietExit("Failed: " + e.message);
|
|
@@ -3439,19 +3451,29 @@ async function setupClaudeLogin(options) {
|
|
|
3439
3451
|
own.writeProjectLogin({ projectId: project.id, projectName: project.name, apiKey: key });
|
|
3440
3452
|
}
|
|
3441
3453
|
const markerFile = own.writeMarker(repoRoot, { projectId: project.id, projectName: project.name });
|
|
3442
|
-
|
|
3443
|
-
|
|
3454
|
+
console.log(reused ? `Claude's own login for ${project.name} was already set up — kept it.` : `Claude's own key for ${project.name} is created and kept in ${own.projectHome(project.id)} (outside the repo, never shown).`);
|
|
3455
|
+
console.log(`This repo is marked as ${project.name}: ${path.relative(repoRoot, markerFile)} — commit it (no secret in it).`);
|
|
3456
|
+
console.log(registerClaudeMcp(repoRoot, project.id));
|
|
3457
|
+
console.log("From now on, when Claude runs qatools here it works as Claude for this project; when you do, it is you.");
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
// Claude Code's qatools MCP server for the repo (local scope: Claude Code's own settings, not the repo), pointed at the
|
|
3461
|
+
// project-own login folder. Returns the line to show.
|
|
3462
|
+
function registerClaudeMcp(repoRoot, projectId) {
|
|
3463
|
+
const cfg = require("./own-login").mcpServerConfig(projectId);
|
|
3444
3464
|
const q = (s) => (/[\s"&|<>^]/.test(s) ? `"${s}"` : s);
|
|
3445
3465
|
const envArgs = Object.entries(cfg.env).flatMap(([k, v]) => ["-e", `${k}=${v}`]);
|
|
3446
3466
|
const sh = (args) => require("child_process").spawnSync("claude", args.map(q), { cwd: repoRoot, shell: true, encoding: "utf8" });
|
|
3447
3467
|
sh(["mcp", "remove", "qatools", "--scope", "local"]);
|
|
3448
3468
|
// the name first: -e takes several values and would swallow it
|
|
3449
3469
|
const added = sh(["mcp", "add", "qatools", "--scope", "local", ...envArgs, "--", cfg.command, ...cfg.args]);
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3470
|
+
if (added.status === 0) return "Claude Code's qatools server for this repo now uses Claude's own login. Restart Claude Code (or reload the window).";
|
|
3471
|
+
return `Could not register the MCP server with Claude Code (${(added.stderr || added.error?.message || "claude not found").trim().split("\n")[0]}). Run in this repo:\n claude mcp add qatools --scope local ${envArgs.map(q).join(" ")} -- ${q(cfg.command)} ${cfg.args.map(q).join(" ")}`;
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
// The repo's root (git top level), or the folder itself
|
|
3475
|
+
function repoRootOf(cwd = process.cwd()) {
|
|
3476
|
+
try { return path.resolve(String(require("child_process").execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, stdio: ["ignore", "pipe", "ignore"] })).trim() || cwd); } catch { return path.resolve(cwd); }
|
|
3455
3477
|
}
|
|
3456
3478
|
|
|
3457
3479
|
program
|
|
@@ -3482,10 +3504,16 @@ program
|
|
|
3482
3504
|
const { signInWithCustomToken } = require("@firebase/auth");
|
|
3483
3505
|
const { getAuth } = require("@firebase/auth");
|
|
3484
3506
|
await signInWithCustomToken(getAuth(), authData.result.customToken);
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3507
|
+
// AVV-68 / cli.claude-own-login: the key is Claude's own login for this repo's project — kept in a
|
|
3508
|
+
// project-own folder, never in the computer-wide ~/.qatools (the person's login and default project stay)
|
|
3509
|
+
const own = require("./own-login");
|
|
3510
|
+
const pid = authData.result.projectId, pname = authData.result.projectName;
|
|
3511
|
+
own.writeProjectLogin({ projectId: pid, projectName: pname, apiKey: options.apiKey });
|
|
3512
|
+
const root = repoRootOf(cwd);
|
|
3513
|
+
own.writeMarker(root, { projectId: pid, projectName: pname });
|
|
3514
|
+
process.env.QATOOLS_API_KEY = options.apiKey; // the rest of this run only, in memory
|
|
3515
|
+
console.log(` ✓ Claude's own login for ${pname} (${pid}) is kept in ${own.projectHome(pid)} — your own login and default project are unchanged`);
|
|
3516
|
+
console.log(` ${registerClaudeMcp(root, pid)}`);
|
|
3489
3517
|
} else {
|
|
3490
3518
|
console.error(" ✗ Invalid API key.");
|
|
3491
3519
|
process.exit(1);
|
|
@@ -3494,7 +3522,7 @@ program
|
|
|
3494
3522
|
console.error(" ✗ Login failed:", e.message);
|
|
3495
3523
|
process.exit(1);
|
|
3496
3524
|
}
|
|
3497
|
-
} else if (existingCreds?.projectId || process.env.QATOOLS_API_KEY) {
|
|
3525
|
+
} else if (existingCreds?.projectId || process.env.QATOOLS_API_KEY || require("./own-login").findProjectMarker(cwd)) {
|
|
3498
3526
|
// Ensure Firebase auth is initialized; with QATOOLS_API_KEY that also picks the key's project for this run
|
|
3499
3527
|
try { await authenticate(options); } catch (e) { /* best effort */ }
|
|
3500
3528
|
const now = getCredentials(); // AVV-38: name the project this run actually uses
|
|
@@ -3525,7 +3553,10 @@ program
|
|
|
3525
3553
|
// Only adds skills that don't already exist in ctx.skills[] (respects user edits).
|
|
3526
3554
|
try {
|
|
3527
3555
|
await authenticate(options);
|
|
3528
|
-
|
|
3556
|
+
// AVV-68: a repo marked with its project syncs that project, not the computer's default project
|
|
3557
|
+
const credsNow = getCredentials();
|
|
3558
|
+
const repoMarker = require("./own-login").findProjectMarker(cwd);
|
|
3559
|
+
const creds = repoMarker ? { ...(credsNow || {}), projectId: repoMarker.projectId, projectName: repoMarker.projectName || credsNow?.projectName } : credsNow;
|
|
3529
3560
|
if (creds?.projectId) {
|
|
3530
3561
|
const getCtx = httpsCallable(functions, "getAppContext");
|
|
3531
3562
|
const ctxResult = await getCtx({ projectId: creds.projectId });
|
|
@@ -4536,7 +4567,7 @@ program
|
|
|
4536
4567
|
});
|
|
4537
4568
|
|
|
4538
4569
|
program.hook("preAction", async (_root, cmd) => {
|
|
4539
|
-
if (cmd.name() === "mcp") return; // the MCP server reports through instructions and get_agenda
|
|
4570
|
+
if (cmd.name() === "mcp" || cmd.name() === "brief") return; // the MCP server reports through instructions and get_agenda, the brief in its own text
|
|
4540
4571
|
for (const w of await staleWarnings({ skipSkills: cmd.name() === "init" })) console.error(`⚠ ${w}`);
|
|
4541
4572
|
});
|
|
4542
4573
|
|