@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
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* shows it next to a run:
|
|
6
6
|
*
|
|
7
7
|
* confluence <page> lib/fetch-confluence.sh: a page by id or by https
|
|
8
|
-
* URL, both only on
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* URL, both only on a host a configured Confluence
|
|
9
|
+
* account covers; a URL on any other host, or any
|
|
10
|
+
* URL when no account is configured, is refused
|
|
11
|
+
* before the script runs; title, markdown body, API
|
|
12
|
+
* contracts count
|
|
13
13
|
* crashlytics <issue-url> lib/fetch-crashlytics.sh: one Crashlytics issue,
|
|
14
14
|
* title, occurrences, impacted users, top frames
|
|
15
15
|
* figma <file-key> <node> lib/figma-screenshot.sh (REST with the Figma
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
* The scripts run as child processes without blocking the caller's event
|
|
25
25
|
* loop (contract-server.mjs serves other routes meanwhile).
|
|
26
26
|
*
|
|
27
|
-
* Credentials are read only by those scripts, through
|
|
28
|
-
* Every text that comes back is scrubbed and redacted; an image
|
|
29
|
-
* base64.
|
|
27
|
+
* Credentials are read only by those scripts, each through the account
|
|
28
|
+
* resolver. Every text that comes back is scrubbed and redacted; an image
|
|
29
|
+
* comes back as base64.
|
|
30
30
|
*
|
|
31
31
|
* Usage:
|
|
32
32
|
* service-read.mjs confluence <page-id|https-url>
|
|
@@ -49,7 +49,7 @@ import { createRedactor } from "./transcript-index.mjs";
|
|
|
49
49
|
import { spawnAsync } from "./_spawn-async.mjs";
|
|
50
50
|
import { runMain } from "../lib/fatal.mjs";
|
|
51
51
|
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
52
|
-
import {
|
|
52
|
+
import { selectAccount } from "../lib/service-account.mjs";
|
|
53
53
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
54
54
|
|
|
55
55
|
exitOnHelp(import.meta.url);
|
|
@@ -104,13 +104,15 @@ async function run(env, file, args, failCodes) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
/**
|
|
108
|
+
* The Confluence host a page may be read from: the account that covers `url`,
|
|
109
|
+
* or, with no URL, the account the resolver picks on its own. A service with
|
|
110
|
+
* no account answers null, which is how "nothing is configured" and "not this
|
|
111
|
+
* host" stay different answers to the caller.
|
|
112
|
+
*/
|
|
113
|
+
function confluenceHost(env, url = undefined) {
|
|
114
|
+
const chosen = selectAccount({ service: "confluence", url }, { env });
|
|
115
|
+
return chosen.ok ? (chosen.account.hosts[0] ?? null) : null;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
/** One Confluence page, by id or by a URL on the configured host only. */
|
|
@@ -129,7 +131,7 @@ export async function confluencePage(page, env = process.env) {
|
|
|
129
131
|
"no Confluence host is configured, so only a page id is accepted",
|
|
130
132
|
);
|
|
131
133
|
}
|
|
132
|
-
if (
|
|
134
|
+
if (!confluenceHost(env, url)) {
|
|
133
135
|
throw new ServiceError("host-not-allowed", "that host is not the configured Confluence host");
|
|
134
136
|
}
|
|
135
137
|
args = [url];
|
|
@@ -44,6 +44,7 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
44
44
|
import { homedir } from "node:os";
|
|
45
45
|
import { fileURLToPath } from "node:url";
|
|
46
46
|
import { hostCommand } from "../lib/user-facing.mjs";
|
|
47
|
+
import { REGISTRY, hostRoot, installedHostIds } from "../lib/host.mjs";
|
|
47
48
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
48
49
|
|
|
49
50
|
exitOnHelp(import.meta.url);
|
|
@@ -61,7 +62,20 @@ const REPO_CMD_DIR = join(REPO_ROOT, "pipeline", "commands", "multi-agent");
|
|
|
61
62
|
const IN_REPO = existsSync(REPO_CMD_DIR);
|
|
62
63
|
const ROOT = IN_REPO ? REPO_ROOT : HOME;
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
// Installed, the specs sit wherever THIS machine's hosts keep them, which is a
|
|
66
|
+
// different tree and a different directory naming on each. Reading the Claude
|
|
67
|
+
// layout unconditionally made a machine with a complete Copilot-only install
|
|
68
|
+
// report "no commands found - the tree layout has changed".
|
|
69
|
+
const INSTALLED_SPECS = installedHostIds(HOME)
|
|
70
|
+
.map((id) => ({
|
|
71
|
+
dir: join(hostRoot(HOME, id), REGISTRY.hosts[id].install.commandSpecs),
|
|
72
|
+
prefix: REGISTRY.hosts[id].install.commandSpecPrefix,
|
|
73
|
+
}))
|
|
74
|
+
.find(({ dir }) => existsSync(dir));
|
|
75
|
+
const CMD_DIR = IN_REPO
|
|
76
|
+
? REPO_CMD_DIR
|
|
77
|
+
: (INSTALLED_SPECS?.dir ?? join(HOME, ".claude", "commands", "multi-agent"));
|
|
78
|
+
const CMD_PREFIX = IN_REPO ? "" : (INSTALLED_SPECS?.prefix ?? "");
|
|
65
79
|
const CORE_DIR = join(REPO_ROOT, "pipeline", "skills", "shared", "core");
|
|
66
80
|
const COPILOT_DIR = join(HOME, ".copilot", "skills");
|
|
67
81
|
const CODEX_DIR = join(HOME, ".codex", "multi-agent-refs", "commands");
|
|
@@ -100,9 +114,11 @@ function commandNames() {
|
|
|
100
114
|
if (!existsSync(CMD_DIR)) return [];
|
|
101
115
|
return readdirSync(CMD_DIR)
|
|
102
116
|
.filter((d) => {
|
|
117
|
+
if (CMD_PREFIX && !d.startsWith(CMD_PREFIX)) return false;
|
|
103
118
|
const p = join(CMD_DIR, d);
|
|
104
119
|
return statSync(p).isDirectory() && existsSync(join(p, "SKILL.md"));
|
|
105
120
|
})
|
|
121
|
+
.map((d) => (CMD_PREFIX ? d.slice(CMD_PREFIX.length) : d))
|
|
106
122
|
.sort();
|
|
107
123
|
}
|
|
108
124
|
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* estimate errs low;
|
|
19
19
|
* 3. accounts: the github.com logins gh holds (usage-identity.mjs) and the
|
|
20
20
|
* author git would write in the current directory;
|
|
21
|
-
* 4. credentials:
|
|
22
|
-
* "registered" when
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* 4. credentials: every store item this machine's accounts name (the account
|
|
22
|
+
* resolver's itemNames) is "registered" when the store lists it. Only
|
|
23
|
+
* names are read: the store is never asked for a value, and nothing about
|
|
24
|
+
* a value (length, prefix) is printed;
|
|
25
25
|
* 5. runs: runs-index.mjs, the same records /multi-agent:status always used.
|
|
26
26
|
*
|
|
27
27
|
* Usage:
|
|
@@ -50,6 +50,7 @@ import { matchRun } from "./activity-snapshot.mjs";
|
|
|
50
50
|
import { buildIndex, phaseCell } from "./runs-index.mjs";
|
|
51
51
|
import { listAccounts } from "./usage-identity.mjs";
|
|
52
52
|
import { prefsPath as sharedPrefsPath } from "../lib/prefs-value.mjs";
|
|
53
|
+
import { itemNames } from "../lib/service-account.mjs";
|
|
53
54
|
|
|
54
55
|
export const CONTRACT_VERSION = "1.0.0";
|
|
55
56
|
export const WINDOW_MS = 24 * 3_600_000;
|
|
@@ -204,11 +205,18 @@ function recentFiles(root, since) {
|
|
|
204
205
|
return out;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* The accounts' credential names and whether each is registered; values are
|
|
210
|
+
* never read.
|
|
211
|
+
*
|
|
212
|
+
* The name shown is the account a slot belongs to, which for a single-secret
|
|
213
|
+
* service is the service itself; a service with more than one secret names the
|
|
214
|
+
* slot as well, so two halves of one login read as two rows rather than one.
|
|
215
|
+
*/
|
|
208
216
|
export function credentialStatus({ env = process.env } = {}) {
|
|
209
|
-
let
|
|
217
|
+
let named;
|
|
210
218
|
try {
|
|
211
|
-
|
|
219
|
+
named = itemNames(JSON.parse(readFileSync(prefsPath(env), "utf8")));
|
|
212
220
|
} catch {
|
|
213
221
|
return { readable: false, items: [] };
|
|
214
222
|
}
|
|
@@ -219,9 +227,11 @@ export function credentialStatus({ env = process.env } = {}) {
|
|
|
219
227
|
});
|
|
220
228
|
if (listed.status !== 0) return { readable: false, items: [] };
|
|
221
229
|
const services = new Set(String(listed.stdout).split("\n").filter(Boolean));
|
|
222
|
-
const items =
|
|
223
|
-
.
|
|
224
|
-
|
|
230
|
+
const items = named
|
|
231
|
+
.map(({ item, accountId, slot }) => ({
|
|
232
|
+
name: slot === "token" ? accountId : `${accountId}/${slot}`,
|
|
233
|
+
registered: services.has(item),
|
|
234
|
+
}))
|
|
225
235
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
226
236
|
return { readable: true, items };
|
|
227
237
|
}
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
} from "../lib/xcode-plugin.mjs";
|
|
59
59
|
import { createInterface } from "readline";
|
|
60
60
|
import { removeHooks, templateCommands } from "./host-hooks.mjs";
|
|
61
|
+
import { HOST_IDS, host as hostEntry } from "../lib/host.mjs";
|
|
61
62
|
import { prefsFileIn } from "../lib/prefs-value.mjs";
|
|
62
63
|
import { legacyWarning, retireOfficeRemote } from "../lib/office-legacy.mjs";
|
|
63
64
|
import { LEGACY_SERVER_ID, finalMatcher } from "../lib/mcp-rename.mjs";
|
|
@@ -118,7 +119,7 @@ export const INSTALL_MANIFEST = ".pipeline-manifest.json";
|
|
|
118
119
|
|
|
119
120
|
const flags = process.argv.slice(2).filter((a) => a !== "uninstall");
|
|
120
121
|
|
|
121
|
-
const TOOL_FLAGS =
|
|
122
|
+
const TOOL_FLAGS = HOST_IDS.map((id) => hostEntry(id).install.flag);
|
|
122
123
|
|
|
123
124
|
// Flags of adapters the installer no longer has, and any other flag this
|
|
124
125
|
// script does not know, are refused rather than ignored: an unrecognised flag
|
|
@@ -142,6 +143,9 @@ const explicitlyTargeted = flags.some((f) => TOOL_FLAGS.includes(f)) || flags.in
|
|
|
142
143
|
const forClaude = flags.includes("--claude") || flags.includes("--all") || !explicitlyTargeted;
|
|
143
144
|
const forCopilot = flags.includes("--copilot") || flags.includes("--all") || !explicitlyTargeted;
|
|
144
145
|
const forCodex = flags.includes("--codex") || flags.includes("--all") || !explicitlyTargeted;
|
|
146
|
+
// The local host is the Codex engine in a tree of its own, so it is removed
|
|
147
|
+
// like Codex but never together with it: a user who keeps one keeps the other.
|
|
148
|
+
const forLocal = flags.includes("--local") || flags.includes("--all") || !explicitlyTargeted;
|
|
145
149
|
|
|
146
150
|
const dryRun = flags.includes("--dry-run");
|
|
147
151
|
const skipPrompt = flags.includes("--yes") || flags.includes("-y");
|
|
@@ -231,23 +235,43 @@ function rmDirExcept(dir, keep) {
|
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
/**
|
|
234
|
-
* Full cleanup removes the settings file, but not
|
|
238
|
+
* Full cleanup removes the settings file, but not what names the tokens.
|
|
235
239
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
+
* These five keys hold no secret, and without them the preserved tokens become
|
|
241
|
+
* unfindable or unusable: the items sit in the OS store under names the user
|
|
242
|
+
* never chose, and nothing records which host each one belongs to. Deleting
|
|
243
|
+
* them while promising "tokens are preserved" makes that promise hollow.
|
|
244
|
+
*
|
|
245
|
+
* `serviceAccounts` is the one that pairs a secret with its host, so dropping
|
|
246
|
+
* it on a machine with two accounts of one service loses the only record of
|
|
247
|
+
* which token is which - the person would reinstall and be asked to tell the
|
|
248
|
+
* difference again. `hosts` and `credentialHosts` are the flat projection of
|
|
249
|
+
* the same thing, and `serviceOptOuts` is the person's answer to a question
|
|
250
|
+
* setup would otherwise ask them a second time.
|
|
240
251
|
*
|
|
241
252
|
* Everything else in the file goes. An absent or unparseable file is not an
|
|
242
253
|
* uninstall failure - it is removed as before.
|
|
243
254
|
* @param {string} prefsPath
|
|
244
255
|
*/
|
|
256
|
+
const PRESERVED_CREDENTIAL_KEYS = [
|
|
257
|
+
"keychainMapping",
|
|
258
|
+
"serviceAccounts",
|
|
259
|
+
"serviceOptOuts",
|
|
260
|
+
"hosts",
|
|
261
|
+
"credentialHosts",
|
|
262
|
+
];
|
|
263
|
+
|
|
245
264
|
function preservePrefsCredentialMapping(prefsPath) {
|
|
246
265
|
if (!existsSync(prefsPath)) return;
|
|
247
266
|
let mapping;
|
|
267
|
+
const kept = {};
|
|
248
268
|
try {
|
|
249
269
|
const prefs = JSON.parse(readFileSync(prefsPath, "utf-8"));
|
|
250
270
|
mapping = prefs?.global?.keychainMapping;
|
|
271
|
+
for (const key of PRESERVED_CREDENTIAL_KEYS) {
|
|
272
|
+
const value = prefs?.global?.[key];
|
|
273
|
+
if (value != null) kept[key] = value;
|
|
274
|
+
}
|
|
251
275
|
} catch {
|
|
252
276
|
/* unreadable: nothing to rescue, fall through to a plain removal */
|
|
253
277
|
}
|
|
@@ -258,17 +282,15 @@ function preservePrefsCredentialMapping(prefsPath) {
|
|
|
258
282
|
if (dryRun) {
|
|
259
283
|
report(
|
|
260
284
|
"would reduce",
|
|
261
|
-
`${prefsPath} to
|
|
285
|
+
`${prefsPath} to ${Object.keys(kept).join(", ")} (${Object.keys(mapping).length} mapped keys)`,
|
|
262
286
|
);
|
|
263
287
|
return;
|
|
264
288
|
}
|
|
265
|
-
writeFileSync(
|
|
266
|
-
prefsPath,
|
|
267
|
-
JSON.stringify({ global: { keychainMapping: mapping } }, null, 2) + "\n",
|
|
268
|
-
);
|
|
289
|
+
writeFileSync(prefsPath, JSON.stringify({ global: kept }, null, 2) + "\n");
|
|
269
290
|
console.log(
|
|
270
|
-
` kept: ${prefsPath} reduced to
|
|
271
|
-
|
|
291
|
+
` kept: ${prefsPath} reduced to ${Object.keys(kept).join(", ")} ` +
|
|
292
|
+
`(${Object.keys(mapping).length} mapped keys) - the preserved tokens stay findable, ` +
|
|
293
|
+
"and so does which host each one belongs to",
|
|
272
294
|
);
|
|
273
295
|
}
|
|
274
296
|
|
|
@@ -532,11 +554,16 @@ export function retiredRegistrations(isRegistered) {
|
|
|
532
554
|
* @param {string[]} [scopeArgs]
|
|
533
555
|
* @param {{dry?: boolean}} [opts]
|
|
534
556
|
*/
|
|
535
|
-
export function deregisterMcpServer(
|
|
557
|
+
export function deregisterMcpServer(
|
|
558
|
+
host,
|
|
559
|
+
cliPath,
|
|
560
|
+
scopeArgs = [],
|
|
561
|
+
{ dry = dryRun, env = process.env } = {},
|
|
562
|
+
) {
|
|
536
563
|
const cli = cliPath || host;
|
|
537
564
|
const isRegistered = (name) => {
|
|
538
565
|
try {
|
|
539
|
-
execFileSync(cli, ["mcp", "get", name], { stdio: "pipe", timeout: 20_000 });
|
|
566
|
+
execFileSync(cli, ["mcp", "get", name], { stdio: "pipe", timeout: 20_000, env });
|
|
540
567
|
return true;
|
|
541
568
|
} catch {
|
|
542
569
|
return false;
|
|
@@ -559,6 +586,7 @@ export function deregisterMcpServer(host, cliPath, scopeArgs = [], { dry = dryRu
|
|
|
559
586
|
execFileSync(cli, ["mcp", "remove", ...scopeArgs, name], {
|
|
560
587
|
stdio: "pipe",
|
|
561
588
|
timeout: 20_000,
|
|
589
|
+
env,
|
|
562
590
|
});
|
|
563
591
|
console.log(` removed: ${name} MCP registration (${host})`);
|
|
564
592
|
} catch {
|
|
@@ -568,8 +596,70 @@ export function deregisterMcpServer(host, cliPath, scopeArgs = [], { dry = dryRu
|
|
|
568
596
|
report("kept", `${MCP_PRESERVED} MCP registration (${host}) - usable without the pipeline`);
|
|
569
597
|
}
|
|
570
598
|
|
|
571
|
-
|
|
572
|
-
|
|
599
|
+
/**
|
|
600
|
+
* Remove a Codex-engine host's tree. Both the Codex CLI host and the local-model
|
|
601
|
+
* host install the same shape under a root of their own, so the removal is one
|
|
602
|
+
* body with two roots rather than two copies that drift apart.
|
|
603
|
+
*
|
|
604
|
+
* @param {object} opts
|
|
605
|
+
* @param {string} opts.label - host label for the console lines
|
|
606
|
+
* @param {string} opts.root - that host's directory
|
|
607
|
+
* @param {string[]} opts.hooksCommands - shipped hook commands to match
|
|
608
|
+
* @param {string[]} opts.extraHooksHomes - other homes a hooks.json may sit in
|
|
609
|
+
* @param {boolean} opts.deregister - whether the host had a stamp to read
|
|
610
|
+
* @param {string|null} opts.codexHome - CODEX_HOME the MCP entry was written under
|
|
611
|
+
*/
|
|
612
|
+
function removeCodexTree({ label, root, hooksCommands, extraHooksHomes, deregister, codexHome }) {
|
|
613
|
+
const removing = dryRun ? "Would remove" : "Removing";
|
|
614
|
+
console.log("");
|
|
615
|
+
console.log(` [${label}] ${removing} from ${root.replace(homedir(), "~")}...`);
|
|
616
|
+
|
|
617
|
+
// Codex reads hooks from $CODEX_HOME when set, so host-hooks.mjs may have
|
|
618
|
+
// registered outside this root as well. The template was read by the caller,
|
|
619
|
+
// before any block removed one.
|
|
620
|
+
const hooksFiles = new Set([join(root, "hooks.json")]);
|
|
621
|
+
for (const home of extraHooksHomes) hooksFiles.add(join(home, "hooks.json"));
|
|
622
|
+
for (const hooksFile of hooksFiles) cleanCodexHooks(hooksFile, hooksCommands);
|
|
623
|
+
|
|
624
|
+
// Wholly pipeline-owned trees.
|
|
625
|
+
rmIfExists(join(root, "multi-agent-refs"));
|
|
626
|
+
rmIfExists(join(root, "scripts"));
|
|
627
|
+
rmDirExcept(join(root, "lib"), KEEP_IN_LIB);
|
|
628
|
+
rmIfExists(join(root, "schemas"));
|
|
629
|
+
rmIfExists(join(root, "office"));
|
|
630
|
+
rmIfExists(join(root, "rules"));
|
|
631
|
+
rmIfExists(join(root, ".pipeline-version"));
|
|
632
|
+
rmMatchingFiles(join(root, "templates"), (name) => PIPELINE_TEMPLATE_FILES.includes(name));
|
|
633
|
+
rmdirIfEmpty(join(root, "templates"));
|
|
634
|
+
|
|
635
|
+
// Co-owned dirs: remove only what the pipeline wrote. `skills/` holds
|
|
636
|
+
// Codex's own `.system` set plus user skills; `prompts/` and `agents/` hold
|
|
637
|
+
// user-authored files.
|
|
638
|
+
const skills = join(root, "skills");
|
|
639
|
+
let n = rmMatchingDirs(
|
|
640
|
+
skills,
|
|
641
|
+
(name) => name === "multi-agent" || name.startsWith("multi-agent-"),
|
|
642
|
+
);
|
|
643
|
+
n += rmPluginDeliveredSkills(skills);
|
|
644
|
+
if (n > 0) console.log(` removed ${n} skill dir(s) under ${skills}`);
|
|
645
|
+
rmIfExists(join(root, "prompts", "multi-agent.md"));
|
|
646
|
+
removeCodexCommandPrompts(join(root, "prompts"));
|
|
647
|
+
removeGeneratedCodexAgents(join(root, "agents"));
|
|
648
|
+
|
|
649
|
+
stripManagedBlock(join(root, "AGENTS.md"), { hostFile: true });
|
|
650
|
+
|
|
651
|
+
// The MCP entry was written by `codex mcp add`, so hand it back the same
|
|
652
|
+
// way rather than editing config.toml - Codex also stores marketplace and
|
|
653
|
+
// plugin state in that file.
|
|
654
|
+
if (deregister) deregisterCodexMcpServer(codexHome);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
function deregisterCodexMcpServer(codexHome) {
|
|
658
|
+
// The installer registers the local host's server with CODEX_HOME pointing at
|
|
659
|
+
// that host's own tree, so the removal has to name the same home or it reads
|
|
660
|
+
// the default one and finds nothing.
|
|
661
|
+
const env = codexHome ? { ...process.env, CODEX_HOME: codexHome } : process.env;
|
|
662
|
+
deregisterMcpServer("codex", undefined, [], { env });
|
|
573
663
|
}
|
|
574
664
|
|
|
575
665
|
/**
|
|
@@ -1101,7 +1191,7 @@ export async function main() {
|
|
|
1101
1191
|
if (retiredGiven.length > 0) {
|
|
1102
1192
|
console.error(
|
|
1103
1193
|
` ${retiredGiven.join(", ")}: no longer supported; nothing was removed.\n` +
|
|
1104
|
-
|
|
1194
|
+
` Name a host with ${TOOL_FLAGS.join(", ")}, or pass none for all of them.`,
|
|
1105
1195
|
);
|
|
1106
1196
|
process.exit(2);
|
|
1107
1197
|
}
|
|
@@ -1131,6 +1221,10 @@ export async function main() {
|
|
|
1131
1221
|
console.log(
|
|
1132
1222
|
" - Codex CLI (~/.codex: skills/multi-agent, multi-agent-refs, agents/*.toml, prompts/multi-agent.md and the user-only command prompts, scripts, lib except the credential reader, schemas, rules, AGENTS.md block, the retired dev-toolkit MCP entry; the multi-agent MCP entry is KEPT)",
|
|
1133
1223
|
);
|
|
1224
|
+
if (forLocal)
|
|
1225
|
+
console.log(
|
|
1226
|
+
` - ${hostEntry("local").label} (~/${hostEntry("local").install.root}: the same tree, which the pipeline owns whole)`,
|
|
1227
|
+
);
|
|
1134
1228
|
console.log("");
|
|
1135
1229
|
if (allData) {
|
|
1136
1230
|
console.log(" FULL CLEANUP (--all-data) also removes:");
|
|
@@ -1161,7 +1255,17 @@ export async function main() {
|
|
|
1161
1255
|
// Read before any stamp is removed: the Codex MCP entry is deregistered last.
|
|
1162
1256
|
const copilotInstalled = hostInstalled(".copilot");
|
|
1163
1257
|
const codexInstalled = hostInstalled(".codex");
|
|
1258
|
+
const LOCAL = hostEntry("local");
|
|
1259
|
+
const LOCAL_ROOT = LOCAL.install.root;
|
|
1260
|
+
const localInstalled = hostInstalled(LOCAL_ROOT);
|
|
1164
1261
|
const removing = dryRun ? "Would remove" : "Removing";
|
|
1262
|
+
// Read before ANY block removes a templates file. The lookup falls back to the
|
|
1263
|
+
// tree this script is running from, so a Copilot-tree uninstall that deletes
|
|
1264
|
+
// its own copy first would leave the Codex hooks unmatched and the entries in
|
|
1265
|
+
// place, pointing at scripts the same run removed.
|
|
1266
|
+
const codexHooks = shippedHookCommands("codex-hooks.json", [
|
|
1267
|
+
join(HOME ?? "", ".codex", "templates"),
|
|
1268
|
+
]);
|
|
1165
1269
|
|
|
1166
1270
|
console.log("");
|
|
1167
1271
|
console.log(" [Office]");
|
|
@@ -1244,9 +1348,14 @@ export async function main() {
|
|
|
1244
1348
|
const COP = join(HOME, ".copilot");
|
|
1245
1349
|
rmIfExists(join(COP, "scripts"));
|
|
1246
1350
|
// Pipeline-managed trees the installer lays down alongside scripts/.
|
|
1351
|
+
rmIfExists(join(COP, "multi-agent-refs"));
|
|
1247
1352
|
rmIfExists(join(COP, "schemas"));
|
|
1248
1353
|
rmIfExists(join(COP, "office"));
|
|
1249
1354
|
rmDirExcept(join(COP, "lib"), KEEP_IN_LIB);
|
|
1355
|
+
// templates/ is installed on every host, so it has to be removed on every
|
|
1356
|
+
// host. By shipped name, not wholesale: the directory is the host's.
|
|
1357
|
+
rmMatchingFiles(join(COP, "templates"), (name) => PIPELINE_TEMPLATE_FILES.includes(name));
|
|
1358
|
+
rmdirIfEmpty(join(COP, "templates"));
|
|
1250
1359
|
rmIfExists(join(COP, ".pipeline-version"));
|
|
1251
1360
|
const skills = join(COP, "skills");
|
|
1252
1361
|
let n = rmMatchingDirs(
|
|
@@ -1308,46 +1417,25 @@ export async function main() {
|
|
|
1308
1417
|
}
|
|
1309
1418
|
|
|
1310
1419
|
if (forCodex && HOME) {
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
for (const hooksFile of hooksFiles) cleanCodexHooks(hooksFile, codexHooks);
|
|
1321
|
-
|
|
1322
|
-
// Wholly pipeline-owned trees.
|
|
1323
|
-
rmIfExists(join(CODEX, "multi-agent-refs"));
|
|
1324
|
-
rmIfExists(join(CODEX, "scripts"));
|
|
1325
|
-
rmDirExcept(join(CODEX, "lib"), KEEP_IN_LIB);
|
|
1326
|
-
rmIfExists(join(CODEX, "schemas"));
|
|
1327
|
-
rmIfExists(join(CODEX, "office"));
|
|
1328
|
-
rmIfExists(join(CODEX, "rules"));
|
|
1329
|
-
rmIfExists(join(CODEX, ".pipeline-version"));
|
|
1330
|
-
|
|
1331
|
-
// Co-owned dirs: remove only what the pipeline wrote. `skills/` holds
|
|
1332
|
-
// Codex's own `.system` set plus user skills; `prompts/` and `agents/` hold
|
|
1333
|
-
// user-authored files.
|
|
1334
|
-
const skills = join(CODEX, "skills");
|
|
1335
|
-
let n = rmMatchingDirs(
|
|
1336
|
-
skills,
|
|
1337
|
-
(name) => name === "multi-agent" || name.startsWith("multi-agent-"),
|
|
1338
|
-
);
|
|
1339
|
-
n += rmPluginDeliveredSkills(skills);
|
|
1340
|
-
if (n > 0) console.log(` removed ${n} skill dir(s) under ${skills}`);
|
|
1341
|
-
rmIfExists(join(CODEX, "prompts", "multi-agent.md"));
|
|
1342
|
-
removeCodexCommandPrompts(join(CODEX, "prompts"));
|
|
1343
|
-
removeGeneratedCodexAgents(join(CODEX, "agents"));
|
|
1344
|
-
|
|
1345
|
-
stripManagedBlock(join(CODEX, "AGENTS.md"), { hostFile: true });
|
|
1420
|
+
removeCodexTree({
|
|
1421
|
+
label: "Codex CLI",
|
|
1422
|
+
root: join(HOME, ".codex"),
|
|
1423
|
+
hooksCommands: codexHooks,
|
|
1424
|
+
extraHooksHomes: process.env.CODEX_HOME ? [process.env.CODEX_HOME] : [],
|
|
1425
|
+
deregister: codexInstalled,
|
|
1426
|
+
codexHome: null,
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1346
1429
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1430
|
+
if (forLocal && HOME) {
|
|
1431
|
+
removeCodexTree({
|
|
1432
|
+
label: LOCAL.label,
|
|
1433
|
+
root: join(HOME, LOCAL_ROOT),
|
|
1434
|
+
hooksCommands: codexHooks,
|
|
1435
|
+
extraHooksHomes: [],
|
|
1436
|
+
deregister: localInstalled,
|
|
1437
|
+
codexHome: join(HOME, LOCAL_ROOT),
|
|
1438
|
+
});
|
|
1351
1439
|
}
|
|
1352
1440
|
|
|
1353
1441
|
console.log("");
|
|
@@ -124,7 +124,8 @@ import {
|
|
|
124
124
|
transportReason,
|
|
125
125
|
} from "./usage-register-beacon.mjs";
|
|
126
126
|
import { PREFS_ENV, prefsFileIn } from "../lib/prefs-value.mjs";
|
|
127
|
-
import { credentialStores } from "../lib/usage-token.mjs";
|
|
127
|
+
import { credentialStores, usagePrefs } from "../lib/usage-token.mjs";
|
|
128
|
+
import { itemNames, resolveSecret } from "../lib/service-account.mjs";
|
|
128
129
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
129
130
|
import { hostDigest, loadRunKey } from "../lib/usage-run-key.mjs";
|
|
130
131
|
import { versionOrUnknown } from "../lib/usage-vocab.mjs";
|
|
@@ -232,13 +233,35 @@ export function registerUrl(endpoint) {
|
|
|
232
233
|
return ep.endsWith("/ingest") ? `${ep.slice(0, -"/ingest".length)}/register` : `${ep}/register`;
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
/**
|
|
237
|
+
* The store item the usage account names, or null.
|
|
238
|
+
*
|
|
239
|
+
* A name, never a value: the resolver reads the accounts the preferences
|
|
240
|
+
* describe, so a file written before accounts existed answers the same as one
|
|
241
|
+
* written after.
|
|
242
|
+
*/
|
|
243
|
+
function usageEntryName(prefs) {
|
|
244
|
+
const named = itemNames(prefs).find((x) => x.service === "usage_ingest" && x.slot === "token");
|
|
245
|
+
return named?.item ?? null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The token already in the store, for the destination it is about to reach.
|
|
250
|
+
*
|
|
251
|
+
* The account resolver decides which usage account answers and whether it
|
|
252
|
+
* covers `url`; a destination it does not cover produces nothing rather than
|
|
253
|
+
* the token this machine happens to hold. Each installed host's store is asked
|
|
254
|
+
* in turn, as a read of the same account.
|
|
255
|
+
*/
|
|
256
|
+
function storedToken(prefs, stores, url) {
|
|
257
|
+
const request = { service: "usage_ingest", url };
|
|
258
|
+
const resolverPrefs = usagePrefs(prefs?.global);
|
|
238
259
|
for (const store of stores) {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
const answer = resolveSecret(request, {
|
|
261
|
+
prefs: resolverPrefs,
|
|
262
|
+
env: { ...process.env, CRED_STORE: store },
|
|
263
|
+
});
|
|
264
|
+
if (answer.ok && answer.secret.trim()) return answer.secret.trim();
|
|
242
265
|
}
|
|
243
266
|
return null;
|
|
244
267
|
}
|
|
@@ -1046,8 +1069,8 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1046
1069
|
pre.reason,
|
|
1047
1070
|
);
|
|
1048
1071
|
// The stored token stays in memory and is sent only in the check's header.
|
|
1049
|
-
const stored = identityMatters ? storedToken(prefs, stores) : null;
|
|
1050
1072
|
const checkAt = registerUrl(prefs.global?.usageLog?.endpoint);
|
|
1073
|
+
const stored = identityMatters ? storedToken(prefs, stores, checkAt) : null;
|
|
1051
1074
|
if (
|
|
1052
1075
|
stored &&
|
|
1053
1076
|
!opts.dryRun &&
|
|
@@ -1110,7 +1133,7 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1110
1133
|
// machine keeps it off: a feedback run reaches this point for the token
|
|
1111
1134
|
// alone, and optOut covers passive collection.
|
|
1112
1135
|
if (current.global?.usageLog?.enabled !== true && !opts.dryRun) {
|
|
1113
|
-
const name = current
|
|
1136
|
+
const name = usageEntryName(current);
|
|
1114
1137
|
if (persistPrefs(prefsPath, name)) {
|
|
1115
1138
|
say(" -> operational reporting: enabled (a token was already onboarded)");
|
|
1116
1139
|
sendInstalledVersion(prefsPath);
|
|
@@ -1217,9 +1240,9 @@ export async function register(argv, { ingestRejected = false } = {}) {
|
|
|
1217
1240
|
|
|
1218
1241
|
const optedOut = prefs.global?.usageLog?.optOut === true;
|
|
1219
1242
|
// A rejected token is overwritten in its own entry rather than left beside a new one.
|
|
1220
|
-
const mapped = current
|
|
1243
|
+
const mapped = usageEntryName(current);
|
|
1221
1244
|
const entry =
|
|
1222
|
-
rejected &&
|
|
1245
|
+
rejected && mapped && /^[A-Za-z0-9._-]{1,128}$/.test(mapped)
|
|
1223
1246
|
? mapped
|
|
1224
1247
|
: `${process.env.USER || user}_Usage_Ingest_Token`;
|
|
1225
1248
|
const set = stores.length
|