@mmerterden/multi-agent-pipeline 16.28.0 → 16.30.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +119 -2
  2. package/README.md +4 -4
  3. package/README.tr.md +3 -3
  4. package/docs/architecture.md +3 -3
  5. package/docs/ecosystem.md +5 -5
  6. package/docs/features.md +14 -0
  7. package/install/claude.mjs +17 -0
  8. package/package.json +1 -1
  9. package/pipeline/commands/multi-agent/analysis-jira/SKILL.md +93 -0
  10. package/pipeline/commands/multi-agent/design-check/SKILL.md +6 -5
  11. package/pipeline/commands/multi-agent/doctor/SKILL.md +78 -0
  12. package/pipeline/commands/multi-agent/help/SKILL.md +15 -12
  13. package/pipeline/commands/multi-agent/manual-test/SKILL.md +1 -1
  14. package/pipeline/commands/multi-agent/setup/SKILL.md +14 -1
  15. package/pipeline/commands/multi-agent/sync/SKILL.md +12 -9
  16. package/pipeline/commands/multi-agent/update/SKILL.md +12 -0
  17. package/pipeline/lib/_jira-auth.sh +99 -0
  18. package/pipeline/lib/analysis-jira-write.sh +203 -0
  19. package/pipeline/lib/issue-fetcher.sh +4 -4
  20. package/pipeline/multi-agent-refs/analysis/render.md +1 -1
  21. package/pipeline/multi-agent-refs/channels/pr.md +37 -1
  22. package/pipeline/multi-agent-refs/cross-cli-contract.md +3 -3
  23. package/pipeline/multi-agent-refs/features/analysis-jira.md +128 -0
  24. package/pipeline/multi-agent-refs/features/doctor.md +197 -0
  25. package/pipeline/multi-agent-refs/features/model-fallback.md +2 -2
  26. package/pipeline/multi-agent-refs/features/visual-evidence.md +103 -20
  27. package/pipeline/multi-agent-refs/phases/phase-0-init.md +38 -7
  28. package/pipeline/multi-agent-refs/phases/phase-3-dev.md +13 -1
  29. package/pipeline/multi-agent-refs/phases/phase-5-test.md +11 -1
  30. package/pipeline/multi-agent-refs/phases/phase-6-commit.md +23 -0
  31. package/pipeline/multi-agent-refs/picker-contract.md +35 -0
  32. package/pipeline/multi-agent-refs/tracker-contract.md +5 -1
  33. package/pipeline/preferences-template.json +1 -1
  34. package/pipeline/schemas/agent-state.schema.json +84 -1
  35. package/pipeline/schemas/analysis-spec.schema.json +336 -95
  36. package/pipeline/schemas/prefs.schema.json +80 -3
  37. package/pipeline/schemas/token-budget.json +10 -10
  38. package/pipeline/scripts/analysis-story-tree.mjs +441 -0
  39. package/pipeline/scripts/capture-evidence.sh +170 -5
  40. package/pipeline/scripts/doctor.mjs +758 -0
  41. package/pipeline/scripts/evidence-gate.mjs +31 -2
  42. package/pipeline/scripts/phase-tracker.sh +97 -17
  43. package/pipeline/scripts/probe-evidence-capability.sh +250 -0
  44. package/pipeline/scripts/run-ui-tests.sh +380 -0
  45. package/pipeline/scripts/scan-agent-config.sh +48 -10
  46. package/pipeline/scripts/skill-siblings.mjs +1 -1
  47. package/pipeline/skills/shared/core/multi-agent-analysis-jira/SKILL.md +94 -0
  48. package/pipeline/skills/shared/core/multi-agent-doctor/SKILL.md +79 -0
  49. package/pipeline/skills/shared/core/multi-agent-manual-test/SKILL.md +10 -1
  50. package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +13 -0
  51. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +9 -6
  52. package/pipeline/skills/shared/core/multi-agent-update/SKILL.md +18 -0
@@ -555,8 +555,8 @@
555
555
  },
556
556
  "fableEnabled": {
557
557
  "type": "boolean",
558
- "default": true,
559
- "description": "Whether the fable rung is available at all on Claude Code. false makes every persona that declares preferredModel: fable dispatch on opus from the first call, with no dispatch attempt on fable and no error to recover from - a cost control, not a fallback. Claude Code only: Copilot CLI does not offer Fable 5, and on Codex CLI the fable rung means gpt-5.6 @ xhigh, which this switch deliberately does not touch. Turning it off also collapses the Phase 4 Claude Code reviewer panel from three to two (Reviewer 1 lands on opus, which Reviewer 2 already holds), and consensus.reviewerCount records 2."
558
+ "default": false,
559
+ "description": "Whether the fable rung is available at all on Claude Code. Ships OFF: the top rung is the most expensive thing a run can reach, and a cost control that is on by default is not a control. false makes every persona that declares preferredModel: fable dispatch on opus from the first call, with no dispatch attempt on fable and no error to recover from - a cost control, not a fallback. Claude Code only: Copilot CLI does not offer Fable 5, and on Codex CLI the fable rung means gpt-5.6 @ xhigh, which this switch deliberately does not touch. Turning it off also collapses the Phase 4 Claude Code reviewer panel from three to two (Reviewer 1 lands on opus, which Reviewer 2 already holds), and consensus.reviewerCount records 2."
560
560
  },
561
561
  "onDispatchError": {
562
562
  "type": "boolean",
@@ -1865,7 +1865,84 @@
1865
1865
  "minimum": 5,
1866
1866
  "maximum": 300,
1867
1867
  "default": 60,
1868
- "description": "Recording cap. A flow needing longer is a debugging session, not a review artefact."
1868
+ "description": "Recording cap. A flow needing longer is a debugging session, not a review artefact. Android's `screenrecord` has its own ceiling of 180s that no setting can lift, so capture-evidence.sh clamps to it and says when it did: one preference honoured on one platform and silently halved on the other is worse than a stated limit."
1869
+ },
1870
+ "githubHost": {
1871
+ "type": "string",
1872
+ "enum": ["branch", "off"],
1873
+ "default": "branch",
1874
+ "description": "Where stills go on a run with no Jira. `branch` pushes them to an orphan `evidence/<task-id>` branch so the PR body can show them; GitHub has no API that attaches a file to an issue or a PR, and the web uploader needs a browser session, so a branch is the only mechanism a script has. `off` means no upload, the PR names the artefact directory, and the absence is recorded as a gap. Video is never pushed here: an mp4 behind a blob link is a download, not evidence a reviewer will open."
1875
+ }
1876
+ }
1877
+ },
1878
+ "testDepth": {
1879
+ "type": "object",
1880
+ "additionalProperties": false,
1881
+ "description": "How far a run tests by default. The question is asked at intake (Phase 0), not in Phase 5, because Phase 5 is not in the phase set for autopilot or either local mode. Autopilot never asks and reads `default` instead; the run records which rule fired.",
1882
+ "properties": {
1883
+ "default": {
1884
+ "type": "string",
1885
+ "enum": ["unit", "unit+ui", "unit+mcp"],
1886
+ "default": "unit+ui",
1887
+ "description": "Used by both autopilot entries, and as the preselected option for everyone else. An option the capability probe found closed is never taken from here: a default that cannot run is not a default."
1888
+ }
1889
+ }
1890
+ },
1891
+ "issueTree": {
1892
+ "type": "object",
1893
+ "additionalProperties": false,
1894
+ "description": "v16.29+ - how /multi-agent:analysis-jira turns an analysis document into a Jira story tree. Every site-specific NAME lives in a free-form map value here, never as a schema key: a key is a published literal and this file ships to everyone, so a site's component, team and issue-type names must be values the site fills in. subtaskRoles ships EMPTY on purpose - an empty list is an instruction to go and look at how this board actually splits work, while a ready-made list would be the guess we most want to avoid. subtaskIssueType null means discover it: createmeta returns whichever type carries subtask:true, under whatever name the site gave it. Same rule as features/jira-context.md - the type travels as it comes from Jira and is never a matching criterion in code.",
1895
+ "properties": {
1896
+ "enabled": {
1897
+ "type": "boolean",
1898
+ "default": true
1899
+ },
1900
+ "projectKey": {
1901
+ "type": ["string", "null"],
1902
+ "default": null,
1903
+ "description": "Where the tree is created. Null means ask at preview time."
1904
+ },
1905
+ "epicIssueType": {
1906
+ "type": "string",
1907
+ "default": "Epic"
1908
+ },
1909
+ "storyIssueType": {
1910
+ "type": "string",
1911
+ "default": "Story"
1912
+ },
1913
+ "subtaskIssueType": {
1914
+ "type": ["string", "null"],
1915
+ "default": null,
1916
+ "description": "Null means discover from createmeta rather than assume a name."
1917
+ },
1918
+ "subtaskRoles": {
1919
+ "type": "array",
1920
+ "items": {
1921
+ "type": "string"
1922
+ },
1923
+ "default": [],
1924
+ "description": "The roles each story is split into. Ships empty: mine the board, do not guess."
1925
+ },
1926
+ "channelComponents": {
1927
+ "type": "object",
1928
+ "additionalProperties": {
1929
+ "type": "string"
1930
+ },
1931
+ "default": {},
1932
+ "description": "channel -> this site's component name. Free-form: the key is the channel, the value is the site's own vocabulary."
1933
+ },
1934
+ "channelTeams": {
1935
+ "type": "object",
1936
+ "additionalProperties": {
1937
+ "type": "string"
1938
+ },
1939
+ "default": {},
1940
+ "description": "channel -> this site's team name. Free-form, same reason."
1941
+ },
1942
+ "labelPrefix": {
1943
+ "type": "string",
1944
+ "default": "ma-analysis",
1945
+ "description": "Prefix of the identity label a created issue carries. The label is how a second run, on a second machine or by a second analyst, finds the tree it already made instead of opening a duplicate."
1869
1946
  }
1870
1947
  }
1871
1948
  }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/token-budget.json",
4
- "description": "Per-phase token budget for lazy-loaded pipeline docs. Enforced by smoke-token-budget.sh.",
4
+ "description": "Per-phase token budget for lazy-loaded pipeline docs. Enforced by smoke-token-budget.sh. Raised in 16.30.0 for the four phases that gained a visual-evidence step (probe + depth question in 0, recording in 3 and 5, host resolution in 6): the docs were compressed first and these numbers are the measured residual, not headroom.",
5
5
  "phases": {
6
6
  "phase-0-init": {
7
- "max_tokens": 12500,
8
- "warn_tokens": 11900
7
+ "max_tokens": 13000,
8
+ "warn_tokens": 12400
9
9
  },
10
10
  "phase-1-analysis": {
11
11
  "max_tokens": 4600,
@@ -16,26 +16,26 @@
16
16
  "warn_tokens": 5650
17
17
  },
18
18
  "phase-3-dev": {
19
- "max_tokens": 8950,
20
- "warn_tokens": 7900
19
+ "max_tokens": 9250,
20
+ "warn_tokens": 8600
21
21
  },
22
22
  "phase-4-review": {
23
23
  "max_tokens": 15150,
24
24
  "warn_tokens": 12950
25
25
  },
26
26
  "phase-5-test": {
27
- "max_tokens": 2900,
28
- "warn_tokens": 2550
27
+ "max_tokens": 3050,
28
+ "warn_tokens": 2850
29
29
  },
30
30
  "phase-6-commit": {
31
- "max_tokens": 6150,
32
- "warn_tokens": 5450
31
+ "max_tokens": 6550,
32
+ "warn_tokens": 6100
33
33
  },
34
34
  "phase-7-report": {
35
35
  "max_tokens": 6350,
36
36
  "warn_tokens": 5600
37
37
  }
38
38
  },
39
- "total_max_tokens": 60750,
39
+ "total_max_tokens": 62400,
40
40
  "note": "Token estimate = ceil(chars / 4). Per-phase budget rule: warn = current+10% (rounded to nearest 50), max = current+25%. Gives ~6 edit cycles of headroom before warn trips - intentionally quiet under normal maintenance, loud when a phase grows unusually. Only the active phase is loaded (lazy). Recalibrated at v10.0.0 after the validator/consistency/simplifier/lesson gate contracts landed in phases 1-4. Recalibrated again at v10.9.0 after the verify-by-test (Phase 4 Step 3.7), update-check (Phase 0 Step 0.6), immutable-test (Phase 3 GREEN) and redTests re-entry contracts landed - Step 3.7 prose was compressed to a pointer into refs/features/verify-by-test.md before the recalibration. Total bumped 50000 -> 51000 at v12.5.0 after the worktree residue/traversal-prune contract (Phase 0 + Phase 5 heal) and the Reflexion causal-diagnosis contract (Phase 4 lesson memory) landed; the prose was compressed first (161 tokens reclaimed) and every per-phase max still passes - only the aggregate needed room. Recalibrated again at v13.6.0 after the install-relative path correction: an instruction that names `pipeline/scripts/x` resolves only from a repo checkout, and a run happens in the user's worktree, so 157 references across these docs moved to `$HOME/.claude/...` at +5 bytes each - 196 tokens of pure correctness cost. Same discipline as before: prose was compressed FIRST (149 tokens reclaimed, by pointing Phase 1's Figma tier table at the Phase 0 probe that already resolved it and Phase 4's Codex constraints at the always-loaded AGENTS.md block), and only then were the budgets moved. Five warn lines had been permanently amber, which makes the amber tier useless as a signal, so every warn was reset to the documented current+10% and the four maxes that the new warn would have collided with were reset to current+25%. Aggregate 51000 -> 51500. Total bumped 51500 -> 52200 at v14.0.0 after Phase 4 Review entered the four --dev mode phase sets and the criteria-resolution contract (Step 1.78) landed. Same discipline as every prior bump: prose was compressed FIRST, 820 tokens reclaimed, before the number moved. Two of those compressions are structural rather than cosmetic - the hardcoded SwiftUI interaction list in Step 1.5 and the SwiftUI convention paragraph in Step 2.8 were transcriptions of rules that now live in a scoped registry, so keeping them here would have re-created the drift this release exists to remove, and the third moved the Step 1.78 full contract into refs/features/skill-conformance.md leaving a pointer. What remains is contract text that cannot be inferred: the manifest's four consumer-visible parts, the conformance checklist the reviewers must return, and the fail-closed semantics. Every per-phase max still passes (phase-4 12405/14750); only the aggregate needed room. Total bumped 52200 -> 52700 at v14.1.0 after two more contracts landed: stack skill routing (Phase 3 pre-flight step 9) and worktree finalize (Phase 6 step 9). Compression came first, as always, and twice: 224 tokens out of Phase 3 by pointing its criteria-ledger and routing steps at their feature files instead of restating them, and 190 out of Phase 6 by moving the finalize contract into refs/features/worktree-finalize.md and leaving the invocation plus the exit-3 semantics. Both new contracts follow the pattern the earlier ones set: the phase doc carries the call and the decision, the feature file carries the reasoning, and the feature files are outside this budget because it loops only the eight phase-N-* keys. Every per-phase max still passes (phase-3 7677/8950, phase-6 5223/6150 and both under warn); only the aggregate needed room. Total bumped 52700 -> 52750 for the Phase 0 Step 3 branch-persistence correction: the step wrote the legacy `projects[].branches` while the TTL filter two sections below read `global.recentBranches`, and both spots named a `{name, lastUsed}` shape the schema rejects (`branch` required, `additionalProperties: false`), so the recent-branch picker option could never populate and a literal implementation would have failed prefs validation. Naming the right target, the right key and the legacy field to avoid costs 41 tokens over the one line it replaces. Compression came first and was applied three times to the replacement text itself, from 120 tokens down to 66, by moving the rationale out of the phase doc entirely: the reasoning now lives where it is enforced, in the migrate-prefs carry-forward comment and the smoke-pref-migration f7 block, leaving the phase doc with only the instruction. 50 was the smallest step that clears it; phase-0-init sits at 10893/12400, far under its own max, so this is purely an aggregate ceiling. v15.0.0: total 52750 -> 53100, the stack-skill tables in phase-1/2/4 now carry plugin-namespaced names (ai-<stack>-toolkit:<skill>) - functional prefixes, ~170 tokens. v15.10.0: total 53350 -> 53950 for the memory-recall + context-offload contracts (Phase 1 two-block durable-knowledge injection and its telemetry, Phase 3 build-log offload pipe, Phase 4 ranked prior art, offload pipe and recall telemetry). Compression came first and twice, taking the new prose from 1168 tokens to 580: the reasoning behind the two blocks lives in multi-agent-refs/prompt-assembly.md and the reasoning behind the offload filter lives in the offload-ref.sh header, both outside this budget, so the phase docs carry only the call, the pref that gates it and the one fact an agent cannot infer - that the evidence gate still reads the whole build log, so offloading changes what is read, never what counts as a verified pass. Every per-phase max still passes (phase-3 7985/8950, phase-4 12997/14750); phase-3 and phase-4 crossed their warn lines and are left amber on purpose, because that is the signal that those two docs are the next ones needing structural compression rather than another bump. v15.13.0: total 53950 -> 54050 for the prefs-to-flag bridges. Five settings had shipped declared-but-inert: contextOffload.minLines and .tailLines (fixed in 15.11.0), learningsLedger.maxBriefEntries, and testGap.scanTree and .promoteSeverity - the last two declared in the schema AND implemented as flags in the scanner, with nothing in between reading the pref and passing the flag. Wiring three of them costs the phase docs 94 tokens, which is the wiring itself and not prose: two `--max` substitutions and a three-line GAP_FLAGS block. Compression came first and twice, as always: the rationale that would have sat in phase-5 now lives in the header of smoke-prefs-consumed.sh, the gate that makes this class fail a build instead of shipping, and a `--severity-promote` table row was dropped because the invocation above it now shows the flag and names the pref that triggers it, which the row did not. 100 was the smallest step that clears it. Every per-phase max still passes; phase-3 and phase-4 remain amber on purpose. v15.14.0: total 54050 -> 54400 for the supported-version gate. Phase 0 Step 0.6 stopped being purely advisory: a release can now publish an npm dist-tag `required` that names the oldest runnable version, and below it the run halts instead of nagging. What the phase doc has to carry is the part an agent cannot infer - the third stdout field, that the halt is identical in autopilot, and that the run must NOT continue on the freshly updated install because its docs were already loaded from the old version. Compression came first, as always, and took the new prose from 469 tokens to 337: the rationale for the floor, the exemption list, the fail-open rules and the `npm dist-tag add` recipe all moved to multi-agent-refs/rules.md \"Supported Version Gate\" (loaded by 25 commands, outside this budget) and to the header of require-supported-version.sh, leaving the phase doc with the call, the decision table and the halt. 350 was the smallest step that clears it. Every per-phase max still passes (phase-0-init 11230/12400); phase-3 and phase-4 remain amber on purpose. v15.17.0: total 54400 -> 54900 for the Phase 1 analysis-document step. Phase 2 and Phase 3 pre-flights had BLOCKED on `analysis/<feature>-<platform>.md` since v9.0.0 while nothing produced it, so a full run either aborted at Phase 2 or the model ignored its own BLOCKING contract; Step 4 is the producer. What the phase doc carries is only what cannot be inferred: the when-table (taskType x Figma reference), the four refs in load order, the two artefacts, and that the doc validator fails closed. Compression came first and took the step from 745 tokens to 497: the history of why the gap existed moved to the CHANGELOG, the per-ref one-line descriptions moved into the refs' own headers, and the autopilot carve-out collapsed to one clause. The 17.4k-token analysis engine itself is NOT in this budget - it moved out of commands/ into multi-agent-refs/analysis/{locked,evidence,synthesis,render}.md, loaded on demand, which also took analysis/SKILL.md from 18081 to 5974 tokens and retired its lint grace entry. 500 was the smallest step that clears it; phase-1-analysis sits at 4338/4600 and is amber on purpose, like phase-3 and phase-4. v15.18.0: total 54900 -> 55250 for analysis mode. Three phase docs gained a mode branch that cannot be inferred: Phase 4 reviews a document instead of a diff (validator, the one question reviewers answer, the open-question walk), and Phase 6 publishes instead of committing. Compression came first and was applied twice to the new prose and once to old: the Phase 4 branch went from 320 tokens to 180 and the Phase 6 branch from 190 to 120 by pointing at multi-agent-refs/analysis/{resolve,render}.md, which now hold the walks themselves, and the front-matter parse contract stopped being spelled out in both pre-flights. The analysis engine keeps leaving this budget rather than entering it: intake joined locked/evidence/synthesis/render/resolve in multi-agent-refs/analysis/, which is what let analysis/SKILL.md drop under the 6000 hard cap after its grace entry was retired. 350 was the smallest step that clears it; phase-4 and phase-6 are amber on purpose, as phase-1 and phase-3 already were. v15.20.0: total 55250 -> 55500 for the TDD bridge. Phase 3 pre-flight read the analysis doc's concept table and even said test method names come from it, while nothing read Section 15 - so the RED step invented tests and the analysis test matrix never reached development. Phase 3 step 5b now loads it into state.dev.testPlan[] and Phase 4 step 1.45 cross-checks every planned row against a real test, which is what turns \"analysis quality is output quality\" from a slogan into a finding. Compression came first on both blocks, 300 tokens down to 175, by dropping the enumerated failure modes to one line each and the rationale to one clause; the reasoning lives in the CHANGELOG. 250 was the smallest step that clears it. v15.21.0: total 55500 -> 55800 for the post-analysis confirmation. Phase 2 gained Step 0.9, the last human checkpoint before Phase 3: derived values are shown for confirmation and only Section 20 rows are asked, through the resolve engine that already exists in refs. It belongs here rather than Phase 4 because Phase 4 runs after development, where an answer arrives too late to change anything. Compression came first and twice, 430 tokens down to 250, by collapsing the derived-vs-asked explanation to one sentence each and moving the walk itself to multi-agent-refs/analysis/resolve.md, which Phase 4 and analysis-resolve already mount. 300 was the smallest step that clears it. v15.22.0: total 55800 -> 55900 for the analyst-toolkit hooks. Phase 1 Step 4 now names the two prefs that decide whether a document is produced at all and how deep it goes (forceFull, mode) - the first of those had shipped declared-but-inert and smoke-prefs-consumed caught it - and Phase 4 triage gained one clause: a finding that blames a third-party library asks evidence-github whether it is already open upstream, which turns it into a deferred item with a citation instead of Phase 3 rework on code that is not ours. Compression came first and three times, taking the new prose from 220 tokens to 110, and the Phase 1d evidence contract itself never entered this budget - it lives in multi-agent-refs/analysis/evidence.md beside the phases it belongs to. 100 was the smallest step that clears it, leaving 34 tokens of headroom. phase-4 stays amber and the debt named at v15.10.0 stands: it is the doc that needs structural compression rather than another bump, and the two candidates are the inline triage JSON shape and the 3.4 telemetry block, both of which restate something already authoritative elsewhere. v16.0.0: total 55900 -> 56350 for the depth picker. `--dev` and the four dev-* commands are gone; depth is Phase 0 Step 7.5, which costs phase-0-init a step it did not have. Compression came first and three times, taking the step from 530 tokens to 300: the question wording, the per-taskType recommendation and the mode tables all live in phases/modes.md (outside this budget), so the phase doc carries only what an agent cannot infer - that the step runs after Step 7 and why, who is exempt, that ASK_CHOICE_DEFAULT must be passed explicitly because ask-choice.sh takes the FIRST option on a non-TTY, and that Short flips the Phase 1/2 tiles late rather than pre-marking them. The phase-4 telemetry block named as compression debt at v15.22.0 was collapsed to an emit() helper (-27) and the four dev-* mode files left the tree entirely, but neither offsets a genuinely new phase step. 450 was the smallest step that clears it, leaving 119 tokens of headroom. phase-4 remains amber and its other named candidate, the inline triage JSON shape, was left alone on purpose: it is the prompt the triage agent is handed, not a restatement for readers. v16.2.0: total 56350 -> 56600 for the spec-freshness and reuse-tag contracts. Phase 3 step 3 had compared `state.run.lastAnalysisDigest` since it was written, against a key nothing ever set and that the state schema did not declare, so the staleness branch was unreachable and every run reported fresh by default. Phase 1 now persists the digest and a `base_commit` anchor, and step 3 gained the repo-drift half the digest cannot see: a reused document keeps a matching digest precisely because its evidence inputs did not change, while the code underneath it moved. The second contract is the Section 14 tag reaching development: Phase 2 carries it onto the todo as `sourceTag` and Phase 3 treats it as an instruction, which is what stops a Reuse row from being re-implemented. Compression came first and took the four additions from 380 tokens to 214, by moving every rationale clause out of the phase docs: why the commit anchor exists rather than a digest recomputation lives in this note and the CHANGELOG, and the schema descriptions carry the field semantics. The baseline had 9 tokens of headroom, so no addition of any size could have fit without a bump. 250 was the smallest step that clears it, leaving 45 tokens. phase-3 and phase-4 remain amber. v16.13.0: total 57600 -> 57700 for the code-graph injection and the fable-rung switch. Phase 1 gained Step 2.6 (query the graph, hand Explore a ranked starting set), Phase 7 gained the post-branch graph refresh, and Phase 0 Step 0 gained one line: a prefs switch that resolves every preferredModel: fable persona to opus for the run, which also collapses the Phase 4 Claude Code panel from three reviewers to two. Compression came first and mostly structurally: of roughly 1,630 tokens of new contract text, 1,310 never entered this budget at all - the whole code-graph contract lives in multi-agent-refs/features/code-graph.md (604) and the fable switch's scope table, per-host effects and cost-accounting consequence live in features/model-fallback.md (+707), leaving the phase docs with the call, the pref that gates it and the one fact an agent cannot infer. Phase 4 was compressed on top of that: its TLDR restated the reviewer matrix 270 lines below it, so 36 tokens came back and the doc nets +6 despite carrying two new clauses. One of those clauses is a correction rather than a feature - the consensus rule still said reviewerCount is 2 on Claude Code, which stopped being true when the third reviewer landed in 16.12.0, and the cross-CLI smoke never caught it because it reads the matrix line instead. 100 was the smallest step that clears it, leaving 54 tokens. phase-3 and phase-4 remain amber. v16.17.0: total 57700 -> 57850 for the platform-parity cross-check. Phase 4 gained Step 1.8: when dev-context carries a counterpart app repo, the review compares the change against the other platform on four axes. Compression came first and structurally, as always - of roughly 1,610 tokens of new contract text, 1,490 never entered this budget at all, because the four axes, the file cap, the graph-query recipe, the read-only prohibitions and the rule that an extractor miss may not be reported as an absence all live in multi-agent-refs/platform-parity.md. The step itself was then cut from ~200 tokens to 120 by deleting everything the ref already owns, leaving the trigger, the pointer and the two facts an agent must not infer: the counterpart repo is read-only, and parity findings are never blocking. The baseline had 13 tokens of headroom, so no addition of any size could have fit without a bump. 150 was the smallest step that clears it, leaving 35 tokens. phase-3 and phase-4 remain amber, and phase-4's structural-compression debt still stands. v16.20.0: phase-4-review max 14750 -> 15150 and total 58250 -> 60250 for the cross-round review delta, the scope self-check handoff and the circuit-breaker wiring. Compression came first and structurally: of roughly 3,900 tokens of new contract text, 2,700 never entered this budget at all - the previous-round-findings block, the scope-self-check block, the Step 3.8 state merge, telemetry and picker wording live in multi-agent-refs/features/review-delta.md, and the scope-check record rules and consumers in features/scope-check.md - so the phase docs carry the call, the pref that gates it and the exit table. The Phase 3 stability rule and the trigger-3 write were cut twice more before the bump; phase-3 stays under its max (8692/8950). Phase 4 is the first per-phase max raised since v10.9.0: the doc gained three steps that cannot be inferred (a per-round triage file, a prefix block that changes what reviewers report, and a halt condition), and its structural-compression debt (the inline triage JSON shape, named at v15.10.0) still stands and is the next candidate. 15150 and 60250 were the smallest steps that clear it, leaving 25 and 45 tokens. v16.23.0: phase-0-init max 12400 -> 12500 and total 60250 -> 60500 for the widget-registration call and the accounting gate. Phase 0 gained the `tiles` call and the exit-3 rule, Phase 7 gained the run report; together they are contract an agent cannot infer - which call registers this host's widget, and that a completion is refused without recorded spend. Compression came first and twice, taking the new prose from 472 tokens to 255: the per-host call list moved into tracker-contract.md \"The card is not the widget\" and the record-then-rerun recovery into \"Accounting is a gate\", both outside this budget, leaving the phase docs with the call and the one fact that cannot be looked up. 100 and 250 were the smallest steps that clear it, leaving 74 and 40 tokens. phase-3 and phase-4 remain amber. v16.24.0: total 60500 -> 60750 for visual evidence. Four phase docs gained one instruction each that cannot be inferred: Phase 0 keeps the issue's own images as the pre-fix evidence, Phase 3 captures the fixed state (there and not Phase 5, because every autopilot and --local entry drops Phase 5), Phase 5 hosts the flow recording when it runs, and Phase 6 blocks on a required artefact that is neither attached nor explained. Compression came first and twice, 42 tokens back, and the contract itself never entered this budget: the trigger matrix, the three video tiers, the size-degradation ladder and both render shapes live in multi-agent-refs/features/visual-evidence.md. phase-0-init cleared its own max without a bump. 250 was the smallest step that clears the aggregate. phase-3 and phase-4 remain amber."
41
41
  }
@@ -0,0 +1,441 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @file analysis-story-tree.mjs - an analysis document, read as a work breakdown.
4
+ *
5
+ * WHAT THIS IS
6
+ *
7
+ * It plans a Jira tree from a rendered analysis document and prints the plan.
8
+ * It never writes to Jira; `analysis-jira-write.sh` does that, from this output.
9
+ * The split is the point: planning is deterministic and testable with no network,
10
+ * and the thing that can create issues is small enough to read in one sitting.
11
+ *
12
+ * THE COVERAGE CHECK IS TWO-WAY, AND THE SECOND DIRECTION IS THE USEFUL ONE
13
+ *
14
+ * Forward: every atom in the document (`BR-<slug>-NN` globally, `FG-NN` in the
15
+ * corporate profile) appears in some story, or is listed as uncovered. That
16
+ * catches a dropped requirement.
17
+ *
18
+ * Backward: every id a story cites is actually defined in the document. That
19
+ * catches an INVENTED story - a node with no requirement behind it - which no
20
+ * forward check can see, and which is the failure mode of building a tree from a
21
+ * model's reading rather than from the document's own ids.
22
+ *
23
+ * AN UNVERIFIABLE RUN MUST NOT LOOK VERIFIED
24
+ *
25
+ * A lite global document may carry no `BR` ids at all. Then coverage cannot run,
26
+ * and the verdict is `unverifiable` - not `ok`. It gets its own line in the
27
+ * preview, its own approval option, and its own heading in any write-back. A run
28
+ * that could not be checked is allowed; one that looks checked when it was not
29
+ * is the defect.
30
+ *
31
+ * IDENTITY IS A LABEL, NOT A TITLE
32
+ *
33
+ * Each planned node carries a label derived from a fingerprint of the document
34
+ * id plus the node's source ids. A second run finds its own tree back through
35
+ * JQL on that label. Titles were the obvious key and are the wrong one: they get
36
+ * edited, and matching on them breaks exactly when someone has improved the
37
+ * wording. The label lives server-side, so it also works from a second machine,
38
+ * after `~/.claude` is deleted, and for a SECOND ANALYST - who is precisely the
39
+ * person positioned to open a duplicate tree.
40
+ *
41
+ * Usage:
42
+ * analysis-story-tree.mjs <analysis.md> [--json] [--prefs FILE]
43
+ *
44
+ * Exit: 0 planned, 2 nothing to plan, 3 usage, 4 the document is not issue-ready.
45
+ */
46
+
47
+ import { readFileSync, existsSync } from "node:fs";
48
+ import { createHash } from "node:crypto";
49
+ import { homedir } from "node:os";
50
+ import { join } from "node:path";
51
+
52
+ const argv = process.argv.slice(2);
53
+ const JSON_OUT = argv.includes("--json");
54
+ const prefsFlag = argv.indexOf("--prefs");
55
+ const PREFS_PATH =
56
+ prefsFlag !== -1
57
+ ? argv[prefsFlag + 1]
58
+ : join(homedir(), ".claude", "multi-agent-preferences.json");
59
+ const file = argv.find((a) => !a.startsWith("--") && a !== PREFS_PATH);
60
+
61
+ function die(msg, code) {
62
+ process.stderr.write(`${msg}\n`);
63
+ process.exitCode = code;
64
+ return null;
65
+ }
66
+
67
+ const ATOM_GLOBAL = /\bBR-[a-z0-9]+(?:-[a-z0-9]+)*-\d+\b/gi;
68
+ const ATOM_CORP = /\bFG-\d{2,3}\b/g;
69
+ const GROUP_CORP = /\bUC-\d{2,3}\b/g;
70
+
71
+ function frontMatter(text) {
72
+ const lines = text.split("\n");
73
+ if (lines[0]?.trim() !== "---") return {};
74
+ const end = lines.indexOf("---", 1);
75
+ if (end < 0) return {};
76
+ const fm = {};
77
+ for (let i = 1; i < end; i++) {
78
+ const m = lines[i].match(/^([a-z_]+):\s*(.*)$/);
79
+ if (m) fm[m[1]] = m[2].trim().replace(/^["']|["']$/g, "");
80
+ }
81
+ return fm;
82
+ }
83
+
84
+ /** Headings with their bodies, so a story can be scoped to a section. */
85
+ function sections(text) {
86
+ const out = [];
87
+ let cur = null;
88
+ for (const line of text.split("\n")) {
89
+ const h = line.match(/^(#{2,3})\s+(\d+(?:\.\d+)*)\.?\s+(.*)$/);
90
+ if (h) {
91
+ if (cur) out.push(cur);
92
+ cur = { number: h[2], title: h[3].trim(), body: [] };
93
+ continue;
94
+ }
95
+ if (cur) cur.body.push(line);
96
+ }
97
+ if (cur) out.push(cur);
98
+ return out;
99
+ }
100
+
101
+ /**
102
+ * The identity label. Derived from the document id, the node's own group and
103
+ * its source ids, so it is stable across re-runs and distinct per node - and it
104
+ * is NOT derived from the title, which is the thing people edit.
105
+ *
106
+ * The group is in the hash because the source ids alone are not an identity:
107
+ * two groups can legitimately cite the same atoms, and a shared label collapses
108
+ * both nodes onto one issue the next time the tree is searched by label.
109
+ */
110
+ export function identityLabel(prefix, docId, sourceIds) {
111
+ const h = createHash("sha256")
112
+ .update(`${docId}${[...sourceIds].sort().join(",")}`)
113
+ .digest("hex")
114
+ .slice(0, 10);
115
+ return `${prefix}-${h}`;
116
+ }
117
+
118
+ /**
119
+ * The settings this file consumes, by their full `parent.leaf` path.
120
+ *
121
+ * Written out rather than destructured because a bare leaf (`enabled`,
122
+ * `projectKey`) is also an ordinary word: a reader cannot tell which settings a
123
+ * file actually reads, and neither can `smoke-prefs-consumed.sh`. Naming the
124
+ * path is what makes "declared" and "consumed" the same list.
125
+ *
126
+ * issueTree.enabled refuse to run when the site turned this off
127
+ * issueTree.projectKey where the tree is created
128
+ * issueTree.epicIssueType the type name for an epic on this site
129
+ * issueTree.storyIssueType the type name for a story
130
+ * issueTree.subtaskIssueType null = discover from createmeta
131
+ * issueTree.subtaskRoles how a story is split; ships empty on purpose
132
+ * issueTree.channelComponents channel -> this site's component name
133
+ * issueTree.channelTeams channel -> this site's team name
134
+ * issueTree.labelPrefix prefix of the identity label
135
+ */
136
+ const ISSUE_TREE_SETTINGS = [
137
+ "issueTree.enabled",
138
+ "issueTree.projectKey",
139
+ "issueTree.epicIssueType",
140
+ "issueTree.storyIssueType",
141
+ "issueTree.subtaskIssueType",
142
+ "issueTree.subtaskRoles",
143
+ "issueTree.channelComponents",
144
+ "issueTree.channelTeams",
145
+ "issueTree.labelPrefix",
146
+ ];
147
+
148
+ function readPrefs() {
149
+ try {
150
+ const j = JSON.parse(readFileSync(PREFS_PATH, "utf8"));
151
+ const g = j?.global || {};
152
+ const out = {};
153
+ for (const path of ISSUE_TREE_SETTINGS) {
154
+ const leaf = path.split(".")[1];
155
+ const v = g.issueTree?.[leaf];
156
+ if (v !== undefined) out[leaf] = v;
157
+ }
158
+ return out;
159
+ } catch {
160
+ return {};
161
+ }
162
+ }
163
+
164
+ /** Every open placeholder that makes a document unfit to become work. */
165
+ export function openItems(text) {
166
+ const found = [];
167
+ for (const [i, line] of text.split("\n").entries()) {
168
+ if (/\bEKLENECEK\b/.test(line)) found.push(`line ${i + 1}: EKLENECEK`);
169
+ else if (/\bTBD\b/.test(line)) found.push(`line ${i + 1}: TBD`);
170
+ else if (/^\s*\|/.test(line) && /(Açık \/ Open|Acik \/ Open|Girdi bekleniyor)/i.test(line))
171
+ found.push(`line ${i + 1}: an open Section 20 row`);
172
+ }
173
+ return found;
174
+ }
175
+
176
+ /**
177
+ * Coverage, in both directions, over a set of defined ids and a set of nodes.
178
+ *
179
+ * Extracted so the backward direction can be tested against ITS OWN code rather
180
+ * than against a re-implementation in a test. The planner cannot produce an
181
+ * invented id - it derives every `sourceIds` from `defined` - so a test that
182
+ * builds one by hand and re-checks it with hand-written logic proves nothing
183
+ * about this function. Calling this with a fabricated node does.
184
+ *
185
+ * The backward direction guards the boundary where a plan arrives from
186
+ * somewhere else: hand-edited, resumed from an older format, or written by
187
+ * something that read the document rather than its ids.
188
+ */
189
+ export function coverageOf(defined, nodes, corporate = false) {
190
+ const covered = new Set(nodes.flatMap((n) => n.sourceIds || []));
191
+ const uncovered = [...defined].filter((id) => !covered.has(id)).sort();
192
+ const invented = [...covered].filter((id) => !defined.has(id)).sort();
193
+ let verdict;
194
+ if (defined.size === 0) {
195
+ // Nothing to check against. Saying "ok" here would be the lie this tool is
196
+ // built to avoid: no atoms means the check did not run, not that it passed.
197
+ verdict = "unverifiable";
198
+ } else if (uncovered.length || invented.length) {
199
+ verdict = "incomplete";
200
+ } else {
201
+ verdict = "ok";
202
+ }
203
+ return {
204
+ verdict,
205
+ atomsDefined: defined.size,
206
+ atomsCovered: covered.size,
207
+ uncovered,
208
+ invented,
209
+ reason:
210
+ verdict === "unverifiable"
211
+ ? `no ${corporate ? "FG-NN" : "BR-<slug>-NN"} ids in the document, so coverage could not be checked`
212
+ : null,
213
+ };
214
+ }
215
+
216
+ export function plan(text, prefs) {
217
+ const fm = frontMatter(text);
218
+ const profile = (fm.profile || "global").toLowerCase();
219
+ const corporate = profile === "corporate";
220
+ const secs = sections(text);
221
+
222
+ const atomRe = corporate ? ATOM_CORP : ATOM_GLOBAL;
223
+ const defined = new Set((text.match(atomRe) || []).map((x) => x.toUpperCase()));
224
+
225
+ // The document's own identity. `evidence_digest` is what changes when the
226
+ // evidence changes, which is exactly when a re-plan should produce new nodes.
227
+ const docId = fm.evidence_digest || fm.feature || "unidentified";
228
+ const prefix = prefs.labelPrefix || "ma-analysis";
229
+
230
+ const groups = corporate
231
+ ? [...new Set(text.match(GROUP_CORP) || [])].sort()
232
+ : [...new Set([...defined].map((id) => id.replace(/-\d+$/, "")))].sort();
233
+
234
+ // One story per group, scoped to the section that defines the most of its
235
+ // atoms. A story with no section is still a story - the atoms are the claim,
236
+ // the heading is only the label.
237
+ //
238
+ // A lite document may carry no ids at all, and its user-story sub-sections are
239
+ // still real work. Deriving from those keeps such a run useful AND makes
240
+ // `unverifiable` a state that actually occurs: without this fallback the
241
+ // no-atom document produced no stories, exited "nothing to plan", and the
242
+ // unverifiable branch below was unreachable - a case the code claimed to
243
+ // handle and never could.
244
+ //
245
+ // Corporate atoms are attributed ROW-WISE, never section-wise. The template
246
+ // states the mapping in a column - the functional-requirement table carries a
247
+ // source-UC cell, and the traceability matrix repeats the chain - so both of
248
+ // those sections necessarily name EVERY use case. Reading attribution from
249
+ // section containment therefore handed every group every atom: three stories
250
+ // with identical sources, identical titles, and, since the label hashes the
251
+ // sources, one identical label, which collapsed the whole tree onto a single
252
+ // issue on the second run while coverage still reported `ok`.
253
+ //
254
+ // No column name is hardcoded. An atom and a group sharing one table row IS
255
+ // the mapping, in whatever language the site writes its headers.
256
+ const rowAtoms = new Map();
257
+ if (corporate) {
258
+ for (const line of text.split("\n")) {
259
+ const gs = line.match(GROUP_CORP);
260
+ if (!gs) continue;
261
+ const as = line.match(ATOM_CORP);
262
+ if (!as) continue;
263
+ for (const g of new Set(gs)) {
264
+ if (!rowAtoms.has(g)) rowAtoms.set(g, new Set());
265
+ for (const a of as) rowAtoms.get(g).add(a.toUpperCase());
266
+ }
267
+ }
268
+ }
269
+
270
+ const stories = [];
271
+ for (const g of groups) {
272
+ let ids;
273
+ if (!corporate) {
274
+ ids = [...defined].filter((id) => id.startsWith(`${g}-`)).sort();
275
+ } else if (rowAtoms.has(g)) {
276
+ ids = [...rowAtoms.get(g)].sort();
277
+ } else {
278
+ // No row states this group's atoms. A document that lists them inside the
279
+ // use-case section instead is still readable; section containment is the
280
+ // fallback, not the rule.
281
+ ids = [
282
+ ...new Set(
283
+ secs
284
+ .filter((s) => s.body.join("\n").includes(g) || s.title.includes(g))
285
+ .flatMap((s) => s.body.join("\n").match(ATOM_CORP) || []),
286
+ ),
287
+ ].sort();
288
+ }
289
+ if (ids.length === 0) continue;
290
+ // The template titles a use-case section with the group's own id, so a title
291
+ // match is the accurate answer where one exists. The hit count is the
292
+ // fallback, and on a consolidated table it names the same section for every
293
+ // group - a cosmetic limit, since the title is a label and the group is the
294
+ // identity.
295
+ const titled = secs.find((s) => s.title.includes(g));
296
+ const best = titled
297
+ ? { s: titled, n: 1 }
298
+ : secs
299
+ .map((s) => ({
300
+ s,
301
+ n: ids.filter((id) => s.body.join("\n").toUpperCase().includes(id)).length,
302
+ }))
303
+ .sort((a, b) => b.n - a.n)[0];
304
+ stories.push({
305
+ kind: "story",
306
+ title: best && best.n > 0 ? `${best.s.number} ${best.s.title}` : g,
307
+ group: g,
308
+ sourceIds: ids,
309
+ label: identityLabel(prefix, docId, [g, ...ids]),
310
+ subtasks: (prefs.subtaskRoles || []).map((role) => ({
311
+ kind: "subtask",
312
+ role,
313
+ title: role,
314
+ sourceIds: ids,
315
+ label: identityLabel(prefix, docId, [g, ...ids, role]),
316
+ })),
317
+ });
318
+ }
319
+
320
+ if (stories.length === 0 && defined.size === 0) {
321
+ const storySections = secs.filter((sec) => /^4\.\d+$/.test(sec.number));
322
+ for (const sec of storySections) {
323
+ if (!sec.body.join("").trim()) continue;
324
+ stories.push({
325
+ kind: "story",
326
+ title: `${sec.number} ${sec.title}`,
327
+ group: sec.number,
328
+ sourceIds: [],
329
+ derivedFrom: "section",
330
+ label: identityLabel(prefix, docId, [sec.number]),
331
+ subtasks: (prefs.subtaskRoles || []).map((role) => ({
332
+ kind: "subtask",
333
+ role,
334
+ title: role,
335
+ sourceIds: [],
336
+ label: identityLabel(prefix, docId, [sec.number, role]),
337
+ })),
338
+ });
339
+ }
340
+ }
341
+
342
+ const coverage = coverageOf(defined, stories, corporate);
343
+
344
+ return {
345
+ document: {
346
+ id: docId,
347
+ profile,
348
+ mode: fm.mode || "full",
349
+ feature: fm.feature || null,
350
+ },
351
+ coverage,
352
+ prefsUsed: {
353
+ projectKey: prefs.projectKey ?? null,
354
+ epicIssueType: prefs.epicIssueType ?? "Epic",
355
+ storyIssueType: prefs.storyIssueType ?? "Story",
356
+ subtaskIssueType: prefs.subtaskIssueType ?? null,
357
+ subtaskRoles: prefs.subtaskRoles ?? [],
358
+ labelPrefix: prefix,
359
+ channelComponents: prefs.channelComponents ?? {},
360
+ channelTeams: prefs.channelTeams ?? {},
361
+ },
362
+ nodes: stories,
363
+ writeCount: stories.reduce((n, s) => n + 1 + s.subtasks.length, 0),
364
+ };
365
+ }
366
+
367
+ function main() {
368
+ if (!file) return die("usage: analysis-story-tree.mjs <analysis.md> [--json] [--prefs FILE]", 3);
369
+ if (!existsSync(file)) return die(`analysis-story-tree: no such file: ${file}`, 3);
370
+ const text = readFileSync(file, "utf8");
371
+
372
+ // The marker gate, before anything else and before any network call. A
373
+ // document with an open placeholder is not a plan, and turning it into a tree
374
+ // publishes the gap as work somebody is now assigned.
375
+ const open = openItems(text);
376
+ if (open.length) {
377
+ process.stderr.write(
378
+ `analysis-story-tree: the document is not issue-ready (${open.length} open item(s))\n`,
379
+ );
380
+ for (const m of open.slice(0, 5)) process.stderr.write(` ${m}\n`);
381
+ process.stderr.write(" run /multi-agent:analysis-resolve to close them first\n");
382
+ process.exitCode = 4;
383
+ return;
384
+ }
385
+
386
+ const prefs = readPrefs();
387
+ // A declared setting that changes nothing is worse than no setting: it reads
388
+ // as a control and is not one.
389
+ if (prefs.enabled === false) {
390
+ process.stderr.write(
391
+ "analysis-story-tree: prefs.global.issueTree.enabled is false on this machine\n",
392
+ );
393
+ process.exitCode = 2;
394
+ return;
395
+ }
396
+
397
+ const result = plan(text, prefs);
398
+ if (result.nodes.length === 0) {
399
+ process.stderr.write("analysis-story-tree: no stories could be derived from this document\n");
400
+ process.exitCode = 2;
401
+ return;
402
+ }
403
+
404
+ if (JSON_OUT) {
405
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
406
+ return;
407
+ }
408
+
409
+ const c = result.coverage;
410
+ process.stdout.write(
411
+ `analysis: ${result.document.feature || result.document.id} (${result.document.profile}, ${result.document.mode})\n`,
412
+ );
413
+ // The verdict gets its own line whatever it is. A reader scanning a preview
414
+ // sees "unverifiable" in the same place they would have seen "ok".
415
+ process.stdout.write(
416
+ `coverage: ${c.verdict}${c.reason ? ` - ${c.reason}` : ` (${c.atomsCovered}/${c.atomsDefined} atoms)`}\n`,
417
+ );
418
+ if (c.uncovered.length) process.stdout.write(` not in any story: ${c.uncovered.join(", ")}\n`);
419
+ if (c.invented.length) process.stdout.write(` cited but undefined: ${c.invented.join(", ")}\n`);
420
+ process.stdout.write(`\n${result.writeCount} issue(s) would be created:\n`);
421
+ for (const s of result.nodes) {
422
+ process.stdout.write(` ${result.prefsUsed.storyIssueType} ${s.title}\n`);
423
+ process.stdout.write(
424
+ ` sources: ${s.sourceIds.length ? s.sourceIds.join(", ") : "(none - derived from the section heading)"}\n`,
425
+ );
426
+ process.stdout.write(` label: ${s.label}\n`);
427
+ for (const t of s.subtasks) {
428
+ process.stdout.write(` subtask ${t.role} [${t.label}]\n`);
429
+ }
430
+ }
431
+ // Every field's provenance, so a wrong setting is visible here rather than in
432
+ // Jira after the writes have happened.
433
+ process.stdout.write("\nfrom prefs.global.issueTree:\n");
434
+ for (const [k, v] of Object.entries(result.prefsUsed)) {
435
+ const shown = typeof v === "object" ? JSON.stringify(v) : String(v);
436
+ process.stdout.write(` ${k.padEnd(20)} ${shown === "null" ? "(not set)" : shown}\n`);
437
+ }
438
+ }
439
+
440
+ const isDirectRun = process.argv[1] && process.argv[1].endsWith("analysis-story-tree.mjs");
441
+ if (isDirectRun) main();