@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
|
@@ -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
|
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* host.mjs - which host this code is installed under, and what that host is
|
|
3
|
+
* called.
|
|
4
|
+
*
|
|
5
|
+
* `pipeline/schemas/hosts.json` is the single source. Everything here reads a
|
|
6
|
+
* field off it; nothing here compares a host name to a literal. A new host is a
|
|
7
|
+
* record in that file plus an installer module, not a branch added in each
|
|
8
|
+
* consumer.
|
|
9
|
+
*
|
|
10
|
+
* The registry is packaged data, never user input: it names install roots and
|
|
11
|
+
* argv, so opening it to extension would be a path-traversal and
|
|
12
|
+
* command-injection surface.
|
|
13
|
+
*
|
|
14
|
+
* @module pipeline/lib/host
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { existsSync, readFileSync } from "fs";
|
|
18
|
+
import { basename, dirname, join } from "path";
|
|
19
|
+
import { fileURLToPath } from "url";
|
|
20
|
+
|
|
21
|
+
// `fileURLToPath`, not `new URL(...).pathname`: the pathname keeps its
|
|
22
|
+
// percent-encoding, so an install under a home directory with a space in it
|
|
23
|
+
// would look for a file whose name contains `%20`. This module is imported by
|
|
24
|
+
// `user-facing.mjs`, which most of the pipeline imports, so that failure is not
|
|
25
|
+
// one script refusing to run - it is all of them.
|
|
26
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
|
|
28
|
+
// What answers when the registry is not on disk. An install missing its schemas
|
|
29
|
+
// tree is broken, and the check that SAYS so lives in a script that imports this
|
|
30
|
+
// module, so throwing here would silence the only thing able to report the
|
|
31
|
+
// cause. The fallback describes the state root and the host the paths are
|
|
32
|
+
// authored against; `install-present` then names the missing tree.
|
|
33
|
+
const FALLBACK = Object.freeze({
|
|
34
|
+
version: "0",
|
|
35
|
+
order: ["claude"],
|
|
36
|
+
stateRoot: ".claude",
|
|
37
|
+
hosts: {
|
|
38
|
+
claude: {
|
|
39
|
+
label: "Claude Code",
|
|
40
|
+
install: { root: ".claude", subtrees: ["scripts", "lib", "schemas"] },
|
|
41
|
+
detect: { rootSegment: ".claude" },
|
|
42
|
+
command: { template: "/multi-agent:{sub}" },
|
|
43
|
+
models: { rungs: {} },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function loadRegistry() {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(readFileSync(join(HERE, "..", "schemas", "hosts.json"), "utf8"));
|
|
51
|
+
} catch {
|
|
52
|
+
return FALLBACK;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @type {{version: string, order: string[], stateRoot: string, hosts: Record<string, any>}} */
|
|
57
|
+
export const REGISTRY = loadRegistry();
|
|
58
|
+
|
|
59
|
+
/** Host ids in the order the installer and every user-facing listing uses them. */
|
|
60
|
+
export const HOST_IDS = Object.freeze([...REGISTRY.order]);
|
|
61
|
+
|
|
62
|
+
/** The tree shared state lives in, whichever hosts are installed. `.claude`. */
|
|
63
|
+
export const STATE_ROOT = REGISTRY.stateRoot;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The host record, or null for an unknown id.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} id
|
|
69
|
+
* @returns {object|null}
|
|
70
|
+
*/
|
|
71
|
+
export function host(id) {
|
|
72
|
+
return REGISTRY.hosts[id] ?? null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The directory a host installs into, e.g. `/Users/x/.copilot`.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} home
|
|
79
|
+
* @param {string} id
|
|
80
|
+
* @returns {string|null} null for an unknown id
|
|
81
|
+
*/
|
|
82
|
+
export function hostRoot(home, id) {
|
|
83
|
+
const h = host(id);
|
|
84
|
+
return h ? join(home, h.install.root) : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Which host a file belongs to, read from the path it sits at.
|
|
89
|
+
*
|
|
90
|
+
* Takes the directory a tree lives in - `~/.copilot/scripts`, `~/.codex/lib` -
|
|
91
|
+
* and answers with the host id, or null when the path is outside every install
|
|
92
|
+
* (a repo checkout, most often).
|
|
93
|
+
*
|
|
94
|
+
* @param {string} dir
|
|
95
|
+
* @returns {string|null}
|
|
96
|
+
*/
|
|
97
|
+
function hostIdFromDir(dir) {
|
|
98
|
+
const segment = basename(dirname(dir));
|
|
99
|
+
for (const id of HOST_IDS) {
|
|
100
|
+
if (REGISTRY.hosts[id].detect.rootSegment === segment) return id;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Which host this module is running from, or null in a repo checkout.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} [dir] - defaults to this file's own directory
|
|
109
|
+
* @returns {string|null}
|
|
110
|
+
*/
|
|
111
|
+
export function currentHostId(dir = HERE) {
|
|
112
|
+
return hostIdFromDir(dir);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* How the user types a pipeline sub-command on a host.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} id
|
|
119
|
+
* @param {string} sub
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
122
|
+
export function hostCommandFor(id, sub) {
|
|
123
|
+
const h = host(id) ?? host(HOST_IDS[0]);
|
|
124
|
+
return h.command.template.replace("{sub}", sub);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The hosts that actually have an install under `home`.
|
|
129
|
+
*
|
|
130
|
+
* Presence is the version stamp, not the directory: `~/.codex` exists on any
|
|
131
|
+
* machine with Codex CLI, installed pipeline or not.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} home
|
|
134
|
+
* @returns {string[]} ids, in registry order
|
|
135
|
+
*/
|
|
136
|
+
export function installedHostIds(home) {
|
|
137
|
+
return HOST_IDS.filter((id) => existsSync(join(hostRoot(home, id), ".pipeline-version")));
|
|
138
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# host.sh - which host a shell script is running under, and what the registry
|
|
3
|
+
# says about it.
|
|
4
|
+
#
|
|
5
|
+
# The mjs side is pipeline/lib/host.mjs and reads the same file. Source this
|
|
6
|
+
# rather than matching a host name: `pipeline/schemas/hosts.json` is the single
|
|
7
|
+
# source, and a script that compares `$HOST` to a literal is a script that has
|
|
8
|
+
# to be edited again when a host is added.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# . "$(dirname "${BASH_SOURCE[0]}")/host.sh"
|
|
12
|
+
# id=$(ma_host_id) # a host id, or empty off an install
|
|
13
|
+
# ma_host_has_provider anthropic && ...
|
|
14
|
+
#
|
|
15
|
+
# Every function answers from the registry that shipped with THIS install, so a
|
|
16
|
+
# script copied into another host's tree answers for that host. Without jq there
|
|
17
|
+
# is no answer at all rather than a wrong one: callers treat an empty answer the
|
|
18
|
+
# way they treat a missing preference.
|
|
19
|
+
|
|
20
|
+
# The registry, resolved from this file's own location so it works in the repo
|
|
21
|
+
# (pipeline/lib -> pipeline/schemas) and in an install (<root>/lib -> <root>/schemas).
|
|
22
|
+
ma_host_registry() {
|
|
23
|
+
printf '%s\n' "$(cd "$(dirname "${BASH_SOURCE[0]}")/../schemas" 2>/dev/null && pwd)/hosts.json"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# The host whose tree this file sits in, or empty from a repo checkout.
|
|
27
|
+
ma_host_id() {
|
|
28
|
+
local reg seg
|
|
29
|
+
reg=$(ma_host_registry)
|
|
30
|
+
[ -f "$reg" ] || return 0
|
|
31
|
+
command -v jq >/dev/null 2>&1 || return 0
|
|
32
|
+
seg=$(basename "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." 2>/dev/null && pwd)")
|
|
33
|
+
jq -r --arg seg "$seg" \
|
|
34
|
+
'[.hosts | to_entries[] | select(.value.detect.rootSegment == $seg) | .key][0] // ""' \
|
|
35
|
+
"$reg" 2>/dev/null || true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# True when this host dispatches to the named provider.
|
|
39
|
+
ma_host_has_provider() {
|
|
40
|
+
local reg id
|
|
41
|
+
reg=$(ma_host_registry)
|
|
42
|
+
id=$(ma_host_id)
|
|
43
|
+
[ -f "$reg" ] || return 1
|
|
44
|
+
command -v jq >/dev/null 2>&1 || return 1
|
|
45
|
+
[ -n "$id" ] || id=$(jq -r '.order[0]' "$reg" 2>/dev/null)
|
|
46
|
+
jq -e --arg id "$id" --arg p "$1" \
|
|
47
|
+
'(.hosts[$id].models.providers // []) | index($p) != null' "$reg" >/dev/null 2>&1
|
|
48
|
+
}
|
|
@@ -200,51 +200,35 @@ def bound_comments(rows):
|
|
|
200
200
|
return kept
|
|
201
201
|
'
|
|
202
202
|
|
|
203
|
-
#
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
# shellcheck source=_service-account.sh
|
|
204
|
+
if [ -f "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/_service-account.sh" ]; then
|
|
205
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/_service-account.sh"
|
|
206
|
+
elif [ -f "$HOME/.claude/lib/_service-account.sh" ]; then
|
|
207
|
+
# shellcheck source=/dev/null
|
|
208
|
+
. "$HOME/.claude/lib/_service-account.sh"
|
|
209
|
+
fi
|
|
206
210
|
|
|
207
|
-
#
|
|
208
|
-
#
|
|
209
|
-
#
|
|
211
|
+
# One authenticated GET. Split out of fetch_jira so the sibling search reuses
|
|
212
|
+
# the same resolution instead of duplicating it. The credential is written into
|
|
213
|
+
# a config that carries the URL too, so a redirect cannot carry the header and
|
|
214
|
+
# the token never reaches argv or a shell variable.
|
|
210
215
|
jira_curl() {
|
|
211
|
-
local path="$1"
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
local path="$1" cfg host
|
|
217
|
+
# The account answers both halves of the question: which instance this run
|
|
218
|
+
# talks to, and the credential for it. ACCOUNT_JIRA_HOST and
|
|
219
|
+
# ACCOUNT_JIRA_TOKEN_KEY still name one when a caller sets them.
|
|
220
|
+
local -a sel=()
|
|
221
|
+
[ -n "${JIRA_HOST:-}" ] && sel+=(--host "$JIRA_HOST")
|
|
222
|
+
[ -n "${JIRA_TOKEN_KEY:-}" ] && sel+=(--item "$JIRA_TOKEN_KEY")
|
|
223
|
+
host="$(sa_host jira "${sel[@]+"${sel[@]}"}")" || {
|
|
224
|
+
echo "ERR: no Jira account for this run: $(sa_explain)" >&2
|
|
214
225
|
return 1
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
# A pre-set CRED_STORE (tests, custom installs) is honored as-is.
|
|
219
|
-
if [ -z "${CRED_STORE:-}" ]; then
|
|
220
|
-
# shellcheck disable=SC1090,SC1091
|
|
221
|
-
# Existence check before sourcing: `. <missing>` aborts the shell under `set -e`,
|
|
222
|
-
# `||` included, so a `.`-chain reaches neither its later candidates nor its error
|
|
223
|
-
# branch. The loop also covers all three hosts - the chain it replaced knew only
|
|
224
|
-
# .claude and .copilot, so a Codex-only install could not resolve at all.
|
|
225
|
-
for _cred_resolver in \
|
|
226
|
-
"$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/credential-store-resolver.sh" \
|
|
227
|
-
"$HOME/.claude/lib/credential-store-resolver.sh" \
|
|
228
|
-
"$HOME/.copilot/lib/credential-store-resolver.sh" \
|
|
229
|
-
"$HOME/.codex/lib/credential-store-resolver.sh"; do
|
|
230
|
-
[ -f "$_cred_resolver" ] || continue
|
|
231
|
-
# shellcheck source=/dev/null
|
|
232
|
-
. "$_cred_resolver" 2>/dev/null || true
|
|
233
|
-
if [ -n "${CRED_STORE:-}" ]; then break; fi
|
|
234
|
-
done
|
|
235
|
-
unset _cred_resolver
|
|
236
|
-
if [ -z "${CRED_STORE:-}" ]; then
|
|
237
|
-
echo "ERR: credential helper not found" >&2
|
|
238
|
-
return 1
|
|
239
|
-
fi
|
|
240
|
-
fi
|
|
241
|
-
local token
|
|
242
|
-
token=$("$CRED_STORE" get "$JIRA_TOKEN_KEY" 2>/dev/null || true)
|
|
243
|
-
if [ -z "$token" ]; then
|
|
244
|
-
echo "ERR: Jira token not found in credential store ($JIRA_TOKEN_KEY)" >&2
|
|
226
|
+
}
|
|
227
|
+
cfg="$(sa_cfg jira "https://$host$path" bearer "${sel[@]+"${sel[@]}"}")" || {
|
|
228
|
+
echo "ERR: $(sa_explain)" >&2
|
|
245
229
|
return 1
|
|
246
|
-
|
|
247
|
-
curl -sf -m 30
|
|
230
|
+
}
|
|
231
|
+
curl -sf -m 30 --config "$cfg"
|
|
248
232
|
}
|
|
249
233
|
|
|
250
234
|
# The field list is a parameter because the related-issue lookup wants a
|
|
@@ -89,7 +89,6 @@ ma_outbound_gate() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
SELF_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
92
|
-
PREFS="${MULTI_AGENT_PREFS:-$HOME/.claude/multi-agent-preferences.json}"
|
|
93
92
|
CURL="${JIRA_PUBLISH_CURL:-curl}"
|
|
94
93
|
|
|
95
94
|
ISSUE=""
|
|
@@ -135,26 +134,29 @@ for cand in "$SELF_DIR/../scripts/jira-wiki-escape.mjs" "$HOME/.claude/scripts/j
|
|
|
135
134
|
done
|
|
136
135
|
[ -n "$ESCAPER" ] || die "jira-wiki-escape.mjs not found next to lib/ or in ~/.claude/scripts" 4
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
137
|
+
# shellcheck source=_jira-auth.sh
|
|
138
|
+
. "$SELF_DIR/_jira-auth.sh"
|
|
139
|
+
jira_auth_resolve || exit 4
|
|
140
|
+
HOST="$JIRA_API_HOST"
|
|
141
|
+
|
|
142
|
+
# The URL is the last argument, as every call site already writes it, and it is
|
|
143
|
+
# the one thing that decides which credential may go out. It is handed to the
|
|
144
|
+
# resolver rather than to curl: the config that comes back carries the URL, the
|
|
145
|
+
# scheme lock and the header together, so nothing can point curl elsewhere
|
|
146
|
+
# between the check and the request. The token never reaches a variable here.
|
|
147
|
+
api() {
|
|
148
|
+
local -a args=("$@")
|
|
149
|
+
local last=$((${#args[@]} - 1))
|
|
150
|
+
local url="${args[$last]}"
|
|
151
|
+
unset "args[$last]"
|
|
152
|
+
local cfg
|
|
153
|
+
cfg="$(sa_cfg jira "$url" bearer "${JIRA_AUTH_SELECTORS[@]+"${JIRA_AUTH_SELECTORS[@]}"}")" || {
|
|
154
|
+
echo "ERR: $(sa_explain)" >&2
|
|
155
|
+
return 4
|
|
156
|
+
}
|
|
157
|
+
"$CURL" -sS -m 30 --config "$cfg" -H "Content-Type: application/json" \
|
|
158
|
+
"${args[@]+"${args[@]}"}"
|
|
159
|
+
}
|
|
158
160
|
|
|
159
161
|
WORK="$(mktemp -d)"
|
|
160
162
|
trap 'rm -rf "$WORK"' EXIT
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* local-model.mjs - the one place a user-chosen local model and server
|
|
3
|
+
* address are read and checked.
|
|
4
|
+
*
|
|
5
|
+
* The host registry is packaged data and names install roots and argv, so it is
|
|
6
|
+
* not extensible. The two things that ARE the user's - which model answers, and
|
|
7
|
+
* where it is served - live in preferences, and everything they reach is
|
|
8
|
+
* validated here before it is written into a config file or an agent TOML.
|
|
9
|
+
*
|
|
10
|
+
* The address is loopback by default and an address off this machine takes an
|
|
11
|
+
* explicit opt-in: a base URL is where every prompt in a run is sent, so a typo
|
|
12
|
+
* that resolves is a silent exfiltration path rather than an error.
|
|
13
|
+
*
|
|
14
|
+
* @module pipeline/lib/local-model
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { existsSync, readFileSync } from "fs";
|
|
18
|
+
|
|
19
|
+
/** Model ids this writes: a narrow set, because the value reaches a TOML file. */
|
|
20
|
+
const MODEL_NAME = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
|
|
21
|
+
|
|
22
|
+
/** Hosts that are this machine. Anything else needs `allowRemote`. */
|
|
23
|
+
const LOOPBACK = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `prefs.global.localModel`, or null when the file does not read.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} prefsPath
|
|
29
|
+
* @returns {{baseUrl?: string, model?: string, contextWindow?: number, allowRemote?: boolean}|null}
|
|
30
|
+
*/
|
|
31
|
+
function readLocalModel(prefsPath) {
|
|
32
|
+
if (!prefsPath || !existsSync(prefsPath)) return null;
|
|
33
|
+
try {
|
|
34
|
+
const parsed = JSON.parse(readFileSync(prefsPath, "utf8"));
|
|
35
|
+
const cfg = parsed?.global?.localModel;
|
|
36
|
+
return cfg && typeof cfg === "object" ? cfg : null;
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Why this configuration cannot be used, or null when it can.
|
|
44
|
+
*
|
|
45
|
+
* Every answer names the field and what it has to be, because the person
|
|
46
|
+
* reading it is editing a JSON file by hand.
|
|
47
|
+
*
|
|
48
|
+
* @param {object|null} cfg
|
|
49
|
+
* @returns {string|null}
|
|
50
|
+
*/
|
|
51
|
+
export function localModelProblem(cfg) {
|
|
52
|
+
if (!cfg) return "global.localModel is not set in preferences";
|
|
53
|
+
if (typeof cfg.model !== "string" || !MODEL_NAME.test(cfg.model)) {
|
|
54
|
+
return "global.localModel.model must be a model id of letters, digits and . _ : / -";
|
|
55
|
+
}
|
|
56
|
+
if (typeof cfg.baseUrl !== "string" || !cfg.baseUrl) {
|
|
57
|
+
return "global.localModel.baseUrl must be the server's base URL";
|
|
58
|
+
}
|
|
59
|
+
let url;
|
|
60
|
+
try {
|
|
61
|
+
url = new URL(cfg.baseUrl);
|
|
62
|
+
} catch {
|
|
63
|
+
return `global.localModel.baseUrl is not a URL: ${cfg.baseUrl}`;
|
|
64
|
+
}
|
|
65
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
66
|
+
return `global.localModel.baseUrl must be http or https, not ${url.protocol}`;
|
|
67
|
+
}
|
|
68
|
+
if (!LOOPBACK.has(url.hostname) && cfg.allowRemote !== true) {
|
|
69
|
+
return `global.localModel.baseUrl points at ${url.hostname}, which is not this machine; set global.localModel.allowRemote to true to send prompts there on purpose`;
|
|
70
|
+
}
|
|
71
|
+
if (!Number.isInteger(cfg.contextWindow) || cfg.contextWindow < 8192) {
|
|
72
|
+
// Measured, not guessed: a trivial one-turn request already carries about
|
|
73
|
+
// 45 KB of instructions before the task itself, and a phase spec is larger
|
|
74
|
+
// again. Below this the diff is truncated and the run reports on a file it
|
|
75
|
+
// never saw.
|
|
76
|
+
return "global.localModel.contextWindow must be an integer of at least 8192 tokens";
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The model id to bind agents to, or null when the configuration is unusable.
|
|
83
|
+
*
|
|
84
|
+
* Null is a working answer: agents are written without a model and the children
|
|
85
|
+
* inherit the session's.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} prefsPath
|
|
88
|
+
* @returns {string|null}
|
|
89
|
+
*/
|
|
90
|
+
export function localModelName(prefsPath) {
|
|
91
|
+
const cfg = readLocalModel(prefsPath);
|
|
92
|
+
return localModelProblem(cfg) === null ? cfg.model : null;
|
|
93
|
+
}
|
|
@@ -21,8 +21,8 @@ Authentication:
|
|
|
21
21
|
CONFLUENCE_BASE_URL - base URL, e.g. https://confluence.example.com
|
|
22
22
|
CONFLUENCE_USER - user (informational; bearer token auth is used)
|
|
23
23
|
Token is resolved from ~/.claude/lib/credential-store.sh using the logical key
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
resolved by the account resolver for the host CONFLUENCE_BASE_URL names.
|
|
25
|
+
An account that does not cover that host is refused, not used.
|
|
26
26
|
|
|
27
27
|
Output:
|
|
28
28
|
JSON envelope on stdout describing what happened (page id, url, attachments,
|
|
@@ -578,31 +578,38 @@ class ConfluenceAuth:
|
|
|
578
578
|
user: str | None = None
|
|
579
579
|
|
|
580
580
|
|
|
581
|
-
def
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
581
|
+
def _resolver() -> Path | None:
|
|
582
|
+
for candidate in (
|
|
583
|
+
Path(__file__).resolve().parent / "service-account.sh",
|
|
584
|
+
Path.home() / ".claude" / "lib" / "service-account.sh",
|
|
585
|
+
):
|
|
586
|
+
if candidate.is_file():
|
|
587
|
+
return candidate
|
|
588
|
+
return None
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
def resolve_token(base_url: str) -> str | None:
|
|
592
|
+
"""The credential for this base URL, or None when no account covers it.
|
|
593
|
+
|
|
594
|
+
The destination is part of the question, not something checked afterwards:
|
|
595
|
+
CONFLUENCE_BASE_URL comes from the caller, and an account that does not
|
|
596
|
+
name that host is refused rather than used.
|
|
597
|
+
"""
|
|
598
|
+
script = _resolver()
|
|
599
|
+
if script is None:
|
|
600
|
+
return None
|
|
601
|
+
try:
|
|
602
|
+
proc = subprocess.run(
|
|
603
|
+
[str(script), "token", "--service", "confluence", "--url", base_url],
|
|
604
|
+
capture_output=True,
|
|
605
|
+
text=True,
|
|
606
|
+
timeout=15,
|
|
607
|
+
)
|
|
608
|
+
except (OSError, subprocess.SubprocessError):
|
|
609
|
+
return None
|
|
610
|
+
if proc.returncode != 0:
|
|
611
|
+
return None
|
|
612
|
+
return proc.stdout or None
|
|
606
613
|
|
|
607
614
|
|
|
608
615
|
def resolve_auth() -> ConfluenceAuth:
|
|
@@ -610,11 +617,11 @@ def resolve_auth() -> ConfluenceAuth:
|
|
|
610
617
|
if not base:
|
|
611
618
|
sys.stderr.write("error: CONFLUENCE_BASE_URL is not set\n")
|
|
612
619
|
sys.exit(2)
|
|
613
|
-
token = resolve_token()
|
|
620
|
+
token = resolve_token(base)
|
|
614
621
|
if not token:
|
|
615
622
|
sys.stderr.write(
|
|
616
|
-
"error: no Confluence
|
|
617
|
-
"
|
|
623
|
+
"error: no Confluence account answers for "
|
|
624
|
+
f"{base} - add one with /multi-agent:setup\n"
|
|
618
625
|
)
|
|
619
626
|
sys.exit(2)
|
|
620
627
|
return ConfluenceAuth(base_url=base, token=token, user=os.environ.get("CONFLUENCE_USER"))
|