@mmerterden/multi-agent-pipeline 23.6.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 (167) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/README.md +61 -27
  3. package/README.tr.md +46 -12
  4. package/SECURITY.md +3 -3
  5. package/docs/architecture.md +47 -8
  6. package/docs/ecosystem.md +20 -18
  7. package/docs/engineering.md +1 -1
  8. package/docs/facts.json +8 -6
  9. package/docs/features.md +59 -15
  10. package/install/_codex-agents.mjs +13 -8
  11. package/install/_common.mjs +24 -0
  12. package/install/_dev-only-files.mjs +4 -0
  13. package/install/_mcp-register.mjs +6 -2
  14. package/install/_rewrite-tree.mjs +197 -0
  15. package/install/codex.mjs +96 -180
  16. package/install/copilot.mjs +24 -54
  17. package/install/index.mjs +29 -11
  18. package/install/templates/codex-instructions.md +21 -5
  19. package/install/templates/copilot-instructions.md +21 -14
  20. package/manifest.json +2082 -0
  21. package/package.json +6 -2
  22. package/pipeline/commands/multi-agent/SKILL.md +7 -5
  23. package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
  24. package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
  25. package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
  26. package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
  27. package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
  28. package/pipeline/commands/multi-agent/resume/SKILL.md +2 -0
  29. package/pipeline/commands/multi-agent/review-rounds/SKILL.md +94 -0
  30. package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
  31. package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
  32. package/pipeline/contract/manifest.json +1 -1
  33. package/pipeline/contract/types/index.d.ts +1 -0
  34. package/pipeline/lib/_jira-auth.sh +50 -78
  35. package/pipeline/lib/_service-account.sh +191 -0
  36. package/pipeline/lib/credential-inventory.sh +49 -37
  37. package/pipeline/lib/credential-store.sh +48 -3
  38. package/pipeline/lib/fetch-confluence.sh +76 -92
  39. package/pipeline/lib/fetch-crashlytics.sh +30 -59
  40. package/pipeline/lib/fetch-figma-annotations.sh +9 -9
  41. package/pipeline/lib/fetch-fortify.sh +77 -81
  42. package/pipeline/lib/fetch-graylog.sh +38 -77
  43. package/pipeline/lib/figma-mcp-refresh.sh +23 -4
  44. package/pipeline/lib/figma-screenshot.sh +7 -8
  45. package/pipeline/lib/figma-token.sh +39 -46
  46. package/pipeline/lib/host.mjs +138 -0
  47. package/pipeline/lib/host.sh +48 -0
  48. package/pipeline/lib/issue-fetcher.sh +25 -41
  49. package/pipeline/lib/jira-publish.sh +23 -21
  50. package/pipeline/lib/local-model.mjs +93 -0
  51. package/pipeline/lib/md2confluence-v3.py +37 -30
  52. package/pipeline/lib/model-dispatch.sh +41 -4
  53. package/pipeline/lib/model-resolve.mjs +58 -0
  54. package/pipeline/lib/post-pr-review.sh +38 -53
  55. package/pipeline/lib/reviewer-families.mjs +70 -0
  56. package/pipeline/lib/service-account.mjs +2131 -0
  57. package/pipeline/lib/service-account.sh +35 -0
  58. package/pipeline/lib/usage-names.generated.mjs +3 -0
  59. package/pipeline/lib/usage-token.mjs +64 -24
  60. package/pipeline/lib/usage-vocab.mjs +1 -1
  61. package/pipeline/lib/user-facing.mjs +11 -3
  62. package/pipeline/lib/vercel-deploy.sh +17 -26
  63. package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
  64. package/pipeline/multi-agent-refs/_input-parser.md +1 -1
  65. package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
  66. package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
  67. package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
  68. package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
  69. package/pipeline/multi-agent-refs/channels/generator.md +10 -2
  70. package/pipeline/multi-agent-refs/channels/menu.md +3 -1
  71. package/pipeline/multi-agent-refs/channels/preview.md +3 -1
  72. package/pipeline/multi-agent-refs/channels/reference.md +16 -2
  73. package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
  74. package/pipeline/multi-agent-refs/component-dispatch.md +2 -2
  75. package/pipeline/multi-agent-refs/cross-cli-contract.md +38 -30
  76. package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +4 -4
  77. package/pipeline/multi-agent-refs/features/doctor.md +37 -11
  78. package/pipeline/multi-agent-refs/features/free-models.md +3 -3
  79. package/pipeline/multi-agent-refs/features/local-model.md +87 -0
  80. package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
  81. package/pipeline/multi-agent-refs/features/product-context.md +6 -5
  82. package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
  83. package/pipeline/multi-agent-refs/features/review-rounds.md +40 -0
  84. package/pipeline/multi-agent-refs/features/rework-escalation.md +5 -4
  85. package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
  86. package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
  87. package/pipeline/multi-agent-refs/help/en.md +31 -2
  88. package/pipeline/multi-agent-refs/help/tr.md +31 -2
  89. package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +3 -2
  90. package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
  91. package/pipeline/multi-agent-refs/phases/modes.md +20 -1
  92. package/pipeline/multi-agent-refs/phases/operations.md +1 -1
  93. package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -1
  94. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
  95. package/pipeline/multi-agent-refs/phases/phase-3-review.md +7 -3
  96. package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
  97. package/pipeline/multi-agent-refs/phases.md +4 -3
  98. package/pipeline/multi-agent-refs/resume/details.md +2 -0
  99. package/pipeline/multi-agent-refs/review/panel.md +30 -18
  100. package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
  101. package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
  102. package/pipeline/multi-agent-refs/sync/overview.md +11 -5
  103. package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
  104. package/pipeline/office/index.html +4 -4
  105. package/pipeline/schemas/agent-state.schema.json +19 -1
  106. package/pipeline/schemas/autopilot-config.schema.json +29 -4
  107. package/pipeline/schemas/hosts.json +512 -0
  108. package/pipeline/schemas/hosts.schema.json +310 -0
  109. package/pipeline/schemas/launch.json +22 -2
  110. package/pipeline/schemas/launch.schema.json +2 -1
  111. package/pipeline/schemas/phases.json +21 -3
  112. package/pipeline/schemas/phases.schema.json +8 -0
  113. package/pipeline/schemas/prefs.schema.json +346 -7
  114. package/pipeline/schemas/token-budget.json +2 -2
  115. package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
  116. package/pipeline/scripts/_autopilot-config.mjs +67 -4
  117. package/pipeline/scripts/_autopilot-item.mjs +67 -0
  118. package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
  119. package/pipeline/scripts/_cost.mjs +75 -3
  120. package/pipeline/scripts/analysis-sources.mjs +22 -5
  121. package/pipeline/scripts/analysis-unattended.mjs +360 -0
  122. package/pipeline/scripts/anonymize-findings.mjs +3 -7
  123. package/pipeline/scripts/autopilot-arming.mjs +19 -10
  124. package/pipeline/scripts/autopilot-intake.mjs +124 -27
  125. package/pipeline/scripts/autopilot-menubar.swift +7 -0
  126. package/pipeline/scripts/autopilot-runner.mjs +77 -48
  127. package/pipeline/scripts/autopilot-status.sh +32 -9
  128. package/pipeline/scripts/bulk-read.sh +37 -5
  129. package/pipeline/scripts/confluence-readback.mjs +15 -7
  130. package/pipeline/scripts/cost-table.json +65 -25
  131. package/pipeline/scripts/doctor.mjs +119 -32
  132. package/pipeline/scripts/entry-mode.mjs +101 -0
  133. package/pipeline/scripts/estimate.mjs +30 -16
  134. package/pipeline/scripts/feedback-send.mjs +11 -8
  135. package/pipeline/scripts/gen-facts.mjs +16 -13
  136. package/pipeline/scripts/jira-attach.sh +23 -28
  137. package/pipeline/scripts/jira-search.sh +5 -21
  138. package/pipeline/scripts/launch-request.mjs +15 -9
  139. package/pipeline/scripts/migrate-prefs.mjs +56 -0
  140. package/pipeline/scripts/phase-tracker.sh +146 -38
  141. package/pipeline/scripts/priority-review.mjs +14 -7
  142. package/pipeline/scripts/product-context.mjs +26 -7
  143. package/pipeline/scripts/prune-logs.sh +4 -2
  144. package/pipeline/scripts/report-file.mjs +285 -0
  145. package/pipeline/scripts/review-rounds.mjs +592 -0
  146. package/pipeline/scripts/rework-escalation.mjs +26 -7
  147. package/pipeline/scripts/service-read.mjs +19 -17
  148. package/pipeline/scripts/skill-siblings.mjs +17 -1
  149. package/pipeline/scripts/status-overview.mjs +20 -10
  150. package/pipeline/scripts/uninstall.mjs +145 -57
  151. package/pipeline/scripts/usage-register.mjs +34 -11
  152. package/pipeline/scripts/usage-report.mjs +31 -26
  153. package/pipeline/scripts/validate-state.mjs +19 -11
  154. package/pipeline/scripts/validate-triage.mjs +11 -1
  155. package/pipeline/scripts/work-items.mjs +25 -28
  156. package/pipeline/scripts/write-store-config.mjs +37 -11
  157. package/pipeline/skills/.skill-manifest.json +11 -7
  158. package/pipeline/skills/.skills-index.json +13 -2
  159. package/pipeline/skills/shared/README.md +4 -3
  160. package/pipeline/skills/shared/core/multi-agent/SKILL.md +14 -6
  161. package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
  162. package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
  163. package/pipeline/skills/shared/core/multi-agent-resume/SKILL.md +1 -1
  164. package/pipeline/skills/shared/core/multi-agent-review-rounds/SKILL.md +92 -0
  165. package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
  166. package/pipeline/skills/skills-index.md +2 -1
  167. package/pipeline/lib/credential-resolve.mjs +0 -75
@@ -43,6 +43,7 @@
43
43
 
44
44
  import { readFileSync, writeFileSync } from "node:fs";
45
45
  import { pathToFileURL } from "node:url";
46
+ import { FAMILIES, familyOf } from "../lib/reviewer-families.mjs";
46
47
 
47
48
  const IDENTITY_KEYS = [
48
49
  "reviewer",
@@ -167,13 +168,8 @@ export function anonymize(input, { seed } = {}) {
167
168
  return { findings: tagged, map: { seed: seedText, labelToModel, malformed } };
168
169
  }
169
170
 
170
- const FAMILIES = ["fable", "opus", "sonnet", "gpt"];
171
-
172
- /** The reviewer family a map entry names, or null for a model outside the four. */
173
- export function familyOf(model) {
174
- const m = String(model ?? "").toLowerCase();
175
- return FAMILIES.find((f) => m.includes(f)) ?? null;
176
- }
171
+ // Derived from the host registry so a rung added there needs no second edit.
172
+ export { FAMILIES, familyOf };
177
173
 
178
174
  /**
179
175
  * The triage document with `reviewer` set on every finding whose `foundBy`
@@ -26,8 +26,8 @@
26
26
  *
27
27
  * Readable, not only recorded. `probe` asks every credential the configured
28
28
  * repos need whether it can be read right now without a prompt: `gh auth
29
- * status` for GitHub, and `credential-store.sh probe` for the logical keys a
30
- * source reads from `prefs.global.keychainMapping` (Jira today). The value is
29
+ * status` for GitHub, and `credential-store.sh probe` for the item the account
30
+ * resolver names for a source (Jira today). The value is
31
31
  * never read into this process - the store answers one word. autopilot-on runs
32
32
  * it before the schedule is offered, and every tick runs the item's own half
33
33
  * through `check --probe`, because a tick runs in the background session, where
@@ -60,6 +60,7 @@ import { configRefusal } from "./_autopilot-config.mjs";
60
60
  import { hostCommand, messages as languageHalf } from "../lib/user-facing.mjs";
61
61
  import { PREFS_ENV, prefsPath } from "../lib/prefs-value.mjs";
62
62
  import { exitOnHelp } from "../lib/cli-help.mjs";
63
+ import { selectAccount } from "../lib/service-account.mjs";
63
64
 
64
65
  exitOnHelp(import.meta.url);
65
66
 
@@ -100,9 +101,9 @@ const MESSAGES = {
100
101
  ghUnauth: () =>
101
102
  "GitHub: gh is not authenticated for a non-interactive session - run gh auth login",
102
103
  unmapped: (key, cmd) =>
103
- `credential "${key}": prefs.global.keychainMapping.${key} is not set - save the token with ${cmd}`,
104
+ `credential "${key}": no ${key} account is configured - save the token with ${cmd}`,
104
105
  noHost: (key, cmd) =>
105
- `credential "${key}": prefs.global.hosts.${key} is not set - record the host with ${cmd}`,
106
+ `credential "${key}": the ${key} account does not say which host it is for - record it with ${cmd}`,
106
107
  missing: (key, item, cmd) =>
107
108
  `credential "${key}" (stored as "${item}") is not in the credential store - save it with ${cmd}`,
108
109
  locked: (key) =>
@@ -129,9 +130,9 @@ const MESSAGES = {
129
130
  ghMissing: () => "GitHub: gh kurulu değil - kur, sonra gh auth login çalıştır",
130
131
  ghUnauth: () => "GitHub: gh etkileşimsiz oturum için giriş yapmamış - gh auth login çalıştır",
131
132
  unmapped: (key, cmd) =>
132
- `"${key}" kimlik bilgisi: prefs.global.keychainMapping.${key} tanımlı değil - token'ı ${cmd} ile kaydet`,
133
+ `"${key}" kimlik bilgisi: ${key} hesabı tanımlı değil - token'ı ${cmd} ile kaydet`,
133
134
  noHost: (key, cmd) =>
134
- `"${key}" kimlik bilgisi: prefs.global.hosts.${key} tanımlı değil - host'u ${cmd} ile kaydet`,
135
+ `"${key}" kimlik bilgisi: ${key} hesabı hangi host için olduğunu söylemiyor - ${cmd} ile kaydet`,
135
136
  missing: (key, item, cmd) =>
136
137
  `"${key}" kimlik bilgisi ("${item}" adıyla) kimlik deposunda yok - ${cmd} ile kaydet`,
137
138
  locked: (key) =>
@@ -272,12 +273,20 @@ export function probeService(service, { prefs, env = process.env, language = "en
272
273
  }
273
274
  const key = service;
274
275
  const setup = hostCommand("setup");
275
- const item = prefs?.global?.keychainMapping?.[key];
276
- if (typeof item !== "string" || !item.trim()) {
276
+ // Which account answers, and which store item it names, is the resolver's
277
+ // question. Asking it here also answers the host one: an account that cannot
278
+ // say where it may be sent is not an account this check will pass.
279
+ const chosen = selectAccount({ service }, { prefs });
280
+ if (!chosen.ok) {
281
+ const status = chosen.reason === "not-configured" ? "unmapped" : "no-host";
282
+ const message = status === "unmapped" ? m.unmapped(key, setup) : m.noHost(key, setup);
283
+ return { service, key, status, message };
284
+ }
285
+ const item = chosen.account.secrets?.[chosen.account.slots?.[0] ?? "token"] ?? "";
286
+ if (!String(item).trim()) {
277
287
  return { service, key, status: "unmapped", message: m.unmapped(key, setup) };
278
288
  }
279
- const host = prefs?.global?.hosts?.[key];
280
- if (typeof host !== "string" || !host.trim()) {
289
+ if (!chosen.account.hosts?.length) {
281
290
  return { service, key, status: "no-host", message: m.noHost(key, setup) };
282
291
  }
283
292
  const r = spawnSync("bash", [STORE, "probe", key], {
@@ -7,6 +7,15 @@
7
7
  * keeping the two apart is what makes the ordering testable without a network,
8
8
  * a simulator, or a willingness to open a real PR while a gate runs.
9
9
  *
10
+ * KINDS. Each repo has two labels per tracker: the development label, whose
11
+ * items run the pipeline and stop at a pull request, and the analysis label,
12
+ * whose items run the analysis command and stop at a document. Each is its own
13
+ * query, each item carries its `kind`, and the ledger keys them apart
14
+ * (_autopilot-item.mjs), so one ticket can be analysed and later developed. A
15
+ * repo whose two labels are equal is refused (_autopilot-config.mjs), and a
16
+ * repo that never said yes to analysis work is never queried for it
17
+ * (`analysisEnrolled`).
18
+ *
10
19
  * ORDER (descending precedence). Deterministic, no model call:
11
20
  *
12
21
  * 1. explicit rank from the label (`agent-queue:1` ... `agent-queue:9`)
@@ -43,6 +52,7 @@ import { join, dirname } from "node:path";
43
52
  import { homedir } from "node:os";
44
53
  import { invokedDirectly } from "../lib/invoked-directly.mjs";
45
54
  import { OUTCOME, isParked, isRetryable, isTerminal } from "./_autopilot-outcomes.mjs";
55
+ import { KIND, historyKey, isAnalysis, queuedKinds } from "./_autopilot-item.mjs";
46
56
  import { configRefusal } from "./_autopilot-config.mjs";
47
57
  import { exitOnHelp } from "../lib/cli-help.mjs";
48
58
 
@@ -75,12 +85,76 @@ export function priorityScore(name) {
75
85
  return PRIORITY[String(name).trim().toLowerCase()] ?? 0;
76
86
  }
77
87
 
88
+ /**
89
+ * The shape a queue label may take.
90
+ *
91
+ * The label is operator-configured, and it is read into three different
92
+ * languages: a regular expression here, a JQL string literal in the Jira
93
+ * query, and a GitHub search term. Rather than escaping it three ways, it is
94
+ * checked once against what a label can actually be - a tracker label is a
95
+ * short name, and nothing that fits this pattern means anything in any of the
96
+ * three.
97
+ */
98
+ const LABEL_RE = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,48}$/;
99
+
100
+ /** The configured label, or null when it is not a label at all. */
101
+ export function checkedLabel(value, fallback) {
102
+ const text = String(value ?? "").trim() || fallback;
103
+ return LABEL_RE.test(text) ? text : null;
104
+ }
105
+
106
+ /**
107
+ * The label each kind is queued by when the repo names none. The schema
108
+ * carries the same two defaults, and test/autopilot-intake.test.mjs fails when
109
+ * they drift.
110
+ */
111
+ export const DEFAULT_LABELS = Object.freeze({
112
+ [KIND.DEVELOPMENT]: "agent-queue",
113
+ [KIND.ANALYSIS]: "agent-analysis",
114
+ });
115
+
116
+ /** Is this repo in the analysis queue at all? One owner: `queuedKinds`. */
117
+ export function analysisEnrolled(repo) {
118
+ return queuedKinds(repo).includes(KIND.ANALYSIS);
119
+ }
120
+
121
+ /**
122
+ * The label one repo queues `kind` work by on one tracker, or null when the
123
+ * configured value is not a label. Every query below is built from this and
124
+ * from nothing else, so an unchecked value never reaches a JQL string literal
125
+ * or a search term.
126
+ *
127
+ * @param {object} repo
128
+ * @param {"github"|"jira"} tracker
129
+ * @param {string} kind
130
+ * @returns {string|null}
131
+ */
132
+ export function labelFor(repo, tracker, kind = KIND.DEVELOPMENT) {
133
+ const analysis = kind === KIND.ANALYSIS;
134
+ const configured =
135
+ tracker === "jira"
136
+ ? analysis
137
+ ? repo.analysisJiraLabel
138
+ : repo.jiraLabel
139
+ : analysis
140
+ ? repo.analysisGithubLabel
141
+ : repo.githubLabel;
142
+ return checkedLabel(configured, DEFAULT_LABELS[kind]);
143
+ }
144
+
78
145
  /** `agent-queue:3` -> 3. Any other label shape -> null (ordered by the rules). */
79
146
  export function rankFromLabels(labels, base) {
147
+ const checked = checkedLabel(base, "");
148
+ if (!checked) return null;
149
+ // Escaped even though the pattern above already excludes every character
150
+ // that means anything here: the two checks answer to different callers, and
151
+ // the one that is only correct because of the other is the one that breaks
152
+ // when either moves.
153
+ const re = new RegExp(`^${checked.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")}:([1-9])$`);
80
154
  for (const l of labels || []) {
81
155
  const name = typeof l === "string" ? l : l?.name;
82
156
  if (!name) continue;
83
- const m = new RegExp(`^${base}:([1-9])$`).exec(name);
157
+ const m = re.exec(name);
84
158
  if (m) return Number(m[1]);
85
159
  }
86
160
  return null;
@@ -160,7 +234,7 @@ export function foldAttempts(lines) {
160
234
  } catch {
161
235
  continue; // a truncated last line is normal on an append-only log
162
236
  }
163
- const key = `${rec.source}:${rec.id}`;
237
+ const key = historyKey(rec);
164
238
  const cur = byKey.get(key) || { attempts: 0, last: null, usd: 0, at: 0, runs: new Set() };
165
239
  if (isRetryable(rec.outcome)) {
166
240
  if (!rec.taskId) cur.attempts += 1;
@@ -188,6 +262,7 @@ export function foldAttempts(lines) {
188
262
  * leaving the item alone, never toward running it twice.
189
263
  */
190
264
  function legacyKey(c) {
265
+ if (isAnalysis(c)) return null; // no analysis row was ever written under the old id
191
266
  if (c?.source !== "github" || typeof c.id !== "string") return null;
192
267
  const m = /^[^/#]+\/([^/#]+)#(\d+)$/.exec(c.id);
193
268
  return m ? `github:${m[1]}#${m[2]}` : null;
@@ -203,7 +278,7 @@ export function selectable(candidates, history, { maxAttempts = 2 } = {}) {
203
278
  const awaiting = [];
204
279
  const dropped = [];
205
280
  for (const c of candidates) {
206
- const h = history.get(`${c.source}:${c.id}`) ?? history.get(legacyKey(c));
281
+ const h = history.get(historyKey(c)) ?? history.get(legacyKey(c));
207
282
  if (!h) {
208
283
  queued.push(c);
209
284
  continue;
@@ -255,8 +330,9 @@ function sh(cmd, args, opts = {}) {
255
330
  * anyone who opens an issue, and an unattended run acts on the issue's text.
256
331
  * `githubAssignee: "*"` lists every labelled issue.
257
332
  */
258
- export function githubListArgs(repo) {
259
- const label = repo.githubLabel || "agent-queue";
333
+ export function githubListArgs(repo, kind = KIND.DEVELOPMENT) {
334
+ const label = labelFor(repo, "github", kind);
335
+ if (!label) return null;
260
336
  const assignee = repo.githubAssignee || "@me";
261
337
  const args = ["issue", "list", "--repo", repo.nameWithOwner, "--label", label];
262
338
  if (assignee !== "*") args.push("--assignee", assignee);
@@ -264,15 +340,17 @@ export function githubListArgs(repo) {
264
340
  return args;
265
341
  }
266
342
 
267
- function fetchGitHub(repo) {
268
- const out = sh("gh", githubListArgs(repo));
343
+ function fetchGitHub(repo, kind = KIND.DEVELOPMENT) {
344
+ const args = githubListArgs(repo, kind);
345
+ if (!args) return [];
346
+ const out = sh("gh", args);
269
347
  let rows;
270
348
  try {
271
349
  rows = JSON.parse(out || "[]");
272
350
  } catch {
273
351
  return [];
274
352
  }
275
- return githubCandidates(repo, rows);
353
+ return githubCandidates(repo, rows, kind);
276
354
  }
277
355
 
278
356
  /**
@@ -281,13 +359,14 @@ function fetchGitHub(repo) {
281
359
  * would let one repo's finished issue drop the other's. `ref` stays short -
282
360
  * the run is launched in the repo's own checkout, which names the repo.
283
361
  */
284
- export function githubCandidates(repo, rows) {
285
- const label = repo.githubLabel || "agent-queue";
362
+ export function githubCandidates(repo, rows, kind = KIND.DEVELOPMENT) {
363
+ const label = labelFor(repo, "github", kind);
286
364
  const short = repo.nameWithOwner.split("/").pop();
287
365
  return (rows || []).map((r) => ({
288
366
  source: "github",
289
367
  id: `${repo.nameWithOwner}#${r.number}`,
290
368
  ref: `${short}#${r.number}`,
369
+ kind,
291
370
  repo: repo.nameWithOwner,
292
371
  localPath: repo.localPath,
293
372
  title: r.title,
@@ -305,10 +384,17 @@ export function githubCandidates(repo, rows) {
305
384
  }));
306
385
  }
307
386
 
308
- function fetchJira(repo) {
309
- const label = repo.jiraLabel || "agent-queue";
387
+ function fetchJira(repo, kind = KIND.DEVELOPMENT) {
388
+ // A label that is not a label never reaches the query: it would be a quote
389
+ // inside a JQL string literal, which is a different query than the one this
390
+ // line reads as.
391
+ const label = labelFor(repo, "jira", kind);
392
+ if (!label) return [];
393
+ // `jiraJql` is the development queue's own search; analysis work is picked
394
+ // up by its label whatever that search says, so a repo with a custom JQL
395
+ // does not silently lose the analysis queue.
310
396
  const jql =
311
- repo.jiraJql ||
397
+ (kind === KIND.ANALYSIS ? null : repo.jiraJql) ||
312
398
  `assignee = currentUser() AND labels = "${label}" AND resolution = EMPTY ` +
313
399
  `AND status not in (Done, Closed, Cancelled) ORDER BY priority DESC, created ASC`;
314
400
  // One helper owns Jira search: URL encoding and JQL injection are already
@@ -327,15 +413,16 @@ function fetchJira(repo) {
327
413
  } catch {
328
414
  return [];
329
415
  }
330
- return jiraCandidates(repo, rows);
416
+ return jiraCandidates(repo, rows, kind);
331
417
  }
332
418
 
333
419
  /** Queue items from a Jira search's `issues`. The issue key is the id. */
334
- export function jiraCandidates(repo, issues) {
420
+ export function jiraCandidates(repo, issues, kind = KIND.DEVELOPMENT) {
335
421
  return (issues || []).map((i) => ({
336
422
  source: "jira",
337
423
  id: i.key,
338
424
  ref: i.key,
425
+ kind,
339
426
  repo: repo.nameWithOwner,
340
427
  localPath: repo.localPath,
341
428
  title: i.fields?.summary,
@@ -354,6 +441,8 @@ export function jiraCandidates(repo, issues) {
354
441
  * repo with Jira on would queue - and run, and open a PR for - the same issue.
355
442
  * The first repo in config order takes it; each other match is returned in
356
443
  * `duplicates` with the reason, so the queue says why it is not listed twice.
444
+ * That holds per kind: the analysis queue and the development queue each pick
445
+ * one owner, and an issue in both is two items, not a duplicate.
357
446
  *
358
447
  * @returns {{items: object[], duplicates: object[]}}
359
448
  */
@@ -366,18 +455,26 @@ export function gather(
366
455
  const jiraOwner = new Map();
367
456
  for (const repo of config.repos || []) {
368
457
  const sources = repo.sources || ["github"];
369
- if (sources.includes("github")) items.push(...gh(repo));
370
- if (!sources.includes("jira")) continue;
371
- for (const it of jira(repo)) {
372
- const owner = jiraOwner.get(it.id);
373
- if (owner === undefined) {
374
- jiraOwner.set(it.id, it.repo);
375
- items.push(it);
376
- } else if (owner !== it.repo) {
377
- duplicates.push({
378
- ...it,
379
- reason: `also matched for ${owner}, queued there - give each repo a jiraJql that matches only its own issues`,
380
- });
458
+ // One pass per kind, because the two labels are two separate queries. The
459
+ // same ticket may answer both, and then it is two items: one analysed, one
460
+ // developed, each with its own key in the ledger. The analysis pass runs
461
+ // only for a repo enrolled in that queue, so a repo picked for development
462
+ // never starts spending runs on documents nobody asked for.
463
+ for (const kind of queuedKinds(repo)) {
464
+ if (sources.includes("github")) items.push(...gh(repo, kind));
465
+ if (!sources.includes("jira")) continue;
466
+ for (const it of jira(repo, kind)) {
467
+ const key = historyKey(it);
468
+ const owner = jiraOwner.get(key);
469
+ if (owner === undefined) {
470
+ jiraOwner.set(key, it.repo);
471
+ items.push(it);
472
+ } else if (owner !== it.repo) {
473
+ duplicates.push({
474
+ ...it,
475
+ reason: `also matched for ${owner}, queued there - give each repo a jiraJql that matches only its own issues`,
476
+ });
477
+ }
381
478
  }
382
479
  }
383
480
  }
@@ -35,6 +35,7 @@ struct Item: Decodable {
35
35
  let stack: String?
36
36
  let startedAt: Double?
37
37
  let state: String? // running | queued | awaiting-answer | blocked
38
+ let kind: String? // development | analysis - what the item delivers
38
39
  let url: String? // the ticket, so a row is clickable
39
40
  }
40
41
 
@@ -135,6 +136,7 @@ struct Strings {
135
136
  let idle: String
136
137
  let queuedHeading: String
137
138
  let queuedMore: String
139
+ let analysisSuffix: String
138
140
  let awaitingHeading: String
139
141
  let reportsHeading: String
140
142
  let todayCount: String
@@ -159,6 +161,7 @@ func strings(for language: Language) -> Strings {
159
161
  idle: "on, nothing queued",
160
162
  queuedHeading: "Queued (%d)",
161
163
  queuedMore: " ... %d more",
164
+ analysisSuffix: "analysis",
162
165
  awaitingHeading: "Waiting for an answer (%d)",
163
166
  reportsHeading: "Reports (%d)",
164
167
  todayCount: "today: %d",
@@ -179,6 +182,7 @@ func strings(for language: Language) -> Strings {
179
182
  idle: "açık, sırada iş yok",
180
183
  queuedHeading: "Sırada (%d)",
181
184
  queuedMore: " ... %d tane daha",
185
+ analysisSuffix: "analiz",
182
186
  awaitingHeading: "Cevap bekliyor (%d)",
183
187
  reportsHeading: "Raporlar (%d)",
184
188
  todayCount: "bugün %d madde",
@@ -281,6 +285,9 @@ final class Controller: NSObject {
281
285
  }
282
286
  if i.startedAt != nil { line += " · \(elapsed(since: i.startedAt, ui))" }
283
287
  if let s = i.stack, !s.isEmpty { line += " · \(s)" }
288
+ // An analysis item ends at a document, not at a pull request. Without
289
+ // this the row reads as work that will produce a PR and never does.
290
+ if i.kind == "analysis" { line += " · \(ui.analysisSuffix)" }
284
291
 
285
292
  let m = NSMenuItem(title: line, action: nil, keyEquivalent: "")
286
293
  // The ticket title is long and would push every row's shape around, so