@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
@@ -125,6 +125,24 @@ esac
125
125
 
126
126
  HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
127
127
  COST_TABLE="$HERE/../scripts/cost-table.json"
128
+ HOSTS_JSON="$HERE/../schemas/hosts.json"
129
+
130
+ # Which host this router is installed under, and therefore which rungs it can
131
+ # dispatch at all. Reading this from the registry rather than assuming one
132
+ # ladder is what keeps a rung another host does not offer from being handed
133
+ # back: a preference file is shared across hosts, so a rule naming a rung that
134
+ # exists on one of them is a normal thing to find here.
135
+ if [ -f "$HOSTS_JSON" ]; then
136
+ # shellcheck source=./host.sh
137
+ [ -f "$HERE/host.sh" ] && . "$HERE/host.sh"
138
+ # Deliberately NOT defaulted to the first host. "I cannot tell which host I
139
+ # am" and "I am the host the paths are authored against" are different
140
+ # answers, and guessing the second hands back the one rung this gate exists
141
+ # to refuse. An empty id takes the single-ladder rule below instead.
142
+ HOST_ID=$(command -v ma_host_id >/dev/null 2>&1 && ma_host_id || echo "")
143
+ else
144
+ HOST_ID=""
145
+ fi
128
146
 
129
147
  STRATEGY=$(jq -r '.global.modelRouting.strategy // "manual"' "$PREFS" 2>/dev/null)
130
148
  CHEAPEST_FIRST=false
@@ -212,10 +230,29 @@ for rung in $CANDIDATES; do
212
230
  echo "model-dispatch: rung 'free' is reachable only at bulk-read and delegate; a $CALL_SITE is dispatched by the host, skipping it" >&2
213
231
  continue
214
232
  fi
215
- if [ "$PROVIDER" != "anthropic" ]; then
216
- # Every call site that asks here hands any other rung to something that
217
- # speaks the Anthropic ladder or the free chain, so returning an external
218
- # rung would produce a failed call rather than a cheaper one.
233
+ # A rung is dispatchable here when THIS host offers it and the model behind it
234
+ # is one this host speaks. The cost table prices a rung by name; what that
235
+ # name runs differs per host, so the name alone cannot answer either question.
236
+ if [ -n "$HOST_ID" ]; then
237
+ RUNG_MODEL=$(jq -r --arg h "$HOST_ID" --arg r "$rung" \
238
+ '.hosts[$h].models.rungs[$r].model // ""' "$HOSTS_JSON" 2>/dev/null)
239
+ if [ -z "$RUNG_MODEL" ]; then
240
+ echo "model-dispatch: rung '$rung' is not offered on $HOST_ID; skipping it" >&2
241
+ continue
242
+ fi
243
+ RUNG_PROVIDER=$(jq -r --arg m "$RUNG_MODEL" \
244
+ 'first(.prices[] | select(.modelId == $m or .copilotModelId == $m) | .provider) // ""' \
245
+ "$COST_TABLE" 2>/dev/null)
246
+ if ! jq -e --arg h "$HOST_ID" --arg p "$RUNG_PROVIDER" \
247
+ '(.hosts[$h].models.providers // []) | index($p) != null' "$HOSTS_JSON" >/dev/null 2>&1; then
248
+ # The call site hands the rung to something that speaks one of this host's
249
+ # own providers, so returning this one would produce a failed call rather
250
+ # than a cheaper one.
251
+ echo "model-dispatch: rung '$rung' runs $RUNG_MODEL ($RUNG_PROVIDER), which $HOST_ID does not dispatch; skipping it" >&2
252
+ continue
253
+ fi
254
+ elif [ "$PROVIDER" != "anthropic" ]; then
255
+ # No registry on this install: keep the single-ladder rule it shipped with.
219
256
  echo "model-dispatch: rung '$rung' is $PROVIDER and no call site dispatches to it; skipping it" >&2
220
257
  continue
221
258
  fi
@@ -0,0 +1,58 @@
1
+ /**
2
+ * model-resolve.mjs - rung names in, model ids out, and back again.
3
+ *
4
+ * Rung names (`fable`, `opus`, `sonnet`, `haiku`) are the contract: every
5
+ * preference, every routing rule and every escalation ladder is written in
6
+ * them. What a rung IS differs per host, and the registry holds that mapping,
7
+ * so this module is the only place that crosses between the two.
8
+ *
9
+ * Binding time differs too and is not something this module can flatten: one
10
+ * host takes the model from the environment at dispatch, another from a flag,
11
+ * a third from a file written at install. What they share is the question
12
+ * answered here - which model id and effort does this rung mean on this host.
13
+ *
14
+ * @module pipeline/lib/model-resolve
15
+ */
16
+
17
+ import { HOST_IDS, REGISTRY, currentHostId } from "./host.mjs";
18
+
19
+ /**
20
+ * What a rung means on a host.
21
+ *
22
+ * @param {string} rung
23
+ * @param {string} [hostId]
24
+ * @returns {{model: string, effort?: string}|null} null when the host does not
25
+ * offer that rung - which is a real answer, not a failure: one host carries
26
+ * no top rung at all.
27
+ */
28
+ export function modelFor(rung, hostId = currentHostId() ?? HOST_IDS[0]) {
29
+ return REGISTRY.hosts[hostId]?.models?.rungs?.[rung] ?? null;
30
+ }
31
+
32
+ /**
33
+ * The rung a model id sits on, for reading back what a run recorded.
34
+ *
35
+ * A tracker records the model it ran, not the rung it was asked for. Comparing
36
+ * that string against the rung ladder answered "not on the ladder" for every
37
+ * host whose rungs are not named after their models, which silently disabled
38
+ * rework escalation there.
39
+ *
40
+ * Where one model fills several rungs at different efforts, the LEAST capable
41
+ * of them answers unless an effort is given. Naming the most capable one reads
42
+ * as "already at the top" and stops an escalation that had somewhere to go;
43
+ * naming the least can at worst propose a step the run is already taking, and
44
+ * `modelFor` makes that a no-op the caller can see.
45
+ *
46
+ * @param {string} model - a model id, or a rung name, which answers itself
47
+ * @param {string} [hostId]
48
+ * @param {string} [effort] - narrows a model that fills several rungs
49
+ * @returns {string|null}
50
+ */
51
+ export function rungOf(model, hostId = currentHostId() ?? HOST_IDS[0], effort = undefined) {
52
+ const rungs = REGISTRY.hosts[hostId]?.models?.rungs ?? {};
53
+ if (Object.hasOwn(rungs, model)) return model;
54
+ const matches = Object.entries(rungs).filter(([, slot]) => slot.model === model);
55
+ if (!matches.length) return null;
56
+ const exact = effort ? matches.filter(([, slot]) => slot.effort === effort) : [];
57
+ return (exact.length ? exact : matches).at(-1)[0];
58
+ }
@@ -94,10 +94,20 @@ if [ -f "$_MA_RP_HERE/run-paths.sh" ]; then . "$_MA_RP_HERE/run-paths.sh"; else
94
94
  # shellcheck source=/dev/null
95
95
  if [ -f "$_MA_RP_HERE/user-facing.sh" ]; then . "$_MA_RP_HERE/user-facing.sh"; else . "$HOME/.claude/lib/user-facing.sh"; fi
96
96
 
97
+ # shellcheck source=/dev/null
98
+ if [ -f "$_MA_RP_HERE/_service-account.sh" ]; then
99
+ . "$_MA_RP_HERE/_service-account.sh"
100
+ elif [ -f "$HOME/.claude/lib/_service-account.sh" ]; then
101
+ . "$HOME/.claude/lib/_service-account.sh"
102
+ fi
97
103
 
98
- # Basic-auth via a curl config fed through process substitution so the
99
- # credential never appears in argv (argv is visible to `ps` / process audit).
100
- bb_auth_cfg() { printf 'user = "%s:%s"\n' "$1" "$2"; }
104
+ # A curl config carrying the Bitbucket credential to exactly this URL. Sets
105
+ # BB_CFG rather than printing it: a caller reading it through a command
106
+ # substitution would resolve in a subshell, where a refusal cannot be reported.
107
+ BB_CFG=""
108
+ bb_cfg() {
109
+ BB_CFG="$(sa_cfg bitbucket "$1" basic)"
110
+ }
101
111
 
102
112
  TASK_ID="${1:-}"
103
113
 
@@ -257,12 +267,12 @@ compute_next_iteration() {
257
267
  # them into the same `[{body: <text>}, ...]` shape that
258
268
  # comment_exists_with_fingerprint expects so the dedupe gate is provider-agnostic.
259
269
  load_existing_comments_bitbucket() {
260
- local host="$1" project="$2" slug="$3" pr_num="$4" auth_user="$5" auth_token="$6"
270
+ local host="$1" project="$2" slug="$3" pr_num="$4"
261
271
  if [ -z "$EXISTING_COMMENTS_CACHE" ]; then
262
272
  local base="https://$host/rest/api/1.0/projects/$project/repos/$slug/pull-requests/$pr_num"
263
273
  local raw
264
- raw=$(curl -sS -m 30 -K <(bb_auth_cfg "$auth_user" "$auth_token") \
265
- "$base/activities?fromType=COMMENT&limit=100" 2>/dev/null || echo "{}")
274
+ bb_cfg "$base/activities?fromType=COMMENT&limit=100" || { EXISTING_COMMENTS_CACHE="[]"; return 0; }
275
+ raw=$(curl -sS -m 30 --config "$BB_CFG" 2>/dev/null || echo "{}")
266
276
  EXISTING_COMMENTS_CACHE=$(jq '
267
277
  def collect_texts(c):
268
278
  if c == null then []
@@ -363,55 +373,27 @@ post_github() {
363
373
  }
364
374
 
365
375
  post_bitbucket_server() {
366
- local host project slug user_slug auth_user auth_token user_key token_key prefs
376
+ local host project slug user_slug
367
377
  host=$(jq -r '.review.input.bbServerHost' "$AGENT_STATE")
368
378
  project=$(jq -r '.review.input.bbProjectKey' "$AGENT_STATE")
369
379
  slug=$(jq -r '.review.input.bbRepoSlug' "$AGENT_STATE")
370
380
 
371
- # Resolve credential keys from prefs.keychainMapping - never hardcode.
372
- prefs="$HOME/.claude/multi-agent-preferences.json"
373
- user_key=$(jq -r '.global.keychainMapping.bitbucket_user // empty' "$prefs" 2>/dev/null || true)
374
- token_key=$(jq -r '.global.keychainMapping.bitbucket_token // empty' "$prefs" 2>/dev/null || true)
381
+ local base="https://$host/rest/api/1.0/projects/$project/repos/$slug/pull-requests/$PR_NUM"
375
382
 
376
- if [ -z "$user_key" ] || [ -z "$token_key" ]; then
377
- echo "post-pr-review: global.keychainMapping.bitbucket_user / .bitbucket_token unset in $prefs" >&2
383
+ # The participant URL carries the reviewer's own name, so the username slot
384
+ # is read as a value here; the password never is.
385
+ if ! command -v sa_cfg >/dev/null 2>&1; then
386
+ echo "post-pr-review: the account resolver is not installed" >&2
378
387
  return 4
379
388
  fi
380
-
381
- # Resolve via the credential helper (macOS Keychain) - sourced lazily so this script keeps
382
- # working when run from either ~/.claude/lib or ~/.copilot/lib.
383
- # shellcheck disable=SC1090
384
- # Existence check before sourcing: `. <missing>` aborts the shell under `set -e`,
385
- # `||` included, so a `.`-chain reaches neither its later candidates nor its error
386
- # branch. The loop also covers all three hosts - the chain it replaced knew only
387
- # .claude and .copilot, so a Codex-only install could not resolve at all.
388
- for _cred_resolver in \
389
- "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/credential-store-resolver.sh" \
390
- "$HOME/.claude/lib/credential-store-resolver.sh" \
391
- "$HOME/.copilot/lib/credential-store-resolver.sh" \
392
- "$HOME/.codex/lib/credential-store-resolver.sh"; do
393
- [ -f "$_cred_resolver" ] || continue
394
- # shellcheck source=/dev/null
395
- . "$_cred_resolver" 2>/dev/null || true
396
- if [ -n "${CRED_STORE:-}" ]; then break; fi
397
- done
398
- unset _cred_resolver
399
- if [ -z "${CRED_STORE:-}" ]; then
400
- echo "post-pr-review: credential helper not found" >&2
389
+ user_slug=$(sa_token bitbucket "$base" --slot username) || {
390
+ echo "post-pr-review: $(sa_explain)" >&2
401
391
  return 4
402
- fi
403
- resolve_credential_store || return 4
404
-
405
- auth_user=$("$CRED_STORE" get "$user_key" 2>/dev/null || true)
406
- auth_token=$("$CRED_STORE" get "$token_key" 2>/dev/null || true)
407
- user_slug="$auth_user"
408
-
409
- if [ -z "$auth_user" ] || [ -z "$auth_token" ]; then
410
- echo "post-pr-review: bitbucket creds not in credential store ($user_key / $token_key)" >&2
392
+ }
393
+ bb_cfg "$base" || {
394
+ echo "post-pr-review: $(sa_explain)" >&2
411
395
  return 4
412
- fi
413
-
414
- local base="https://$host/rest/api/1.0/projects/$project/repos/$slug/pull-requests/$PR_NUM"
396
+ }
415
397
 
416
398
  # Dedupe gate - read pref, default ON. Bitbucket uses the activities feed.
417
399
  local DEDUPE_ENABLED
@@ -420,7 +402,7 @@ post_bitbucket_server() {
420
402
  # Load existing comments on any needs_work post: dedupe needs them when
421
403
  # enabled, and the iteration counter is always derived from them.
422
404
  if [ "$DECISION" = "needs_work" ]; then
423
- load_existing_comments_bitbucket "$host" "$project" "$slug" "$PR_NUM" "$auth_user" "$auth_token"
405
+ load_existing_comments_bitbucket "$host" "$project" "$slug" "$PR_NUM"
424
406
  ITERATION=$(compute_next_iteration)
425
407
  fi
426
408
 
@@ -449,8 +431,9 @@ post_bitbucket_server() {
449
431
  if [ "$line" -gt 0 ] 2>/dev/null; then
450
432
  payload=$(jq -n --arg t "$body" --arg p "$path" --argjson l "$line" \
451
433
  '{text: $t, anchor: {path: $p, line: $l, lineType: "ADDED", fileType: "TO"}}')
452
- http=$(curl -sS -m 30 -K <(bb_auth_cfg "$auth_user" "$auth_token") -X POST \
453
- -H "Content-Type: application/json" "$base/comments" \
434
+ bb_cfg "$base/comments" || { echo "post-pr-review: $(sa_explain)" >&2; return 4; }
435
+ http=$(curl -sS -m 30 --config "$BB_CFG" -X POST \
436
+ -H "Content-Type: application/json" \
454
437
  -d "$payload" -o /dev/null -w '%{http_code}' || echo 000)
455
438
  if [ "$http" = "200" ] || [ "$http" = "201" ]; then
456
439
  inline_ok=1
@@ -461,8 +444,9 @@ post_bitbucket_server() {
461
444
 
462
445
  if [ "$inline_ok" -eq 0 ]; then
463
446
  payload=$(jq -n --arg t "$body" '{text: $t}')
464
- curl -sS -m 30 -K <(bb_auth_cfg "$auth_user" "$auth_token") -X POST \
465
- -H "Content-Type: application/json" "$base/comments" \
447
+ bb_cfg "$base/comments" || { echo "post-pr-review: $(sa_explain)" >&2; return 4; }
448
+ curl -sS -m 30 --config "$BB_CFG" -X POST \
449
+ -H "Content-Type: application/json" \
466
450
  -d "$payload" >/dev/null \
467
451
  || echo "post-pr-review: bitbucket top-level comment failed for $path:$line" >&2
468
452
  fi
@@ -476,8 +460,9 @@ post_bitbucket_server() {
476
460
  esac
477
461
 
478
462
  local http
479
- http=$(curl -sS -m 30 -K <(bb_auth_cfg "$auth_user" "$auth_token") -X PUT \
480
- -H "Content-Type: application/json" "$base/participants/$user_slug" \
463
+ bb_cfg "$base/participants/$user_slug" || { echo "post-pr-review: $(sa_explain)" >&2; return 4; }
464
+ http=$(curl -sS -m 30 --config "$BB_CFG" -X PUT \
465
+ -H "Content-Type: application/json" \
481
466
  -d "$status_payload" -o /dev/null -w '%{http_code}' || echo 000)
482
467
  case "$http" in
483
468
  200|201) ;;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * reviewer-families.mjs - the reviewer families anonymized triage may name.
3
+ *
4
+ * Triage sees `Source A/B/C`, never a model. After it decides, the label map
5
+ * writes a FAMILY back onto each finding for per-reviewer telemetry, and the
6
+ * validator refuses any other value.
7
+ *
8
+ * Both lists are derived from the host registry rather than written out here,
9
+ * so a rung added there is covered without a second edit. A hand-written list
10
+ * fails quietly for a model outside it: nothing rejects the model, it simply
11
+ * gets no family, and a finding with no reviewer passes the validator.
12
+ *
13
+ * Order is load-bearing: rung names come first, so `claude-opus-4.7` is `opus`
14
+ * and not `claude`. The vendor prefix is the fallback for a model whose rung
15
+ * name is not in its id.
16
+ *
17
+ * @module pipeline/lib/reviewer-families
18
+ */
19
+
20
+ import { HOST_IDS, REGISTRY } from "./host.mjs";
21
+
22
+ /**
23
+ * Every family a reviewer slot can produce, rung names first.
24
+ *
25
+ * Derived from the review PANEL and triage slots, not from the rung ladder: a
26
+ * rung the ladder carries but no panel seats cannot author a finding, and
27
+ * accepting it would let the validator pass a reviewer that never ran.
28
+ *
29
+ * A slot naming a model whose id carries a rung name is that rung (one host
30
+ * seats its own build of the same tier). A slot naming anything else is its
31
+ * vendor, because on that host the tier distinction is carried by effort rather
32
+ * than by the model id.
33
+ */
34
+ function buildFamilies(registry = REGISTRY, ids = HOST_IDS) {
35
+ const rungs = [];
36
+ const vendors = [];
37
+ for (const id of ids) {
38
+ const host = registry.hosts[id];
39
+ const ladder = Object.keys(host?.models?.rungs ?? {});
40
+ for (const slot of [...(host?.review?.panel ?? []), host?.review?.triage].filter(Boolean)) {
41
+ if (slot.rung) {
42
+ if (!rungs.includes(slot.rung)) rungs.push(slot.rung);
43
+ continue;
44
+ }
45
+ const model = String(slot.model ?? "").toLowerCase();
46
+ const named = ladder.find((rung) => model.includes(rung));
47
+ if (named) {
48
+ if (!rungs.includes(named)) rungs.push(named);
49
+ continue;
50
+ }
51
+ const prefix = /^([a-z]+)/.exec(model)?.[1];
52
+ if (prefix && !vendors.includes(prefix)) vendors.push(prefix);
53
+ }
54
+ }
55
+ return Object.freeze([...rungs, ...vendors.filter((v) => !rungs.includes(v))]);
56
+ }
57
+
58
+ /** @type {ReadonlyArray<string>} */
59
+ export const FAMILIES = buildFamilies();
60
+
61
+ /**
62
+ * The reviewer family a model name belongs to, or null when none matches.
63
+ *
64
+ * @param {unknown} model
65
+ * @returns {string|null}
66
+ */
67
+ export function familyOf(model) {
68
+ const m = String(model ?? "").toLowerCase();
69
+ return FAMILIES.find((f) => m.includes(f)) ?? null;
70
+ }