@mmerterden/multi-agent-pipeline 23.7.0 → 24.1.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 +60 -1
- package/README.md +59 -24
- package/README.tr.md +43 -8
- package/SECURITY.md +3 -3
- package/docs/architecture.md +41 -4
- package/docs/ecosystem.md +15 -13
- package/docs/facts.json +5 -4
- package/docs/features.md +67 -15
- package/install/_codex-agents.mjs +13 -8
- package/install/_common.mjs +24 -0
- package/install/_dev-only-files.mjs +5 -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 +2083 -0
- package/package.json +8 -2
- package/pipeline/commands/multi-agent/SKILL.md +5 -4
- package/pipeline/commands/multi-agent/analysis/SKILL.md +5 -1
- 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/stack/SKILL.md +1 -1
- package/pipeline/contract/CHANGELOG.md +15 -0
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +6 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +21 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +18 -3
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +31 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +31 -1
- package/pipeline/contract/fixtures/runs-running.json +16 -1
- package/pipeline/contract/manifest.json +14 -14
- package/pipeline/contract/types/index.d.ts +20 -1
- 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-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/analysis/intake.md +2 -0
- package/pipeline/multi-agent-refs/analysis/render.md +12 -1
- 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/cross-cli-contract.md +35 -27
- 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/service-accounts.md +233 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
- package/pipeline/multi-agent-refs/help/en.md +36 -1
- package/pipeline/multi-agent-refs/help/tr.md +34 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +2 -1
- 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/phase-0-init.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-4-commit.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +13 -11
- package/pipeline/multi-agent-refs/phases.md +4 -3
- 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 +64 -20
- package/pipeline/office/index.html +77 -4
- package/pipeline/schemas/activity.schema.json +63 -4
- 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/now-lines.json +103 -0
- package/pipeline/schemas/now-lines.schema.json +42 -0
- package/pipeline/schemas/phases.json +19 -1
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +331 -4
- package/pipeline/schemas/runs-index.schema.json +22 -1
- 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/_contract-core.mjs +1 -1
- package/pipeline/scripts/_cost.mjs +75 -3
- package/pipeline/scripts/activity-snapshot.mjs +27 -1
- 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 +7 -9
- 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 +226 -50
- 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/render-work-summary.sh +51 -1
- package/pipeline/scripts/report-file.mjs +285 -0
- package/pipeline/scripts/rework-escalation.mjs +19 -4
- package/pipeline/scripts/runs-index.mjs +2 -1
- 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-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 +4 -4
- package/pipeline/skills/.skills-index.json +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +11 -3
- 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/lib/credential-resolve.mjs +0 -75
|
@@ -15,14 +15,17 @@
|
|
|
15
15
|
# the person reading the ticket never needed the URL.
|
|
16
16
|
#
|
|
17
17
|
# Required configuration:
|
|
18
|
-
#
|
|
19
|
-
#
|
|
18
|
+
# a Fortify account - its host is the SSC, its token slot
|
|
19
|
+
# holds the API token; add one with
|
|
20
|
+
# /multi-agent:setup
|
|
20
21
|
# prefs.global.fortify.versionIds[] - project versions searched, in order,
|
|
21
22
|
# when only an instance id is known
|
|
22
23
|
#
|
|
23
24
|
# Optional env:
|
|
24
25
|
# FORTIFY_TIMEOUT_SECONDS default 25
|
|
25
|
-
# FORTIFY_HOST_OVERRIDE
|
|
26
|
+
# FORTIFY_HOST_OVERRIDE names which account to use, when more than one is
|
|
27
|
+
# configured. It still has to be a host an account
|
|
28
|
+
# covers: an override picks, it does not excuse.
|
|
26
29
|
# FORTIFY_AUTH_SCHEME auto|bearer|fortifytoken (default: auto)
|
|
27
30
|
#
|
|
28
31
|
# Output (stdout, single JSON object):
|
|
@@ -46,8 +49,9 @@
|
|
|
46
49
|
# 2 missing/expired credential (orchestrator handles the Save Flow)
|
|
47
50
|
# 3 network/auth failure
|
|
48
51
|
# 4 bad usage
|
|
49
|
-
# 6 not configured (
|
|
50
|
-
# lookup with no prefs.global.fortify.versionIds
|
|
52
|
+
# 6 not configured (no Fortify account, no account covering the host asked
|
|
53
|
+
# for, or an instance-id-only lookup with no prefs.global.fortify.versionIds
|
|
54
|
+
# to search)
|
|
51
55
|
#
|
|
52
56
|
# Phase 3 review gate contract:
|
|
53
57
|
# Critical > 0 → blocking=true, reason="critical-findings"
|
|
@@ -79,24 +83,51 @@ while [ $# -gt 0 ]; do
|
|
|
79
83
|
esac
|
|
80
84
|
done
|
|
81
85
|
|
|
82
|
-
#
|
|
86
|
+
# Which SSC this run talks to, and with which credential, is one decision: the
|
|
87
|
+
# account resolver makes it, and writes the credential only into a config
|
|
88
|
+
# pinned to the URL it checked.
|
|
83
89
|
PREFS="$HOME/.claude/multi-agent-preferences.json"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
")
|
|
90
|
+
_MA_FF_HERE="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
91
|
+
# shellcheck source=/dev/null
|
|
92
|
+
if [ -f "$_MA_FF_HERE/_service-account.sh" ]; then
|
|
93
|
+
. "$_MA_FF_HERE/_service-account.sh"
|
|
94
|
+
elif [ -f "$HOME/.claude/lib/_service-account.sh" ]; then
|
|
95
|
+
. "$HOME/.claude/lib/_service-account.sh"
|
|
96
|
+
else
|
|
97
|
+
printf '%s\n' '{"status":"blocked","reason":"missing-credential-helper","service":"fortify"}' >&2
|
|
98
|
+
exit 2
|
|
94
99
|
fi
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
|
|
101
|
+
SA_PICK=()
|
|
102
|
+
if [ -n "${FORTIFY_HOST_OVERRIDE:-}" ]; then
|
|
103
|
+
SA_PICK+=(--host "${FORTIFY_HOST_OVERRIDE%/}")
|
|
98
104
|
fi
|
|
99
|
-
|
|
105
|
+
|
|
106
|
+
fortify_blocked() {
|
|
107
|
+
local reason code
|
|
108
|
+
case "$(sa_code)" in
|
|
109
|
+
host-mismatch|no-account-for-target|identity-mismatch|insecure-url)
|
|
110
|
+
reason="host-not-allowed"; code=6 ;;
|
|
111
|
+
not-configured|unknown-account)
|
|
112
|
+
# No account exists. That is a credential still to be saved when
|
|
113
|
+
# something says where this SSC is - the file, or the caller's own
|
|
114
|
+
# override - and a missing configuration when nothing does.
|
|
115
|
+
if [ -n "${FORTIFY_HOST_OVERRIDE:-}" ] || [ "$(sa_field hostKnown)" = "true" ]; then
|
|
116
|
+
reason="missing-token"; code=2
|
|
117
|
+
else
|
|
118
|
+
reason="host-not-configured"; code=6
|
|
119
|
+
fi ;;
|
|
120
|
+
prefs-unreadable|invalid-config)
|
|
121
|
+
reason="host-not-configured"; code=6 ;;
|
|
122
|
+
store-unavailable)
|
|
123
|
+
reason="missing-credential-helper"; code=2 ;;
|
|
124
|
+
*)
|
|
125
|
+
reason="missing-token"; code=2 ;;
|
|
126
|
+
esac
|
|
127
|
+
printf '%s\n' '{"status":"blocked","reason":"'"$reason"'","service":"fortify","expected_pref":"global.hosts.fortify"}' >&2
|
|
128
|
+
exit "$code"
|
|
129
|
+
}
|
|
130
|
+
|
|
100
131
|
|
|
101
132
|
# Parse URL components when present.
|
|
102
133
|
if [ -n "$URL" ] && [ -z "$VERSION_ID" ]; then
|
|
@@ -144,78 +175,43 @@ if [ -z "$VERSION_ID" ] && [ -z "$VERSION_CANDIDATES" ]; then
|
|
|
144
175
|
exit 6
|
|
145
176
|
fi
|
|
146
177
|
|
|
147
|
-
#
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
p = json.load(open('$PREFS'))
|
|
154
|
-
print(p.get('global', {}).get('keychainMapping', {}).get('fortify') or '')
|
|
155
|
-
except Exception:
|
|
156
|
-
print('')
|
|
157
|
-
")
|
|
158
|
-
fi
|
|
159
|
-
[ -z "$TOKEN_KEY" ] && TOKEN_KEY="${USER}_Fortify_Access_Token"
|
|
160
|
-
|
|
161
|
-
# Locate the resolver with an existence check, not a `.`-chain.
|
|
162
|
-
#
|
|
163
|
-
# Sourcing a file that does not exist aborts the shell under `set -e` - `||` included -
|
|
164
|
-
# so `. <candidate> || . <candidate> || { error }` reaches neither its later candidates
|
|
165
|
-
# nor its error branch. Every fetcher used that shape starting from `$HOME/.claude/...`,
|
|
166
|
-
# so on a Copilot-only or Codex-only install they all died with a bare exit 1 and no
|
|
167
|
-
# message. Reordering does not help: whichever candidate is absent aborts at that point.
|
|
168
|
-
# Checking for the file before sourcing it is the only safe form.
|
|
169
|
-
for _cred_resolver in \
|
|
170
|
-
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/credential-store-resolver.sh" \
|
|
171
|
-
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/../lib" 2>/dev/null && pwd)/credential-store-resolver.sh" \
|
|
172
|
-
"$HOME/.claude/lib/credential-store-resolver.sh" \
|
|
173
|
-
"$HOME/.copilot/lib/credential-store-resolver.sh" \
|
|
174
|
-
"$HOME/.codex/lib/credential-store-resolver.sh"; do
|
|
175
|
-
[ -f "$_cred_resolver" ] || continue
|
|
176
|
-
# shellcheck source=/dev/null
|
|
177
|
-
. "$_cred_resolver" 2>/dev/null || true
|
|
178
|
-
# `if`, not `[ ... ] && break`: the latter is the loop body's last command and returns
|
|
179
|
-
# 1 when CRED_STORE is still empty, which under `set -e` kills the loop on the first
|
|
180
|
-
# candidate that does not resolve - the very case the loop exists to survive.
|
|
181
|
-
if [ -n "${CRED_STORE:-}" ]; then break; fi
|
|
182
|
-
done
|
|
183
|
-
unset _cred_resolver
|
|
184
|
-
if [ -z "${CRED_STORE:-}" ]; then
|
|
185
|
-
printf '%s\n' '{"status":"blocked","reason":"missing-credential-helper","service":"fortify","expected_key":"'"$TOKEN_KEY"'"}' >&2
|
|
186
|
-
exit 2
|
|
187
|
-
fi
|
|
188
|
-
|
|
189
|
-
TOKEN=$("$CRED_STORE" get "$TOKEN_KEY" 2>/dev/null || true)
|
|
190
|
-
if [ -z "$TOKEN" ]; then
|
|
191
|
-
printf '%s\n' '{"status":"blocked","reason":"missing-token","service":"fortify","expected_key":"'"$TOKEN_KEY"'"}' >&2
|
|
192
|
-
exit 2
|
|
178
|
+
# Settled after the invocation is known to be well formed, so a usage error is
|
|
179
|
+
# reported as one rather than as a credential problem.
|
|
180
|
+
HOST="$(sa_host fortify "${SA_PICK[@]+"${SA_PICK[@]}"}")" || fortify_blocked
|
|
181
|
+
if [ -z "$HOST" ]; then
|
|
182
|
+
printf '%s\n' '{"status":"blocked","reason":"host-not-configured","service":"fortify","expected_pref":"global.hosts.fortify"}' >&2
|
|
183
|
+
exit 6
|
|
193
184
|
fi
|
|
194
185
|
|
|
195
186
|
API_BASE="https://$HOST/ssc/api/v1"
|
|
196
187
|
|
|
188
|
+
# Settled before the first request, outside any command substitution, so a
|
|
189
|
+
# missing credential exits with the contract's own status rather than reading
|
|
190
|
+
# as an authentication failure later.
|
|
191
|
+
sa_cfg fortify "$API_BASE/projectVersions" bearer "${SA_PICK[@]+"${SA_PICK[@]}"}" >/dev/null || fortify_blocked
|
|
192
|
+
|
|
197
193
|
fortify_get() {
|
|
198
194
|
# Usage: fortify_get <path-relative-to-API_BASE>
|
|
199
195
|
local path="$1"
|
|
200
196
|
local url="$API_BASE/$path"
|
|
201
|
-
local resp http
|
|
197
|
+
local resp http cfg
|
|
198
|
+
local -a schemes
|
|
202
199
|
case "$AUTH_SCHEME" in
|
|
203
|
-
bearer) schemes=
|
|
204
|
-
fortifytoken) schemes=
|
|
205
|
-
*) schemes=
|
|
200
|
+
bearer) schemes=(bearer) ;;
|
|
201
|
+
fortifytoken) schemes=(fortify-token) ;;
|
|
202
|
+
*) schemes=(bearer fortify-token) ;;
|
|
206
203
|
esac
|
|
207
|
-
for s in $schemes; do
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
# token never appears in argv (argv is visible to ps).
|
|
204
|
+
for s in "${schemes[@]}"; do
|
|
205
|
+
# A refusal here cannot exit: this function is called from a command
|
|
206
|
+
# substitution, where an exit ends only the subshell. The account was
|
|
207
|
+
# already settled before the first request, so this reads as auth failure.
|
|
208
|
+
cfg="$(sa_cfg fortify "$url" "$s" "${SA_PICK[@]+"${SA_PICK[@]}"}")" || {
|
|
209
|
+
printf 'HTTP_AUTH_FAILED'
|
|
210
|
+
return 1
|
|
211
|
+
}
|
|
216
212
|
resp=$(curl -sS --max-time "$TIMEOUT" --connect-timeout 5 -w "\n%{http_code}" \
|
|
217
|
-
|
|
218
|
-
-H "Accept: application/json"
|
|
213
|
+
--config "$cfg" \
|
|
214
|
+
-H "Accept: application/json" 2>/dev/null || true)
|
|
219
215
|
http=$(printf '%s' "$resp" | tail -n1)
|
|
220
216
|
if [ "$http" = "200" ]; then
|
|
221
217
|
printf '%s' "$resp" | sed '$d'
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
# `--env prod` / `--env test` pin a single instance.
|
|
23
23
|
#
|
|
24
24
|
# Required configuration:
|
|
25
|
-
#
|
|
26
|
-
#
|
|
25
|
+
# the prod account's host - production instance (e.g. logs.example.com)
|
|
26
|
+
# a graylog account scoped to prod - its token slot holds the API token
|
|
27
27
|
# Optional (test environment):
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
28
|
+
# the test account's host - test instance; without one, test is skipped
|
|
29
|
+
# a graylog account scoped to test - its own token. A deployment that
|
|
30
|
+
# issues one token for both names
|
|
31
|
+
# the same store item in both
|
|
32
|
+
# accounts
|
|
31
33
|
#
|
|
32
34
|
# Optional env:
|
|
33
35
|
# GRAYLOG_TIMEOUT_SECONDS default 25
|
|
@@ -93,36 +95,21 @@ case "$ENVIRONMENT" in
|
|
|
93
95
|
*) echo "ERR: --env must be auto, prod or test (got '$ENVIRONMENT')" >&2; exit 4 ;;
|
|
94
96
|
esac
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
node = json.load(open('$PREFS')).get('global', {})
|
|
107
|
-
for part in os.environ['PREF_PATH'].split('.'):
|
|
108
|
-
node = node.get(part, {}) if isinstance(node, dict) else {}
|
|
109
|
-
print(node if isinstance(node, str) else '')
|
|
110
|
-
except Exception:
|
|
111
|
-
print('')
|
|
112
|
-
" 2>/dev/null || printf ''
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
HOST_PROD=$(pref_str hosts.graylog)
|
|
116
|
-
HOST_TEST=$(pref_str hosts.graylogTest)
|
|
117
|
-
HOST_PROD=${HOST_PROD%/}
|
|
118
|
-
HOST_TEST=${HOST_TEST%/}
|
|
98
|
+
_MA_GL_HERE="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
99
|
+
# shellcheck source=/dev/null
|
|
100
|
+
if [ -f "$_MA_GL_HERE/_service-account.sh" ]; then
|
|
101
|
+
. "$_MA_GL_HERE/_service-account.sh"
|
|
102
|
+
elif [ -f "$HOME/.claude/lib/_service-account.sh" ]; then
|
|
103
|
+
. "$HOME/.claude/lib/_service-account.sh"
|
|
104
|
+
else
|
|
105
|
+
printf '%s\n' '{"status":"blocked","reason":"missing-credential-helper","service":"graylog"}' >&2
|
|
106
|
+
exit 2
|
|
107
|
+
fi
|
|
119
108
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
KEY_TEST=$(pref_str keychainMapping.graylog_test)
|
|
125
|
-
[ -z "$KEY_TEST" ] && KEY_TEST="$KEY_PROD"
|
|
109
|
+
# Each instance is an account of its own, scoped to its environment, so a test
|
|
110
|
+
# token can never be sent to production and the other way round.
|
|
111
|
+
HOST_PROD="$(sa_host graylog --environment production 2>/dev/null || true)"
|
|
112
|
+
HOST_TEST="$(sa_host graylog --environment test 2>/dev/null || true)"
|
|
126
113
|
|
|
127
114
|
if [ -z "$TRX_ID" ] && [ -z "$CONV_ID" ]; then
|
|
128
115
|
echo "ERR: no id (pass --trx <transaction-id> and/or --conv <conversation-id>)" >&2
|
|
@@ -143,33 +130,6 @@ if [ -n "$CONV_ID" ]; then
|
|
|
143
130
|
fi
|
|
144
131
|
|
|
145
132
|
# Locate the resolver with an existence check, not a `.`-chain.
|
|
146
|
-
#
|
|
147
|
-
# Sourcing a file that does not exist aborts the shell under `set -e` - `||` included -
|
|
148
|
-
# so `. <candidate> || . <candidate> || { error }` reaches neither its later candidates
|
|
149
|
-
# nor its error branch. Every fetcher used that shape starting from `$HOME/.claude/...`,
|
|
150
|
-
# so on a Copilot-only or Codex-only install they all died with a bare exit 1 and no
|
|
151
|
-
# message. Reordering does not help: whichever candidate is absent aborts at that point.
|
|
152
|
-
# Checking for the file before sourcing it is the only safe form.
|
|
153
|
-
for _cred_resolver in \
|
|
154
|
-
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/credential-store-resolver.sh" \
|
|
155
|
-
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/../lib" 2>/dev/null && pwd)/credential-store-resolver.sh" \
|
|
156
|
-
"$HOME/.claude/lib/credential-store-resolver.sh" \
|
|
157
|
-
"$HOME/.copilot/lib/credential-store-resolver.sh" \
|
|
158
|
-
"$HOME/.codex/lib/credential-store-resolver.sh"; do
|
|
159
|
-
[ -f "$_cred_resolver" ] || continue
|
|
160
|
-
# shellcheck source=/dev/null
|
|
161
|
-
. "$_cred_resolver" 2>/dev/null || true
|
|
162
|
-
# `if`, not `[ ... ] && break`: the latter is the loop body's last command and returns
|
|
163
|
-
# 1 when CRED_STORE is still empty, which under `set -e` kills the loop on the first
|
|
164
|
-
# candidate that does not resolve - the very case the loop exists to survive.
|
|
165
|
-
if [ -n "${CRED_STORE:-}" ]; then break; fi
|
|
166
|
-
done
|
|
167
|
-
unset _cred_resolver
|
|
168
|
-
if [ -z "${CRED_STORE:-}" ]; then
|
|
169
|
-
printf '%s\n' '{"status":"blocked","reason":"missing-credential-helper","service":"graylog","expected_key":"'"$KEY_PROD"'"}' >&2
|
|
170
|
-
exit 2
|
|
171
|
-
fi
|
|
172
|
-
|
|
173
133
|
# Graylog relative universal search, built once and reused per environment.
|
|
174
134
|
ENC_QUERY=$(QUERY_IN="$QUERY" python3 -c "
|
|
175
135
|
import os, urllib.parse as up
|
|
@@ -183,22 +143,20 @@ RUN_BODY=""
|
|
|
183
143
|
RUN_HITS=0
|
|
184
144
|
|
|
185
145
|
run_search() {
|
|
186
|
-
# Usage: run_search <host> <
|
|
187
|
-
local host="$1"
|
|
188
|
-
|
|
189
|
-
|
|
146
|
+
# Usage: run_search <host> <environment>
|
|
147
|
+
local host="$1" environment="$2" url resp cfg
|
|
148
|
+
url="https://$host/api/$SEARCH_PATH"
|
|
149
|
+
# The config carries the URL as well as the credential, so this instance's
|
|
150
|
+
# token cannot travel to the other one, and a redirect is refused outright.
|
|
151
|
+
cfg=$(sa_cfg graylog "$url" graylog-pat --environment "$environment") || {
|
|
190
152
|
RUN_HTTP="no-token"; RUN_BODY=""; RUN_HITS=0
|
|
191
153
|
return 0
|
|
192
|
-
|
|
193
|
-
url="https://$host/api/$SEARCH_PATH"
|
|
194
|
-
# PAT basic auth: username=<token>, password=literal "token". The credential
|
|
195
|
-
# goes through a curl config via process substitution so it never lands in
|
|
196
|
-
# argv (argv is visible to ps).
|
|
154
|
+
}
|
|
197
155
|
resp=$(curl -sS --max-time "$TIMEOUT" --connect-timeout 5 -w "\n%{http_code}" \
|
|
198
|
-
|
|
156
|
+
--config "$cfg" \
|
|
199
157
|
-H "Accept: application/json" \
|
|
200
158
|
-H "X-Requested-By: multi-agent-pipeline" \
|
|
201
|
-
|
|
159
|
+
2>/dev/null || true)
|
|
202
160
|
RUN_HTTP=$(printf '%s' "$resp" | tail -n1)
|
|
203
161
|
RUN_BODY=$(printf '%s' "$resp" | sed '$d')
|
|
204
162
|
RUN_HITS=0
|
|
@@ -235,10 +193,13 @@ host_for() {
|
|
|
235
193
|
*) printf '%s' "$HOST_PROD" ;;
|
|
236
194
|
esac
|
|
237
195
|
}
|
|
238
|
-
|
|
196
|
+
# The accounts use the schema's vocabulary, which spells production in full;
|
|
197
|
+
# the flag and the reported environment stay the short form this script has
|
|
198
|
+
# always printed.
|
|
199
|
+
env_for() {
|
|
239
200
|
case "$1" in
|
|
240
|
-
test) printf '
|
|
241
|
-
*) printf '
|
|
201
|
+
test) printf 'test' ;;
|
|
202
|
+
*) printf 'production' ;;
|
|
242
203
|
esac
|
|
243
204
|
}
|
|
244
205
|
|
|
@@ -263,7 +224,7 @@ BODY=""
|
|
|
263
224
|
LAST_CANDIDATE="${CANDIDATES##* }"
|
|
264
225
|
for _env in $CANDIDATES; do
|
|
265
226
|
SEARCHED="${SEARCHED:+$SEARCHED }$_env"
|
|
266
|
-
run_search "$(host_for "$_env")" "$(
|
|
227
|
+
run_search "$(host_for "$_env")" "$(env_for "$_env")"
|
|
267
228
|
HOST=$(host_for "$_env")
|
|
268
229
|
ENV_USED="$_env"
|
|
269
230
|
HTTP="$RUN_HTTP"
|
|
@@ -282,7 +243,7 @@ for _env in $CANDIDATES; do
|
|
|
282
243
|
done
|
|
283
244
|
|
|
284
245
|
if [ "$HTTP" = "no-token" ]; then
|
|
285
|
-
printf '%s\n' '{"status":"blocked","reason":"missing-token","service":"graylog","
|
|
246
|
+
printf '%s\n' '{"status":"blocked","reason":"missing-token","service":"graylog","environment":"'"$(env_for "$ENV_USED")"'"}' >&2
|
|
286
247
|
exit 2
|
|
287
248
|
fi
|
|
288
249
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# expired-token decision (refs/keychain.md). Never prints token values - status lines only.
|
|
6
6
|
#
|
|
7
7
|
# Flow:
|
|
8
|
-
# 1.
|
|
8
|
+
# 1. Ask the account resolver which store item each slot lives in.
|
|
9
9
|
# 2. Read the refresh token from "<name>_Refresh" (written by the user's generation script).
|
|
10
10
|
# 3. Read client credentials from .figma-oauth.json next to prefs.global.tokenScripts.figma_mcp.
|
|
11
11
|
# 4. POST grant_type=refresh_token to the Figma token endpoint.
|
|
@@ -43,10 +43,29 @@ say() { printf '%s\n' "$*"; }
|
|
|
43
43
|
|
|
44
44
|
[ -f "$PREFS_FILE" ] || { say "figma-mcp-refresh: prefs file missing ($PREFS_FILE)"; exit 2; }
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
# The store item each slot lives in, named by the account rather than derived
|
|
47
|
+
# from a key here: a second place that builds the name is a second place that
|
|
48
|
+
# can be renamed out from under the first.
|
|
49
|
+
sa_item() {
|
|
50
|
+
local slot="$1" script
|
|
51
|
+
for script in \
|
|
52
|
+
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/service-account.sh" \
|
|
53
|
+
"$HOME/.claude/lib/service-account.sh" \
|
|
54
|
+
"$HOME/.copilot/lib/service-account.sh" \
|
|
55
|
+
"$HOME/.codex/lib/service-account.sh"; do
|
|
56
|
+
[ -x "$script" ] || continue
|
|
57
|
+
bash "$script" item-ref --service figma_mcp --slot "$slot" 2>/dev/null |
|
|
58
|
+
jq -r '.itemName // empty'
|
|
59
|
+
return 0
|
|
60
|
+
done
|
|
61
|
+
return 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
KEY_NAME=$(sa_item token)
|
|
65
|
+
[ -n "$KEY_NAME" ] || { say "figma-mcp-refresh: no Figma MCP account is configured"; exit 2; }
|
|
48
66
|
|
|
49
|
-
REFRESH_KEY
|
|
67
|
+
REFRESH_KEY=$(sa_item refresh_token)
|
|
68
|
+
[ -n "$REFRESH_KEY" ] || REFRESH_KEY="${KEY_NAME}_Refresh"
|
|
50
69
|
|
|
51
70
|
# Locate the resolver with an existence check, not a `.`-chain.
|
|
52
71
|
#
|
|
@@ -90,12 +90,12 @@ for _figma_token_lib in \
|
|
|
90
90
|
[ -f "$_figma_token_lib" ] || continue
|
|
91
91
|
# shellcheck source=/dev/null
|
|
92
92
|
. "$_figma_token_lib" 2>/dev/null || true
|
|
93
|
-
if command -v
|
|
93
|
+
if command -v figma_cfg >/dev/null 2>&1; then break; fi
|
|
94
94
|
done
|
|
95
95
|
unset _figma_token_lib
|
|
96
|
-
if ! command -v
|
|
97
|
-
|
|
98
|
-
figma_token_remediation() { printf 'figma-token.sh not found - reinstall the pipeline
|
|
96
|
+
if ! command -v figma_cfg >/dev/null 2>&1; then
|
|
97
|
+
figma_cfg() { return 2; }
|
|
98
|
+
figma_token_remediation() { printf 'figma-token.sh not found - reinstall the pipeline.'; }
|
|
99
99
|
fi
|
|
100
100
|
|
|
101
101
|
FIGMA_API="https://api.figma.com/v1"
|
|
@@ -206,6 +206,7 @@ PY
|
|
|
206
206
|
curl_figma() {
|
|
207
207
|
local out="$1" url="$2"
|
|
208
208
|
local code attempt sleep_s
|
|
209
|
+
figma_cfg "$url" || { printf '000'; return 0; }
|
|
209
210
|
for attempt in 1 2 3; do
|
|
210
211
|
# Token header goes through a curl config via process substitution so it
|
|
211
212
|
# never appears in argv (argv is visible to ps).
|
|
@@ -220,8 +221,7 @@ curl_figma() {
|
|
|
220
221
|
# genuinely empty.
|
|
221
222
|
code=$(curl -sS -o "$out" -w '%{http_code}' \
|
|
222
223
|
--max-time "$HTTP_TIMEOUT" --connect-timeout 5 \
|
|
223
|
-
|
|
224
|
-
"$url") || true
|
|
224
|
+
--config "$FIGMA_CFG") || true
|
|
225
225
|
code="${code:-000}"
|
|
226
226
|
case "$code" in
|
|
227
227
|
2*) printf '%s' "$code"; return 0 ;;
|
|
@@ -446,8 +446,7 @@ require_cmd python3
|
|
|
446
446
|
# Tier 1 (Figma MCP) is not reachable from a bash script. Stay on Tier 2 (REST).
|
|
447
447
|
log "INFO: Tier 1 (Figma MCP) not available from shell; using Tier 2 (REST)."
|
|
448
448
|
|
|
449
|
-
|
|
450
|
-
if [ -z "${FIGMA_TOKEN:-}" ]; then
|
|
449
|
+
if ! figma_cfg "$FIGMA_API/files/${FILE_KEY:-x}"; then
|
|
451
450
|
log "Tier 3 (user-provided screenshot required): no PAT resolved."
|
|
452
451
|
log "Hint: $(figma_token_remediation)"
|
|
453
452
|
exit 3
|
|
@@ -1,71 +1,64 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
#
|
|
3
3
|
# figma-token.sh
|
|
4
|
-
#
|
|
4
|
+
# The one place a Tier 2 Figma request gets its credential.
|
|
5
5
|
#
|
|
6
6
|
# Sourced by every Tier 2 fetcher (fetch-figma-annotations.sh,
|
|
7
7
|
# figma-screenshot.sh). It exists because those two each carried their own copy
|
|
8
|
-
# of
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
# under the new name - and the error text told the user to map the key the
|
|
13
|
-
# migration had just removed. One copy of the lookup cannot drift from itself.
|
|
8
|
+
# of the lookup, and a copy drifts: when the key a fetcher read was renamed,
|
|
9
|
+
# only one of the three places learned about it, and a valid PAT read as
|
|
10
|
+
# `missing-token` while the error text named a key that no longer existed. One
|
|
11
|
+
# copy of the lookup cannot drift from itself.
|
|
14
12
|
#
|
|
15
13
|
# Tier 2 is only reached when Tier 1 (Figma MCP) is unreachable; see the Figma
|
|
16
14
|
# Access Tier rule in multi-agent-refs/rules.md for the chain and the
|
|
17
15
|
# expired-token decision that gates the move to Tier 3.
|
|
18
16
|
#
|
|
19
|
-
# Resolution
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
17
|
+
# Resolution goes through the account resolver, which owns the whole question:
|
|
18
|
+
# which account answers for Figma, which store item holds its PAT, whether the
|
|
19
|
+
# environment carries one instead, and whether the URL being called is one that
|
|
20
|
+
# account may be sent to. No logical key, no store path and no Keychain service
|
|
21
|
+
# name appears here, which is what keeps the Synced Command Hygiene rule
|
|
22
|
+
# satisfied by construction rather than by review.
|
|
23
23
|
#
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
# Keychain service name appears here, which keeps the Synced Command Hygiene
|
|
28
|
-
# rule satisfied.
|
|
24
|
+
# Usage:
|
|
25
|
+
# figma_cfg "https://api.figma.com/v1/..." # sets FIGMA_CFG, or returns non-zero
|
|
26
|
+
# curl --config "$FIGMA_CFG" ...
|
|
29
27
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
28
|
+
# The credential never reaches a shell variable: it is written into a curl
|
|
29
|
+
# config that also carries the URL it is for, so the two cannot be separated
|
|
30
|
+
# and a redirect is refused rather than followed with the header on.
|
|
33
31
|
|
|
34
32
|
_MA_FT_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
35
33
|
# shellcheck source=/dev/null
|
|
36
34
|
if [ -f "$_MA_FT_HERE/user-facing.sh" ]; then . "$_MA_FT_HERE/user-facing.sh"; else . "$HOME/.claude/lib/user-facing.sh"; fi
|
|
35
|
+
# shellcheck source=/dev/null
|
|
36
|
+
if [ -f "$_MA_FT_HERE/_service-account.sh" ]; then
|
|
37
|
+
. "$_MA_FT_HERE/_service-account.sh"
|
|
38
|
+
elif [ -f "$HOME/.claude/lib/_service-account.sh" ]; then
|
|
39
|
+
. "$HOME/.claude/lib/_service-account.sh"
|
|
40
|
+
fi
|
|
37
41
|
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
tok=$("$CRED_STORE" get "$key" 2>/dev/null || true)
|
|
51
|
-
if [ -n "$tok" ]; then
|
|
52
|
-
printf '%s' "$tok"
|
|
53
|
-
return 0
|
|
54
|
-
fi
|
|
55
|
-
done <<EOF_KEYS
|
|
56
|
-
$(printf '%s\n' "$FIGMA_TOKEN_LOGICAL_KEYS" | tr ' ' '\n')
|
|
57
|
-
EOF_KEYS
|
|
58
|
-
fi
|
|
59
|
-
if [ -n "${FIGMA_PAT:-}" ]; then
|
|
60
|
-
printf '%s' "$FIGMA_PAT"
|
|
61
|
-
return 0
|
|
42
|
+
# figma_cfg <url>
|
|
43
|
+
# Sets FIGMA_CFG to a curl config carrying the PAT to that URL, or returns
|
|
44
|
+
# non-zero with the refusal available from sa_reason / sa_explain.
|
|
45
|
+
#
|
|
46
|
+
# It sets a variable rather than printing one because a caller reading it
|
|
47
|
+
# through a command substitution runs in a subshell, where a refusal branch's
|
|
48
|
+
# `exit` ends the subshell and the caller carries on unauthenticated.
|
|
49
|
+
# shellcheck disable=SC2034 # read by the fetchers that source this file
|
|
50
|
+
FIGMA_CFG=""
|
|
51
|
+
figma_cfg() {
|
|
52
|
+
if ! command -v sa_cfg >/dev/null 2>&1; then
|
|
53
|
+
return 2
|
|
62
54
|
fi
|
|
63
|
-
|
|
55
|
+
# shellcheck disable=SC2034 # read by the fetchers that source this file
|
|
56
|
+
FIGMA_CFG="$(sa_cfg figma "$1" figma-pat)"
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
# figma_token_remediation
|
|
67
60
|
# The one place the "how do I fix this" sentence is written, so a fetcher can
|
|
68
|
-
# never name a key
|
|
61
|
+
# never name a key that does not exist.
|
|
69
62
|
figma_token_remediation() {
|
|
70
|
-
printf 'no Figma PAT for Tier 2.
|
|
63
|
+
printf 'no Figma PAT for Tier 2. Add a Figma account with %s, or export FIGMA_PAT.' "$(ma_command setup)"
|
|
71
64
|
}
|