@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.
- package/CHANGELOG.md +56 -1
- package/README.md +61 -27
- package/README.tr.md +46 -12
- package/SECURITY.md +3 -3
- package/docs/architecture.md +47 -8
- package/docs/ecosystem.md +20 -18
- package/docs/engineering.md +1 -1
- package/docs/facts.json +8 -6
- package/docs/features.md +59 -15
- package/install/_codex-agents.mjs +13 -8
- package/install/_common.mjs +24 -0
- package/install/_dev-only-files.mjs +4 -0
- package/install/_mcp-register.mjs +6 -2
- package/install/_rewrite-tree.mjs +197 -0
- package/install/codex.mjs +96 -180
- package/install/copilot.mjs +24 -54
- package/install/index.mjs +29 -11
- package/install/templates/codex-instructions.md +21 -5
- package/install/templates/copilot-instructions.md +21 -14
- package/manifest.json +2082 -0
- package/package.json +6 -2
- package/pipeline/commands/multi-agent/SKILL.md +7 -5
- package/pipeline/commands/multi-agent/analysis/SKILL.md +4 -0
- package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
- package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
- package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
- package/pipeline/commands/multi-agent/resume/SKILL.md +2 -0
- package/pipeline/commands/multi-agent/review-rounds/SKILL.md +94 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/sync/SKILL.md +3 -3
- package/pipeline/contract/manifest.json +1 -1
- package/pipeline/contract/types/index.d.ts +1 -0
- package/pipeline/lib/_jira-auth.sh +50 -78
- package/pipeline/lib/_service-account.sh +191 -0
- package/pipeline/lib/credential-inventory.sh +49 -37
- package/pipeline/lib/credential-store.sh +48 -3
- package/pipeline/lib/fetch-confluence.sh +76 -92
- package/pipeline/lib/fetch-crashlytics.sh +30 -59
- package/pipeline/lib/fetch-figma-annotations.sh +9 -9
- package/pipeline/lib/fetch-fortify.sh +77 -81
- package/pipeline/lib/fetch-graylog.sh +38 -77
- package/pipeline/lib/figma-mcp-refresh.sh +23 -4
- package/pipeline/lib/figma-screenshot.sh +7 -8
- package/pipeline/lib/figma-token.sh +39 -46
- package/pipeline/lib/host.mjs +138 -0
- package/pipeline/lib/host.sh +48 -0
- package/pipeline/lib/issue-fetcher.sh +25 -41
- package/pipeline/lib/jira-publish.sh +23 -21
- package/pipeline/lib/local-model.mjs +93 -0
- package/pipeline/lib/md2confluence-v3.py +37 -30
- package/pipeline/lib/model-dispatch.sh +41 -4
- package/pipeline/lib/model-resolve.mjs +58 -0
- package/pipeline/lib/post-pr-review.sh +38 -53
- package/pipeline/lib/reviewer-families.mjs +70 -0
- package/pipeline/lib/service-account.mjs +2131 -0
- package/pipeline/lib/service-account.sh +35 -0
- package/pipeline/lib/usage-names.generated.mjs +3 -0
- package/pipeline/lib/usage-token.mjs +64 -24
- package/pipeline/lib/usage-vocab.mjs +1 -1
- package/pipeline/lib/user-facing.mjs +11 -3
- package/pipeline/lib/vercel-deploy.sh +17 -26
- package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
- package/pipeline/multi-agent-refs/_input-parser.md +1 -1
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
- package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
- package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
- package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
- package/pipeline/multi-agent-refs/channels/generator.md +10 -2
- package/pipeline/multi-agent-refs/channels/menu.md +3 -1
- package/pipeline/multi-agent-refs/channels/preview.md +3 -1
- package/pipeline/multi-agent-refs/channels/reference.md +16 -2
- package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
- package/pipeline/multi-agent-refs/component-dispatch.md +2 -2
- package/pipeline/multi-agent-refs/cross-cli-contract.md +38 -30
- package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +4 -4
- package/pipeline/multi-agent-refs/features/doctor.md +37 -11
- package/pipeline/multi-agent-refs/features/free-models.md +3 -3
- package/pipeline/multi-agent-refs/features/local-model.md +87 -0
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
- package/pipeline/multi-agent-refs/features/product-context.md +6 -5
- package/pipeline/multi-agent-refs/features/review-delta.md +1 -1
- package/pipeline/multi-agent-refs/features/review-rounds.md +40 -0
- package/pipeline/multi-agent-refs/features/rework-escalation.md +5 -4
- package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
- package/pipeline/multi-agent-refs/help/en.md +31 -2
- package/pipeline/multi-agent-refs/help/tr.md +31 -2
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +3 -2
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
- package/pipeline/multi-agent-refs/phases/modes.md +20 -1
- package/pipeline/multi-agent-refs/phases/operations.md +1 -1
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -1
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +7 -3
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +12 -10
- package/pipeline/multi-agent-refs/phases.md +4 -3
- package/pipeline/multi-agent-refs/resume/details.md +2 -0
- package/pipeline/multi-agent-refs/review/panel.md +30 -18
- package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
- package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
- package/pipeline/multi-agent-refs/sync/overview.md +11 -5
- package/pipeline/multi-agent-refs/tracker-contract.md +28 -10
- package/pipeline/office/index.html +4 -4
- package/pipeline/schemas/agent-state.schema.json +19 -1
- package/pipeline/schemas/autopilot-config.schema.json +29 -4
- package/pipeline/schemas/hosts.json +512 -0
- package/pipeline/schemas/hosts.schema.json +310 -0
- package/pipeline/schemas/launch.json +22 -2
- package/pipeline/schemas/launch.schema.json +2 -1
- package/pipeline/schemas/phases.json +21 -3
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +346 -7
- package/pipeline/schemas/token-budget.json +2 -2
- package/pipeline/scripts/.doctor-mut.47076.mjs +2253 -0
- package/pipeline/scripts/_autopilot-config.mjs +67 -4
- package/pipeline/scripts/_autopilot-item.mjs +67 -0
- package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
- package/pipeline/scripts/_cost.mjs +75 -3
- package/pipeline/scripts/analysis-sources.mjs +22 -5
- package/pipeline/scripts/analysis-unattended.mjs +360 -0
- package/pipeline/scripts/anonymize-findings.mjs +3 -7
- package/pipeline/scripts/autopilot-arming.mjs +19 -10
- package/pipeline/scripts/autopilot-intake.mjs +124 -27
- package/pipeline/scripts/autopilot-menubar.swift +7 -0
- package/pipeline/scripts/autopilot-runner.mjs +77 -48
- package/pipeline/scripts/autopilot-status.sh +32 -9
- package/pipeline/scripts/bulk-read.sh +37 -5
- package/pipeline/scripts/confluence-readback.mjs +15 -7
- package/pipeline/scripts/cost-table.json +65 -25
- package/pipeline/scripts/doctor.mjs +119 -32
- package/pipeline/scripts/entry-mode.mjs +101 -0
- package/pipeline/scripts/estimate.mjs +30 -16
- package/pipeline/scripts/feedback-send.mjs +11 -8
- package/pipeline/scripts/gen-facts.mjs +16 -13
- package/pipeline/scripts/jira-attach.sh +23 -28
- package/pipeline/scripts/jira-search.sh +5 -21
- package/pipeline/scripts/launch-request.mjs +15 -9
- package/pipeline/scripts/migrate-prefs.mjs +56 -0
- package/pipeline/scripts/phase-tracker.sh +146 -38
- package/pipeline/scripts/priority-review.mjs +14 -7
- package/pipeline/scripts/product-context.mjs +26 -7
- package/pipeline/scripts/prune-logs.sh +4 -2
- package/pipeline/scripts/report-file.mjs +285 -0
- package/pipeline/scripts/review-rounds.mjs +592 -0
- package/pipeline/scripts/rework-escalation.mjs +26 -7
- package/pipeline/scripts/service-read.mjs +19 -17
- package/pipeline/scripts/skill-siblings.mjs +17 -1
- package/pipeline/scripts/status-overview.mjs +20 -10
- package/pipeline/scripts/uninstall.mjs +145 -57
- package/pipeline/scripts/usage-register.mjs +34 -11
- package/pipeline/scripts/usage-report.mjs +31 -26
- package/pipeline/scripts/validate-state.mjs +19 -11
- package/pipeline/scripts/validate-triage.mjs +11 -1
- package/pipeline/scripts/work-items.mjs +25 -28
- package/pipeline/scripts/write-store-config.mjs +37 -11
- package/pipeline/skills/.skill-manifest.json +11 -7
- package/pipeline/skills/.skills-index.json +13 -2
- package/pipeline/skills/shared/README.md +4 -3
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +14 -6
- package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
- package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
- package/pipeline/skills/shared/core/multi-agent-resume/SKILL.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-review-rounds/SKILL.md +92 -0
- package/pipeline/skills/shared/core/multi-agent-sync/SKILL.md +3 -3
- package/pipeline/skills/skills-index.md +2 -1
- package/pipeline/lib/credential-resolve.mjs +0 -75
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
// anyone can install off npm. A person can paste the one line they think
|
|
15
15
|
// matters; a script cannot know which line that is.
|
|
16
16
|
//
|
|
17
|
-
// Auth reuses the usage ingest token
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
17
|
+
// Auth reuses the usage ingest token this machine already registered, resolved
|
|
18
|
+
// through lib/usage-token.mjs for this endpoint and no other, so nothing new
|
|
19
|
+
// has to be onboarded. Unlike usage telemetry, `optOut` does NOT silence this:
|
|
20
|
+
// telemetry is passive collection, feedback is a deliberate act by the person
|
|
21
|
+
// running the command, and silently dropping something a user chose to send is
|
|
22
|
+
// worse than not offering the command.
|
|
22
23
|
//
|
|
23
24
|
// Usage:
|
|
24
25
|
// node feedback-send.mjs --text "<message>" [--kind bug|idea|question]
|
|
@@ -78,8 +79,10 @@ function host() {
|
|
|
78
79
|
return "unknown";
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
// The endpoint is passed in because it is the destination the token is about to
|
|
83
|
+
// reach: a usage account that does not cover it hands nothing out.
|
|
84
|
+
function resolveToken(endpoint) {
|
|
85
|
+
return resolveUsageToken(readPrefs(), { endpoint });
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
async function main() {
|
|
@@ -121,7 +124,7 @@ async function main() {
|
|
|
121
124
|
process.exit(1);
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
const token = resolveToken();
|
|
127
|
+
const token = resolveToken(endpoint);
|
|
125
128
|
if (!token) {
|
|
126
129
|
process.stderr.write(
|
|
127
130
|
`ERROR: no ingest token. Run ${hostCommand("update", import.meta.dirname)} once (it registers one) or ${hostCommand("setup", import.meta.dirname)}.\n`,
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
* skillCount a count of pipeline/skills/shared/external/<name>/SKILL.md
|
|
14
14
|
* skillCountAll every SKILL.md under pipeline/skills, at any depth
|
|
15
15
|
* agentCount a count of pipeline/agents/*.md
|
|
16
|
-
* hosts
|
|
16
|
+
* hosts every host the registry declares, by label
|
|
17
17
|
* toolCount the toolkit's own tools/list response, when reachable
|
|
18
18
|
* toolCategories that same response, grouped by the prefix in each tool name
|
|
19
19
|
* pluginSkillCount every SKILL.md in the plugin marketplace, when checked out,
|
|
20
20
|
* except the aliases a rename leaves under the old name
|
|
21
21
|
* reworkCap the maximum pipeline/schemas/prefs.schema.json allows for
|
|
22
|
-
* global.
|
|
22
|
+
* global.review.maxReworkCycles
|
|
23
|
+
* reworkDefault the default that same schema field carries
|
|
23
24
|
* version package.json
|
|
24
25
|
*
|
|
25
26
|
* Counts come from the filesystem at the moment of writing, never from a README
|
|
@@ -42,6 +43,7 @@ import { fileURLToPath } from "node:url";
|
|
|
42
43
|
import { spawnSync } from "node:child_process";
|
|
43
44
|
import { siblingsParent } from "./_sibling-root.mjs";
|
|
44
45
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
46
|
+
import { HOST_IDS, host } from "../lib/host.mjs";
|
|
45
47
|
import { SERVER_CHECKOUT_DIRS } from "../lib/mcp-rename.mjs";
|
|
46
48
|
|
|
47
49
|
exitOnHelp(import.meta.url);
|
|
@@ -89,17 +91,20 @@ try {
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
let reworkCap;
|
|
94
|
+
let reworkDefault;
|
|
92
95
|
try {
|
|
93
96
|
const prefsSchema = JSON.parse(
|
|
94
97
|
readFileSync(join(ROOT, "pipeline", "schemas", "prefs.schema.json"), "utf8"),
|
|
95
98
|
);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
const field = prefsSchema.properties?.global?.properties?.review?.properties?.maxReworkCycles;
|
|
100
|
+
reworkCap = field?.maximum;
|
|
101
|
+
reworkDefault = field?.default;
|
|
99
102
|
} catch (err) {
|
|
100
103
|
die(`cannot read the prefs schema - ${err.message}`);
|
|
101
104
|
}
|
|
102
105
|
if (!Number.isInteger(reworkCap)) die("prefs schema has no integer maximum for maxReworkCycles");
|
|
106
|
+
if (!Number.isInteger(reworkDefault))
|
|
107
|
+
die("prefs schema has no integer default for maxReworkCycles");
|
|
103
108
|
|
|
104
109
|
let pkg;
|
|
105
110
|
try {
|
|
@@ -218,6 +223,7 @@ const facts = {
|
|
|
218
223
|
phaseCount: contract.phases.length,
|
|
219
224
|
modes: Object.fromEntries(Object.entries(contract.modes).map(([k, v]) => [k, v.phases])),
|
|
220
225
|
reworkCap,
|
|
226
|
+
reworkDefault,
|
|
221
227
|
commandCount: countSkillDirs("pipeline/commands/multi-agent"),
|
|
222
228
|
// Two populations: `skillCount` is the external set a user installs;
|
|
223
229
|
// `skillCountAll` is every SKILL.md the repo ships, mirrors included. The site
|
|
@@ -228,14 +234,11 @@ const facts = {
|
|
|
228
234
|
// Both are headline figures on the site; generated from pipeline/agents and
|
|
229
235
|
// install/, so the sub-agent count and the host list follow what ships.
|
|
230
236
|
agentCount: readdirSync(join(ROOT, "pipeline", "agents")).filter((f) => f.endsWith(".md")).length,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
f.replace(".mjs", "")
|
|
237
|
-
],
|
|
238
|
-
)
|
|
237
|
+
// From the host registry, not from the files in install/: a host whose
|
|
238
|
+
// installer is another host's (the local one runs the Codex installer) has
|
|
239
|
+
// no file of its own, and a list built from filenames leaves it out of every
|
|
240
|
+
// sentence that counts hosts.
|
|
241
|
+
hosts: HOST_IDS.map((id) => host(id).label)
|
|
239
242
|
.filter(Boolean)
|
|
240
243
|
.sort(),
|
|
241
244
|
toolCount,
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
# jira-attach.sh <issue-key> <file> [file...]
|
|
14
14
|
#
|
|
15
15
|
# Env:
|
|
16
|
-
# JIRA_BASE https://host -
|
|
17
|
-
#
|
|
16
|
+
# JIRA_BASE https://host - names which account to use, when more than
|
|
17
|
+
# one is configured. Otherwise the account resolver picks.
|
|
18
|
+
# JIRA_TOKEN_KEY a store item name, when the account is to be named by item.
|
|
19
|
+
# JIRA_TOKEN a token for a run with no configured account.
|
|
18
20
|
#
|
|
19
21
|
# Output (stdout), one line per uploaded file:
|
|
20
22
|
# <filename>\t<content-url>
|
|
@@ -30,32 +32,21 @@ shift 2>/dev/null || true
|
|
|
30
32
|
exit 2
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
PREFS="$HOME/.claude/multi-agent-preferences.json"
|
|
34
|
-
|
|
35
35
|
_MA_JA_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
36
36
|
# shellcheck source=/dev/null
|
|
37
37
|
if [ -f "$_MA_JA_HERE/../lib/user-facing.sh" ]; then . "$_MA_JA_HERE/../lib/user-facing.sh"; else . "$HOME/.claude/lib/user-facing.sh"; fi
|
|
38
|
+
# shellcheck source=/dev/null
|
|
39
|
+
if [ -f "$_MA_JA_HERE/../lib/_service-account.sh" ]; then . "$_MA_JA_HERE/../lib/_service-account.sh"; else . "$HOME/.claude/lib/_service-account.sh"; fi
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try{const g=(JSON.parse(fs.readFileSync(process.argv[1],"utf8")).global||{});
|
|
43
|
-
process.stdout.write((g.hosts||{}).jira||"")}catch{process.stdout.write("")}
|
|
44
|
-
' "$PREFS" 2>/dev/null)
|
|
45
|
-
fi
|
|
46
|
-
[ -n "$JIRA_BASE" ] || { echo "jira-attach: no Jira host (set JIRA_BASE or prefs hosts.jira)" >&2; exit 2; }
|
|
47
|
-
case "$JIRA_BASE" in http*) ;; *) JIRA_BASE="https://$JIRA_BASE" ;; esac
|
|
41
|
+
SA_PICK=()
|
|
42
|
+
if [ -n "${JIRA_BASE:-}" ]; then SA_PICK+=(--host "$JIRA_BASE"); fi
|
|
43
|
+
if [ -n "${JIRA_TOKEN_KEY:-}" ]; then SA_PICK+=(--item "$JIRA_TOKEN_KEY"); fi
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
' "$PREFS" 2>/dev/null)
|
|
55
|
-
[ -n "$KEY" ] || { echo "jira-attach: keychainMapping.jira is not set - onboard it via $(ma_command setup)" >&2; exit 2; }
|
|
56
|
-
JIRA_TOKEN=$(bash "$HOME/.claude/lib/credential-store.sh" get "$KEY" 2>/dev/null)
|
|
57
|
-
fi
|
|
58
|
-
[ -n "${JIRA_TOKEN:-}" ] || { echo "jira-attach: no Jira token - onboard it via $(ma_command setup)" >&2; exit 2; }
|
|
45
|
+
JIRA_BASE="$(sa_base jira "${SA_PICK[@]+"${SA_PICK[@]}"}")" || {
|
|
46
|
+
echo "jira-attach: $(sa_explain)" >&2
|
|
47
|
+
exit 2
|
|
48
|
+
}
|
|
49
|
+
[ -n "$JIRA_BASE" ] || { echo "jira-attach: no Jira account - add one with $(ma_command setup)" >&2; exit 2; }
|
|
59
50
|
|
|
60
51
|
RC=0
|
|
61
52
|
for f in "$@"; do
|
|
@@ -64,12 +55,16 @@ for f in "$@"; do
|
|
|
64
55
|
RC=3
|
|
65
56
|
continue
|
|
66
57
|
fi
|
|
67
|
-
# The
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
# The config carries the URL as well as the credential, so the two cannot be
|
|
59
|
+
# separated: a redirect is refused rather than followed with the header on.
|
|
60
|
+
cfg=$(sa_cfg jira "$JIRA_BASE/rest/api/2/issue/$ISSUE/attachments" bearer \
|
|
61
|
+
"${SA_PICK[@]+"${SA_PICK[@]}"}") || {
|
|
62
|
+
echo "jira-attach: $(sa_explain)" >&2
|
|
63
|
+
exit 2
|
|
64
|
+
}
|
|
65
|
+
resp=$(curl -sS -X POST --config "$cfg" \
|
|
70
66
|
-H "X-Atlassian-Token: no-check" \
|
|
71
|
-
-F "file=@$f"
|
|
72
|
-
"$JIRA_BASE/rest/api/2/issue/$ISSUE/attachments" 2>/dev/null)
|
|
67
|
+
-F "file=@$f" 2>/dev/null)
|
|
73
68
|
line=$(printf '%s' "$resp" | node -e '
|
|
74
69
|
let b="";process.stdin.on("data",d=>b+=d).on("end",()=>{
|
|
75
70
|
try{
|
|
@@ -34,32 +34,16 @@ while [ $# -gt 0 ]; do
|
|
|
34
34
|
done
|
|
35
35
|
[ -n "$JQL" ] || { echo "jira-search: --jql is required" >&2; exit 2; }
|
|
36
36
|
|
|
37
|
-
PREFS="${MA_PREFS_FILE:-$HOME/.claude/multi-agent-preferences.json}"
|
|
38
|
-
[ -f "$PREFS" ] || { echo "jira-search: no preferences file" >&2; exit 1; }
|
|
39
37
|
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
import json, sys, shlex
|
|
45
|
-
try:
|
|
46
|
-
g = json.load(open(sys.argv[1]))["global"]
|
|
47
|
-
except Exception:
|
|
48
|
-
g = {}
|
|
49
|
-
host = (g.get("hosts") or {}).get("jira", "")
|
|
50
|
-
key = (g.get("keychainMapping") or {}).get("jira", "")
|
|
51
|
-
print(f"ACCOUNT_JIRA_HOST={shlex.quote(host)}")
|
|
52
|
-
print(f"ACCOUNT_JIRA_TOKEN_KEY={shlex.quote(key)}")
|
|
53
|
-
PY
|
|
54
|
-
)"
|
|
38
|
+
# Which Jira account answers, and where its credential lives, is the account
|
|
39
|
+
# resolver's question. ACCOUNT_JIRA_HOST and ACCOUNT_JIRA_TOKEN_KEY are still
|
|
40
|
+
# honoured when a caller sets them: they name an account rather than replacing
|
|
41
|
+
# the check that it may be sent to.
|
|
55
42
|
export ACCOUNT_JIRA_HOST ACCOUNT_JIRA_TOKEN_KEY
|
|
56
|
-
[ -n "$ACCOUNT_JIRA_HOST" ] && [ -n "$ACCOUNT_JIRA_TOKEN_KEY" ] || {
|
|
57
|
-
echo "jira-search: jira is not onboarded (host or keychainMapping.jira missing)" >&2
|
|
58
|
-
exit 1
|
|
59
|
-
}
|
|
60
43
|
|
|
61
44
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
62
45
|
for cand in "$HERE/../lib/issue-fetcher.sh" "$HOME/.claude/lib/issue-fetcher.sh"; do
|
|
46
|
+
# shellcheck source=/dev/null
|
|
63
47
|
[ -f "$cand" ] && { . "$cand"; break; }
|
|
64
48
|
done
|
|
65
49
|
command -v jira_search >/dev/null 2>&1 || {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
*
|
|
37
37
|
* - a structured reference: a Jira key, a GitHub issue URL
|
|
38
38
|
* (https://github.com/<owner>/<repo>/issues/<n>), repo#N, #N, or a Jira
|
|
39
|
-
* URL on the
|
|
40
|
-
*
|
|
39
|
+
* URL on the host this machine's Jira account names. It reaches the
|
|
40
|
+
* prompt as it is;
|
|
41
41
|
* - free text (the bearer route, the CLI, and a request file Phase 0
|
|
42
42
|
* reads): one line of at most FREE_TEXT_MAX printable
|
|
43
43
|
* characters, no quote, backslash or backtick, reaching the prompt as one
|
|
@@ -109,7 +109,8 @@ import { lockTimeoutFrom, updateJsonFileSync } from "../lib/json-file-lock.mjs";
|
|
|
109
109
|
import { unattendedSettingsPath } from "../lib/unattended-settings-location.mjs";
|
|
110
110
|
import { isUnattended } from "../lib/unattended.mjs";
|
|
111
111
|
import { listRuns, logsRoot } from "./_run-paths.mjs";
|
|
112
|
-
import {
|
|
112
|
+
import { prefsPath, readPrefsFile } from "../lib/prefs-value.mjs";
|
|
113
|
+
import { selectAccount } from "../lib/service-account.mjs";
|
|
113
114
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
114
115
|
|
|
115
116
|
exitOnHelp(import.meta.url);
|
|
@@ -173,14 +174,19 @@ const normalizeHost = (h) =>
|
|
|
173
174
|
.replace(/:.*$/, "")
|
|
174
175
|
.replace(/\.$/, "");
|
|
175
176
|
|
|
176
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* The host of this machine's Jira account, or "" when no account answers.
|
|
179
|
+
*
|
|
180
|
+
* A Jira URL is a structured reference only on that host; anything else is
|
|
181
|
+
* free text. The account resolver decides, so a machine with two Jira
|
|
182
|
+
* instances is asked rather than guessed at, and a file that names no account
|
|
183
|
+
* makes every Jira URL free text instead of a reference to a host nobody
|
|
184
|
+
* configured.
|
|
185
|
+
*/
|
|
177
186
|
export function configuredJiraHost(env = process.env) {
|
|
178
187
|
const file = prefsPath(env, { envVar: "MA_PREFS_FILE" });
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} catch {
|
|
182
|
-
return "";
|
|
183
|
-
}
|
|
188
|
+
const chosen = selectAccount({ service: "jira" }, { env, prefs: readPrefsFile(file).prefs });
|
|
189
|
+
return chosen.ok ? (chosen.account.hosts[0] ?? "") : "";
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
/** The words the dispatcher's routing table routes on: the first word of each row's pattern. */
|
|
@@ -19,6 +19,7 @@ import { canonicalEndpoint } from "../lib/usage-endpoint.mjs";
|
|
|
19
19
|
import { lockTimeoutFrom, withFileLockSync, writeJsonAtomicSync } from "../lib/json-file-lock.mjs";
|
|
20
20
|
import { prefsFileIn } from "../lib/prefs-value.mjs";
|
|
21
21
|
import { migrateServerPrefs } from "../lib/mcp-rename.mjs";
|
|
22
|
+
import { effectiveAccounts, projectLegacy, reconcileAccounts } from "../lib/service-account.mjs";
|
|
22
23
|
import { ArgsError, parseArgs as parseArgv } from "../lib/args.mjs";
|
|
23
24
|
|
|
24
25
|
const DEFAULT_FILE = prefsFileIn(os.homedir());
|
|
@@ -227,6 +228,55 @@ function defaultTriageCrossCheck() {
|
|
|
227
228
|
return { enabled: false, samplePct: 10, model: "sonnet", blockOnDisagreement: false };
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Derive `serviceAccounts[]` from the flat credential keys.
|
|
233
|
+
*
|
|
234
|
+
* What it will not do is guess. Where the file holds one token and one host for
|
|
235
|
+
* a service, that pair is the only one the data allows and it is written. Where
|
|
236
|
+
* it holds more of either and nothing says which goes with which, the entry is
|
|
237
|
+
* written with `unresolved` instead of a host, which the resolver refuses and
|
|
238
|
+
* setup asks a person about. A token sent to a host nobody paired it with is
|
|
239
|
+
* the failure this whole change exists to prevent, so the migration may not
|
|
240
|
+
* introduce one.
|
|
241
|
+
*
|
|
242
|
+
* Idempotent: a second run reconciles its own output and finds nothing to say.
|
|
243
|
+
*/
|
|
244
|
+
function buildServiceAccounts(out, changes) {
|
|
245
|
+
const g = out.global;
|
|
246
|
+
const before = JSON.stringify(g.serviceAccounts ?? null);
|
|
247
|
+
const { accounts, notes } = reconcileAccounts(out);
|
|
248
|
+
if (JSON.stringify(accounts) !== before) {
|
|
249
|
+
g.serviceAccounts = accounts;
|
|
250
|
+
const unpaired = accounts.filter((a) => a.unresolved).length;
|
|
251
|
+
changes.push(
|
|
252
|
+
`serviceAccounts: ${accounts.length} account(s) derived from keychainMapping and hosts` +
|
|
253
|
+
(unpaired ? `, ${unpaired} waiting for a host` : ""),
|
|
254
|
+
);
|
|
255
|
+
for (const note of notes) changes.push(`serviceAccounts: ${note}`);
|
|
256
|
+
}
|
|
257
|
+
if (!Array.isArray(g.serviceOptOuts)) {
|
|
258
|
+
g.serviceOptOuts = [];
|
|
259
|
+
changes.push("added empty serviceOptOuts");
|
|
260
|
+
}
|
|
261
|
+
// identities[] is deliberately left byte-identical. An identity id is derived
|
|
262
|
+
// from the name on every read, so an account can point at one without the
|
|
263
|
+
// file carrying it; it is persisted the first time a person adds an account
|
|
264
|
+
// through setup, which is a write they asked for. Renaming an identity before
|
|
265
|
+
// that happens orphans the link, and the resolver says so and refuses rather
|
|
266
|
+
// than quietly binding the account to whoever now answers to that name.
|
|
267
|
+
// The flat keys stay the projection of the accounts, so everything still
|
|
268
|
+
// reading them keeps reading the same answer. Only absent keys are filled;
|
|
269
|
+
// a value already there is left alone, because this step has no business
|
|
270
|
+
// overruling something a person set.
|
|
271
|
+
const legacy = projectLegacy(effectiveAccounts(out).accounts);
|
|
272
|
+
for (const [key, value] of Object.entries(legacy.hosts)) {
|
|
273
|
+
if (!g.hosts?.[key]) {
|
|
274
|
+
g.hosts = { ...g.hosts, [key]: value };
|
|
275
|
+
changes.push(`hosts.${key}: filled from the account that holds it`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
230
280
|
function migrate(prefs) {
|
|
231
281
|
const changes = [];
|
|
232
282
|
const out = JSON.parse(JSON.stringify(prefs)); // deep clone
|
|
@@ -470,6 +520,12 @@ function migrate(prefs) {
|
|
|
470
520
|
// 15. The MCP server renamed: guard rules and devToolkit fields that name it.
|
|
471
521
|
migrateServerPrefs(out, changes);
|
|
472
522
|
|
|
523
|
+
// 16. serviceAccounts[]: the host, the secret and the identity of one
|
|
524
|
+
// credential on one entry. Runs last, because it reads the flat keys every
|
|
525
|
+
// step above may still have been fixing. Idempotent, and it rewrites no
|
|
526
|
+
// legacy value: the flat keys stay exactly where everything else reads them.
|
|
527
|
+
buildServiceAccounts(out, changes);
|
|
528
|
+
|
|
473
529
|
return { out, changes, alreadyMigrated: changes.length === 0 };
|
|
474
530
|
}
|
|
475
531
|
|