@fusebase/harness-lead 0.3.2 → 0.3.4

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 — 2026-12-04
4
+
5
+ - `lead mode readonly`: lead reads and reports and changes nothing in the project. The CLI refuses every command that writes (exit 3, an allow-list, so a new command is refused until listed): task and board changes, `scaffold`, `spec`, `install`/`update`, `adopt --write`, `waves --write`, `sync-plan` without `--preview`, `watch` start/stop/ack/probe shadow. Reads, previews, `watch probe report|--dry`, the switches (`enable`, `mode`, `use`) and the local notes (`improve`, `activity`) still work. The session-start hook and the skill tell the agent to stay read-only. Editing files by the agent's own tools is held by those instructions, not by the CLI.
6
+
7
+ ## 0.3.3 — 2026-12-04
8
+
9
+ - `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.
10
+
11
+ - 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.
12
+ - 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.
13
+
3
14
  ## 0.3.2 — 2026-12-03
4
15
 
5
16
  - `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 log = require_log();
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
- log.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.`);
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 log = require_log();
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) => log.warn(doc.options.logLevel, 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 mkdirSync14, realpathSync as realpathSync6, writeFileSync as writeFileSync15 } from "node:fs";
7310
- import { dirname as dirname6, join as join32, resolve as resolve3 } from "node:path";
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.2'], 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",
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.4'], 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 log = [];
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
- log.push(`${CLAUDE_SETTINGS}: added ${event} hook`);
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) log.push(`${CLAUDE_SETTINGS}: removed lead's shared allow rules`);
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 (log.length) {
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 log;
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 log = [];
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
- log.push(`${CODEX_HOOKS}: added ${event} hook`);
8288
+ log2.push(`${CODEX_HOOKS}: added ${event} hook`);
8289
8289
  }
8290
8290
  }
8291
- if (log.length) {
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 log;
8296
+ return log2;
8297
8297
  }
8298
8298
 
8299
8299
  // src/install.ts
8300
- var VERSION = true ? "0.3.2" : "dev";
8300
+ var VERSION = true ? "0.3.4" : "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 log = [];
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
- log.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`);
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) log.push(`overwrote ${rel}: it was changed by hand`);
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
- log.push(`AGENTS.md: ${upsertBlock(join11(target, "AGENTS.md"), block, "# Agent instructions\n\n")} lead block`);
8373
- log.push(...ensureGitIgnore(target));
8374
- log.push(...ensureClaudeSettings(target));
8375
- log.push(...ensureCodexHooks(target));
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
- log.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 log;
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 log = [];
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
- log.push(`created ${rel}`);
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
- log.push(`created ${join11(work, d)}/`);
8409
+ log2.push(`created ${join11(work, d)}/`);
8410
8410
  }
8411
8411
  }
8412
8412
  }
8413
- return log;
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 log = [];
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
- log.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
8774
+ log2.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
8775
8775
  }
8776
- return log.length ? log : ["waves are up to date"];
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,15 +9267,15 @@ function writeEntrypoints(root) {
9267
9267
  }
9268
9268
 
9269
9269
  // src/cli.ts
9270
- import { execFileSync as execFileSync6, spawnSync as spawnSync3 } from "node:child_process";
9271
- import { existsSync as existsSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync6 } from "node:fs";
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
9275
9275
  import { existsSync as existsSync17, mkdirSync as mkdirSync6, readFileSync as readFileSync15, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "node:fs";
9276
9276
  import { join as join18 } from "node:path";
9277
9277
  var MODE_PATH = ".lead/mode";
9278
- var MODES = ["auto", "approve"];
9278
+ var MODES = ["auto", "approve", "readonly"];
9279
9279
  function isMode(v) {
9280
9280
  return MODES.includes(v);
9281
9281
  }
@@ -9294,6 +9294,51 @@ function clearMode(root) {
9294
9294
  rmSync3(join18(root, MODE_PATH), { force: true });
9295
9295
  }
9296
9296
 
9297
+ // src/readonly.ts
9298
+ var READS = /* @__PURE__ */ new Set([
9299
+ "help",
9300
+ "--help",
9301
+ "version",
9302
+ "how",
9303
+ "status",
9304
+ "check",
9305
+ "projects",
9306
+ "doctor",
9307
+ "inbox",
9308
+ "docs",
9309
+ "similarity",
9310
+ "sync-one-pager",
9311
+ "delegate",
9312
+ "adapters",
9313
+ "session-start",
9314
+ "stop-check",
9315
+ "enabled",
9316
+ "enable",
9317
+ "disable",
9318
+ "mode",
9319
+ "use",
9320
+ "improve",
9321
+ "activity"
9322
+ ]);
9323
+ function writeReason(cmd, args, flags) {
9324
+ if (cmd === void 0 || READS.has(cmd)) return void 0;
9325
+ if (cmd === "waves") return flags.write ? "waves --write rewrites task files" : void 0;
9326
+ if (cmd === "adopt") return flags.write ? "adopt --write creates the initiative files" : void 0;
9327
+ if (cmd === "initiative") return args[0] === "waves" && flags.write ? "initiative waves --write rewrites task files" : void 0;
9328
+ if (cmd === "sync-plan") return flags.preview ? void 0 : "sync-plan saves the plan; use --preview to read it";
9329
+ if (cmd === "score") return args[0] === "record" ? "score record stores a result" : void 0;
9330
+ if (cmd === "watch") {
9331
+ const [sub, next] = args;
9332
+ if (sub === void 0 || sub === "status") return void 0;
9333
+ if (sub === "probe" && (next === "report" || next === void 0 && flags.dry === true)) return void 0;
9334
+ return `watch ${[sub, next].filter((x) => x && !x.startsWith("-")).join(" ")} changes the clock state; read with watch status, watch probe --dry or watch probe report`;
9335
+ }
9336
+ return `${cmd} changes the project`;
9337
+ }
9338
+ function readonlyRefusal(reason) {
9339
+ return `lead is read-only here: ${reason}. Nothing was changed. Only the person leaves this mode: node .lead/lead.mjs mode clear (or mode auto|approve).`;
9340
+ }
9341
+
9297
9342
  // src/status.ts
9298
9343
  import { existsSync as existsSync19 } from "node:fs";
9299
9344
  import { join as join21 } from "node:path";
@@ -9425,7 +9470,7 @@ function recordChecks(ctx, t, opts) {
9425
9470
  const stamp = now.toISOString().replace(/[:.]/g, "-");
9426
9471
  const logRel = `.lead/logs/${t.id}-${stamp}.log`;
9427
9472
  mkdirSync7(join20(ctx.root, ".lead/logs"), { recursive: true });
9428
- let log = "";
9473
+ let log2 = "";
9429
9474
  const commands = [];
9430
9475
  const failures = [];
9431
9476
  for (const [name, template] of checks) {
@@ -9433,14 +9478,14 @@ function recordChecks(ctx, t, opts) {
9433
9478
  const r = spawnSync2("sh", ["-c", cmd], { cwd: dir, encoding: "utf8", timeout: 15 * 60 * 1e3, maxBuffer: 64 * 1024 * 1024 });
9434
9479
  const code = r.status ?? 1;
9435
9480
  const output = `${r.stdout ?? ""}${r.stderr ?? ""}`;
9436
- log += `$ ${cmd} (${name}, exit ${code})
9481
+ log2 += `$ ${cmd} (${name}, exit ${code})
9437
9482
  ${output}
9438
9483
  `;
9439
9484
  commands.push({ cmd, exit_code: code });
9440
9485
  if (code !== 0) failures.push(`${name} (exit ${code}):
9441
9486
  ${tail(output, 40)}`);
9442
9487
  }
9443
- writeFileSync8(join20(ctx.root, logRel), log);
9488
+ writeFileSync8(join20(ctx.root, logRel), log2);
9444
9489
  const commit = treeId(dir);
9445
9490
  const round = t.rounds + 1;
9446
9491
  const summary = commands.map((c) => `\`${c.cmd}\` \u2192 ${c.exit_code}`).join(", ");
@@ -10465,7 +10510,7 @@ function syncRecord(ctx, action, result) {
10465
10510
  function writeWaves(ctx) {
10466
10511
  const waves = computeWaves(ctx.tasks, ctx.config.shared_paths);
10467
10512
  if (!waves) throw new Error("dependency cycle: fix blocked_by first (run `lead check`)");
10468
- const log = [];
10513
+ const log2 = [];
10469
10514
  for (const t of ctx.tasks) {
10470
10515
  const w = waves.get(t.id);
10471
10516
  if (w === void 0 || w === t.wave || t.status === "done") continue;
@@ -10475,13 +10520,13 @@ function writeWaves(ctx) {
10475
10520
  if (!parsed) continue;
10476
10521
  parsed.data.wave = w;
10477
10522
  writeFileSync10(abs, renderFrontmatter(parsed.data, parsed.body));
10478
- log.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
10523
+ log2.push(`${t.id}: wave ${t.wave ?? "-"} \u2192 ${w}`);
10479
10524
  }
10480
- return log;
10525
+ return log2;
10481
10526
  }
10482
10527
  function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
10483
10528
  if (!ctx.project) throw new Error("no project selected");
10484
- const log = [];
10529
+ const log2 = [];
10485
10530
  const board = renderBoard({ projectName: ctx.project.name, tasks: ctx.tasks, onePager: ctx.onePager, config: ctx.config });
10486
10531
  const boardPath = join23(ctx.project.workDir, "board.md");
10487
10532
  let old = "";
@@ -10491,14 +10536,14 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
10491
10536
  }
10492
10537
  if (old !== board) {
10493
10538
  writeFileSync10(boardPath, board);
10494
- log.push("board.md updated");
10539
+ log2.push("board.md updated");
10495
10540
  }
10496
10541
  if (ctx.onePager) {
10497
10542
  const blocks = renderOnePagerBlocks(ctx.tasks, ctx.onePager.milestones, isMerged, ctx.config.can_show);
10498
10543
  const next = replaceBlocks(ctx.onePager.text, (k) => blocks[k]);
10499
10544
  if (next !== ctx.onePager.text) {
10500
10545
  writeFileSync10(join23(ctx.root, ctx.onePager.file), next);
10501
- log.push(`one-pager.md blocks updated: ${blockKinds(next).join(", ")}`);
10546
+ log2.push(`one-pager.md blocks updated: ${blockKinds(next).join(", ")}`);
10502
10547
  }
10503
10548
  }
10504
10549
  const backlog = join23(ctx.project.workDir, "backlog.md");
@@ -10507,14 +10552,14 @@ function writeBoard(ctx, isMerged = gitMergedChecker(ctx.root)) {
10507
10552
  const next = replaceBlocks(current, (kind) => ["tasks", "proposals"].includes(kind) ? renderBacklogItems(ctx.project.workDir) : void 0);
10508
10553
  if (next !== current) {
10509
10554
  writeFileSync10(backlog, next);
10510
- log.push("backlog.md tasks updated");
10555
+ log2.push("backlog.md tasks updated");
10511
10556
  }
10512
10557
  }
10513
- return log;
10558
+ return log2;
10514
10559
  }
10515
10560
 
10516
10561
  // src/cli.ts
10517
- import { readFileSync as readFileSync27 } from "node:fs";
10562
+ import { readFileSync as readFileSync28 } from "node:fs";
10518
10563
 
10519
10564
  // src/inbox.ts
10520
10565
  import { createHash as createHash6 } from "node:crypto";
@@ -10739,8 +10784,188 @@ function delegatedTasks(tasks, id2) {
10739
10784
 
10740
10785
  // src/watch.ts
10741
10786
  import { spawn } from "node:child_process";
10742
- import { existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "node:fs";
10787
+ import { existsSync as existsSync26, mkdirSync as mkdirSync11, readFileSync as readFileSync23, writeFileSync as writeFileSync13 } from "node:fs";
10788
+ import { join as join28 } from "node:path";
10789
+
10790
+ // src/probe.ts
10791
+ import { spawnSync as spawnSync3 } from "node:child_process";
10792
+ import { createHash as createHash8 } from "node:crypto";
10793
+ import { appendFileSync as appendFileSync2, existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "node:fs";
10743
10794
  import { join as join27 } from "node:path";
10795
+ var PROBE_LOG = ".lead/logs/watch-probe.jsonl";
10796
+ var PROBE_STATE = ".lead/logs/watch-probe-state.json";
10797
+ var FORCED_AFTER_MS = 24 * 60 * 60 * 1e3;
10798
+ var GATE = { days: 7, ticks: 200, maxUnknownRatio: 0.05 };
10799
+ var shell = (cmd, args) => {
10800
+ const r = spawnSync3(cmd, args, { encoding: "utf8", timeout: 6e4, maxBuffer: 16 * 1024 * 1024 });
10801
+ 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]) };
10802
+ };
10803
+ var MR_URL = /https?:\/\/([^\s/)>\]]+)\/([^\s)>\]]+?)\/-\/merge_requests\/(\d+)/g;
10804
+ function mrUrls(text) {
10805
+ return [...new Set([...text.matchAll(MR_URL)].map((m) => m[0]))].sort();
10806
+ }
10807
+ function fetchMr(url, run2) {
10808
+ const m = new RegExp(MR_URL.source).exec(url);
10809
+ if (!m) return { url, unavailable: "not a merge request address" };
10810
+ const r = run2("glab", ["api", "--hostname", m[1], `projects/${encodeURIComponent(m[2])}/merge_requests/${m[3]}`]);
10811
+ if (!r.ok) return { url, unavailable: `glab: ${r.error ?? "failed"}` };
10812
+ try {
10813
+ const d = JSON.parse(r.stdout);
10814
+ const pipe = d.head_pipeline ?? d.pipeline;
10815
+ return {
10816
+ url,
10817
+ state: String(d.state ?? ""),
10818
+ sha: String(d.sha ?? ""),
10819
+ pipeline: String(pipe?.status ?? "none"),
10820
+ mergeStatus: String(d.detailed_merge_status ?? d.merge_status ?? ""),
10821
+ conflicts: d.has_conflicts === true,
10822
+ discussionsResolved: d.blocking_discussions_resolved !== false,
10823
+ notes: Number(d.user_notes_count ?? 0)
10824
+ };
10825
+ } catch {
10826
+ return { url, unavailable: "glab: unreadable answer" };
10827
+ }
10828
+ }
10829
+ function fetchJira(key, run2, command = process.env.LEAD_WATCH_JIRA_COMMAND) {
10830
+ if (!command) return { unavailable: "LEAD_WATCH_JIRA_COMMAND is not set" };
10831
+ if (!/^[A-Z][A-Z0-9]*-\d+$/.test(key)) return { unavailable: `"${key}" is not an issue key` };
10832
+ const r = run2("sh", ["-c", `${command} "$1"`, "sh", key]);
10833
+ if (!r.ok) return { unavailable: `tracker command: ${r.error ?? "failed"}` };
10834
+ try {
10835
+ const d = JSON.parse(r.stdout);
10836
+ if (typeof d.status !== "string" || !d.status) return { unavailable: "tracker command: no status in the answer" };
10837
+ return { status: d.status, ...typeof d.updated === "string" ? { updated: d.updated } : {}, ...typeof d.comments === "number" ? { comments: d.comments } : {} };
10838
+ } catch {
10839
+ return { unavailable: "tracker command: unreadable answer" };
10840
+ }
10841
+ }
10842
+ function collectFacts(root, run2 = shell, jiraCommand) {
10843
+ const ctx = loadContext(root);
10844
+ return delegatedTasks(ctx.tasks).filter((t) => t.status !== "done").map((t) => {
10845
+ const text = existsSync25(join27(root, t.file)) ? readFileSync22(join27(root, t.file), "utf8") : "";
10846
+ return {
10847
+ task: t.id,
10848
+ ...t.delegate_ref ? { ref: t.delegate_ref } : {},
10849
+ ...t.delegate_ref ? { jira: fetchJira(t.delegate_ref, run2, jiraCommand ?? process.env.LEAD_WATCH_JIRA_COMMAND) } : {},
10850
+ mrs: mrUrls(text).map((u) => fetchMr(u, run2))
10851
+ };
10852
+ });
10853
+ }
10854
+ 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;
10855
+ var fingerprint = (f) => createHash8("sha256").update(JSON.stringify(canon(f))).digest("hex").slice(0, 16);
10856
+ var unavailable = (x) => !!x && typeof x === "object" && "unavailable" in x;
10857
+ function classify(f, st, state, now) {
10858
+ const fp = fingerprint(f);
10859
+ const reasons = [];
10860
+ const bad = [f.jira, ...f.mrs].filter(unavailable);
10861
+ const base = { task: f.task, fingerprint: fp };
10862
+ if (bad.length) return { ...base, class: "unknown", needsAi: true, reasons: bad.map((b) => b.unavailable) };
10863
+ if (!st?.handled) return { ...base, class: "new", needsAi: true, reasons: ["no acknowledged check yet"] };
10864
+ const stale = !state.lastAck || now.getTime() - new Date(state.lastAck).getTime() > FORCED_AFTER_MS;
10865
+ 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: [] };
10866
+ const mrs = f.mrs.filter((m) => !unavailable(m));
10867
+ const status2 = unavailable(f.jira) ? "" : f.jira?.status ?? "";
10868
+ let cls = "changed";
10869
+ if (mrs.some((m) => m.conflicts)) cls = "conflict", reasons.push("a merge request has conflicts");
10870
+ else if (mrs.some((m) => m.pipeline === "failed")) cls = "ci_failed", reasons.push("a pipeline failed");
10871
+ else if (/human review/i.test(status2)) cls = "review", reasons.push(`status ${status2}`);
10872
+ else if (/blocked/i.test(status2)) cls = "blocked", reasons.push(`status ${status2}`);
10873
+ else if (/dev check/i.test(status2)) cls = "dev_check", reasons.push(`status ${status2}`);
10874
+ else if (/clarification/i.test(status2)) cls = "clarification", reasons.push(`status ${status2}`);
10875
+ else if (/ready for qa/i.test(status2)) cls = "qa", reasons.push(`status ${status2}`);
10876
+ else if (/^done$/i.test(status2)) cls = "done", reasons.push(`status ${status2}`);
10877
+ else reasons.push("facts changed since the last acknowledged check");
10878
+ return { ...base, class: cls, needsAi: true, reasons };
10879
+ }
10880
+ function readState(root) {
10881
+ try {
10882
+ const d = JSON.parse(readFileSync22(join27(root, PROBE_STATE), "utf8"));
10883
+ return { tasks: d.tasks ?? {}, ...d.lastAck ? { lastAck: d.lastAck } : {} };
10884
+ } catch {
10885
+ return { tasks: {} };
10886
+ }
10887
+ }
10888
+ var writeState = (root, s) => {
10889
+ mkdirSync10(join27(root, ".lead/logs"), { recursive: true });
10890
+ writeFileSync12(join27(root, PROBE_STATE), `${JSON.stringify(s, null, 2)}
10891
+ `);
10892
+ };
10893
+ var log = (root, record) => {
10894
+ mkdirSync10(join27(root, ".lead/logs"), { recursive: true });
10895
+ appendFileSync2(join27(root, PROBE_LOG), `${JSON.stringify(record)}
10896
+ `);
10897
+ };
10898
+ function runProbe(root, opts = {}) {
10899
+ const now = opts.now ?? /* @__PURE__ */ new Date();
10900
+ const state = readState(root);
10901
+ const facts = collectFacts(root, opts.run ?? shell, opts.jiraCommand);
10902
+ const verdicts = facts.map((f) => classify(f, state.tasks[f.task], state, now));
10903
+ const result = { at: now.toISOString(), verdicts, wouldWake: verdicts.some((v) => v.needsAi) };
10904
+ if (opts.record !== false) {
10905
+ for (const v of verdicts) state.tasks[v.task] = { ...state.tasks[v.task], seen: v.fingerprint };
10906
+ writeState(root, state);
10907
+ log(root, { event: "probe", at: result.at, wouldWake: result.wouldWake, tasks: verdicts.map((v) => ({ task: v.task, class: v.class, fp: v.fingerprint })) });
10908
+ }
10909
+ return result;
10910
+ }
10911
+ function recordAck(root, acted, now = /* @__PURE__ */ new Date()) {
10912
+ const state = readState(root);
10913
+ for (const t of Object.values(state.tasks)) if (t.seen) t.handled = t.seen;
10914
+ state.lastAck = now.toISOString();
10915
+ writeState(root, state);
10916
+ log(root, { event: "ack", at: now.toISOString(), acted });
10917
+ }
10918
+ function report(root) {
10919
+ const lines = existsSync25(join27(root, PROBE_LOG)) ? readFileSync22(join27(root, PROBE_LOG), "utf8").split("\n").filter(Boolean) : [];
10920
+ const events = lines.flatMap((l) => {
10921
+ try {
10922
+ return [JSON.parse(l)];
10923
+ } catch {
10924
+ return [];
10925
+ }
10926
+ });
10927
+ const r = { ticks: 0, acked: 0, quiet: 0, wake: 0, unknown: 0, unreported: 0, misses: 0, falseWakes: 0, spanDays: 0, ready: false, blockers: [] };
10928
+ let last;
10929
+ for (const e of events) {
10930
+ if (e.event === "probe") {
10931
+ r.ticks++;
10932
+ r.firstAt ??= e.at;
10933
+ r.lastAt = e.at;
10934
+ if (e.wouldWake) r.wake++;
10935
+ else r.quiet++;
10936
+ if (e.tasks?.some((t) => t.class === "unknown")) r.unknown++;
10937
+ last = e;
10938
+ } else if (e.event === "ack" && last) {
10939
+ r.acked++;
10940
+ if (e.acted === null || e.acted === void 0) r.unreported++;
10941
+ if (!last.wouldWake && e.acted === true) r.misses++;
10942
+ if (last.wouldWake && e.acted === false) r.falseWakes++;
10943
+ last = void 0;
10944
+ }
10945
+ }
10946
+ r.spanDays = r.firstAt && r.lastAt ? (new Date(r.lastAt).getTime() - new Date(r.firstAt).getTime()) / 864e5 : 0;
10947
+ if (r.spanDays < GATE.days) r.blockers.push(`shadow run is ${r.spanDays.toFixed(1)} days, needs ${GATE.days}`);
10948
+ if (r.ticks < GATE.ticks) r.blockers.push(`${r.ticks} ticks, needs ${GATE.ticks}`);
10949
+ if (r.misses > 0) r.blockers.push(`${r.misses} tick(s) the probe called quiet but an agent acted on`);
10950
+ 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)`);
10951
+ 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}%)`);
10952
+ r.ready = r.blockers.length === 0;
10953
+ return r;
10954
+ }
10955
+ function renderVerdicts(r) {
10956
+ if (!r.verdicts.length) return ["no delegated tasks to probe"];
10957
+ 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("; ")}` : ""}`)];
10958
+ }
10959
+ function renderReport(r) {
10960
+ return [
10961
+ `ticks ${r.ticks} (acknowledged ${r.acked}, without a note ${r.unreported}): quiet ${r.quiet}, would wake ${r.wake}, unreadable source ${r.unknown}`,
10962
+ `misses ${r.misses} (probe quiet, agent acted), unnecessary wakes ${r.falseWakes}`,
10963
+ `span ${r.spanDays.toFixed(1)} days${r.firstAt ? ` (${r.firstAt} \u2026 ${r.lastAt})` : ""}`,
10964
+ r.ready ? "ready: the probe agreed with every acknowledged check" : `not ready: ${r.blockers.join("; ")}`
10965
+ ];
10966
+ }
10967
+
10968
+ // src/watch.ts
10744
10969
  var WATCH_PATH = ".lead/watch.json";
10745
10970
  var MIN_INTERVAL_MS = 5 * 60 * 1e3;
10746
10971
  var DEFAULT_INTERVAL = "15m";
@@ -10753,18 +10978,18 @@ function parseInterval(text) {
10753
10978
  return ms;
10754
10979
  }
10755
10980
  function readWatch(root) {
10756
- const p = join27(root, WATCH_PATH);
10757
- if (!existsSync25(p)) return { interval: DEFAULT_INTERVAL, close: false };
10981
+ const p = join28(root, WATCH_PATH);
10982
+ if (!existsSync26(p)) return { interval: DEFAULT_INTERVAL, close: false };
10758
10983
  try {
10759
- const d = JSON.parse(readFileSync22(p, "utf8"));
10760
- return { interval: typeof d.interval === "string" ? d.interval : DEFAULT_INTERVAL, close: d.close === true, pid: d.pid, startedAt: d.startedAt, due: d.due };
10984
+ const d = JSON.parse(readFileSync23(p, "utf8"));
10985
+ 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
10986
  } catch {
10762
10987
  return { interval: DEFAULT_INTERVAL, close: false };
10763
10988
  }
10764
10989
  }
10765
10990
  function writeWatch(root, state) {
10766
- mkdirSync10(join27(root, ".lead"), { recursive: true });
10767
- writeFileSync12(join27(root, WATCH_PATH), `${JSON.stringify(state, null, 2)}
10991
+ mkdirSync11(join28(root, ".lead"), { recursive: true });
10992
+ writeFileSync13(join28(root, WATCH_PATH), `${JSON.stringify(state, null, 2)}
10768
10993
  `);
10769
10994
  }
10770
10995
  function alive(pid) {
@@ -10780,6 +11005,7 @@ function watchStatus(root) {
10780
11005
  const s = readWatch(root);
10781
11006
  const on = alive(s.pid);
10782
11007
  const bits = [`watch ${on ? "on" : "off"}`, `every ${s.interval}`, s.close ? "may close a finished milestone" : "asks before closing a milestone"];
11008
+ if (s.probe) bits.push(`probe ${s.probe}`);
10783
11009
  if (s.due) bits.push(`check due since ${s.due}`);
10784
11010
  return bits.join(", ");
10785
11011
  }
@@ -10835,6 +11061,12 @@ function runWatchLoop(root, sleep = (ms) => Atomics.wait(new Int32Array(new Shar
10835
11061
  sleep(ms);
10836
11062
  const after = readWatch(root);
10837
11063
  if (after.pid !== process.pid) return;
11064
+ if (after.probe === "shadow") {
11065
+ try {
11066
+ runProbe(root);
11067
+ } catch {
11068
+ }
11069
+ }
10838
11070
  after.due = (/* @__PURE__ */ new Date()).toISOString();
10839
11071
  writeWatch(root, after);
10840
11072
  const cmd = process.env.LEAD_WATCH_COMMAND;
@@ -10843,15 +11075,15 @@ function runWatchLoop(root, sleep = (ms) => Atomics.wait(new Int32Array(new Shar
10843
11075
  }
10844
11076
 
10845
11077
  // src/mergehold.ts
10846
- import { existsSync as existsSync26, mkdirSync as mkdirSync11, readFileSync as readFileSync23, rmSync as rmSync5, writeFileSync as writeFileSync13 } from "node:fs";
10847
- import { join as join28 } from "node:path";
11078
+ import { existsSync as existsSync27, mkdirSync as mkdirSync12, readFileSync as readFileSync24, rmSync as rmSync5, writeFileSync as writeFileSync14 } from "node:fs";
11079
+ import { join as join29 } from "node:path";
10848
11080
  var MERGE_LOCK = ".lead/merge.json";
10849
11081
  var HOLD_MS = 15 * 60 * 1e3;
10850
11082
  function read2(root) {
10851
- const p = join28(root, MERGE_LOCK);
10852
- if (!existsSync26(p)) return void 0;
11083
+ const p = join29(root, MERGE_LOCK);
11084
+ if (!existsSync27(p)) return void 0;
10853
11085
  try {
10854
- return JSON.parse(readFileSync23(p, "utf8"));
11086
+ return JSON.parse(readFileSync24(p, "utf8"));
10855
11087
  } catch {
10856
11088
  return void 0;
10857
11089
  }
@@ -10862,9 +11094,9 @@ function holdMerge(root, opts) {
10862
11094
  if (cur && cur.session !== opts.session && now.getTime() - Date.parse(cur.at) < HOLD_MS) {
10863
11095
  return { ok: false, message: `${cur.task} merge is held by session ${cur.session} since ${cur.at}` };
10864
11096
  }
10865
- mkdirSync11(join28(root, ".lead"), { recursive: true });
11097
+ mkdirSync12(join29(root, ".lead"), { recursive: true });
10866
11098
  const lock = { task: opts.task, session: opts.session, mr: opts.mr, at: now.toISOString() };
10867
- writeFileSync13(join28(root, MERGE_LOCK), `${JSON.stringify(lock, null, 2)}
11099
+ writeFileSync14(join29(root, MERGE_LOCK), `${JSON.stringify(lock, null, 2)}
10868
11100
  `);
10869
11101
  return { ok: true, message: `merge ${opts.mr} held for ${opts.task}` };
10870
11102
  }
@@ -10873,13 +11105,13 @@ function releaseMerge(root, opts) {
10873
11105
  if (!cur) return { ok: true, message: "no merge hold" };
10874
11106
  if (cur.task !== opts.task) return { ok: false, message: `merge hold is for ${cur.task}, not ${opts.task}` };
10875
11107
  if (cur.session !== opts.session) return { ok: false, message: `merge hold belongs to session ${cur.session}` };
10876
- rmSync5(join28(root, MERGE_LOCK), { force: true });
11108
+ rmSync5(join29(root, MERGE_LOCK), { force: true });
10877
11109
  return { ok: true, message: `merge hold for ${opts.task} released` };
10878
11110
  }
10879
11111
 
10880
11112
  // src/activity.ts
10881
- import { appendFileSync as appendFileSync2, existsSync as existsSync27, mkdirSync as mkdirSync12, readdirSync as readdirSync14, readFileSync as readFileSync24 } from "node:fs";
10882
- import { join as join29 } from "node:path";
11113
+ import { appendFileSync as appendFileSync3, existsSync as existsSync28, mkdirSync as mkdirSync13, readdirSync as readdirSync14, readFileSync as readFileSync25 } from "node:fs";
11114
+ import { join as join30 } from "node:path";
10883
11115
  var ACTIVITY_DIR = ".lead/activity";
10884
11116
  var EVENTS = ["start", "end", "check", "status", "note", "wait", "merge"];
10885
11117
  function isEvent(v) {
@@ -10897,21 +11129,21 @@ function appendActivity(root, entry) {
10897
11129
  ...entry.session ? { session: oneLine2(entry.session) } : {},
10898
11130
  ...entry.goal ? { goal: oneLine2(entry.goal) } : {}
10899
11131
  };
10900
- const rel = join29(ACTIVITY_DIR, `${at.slice(0, 10)}.jsonl`);
10901
- const abs = join29(root, rel);
10902
- mkdirSync12(join29(root, ACTIVITY_DIR), { recursive: true });
10903
- appendFileSync2(abs, `${JSON.stringify(row)}
11132
+ const rel = join30(ACTIVITY_DIR, `${at.slice(0, 10)}.jsonl`);
11133
+ const abs = join30(root, rel);
11134
+ mkdirSync13(join30(root, ACTIVITY_DIR), { recursive: true });
11135
+ appendFileSync3(abs, `${JSON.stringify(row)}
10904
11136
  `);
10905
11137
  return rel;
10906
11138
  }
10907
11139
  function readActivityDay(root, day) {
10908
- const p = join29(root, ACTIVITY_DIR, `${day}.jsonl`);
10909
- if (!existsSync27(p)) return [];
10910
- return readFileSync24(p, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
11140
+ const p = join30(root, ACTIVITY_DIR, `${day}.jsonl`);
11141
+ if (!existsSync28(p)) return [];
11142
+ return readFileSync25(p, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));
10911
11143
  }
10912
11144
  function listActivityDays(root) {
10913
- const dir = join29(root, ACTIVITY_DIR);
10914
- if (!existsSync27(dir)) return [];
11145
+ const dir = join30(root, ACTIVITY_DIR);
11146
+ if (!existsSync28(dir)) return [];
10915
11147
  return readdirSync14(dir).filter((n) => /^\d{4}-\d{2}-\d{2}\.jsonl$/.test(n)).map((n) => n.replace(/\.jsonl$/, "")).sort();
10916
11148
  }
10917
11149
  function loadActivity(root, opts = {}) {
@@ -10984,8 +11216,8 @@ function oneLine2(s) {
10984
11216
 
10985
11217
  // src/adopt.ts
10986
11218
  var import_yaml4 = __toESM(require_dist(), 1);
10987
- import { existsSync as existsSync28, mkdirSync as mkdirSync13, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "node:fs";
10988
- import { dirname as dirname5, join as join30 } from "node:path";
11219
+ import { existsSync as existsSync29, mkdirSync as mkdirSync14, readFileSync as readFileSync26, writeFileSync as writeFileSync15 } from "node:fs";
11220
+ import { dirname as dirname5, join as join31 } from "node:path";
10989
11221
  var REPO = /^[a-z][a-z0-9-]*$/;
10990
11222
  var keyNum = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? 0);
10991
11223
  function validateInventory(raw) {
@@ -11280,45 +11512,45 @@ function syncText(p) {
11280
11512
  `;
11281
11513
  }
11282
11514
  function writeProposal(root, p, force = false) {
11283
- const log = [];
11515
+ const log2 = [];
11284
11516
  const put = (rel, text, regenerate) => {
11285
- const abs = join30(root, rel);
11286
- if (existsSync28(abs)) {
11287
- const prev = readFileSync25(abs, "utf8");
11288
- if (prev === text) return void log.push(`unchanged ${rel}`);
11289
- if (!regenerate && !force) return void log.push(`kept ${rel}: it already exists and differs; --force replaces it`);
11290
- }
11291
- mkdirSync13(dirname5(abs), { recursive: true });
11292
- writeFileSync14(abs, text);
11293
- log.push(`wrote ${rel}`);
11517
+ const abs = join31(root, rel);
11518
+ if (existsSync29(abs)) {
11519
+ const prev = readFileSync26(abs, "utf8");
11520
+ if (prev === text) return void log2.push(`unchanged ${rel}`);
11521
+ if (!regenerate && !force) return void log2.push(`kept ${rel}: it already exists and differs; --force replaces it`);
11522
+ }
11523
+ mkdirSync14(dirname5(abs), { recursive: true });
11524
+ writeFileSync15(abs, text);
11525
+ log2.push(`wrote ${rel}`);
11294
11526
  };
11295
11527
  const dir = `${INITIATIVES_DIR}/${p.id}`;
11296
11528
  put(`${dir}/initiative.md`, initiativeText(p), false);
11297
11529
  put(`${dir}/one-pager.md`, onePagerText(p), false);
11298
11530
  put(`.lead/adapters/${p.id}/SKILL.md`, adapterText(p), false);
11299
11531
  put(`${dir}/sync.json`, syncText(p), true);
11300
- return log;
11532
+ return log2;
11301
11533
  }
11302
11534
 
11303
11535
  // src/score.ts
11304
- import { existsSync as existsSync29, readdirSync as readdirSync15, readFileSync as readFileSync26 } from "node:fs";
11305
- import { join as join31, relative as relative13 } from "node:path";
11536
+ import { existsSync as existsSync30, readdirSync as readdirSync15, readFileSync as readFileSync27 } from "node:fs";
11537
+ import { join as join32, relative as relative13 } from "node:path";
11306
11538
  function rubrics(root, kit) {
11307
11539
  const dirs = [
11308
- join31(kit, "skills/lead/scorers"),
11309
- join31(root, ".claude/skills/lead/scorers"),
11310
- join31(root, ".agents/skills/lead/scorers"),
11311
- join31(root, ".lead/local/scorers")
11540
+ join32(kit, "skills/lead/scorers"),
11541
+ join32(root, ".claude/skills/lead/scorers"),
11542
+ join32(root, ".agents/skills/lead/scorers"),
11543
+ join32(root, ".lead/local/scorers")
11312
11544
  ];
11313
11545
  const all = /* @__PURE__ */ new Map();
11314
- for (const dir of dirs.filter(existsSync29)) {
11546
+ for (const dir of dirs.filter(existsSync30)) {
11315
11547
  for (const name of readdirSync15(dir).sort()) {
11316
- const file = join31(dir, name, "scorer.md");
11317
- if (existsSync29(file)) all.set(name, file);
11548
+ const file = join32(dir, name, "scorer.md");
11549
+ if (existsSync30(file)) all.set(name, file);
11318
11550
  }
11319
11551
  }
11320
11552
  return [...all].map(([id2, file]) => {
11321
- const text = readFileSync26(file, "utf8");
11553
+ const text = readFileSync27(file, "utf8");
11322
11554
  const { parsed } = parseFrontmatter(text, file);
11323
11555
  const data = parsed?.data;
11324
11556
  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 +11696,8 @@ Usage: node .lead/lead.mjs <command> [options]
11464
11696
  initiative waves <id> [--write] compute (and with --write store) waves across the initiative's repositories
11465
11697
  adapters [name] [--json] project adapters in .lead/adapters/ (rules for reading this project's existing records)
11466
11698
  delegate [id] [check] [--json] services that can take a task, and tasks already handed off
11699
+ watch probe [report|shadow|off] [--dry] token-free pass over delegated tasks; shadow records its decision beside each tick
11700
+ watch ack [--acted|--idle] acknowledge a due check (--acted: an action was taken or required; --idle: nothing to do)
11467
11701
  watch [start|stop|interval 15m|ack] local clock for delegated tasks (default 15m; --close on start)
11468
11702
  improve print .lead/improve.md (stops, asks, what a kit change would avoid)
11469
11703
  improve --kind stop|ask|avoidable --where TEXT --what TEXT [--avoid TEXT]
@@ -11503,7 +11737,7 @@ function watchLine(root) {
11503
11737
  function kitRoot() {
11504
11738
  return resolve3(dirname6(fileURLToPath(import.meta.url)), "..");
11505
11739
  }
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"]);
11740
+ 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
11741
  function main(argv, out = (s) => console.log(s)) {
11508
11742
  const { cmd, args, flags } = parseArgs(argv);
11509
11743
  const unknown = Object.keys(flags).filter((f) => !KNOWN_FLAGS.has(f));
@@ -11528,7 +11762,7 @@ function main(argv, out = (s) => console.log(s)) {
11528
11762
  if (ws) {
11529
11763
  const path = relative14(ws.root, realpathSync6(origin));
11530
11764
  if (path === ".." || path.startsWith(".." + sep5)) throw new Error("the command directory is outside this workspace");
11531
- sharedKit = join32(ws.root, RUNTIME);
11765
+ sharedKit = join33(ws.root, RUNTIME);
11532
11766
  }
11533
11767
  if (flags.repo && (!ws || !str2(flags.repo))) throw new Error("--repo requires a workspace and repository name");
11534
11768
  if (cmd === "workspace") {
@@ -11546,15 +11780,15 @@ function main(argv, out = (s) => console.log(s)) {
11546
11780
  return 0;
11547
11781
  }
11548
11782
  if (args[0] === "improve") {
11549
- const report = workspaceImprove(ws);
11550
- if (flags.json) out(JSON.stringify(report, null, 2));
11783
+ const report2 = workspaceImprove(ws);
11784
+ if (flags.json) out(JSON.stringify(report2, null, 2));
11551
11785
  else {
11552
- out(`${report.entries.length} improvement entries across ${report.repositories.length} registered repositories`);
11553
- for (const repo of report.repositories) {
11786
+ out(`${report2.entries.length} improvement entries across ${report2.repositories.length} registered repositories`);
11787
+ for (const repo of report2.repositories) {
11554
11788
  const malformed = repo.malformed?.length ? ` \xB7 unparsed headings at lines ${repo.malformed.join(", ")}` : "";
11555
11789
  out(`- ${repo.id}: ${repo.count} \xB7 ${repo.state}${malformed}${repo.reason ? ` \xB7 ${repo.reason}` : ""}`);
11556
11790
  }
11557
- for (const entry of report.entries) {
11791
+ for (const entry of report2.entries) {
11558
11792
  out(`
11559
11793
  ## ${entry.at} \u2014 ${entry.kind} \xB7 ${entry.repository}
11560
11794
  ${entry.source}:${entry.line}
@@ -11571,7 +11805,8 @@ ${entry.source}:${entry.line}
11571
11805
  }
11572
11806
  if (args[0] === "attach" && args[1]) {
11573
11807
  const target = routeScope(ws, ws.root, void 0, args[1]).root;
11574
- if (existsSync30(join32(target, ".lead/lead.mjs")) && !isPortableLauncher(target)) throw new Error("a lead entry point already exists; review and migrate it before attaching");
11808
+ if (readMode(target) === "readonly") throw new Error("that repository is read-only (mode readonly)");
11809
+ 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
11810
  writeEntrypoints(target);
11576
11811
  for (const line of [...ensureGitIgnore(target), ...ensureClaudeSettings(target), ...ensureCodexHooks(target)]) out(line);
11577
11812
  out(`attached ${args[1]} to the shared lead workspace`);
@@ -11598,7 +11833,7 @@ ${entry.source}:${entry.line}
11598
11833
  if (scope) {
11599
11834
  cwd = scope.cwd;
11600
11835
  project = scope.project;
11601
- } else if (repoRoot(origin) === ws.root || !existsSync30(join32(repoRoot(origin), ".git"))) {
11836
+ } else if (repoRoot(origin) === ws.root || !existsSync31(join33(repoRoot(origin), ".git"))) {
11602
11837
  if (cmd === "session-start" && session) {
11603
11838
  out(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: `lead workspace session: ${session}. Pass --session ${session} to lead commands.` } }));
11604
11839
  return 0;
@@ -11616,6 +11851,14 @@ ${entry.source}:${entry.line}
11616
11851
  return 2;
11617
11852
  }
11618
11853
  }
11854
+ if (cmd) {
11855
+ const reason = writeReason(cmd, args, flags);
11856
+ const guarded = cmd === "install" && args[0] ? resolve3(cwd, args[0]) : repoRoot(cwd);
11857
+ if (reason && readMode(guarded) === "readonly") {
11858
+ out(readonlyRefusal(reason));
11859
+ return 3;
11860
+ }
11861
+ }
11619
11862
  switch (cmd) {
11620
11863
  case void 0:
11621
11864
  case "help":
@@ -11666,8 +11909,8 @@ ${entry.source}:${entry.line}
11666
11909
  return 1;
11667
11910
  }
11668
11911
  if (flags.write) {
11669
- const log = writeWaves(ctx);
11670
- out(log.length ? log.join("\n") : "waves already up to date");
11912
+ const log2 = writeWaves(ctx);
11913
+ out(log2.length ? log2.join("\n") : "waves already up to date");
11671
11914
  } else {
11672
11915
  const groups = /* @__PURE__ */ new Map();
11673
11916
  for (const [id2, w] of waves) groups.set(w, [...groups.get(w) ?? [], id2]);
@@ -11677,8 +11920,8 @@ ${entry.source}:${entry.line}
11677
11920
  }
11678
11921
  case "board": {
11679
11922
  const ctx = loadContext(cwd, project);
11680
- const log = writeBoard(ctx);
11681
- out(log.length ? log.join("\n") : "board is up to date");
11923
+ const log2 = writeBoard(ctx);
11924
+ out(log2.length ? log2.join("\n") : "board is up to date");
11682
11925
  return 0;
11683
11926
  }
11684
11927
  case "start":
@@ -11722,10 +11965,10 @@ ${entry.source}:${entry.line}
11722
11965
  case "enable":
11723
11966
  case "disable": {
11724
11967
  const root = repoRoot(cwd);
11725
- mkdirSync14(join32(root, ".lead"), { recursive: true });
11726
- if (cmd === "enable") writeFileSync15(join32(root, ENABLED_PATH), `${(/* @__PURE__ */ new Date()).toISOString()}
11968
+ mkdirSync15(join33(root, ".lead"), { recursive: true });
11969
+ if (cmd === "enable") writeFileSync16(join33(root, ENABLED_PATH), `${(/* @__PURE__ */ new Date()).toISOString()}
11727
11970
  `);
11728
- else rmSync6(join32(root, ENABLED_PATH), { force: true });
11971
+ else rmSync6(join33(root, ENABLED_PATH), { force: true });
11729
11972
  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
11973
  return 0;
11731
11974
  }
@@ -11746,7 +11989,7 @@ ${entry.source}:${entry.line}
11746
11989
  return 0;
11747
11990
  }
11748
11991
  if (!isMode(arg)) {
11749
- out("usage: mode [auto|approve|clear]");
11992
+ out("usage: mode [auto|approve|readonly|clear]");
11750
11993
  return 2;
11751
11994
  }
11752
11995
  writeMode(root, arg);
@@ -11765,7 +12008,8 @@ ${entry.source}:${entry.line}
11765
12008
  return 0;
11766
12009
  }
11767
12010
  case "session-start": {
11768
- const pointer = sharedKit && scope ? [`lead: this project runs with lead, no /lead needed. Launcher: ${join32(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.`] : [];
12011
+ 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.`] : [];
12012
+ if (readMode(repoRoot(cwd)) === "readonly") pointer.push("lead: READ-ONLY mode. Read and report only: do not edit files, create branches or worktrees, commit, push, write to the tracker or FuseBase, or run lead commands that write (the CLI refuses them). Only the person leaves this mode.");
11769
12013
  if (!isEnabled(repoRoot(cwd))) {
11770
12014
  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
12015
  return 0;
@@ -11823,7 +12067,7 @@ start the builder with: ${r.launch}`);
11823
12067
  return 2;
11824
12068
  }
11825
12069
  const ctx = loadContext(cwd, project);
11826
- const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [join32(ctx.root, ctx.project?.path ?? ".")];
12070
+ const targets = args.length ? args.map((a) => resolve3(cwd, a)) : [join33(ctx.root, ctx.project?.path ?? ".")];
11827
12071
  const matches = similarity(resolve3(cwd, source), targets, ctx.root);
11828
12072
  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
12073
  out(`${matches.length} shared fragments`);
@@ -11838,7 +12082,7 @@ start the builder with: ${r.launch}`);
11838
12082
  }
11839
12083
  const file = str2(flags.input);
11840
12084
  if (!file) throw new Error("--input FILE must point to the read-back Markdown");
11841
- const mismatches = verifyOnePager(markdown, readFileSync27(resolve3(cwd, file), "utf8"));
12085
+ const mismatches = verifyOnePager(markdown, readFileSync28(resolve3(cwd, file), "utf8"));
11842
12086
  out(mismatches.length ? mismatches.join("\n") : "One Pager read-back matches the roadmap, triage, widgets and links");
11843
12087
  return mismatches.length ? 1 : 0;
11844
12088
  } catch (e) {
@@ -11914,8 +12158,8 @@ start the builder with: ${r.launch}`);
11914
12158
  return 0;
11915
12159
  }
11916
12160
  const actions = syncPlan(ctx).map((a, i) => ({ id: i + 1, ...a }));
11917
- mkdirSync14(join32(ctx.root, ".lead/logs"), { recursive: true });
11918
- writeFileSync15(syncPlanPath(ctx.root, ctx.project.name), JSON.stringify({ project: ctx.project.name, actions }, null, 2));
12161
+ mkdirSync15(join33(ctx.root, ".lead/logs"), { recursive: true });
12162
+ writeFileSync16(syncPlanPath(ctx.root, ctx.project.name), JSON.stringify({ project: ctx.project.name, actions }, null, 2));
11919
12163
  out(JSON.stringify(actions, null, 2));
11920
12164
  return 0;
11921
12165
  }
@@ -11970,7 +12214,7 @@ start the builder with: ${r.launch}`);
11970
12214
  const input = () => {
11971
12215
  const file = str2(flags.input);
11972
12216
  if (!file) throw new Error("--input FILE is required");
11973
- return JSON.parse(readFileSync27(resolve3(cwd, file), "utf8"));
12217
+ return JSON.parse(readFileSync28(resolve3(cwd, file), "utf8"));
11974
12218
  };
11975
12219
  if (cmd === "qa-record") {
11976
12220
  const task = ctx.tasks.find((t) => t.id === args[0]);
@@ -12000,8 +12244,8 @@ start the builder with: ${r.launch}`);
12000
12244
  }
12001
12245
  }
12002
12246
  case "settings": {
12003
- const log = ensureClaudeSettings(repoRoot(cwd));
12004
- out(log.length ? log.join("\n") : "settings already up to date");
12247
+ const log2 = ensureClaudeSettings(repoRoot(cwd));
12248
+ out(log2.length ? log2.join("\n") : "settings already up to date");
12005
12249
  return 0;
12006
12250
  }
12007
12251
  case "claim":
@@ -12039,8 +12283,8 @@ start the builder with: ${r.launch}`);
12039
12283
  out(`usage: use <project>; projects: ${projects.map((p) => p.name).join(", ") || "none"}`);
12040
12284
  return 2;
12041
12285
  }
12042
- mkdirSync14(join32(root, ".lead"), { recursive: true });
12043
- writeFileSync15(join32(root, CURRENT_PATH), `${name}
12286
+ mkdirSync15(join33(root, ".lead"), { recursive: true });
12287
+ writeFileSync16(join33(root, CURRENT_PATH), `${name}
12044
12288
  `);
12045
12289
  out(`current project: ${name}`);
12046
12290
  return 0;
@@ -12052,10 +12296,10 @@ start the builder with: ${r.launch}`);
12052
12296
  }
12053
12297
  case "scaffold": {
12054
12298
  const ctx = loadContext(cwd, project);
12055
- const log = scaffold(ctx.root, ctx.configExists ? ctx.project : void 0);
12056
- if (!ctx.configExists) log.push("fill .lead/config.yml (checks, projects), then run scaffold again to create work/");
12057
- else if (!ctx.project) log.push("choose a project (--project NAME or `use NAME`) to create its work/");
12058
- out(log.length ? log.join("\n") : "nothing to create");
12299
+ const log2 = scaffold(ctx.root, ctx.configExists ? ctx.project : void 0);
12300
+ if (!ctx.configExists) log2.push("fill .lead/config.yml (checks, projects), then run scaffold again to create work/");
12301
+ else if (!ctx.project) log2.push("choose a project (--project NAME or `use NAME`) to create its work/");
12302
+ out(log2.length ? log2.join("\n") : "nothing to create");
12059
12303
  return 0;
12060
12304
  }
12061
12305
  case "doctor": {
@@ -12070,8 +12314,8 @@ start the builder with: ${r.launch}`);
12070
12314
  out("usage: install <repo>");
12071
12315
  return 2;
12072
12316
  }
12073
- const log = install(kitRoot(), realpathSync6(target), fileURLToPath(import.meta.url), { keepModified: !!flags["keep-modified"] });
12074
- out(log.join("\n"));
12317
+ const log2 = install(kitRoot(), realpathSync6(target), fileURLToPath(import.meta.url), { keepModified: !!flags["keep-modified"] });
12318
+ out(log2.join("\n"));
12075
12319
  return 0;
12076
12320
  }
12077
12321
  case "update": {
@@ -12084,9 +12328,9 @@ start the builder with: ${r.launch}`);
12084
12328
  const applyKit = (kit) => {
12085
12329
  if (!isKitRoot(kit)) throw new Error(`${kit} is not a lead kit release (missing dist/lead.mjs or skills/lead)`);
12086
12330
  const before = readLock(root)?.version ?? "none";
12087
- const r = spawnSync3(
12331
+ const r = spawnSync4(
12088
12332
  process.execPath,
12089
- [join32(kit, "dist/lead.mjs"), "install", root, ...flags.force ? [] : ["--keep-modified"]],
12333
+ [join33(kit, "dist/lead.mjs"), "install", root, ...flags.force ? [] : ["--keep-modified"]],
12090
12334
  { cwd: root, encoding: "utf8" }
12091
12335
  );
12092
12336
  const output = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
@@ -12100,8 +12344,8 @@ start the builder with: ${r.launch}`);
12100
12344
  try {
12101
12345
  if (!from) return withRegistryKit(root, out, applyKit);
12102
12346
  const path = resolve3(cwd, from);
12103
- if (existsSync30(path)) return applyKit(path);
12104
- tmp = mkdtempSync3(join32(tmpdir3(), "lead-kit-"));
12347
+ if (existsSync31(path)) return applyKit(path);
12348
+ tmp = mkdtempSync3(join33(tmpdir3(), "lead-kit-"));
12105
12349
  execFileSync6("git", ["clone", "-q", "--depth", "1", "--", from, tmp], { cwd, stdio: ["ignore", "pipe", "pipe"] });
12106
12350
  return applyKit(tmp);
12107
12351
  } catch (e) {
@@ -12129,7 +12373,7 @@ start the builder with: ${r.launch}`);
12129
12373
  }
12130
12374
  let raw;
12131
12375
  try {
12132
- raw = JSON.parse(readFileSync27(resolve3(cwd, input), "utf8"));
12376
+ raw = JSON.parse(readFileSync28(resolve3(cwd, input), "utf8"));
12133
12377
  } catch (error) {
12134
12378
  out(`cannot read ${input}: ${error.message}`);
12135
12379
  return 2;
@@ -12139,10 +12383,10 @@ start the builder with: ${r.launch}`);
12139
12383
  for (const e of errors) out(`error ${e}`);
12140
12384
  return 2;
12141
12385
  }
12142
- const syncFile = join32(root, "work/initiatives", id2, "sync.json");
12386
+ const syncFile = join33(root, "work/initiatives", id2, "sync.json");
12143
12387
  let previous;
12144
12388
  try {
12145
- previous = JSON.parse(readFileSync27(syncFile, "utf8"));
12389
+ previous = JSON.parse(readFileSync28(syncFile, "utf8"));
12146
12390
  } catch {
12147
12391
  previous = void 0;
12148
12392
  }
@@ -12233,7 +12477,7 @@ start the builder with: ${r.launch}`);
12233
12477
  out(`no adapter "${name}". Known: ${adapters.map((a) => a.id).join(", ") || "none"}`);
12234
12478
  return 1;
12235
12479
  }
12236
- out(flags.json ? JSON.stringify({ ...found, text: readFileSync27(join32(root, found.file), "utf8") }, null, 2) : readFileSync27(join32(root, found.file), "utf8").trimEnd());
12480
+ out(flags.json ? JSON.stringify({ ...found, text: readFileSync28(join33(root, found.file), "utf8") }, null, 2) : readFileSync28(join33(root, found.file), "utf8").trimEnd());
12237
12481
  return 0;
12238
12482
  }
12239
12483
  if (flags.json) out(JSON.stringify({ adapters, issues }, null, 2));
@@ -12275,9 +12519,33 @@ start the builder with: ${r.launch}`);
12275
12519
  }
12276
12520
  if (args[0] === "ack") {
12277
12521
  clearDue(root);
12522
+ recordAck(root, flags.acted === true ? true : flags.idle === true ? false : null);
12278
12523
  out("watch check acknowledged");
12279
12524
  return 0;
12280
12525
  }
12526
+ if (args[0] === "probe") {
12527
+ const sub = args[1];
12528
+ if (sub === "shadow" || sub === "off") {
12529
+ const st = readWatch(root);
12530
+ if (sub === "shadow") st.probe = "shadow";
12531
+ else delete st.probe;
12532
+ writeWatch(root, st);
12533
+ out(`probe ${sub === "shadow" ? "shadow: each tick also records what the token-free probe would decide; checks are not skipped" : "off"}`);
12534
+ return 0;
12535
+ }
12536
+ if (sub === "report") {
12537
+ const r2 = report(root);
12538
+ for (const line of flags.json ? [JSON.stringify(r2, null, 2)] : renderReport(r2)) out(line);
12539
+ return 0;
12540
+ }
12541
+ if (sub !== void 0) {
12542
+ out("usage: watch probe [report|shadow|off] [--dry] [--json]");
12543
+ return 2;
12544
+ }
12545
+ const res = runProbe(root, { record: flags.dry !== true });
12546
+ for (const line of flags.json ? [JSON.stringify(res, null, 2)] : renderVerdicts(res)) out(line);
12547
+ return 0;
12548
+ }
12281
12549
  const r = watchCommand(root, args, {
12282
12550
  close: flags.close === true,
12283
12551
  spawnLoop: () => {
@@ -12311,8 +12579,8 @@ start the builder with: ${r.launch}`);
12311
12579
  const root = repoRoot(cwd);
12312
12580
  if (args[0] === "analyze") {
12313
12581
  const rows = loadActivity(root, { day: str2(flags.day), since: str2(flags.since) });
12314
- const report = analyzeActivity(rows);
12315
- out(flags.json ? JSON.stringify(report, null, 2) : formatActivityReport(report));
12582
+ const report2 = analyzeActivity(rows);
12583
+ out(flags.json ? JSON.stringify(report2, null, 2) : formatActivityReport(report2));
12316
12584
  return 0;
12317
12585
  }
12318
12586
  const event = str2(flags.event);
@@ -12374,10 +12642,10 @@ ${HELP}`);
12374
12642
  }
12375
12643
  }
12376
12644
  function syncPlanPath(root, project) {
12377
- return join32(root, ".lead/logs", `sync-plan-${project === "." ? "root" : project.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
12645
+ return join33(root, ".lead/logs", `sync-plan-${project === "." ? "root" : project.replace(/[^a-zA-Z0-9_-]/g, "_")}.json`);
12378
12646
  }
12379
12647
  function savedSyncAction(root, project, id2) {
12380
- const saved = JSON.parse(readFileSync27(syncPlanPath(root, project), "utf8"));
12648
+ const saved = JSON.parse(readFileSync28(syncPlanPath(root, project), "utf8"));
12381
12649
  if (saved.project !== project) throw new Error(`the saved plan is for ${saved.project}, not ${project}`);
12382
12650
  return saved.actions.find((action) => action.id === id2);
12383
12651
  }
@@ -12391,20 +12659,20 @@ function syncLabel(action) {
12391
12659
  return `${action.kind}${target ? ` \xB7 ${target}` : ""}${transition}`;
12392
12660
  }
12393
12661
  function syncJournalPath(root, project) {
12394
- return join32(root, ".lead/logs", `sync-journal-${digest(project)}.json`);
12662
+ return join33(root, ".lead/logs", `sync-journal-${digest(project)}.json`);
12395
12663
  }
12396
12664
  function readSyncJournal(root, project) {
12397
12665
  const file = syncJournalPath(root, project);
12398
- return existsSync30(file) ? JSON.parse(readFileSync27(file, "utf8")) : {};
12666
+ return existsSync31(file) ? JSON.parse(readFileSync28(file, "utf8")) : {};
12399
12667
  }
12400
12668
  function writeSyncJournal(root, project, journal) {
12401
12669
  const file = syncJournalPath(root, project);
12402
- mkdirSync14(dirname6(file), { recursive: true });
12403
- writeFileSync15(file, JSON.stringify(journal, null, 2));
12670
+ mkdirSync15(dirname6(file), { recursive: true });
12671
+ writeFileSync16(file, JSON.stringify(journal, null, 2));
12404
12672
  }
12405
12673
  function readStdinJson() {
12406
12674
  try {
12407
- const text = readFileSync27(0, "utf8");
12675
+ const text = readFileSync28(0, "utf8");
12408
12676
  return text.trim() ? JSON.parse(text) : {};
12409
12677
  } catch {
12410
12678
  return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusebase/harness-lead",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "description": "Dev-loop kit for coding agents: plan, clean room, tasks and waves as Markdown in your repo.",
6
6
  "license": "UNLICENSED",
@@ -28,7 +28,7 @@ lead is opt-in for each developer. `node .lead/lead.mjs enabled` prints `on` or
28
28
  ## Every /lead
29
29
 
30
30
  1. Run `node .lead/lead.mjs status --json --session <id> --project <name>`. Take `<name>` only from this conversation, after the person picked or created it here. A line from a previous thread, `.lead/current`, or a remembered app does not count. If this conversation has not chosen one, replace `--project <name>` with `--cwd <the folder this session started in>`. If `.lead/lead.mjs` is missing, say lead is not installed in this repo and stop.
31
- 2. Arguments decide directly, without asking: a `teams.microsoft.com`, Discord, or Slack message link → `references/intake.md` (do not pass the URL to the CLI); `how` → show the output of `node .lead/lead.mjs how` as markdown, not inside a code fence, so its mermaid diagram renders; `help` → read `references/help.md`; `init` → `references/init.md`; `plan` → `references/plan.md`; `task [id]` → `references/task.md`; `qa <id>` → `references/review.md`; `sync` → `references/sync.md`; `status` → `references/status.md` and `references/visual.md`; `delegate` → `references/delegate.md`; `watch` → `references/watch.md`; `reverse <x>` → `references/reverse.md`; `qa milestone` → `references/qa.md`; `improve` → print `node .lead/lead.mjs improve` as markdown; `activity` → print `node .lead/lead.mjs activity` (or `--day YYYY-MM-DD`); `score` → `references/score.md`; `adopt` → `references/adopt.md` (also for refreshing an adopted epic and settling open items with `map:`); `initiative <id> --in <repo>` shows one repository's tasks and tracker records; `initiative [id]` → print `node .lead/lead.mjs initiative` (read-only: milestones, repositories, tasks, adapter of each large feature in `work/initiatives/`); `initiative check [id]` and `initiative waves <id> [--write]` check and order its tasks across repositories (task ids are unique in the initiative; `repo:` says where the code is; `blocked_by` takes `T-001` or `<repo>:T-001`); `adapters [name]` → print `node .lead/lead.mjs adapters` (or the named adapter); read the adapter that covers the epic or story before following any reference that reads this project's existing records; `mode` → `node .lead/lead.mjs mode` with no argument prints the mode, `mode auto` or `mode approve` sets it. When a Cursor goal is active in this conversation, also follow `references/goal.md`.
31
+ 2. Arguments decide directly, without asking: a `teams.microsoft.com`, Discord, or Slack message link → `references/intake.md` (do not pass the URL to the CLI); `how` → show the output of `node .lead/lead.mjs how` as markdown, not inside a code fence, so its mermaid diagram renders; `help` → read `references/help.md`; `init` → `references/init.md`; `plan` → `references/plan.md`; `task [id]` → `references/task.md`; `qa <id>` → `references/review.md`; `sync` → `references/sync.md`; `status` → `references/status.md` and `references/visual.md`; `delegate` → `references/delegate.md`; `watch` → `references/watch.md`; `reverse <x>` → `references/reverse.md`; `qa milestone` → `references/qa.md`; `improve` → print `node .lead/lead.mjs improve` as markdown; `activity` → print `node .lead/lead.mjs activity` (or `--day YYYY-MM-DD`); `score` → `references/score.md`; `adopt` → `references/adopt.md` (also for refreshing an adopted epic and settling open items with `map:`); `initiative <id> --in <repo>` shows one repository's tasks and tracker records; `initiative [id]` → print `node .lead/lead.mjs initiative` (read-only: milestones, repositories, tasks, adapter of each large feature in `work/initiatives/`); `initiative check [id]` and `initiative waves <id> [--write]` check and order its tasks across repositories (task ids are unique in the initiative; `repo:` says where the code is; `blocked_by` takes `T-001` or `<repo>:T-001`); `adapters [name]` → print `node .lead/lead.mjs adapters` (or the named adapter); read the adapter that covers the epic or story before following any reference that reads this project's existing records; `mode` → `node .lead/lead.mjs mode` with no argument prints the mode, `mode auto`, `mode approve` or `mode readonly` sets it, `mode clear` removes it. When a Cursor goal is active in this conversation, also follow `references/goal.md`.
32
32
  3. Without arguments: tell the state in one to three lines (project, milestone, wave, what is ready, in review, waiting for a human) and draw it (`references/visual.md`). Then follow **Mode**. Do not ask "What next?" when the mode says to act.
33
33
 
34
34
  | `next.kind` | Recommend | Read |
@@ -69,6 +69,7 @@ A command the host may hold for approval is the last command of the turn. Before
69
69
  - No mode yet: the first time you would pause, ask once and save it. Options, recommended first: auto — carry out the procedure and say what you did; approve — ask before each step. `node .lead/lead.mjs mode auto` or `mode approve`. If they pick auto, do the step.
70
70
  - `auto`: carry out the procedure. One line on what you did, then the following step. Do not end the turn on a menu.
71
71
  - `approve`: ask before each step, recommended option first, then do what they pick. The four stops above are asked in either mode.
72
+ - `readonly`: look and report, change nothing. Allowed: `status`, `check`, `inbox`, `initiative` (not `waves --write`), `adapters`, `adopt` and `sync-plan --preview` as previews, `watch status`, `watch probe --dry|report`, `workspace overview`, reading the tracker and merge requests. Not allowed: editing files, branches or worktrees, commits and pushes, `start`/`finish`/`review`/`claim`, `scaffold`, `board`, `spec`, `adopt --write`, `sync`, any write to the tracker or FuseBase, merging. The CLI refuses its own writing commands (exit 3); the rest is on you. Do not run `mode auto|approve|clear` yourself: only the person leaves this mode. If a step needs a write, say which one and stop. This overrides the rest of this section.
72
73
 
73
74
  ## Context: do not ask again
74
75
 
@@ -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
 
@@ -19,7 +19,7 @@ Show this list, then the state from `status --json`: project, milestone, wave, n
19
19
  /lead activity agent run log (.lead/activity/*.jsonl); `activity analyze` summarises waits and tasks
20
20
  /lead score sample past runs, apply rubrics, or review recurring findings (references/score.md)
21
21
  /lead help this list
22
- /lead mode auto or approve: whether a step inside the plan runs or waits (local, not in git)
22
+ /lead mode auto, approve or readonly: whether a step inside the plan runs, waits, or nothing is changed (local, not in git)
23
23
  /lead enable turn lead on for you in this repo (off by default; local, not in git)
24
24
  /lead disable turn it off again
25
25
  ```
@@ -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.