@fusebase/harness-lead 0.3.2 → 0.3.3
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/CHANGELOG.md +7 -0
- package/dist/lead.mjs +358 -145
- package/package.json +1 -1
- package/skills/lead/delegates/codee/SKILL.md +1 -0
- package/skills/lead/references/qa.md +2 -0
- package/skills/lead/references/watch.md +12 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.3 — 2026-12-04
|
|
4
|
+
|
|
5
|
+
- `watch probe`: a token-free pass over delegated tasks (merge requests through `glab`, the tracker through a command the person provides) that fingerprints the facts and says whether an agent would have anything to do. `watch probe shadow` records its decision beside each clock tick without skipping any check; `watch probe report` compares it with what agents did. `watch ack --acted|--idle` records whether the check led to action. Nothing gates a real check yet.
|
|
6
|
+
|
|
7
|
+
- Browser QA says to run the available checks directly (local or stage before deployment, the rest after the deployed revision is verified) instead of reporting QA as a next step.
|
|
8
|
+
- Codee: every check reviews review-ready implementation and QA-dependency tickets (including a dependency merge request in another repository), records the verdict, moves a clean ticket on (Done for a verified merged dependency) and tags the responsible person for a concern.
|
|
9
|
+
|
|
3
10
|
## 0.3.2 — 2026-12-03
|
|
4
11
|
|
|
5
12
|
- `workspace overview --json` lists each repository's initiatives: epic and link, flag, one-pager, milestones, repositories (home or reference, and whether a checkout is available), task counts and the tracker records adopted for it, counted per milestone. Read-only, like the rest of the overview.
|
package/dist/lead.mjs
CHANGED
|
@@ -1738,7 +1738,7 @@ var require_merge = __commonJS({
|
|
|
1738
1738
|
var require_addPairToJSMap = __commonJS({
|
|
1739
1739
|
"node_modules/.pnpm/yaml@2.7.0/node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
|
|
1740
1740
|
"use strict";
|
|
1741
|
-
var
|
|
1741
|
+
var log2 = require_log();
|
|
1742
1742
|
var merge = require_merge();
|
|
1743
1743
|
var stringify3 = require_stringify();
|
|
1744
1744
|
var identity = require_identity();
|
|
@@ -1787,7 +1787,7 @@ var require_addPairToJSMap = __commonJS({
|
|
|
1787
1787
|
let jsonStr = JSON.stringify(strKey);
|
|
1788
1788
|
if (jsonStr.length > 40)
|
|
1789
1789
|
jsonStr = jsonStr.substring(0, 36) + '..."';
|
|
1790
|
-
|
|
1790
|
+
log2.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
|
|
1791
1791
|
ctx.mapKeyWarned = true;
|
|
1792
1792
|
}
|
|
1793
1793
|
return strKey;
|
|
@@ -7163,7 +7163,7 @@ var require_public_api = __commonJS({
|
|
|
7163
7163
|
var composer = require_composer();
|
|
7164
7164
|
var Document = require_Document();
|
|
7165
7165
|
var errors = require_errors();
|
|
7166
|
-
var
|
|
7166
|
+
var log2 = require_log();
|
|
7167
7167
|
var identity = require_identity();
|
|
7168
7168
|
var lineCounter = require_line_counter();
|
|
7169
7169
|
var parser = require_parser();
|
|
@@ -7215,7 +7215,7 @@ var require_public_api = __commonJS({
|
|
|
7215
7215
|
const doc = parseDocument(src, options);
|
|
7216
7216
|
if (!doc)
|
|
7217
7217
|
return null;
|
|
7218
|
-
doc.warnings.forEach((warning) =>
|
|
7218
|
+
doc.warnings.forEach((warning) => log2.warn(doc.options.logLevel, warning));
|
|
7219
7219
|
if (doc.errors.length > 0) {
|
|
7220
7220
|
if (doc.options.logLevel !== "silent")
|
|
7221
7221
|
throw doc.errors[0];
|
|
@@ -7306,8 +7306,8 @@ var require_dist = __commonJS({
|
|
|
7306
7306
|
});
|
|
7307
7307
|
|
|
7308
7308
|
// src/cli.ts
|
|
7309
|
-
import { mkdirSync as
|
|
7310
|
-
import { dirname as dirname6, join as
|
|
7309
|
+
import { mkdirSync as mkdirSync15, realpathSync as realpathSync6, writeFileSync as writeFileSync16 } from "node:fs";
|
|
7310
|
+
import { dirname as dirname6, join as join33, resolve as resolve3 } from "node:path";
|
|
7311
7311
|
import { fileURLToPath } from "node:url";
|
|
7312
7312
|
|
|
7313
7313
|
// src/check.ts
|
|
@@ -7549,7 +7549,7 @@ var TEMPLATES = {
|
|
|
7549
7549
|
"workspace-crew.md": "---\nname: crew-lead\ndescription: Run the lead workflow. Use only when the user invokes /crew-lead or $crew-lead.\n---\n<!-- evercrew:workspace-entry -->\nFollow the adjacent `../lead/SKILL.md` entry point as if the user invoked lead. Pass through the request and its arguments.\n",
|
|
7550
7550
|
"workspace-entry.md": "---\nname: lead\ndescription: Run lead for this project or show the workspace overview. Use when the user types /lead or $lead, asks to use lead, or asks for an overview of all workspace projects.\n---\n<!-- evercrew:workspace-entry -->\nIf the session context already names the lead launcher and kit, use them and skip the next two steps. Otherwise find the nearest `.lead/lead.mjs` from the directory this conversation started in. Preserve that starting directory as `--cwd` on the first call. Run `node <launcher> kit-path`, then read `skills/lead/SKILL.md` from the returned kit directory and follow it. References are relative to that kit directory. Keep the same session ID throughout this conversation. The launcher and kit path are local setup, not product state.\n",
|
|
7551
7551
|
"workspace-goal.md": "---\nname: lead-goal\ndescription: Record lead activity and keep the heartbeat for an active Cursor goal.\n---\n<!-- evercrew:workspace-entry -->\nRun `node .lead/lead.mjs kit-path` from the lead workspace or target checkout, then read `skills/lead-goal/SKILL.md` from the returned kit directory. Use the same repository scope and session ID as lead.\n",
|
|
7552
|
-
"workspace-launcher.mjs": "#!/usr/bin/env node\n// evercrew:workspace-entry\n// Portable entry point. The runtime belongs to the workspace or to the user's npm cache.\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst args = process.argv.slice(2);\nconst here = dirname(dirname(fileURLToPath(import.meta.url)));\nconst hook = args[0] === 'stop-check' || args[0] === 'session-start';\nconst cwdFlag = args.indexOf('--cwd');\nconst cwd = cwdFlag >= 0 && args[cwdFlag + 1] ? resolve(args[cwdFlag + 1]) : process.cwd();\nconst cli = (kit) => join(kit, 'dist/lead.mjs');\n\nfunction workspaceKit(start) {\n let dir = realpathSync(start);\n while (true) {\n if (existsSync(join(dir, '.lead/workspace.yml'))) {\n const kit = join(dir, '.lead/workspace-kit');\n if (existsSync(cli(kit))) return kit;\n if (hook) return;\n throw new Error(`The lead workspace at ${dir} has no runtime. Deploy its kit first.`);\n }\n if (dirname(dir) === dir) return;\n dir = dirname(dir);\n }\n}\n\nfunction run(bin, argv, diagnosticsOnly = false) {\n const result = spawnSync(bin, argv, { stdio: diagnosticsOnly ? ['inherit', 2, 2] : 'inherit', env: bin === 'npm' ? { ...process.env, 'npm_config_@fusebase:registry': 'https://registry.npmjs.org/' } : process.env });\n if (result.error) throw result.error;\n return result.status ?? 1;\n}\n\nfunction main() {\n const shared = workspaceKit(cwd) ?? workspaceKit(here);\n const installed = join(here, 'node_modules/@fusebase/harness-lead');\n const cache = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'harness-lead', 'standalone');\n const cached = join(cache, 'node_modules/@fusebase/harness-lead');\n let kit = shared ?? (existsSync(cli(cached)) ? cached : installed);\n if (!shared && (args[0] === 'update' || !existsSync(cli(kit)))) {\n if (hook) return 0;\n if (args[0] === 'update' && args.length > 1) throw new Error('Standalone launcher update refreshes the user cache. Run the chosen kit directly for an explicit source.');\n mkdirSync(cache, { recursive: true });\n const status = run('npm', ['install', '--prefix', cache, '--no-save', '--no-package-lock', '--ignore-scripts', '--no-audit', '--no-fund',\n args[0] === 'update' ? '@fusebase/harness-lead@latest' : '@fusebase/harness-lead@0.3.
|
|
7552
|
+
"workspace-launcher.mjs": "#!/usr/bin/env node\n// evercrew:workspace-entry\n// Portable entry point. The runtime belongs to the workspace or to the user's npm cache.\nimport { spawnSync } from 'node:child_process';\nimport { existsSync, mkdirSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst args = process.argv.slice(2);\nconst here = dirname(dirname(fileURLToPath(import.meta.url)));\nconst hook = args[0] === 'stop-check' || args[0] === 'session-start';\nconst cwdFlag = args.indexOf('--cwd');\nconst cwd = cwdFlag >= 0 && args[cwdFlag + 1] ? resolve(args[cwdFlag + 1]) : process.cwd();\nconst cli = (kit) => join(kit, 'dist/lead.mjs');\n\nfunction workspaceKit(start) {\n let dir = realpathSync(start);\n while (true) {\n if (existsSync(join(dir, '.lead/workspace.yml'))) {\n const kit = join(dir, '.lead/workspace-kit');\n if (existsSync(cli(kit))) return kit;\n if (hook) return;\n throw new Error(`The lead workspace at ${dir} has no runtime. Deploy its kit first.`);\n }\n if (dirname(dir) === dir) return;\n dir = dirname(dir);\n }\n}\n\nfunction run(bin, argv, diagnosticsOnly = false) {\n const result = spawnSync(bin, argv, { stdio: diagnosticsOnly ? ['inherit', 2, 2] : 'inherit', env: bin === 'npm' ? { ...process.env, 'npm_config_@fusebase:registry': 'https://registry.npmjs.org/' } : process.env });\n if (result.error) throw result.error;\n return result.status ?? 1;\n}\n\nfunction main() {\n const shared = workspaceKit(cwd) ?? workspaceKit(here);\n const installed = join(here, 'node_modules/@fusebase/harness-lead');\n const cache = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'harness-lead', 'standalone');\n const cached = join(cache, 'node_modules/@fusebase/harness-lead');\n let kit = shared ?? (existsSync(cli(cached)) ? cached : installed);\n if (!shared && (args[0] === 'update' || !existsSync(cli(kit)))) {\n if (hook) return 0;\n if (args[0] === 'update' && args.length > 1) throw new Error('Standalone launcher update refreshes the user cache. Run the chosen kit directly for an explicit source.');\n mkdirSync(cache, { recursive: true });\n const status = run('npm', ['install', '--prefix', cache, '--no-save', '--no-package-lock', '--ignore-scripts', '--no-audit', '--no-fund',\n args[0] === 'update' ? '@fusebase/harness-lead@latest' : '@fusebase/harness-lead@0.3.3'], true);\n if (status || !existsSync(cli(cached))) return status || 1;\n kit = cached;\n if (args[0] === 'update') return run(process.execPath, [cli(kit), 'version']);\n }\n if (args[0] === 'kit-path') {\n console.log(realpathSync(kit));\n return 0;\n }\n return run(process.execPath, [cli(kit), ...args]);\n}\n\ntry { process.exitCode = main(); }\ncatch (error) {\n if (!hook) console.error(`lead: ${error.message}`);\n process.exitCode = hook ? 0 : 1;\n}\n",
|
|
7553
7553
|
"backlog-index.md": '# <Project> Backlog\n\n[One Pager](one-pager.md)\n\n## Reviewed backlog\n\n<!-- evercrew:view kind="proposals" -->\n<!-- /evercrew:view -->\n\n## Needs triage\n\n<!-- For each candidate, link the task note and record what needs clarification. -->\n\n## Triage decisions\n\n<!-- Link source evidence and explain why an item was linked, completed, deferred or superseded. -->\n\n## History\n\n<!-- Link the complete source reconciliation, including repeated entries. -->\n',
|
|
7554
7554
|
"one-pager.md": '---\nmilestones:\n - id: mvp\n title: MVP\n shows: ""\n status: current\n---\n# <Project> \u2014 One Pager\n\n## Status now\n\n<!-- 3\u20134 sentences, written by a human. -->\n\n**What to show.**\n\n**What landed.**\n\n**Evidence.** <!-- Add the date, source revision, checks and open verification. -->\n\n<!-- evercrew:view kind="stats" -->\n<!-- /evercrew:view -->\n\n## Needs attention\n\n<!-- Decisions and immediate checks. Link the evidence and name the owner when known. -->\n\n## Product bet\n\n<!-- One sentence. -->\n\n## Research\n\nConclusions only. The long note is [the research](spec/01-research.md).\n\n<!-- Paste ### Conclusions from spec/01-research.md. Do not paste the rest. -->\n\n## Readiness\n\n<!-- evercrew:view kind="readiness" -->\n<!-- /evercrew:view -->\n\n## Roadmap\n\n<!-- evercrew:view kind="order" -->\n<!-- /evercrew:view -->\n\n## Next 3 steps\n\n<!-- evercrew:view kind="next-steps" -->\n<!-- /evercrew:view -->\n\n## Inbox triage\n\nTick an item when the team agrees to take it into the plan. Review higher priorities first, then use list order within each priority.\n\n<!-- Example: add real rows and remove this comment.\n:::checklist[Take into the plan]\n::check[:badge[Feature request]{tone="info"} :badge[High]{tone="danger"} Task summary \xB7 [Task note](tasks/T-001-example.md)]{done="false"}\n:::\n-->\n\n## Next versions (do not promise on a demo)\n\n## Reference\n\n- [Execution board](board.md)\n- [Backlog and triage decisions](backlog.md)\n<!-- Link history, architecture and QA evidence once available. -->\n',
|
|
7555
7555
|
"task-note.md": "# <Task summary>\n\n## Links\n\n<!-- Fill the links or document permitted exceptions before publishing. -->\n\n- [Epic](https://example.invalid/epic)\n- [Jira Story](https://example.invalid/story)\n- [Proposal](https://example.invalid/proposal)\n- [Mockup](https://example.invalid/mockup)\n- [One Pager](https://example.invalid/one-pager)\n\n## Goal\n\n<!-- Describe the user need and intended outcome. -->\n\n## User flow\n\n<!-- Add a Mermaid diagram covering the requested path. -->\n\n## Technical design\n\n<!-- Describe changes, interfaces, and relevant constraints. -->\n\n## Decisions\n\n<!-- Record agreed decisions and tradeoffs. -->\n\n## Acceptance criteria\n\n<!-- State observable checks and expected results. -->\n\n## Out of scope\n\n<!-- Name exclusions or say whether there are none. -->\n"
|
|
@@ -8241,29 +8241,29 @@ function read(root) {
|
|
|
8241
8241
|
}
|
|
8242
8242
|
function ensureClaudeSettings(root) {
|
|
8243
8243
|
const s = read(root);
|
|
8244
|
-
const
|
|
8244
|
+
const log2 = [];
|
|
8245
8245
|
s.hooks ??= {};
|
|
8246
8246
|
for (const [event, command] of Object.entries(HOOKS)) {
|
|
8247
8247
|
const list = s.hooks[event] ??= [];
|
|
8248
8248
|
if (!list.some((e) => e.hooks?.some((h2) => h2.command === command))) {
|
|
8249
8249
|
list.push({ hooks: [{ type: "command", command }] });
|
|
8250
|
-
|
|
8250
|
+
log2.push(`${CLAUDE_SETTINGS}: added ${event} hook`);
|
|
8251
8251
|
}
|
|
8252
8252
|
}
|
|
8253
8253
|
if (s.permissions?.allow) {
|
|
8254
8254
|
const before = s.permissions.allow.length;
|
|
8255
8255
|
s.permissions.allow = s.permissions.allow.filter((r) => !OLD_ALLOW.includes(r));
|
|
8256
|
-
if (s.permissions.allow.length !== before)
|
|
8256
|
+
if (s.permissions.allow.length !== before) log2.push(`${CLAUDE_SETTINGS}: removed lead's shared allow rules`);
|
|
8257
8257
|
if (!s.permissions.allow.length) delete s.permissions.allow;
|
|
8258
8258
|
if (!Object.keys(s.permissions).length) delete s.permissions;
|
|
8259
8259
|
}
|
|
8260
|
-
if (
|
|
8260
|
+
if (log2.length) {
|
|
8261
8261
|
const p = join10(root, CLAUDE_SETTINGS);
|
|
8262
8262
|
mkdirSync2(dirname(p), { recursive: true });
|
|
8263
8263
|
writeFileSync3(p, `${JSON.stringify(s, null, 2)}
|
|
8264
8264
|
`);
|
|
8265
8265
|
}
|
|
8266
|
-
return
|
|
8266
|
+
return log2;
|
|
8267
8267
|
}
|
|
8268
8268
|
function claudeSettingsOk(root) {
|
|
8269
8269
|
const s = read(root);
|
|
@@ -8279,25 +8279,25 @@ var CODEX = { SessionStart: `${CODEX_CLI} session-start`, Stop: `${CODEX_CLI} st
|
|
|
8279
8279
|
function ensureCodexHooks(root) {
|
|
8280
8280
|
const p = join10(root, CODEX_HOOKS);
|
|
8281
8281
|
const s = existsSync9(p) ? JSON.parse(readFileSync8(p, "utf8")) : {};
|
|
8282
|
-
const
|
|
8282
|
+
const log2 = [];
|
|
8283
8283
|
s.hooks ??= {};
|
|
8284
8284
|
for (const [event, command] of Object.entries(CODEX)) {
|
|
8285
8285
|
const list = s.hooks[event] ??= [];
|
|
8286
8286
|
if (!list.some((e) => e.hooks?.some((h2) => h2.command === command))) {
|
|
8287
8287
|
list.push({ hooks: [{ type: "command", command, ...event === "Stop" ? { timeout: 120 } : {} }] });
|
|
8288
|
-
|
|
8288
|
+
log2.push(`${CODEX_HOOKS}: added ${event} hook`);
|
|
8289
8289
|
}
|
|
8290
8290
|
}
|
|
8291
|
-
if (
|
|
8291
|
+
if (log2.length) {
|
|
8292
8292
|
mkdirSync2(dirname(p), { recursive: true });
|
|
8293
8293
|
writeFileSync3(p, `${JSON.stringify(s, null, 2)}
|
|
8294
8294
|
`);
|
|
8295
8295
|
}
|
|
8296
|
-
return
|
|
8296
|
+
return log2;
|
|
8297
8297
|
}
|
|
8298
8298
|
|
|
8299
8299
|
// src/install.ts
|
|
8300
|
-
var VERSION = true ? "0.3.
|
|
8300
|
+
var VERSION = true ? "0.3.3" : "dev";
|
|
8301
8301
|
var LOCK_PATH = ".lead/kit.lock";
|
|
8302
8302
|
var SKILLS = ["lead", "crew-lead", "lead-goal"];
|
|
8303
8303
|
var SKILL_DIRS = [".agents/skills", ".claude/skills"];
|
|
@@ -8342,7 +8342,7 @@ ${block}
|
|
|
8342
8342
|
return "added";
|
|
8343
8343
|
}
|
|
8344
8344
|
function install(kitRoot2, target, cliPath, opts = {}) {
|
|
8345
|
-
const
|
|
8345
|
+
const log2 = [];
|
|
8346
8346
|
const prev = readLock(target);
|
|
8347
8347
|
const files2 = {};
|
|
8348
8348
|
const put = (src, rel) => {
|
|
@@ -8353,10 +8353,10 @@ function install(kitRoot2, target, cliPath, opts = {}) {
|
|
|
8353
8353
|
mkdirSync3(dirname2(side), { recursive: true });
|
|
8354
8354
|
copyFileSync(src, side);
|
|
8355
8355
|
files2[rel] = prev.files[rel];
|
|
8356
|
-
|
|
8356
|
+
log2.push(`kept ${rel}: changed by hand; new kit version is in .lead/update/${rel} \u2014 move the local change to .lead/local/ and run update --force`);
|
|
8357
8357
|
return;
|
|
8358
8358
|
}
|
|
8359
|
-
if (changedByHand)
|
|
8359
|
+
if (changedByHand) log2.push(`overwrote ${rel}: it was changed by hand`);
|
|
8360
8360
|
mkdirSync3(dirname2(dst), { recursive: true });
|
|
8361
8361
|
copyFileSync(src, dst);
|
|
8362
8362
|
files2[rel] = sha256(dst);
|
|
@@ -8369,24 +8369,24 @@ function install(kitRoot2, target, cliPath, opts = {}) {
|
|
|
8369
8369
|
}
|
|
8370
8370
|
put(cliPath, ".lead/lead.mjs");
|
|
8371
8371
|
const block = TEMPLATES["AGENTS.block.md"].trim();
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8372
|
+
log2.push(`AGENTS.md: ${upsertBlock(join11(target, "AGENTS.md"), block, "# Agent instructions\n\n")} lead block`);
|
|
8373
|
+
log2.push(...ensureGitIgnore(target));
|
|
8374
|
+
log2.push(...ensureClaudeSettings(target));
|
|
8375
|
+
log2.push(...ensureCodexHooks(target));
|
|
8376
8376
|
const lock = { version: VERSION, files: files2 };
|
|
8377
8377
|
writeFileSync4(join11(target, LOCK_PATH), `${JSON.stringify(lock, null, 2)}
|
|
8378
8378
|
`);
|
|
8379
|
-
|
|
8380
|
-
return
|
|
8379
|
+
log2.push(prev && prev.version !== VERSION ? `updated lead ${prev.version} \u2192 ${VERSION}: ${Object.keys(files2).length} kit files` : `installed lead ${VERSION}: ${Object.keys(files2).length} kit files`);
|
|
8380
|
+
return log2;
|
|
8381
8381
|
}
|
|
8382
8382
|
function scaffold(root, project) {
|
|
8383
|
-
const
|
|
8383
|
+
const log2 = [];
|
|
8384
8384
|
const make = (rel, template) => {
|
|
8385
8385
|
const abs = join11(root, rel);
|
|
8386
8386
|
if (existsSync10(abs)) return;
|
|
8387
8387
|
mkdirSync3(dirname2(abs), { recursive: true });
|
|
8388
8388
|
writeFileSync4(abs, TEMPLATES[template]);
|
|
8389
|
-
|
|
8389
|
+
log2.push(`created ${rel}`);
|
|
8390
8390
|
};
|
|
8391
8391
|
make(CONFIG_PATH, "config.yml");
|
|
8392
8392
|
make(".lead/local.md", "local.md");
|
|
@@ -8406,11 +8406,11 @@ function scaffold(root, project) {
|
|
|
8406
8406
|
if (!existsSync10(abs)) {
|
|
8407
8407
|
mkdirSync3(abs, { recursive: true });
|
|
8408
8408
|
writeFileSync4(join11(abs, ".gitkeep"), "");
|
|
8409
|
-
|
|
8409
|
+
log2.push(`created ${join11(work, d)}/`);
|
|
8410
8410
|
}
|
|
8411
8411
|
}
|
|
8412
8412
|
}
|
|
8413
|
-
return
|
|
8413
|
+
return log2;
|
|
8414
8414
|
}
|
|
8415
8415
|
function ensureGitIgnore(root) {
|
|
8416
8416
|
const file = join11(root, ".gitignore");
|
|
@@ -8764,16 +8764,16 @@ function writeInitiativeWaves(root, i) {
|
|
|
8764
8764
|
const { tasks } = loadInitiativeTasks(root, i);
|
|
8765
8765
|
const waves = initiativeWaves(tasks, i);
|
|
8766
8766
|
if (!waves) throw new Error("dependency cycle: fix blocked_by first (run `lead initiative check`)");
|
|
8767
|
-
const
|
|
8767
|
+
const log2 = [];
|
|
8768
8768
|
for (const t of tasks) {
|
|
8769
8769
|
const w = waves.get(t.id);
|
|
8770
8770
|
if (w === void 0 || w === t.wave || t.status === "done") continue;
|
|
8771
8771
|
updateTask(root, t, (d) => {
|
|
8772
8772
|
d.wave = w;
|
|
8773
8773
|
});
|
|
8774
|
-
|
|
8774
|
+
log2.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
|
|
8775
8775
|
}
|
|
8776
|
-
return
|
|
8776
|
+
return log2.length ? log2 : ["waves are up to date"];
|
|
8777
8777
|
}
|
|
8778
8778
|
function checkInitiative(root, i, ws) {
|
|
8779
8779
|
const { tasks, issues } = loadInitiativeTasks(root, i);
|
|
@@ -9267,8 +9267,8 @@ function writeEntrypoints(root) {
|
|
|
9267
9267
|
}
|
|
9268
9268
|
|
|
9269
9269
|
// src/cli.ts
|
|
9270
|
-
import { execFileSync as execFileSync6, spawnSync as
|
|
9271
|
-
import { existsSync as
|
|
9270
|
+
import { execFileSync as execFileSync6, spawnSync as spawnSync4 } from "node:child_process";
|
|
9271
|
+
import { existsSync as existsSync31, mkdtempSync as mkdtempSync3, rmSync as rmSync6 } from "node:fs";
|
|
9272
9272
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
9273
9273
|
|
|
9274
9274
|
// src/mode.ts
|
|
@@ -9425,7 +9425,7 @@ function recordChecks(ctx, t, opts) {
|
|
|
9425
9425
|
const stamp = now.toISOString().replace(/[:.]/g, "-");
|
|
9426
9426
|
const logRel = `.lead/logs/${t.id}-${stamp}.log`;
|
|
9427
9427
|
mkdirSync7(join20(ctx.root, ".lead/logs"), { recursive: true });
|
|
9428
|
-
let
|
|
9428
|
+
let log2 = "";
|
|
9429
9429
|
const commands = [];
|
|
9430
9430
|
const failures = [];
|
|
9431
9431
|
for (const [name, template] of checks) {
|
|
@@ -9433,14 +9433,14 @@ function recordChecks(ctx, t, opts) {
|
|
|
9433
9433
|
const r = spawnSync2("sh", ["-c", cmd], { cwd: dir, encoding: "utf8", timeout: 15 * 60 * 1e3, maxBuffer: 64 * 1024 * 1024 });
|
|
9434
9434
|
const code = r.status ?? 1;
|
|
9435
9435
|
const output = `${r.stdout ?? ""}${r.stderr ?? ""}`;
|
|
9436
|
-
|
|
9436
|
+
log2 += `$ ${cmd} (${name}, exit ${code})
|
|
9437
9437
|
${output}
|
|
9438
9438
|
`;
|
|
9439
9439
|
commands.push({ cmd, exit_code: code });
|
|
9440
9440
|
if (code !== 0) failures.push(`${name} (exit ${code}):
|
|
9441
9441
|
${tail(output, 40)}`);
|
|
9442
9442
|
}
|
|
9443
|
-
writeFileSync8(join20(ctx.root, logRel),
|
|
9443
|
+
writeFileSync8(join20(ctx.root, logRel), log2);
|
|
9444
9444
|
const commit = treeId(dir);
|
|
9445
9445
|
const round = t.rounds + 1;
|
|
9446
9446
|
const summary = commands.map((c) => `\`${c.cmd}\` \u2192 ${c.exit_code}`).join(", ");
|
|
@@ -10465,7 +10465,7 @@ function syncRecord(ctx, action, result) {
|
|
|
10465
10465
|
function writeWaves(ctx) {
|
|
10466
10466
|
const waves = computeWaves(ctx.tasks, ctx.config.shared_paths);
|
|
10467
10467
|
if (!waves) throw new Error("dependency cycle: fix blocked_by first (run `lead check`)");
|
|
10468
|
-
const
|
|
10468
|
+
const log2 = [];
|
|
10469
10469
|
for (const t of ctx.tasks) {
|
|
10470
10470
|
const w = waves.get(t.id);
|
|
10471
10471
|
if (w === void 0 || w === t.wave || t.status === "done") continue;
|
|
@@ -10475,13 +10475,13 @@ function writeWaves(ctx) {
|
|
|
10475
10475
|
if (!parsed) continue;
|
|
10476
10476
|
parsed.data.wave = w;
|
|
10477
10477
|
writeFileSync10(abs, renderFrontmatter(parsed.data, parsed.body));
|
|
10478
|
-
|
|
10478
|
+
log2.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
|
|
10479
10479
|
}
|
|
10480
|
-
return
|
|
10480
|
+
return log2;
|
|
10481
10481
|
}
|
|
10482
10482
|
function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
10483
10483
|
if (!ctx.project) throw new Error("no project selected");
|
|
10484
|
-
const
|
|
10484
|
+
const log2 = [];
|
|
10485
10485
|
const board = renderBoard({ projectName: ctx.project.name, tasks: ctx.tasks, onePager: ctx.onePager, config: ctx.config });
|
|
10486
10486
|
const boardPath = join23(ctx.project.workDir, "board.md");
|
|
10487
10487
|
let old = "";
|
|
@@ -10491,14 +10491,14 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10491
10491
|
}
|
|
10492
10492
|
if (old !== board) {
|
|
10493
10493
|
writeFileSync10(boardPath, board);
|
|
10494
|
-
|
|
10494
|
+
log2.push("board.md updated");
|
|
10495
10495
|
}
|
|
10496
10496
|
if (ctx.onePager) {
|
|
10497
10497
|
const blocks = renderOnePagerBlocks(ctx.tasks, ctx.onePager.milestones, isMerged, ctx.config.can_show);
|
|
10498
10498
|
const next = replaceBlocks(ctx.onePager.text, (k) => blocks[k]);
|
|
10499
10499
|
if (next !== ctx.onePager.text) {
|
|
10500
10500
|
writeFileSync10(join23(ctx.root, ctx.onePager.file), next);
|
|
10501
|
-
|
|
10501
|
+
log2.push(`one-pager.md blocks updated: ${blockKinds(next).join(", ")}`);
|
|
10502
10502
|
}
|
|
10503
10503
|
}
|
|
10504
10504
|
const backlog = join23(ctx.project.workDir, "backlog.md");
|
|
@@ -10507,14 +10507,14 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
|
|
|
10507
10507
|
const next = replaceBlocks(current, (kind) => ["tasks", "proposals"].includes(kind) ? renderBacklogItems(ctx.project.workDir) : void 0);
|
|
10508
10508
|
if (next !== current) {
|
|
10509
10509
|
writeFileSync10(backlog, next);
|
|
10510
|
-
|
|
10510
|
+
log2.push("backlog.md tasks updated");
|
|
10511
10511
|
}
|
|
10512
10512
|
}
|
|
10513
|
-
return
|
|
10513
|
+
return log2;
|
|
10514
10514
|
}
|
|
10515
10515
|
|
|
10516
10516
|
// src/cli.ts
|
|
10517
|
-
import { readFileSync as
|
|
10517
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
10518
10518
|
|
|
10519
10519
|
// src/inbox.ts
|
|
10520
10520
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -10739,8 +10739,188 @@ function delegatedTasks(tasks, id2) {
|
|
|
10739
10739
|
|
|
10740
10740
|
// src/watch.ts
|
|
10741
10741
|
import { spawn } from "node:child_process";
|
|
10742
|
-
import { existsSync as
|
|
10742
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync11, readFileSync as readFileSync23, writeFileSync as writeFileSync13 } from "node:fs";
|
|
10743
|
+
import { join as join28 } from "node:path";
|
|
10744
|
+
|
|
10745
|
+
// src/probe.ts
|
|
10746
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
10747
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
10748
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "node:fs";
|
|
10743
10749
|
import { join as join27 } from "node:path";
|
|
10750
|
+
var PROBE_LOG = ".lead/logs/watch-probe.jsonl";
|
|
10751
|
+
var PROBE_STATE = ".lead/logs/watch-probe-state.json";
|
|
10752
|
+
var FORCED_AFTER_MS = 24 * 60 * 60 * 1e3;
|
|
10753
|
+
var GATE = { days: 7, ticks: 200, maxUnknownRatio: 0.05 };
|
|
10754
|
+
var shell = (cmd, args) => {
|
|
10755
|
+
const r = spawnSync3(cmd, args, { encoding: "utf8", timeout: 6e4, maxBuffer: 16 * 1024 * 1024 });
|
|
10756
|
+
return { ok: r.status === 0 && !r.error, stdout: r.stdout ?? "", error: r.error?.message ?? (r.status === 0 ? void 0 : (r.stderr ?? "").trim().split("\n")[0]) };
|
|
10757
|
+
};
|
|
10758
|
+
var MR_URL = /https?:\/\/([^\s/)>\]]+)\/([^\s)>\]]+?)\/-\/merge_requests\/(\d+)/g;
|
|
10759
|
+
function mrUrls(text) {
|
|
10760
|
+
return [...new Set([...text.matchAll(MR_URL)].map((m) => m[0]))].sort();
|
|
10761
|
+
}
|
|
10762
|
+
function fetchMr(url, run2) {
|
|
10763
|
+
const m = new RegExp(MR_URL.source).exec(url);
|
|
10764
|
+
if (!m) return { url, unavailable: "not a merge request address" };
|
|
10765
|
+
const r = run2("glab", ["api", "--hostname", m[1], `projects/${encodeURIComponent(m[2])}/merge_requests/${m[3]}`]);
|
|
10766
|
+
if (!r.ok) return { url, unavailable: `glab: ${r.error ?? "failed"}` };
|
|
10767
|
+
try {
|
|
10768
|
+
const d = JSON.parse(r.stdout);
|
|
10769
|
+
const pipe = d.head_pipeline ?? d.pipeline;
|
|
10770
|
+
return {
|
|
10771
|
+
url,
|
|
10772
|
+
state: String(d.state ?? ""),
|
|
10773
|
+
sha: String(d.sha ?? ""),
|
|
10774
|
+
pipeline: String(pipe?.status ?? "none"),
|
|
10775
|
+
mergeStatus: String(d.detailed_merge_status ?? d.merge_status ?? ""),
|
|
10776
|
+
conflicts: d.has_conflicts === true,
|
|
10777
|
+
discussionsResolved: d.blocking_discussions_resolved !== false,
|
|
10778
|
+
notes: Number(d.user_notes_count ?? 0)
|
|
10779
|
+
};
|
|
10780
|
+
} catch {
|
|
10781
|
+
return { url, unavailable: "glab: unreadable answer" };
|
|
10782
|
+
}
|
|
10783
|
+
}
|
|
10784
|
+
function fetchJira(key, run2, command = process.env.LEAD_WATCH_JIRA_COMMAND) {
|
|
10785
|
+
if (!command) return { unavailable: "LEAD_WATCH_JIRA_COMMAND is not set" };
|
|
10786
|
+
if (!/^[A-Z][A-Z0-9]*-\d+$/.test(key)) return { unavailable: `"${key}" is not an issue key` };
|
|
10787
|
+
const r = run2("sh", ["-c", `${command} "$1"`, "sh", key]);
|
|
10788
|
+
if (!r.ok) return { unavailable: `tracker command: ${r.error ?? "failed"}` };
|
|
10789
|
+
try {
|
|
10790
|
+
const d = JSON.parse(r.stdout);
|
|
10791
|
+
if (typeof d.status !== "string" || !d.status) return { unavailable: "tracker command: no status in the answer" };
|
|
10792
|
+
return { status: d.status, ...typeof d.updated === "string" ? { updated: d.updated } : {}, ...typeof d.comments === "number" ? { comments: d.comments } : {} };
|
|
10793
|
+
} catch {
|
|
10794
|
+
return { unavailable: "tracker command: unreadable answer" };
|
|
10795
|
+
}
|
|
10796
|
+
}
|
|
10797
|
+
function collectFacts(root, run2 = shell, jiraCommand) {
|
|
10798
|
+
const ctx = loadContext(root);
|
|
10799
|
+
return delegatedTasks(ctx.tasks).filter((t) => t.status !== "done").map((t) => {
|
|
10800
|
+
const text = existsSync25(join27(root, t.file)) ? readFileSync22(join27(root, t.file), "utf8") : "";
|
|
10801
|
+
return {
|
|
10802
|
+
task: t.id,
|
|
10803
|
+
...t.delegate_ref ? { ref: t.delegate_ref } : {},
|
|
10804
|
+
...t.delegate_ref ? { jira: fetchJira(t.delegate_ref, run2, jiraCommand ?? process.env.LEAD_WATCH_JIRA_COMMAND) } : {},
|
|
10805
|
+
mrs: mrUrls(text).map((u) => fetchMr(u, run2))
|
|
10806
|
+
};
|
|
10807
|
+
});
|
|
10808
|
+
}
|
|
10809
|
+
var canon = (v) => Array.isArray(v) ? v.map(canon) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b)).map(([k, x]) => [k, canon(x)])) : v;
|
|
10810
|
+
var fingerprint = (f) => createHash8("sha256").update(JSON.stringify(canon(f))).digest("hex").slice(0, 16);
|
|
10811
|
+
var unavailable = (x) => !!x && typeof x === "object" && "unavailable" in x;
|
|
10812
|
+
function classify(f, st, state, now) {
|
|
10813
|
+
const fp = fingerprint(f);
|
|
10814
|
+
const reasons = [];
|
|
10815
|
+
const bad = [f.jira, ...f.mrs].filter(unavailable);
|
|
10816
|
+
const base = { task: f.task, fingerprint: fp };
|
|
10817
|
+
if (bad.length) return { ...base, class: "unknown", needsAi: true, reasons: bad.map((b) => b.unavailable) };
|
|
10818
|
+
if (!st?.handled) return { ...base, class: "new", needsAi: true, reasons: ["no acknowledged check yet"] };
|
|
10819
|
+
const stale = !state.lastAck || now.getTime() - new Date(state.lastAck).getTime() > FORCED_AFTER_MS;
|
|
10820
|
+
if (st.handled === fp) return stale ? { ...base, class: "forced", needsAi: true, reasons: ["full check due: none acknowledged for 24 hours"] } : { ...base, class: "quiet", needsAi: false, reasons: [] };
|
|
10821
|
+
const mrs = f.mrs.filter((m) => !unavailable(m));
|
|
10822
|
+
const status2 = unavailable(f.jira) ? "" : f.jira?.status ?? "";
|
|
10823
|
+
let cls = "changed";
|
|
10824
|
+
if (mrs.some((m) => m.conflicts)) cls = "conflict", reasons.push("a merge request has conflicts");
|
|
10825
|
+
else if (mrs.some((m) => m.pipeline === "failed")) cls = "ci_failed", reasons.push("a pipeline failed");
|
|
10826
|
+
else if (/human review/i.test(status2)) cls = "review", reasons.push(`status ${status2}`);
|
|
10827
|
+
else if (/blocked/i.test(status2)) cls = "blocked", reasons.push(`status ${status2}`);
|
|
10828
|
+
else if (/dev check/i.test(status2)) cls = "dev_check", reasons.push(`status ${status2}`);
|
|
10829
|
+
else if (/clarification/i.test(status2)) cls = "clarification", reasons.push(`status ${status2}`);
|
|
10830
|
+
else if (/ready for qa/i.test(status2)) cls = "qa", reasons.push(`status ${status2}`);
|
|
10831
|
+
else if (/^done$/i.test(status2)) cls = "done", reasons.push(`status ${status2}`);
|
|
10832
|
+
else reasons.push("facts changed since the last acknowledged check");
|
|
10833
|
+
return { ...base, class: cls, needsAi: true, reasons };
|
|
10834
|
+
}
|
|
10835
|
+
function readState(root) {
|
|
10836
|
+
try {
|
|
10837
|
+
const d = JSON.parse(readFileSync22(join27(root, PROBE_STATE), "utf8"));
|
|
10838
|
+
return { tasks: d.tasks ?? {}, ...d.lastAck ? { lastAck: d.lastAck } : {} };
|
|
10839
|
+
} catch {
|
|
10840
|
+
return { tasks: {} };
|
|
10841
|
+
}
|
|
10842
|
+
}
|
|
10843
|
+
var writeState = (root, s) => {
|
|
10844
|
+
mkdirSync10(join27(root, ".lead/logs"), { recursive: true });
|
|
10845
|
+
writeFileSync12(join27(root, PROBE_STATE), `${JSON.stringify(s, null, 2)}
|
|
10846
|
+
`);
|
|
10847
|
+
};
|
|
10848
|
+
var log = (root, record) => {
|
|
10849
|
+
mkdirSync10(join27(root, ".lead/logs"), { recursive: true });
|
|
10850
|
+
appendFileSync2(join27(root, PROBE_LOG), `${JSON.stringify(record)}
|
|
10851
|
+
`);
|
|
10852
|
+
};
|
|
10853
|
+
function runProbe(root, opts = {}) {
|
|
10854
|
+
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
10855
|
+
const state = readState(root);
|
|
10856
|
+
const facts = collectFacts(root, opts.run ?? shell, opts.jiraCommand);
|
|
10857
|
+
const verdicts = facts.map((f) => classify(f, state.tasks[f.task], state, now));
|
|
10858
|
+
const result = { at: now.toISOString(), verdicts, wouldWake: verdicts.some((v) => v.needsAi) };
|
|
10859
|
+
if (opts.record !== false) {
|
|
10860
|
+
for (const v of verdicts) state.tasks[v.task] = { ...state.tasks[v.task], seen: v.fingerprint };
|
|
10861
|
+
writeState(root, state);
|
|
10862
|
+
log(root, { event: "probe", at: result.at, wouldWake: result.wouldWake, tasks: verdicts.map((v) => ({ task: v.task, class: v.class, fp: v.fingerprint })) });
|
|
10863
|
+
}
|
|
10864
|
+
return result;
|
|
10865
|
+
}
|
|
10866
|
+
function recordAck(root, acted, now = /* @__PURE__ */ new Date()) {
|
|
10867
|
+
const state = readState(root);
|
|
10868
|
+
for (const t of Object.values(state.tasks)) if (t.seen) t.handled = t.seen;
|
|
10869
|
+
state.lastAck = now.toISOString();
|
|
10870
|
+
writeState(root, state);
|
|
10871
|
+
log(root, { event: "ack", at: now.toISOString(), acted });
|
|
10872
|
+
}
|
|
10873
|
+
function report(root) {
|
|
10874
|
+
const lines = existsSync25(join27(root, PROBE_LOG)) ? readFileSync22(join27(root, PROBE_LOG), "utf8").split("\n").filter(Boolean) : [];
|
|
10875
|
+
const events = lines.flatMap((l) => {
|
|
10876
|
+
try {
|
|
10877
|
+
return [JSON.parse(l)];
|
|
10878
|
+
} catch {
|
|
10879
|
+
return [];
|
|
10880
|
+
}
|
|
10881
|
+
});
|
|
10882
|
+
const r = { ticks: 0, acked: 0, quiet: 0, wake: 0, unknown: 0, unreported: 0, misses: 0, falseWakes: 0, spanDays: 0, ready: false, blockers: [] };
|
|
10883
|
+
let last;
|
|
10884
|
+
for (const e of events) {
|
|
10885
|
+
if (e.event === "probe") {
|
|
10886
|
+
r.ticks++;
|
|
10887
|
+
r.firstAt ??= e.at;
|
|
10888
|
+
r.lastAt = e.at;
|
|
10889
|
+
if (e.wouldWake) r.wake++;
|
|
10890
|
+
else r.quiet++;
|
|
10891
|
+
if (e.tasks?.some((t) => t.class === "unknown")) r.unknown++;
|
|
10892
|
+
last = e;
|
|
10893
|
+
} else if (e.event === "ack" && last) {
|
|
10894
|
+
r.acked++;
|
|
10895
|
+
if (e.acted === null || e.acted === void 0) r.unreported++;
|
|
10896
|
+
if (!last.wouldWake && e.acted === true) r.misses++;
|
|
10897
|
+
if (last.wouldWake && e.acted === false) r.falseWakes++;
|
|
10898
|
+
last = void 0;
|
|
10899
|
+
}
|
|
10900
|
+
}
|
|
10901
|
+
r.spanDays = r.firstAt && r.lastAt ? (new Date(r.lastAt).getTime() - new Date(r.firstAt).getTime()) / 864e5 : 0;
|
|
10902
|
+
if (r.spanDays < GATE.days) r.blockers.push(`shadow run is ${r.spanDays.toFixed(1)} days, needs ${GATE.days}`);
|
|
10903
|
+
if (r.ticks < GATE.ticks) r.blockers.push(`${r.ticks} ticks, needs ${GATE.ticks}`);
|
|
10904
|
+
if (r.misses > 0) r.blockers.push(`${r.misses} tick(s) the probe called quiet but an agent acted on`);
|
|
10905
|
+
if (r.acked && r.unreported / r.acked > 0.1) r.blockers.push(`${r.unreported} of ${r.acked} acknowledgements did not say whether the agent acted (use --acted or --idle)`);
|
|
10906
|
+
if (r.ticks && r.unknown / r.ticks > GATE.maxUnknownRatio) r.blockers.push(`${r.unknown} of ${r.ticks} ticks had a source the probe could not read (limit ${GATE.maxUnknownRatio * 100}%)`);
|
|
10907
|
+
r.ready = r.blockers.length === 0;
|
|
10908
|
+
return r;
|
|
10909
|
+
}
|
|
10910
|
+
function renderVerdicts(r) {
|
|
10911
|
+
if (!r.verdicts.length) return ["no delegated tasks to probe"];
|
|
10912
|
+
return [`${r.wouldWake ? "an agent would be woken" : "quiet: no agent needed"} (${r.at})`, ...r.verdicts.map((v) => ` ${v.task} ${v.class}${v.reasons.length ? ` \u2014 ${v.reasons.join("; ")}` : ""}`)];
|
|
10913
|
+
}
|
|
10914
|
+
function renderReport(r) {
|
|
10915
|
+
return [
|
|
10916
|
+
`ticks ${r.ticks} (acknowledged ${r.acked}, without a note ${r.unreported}): quiet ${r.quiet}, would wake ${r.wake}, unreadable source ${r.unknown}`,
|
|
10917
|
+
`misses ${r.misses} (probe quiet, agent acted), unnecessary wakes ${r.falseWakes}`,
|
|
10918
|
+
`span ${r.spanDays.toFixed(1)} days${r.firstAt ? ` (${r.firstAt} \u2026 ${r.lastAt})` : ""}`,
|
|
10919
|
+
r.ready ? "ready: the probe agreed with every acknowledged check" : `not ready: ${r.blockers.join("; ")}`
|
|
10920
|
+
];
|
|
10921
|
+
}
|
|
10922
|
+
|
|
10923
|
+
// src/watch.ts
|
|
10744
10924
|
var WATCH_PATH = ".lead/watch.json";
|
|
10745
10925
|
var MIN_INTERVAL_MS = 5 * 60 * 1e3;
|
|
10746
10926
|
var DEFAULT_INTERVAL = "15m";
|
|
@@ -10753,18 +10933,18 @@ function parseInterval(text) {
|
|
|
10753
10933
|
return ms;
|
|
10754
10934
|
}
|
|
10755
10935
|
function readWatch(root) {
|
|
10756
|
-
const p =
|
|
10757
|
-
if (!
|
|
10936
|
+
const p = join28(root, WATCH_PATH);
|
|
10937
|
+
if (!existsSync26(p)) return { interval: DEFAULT_INTERVAL, close: false };
|
|
10758
10938
|
try {
|
|
10759
|
-
const d = JSON.parse(
|
|
10760
|
-
return { interval: typeof d.interval === "string" ? d.interval : DEFAULT_INTERVAL, close: d.close === true, pid: d.pid, startedAt: d.startedAt, due: d.due };
|
|
10939
|
+
const d = JSON.parse(readFileSync23(p, "utf8"));
|
|
10940
|
+
return { interval: typeof d.interval === "string" ? d.interval : DEFAULT_INTERVAL, close: d.close === true, pid: d.pid, startedAt: d.startedAt, due: d.due, ...d.probe === "shadow" ? { probe: "shadow" } : {} };
|
|
10761
10941
|
} catch {
|
|
10762
10942
|
return { interval: DEFAULT_INTERVAL, close: false };
|
|
10763
10943
|
}
|
|
10764
10944
|
}
|
|
10765
10945
|
function writeWatch(root, state) {
|
|
10766
|
-
|
|
10767
|
-
|
|
10946
|
+
mkdirSync11(join28(root, ".lead"), { recursive: true });
|
|
10947
|
+
writeFileSync13(join28(root, WATCH_PATH), `${JSON.stringify(state, null, 2)}
|
|
10768
10948
|
`);
|
|
10769
10949
|
}
|
|
10770
10950
|
function alive(pid) {
|
|
@@ -10780,6 +10960,7 @@ function watchStatus(root) {
|
|
|
10780
10960
|
const s = readWatch(root);
|
|
10781
10961
|
const on = alive(s.pid);
|
|
10782
10962
|
const bits = [`watch ${on ? "on" : "off"}`, `every ${s.interval}`, s.close ? "may close a finished milestone" : "asks before closing a milestone"];
|
|
10963
|
+
if (s.probe) bits.push(`probe ${s.probe}`);
|
|
10783
10964
|
if (s.due) bits.push(`check due since ${s.due}`);
|
|
10784
10965
|
return bits.join(", ");
|
|
10785
10966
|
}
|
|
@@ -10835,6 +11016,12 @@ function runWatchLoop(root, sleep = (ms) => Atomics.wait(new Int32Array(new Shar
|
|
|
10835
11016
|
sleep(ms);
|
|
10836
11017
|
const after = readWatch(root);
|
|
10837
11018
|
if (after.pid !== process.pid) return;
|
|
11019
|
+
if (after.probe === "shadow") {
|
|
11020
|
+
try {
|
|
11021
|
+
runProbe(root);
|
|
11022
|
+
} catch {
|
|
11023
|
+
}
|
|
11024
|
+
}
|
|
10838
11025
|
after.due = (/* @__PURE__ */ new Date()).toISOString();
|
|
10839
11026
|
writeWatch(root, after);
|
|
10840
11027
|
const cmd = process.env.LEAD_WATCH_COMMAND;
|
|
@@ -10843,15 +11030,15 @@ function runWatchLoop(root, sleep = (ms) => Atomics.wait(new Int32Array(new Shar
|
|
|
10843
11030
|
}
|
|
10844
11031
|
|
|
10845
11032
|
// src/mergehold.ts
|
|
10846
|
-
import { existsSync as
|
|
10847
|
-
import { join as
|
|
11033
|
+
import { existsSync as existsSync27, mkdirSync as mkdirSync12, readFileSync as readFileSync24, rmSync as rmSync5, writeFileSync as writeFileSync14 } from "node:fs";
|
|
11034
|
+
import { join as join29 } from "node:path";
|
|
10848
11035
|
var MERGE_LOCK = ".lead/merge.json";
|
|
10849
11036
|
var HOLD_MS = 15 * 60 * 1e3;
|
|
10850
11037
|
function read2(root) {
|
|
10851
|
-
const p =
|
|
10852
|
-
if (!
|
|
11038
|
+
const p = join29(root, MERGE_LOCK);
|
|
11039
|
+
if (!existsSync27(p)) return void 0;
|
|
10853
11040
|
try {
|
|
10854
|
-
return JSON.parse(
|
|
11041
|
+
return JSON.parse(readFileSync24(p, "utf8"));
|
|
10855
11042
|
} catch {
|
|
10856
11043
|
return void 0;
|
|
10857
11044
|
}
|
|
@@ -10862,9 +11049,9 @@ function holdMerge(root, opts) {
|
|
|
10862
11049
|
if (cur && cur.session !== opts.session && now.getTime() - Date.parse(cur.at) < HOLD_MS) {
|
|
10863
11050
|
return { ok: false, message: `${cur.task} merge is held by session ${cur.session} since ${cur.at}` };
|
|
10864
11051
|
}
|
|
10865
|
-
|
|
11052
|
+
mkdirSync12(join29(root, ".lead"), { recursive: true });
|
|
10866
11053
|
const lock = { task: opts.task, session: opts.session, mr: opts.mr, at: now.toISOString() };
|
|
10867
|
-
|
|
11054
|
+
writeFileSync14(join29(root, MERGE_LOCK), `${JSON.stringify(lock, null, 2)}
|
|
10868
11055
|
`);
|
|
10869
11056
|
return { ok: true, message: `merge ${opts.mr} held for ${opts.task}` };
|
|
10870
11057
|
}
|
|
@@ -10873,13 +11060,13 @@ function releaseMerge(root, opts) {
|
|
|
10873
11060
|
if (!cur) return { ok: true, message: "no merge hold" };
|
|
10874
11061
|
if (cur.task !== opts.task) return { ok: false, message: `merge hold is for ${cur.task}, not ${opts.task}` };
|
|
10875
11062
|
if (cur.session !== opts.session) return { ok: false, message: `merge hold belongs to session ${cur.session}` };
|
|
10876
|
-
rmSync5(
|
|
11063
|
+
rmSync5(join29(root, MERGE_LOCK), { force: true });
|
|
10877
11064
|
return { ok: true, message: `merge hold for ${opts.task} released` };
|
|
10878
11065
|
}
|
|
10879
11066
|
|
|
10880
11067
|
// src/activity.ts
|
|
10881
|
-
import { appendFileSync as
|
|
10882
|
-
import { join as
|
|
11068
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync28, mkdirSync as mkdirSync13, readdirSync as readdirSync14, readFileSync as readFileSync25 } from "node:fs";
|
|
11069
|
+
import { join as join30 } from "node:path";
|
|
10883
11070
|
var ACTIVITY_DIR = ".lead/activity";
|
|
10884
11071
|
var EVENTS = ["start", "end", "check", "status", "note", "wait", "merge"];
|
|
10885
11072
|
function isEvent(v) {
|
|
@@ -10897,21 +11084,21 @@ function appendActivity(root, entry) {
|
|
|
10897
11084
|
...entry.session ? { session: oneLine2(entry.session) } : {},
|
|
10898
11085
|
...entry.goal ? { goal: oneLine2(entry.goal) } : {}
|
|
10899
11086
|
};
|
|
10900
|
-
const rel =
|
|
10901
|
-
const abs =
|
|
10902
|
-
|
|
10903
|
-
|
|
11087
|
+
const rel = join30(ACTIVITY_DIR, `${at.slice(0, 10)}.jsonl`);
|
|
11088
|
+
const abs = join30(root, rel);
|
|
11089
|
+
mkdirSync13(join30(root, ACTIVITY_DIR), { recursive: true });
|
|
11090
|
+
appendFileSync3(abs, `${JSON.stringify(row)}
|
|
10904
11091
|
`);
|
|
10905
11092
|
return rel;
|
|
10906
11093
|
}
|
|
10907
11094
|
function readActivityDay(root, day) {
|
|
10908
|
-
const p =
|
|
10909
|
-
if (!
|
|
10910
|
-
return
|
|
11095
|
+
const p = join30(root, ACTIVITY_DIR, `${day}.jsonl`);
|
|
11096
|
+
if (!existsSync28(p)) return [];
|
|
11097
|
+
return readFileSync25(p, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
|
|
10911
11098
|
}
|
|
10912
11099
|
function listActivityDays(root) {
|
|
10913
|
-
const dir =
|
|
10914
|
-
if (!
|
|
11100
|
+
const dir = join30(root, ACTIVITY_DIR);
|
|
11101
|
+
if (!existsSync28(dir)) return [];
|
|
10915
11102
|
return readdirSync14(dir).filter((n) => /^\d{4}-\d{2}-\d{2}\.jsonl$/.test(n)).map((n) => n.replace(/\.jsonl$/, "")).sort();
|
|
10916
11103
|
}
|
|
10917
11104
|
function loadActivity(root, opts = {}) {
|
|
@@ -10984,8 +11171,8 @@ function oneLine2(s) {
|
|
|
10984
11171
|
|
|
10985
11172
|
// src/adopt.ts
|
|
10986
11173
|
var import_yaml4 = __toESM(require_dist(), 1);
|
|
10987
|
-
import { existsSync as
|
|
10988
|
-
import { dirname as dirname5, join as
|
|
11174
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync14, readFileSync as readFileSync26, writeFileSync as writeFileSync15 } from "node:fs";
|
|
11175
|
+
import { dirname as dirname5, join as join31 } from "node:path";
|
|
10989
11176
|
var REPO = /^[a-z][a-z0-9-]*$/;
|
|
10990
11177
|
var keyNum = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? 0);
|
|
10991
11178
|
function validateInventory(raw) {
|
|
@@ -11280,45 +11467,45 @@ function syncText(p) {
|
|
|
11280
11467
|
`;
|
|
11281
11468
|
}
|
|
11282
11469
|
function writeProposal(root, p, force = false) {
|
|
11283
|
-
const
|
|
11470
|
+
const log2 = [];
|
|
11284
11471
|
const put = (rel, text, regenerate) => {
|
|
11285
|
-
const abs =
|
|
11286
|
-
if (
|
|
11287
|
-
const prev =
|
|
11288
|
-
if (prev === text) return void
|
|
11289
|
-
if (!regenerate && !force) return void
|
|
11290
|
-
}
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
11472
|
+
const abs = join31(root, rel);
|
|
11473
|
+
if (existsSync29(abs)) {
|
|
11474
|
+
const prev = readFileSync26(abs, "utf8");
|
|
11475
|
+
if (prev === text) return void log2.push(`unchanged ${rel}`);
|
|
11476
|
+
if (!regenerate && !force) return void log2.push(`kept ${rel}: it already exists and differs; --force replaces it`);
|
|
11477
|
+
}
|
|
11478
|
+
mkdirSync14(dirname5(abs), { recursive: true });
|
|
11479
|
+
writeFileSync15(abs, text);
|
|
11480
|
+
log2.push(`wrote ${rel}`);
|
|
11294
11481
|
};
|
|
11295
11482
|
const dir = `${INITIATIVES_DIR}/${p.id}`;
|
|
11296
11483
|
put(`${dir}/initiative.md`, initiativeText(p), false);
|
|
11297
11484
|
put(`${dir}/one-pager.md`, onePagerText(p), false);
|
|
11298
11485
|
put(`.lead/adapters/${p.id}/SKILL.md`, adapterText(p), false);
|
|
11299
11486
|
put(`${dir}/sync.json`, syncText(p), true);
|
|
11300
|
-
return
|
|
11487
|
+
return log2;
|
|
11301
11488
|
}
|
|
11302
11489
|
|
|
11303
11490
|
// src/score.ts
|
|
11304
|
-
import { existsSync as
|
|
11305
|
-
import { join as
|
|
11491
|
+
import { existsSync as existsSync30, readdirSync as readdirSync15, readFileSync as readFileSync27 } from "node:fs";
|
|
11492
|
+
import { join as join32, relative as relative13 } from "node:path";
|
|
11306
11493
|
function rubrics(root, kit) {
|
|
11307
11494
|
const dirs = [
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11495
|
+
join32(kit, "skills/lead/scorers"),
|
|
11496
|
+
join32(root, ".claude/skills/lead/scorers"),
|
|
11497
|
+
join32(root, ".agents/skills/lead/scorers"),
|
|
11498
|
+
join32(root, ".lead/local/scorers")
|
|
11312
11499
|
];
|
|
11313
11500
|
const all = /* @__PURE__ */ new Map();
|
|
11314
|
-
for (const dir of dirs.filter(
|
|
11501
|
+
for (const dir of dirs.filter(existsSync30)) {
|
|
11315
11502
|
for (const name of readdirSync15(dir).sort()) {
|
|
11316
|
-
const file =
|
|
11317
|
-
if (
|
|
11503
|
+
const file = join32(dir, name, "scorer.md");
|
|
11504
|
+
if (existsSync30(file)) all.set(name, file);
|
|
11318
11505
|
}
|
|
11319
11506
|
}
|
|
11320
11507
|
return [...all].map(([id2, file]) => {
|
|
11321
|
-
const text =
|
|
11508
|
+
const text = readFileSync27(file, "utf8");
|
|
11322
11509
|
const { parsed } = parseFrontmatter(text, file);
|
|
11323
11510
|
const data = parsed?.data;
|
|
11324
11511
|
if (!data || !/^[a-z][a-z0-9_-]*$/.test(id2) || data.id !== id2 || typeof data.version !== "number" || !Number.isInteger(data.version) || data.version < 1 || !["task", "mockup", "qa"].includes(String(data.applies_to)) || typeof data.sample_rate !== "number" || !(data.sample_rate >= 0 && data.sample_rate <= 1) || typeof data.pass_threshold !== "number" || !Number.isFinite(data.pass_threshold)) {
|
|
@@ -11464,6 +11651,8 @@ Usage: node .lead/lead.mjs <command> [options]
|
|
|
11464
11651
|
initiative waves <id> [--write] compute (and with --write store) waves across the initiative's repositories
|
|
11465
11652
|
adapters [name] [--json] project adapters in .lead/adapters/ (rules for reading this project's existing records)
|
|
11466
11653
|
delegate [id] [check] [--json] services that can take a task, and tasks already handed off
|
|
11654
|
+
watch probe [report|shadow|off] [--dry] token-free pass over delegated tasks; shadow records its decision beside each tick
|
|
11655
|
+
watch ack [--acted|--idle] acknowledge a due check (--acted: an action was taken or required; --idle: nothing to do)
|
|
11467
11656
|
watch [start|stop|interval 15m|ack] local clock for delegated tasks (default 15m; --close on start)
|
|
11468
11657
|
improve print .lead/improve.md (stops, asks, what a kit change would avoid)
|
|
11469
11658
|
improve --kind stop|ask|avoidable --where TEXT --what TEXT [--avoid TEXT]
|
|
@@ -11503,7 +11692,7 @@ function watchLine(root) {
|
|
|
11503
11692
|
function kitRoot() {
|
|
11504
11693
|
return resolve3(dirname6(fileURLToPath(import.meta.url)), "..");
|
|
11505
11694
|
}
|
|
11506
|
-
var KNOWN_FLAGS = /* @__PURE__ */ new Set(["from", "keep-modified", "deny", "confirm", "reopen", "source", "json", "session", "project", "cwd", "tool", "force", "only", "verdict", "notes", "merged", "question", "write", "id", "result", "status", "worktree", "help", "close", "kind", "where", "what", "avoid", "mr", "event", "day", "goal", "task", "since", "input", "scorer", "run", "limit", "preview", "retry", "action", "discard", "repo", "home", "flag", "title", "in", "key"]);
|
|
11695
|
+
var KNOWN_FLAGS = /* @__PURE__ */ new Set(["from", "keep-modified", "deny", "confirm", "reopen", "source", "json", "session", "project", "cwd", "tool", "force", "only", "verdict", "notes", "merged", "question", "write", "id", "result", "status", "worktree", "help", "close", "kind", "where", "what", "avoid", "mr", "event", "day", "goal", "task", "since", "input", "scorer", "run", "limit", "preview", "retry", "action", "discard", "repo", "home", "flag", "title", "in", "key", "acted", "idle", "dry"]);
|
|
11507
11696
|
function main(argv, out = (s) => console.log(s)) {
|
|
11508
11697
|
const { cmd, args, flags } = parseArgs(argv);
|
|
11509
11698
|
const unknown = Object.keys(flags).filter((f) => !KNOWN_FLAGS.has(f));
|
|
@@ -11528,7 +11717,7 @@ function main(argv, out = (s) => console.log(s)) {
|
|
|
11528
11717
|
if (ws) {
|
|
11529
11718
|
const path = relative14(ws.root, realpathSync6(origin));
|
|
11530
11719
|
if (path === ".." || path.startsWith(".." + sep5)) throw new Error("the command directory is outside this workspace");
|
|
11531
|
-
sharedKit =
|
|
11720
|
+
sharedKit = join33(ws.root, RUNTIME);
|
|
11532
11721
|
}
|
|
11533
11722
|
if (flags.repo && (!ws || !str2(flags.repo))) throw new Error("--repo requires a workspace and repository name");
|
|
11534
11723
|
if (cmd === "workspace") {
|
|
@@ -11546,15 +11735,15 @@ function main(argv, out = (s) => console.log(s)) {
|
|
|
11546
11735
|
return 0;
|
|
11547
11736
|
}
|
|
11548
11737
|
if (args[0] === "improve") {
|
|
11549
|
-
const
|
|
11550
|
-
if (flags.json) out(JSON.stringify(
|
|
11738
|
+
const report2 = workspaceImprove(ws);
|
|
11739
|
+
if (flags.json) out(JSON.stringify(report2, null, 2));
|
|
11551
11740
|
else {
|
|
11552
|
-
out(`${
|
|
11553
|
-
for (const repo of
|
|
11741
|
+
out(`${report2.entries.length} improvement entries across ${report2.repositories.length} registered repositories`);
|
|
11742
|
+
for (const repo of report2.repositories) {
|
|
11554
11743
|
const malformed = repo.malformed?.length ? ` \xB7 unparsed headings at lines ${repo.malformed.join(", ")}` : "";
|
|
11555
11744
|
out(`- ${repo.id}: ${repo.count} \xB7 ${repo.state}${malformed}${repo.reason ? ` \xB7 ${repo.reason}` : ""}`);
|
|
11556
11745
|
}
|
|
11557
|
-
for (const entry of
|
|
11746
|
+
for (const entry of report2.entries) {
|
|
11558
11747
|
out(`
|
|
11559
11748
|
## ${entry.at} \u2014 ${entry.kind} \xB7 ${entry.repository}
|
|
11560
11749
|
${entry.source}:${entry.line}
|
|
@@ -11571,7 +11760,7 @@ ${entry.source}:${entry.line}
|
|
|
11571
11760
|
}
|
|
11572
11761
|
if (args[0] === "attach" && args[1]) {
|
|
11573
11762
|
const target = routeScope(ws, ws.root, void 0, args[1]).root;
|
|
11574
|
-
if (
|
|
11763
|
+
if (existsSync31(join33(target, ".lead/lead.mjs")) && !isPortableLauncher(target)) throw new Error("a lead entry point already exists; review and migrate it before attaching");
|
|
11575
11764
|
writeEntrypoints(target);
|
|
11576
11765
|
for (const line of [...ensureGitIgnore(target), ...ensureClaudeSettings(target), ...ensureCodexHooks(target)]) out(line);
|
|
11577
11766
|
out(`attached ${args[1]} to the shared lead workspace`);
|
|
@@ -11598,7 +11787,7 @@ ${entry.source}:${entry.line}
|
|
|
11598
11787
|
if (scope) {
|
|
11599
11788
|
cwd = scope.cwd;
|
|
11600
11789
|
project = scope.project;
|
|
11601
|
-
} else if (repoRoot(origin) === ws.root || !
|
|
11790
|
+
} else if (repoRoot(origin) === ws.root || !existsSync31(join33(repoRoot(origin), ".git"))) {
|
|
11602
11791
|
if (cmd === "session-start" && session) {
|
|
11603
11792
|
out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: `lead workspace session: ${session}. Pass --session ${session} to lead commands.` } }));
|
|
11604
11793
|
return 0;
|
|
@@ -11666,8 +11855,8 @@ ${entry.source}:${entry.line}
|
|
|
11666
11855
|
return 1;
|
|
11667
11856
|
}
|
|
11668
11857
|
if (flags.write) {
|
|
11669
|
-
const
|
|
11670
|
-
out(
|
|
11858
|
+
const log2 = writeWaves(ctx);
|
|
11859
|
+
out(log2.length ? log2.join("\n") : "waves already up to date");
|
|
11671
11860
|
} else {
|
|
11672
11861
|
const groups = /* @__PURE__ */ new Map();
|
|
11673
11862
|
for (const [id2, w] of waves) groups.set(w, [...groups.get(w) ?? [], id2]);
|
|
@@ -11677,8 +11866,8 @@ ${entry.source}:${entry.line}
|
|
|
11677
11866
|
}
|
|
11678
11867
|
case "board": {
|
|
11679
11868
|
const ctx = loadContext(cwd, project);
|
|
11680
|
-
const
|
|
11681
|
-
out(
|
|
11869
|
+
const log2 = writeBoard(ctx);
|
|
11870
|
+
out(log2.length ? log2.join("\n") : "board is up to date");
|
|
11682
11871
|
return 0;
|
|
11683
11872
|
}
|
|
11684
11873
|
case "start":
|
|
@@ -11722,10 +11911,10 @@ ${entry.source}:${entry.line}
|
|
|
11722
11911
|
case "enable":
|
|
11723
11912
|
case "disable": {
|
|
11724
11913
|
const root = repoRoot(cwd);
|
|
11725
|
-
|
|
11726
|
-
if (cmd === "enable")
|
|
11914
|
+
mkdirSync15(join33(root, ".lead"), { recursive: true });
|
|
11915
|
+
if (cmd === "enable") writeFileSync16(join33(root, ENABLED_PATH), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
11727
11916
|
`);
|
|
11728
|
-
else rmSync6(
|
|
11917
|
+
else rmSync6(join33(root, ENABLED_PATH), { force: true });
|
|
11729
11918
|
out(cmd === "enable" ? "lead is on for you in this repo (hooks active; stored in .lead/enabled, not in git)" : "lead is off for you in this repo: hooks are silent");
|
|
11730
11919
|
return 0;
|
|
11731
11920
|
}
|
|
@@ -11765,7 +11954,7 @@ ${entry.source}:${entry.line}
|
|
|
11765
11954
|
return 0;
|
|
11766
11955
|
}
|
|
11767
11956
|
case "session-start": {
|
|
11768
|
-
const pointer = sharedKit && scope ? [`lead: this project runs with lead, no /lead needed. Launcher: ${
|
|
11957
|
+
const pointer = sharedKit && scope ? [`lead: this project runs with lead, no /lead needed. Launcher: ${join33(repoRoot(cwd), ".lead/lead.mjs")}; kit: ${sharedKit} (start from skills/lead/SKILL.md; references are relative to the kit). When the person asks about plans, tasks, status, handoffs or the board, read that SKILL.md and follow it; do not search for the launcher or run kit-path.`] : [];
|
|
11769
11958
|
if (!isEnabled(repoRoot(cwd))) {
|
|
11770
11959
|
if (pointer.length) out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: [...pointer, `lead: this session id is ${session ?? "unknown"}; pass --session ${session ?? "<id>"} to lead.mjs commands.`].join("\n") } }));
|
|
11771
11960
|
return 0;
|
|
@@ -11823,7 +12012,7 @@ start the builder with: ${r.launch}`);
|
|
|
11823
12012
|
return 2;
|
|
11824
12013
|
}
|
|
11825
12014
|
const ctx = loadContext(cwd, project);
|
|
11826
|
-
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [
|
|
12015
|
+
const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [join33(ctx.root, ctx.project?.path ?? ".")];
|
|
11827
12016
|
const matches = similarity(resolve3(cwd, source), targets, ctx.root);
|
|
11828
12017
|
for (const m of matches.slice(0, 50)) out(`${m.file}:${m.line} ${m.kind === "block" ? "block of lines" : "long line"} also in ${m.source}:${m.sourceLine}`);
|
|
11829
12018
|
out(`${matches.length} shared fragments`);
|
|
@@ -11838,7 +12027,7 @@ start the builder with: ${r.launch}`);
|
|
|
11838
12027
|
}
|
|
11839
12028
|
const file = str2(flags.input);
|
|
11840
12029
|
if (!file) throw new Error("--input FILE must point to the read-back Markdown");
|
|
11841
|
-
const mismatches = verifyOnePager(markdown,
|
|
12030
|
+
const mismatches = verifyOnePager(markdown, readFileSync28(resolve3(cwd, file), "utf8"));
|
|
11842
12031
|
out(mismatches.length ? mismatches.join("\n") : "One Pager read-back matches the roadmap, triage, widgets and links");
|
|
11843
12032
|
return mismatches.length ? 1 : 0;
|
|
11844
12033
|
} catch (e) {
|
|
@@ -11914,8 +12103,8 @@ start the builder with: ${r.launch}`);
|
|
|
11914
12103
|
return 0;
|
|
11915
12104
|
}
|
|
11916
12105
|
const actions = syncPlan(ctx).map((a, i) => ({ id: i + 1, ...a }));
|
|
11917
|
-
|
|
11918
|
-
|
|
12106
|
+
mkdirSync15(join33(ctx.root, ".lead/logs"), { recursive: true });
|
|
12107
|
+
writeFileSync16(syncPlanPath(ctx.root, ctx.project.name), JSON.stringify({ project: ctx.project.name, actions }, null, 2));
|
|
11919
12108
|
out(JSON.stringify(actions, null, 2));
|
|
11920
12109
|
return 0;
|
|
11921
12110
|
}
|
|
@@ -11970,7 +12159,7 @@ start the builder with: ${r.launch}`);
|
|
|
11970
12159
|
const input = () => {
|
|
11971
12160
|
const file = str2(flags.input);
|
|
11972
12161
|
if (!file) throw new Error("--input FILE is required");
|
|
11973
|
-
return JSON.parse(
|
|
12162
|
+
return JSON.parse(readFileSync28(resolve3(cwd, file), "utf8"));
|
|
11974
12163
|
};
|
|
11975
12164
|
if (cmd === "qa-record") {
|
|
11976
12165
|
const task = ctx.tasks.find((t) => t.id === args[0]);
|
|
@@ -12000,8 +12189,8 @@ start the builder with: ${r.launch}`);
|
|
|
12000
12189
|
}
|
|
12001
12190
|
}
|
|
12002
12191
|
case "settings": {
|
|
12003
|
-
const
|
|
12004
|
-
out(
|
|
12192
|
+
const log2 = ensureClaudeSettings(repoRoot(cwd));
|
|
12193
|
+
out(log2.length ? log2.join("\n") : "settings already up to date");
|
|
12005
12194
|
return 0;
|
|
12006
12195
|
}
|
|
12007
12196
|
case "claim":
|
|
@@ -12039,8 +12228,8 @@ start the builder with: ${r.launch}`);
|
|
|
12039
12228
|
out(`usage: use <project>; projects: ${projects.map((p) => p.name).join(", ") || "none"}`);
|
|
12040
12229
|
return 2;
|
|
12041
12230
|
}
|
|
12042
|
-
|
|
12043
|
-
|
|
12231
|
+
mkdirSync15(join33(root, ".lead"), { recursive: true });
|
|
12232
|
+
writeFileSync16(join33(root, CURRENT_PATH), `${name}
|
|
12044
12233
|
`);
|
|
12045
12234
|
out(`current project: ${name}`);
|
|
12046
12235
|
return 0;
|
|
@@ -12052,10 +12241,10 @@ start the builder with: ${r.launch}`);
|
|
|
12052
12241
|
}
|
|
12053
12242
|
case "scaffold": {
|
|
12054
12243
|
const ctx = loadContext(cwd, project);
|
|
12055
|
-
const
|
|
12056
|
-
if (!ctx.configExists)
|
|
12057
|
-
else if (!ctx.project)
|
|
12058
|
-
out(
|
|
12244
|
+
const log2 = scaffold(ctx.root, ctx.configExists ? ctx.project : void 0);
|
|
12245
|
+
if (!ctx.configExists) log2.push("fill .lead/config.yml (checks, projects), then run scaffold again to create work/");
|
|
12246
|
+
else if (!ctx.project) log2.push("choose a project (--project NAME or `use NAME`) to create its work/");
|
|
12247
|
+
out(log2.length ? log2.join("\n") : "nothing to create");
|
|
12059
12248
|
return 0;
|
|
12060
12249
|
}
|
|
12061
12250
|
case "doctor": {
|
|
@@ -12070,8 +12259,8 @@ start the builder with: ${r.launch}`);
|
|
|
12070
12259
|
out("usage: install <repo>");
|
|
12071
12260
|
return 2;
|
|
12072
12261
|
}
|
|
12073
|
-
const
|
|
12074
|
-
out(
|
|
12262
|
+
const log2 = install(kitRoot(), realpathSync6(target), fileURLToPath(import.meta.url), { keepModified: !!flags["keep-modified"] });
|
|
12263
|
+
out(log2.join("\n"));
|
|
12075
12264
|
return 0;
|
|
12076
12265
|
}
|
|
12077
12266
|
case "update": {
|
|
@@ -12084,9 +12273,9 @@ start the builder with: ${r.launch}`);
|
|
|
12084
12273
|
const applyKit = (kit) => {
|
|
12085
12274
|
if (!isKitRoot(kit)) throw new Error(`${kit} is not a lead kit release (missing dist/lead.mjs or skills/lead)`);
|
|
12086
12275
|
const before = readLock(root)?.version ?? "none";
|
|
12087
|
-
const r =
|
|
12276
|
+
const r = spawnSync4(
|
|
12088
12277
|
process.execPath,
|
|
12089
|
-
[
|
|
12278
|
+
[join33(kit, "dist/lead.mjs"), "install", root, ...flags.force ? [] : ["--keep-modified"]],
|
|
12090
12279
|
{ cwd: root, encoding: "utf8" }
|
|
12091
12280
|
);
|
|
12092
12281
|
const output = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
|
|
@@ -12100,8 +12289,8 @@ start the builder with: ${r.launch}`);
|
|
|
12100
12289
|
try {
|
|
12101
12290
|
if (!from) return withRegistryKit(root, out, applyKit);
|
|
12102
12291
|
const path = resolve3(cwd, from);
|
|
12103
|
-
if (
|
|
12104
|
-
tmp = mkdtempSync3(
|
|
12292
|
+
if (existsSync31(path)) return applyKit(path);
|
|
12293
|
+
tmp = mkdtempSync3(join33(tmpdir3(), "lead-kit-"));
|
|
12105
12294
|
execFileSync6("git", ["clone", "-q", "--depth", "1", "--", from, tmp], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
12106
12295
|
return applyKit(tmp);
|
|
12107
12296
|
} catch (e) {
|
|
@@ -12129,7 +12318,7 @@ start the builder with: ${r.launch}`);
|
|
|
12129
12318
|
}
|
|
12130
12319
|
let raw;
|
|
12131
12320
|
try {
|
|
12132
|
-
raw = JSON.parse(
|
|
12321
|
+
raw = JSON.parse(readFileSync28(resolve3(cwd, input), "utf8"));
|
|
12133
12322
|
} catch (error) {
|
|
12134
12323
|
out(`cannot read ${input}: ${error.message}`);
|
|
12135
12324
|
return 2;
|
|
@@ -12139,10 +12328,10 @@ start the builder with: ${r.launch}`);
|
|
|
12139
12328
|
for (const e of errors) out(`error ${e}`);
|
|
12140
12329
|
return 2;
|
|
12141
12330
|
}
|
|
12142
|
-
const syncFile =
|
|
12331
|
+
const syncFile = join33(root, "work/initiatives", id2, "sync.json");
|
|
12143
12332
|
let previous;
|
|
12144
12333
|
try {
|
|
12145
|
-
previous = JSON.parse(
|
|
12334
|
+
previous = JSON.parse(readFileSync28(syncFile, "utf8"));
|
|
12146
12335
|
} catch {
|
|
12147
12336
|
previous = void 0;
|
|
12148
12337
|
}
|
|
@@ -12233,7 +12422,7 @@ start the builder with: ${r.launch}`);
|
|
|
12233
12422
|
out(`no adapter "${name}". Known: ${adapters.map((a) => a.id).join(", ") || "none"}`);
|
|
12234
12423
|
return 1;
|
|
12235
12424
|
}
|
|
12236
|
-
out(flags.json ? JSON.stringify({ ...found, text:
|
|
12425
|
+
out(flags.json ? JSON.stringify({ ...found, text: readFileSync28(join33(root, found.file), "utf8") }, null, 2) : readFileSync28(join33(root, found.file), "utf8").trimEnd());
|
|
12237
12426
|
return 0;
|
|
12238
12427
|
}
|
|
12239
12428
|
if (flags.json) out(JSON.stringify({ adapters, issues }, null, 2));
|
|
@@ -12275,9 +12464,33 @@ start the builder with: ${r.launch}`);
|
|
|
12275
12464
|
}
|
|
12276
12465
|
if (args[0] === "ack") {
|
|
12277
12466
|
clearDue(root);
|
|
12467
|
+
recordAck(root, flags.acted === true ? true : flags.idle === true ? false : null);
|
|
12278
12468
|
out("watch check acknowledged");
|
|
12279
12469
|
return 0;
|
|
12280
12470
|
}
|
|
12471
|
+
if (args[0] === "probe") {
|
|
12472
|
+
const sub = args[1];
|
|
12473
|
+
if (sub === "shadow" || sub === "off") {
|
|
12474
|
+
const st = readWatch(root);
|
|
12475
|
+
if (sub === "shadow") st.probe = "shadow";
|
|
12476
|
+
else delete st.probe;
|
|
12477
|
+
writeWatch(root, st);
|
|
12478
|
+
out(`probe ${sub === "shadow" ? "shadow: each tick also records what the token-free probe would decide; checks are not skipped" : "off"}`);
|
|
12479
|
+
return 0;
|
|
12480
|
+
}
|
|
12481
|
+
if (sub === "report") {
|
|
12482
|
+
const r2 = report(root);
|
|
12483
|
+
for (const line of flags.json ? [JSON.stringify(r2, null, 2)] : renderReport(r2)) out(line);
|
|
12484
|
+
return 0;
|
|
12485
|
+
}
|
|
12486
|
+
if (sub !== void 0) {
|
|
12487
|
+
out("usage: watch probe [report|shadow|off] [--dry] [--json]");
|
|
12488
|
+
return 2;
|
|
12489
|
+
}
|
|
12490
|
+
const res = runProbe(root, { record: flags.dry !== true });
|
|
12491
|
+
for (const line of flags.json ? [JSON.stringify(res, null, 2)] : renderVerdicts(res)) out(line);
|
|
12492
|
+
return 0;
|
|
12493
|
+
}
|
|
12281
12494
|
const r = watchCommand(root, args, {
|
|
12282
12495
|
close: flags.close === true,
|
|
12283
12496
|
spawnLoop: () => {
|
|
@@ -12311,8 +12524,8 @@ start the builder with: ${r.launch}`);
|
|
|
12311
12524
|
const root = repoRoot(cwd);
|
|
12312
12525
|
if (args[0] === "analyze") {
|
|
12313
12526
|
const rows = loadActivity(root, { day: str2(flags.day), since: str2(flags.since) });
|
|
12314
|
-
const
|
|
12315
|
-
out(flags.json ? JSON.stringify(
|
|
12527
|
+
const report2 = analyzeActivity(rows);
|
|
12528
|
+
out(flags.json ? JSON.stringify(report2, null, 2) : formatActivityReport(report2));
|
|
12316
12529
|
return 0;
|
|
12317
12530
|
}
|
|
12318
12531
|
const event = str2(flags.event);
|
|
@@ -12374,10 +12587,10 @@ ${HELP}`);
|
|
|
12374
12587
|
}
|
|
12375
12588
|
}
|
|
12376
12589
|
function syncPlanPath(root, project) {
|
|
12377
|
-
return
|
|
12590
|
+
return join33(root, ".lead/logs", `sync-plan-${project === "." ? "root" : project.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
|
|
12378
12591
|
}
|
|
12379
12592
|
function savedSyncAction(root, project, id2) {
|
|
12380
|
-
const saved = JSON.parse(
|
|
12593
|
+
const saved = JSON.parse(readFileSync28(syncPlanPath(root, project), "utf8"));
|
|
12381
12594
|
if (saved.project !== project) throw new Error(`the saved plan is for ${saved.project}, not ${project}`);
|
|
12382
12595
|
return saved.actions.find((action) => action.id === id2);
|
|
12383
12596
|
}
|
|
@@ -12391,20 +12604,20 @@ function syncLabel(action) {
|
|
|
12391
12604
|
return `${action.kind}${target ? ` \xB7 ${target}` : ""}${transition}`;
|
|
12392
12605
|
}
|
|
12393
12606
|
function syncJournalPath(root, project) {
|
|
12394
|
-
return
|
|
12607
|
+
return join33(root, ".lead/logs", `sync-journal-${digest(project)}.json`);
|
|
12395
12608
|
}
|
|
12396
12609
|
function readSyncJournal(root, project) {
|
|
12397
12610
|
const file = syncJournalPath(root, project);
|
|
12398
|
-
return
|
|
12611
|
+
return existsSync31(file) ? JSON.parse(readFileSync28(file, "utf8")) : {};
|
|
12399
12612
|
}
|
|
12400
12613
|
function writeSyncJournal(root, project, journal) {
|
|
12401
12614
|
const file = syncJournalPath(root, project);
|
|
12402
|
-
|
|
12403
|
-
|
|
12615
|
+
mkdirSync15(dirname6(file), { recursive: true });
|
|
12616
|
+
writeFileSync16(file, JSON.stringify(journal, null, 2));
|
|
12404
12617
|
}
|
|
12405
12618
|
function readStdinJson() {
|
|
12406
12619
|
try {
|
|
12407
|
-
const text =
|
|
12620
|
+
const text = readFileSync28(0, "utf8");
|
|
12408
12621
|
return text.trim() ? JSON.parse(text) : {};
|
|
12409
12622
|
} catch {
|
|
12410
12623
|
return {};
|
package/package.json
CHANGED
|
@@ -68,6 +68,7 @@ On an auto watch tick, perform the following after the Check, in the same turn w
|
|
|
68
68
|
- **`[AI] Ready for Human Review`.** Move a passing issue to Ready for QA on Develop after reviewing the diff and seeing green required checks for the current revision. A parent Story can pass after its required children pass. For shared MRs, record the verdict against each issue's own criteria. Return only the child whose own acceptance fails to `[AI] Ready for development`, with the unmet criterion and evidence. A running pipeline or inconclusive evidence is a named blocker. Leave the merge to the separate merge workflow.
|
|
69
69
|
- **Story in human review with a required child back in development.** Check the current statuses of the Story and its required children, including after any child transition on this tick. If a required child is in `[AI] Ready for development` or `[AI] In Progress` while the parent remains in human review, Codee may wait on the parent. Report the child's summary and request any required approval to transition the parent to `[AI] Ready for development`. Recheck both statuses before applying the approved transition. Leave passing siblings and any blocked QA subtask in their current states. If a child is only blocked or its evidence is inconclusive, report the blocker and keep the Story in review.
|
|
70
70
|
- **QA subtask blocked on named dev merges.** Read the blocker and the current state of every dependency it names. For each required merge, verify that the merged commit is reachable from the repository's actual dev deployment branch and that a successful pipeline on that branch includes that commit. If deployment is a separate step, verify the dev deployment also includes it. If a named dependency is back in development, a merge or pipeline is missing, or another blocker remains, leave QA blocked and report the specific dependency and evidence.
|
|
71
|
+
- **Review-ready dependency or QA ticket.** On every check, process each implementation or QA-dependency ticket that is ready for review, including a merge request in another repository that a QA subtask names. Review the current diff, the pipeline, and the deployed evidence where it applies; reproduce the relevant check independently and separate code checks from a live rollout. With no finding or open risk, record the verdict and move the ticket to its next status, including Done for a verified merged dependency. With a concern, tag the responsible person in Jira with the finding, the evidence and the decision needed. Do not leave a ticket in review because a monitor only listed it.
|
|
71
72
|
- **QA subtask blocked on a dependency that is still open.** Trace each prerequisite to the failing job, deployment, or Jira issue and verify the cause before waiting. If the dependency is an existing To Do issue that suits Codee and the handoff is authorized, assign it to Codee and move it to `[AI] Ready for development` with the evidence and a concrete verification check. After the fix lands, verify the expected build on the required environment, then move only the eligible QA subtasks to Ready for QA. Escalate only an unresolved decision or missing access.
|
|
72
73
|
- Once all of that QA subtask's prerequisites are satisfied, prepare a Jira comment with the verified branch, commit and pipeline links for each dependency. Request any required approval for the comment and the exact `[AI] Ready for QA` transition. When authorized, post the evidence and transition only that still-blocked QA subtask in the same turn. Recheck its current status before writing. If the comment already exists after a partial attempt, reuse it and request approval for the remaining write as required.
|
|
73
74
|
|
|
@@ -29,3 +29,5 @@ Use when `.lead/config.yml` has `qa` (`run`, `url`, `ready`) and the change touc
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Required checks must all pass for the checked code before `finish` can hand off the task. After code changes, repeat the affected QA and record the full result for the new code.
|
|
32
|
+
|
|
33
|
+
Run the QA yourself. Do not report QA as "ready" or as the person's next step while checks the agent can run are still unrun. Use the real app and a browser with the test identities the person or `.lead/local.md` approved. Before a deployment, run the relevant local or stage checks and record which scenarios need a deployed build. After verifying the deployed revision, run the rest and attach the evidence. Stop only on a specific access blocker, and name it.
|
|
@@ -19,7 +19,7 @@ Run `node .lead/lead.mjs watch ...` for the same words. State is `.lead/watch.js
|
|
|
19
19
|
2. For each task that is not `done`, follow the Check section of its service skill. A due watch in auto mode can also perform documented follow-up when the decision is already made and the required authorization is in place. If approval is required, report the exact proposed changes and wait. Explicit status and delegate checks are read-only.
|
|
20
20
|
3. Record the service status, ref, date, and any action taken or required under `## Notes` in the task file. Then run `board`.
|
|
21
21
|
4. Do not merge on a watch tick or mark a task done from the service status. `finish --merged` only when the branch is already merged, the same rule as any other task.
|
|
22
|
-
5. After assessing the actionable items, run `node .lead/lead.mjs watch ack` so the same tick is not done twice.
|
|
22
|
+
5. After assessing the actionable items, run `node .lead/lead.mjs watch ack --acted` when you took or required any action, or `node .lead/lead.mjs watch ack --idle` when there was nothing to do, so the same tick is not done twice. The flag feeds the probe comparison below; state it honestly.
|
|
23
23
|
6. Report changes and actionable waits even when the status stayed the same. Name the open question, failed check, or approval needed and who can resolve it. Do not post to a messenger.
|
|
24
24
|
|
|
25
25
|
## Closing a milestone
|
|
@@ -31,3 +31,14 @@ With `--close`, when every task of the current milestone is `done`, say that it
|
|
|
31
31
|
## A check while nobody has a session open
|
|
32
32
|
|
|
33
33
|
The clock only marks the check due. To run it with no chat open, set `LEAD_WATCH_COMMAND` in the environment of the process that starts the watch to a headless agent command whose prompt is: read `references/watch.md` and run the due check in this repo. The kit does not pick that command.
|
|
34
|
+
|
|
35
|
+
## Probe (shadow)
|
|
36
|
+
|
|
37
|
+
`node .lead/lead.mjs watch probe` is a pass over the delegated tasks that spends no model tokens. It reads cheap facts, fingerprints them and says whether an agent would have anything to do:
|
|
38
|
+
|
|
39
|
+
- Merge requests: every merge request address found in the task file, through `glab api` (state, head commit, pipeline, conflicts, open discussions).
|
|
40
|
+
- Tracker: a command the person provides in `LEAD_WATCH_JIRA_COMMAND`. It is called with an issue key and prints `{"status": "...", "updated": "...", "comments": 3}`. The kit holds no tracker credentials; without the command the tracker source is unreadable and every tick wakes an agent.
|
|
41
|
+
|
|
42
|
+
Verdicts: `quiet` (nothing changed since the last acknowledged check), `new`, `forced` (no acknowledged check for 24 hours), `unknown` (a source could not be read, never treated as quiet), and for a change `conflict`, `ci_failed`, `review`, `blocked`, `dev_check`, `clarification`, `qa`, `done`, `changed`. Any change in the facts, including a new commit or comment, wakes an agent.
|
|
43
|
+
|
|
44
|
+
`watch probe shadow` makes each clock tick also record what the probe would have decided (`.lead/logs/watch-probe.jsonl`, not in git). **Shadow never skips a check**: the agent still runs it as above. `watch probe report` compares the two: a tick the probe called quiet but an agent acted on is a probe bug. The report says "ready" only after 7 days, 200 ticks, no such miss, and few unreadable sources or unannotated acknowledgements. Nothing switches checks off yet; `watch probe off` stops recording. `watch probe --dry` runs one pass without recording.
|