@mmerterden/multi-agent-pipeline 23.7.0 → 24.0.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 (142) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/README.md +57 -24
  3. package/README.tr.md +41 -8
  4. package/SECURITY.md +3 -3
  5. package/docs/architecture.md +41 -4
  6. package/docs/ecosystem.md +15 -13
  7. package/docs/facts.json +5 -4
  8. package/docs/features.md +59 -15
  9. package/install/_codex-agents.mjs +13 -8
  10. package/install/_common.mjs +24 -0
  11. package/install/_dev-only-files.mjs +4 -0
  12. package/install/_mcp-register.mjs +6 -2
  13. package/install/_rewrite-tree.mjs +197 -0
  14. package/install/codex.mjs +96 -180
  15. package/install/copilot.mjs +24 -54
  16. package/install/index.mjs +29 -11
  17. package/install/templates/codex-instructions.md +21 -5
  18. package/install/templates/copilot-instructions.md +21 -14
  19. package/manifest.json +2082 -0
  20. package/package.json +6 -2
  21. package/pipeline/commands/multi-agent/SKILL.md +5 -4
  22. package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
  23. package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
  24. package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
  25. package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
  26. package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
  27. package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
  28. package/pipeline/contract/manifest.json +1 -1
  29. package/pipeline/contract/types/index.d.ts +1 -0
  30. package/pipeline/lib/_jira-auth.sh +50 -78
  31. package/pipeline/lib/_service-account.sh +191 -0
  32. package/pipeline/lib/credential-inventory.sh +49 -37
  33. package/pipeline/lib/credential-store.sh +48 -3
  34. package/pipeline/lib/fetch-confluence.sh +76 -92
  35. package/pipeline/lib/fetch-crashlytics.sh +30 -59
  36. package/pipeline/lib/fetch-figma-annotations.sh +9 -9
  37. package/pipeline/lib/fetch-fortify.sh +77 -81
  38. package/pipeline/lib/fetch-graylog.sh +38 -77
  39. package/pipeline/lib/figma-mcp-refresh.sh +23 -4
  40. package/pipeline/lib/figma-screenshot.sh +7 -8
  41. package/pipeline/lib/figma-token.sh +39 -46
  42. package/pipeline/lib/host.mjs +138 -0
  43. package/pipeline/lib/host.sh +48 -0
  44. package/pipeline/lib/issue-fetcher.sh +25 -41
  45. package/pipeline/lib/jira-publish.sh +23 -21
  46. package/pipeline/lib/local-model.mjs +93 -0
  47. package/pipeline/lib/md2confluence-v3.py +37 -30
  48. package/pipeline/lib/model-dispatch.sh +41 -4
  49. package/pipeline/lib/model-resolve.mjs +58 -0
  50. package/pipeline/lib/post-pr-review.sh +38 -53
  51. package/pipeline/lib/reviewer-families.mjs +70 -0
  52. package/pipeline/lib/service-account.mjs +2131 -0
  53. package/pipeline/lib/service-account.sh +35 -0
  54. package/pipeline/lib/usage-token.mjs +64 -24
  55. package/pipeline/lib/usage-vocab.mjs +1 -1
  56. package/pipeline/lib/user-facing.mjs +11 -3
  57. package/pipeline/lib/vercel-deploy.sh +17 -26
  58. package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
  59. package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
  60. package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
  61. package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
  62. package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
  63. package/pipeline/multi-agent-refs/channels/generator.md +10 -2
  64. package/pipeline/multi-agent-refs/channels/menu.md +3 -1
  65. package/pipeline/multi-agent-refs/channels/preview.md +3 -1
  66. package/pipeline/multi-agent-refs/channels/reference.md +16 -2
  67. package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
  68. package/pipeline/multi-agent-refs/cross-cli-contract.md +35 -27
  69. package/pipeline/multi-agent-refs/features/doctor.md +37 -11
  70. package/pipeline/multi-agent-refs/features/free-models.md +3 -3
  71. package/pipeline/multi-agent-refs/features/local-model.md +87 -0
  72. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
  73. package/pipeline/multi-agent-refs/features/product-context.md +6 -5
  74. package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
  75. package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
  76. package/pipeline/multi-agent-refs/help/en.md +28 -1
  77. package/pipeline/multi-agent-refs/help/tr.md +28 -1
  78. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +2 -1
  79. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
  80. package/pipeline/multi-agent-refs/phases/modes.md +20 -1
  81. package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
  82. package/pipeline/multi-agent-refs/phases.md +4 -3
  83. package/pipeline/multi-agent-refs/review/panel.md +30 -18
  84. package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
  85. package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
  86. package/pipeline/multi-agent-refs/sync/overview.md +11 -5
  87. package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
  88. package/pipeline/office/index.html +3 -3
  89. package/pipeline/schemas/autopilot-config.schema.json +29 -4
  90. package/pipeline/schemas/hosts.json +512 -0
  91. package/pipeline/schemas/hosts.schema.json +310 -0
  92. package/pipeline/schemas/launch.json +22 -2
  93. package/pipeline/schemas/launch.schema.json +2 -1
  94. package/pipeline/schemas/phases.json +19 -1
  95. package/pipeline/schemas/phases.schema.json +8 -0
  96. package/pipeline/schemas/prefs.schema.json +331 -4
  97. package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
  98. package/pipeline/scripts/_autopilot-config.mjs +67 -4
  99. package/pipeline/scripts/_autopilot-item.mjs +67 -0
  100. package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
  101. package/pipeline/scripts/_cost.mjs +75 -3
  102. package/pipeline/scripts/analysis-sources.mjs +22 -5
  103. package/pipeline/scripts/analysis-unattended.mjs +360 -0
  104. package/pipeline/scripts/anonymize-findings.mjs +3 -7
  105. package/pipeline/scripts/autopilot-arming.mjs +19 -10
  106. package/pipeline/scripts/autopilot-intake.mjs +124 -27
  107. package/pipeline/scripts/autopilot-menubar.swift +7 -0
  108. package/pipeline/scripts/autopilot-runner.mjs +77 -48
  109. package/pipeline/scripts/autopilot-status.sh +32 -9
  110. package/pipeline/scripts/bulk-read.sh +37 -5
  111. package/pipeline/scripts/confluence-readback.mjs +15 -7
  112. package/pipeline/scripts/cost-table.json +65 -25
  113. package/pipeline/scripts/doctor.mjs +119 -32
  114. package/pipeline/scripts/entry-mode.mjs +101 -0
  115. package/pipeline/scripts/estimate.mjs +30 -16
  116. package/pipeline/scripts/feedback-send.mjs +11 -8
  117. package/pipeline/scripts/gen-facts.mjs +7 -9
  118. package/pipeline/scripts/jira-attach.sh +23 -28
  119. package/pipeline/scripts/jira-search.sh +5 -21
  120. package/pipeline/scripts/launch-request.mjs +15 -9
  121. package/pipeline/scripts/migrate-prefs.mjs +56 -0
  122. package/pipeline/scripts/phase-tracker.sh +146 -38
  123. package/pipeline/scripts/priority-review.mjs +14 -7
  124. package/pipeline/scripts/product-context.mjs +26 -7
  125. package/pipeline/scripts/prune-logs.sh +4 -2
  126. package/pipeline/scripts/report-file.mjs +285 -0
  127. package/pipeline/scripts/rework-escalation.mjs +19 -4
  128. package/pipeline/scripts/service-read.mjs +19 -17
  129. package/pipeline/scripts/skill-siblings.mjs +17 -1
  130. package/pipeline/scripts/status-overview.mjs +20 -10
  131. package/pipeline/scripts/uninstall.mjs +145 -57
  132. package/pipeline/scripts/usage-register.mjs +34 -11
  133. package/pipeline/scripts/usage-report.mjs +31 -26
  134. package/pipeline/scripts/validate-triage.mjs +11 -1
  135. package/pipeline/scripts/work-items.mjs +25 -28
  136. package/pipeline/scripts/write-store-config.mjs +37 -11
  137. package/pipeline/skills/.skill-manifest.json +4 -4
  138. package/pipeline/skills/.skills-index.json +1 -1
  139. package/pipeline/skills/shared/core/multi-agent/SKILL.md +11 -3
  140. package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
  141. package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
  142. package/pipeline/lib/credential-resolve.mjs +0 -75
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmerterden/multi-agent-pipeline",
3
- "version": "23.7.0",
3
+ "version": "24.0.0",
4
4
  "description": "6-phase AI development pipeline with full orchestration on Claude Code, Copilot CLI and Codex CLI. Analysis, planning, TDD, CLI-aware parallel review with consensus surfacing + Fable triage, default-FAIL evidence gates, secret + intent guards, per-phase cost ledger, persistent learnings memory, wiki generation, commit automation. Token-preserving uninstall.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "scripts": {
22
22
  "start": "node index.js",
23
- "test": "npm run format:check && npm run lint && node --test test/*.test.mjs && node --test test/*.serial.mjs && node pipeline/scripts/run-smokes.mjs && node pipeline/scripts/lint-skills.mjs && node pipeline/scripts/gen-skills-index.mjs --check && node pipeline/scripts/build-skills-index.mjs --check && node pipeline/scripts/gen-free-llm-skill.mjs --check && node pipeline/scripts/gen-secret-patterns.mjs --check && node pipeline/scripts/gen-free-hosts.mjs --check && node pipeline/scripts/gen-usage-names.mjs --check && node pipeline/scripts/sync-skill-copies.mjs --check && node pipeline/scripts/gen-toolkit-path-params.mjs --check && node pipeline/scripts/gen-fact-marks.mjs --check && node pipeline/scripts/gen-office-command-matrix.mjs --check && node pipeline/scripts/gen-access-check.mjs --check && node pipeline/scripts/lint-unused-exports.mjs --baseline pipeline/scripts/fixtures/unused-exports-baseline.txt && node pipeline/scripts/lint-personas.mjs && node pipeline/scripts/lint-mcp-refs.mjs && node pipeline/scripts/eval-triage.mjs && node pipeline/scripts/eval-golden-tasks.mjs && node pipeline/scripts/eval-intent.mjs && node pipeline/scripts/eval-recall.mjs && node pipeline/scripts/eval-call-edges.mjs && node pipeline/scripts/eval-persona-walk.mjs && node pipeline/scripts/eval-guard-robustness.mjs --fast && node pipeline/scripts/validate-schemas.mjs && node pipeline/scripts/validate-prefs.mjs && node pipeline/scripts/scorecard.mjs",
23
+ "test": "npm run format:check && npm run lint && node --test test/*.test.mjs && node --test test/*.serial.mjs && node pipeline/scripts/run-smokes.mjs && node pipeline/scripts/lint-skills.mjs && node pipeline/scripts/gen-skills-index.mjs --check && node pipeline/scripts/build-skills-index.mjs --check && node pipeline/scripts/gen-free-llm-skill.mjs --check && node pipeline/scripts/gen-secret-patterns.mjs --check && node pipeline/scripts/gen-free-hosts.mjs --check && node pipeline/scripts/gen-usage-names.mjs --check && node pipeline/scripts/sync-skill-copies.mjs --check && node pipeline/scripts/gen-toolkit-path-params.mjs --check && node pipeline/scripts/gen-fact-marks.mjs --check && node pipeline/scripts/gen-office-command-matrix.mjs --check && node pipeline/scripts/gen-host-tables.mjs --check && node pipeline/scripts/gen-access-check.mjs --check && node pipeline/scripts/lint-host-literals.mjs --baseline pipeline/scripts/fixtures/host-literals-baseline.txt && node pipeline/scripts/lint-credential-reads.mjs --baseline pipeline/scripts/fixtures/credential-reads-baseline.txt && node pipeline/scripts/lint-unused-exports.mjs --baseline pipeline/scripts/fixtures/unused-exports-baseline.txt && node pipeline/scripts/lint-temp-guards.mjs && node pipeline/scripts/lint-personas.mjs && node pipeline/scripts/lint-mcp-refs.mjs && node pipeline/scripts/eval-triage.mjs && node pipeline/scripts/eval-golden-tasks.mjs && node pipeline/scripts/eval-intent.mjs && node pipeline/scripts/eval-recall.mjs && node pipeline/scripts/eval-call-edges.mjs && node pipeline/scripts/eval-persona-walk.mjs && node pipeline/scripts/eval-guard-robustness.mjs --fast && node pipeline/scripts/validate-schemas.mjs && node pipeline/scripts/validate-prefs.mjs && node pipeline/scripts/scorecard.mjs",
24
24
  "test:unit": "node --test test/*.test.mjs && node --test test/*.serial.mjs",
25
25
  "test:smoke": "node pipeline/scripts/run-smokes.mjs",
26
26
  "lint:skills": "node pipeline/scripts/lint-skills.mjs",
@@ -112,6 +112,7 @@
112
112
  "!pipeline/scripts/gen-fact-marks.mjs",
113
113
  "!pipeline/scripts/gen-access-check.mjs",
114
114
  "!pipeline/scripts/gen-office-command-matrix.mjs",
115
+ "!pipeline/scripts/gen-host-tables.mjs",
115
116
  "!pipeline/scripts/gen-ref-toc.mjs",
116
117
  "!pipeline/scripts/ref-filler-audit.mjs",
117
118
  "!pipeline/scripts/make-manifest.mjs",
@@ -124,6 +125,9 @@
124
125
  "!pipeline/scripts/lint-mcp-refs.mjs",
125
126
  "!pipeline/scripts/lint-phase-labels.mjs",
126
127
  "!pipeline/scripts/lint-unused-exports.mjs",
128
+ "!pipeline/scripts/lint-host-literals.mjs",
129
+ "!pipeline/scripts/lint-temp-guards.mjs",
130
+ "!pipeline/scripts/lint-credential-reads.mjs",
127
131
  "!pipeline/scripts/check-md-links.mjs",
128
132
  "!pipeline/scripts/validate-schemas.mjs",
129
133
  "!pipeline/scripts/sync-parity-check.sh",
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  description: "Task orchestrator - full pipeline via Jira ID + branch or GitHub Issue URL: analysis, plan, TDD development, parallel review + Fable triage (3 reviewers per host: Fable + Opus + Sonnet on Claude Code, GPT-5.4 + Opus + Sonnet on Copilot CLI), commit, log. Use when given a Jira ID, a GitHub issue or a free-text task and the whole pipeline should run."
3
3
  description-tr: "Görev orkestratörü - Jira ID + branch veya GitHub Issue URL ile tam pipeline: analiz, plan, TDD geliştirme, paralel review + Fable triyajı (CLI'ya göre: Claude Code'da 3, Copilot CLI'da 3 model), commit, log"
4
- argument-hint: "[JIRA-KEY | issue URL | repo#N | \"task\"] [autopilot [--loop N]] [--review-rounds N] - or a sub-command: status, log #N, resume #N, kill #N"
4
+ argument-hint: '[JIRA-KEY | issue URL | repo#N | "task"] [autopilot [--loop N]] [--review-rounds N] - or a sub-command: status, log #N, resume #N, kill #N'
5
5
  allowed-tools: Agent, Bash, Read, Write, Edit, Glob, Grep, TaskCreate, TaskUpdate, TaskList, TaskGet, AskUserQuestion, WebFetch, WebSearch, NotebookEdit, Skill
6
6
  ---
7
7
 
@@ -38,7 +38,7 @@ ACCESS_LINE=$(node "$HOME/.claude/scripts/usage-access.mjs"); ACCESS_RC=$?
38
38
  Read `$HOME/.claude/multi-agent-refs/orchestrator/dispatcher.md` "Routing and loading tables" whenever a row below is not enough: every row in full, the loading table, guide selection and the lib scripts. After routing, `Read` only the file the action needs.
39
39
 
40
40
  | Input | Read / do |
41
- |---|---|
41
+ | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42
42
  | Task (Jira id / URL, GitHub `#N` / URL, `repo#N`, free text) | `$HOME/.claude/multi-agent-refs/phases.md` + `_account-picker.md` + `_repo-picker.md` + `_dev-context.md` |
43
43
  | `jira` / `issue` | `$HOME/.claude/commands/multi-agent/jira/SKILL.md` / `issue/SKILL.md` (4-step pickers) |
44
44
  | `status`, `log [id]`, `resume [id]` | Inline; status scans `$HOME/.claude/logs/multi-agent/` |
@@ -53,7 +53,8 @@ Read `$HOME/.claude/multi-agent-refs/orchestrator/dispatcher.md` "Routing and lo
53
53
  | Any other subcommand (`setup`, `channels`, `analysis`, `design-check`, `store-ready`, ...) | `$HOME/.claude/commands/multi-agent/<name>/SKILL.md`, except the user-only commands `clean-disk`, `forget`, `garbage-collect`, `kill`, `pair`, `prune-logs`, `prune-prompts`, `purge`, `review-priority`, `routines-delete`, `uninstall` (each sets `disable-model-invocation: true`): never read their files; name the command for the user to type (`/multi-agent:<name>` on Claude Code, the `/multi-agent-<name>` prompt on Codex CLI) and stop |
54
54
  | `--review-rounds N` | Modifier: this run allows N review rework rounds (1 to 3, default 2), overriding the repo and global setting for this run only. `node "$HOME/.claude/scripts/review-rounds.mjs" parse "<modifiers>"` returns N (exit 2 on a value outside 1 to 3: say so and stop before Phase 0). Phase 0 stores it with `review-rounds.mjs record --state "$STATE_FILE" --rounds N` (`features/review-rounds.md`). The standing setting is `/multi-agent:review-rounds` |
55
55
  | `autopilot` | Modifier: skip confirmations, auto commit/PR (`phases/modes.md`). With `--loop N`: Loop mode below |
56
- | No args / `help` | `$HOME/.claude/commands/multi-agent/help/SKILL.md` |
56
+ | `help` | `$HOME/.claude/commands/multi-agent/help/SKILL.md` |
57
+ | No args | `$HOME/.claude/multi-agent-refs/_entry-picker.md`: ask which kind of task this is, then route the answer through this table. Never reached by an unattended run |
57
58
 
58
59
  `jira`, `issue` and the direct-ID path all end in the Interactive Launcher, then Phase 0; account is always asked, the maturity check halts on a blocker, and the dev-context step always runs. Read `$HOME/.claude/multi-agent-refs/orchestrator/dispatcher.md` before routing any of them: the per-command steps, the Jira empty-description question and the launcher prompts.
59
60
 
@@ -74,7 +75,7 @@ Each iteration is a full unattended autopilot run: without `install --unattended
74
75
 
75
76
  ## Agents and model routing
76
77
 
77
- Agent definitions: `dispatcher.md` "Agent definitions". Before each Agent dispatch, read `preferredModel` from the persona file and export `CLAUDE_CODE_SUBAGENT_MODEL` (Claude Code) / pass `--model` (Copilot CLI). Precedence: `PHASE_MODEL_OVERRIDE` > a matching `prefs.global.modelRouting` rule (only when the phase named no model, Anthropic ladder only) > persona `preferredModel` > `fable` (fallback: `$HOME/.claude/multi-agent-refs/features/model-fallback.md`). Simple text tasks ask `model-dispatch.sh delegate --default host` first: `$HOME/.claude/multi-agent-refs/features/free-models.md`.
78
+ Agent definitions: `dispatcher.md` "Agent definitions". Before each Agent dispatch, read `preferredModel` from the persona file and hand the resolved rung to the child the way THIS host does it (`features/model-fallback.md` "Routing at dispatch" has the table, generated from the host registry). Precedence: `PHASE_MODEL_OVERRIDE` > a matching `prefs.global.modelRouting` rule (only when the phase named no model, and only for a rung this host offers) > persona `preferredModel` > `fable` (fallback: `$HOME/.claude/multi-agent-refs/features/model-fallback.md`). Simple text tasks ask `model-dispatch.sh delegate --default host` first: `$HOME/.claude/multi-agent-refs/features/free-models.md`.
78
79
 
79
80
  ## Rules
80
81
 
@@ -37,6 +37,10 @@ Never surface them as questions, re-derive them or invite an override mid-run. T
37
37
 
38
38
  `$ARGUMENTS`: optional analysis name, else asked at Phase 0. `check|refresh <doc.md>`: follow `$HOME/.claude/multi-agent-refs/features/analysis-sources.md` instead. `conform <doc.md>`: follow `$HOME/.claude/multi-agent-refs/features/analysis-outline.md` instead.
39
39
 
40
+ `<tracker-ref> autopilot`: the unattended form continuous mode launches for an item carrying the repo's analysis label (`analysisGithubLabel` / `analysisJiraLabel`). The reference is the item itself - a Jira key or `owner/repo#N` - and the side-effect contract above is unchanged: the run stops at the document, which is what the queue records as `doc-delivered`. It is its own declared mode (`phases.json` `modes.analysis-autopilot`): record it as `mode: "analysis"` with `autopilot: true`, ask nothing, and answer every Phase 0 question from evidence or park on it - Phase 0 mounts the derivation contract, and nothing below is taken as a default because nobody answered.
41
+
42
+ With nothing after the command, read `$HOME/.claude/multi-agent-refs/_entry-picker.md` first: a bare invocation asks which of the four it is, rather than assuming a new analysis and asking only for a name. An unattended run with no argument refuses there and never reaches a question.
43
+
40
44
  ## Steps
41
45
 
42
46
  ### Phase 0 - Intake
@@ -59,7 +59,7 @@ is no `add-repo` / `remove-repo` command.
59
59
  Unavailable repos are printed above the question as a plain list with their
60
60
  reason, not offered as options.
61
61
 
62
- ### 4. Sources and label, per selected repo
62
+ ### 4. Sources and labels, per selected repo
63
63
 
64
64
  One `AskUserQuestion` per newly added repo (never re-ask a configured one):
65
65
 
@@ -71,6 +71,31 @@ query per source is in `details.md`, "Source queries". When Jira is selected,
71
71
  state the two Jira caveats from that section (global label namespace, Labels
72
72
  field on the edit screen).
73
73
 
74
+ Then one more question per repo, for the **second queue**:
75
+
76
+ ```
77
+ header: "Analysis"
78
+ question: <localized: "Should this repo also pick up analysis work? A labelled item then runs the analysis command and stops at a written document instead of a pull request.">
79
+ options:
80
+ - label: "Development only" # pre-selected
81
+ description: <localized: "The repo stays on one queue. Nothing changes.">
82
+ - label: "Analysis too, agent-analysis"
83
+ description: <localized: "Items carrying agent-analysis are analysed; the label must differ from the development one.">
84
+ - label: "Analysis too, my own label"
85
+ description: <localized: "Same, under a label you name.">
86
+ ```
87
+
88
+ Branch on the option selected, never on its text. **Development only** writes
89
+ neither `analysisQueue` nor an analysis label, and that is what leaves the repo
90
+ out: an analysis label nobody asked for would enrol a repo in a second queue
91
+ that spends runs on documents. The other two write `analysisQueue: true` plus
92
+ `analysisGithubLabel` / `analysisJiraLabel` for the sources selected above. The
93
+ analysis label must differ from the development one on the same tracker - a
94
+ config where they are equal is refused when the queue next loads, so refuse it
95
+ here, say which two fields collided, and re-ask.
96
+
97
+ Reasoning and the analysis query: `details.md`, "Source queries".
98
+
74
99
  Run the query before saving it, and show the count:
75
100
 
76
101
  ```bash
@@ -104,7 +129,9 @@ Validate against `schemas/autopilot-config.schema.json`, then write
104
129
  `slots: 1`, `scanIntervalSeconds: 120`, `maxAttempts: 2`,
105
130
  `costCeilingUsd: 25`. `awake` carries the answer from the previous step. Never
106
131
  write `askOnLowMaturity`, `reportStatus`, `sendItemKeys` or `depthRouter`; drop
107
- them when rewriting an older file.
132
+ them when rewriting an older file. `analysisQueue` and the analysis labels are
133
+ written only for a repo whose step 4 answer asked for them, and removed from a
134
+ repo whose answer no longer does.
108
135
 
109
136
  ### 7. Build the menu bar indicator (best effort)
110
137
 
@@ -160,7 +187,8 @@ saves the selection and installs neither.
160
187
 
161
188
  ### 9. Report what is now true
162
189
 
163
- Say all five: which repos and which labels; that it survives a restart with no
190
+ Say all five: which repos and which labels, naming any repo that is on the
191
+ analysis queue as well and what that queue delivers (a document, not a PR); that it survives a restart with no
164
192
  command to run (launchd loads at **login**, not boot); that the machine is kept awake while the mode is on and whether the display is kept on; the slot count
165
193
  and the ceiling this machine would allow (`ma_ap_slot_ceiling`); and that
166
194
  `/multi-agent:autopilot-off` is the only way to stop it.
@@ -30,7 +30,8 @@ you spells it.
30
30
  |---|---|
31
31
  | `OFF` with repos selected | the selection is kept, launchd holds no job. `autopilot-on` starts it again without re-asking |
32
32
  | `not set up` | never configured on this machine; nothing has been written |
33
- | `Running` | in flight now. Phase and elapsed come from the run's own state, not from a guess |
33
+ | `Running` | in flight now. Phase and elapsed come from the run's own state, not from a guess; an analysis item says so and shows its own step names (Intake, Evidence, Synthesis, ...) |
34
+ | `Queued for development` / `Queued for analysis` | the two queues, listed apart because they deliver different things: a pull request, or a written document with no branch and no PR. A repo is only in the second one when it was enrolled (`/multi-agent:autopilot-on`, step 4); no analysis heading means no repo asked for it |
34
35
  | `Waiting for an answer` | the run is parked on a question and never re-runs on its own. Answer it with `resume <id> --answer <option>` or from a client; the questions are posted on the item only when `autopilotCommentsOnIssue` is on (default off) |
35
36
  | `the config is on but launchd holds no job` | the failure a `resume` command would have hidden: an OS update dropped the plist, or it was booted out. Re-run `autopilot-on` |
36
37
 
@@ -44,6 +45,8 @@ not a fault.
44
45
  (`features/autopilot-operations.md`): `inhibitorHeld` (a sleep inhibitor is held
45
46
  for a run in flight), `lastGcReport` and `lastDigest` (paths of the newest daily
46
47
  cleanup report and digest in `~/.claude/autopilot/`, empty when there is none),
48
+ `queuedDevelopment` and `queuedAnalysis` (the same queue split by kind, so a
49
+ client renders the two without re-deriving the rule),
47
50
  `maxParallelAgents` (the configured cap, `null` when unlimited), and `awake`,
48
51
  `{held, display}`: whether the awake agent that keeps the Mac awake for as long
49
52
  as the mode is on is running, and whether it keeps the display on too. On with
@@ -86,6 +89,7 @@ string per row:
86
89
 
87
90
  ```
88
91
  PROJ-1234 · Phase 2/5 Dev · ios
92
+ PROJ-1240 · Phase 2/5 Synthesis · ios · analysis
89
93
  PROJ-1199 · waiting for an answer
90
94
  ```
91
95
 
@@ -1,8 +1,8 @@
1
1
  ---
2
- description: "Multi-channel reporter - Jira/Confluence/Wiki/PR description/Board status. Multi-select channels + content, humanizer pass, reviewer-preserving Bitbucket PR PUT, GitHub Projects v2 board status move. Use to post or redo a run's report; Phase 5 delegates here, or invoke by Jira ID / PR URL / branch."
3
- description-tr: "Çok kanallı raporlayıcı - Jira/Confluence/Wiki/PR açıklaması/Board durumu. Çoklu kanal + içerik seçimi, humanizer geçişi, reviewer'ı koruyan Bitbucket PR PUT, GitHub Projects v2 board durum taşıma. Faz 5 bu skill'e delege eder; Jira ID / PR URL / branch ile sonradan da çağrılabilir."
4
- argument-hint: '[Jira-id | PR-url | #N | Jira-url] [--channels pr,jira,confluence,wiki,board] [--content normal,technical,test,auto-diff,note,test-run] [--flow-run <runId>] [--message "..."] [--message-file path] [--board-status <key>] [--dry-run] [--append] [--ready]'
5
- parameters: [{"name":"target","kind":"text"},{"name":"--channels","kind":"enum","repeat":true,"enum":["pr","jira","confluence","wiki","board"]},{"name":"--content","kind":"enum","repeat":true,"enum":["normal","technical","test","auto-diff","note","test-run"]},{"name":"--flow-run","kind":"text"},{"name":"--message","kind":"text"},{"name":"--message-file","kind":"path"},{"name":"--board-status","kind":"text"},{"name":"--dry-run","kind":"flag"},{"name":"--append","kind":"flag"},{"name":"--ready","kind":"flag"}]
2
+ description: "Multi-channel reporter - Jira/Confluence/Wiki/PR description/Board status. Multi-select channels + content, humanizer pass, reviewer-preserving Bitbucket PR PUT, GitHub Projects v2 board status move. Also writes the run's report to a local file on every run, whatever the channels did. Use to post or redo a run's report; Phase 5 delegates here, or invoke by Jira ID / PR URL / branch."
3
+ description-tr: "Çok kanallı raporlayıcı - Jira/Confluence/Wiki/PR açıklaması/Board durumu. Çoklu kanal + içerik seçimi, humanizer geçişi, reviewer'ı koruyan Bitbucket PR PUT, GitHub Projects v2 board durum taşıma. Her koşuda, kanallardan bağımsız olarak, koşunun raporunu yerel bir dosyaya da yazar. Faz 5 bu skill'e delege eder; Jira ID / PR URL / branch ile sonradan da çağrılabilir."
4
+ argument-hint: '[Jira-id | PR-url | #N | Jira-url] [--channels pr,jira,confluence,wiki,board] [--content normal,technical,test,auto-diff,note,test-run] [--flow-run <runId>] [--message "..."] [--message-file path] [--board-status <key>] [--dry-run] [--append] [--ready] [--file-only]'
5
+ parameters: [{"name":"target","kind":"text"},{"name":"--channels","kind":"enum","repeat":true,"enum":["pr","jira","confluence","wiki","board"]},{"name":"--content","kind":"enum","repeat":true,"enum":["normal","technical","test","auto-diff","note","test-run"]},{"name":"--flow-run","kind":"text"},{"name":"--message","kind":"text"},{"name":"--message-file","kind":"path"},{"name":"--board-status","kind":"text"},{"name":"--dry-run","kind":"flag"},{"name":"--append","kind":"flag"},{"name":"--ready","kind":"flag"},{"name":"--file-only","kind":"flag"}]
6
6
  gui: form
7
7
  destructive: false
8
8
  confirm: none
@@ -21,9 +21,11 @@ ACCESS_LINE=$(node "$HOME/.claude/scripts/usage-access.mjs"); ACCESS_RC=$?
21
21
 
22
22
  Single entry point for posting a task report to Jira, Confluence, Wiki (component-only), the PR description and Board status (GitHub Projects v2). Phase 5 delegates here; users also invoke it post-hoc by Jira ID / PR URL / branch. Claude Code: `/multi-agent:channels <target>`; Copilot CLI: `multi-agent-channels <target>`.
23
23
 
24
+ Every run that composes a body also writes it to `task-report.md` beside the run's `agent-log.md`. That file is not a channel and has no setting: it is what a machine with no tracker, an unattended run and a cancelled menu are left with. Contract: `$HOME/.claude/multi-agent-refs/channels/report-file.md`.
25
+
24
26
  ## Gotchas
25
27
 
26
- - Nothing is posted before the Step 6 approval gate resolves, in every interactive mode. Under `MULTI_AGENT_UNATTENDED=1` nothing is posted at all.
28
+ - Nothing is posted before the Step 6 approval gate resolves, in every interactive mode. Under `MULTI_AGENT_UNATTENDED=1` nothing is posted at all. The report file is still written in both cases; it is not a post.
27
29
  - Jira renders `:)` `(x)` `(!)` as emoticons, so a Swift selector like `login(source:input:)` breaks. Post through `jira-publish.sh`, which escapes the body; never assemble the request by hand.
28
30
  - A Bitbucket PR update must carry the reviewer list back, or the PUT removes every reviewer.
29
31
  - With several repos, the PR description goes to every PR but Jira and Confluence get one post each.
@@ -44,9 +46,11 @@ Pipeline log, PR diff, or a manual message, best first. Read `$HOME/.claude/mult
44
46
 
45
47
  Step 3a prints the Work Summary first (summary-first flow) when `agent-state.json` exists, and auto-ticks that content row; an explicit pref wins. Step 3b: **Channels** (PR description, Jira comment, Confluence page, Wiki, Board) and **Content**; an unavailable option is greyed with a reason, never hidden. Selections pre-tick from and save to `prefs.global.reportChannels` / `prefs.global.reportContent`. Autopilot still pauses here; unattended posts nothing (`$HOME/.claude/multi-agent-refs/features/unattended-security.md`).
46
48
 
49
+ Above the picker, print one line: the report file is always written, and where. Zero channels ticked is a valid selection and means file-only. When no channel is selectable at all, print the greyed rows with their reasons as text and ask only Content.
50
+
47
51
  ### Step 4 - Mode short-circuit
48
52
 
49
- `--channels` + `--content` flags, autopilot (prefs), and `--dry-run` skip or shortcut the menu (table in `reference.md`).
53
+ `--channels` + `--content` flags, autopilot (prefs), `--dry-run` and `--file-only` skip or shortcut the menu (table in `reference.md`).
50
54
 
51
55
  ### Step 5 - Generator
52
56
 
@@ -55,6 +59,7 @@ One section body per selected content source, each run through the `humanizer` s
55
59
  - **The Jira body is not the PR body.** Jira gets only `Geliştirme Özeti`, `Test Senaryoları`, `Etki Analizi` and `Bağlantılar` (plus the test run when selected); technical sections are dropped from it, never converted, and go to the PR and Confluence.
56
60
  - PR section order is fixed by `channels/pr.md`; content options are sources, not the shape.
57
61
  - Target length: under 80 lines; auto-diff capped at 5 lines per section.
62
+ - **After the humanizer, write the report file** (`report-file.mjs write`), before Step 6. The file always carries one PR-shaped body: the PR body when `pr` is selected, otherwise a `Report` body composed in the `channels/pr.md` order with the PR tone.
58
63
 
59
64
  ### Step 6 - Body preview + approval gate
60
65
 
@@ -64,9 +69,11 @@ One `AskUserQuestion` (`picker-contract.md`; `question` / `label` / `description
64
69
 
65
70
  **Hard rule:** what is posted is byte-identical to the approved preview (markup conversion excepted). Any regeneration after approval invalidates the approval and re-runs the gate.
66
71
 
72
+ The report file is not a post and is outside this gate: `Edit` rewrites it, `Cancel` leaves it in place.
73
+
67
74
  ### Step 7 - Channel dispatch
68
75
 
69
- Adapters run in parallel; one failure does not block the others. Dispatch NEVER starts before the Step 6 gate resolves, except autopilot and `--dry-run`. Multi-repo: `channels/multi-repo.md`.
76
+ Adapters run in parallel; one failure does not block the others. The report file is not an adapter, and no adapter failure affects it. Dispatch NEVER starts before the Step 6 gate resolves, except autopilot and `--dry-run`. Multi-repo: `channels/multi-repo.md`.
70
77
 
71
78
  - **PR description**: GitHub `gh pr edit --body-file`; Bitbucket a reviewer-preserving `PUT` that re-sends `reviewers`, `fromRef`, `toRef`, `draft`, `version`. Replace by default, `--append` opt-in. Contract: `$HOME/.claude/multi-agent-refs/channels/pr.md`.
72
79
  - **Jira comment**: PR URL on line 1, then the four sections. Post with `bash "$HOME/.claude/lib/jira-publish.sh" --issue "$JIRA_ID" --body-file "$F" --target comment` (escapes the body, token never on argv). Contract: `$HOME/.claude/multi-agent-refs/channels/jira.md`. Issue family (`state.jiraFamily`): `jira-family-write.sh plan`, preview, `apply`, per `$HOME/.claude/multi-agent-refs/features/jira-family.md`.
@@ -76,7 +83,7 @@ Adapters run in parallel; one failure does not block the others. Dispatch NEVER
76
83
 
77
84
  ### Step 8 - Summary
78
85
 
79
- One line per channel (status, metric, URL), format in `reference.md`; persist the selections to prefs.
86
+ One line per channel (status, metric, URL), format in `reference.md`; persist the selections to prefs. Re-run `report-file.mjs write` with `--delivery` to stamp the outcomes, then print the `Report file` row last.
80
87
 
81
88
  ## Required rules
82
89
 
@@ -88,4 +95,5 @@ One line per channel (status, metric, URL), format in `reference.md`; persist th
88
95
  - **Every body item cites a symbol / file / line** from the diff or log.
89
96
  - **Adapter failures are non-blocking**.
90
97
  - **Approval before post**: autopilot and `--dry-run` are the only bypasses.
98
+ - **Report file every run**: written whenever a body was composed, never gated, never posted; `--dry-run` is the only case that composes and does not write.
91
99
  - **Phase 5 autopilot** always pauses at the menu; a 30-min timeout ends the session cleanly, resumable via `/multi-agent:resume`.
@@ -27,6 +27,8 @@ Show the task's detailed agent-log.md report.
27
27
 
28
28
  3. **Read agent-log.md** - display the file.
29
29
 
30
+ 3b. **Name the report file when it is there.** `task-report.md` in the same directory is the run's report as Phase 5 composed it, written whether or not a channel took it. Print its path in one line; do not inline it, since the log is already long and the two say different things.
31
+
30
32
  4. **Cost + durations come from the tracker, not only the log.** The tracker contract promises token/duration data "surfaced in `:log` reports", and agent-log.md only carries it when Phase 5 appended the Cost Breakdown. When that section is absent, render it live:
31
33
  ```bash
32
34
  bash $HOME/.claude/scripts/render-agent-log-cost.sh "<task-id>" 2>/dev/null
@@ -37,7 +37,7 @@ Derived, not listed: `pluginsForStacks()` in `scripts/_stack-routing.mjs` owns i
37
37
  - **legacy-key cleanup**: delete any `ai-*-engineering-toolkit@multi-agent-plugins` keys - those plugin names were retired by the `ai-<stack>-toolkit` rename and a stale `true` there enables a plugin that no longer exists in the marketplace
38
38
  - **Apple's Xcode skills**: when `~/.claude/xcode-apple-marketplace` exists, set `xcode-integration@xcode-apple` to `true` if `ios` is in the selection and `false` otherwise. Without that directory leave the key absent
39
39
  4. **Unknown arg** → show the known stacks; do not guess.
40
- 5. **Copilot/Codex refresh offer.** Their local skill copies are filtered to the enabled stacks at install time, so after a change ask (single `AskUserQuestion`, not silent): "Refresh Copilot/Codex local copies now?" - Yes runs `node <pipelineRepo>/install.js --copilot --codex`, No leaves them stale with a one-line warning naming the command to run later. Skip this question entirely when neither `~/.copilot` nor `~/.codex` exists.
40
+ 5. **Engine-host refresh offer.** Every host that keeps its own skill copies filters them to the enabled stacks at install time, so after a change ask (single `AskUserQuestion`, not silent): "Refresh the other hosts' local copies now?" - Yes runs `node <pipelineRepo>/install.js` with one flag per host tree that already exists (`--copilot` for `~/.copilot`, `--codex` for `~/.codex`, `--local` for `~/.codex-local`), No leaves them stale with a one-line warning naming the command to run later. A flag for a tree that is not there would install a host the user never asked for, so the flags follow the trees rather than the registry. Skip this question entirely when none of those trees exists.
41
41
 
42
42
  ## Implementation
43
43
 
@@ -180,7 +180,7 @@
180
180
  "query": ["redact"],
181
181
  "cli": ["node", "scripts/launch-request.mjs", "spec"],
182
182
  "schema": "launch.schema.json",
183
- "version": "1.2.0",
183
+ "version": "1.3.0",
184
184
  "remote": "read",
185
185
  "risk": "read"
186
186
  },
@@ -308,6 +308,7 @@ export interface LaunchHost {
308
308
  bin?: string;
309
309
  cwd?: string;
310
310
  note: string;
311
+ /** The launch shape per declared mode of schemas/phases.json that a client may start without a terminal conversation. autopilot runs the pipeline and stops at a pull request; analysis-autopilot runs the analysis command and stops at a document. */
311
312
  modes?: {
312
313
  [key: string]: LaunchShape;
313
314
  };
@@ -8,106 +8,78 @@
8
8
  # and a third writer was about to make it three. Duplicated auth does not stay
9
9
  # duplicated: it drifts, and the copy that drifts is the one nobody is looking at.
10
10
  #
11
- # Today only `analysis-jira-write.sh` sources this. The two older callers still
12
- # carry their own resolution - `issue-fetcher.sh` resolves per-account token keys
13
- # this helper does not model yet - so this is where new callers go, not a
14
- # consolidation that has already happened.
15
11
  # Worse, the part most worth getting right is the part most easily retyped badly -
16
- # the token goes to curl through a `-K` config on process substitution so it never
17
- # reaches argv, a log, or `ps`. A second-hand copy of that idiom is a leak waiting
18
- # for the first person who simplifies it.
12
+ # the token goes to curl through a config file so it never reaches argv, a log,
13
+ # or `ps`. A second-hand copy of that idiom is a leak waiting for the first
14
+ # person who simplifies it.
15
+ #
16
+ # Host and token are now one answer rather than two lookups: `service-account.sh`
17
+ # decides which account covers the host being called and hands out that account's
18
+ # token for that host only. The token never reaches a shell variable here -
19
+ # `jira_api` asks for a curl config per call - so a stray `set -x` or an error
20
+ # trace has nothing to print.
19
21
  #
20
22
  # Sourced, never executed. The leading underscore marks it: it is a library for
21
23
  # the scripts beside it, not a command.
22
24
  #
23
25
  # . "$(dirname "$0")/_jira-auth.sh"
24
- # jira_auth_resolve || exit 4 # sets JIRA_API_HOST and JIRA_API_TOKEN
26
+ # jira_auth_resolve || exit 4 # sets JIRA_API_HOST
25
27
  # jira_api GET /rest/api/2/myself
26
28
  #
27
- # Resolution, in order, for each of the two values:
28
- # host $JIRA_HOST, $ACCOUNT_JIRA_HOST, prefs .global.hosts.jira
29
- # token $JIRA_TOKEN, else credential-store.sh get <key>, where the key is
30
- # $JIRA_TOKEN_KEY, $ACCOUNT_JIRA_TOKEN_KEY, or
31
- # prefs .global.keychainMapping.jira
29
+ # What the caller may still say, and what each now means to the resolver:
30
+ # $JIRA_HOST, $ACCOUNT_JIRA_HOST the destination; an account must cover it
31
+ # $JIRA_TOKEN a credential from the environment
32
+ # $JIRA_TOKEN_KEY, $ACCOUNT_JIRA_TOKEN_KEY a store item name; the account
33
+ # holding it answers
32
34
  #
33
- # Exit contract: `jira_auth_resolve` returns 0 when both resolved, 4 when either
34
- # did not, having already said which on stderr. 4 is the same code both callers
35
- # already used for "could not resolve", so nothing downstream changes meaning.
36
- # It returns 3 when a value had to come from prefs and jq is not installed, so
37
- # a missing tool is not reported as a missing host or token.
35
+ # Exit contract: `jira_auth_resolve` returns 0 when the host and an account for
36
+ # it both resolved, and 4 when either did not, having already said which on
37
+ # stderr. 4 is the code both original callers used for "could not resolve", so
38
+ # nothing downstream changes meaning. jq is no longer involved, so the old 3
39
+ # ("a value had to come from prefs and jq is not installed") can no longer
40
+ # happen; a caller testing for it will simply never see it.
38
41
 
39
42
  # shellcheck shell=bash
40
43
 
41
- # MULTI_AGENT_PREFS is the same override jira-publish.sh reads, so a read and
42
- # the write after it resolve the same host and token.
43
- JIRA_AUTH_PREFS="${JIRA_AUTH_PREFS:-${MULTI_AGENT_PREFS:-$HOME/.claude/multi-agent-preferences.json}}"
44
-
45
- _jira_auth_pref() { # _jira_auth_pref <jq path> -> value or empty
46
- [ -f "$JIRA_AUTH_PREFS" ] || { printf ''; return 0; }
47
- # Without jq this printed empty and returned 0, so "no jq" and "key not set"
48
- # were the same answer and the caller went on to authenticate with nothing -
49
- # surfacing much later as a 401 that blames the credential.
50
- if ! command -v jq >/dev/null 2>&1; then
51
- echo "jq not found - cannot read $JIRA_AUTH_PREFS (install: brew install jq)" >&2
52
- printf ''
53
- return 3
54
- fi
55
- jq -r "$1 // empty" "$JIRA_AUTH_PREFS" 2>/dev/null || printf ''
56
- }
44
+ # shellcheck source=_service-account.sh
45
+ . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/_service-account.sh"
57
46
 
58
- _jira_auth_store() { # locate credential-store.sh from lib/ or the install
59
- local here
60
- here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
61
- for cand in "$here/credential-store.sh" "$HOME/.claude/lib/credential-store.sh"; do
62
- [ -f "$cand" ] && { printf '%s' "$cand"; return 0; }
63
- done
64
- return 1
47
+ # The selectors the environment asked for, as resolver arguments.
48
+ _jira_auth_selectors() {
49
+ local host="${JIRA_HOST:-${ACCOUNT_JIRA_HOST:-}}"
50
+ local item="${JIRA_TOKEN_KEY:-${ACCOUNT_JIRA_TOKEN_KEY:-}}"
51
+ [ -n "$host" ] && printf '%s\n%s\n' "--host" "$host"
52
+ [ -n "$item" ] && printf '%s\n%s\n' "--item" "$item"
53
+ return 0
65
54
  }
66
55
 
67
56
  jira_auth_resolve() {
68
- JIRA_API_HOST="${JIRA_HOST:-${ACCOUNT_JIRA_HOST:-}}"
69
- # `|| return $?`: the pref reader runs in a subshell, and its 3 ("no jq")
70
- # must reach the caller instead of being reported as a missing value.
71
- [ -n "$JIRA_API_HOST" ] || JIRA_API_HOST="$(_jira_auth_pref '.global.hosts.jira')" || return $?
57
+ local -a sel=()
58
+ while IFS= read -r line; do [ -n "$line" ] && sel+=("$line"); done < <(_jira_auth_selectors)
59
+
60
+ JIRA_API_HOST="$(sa_host jira "${sel[@]+"${sel[@]}"}")" || {
61
+ echo "ERR: no Jira account for this run: $(sa_explain)" >&2
62
+ return 4
63
+ }
72
64
  if [ -z "$JIRA_API_HOST" ]; then
73
- echo "ERR: no Jira host: set JIRA_HOST or prefs .global.hosts.jira" >&2
65
+ echo "ERR: the Jira account names no host; run /multi-agent:setup" >&2
74
66
  return 4
75
67
  fi
76
- # A host is a host, whatever the caller pasted.
77
- JIRA_API_HOST="${JIRA_API_HOST#https://}"
78
- JIRA_API_HOST="${JIRA_API_HOST#http://}"
79
- JIRA_API_HOST="${JIRA_API_HOST%/}"
80
-
81
- JIRA_API_TOKEN="${JIRA_TOKEN:-}"
82
- if [ -z "$JIRA_API_TOKEN" ]; then
83
- local key store
84
- key="${JIRA_TOKEN_KEY:-${ACCOUNT_JIRA_TOKEN_KEY:-}}"
85
- [ -n "$key" ] || key="$(_jira_auth_pref '.global.keychainMapping.jira')" || return $?
86
- if [ -z "$key" ]; then
87
- echo "ERR: no Jira token: set JIRA_TOKEN or map prefs .global.keychainMapping.jira" >&2
88
- return 4
89
- fi
90
- store="$(_jira_auth_store)" || {
91
- echo "ERR: credential-store.sh not found next to lib/ or in ~/.claude/lib" >&2
92
- return 4
93
- }
94
- JIRA_API_TOKEN="$(bash "$store" get "$key" 2>/dev/null || printf '')"
95
- if [ -z "$JIRA_API_TOKEN" ]; then
96
- echo "ERR: Jira token not in the credential store under: $key" >&2
97
- return 4
98
- fi
99
- fi
68
+ JIRA_AUTH_SELECTORS=("${sel[@]+"${sel[@]}"}")
100
69
  return 0
101
70
  }
102
71
 
103
- # The token reaches curl only through a -K config on process substitution: never
104
- # argv, never a log, never `ps`. Every caller goes through here so that stays
105
- # true in one place instead of three.
106
- _jira_auth_cfg() { printf 'header = "Authorization: Bearer %s"\n' "$1"; }
107
-
108
72
  jira_api() { # jira_api <METHOD> <path> [curl args...]
109
- local method="$1" path="$2"; shift 2
110
- curl -sS -m 30 -K <(_jira_auth_cfg "$JIRA_API_TOKEN") \
73
+ local method="$1" path="$2" cfg
74
+ shift 2
75
+ cfg="$(sa_cfg jira "https://$JIRA_API_HOST$path" bearer \
76
+ "${JIRA_AUTH_SELECTORS[@]+"${JIRA_AUTH_SELECTORS[@]}"}")" || {
77
+ echo "ERR: $(sa_explain)" >&2
78
+ return 4
79
+ }
80
+ # The URL and the scheme lock live in the config, so they cannot be separated
81
+ # from the header between the check and the request.
82
+ curl -sS -m 30 --config "$cfg" \
111
83
  -H "Content-Type: application/json" \
112
- -X "$method" "https://$JIRA_API_HOST$path" "$@"
84
+ -X "$method" "$@"
113
85
  }