qatools-cli 1.2.42 → 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/package.json +1 -1
- package/qatools.js +32 -13
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
|
@@ -3451,19 +3451,29 @@ async function setupClaudeLogin(options) {
|
|
|
3451
3451
|
own.writeProjectLogin({ projectId: project.id, projectName: project.name, apiKey: key });
|
|
3452
3452
|
}
|
|
3453
3453
|
const markerFile = own.writeMarker(repoRoot, { projectId: project.id, projectName: project.name });
|
|
3454
|
-
|
|
3455
|
-
|
|
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);
|
|
3456
3464
|
const q = (s) => (/[\s"&|<>^]/.test(s) ? `"${s}"` : s);
|
|
3457
3465
|
const envArgs = Object.entries(cfg.env).flatMap(([k, v]) => ["-e", `${k}=${v}`]);
|
|
3458
3466
|
const sh = (args) => require("child_process").spawnSync("claude", args.map(q), { cwd: repoRoot, shell: true, encoding: "utf8" });
|
|
3459
3467
|
sh(["mcp", "remove", "qatools", "--scope", "local"]);
|
|
3460
3468
|
// the name first: -e takes several values and would swallow it
|
|
3461
3469
|
const added = sh(["mcp", "add", "qatools", "--scope", "local", ...envArgs, "--", cfg.command, ...cfg.args]);
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
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); }
|
|
3467
3477
|
}
|
|
3468
3478
|
|
|
3469
3479
|
program
|
|
@@ -3494,10 +3504,16 @@ program
|
|
|
3494
3504
|
const { signInWithCustomToken } = require("@firebase/auth");
|
|
3495
3505
|
const { getAuth } = require("@firebase/auth");
|
|
3496
3506
|
await signInWithCustomToken(getAuth(), authData.result.customToken);
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
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)}`);
|
|
3501
3517
|
} else {
|
|
3502
3518
|
console.error(" ✗ Invalid API key.");
|
|
3503
3519
|
process.exit(1);
|
|
@@ -3506,7 +3522,7 @@ program
|
|
|
3506
3522
|
console.error(" ✗ Login failed:", e.message);
|
|
3507
3523
|
process.exit(1);
|
|
3508
3524
|
}
|
|
3509
|
-
} else if (existingCreds?.projectId || process.env.QATOOLS_API_KEY) {
|
|
3525
|
+
} else if (existingCreds?.projectId || process.env.QATOOLS_API_KEY || require("./own-login").findProjectMarker(cwd)) {
|
|
3510
3526
|
// Ensure Firebase auth is initialized; with QATOOLS_API_KEY that also picks the key's project for this run
|
|
3511
3527
|
try { await authenticate(options); } catch (e) { /* best effort */ }
|
|
3512
3528
|
const now = getCredentials(); // AVV-38: name the project this run actually uses
|
|
@@ -3537,7 +3553,10 @@ program
|
|
|
3537
3553
|
// Only adds skills that don't already exist in ctx.skills[] (respects user edits).
|
|
3538
3554
|
try {
|
|
3539
3555
|
await authenticate(options);
|
|
3540
|
-
|
|
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;
|
|
3541
3560
|
if (creds?.projectId) {
|
|
3542
3561
|
const getCtx = httpsCallable(functions, "getAppContext");
|
|
3543
3562
|
const ctxResult = await getCtx({ projectId: creds.projectId });
|