@mmerterden/multi-agent-pipeline 23.7.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 +38 -1
- package/README.md +57 -24
- package/README.tr.md +41 -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 +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 +5 -4
- 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/stack/SKILL.md +1 -1
- 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-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/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 +28 -1
- package/pipeline/multi-agent-refs/help/tr.md +28 -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-5-report.md +12 -10
- 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 +28 -10
- package/pipeline/office/index.html +3 -3
- 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 +19 -1
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +331 -4
- 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 +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 +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/rework-escalation.mjs +19 -4
- 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
|
@@ -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
|
|
@@ -51,7 +51,6 @@ import { DEFAULT_ENDPOINT, canonicalEndpoint, registerUrlAllowed } from "../lib/
|
|
|
51
51
|
import { homedir, platform } from "os";
|
|
52
52
|
import { dirname, join } from "path";
|
|
53
53
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
54
|
-
import { execFileSync } from "child_process";
|
|
55
54
|
import { randomBytes } from "crypto";
|
|
56
55
|
import { costUsd } from "./_cost.mjs";
|
|
57
56
|
import { defaultPrefsPath, identityHidden, resolveReportingLogin } from "./usage-identity.mjs";
|
|
@@ -59,6 +58,7 @@ import { installedVersion, lifecycleEvent } from "../lib/usage-lifecycle.mjs";
|
|
|
59
58
|
import { lockTimeoutFrom, updateJsonFileSync } from "../lib/json-file-lock.mjs";
|
|
60
59
|
import { ALWAYS_ON, KNOWN_STACKS, STACK_PLUGIN_ALIAS } from "./_stack-routing.mjs";
|
|
61
60
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
61
|
+
import { resolveSecret } from "../lib/service-account.mjs";
|
|
62
62
|
import { detachSelf, shouldDetach } from "../lib/detach-self.mjs";
|
|
63
63
|
import { isPublicMcpServer, publicServerName } from "../lib/public-mcp-servers.mjs";
|
|
64
64
|
import { MCP_SERVER_ID } from "../lib/mcp-rename.mjs";
|
|
@@ -227,32 +227,22 @@ function resolvePrefs() {
|
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
229
|
* Resolve the ingest token without ever storing it in a synced file.
|
|
230
|
-
*
|
|
231
|
-
* prefs.
|
|
232
|
-
*
|
|
230
|
+
*
|
|
231
|
+
* Order: env, then prefs.usageLog.token, then the account resolver, which
|
|
232
|
+
* reads the store only for the endpoint this report is actually being sent
|
|
233
|
+
* to. That last step is the change: before it, the token was read whatever
|
|
234
|
+
* the endpoint was, so an endpoint edited in the preferences file carried the
|
|
235
|
+
* same token to somewhere else entirely.
|
|
233
236
|
*/
|
|
234
237
|
function resolveToken() {
|
|
235
238
|
if (process.env.MULTI_AGENT_USAGE_TOKEN) return process.env.MULTI_AGENT_USAGE_TOKEN;
|
|
236
239
|
const g = resolveGlobalPrefs();
|
|
237
240
|
const inline = g.usageLog?.token;
|
|
238
241
|
if (typeof inline === "string" && inline.trim()) return inline.trim();
|
|
239
|
-
const
|
|
240
|
-
if (typeof
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
try {
|
|
244
|
-
const out = execFileSync("bash", [store, "get", name.trim()], {
|
|
245
|
-
encoding: "utf-8",
|
|
246
|
-
timeout: 4000,
|
|
247
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
248
|
-
}).trim();
|
|
249
|
-
if (out) return out;
|
|
250
|
-
} catch {
|
|
251
|
-
/* keychain unavailable - stay silent */
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
return "";
|
|
242
|
+
const endpoint = g.usageLog?.endpoint;
|
|
243
|
+
if (typeof endpoint !== "string" || !endpoint.trim()) return "";
|
|
244
|
+
const answer = resolveSecret({ service: "usage_ingest", url: endpoint.trim() });
|
|
245
|
+
return answer.ok ? answer.secret.trim() : "";
|
|
256
246
|
}
|
|
257
247
|
|
|
258
248
|
// A plugin key mapped to `false` is de-selected (e.g. /multi-agent:stack writes
|
|
@@ -658,14 +648,25 @@ function commandName(state) {
|
|
|
658
648
|
* invoked command when it names a mode, an explicit state.mode, the autopilot
|
|
659
649
|
* flag (the mode phases.json marks autopilot: true), then "full", which is
|
|
660
650
|
* what an absent mode means in agent-state.schema.json.
|
|
651
|
+
*
|
|
652
|
+
* A run that carries the autopilot flag resolves to the unattended variant of
|
|
653
|
+
* whatever mode it is in, when the contract declares one: `/multi-agent:analysis
|
|
654
|
+
* <ref> autopilot` is `analysis-autopilot`, not the attended `analysis` it would
|
|
655
|
+
* otherwise read as. The panel's whole question about a mode is what it cost
|
|
656
|
+
* and how it ended, and those differ between the two.
|
|
661
657
|
*/
|
|
662
658
|
export function modeOf(state, modes = allowedModes()) {
|
|
663
659
|
const names = Object.keys(modes);
|
|
664
660
|
const has = (n) => typeof n === "string" && names.includes(n);
|
|
661
|
+
const unattended = (n) => {
|
|
662
|
+
if (!state.autopilot || modes[n]?.autopilot === true) return n;
|
|
663
|
+
const variant = names.find((v) => v === `${n}-autopilot` && modes[v]?.autopilot === true);
|
|
664
|
+
return variant || n;
|
|
665
|
+
};
|
|
665
666
|
const cmd = commandName(state);
|
|
666
|
-
if (has(cmd)) return cmd;
|
|
667
|
+
if (has(cmd)) return unattended(cmd);
|
|
667
668
|
if (typeof state.mode === "string" && state.mode.trim()) {
|
|
668
|
-
return has(state.mode.trim()) ? state.mode.trim() : "unknown";
|
|
669
|
+
return has(state.mode.trim()) ? unattended(state.mode.trim()) : "unknown";
|
|
669
670
|
}
|
|
670
671
|
if (state.autopilot === true) {
|
|
671
672
|
const ap = names.find((n) => modes[n]?.autopilot === true);
|
|
@@ -1363,9 +1364,13 @@ async function selfHeal(rejectedToken) {
|
|
|
1363
1364
|
* The login to name a run after. A context that cannot see this machine's
|
|
1364
1365
|
* accounts (usage-identity.mjs `hidden`) falls back to the login an earlier
|
|
1365
1366
|
* check cached; the server names the record after the token's login anyway.
|
|
1367
|
+
*
|
|
1368
|
+
* `write: false` resolves without caching the answer in preferences. A dry run
|
|
1369
|
+
* passes it: the environment it resolves under is its caller's, not the one a
|
|
1370
|
+
* real send would use, so remembering its verdict would decide the next run.
|
|
1366
1371
|
*/
|
|
1367
|
-
function reportingLogin(prefs) {
|
|
1368
|
-
const who = registeredLogin(prefs) ?? resolveReportingLogin();
|
|
1372
|
+
function reportingLogin(prefs, { write = true } = {}) {
|
|
1373
|
+
const who = registeredLogin(prefs) ?? resolveReportingLogin({ write });
|
|
1369
1374
|
if (who.login || !who.hidden) return who;
|
|
1370
1375
|
const cached = typeof prefs?.login === "string" ? prefs.login.trim() : "";
|
|
1371
1376
|
return /^[A-Za-z0-9][A-Za-z0-9_-]{0,38}$/.test(cached) ? { ...who, login: cached } : who;
|
|
@@ -1449,7 +1454,7 @@ async function main() {
|
|
|
1449
1454
|
if (args.status) state.status = args.status;
|
|
1450
1455
|
const kind = EVENT_KINDS.includes(args.event) ? args.event : null;
|
|
1451
1456
|
|
|
1452
|
-
const who = reportingLogin(prefs);
|
|
1457
|
+
const who = reportingLogin(prefs, { write: !args.dryRun });
|
|
1453
1458
|
if (!who.login) {
|
|
1454
1459
|
process.stderr.write(`usage-report: not sent - ${who.reason}\n`);
|
|
1455
1460
|
if (!args.dryRun) {
|
|
@@ -43,7 +43,17 @@ await import("../lib/cli-help.mjs").then(
|
|
|
43
43
|
() => {},
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
// The same families anonymize-findings writes back, derived from the host
|
|
47
|
+
// registry rather than listed twice. This script also runs copied on its own,
|
|
48
|
+
// without lib/ beside it, so the import is optional the way --help is: there
|
|
49
|
+
// the hand-written floor applies and no reviewer value is rejected for being
|
|
50
|
+
// newer than this copy.
|
|
51
|
+
const ALLOWED_REVIEWERS = new Set(
|
|
52
|
+
await import("../lib/reviewer-families.mjs").then(
|
|
53
|
+
(m) => m.FAMILIES,
|
|
54
|
+
() => ["fable", "opus", "sonnet", "gpt", "local"],
|
|
55
|
+
),
|
|
56
|
+
);
|
|
47
57
|
const FOUND_BY_RE = /^(Source [A-Z]|security-auditor)$/;
|
|
48
58
|
const ANONYMIZED = process.argv.includes("--anonymized");
|
|
49
59
|
const ALLOWED_SEVERITIES = new Set(["blocking", "important", "suggestion"]);
|
|
@@ -63,11 +63,10 @@ import { spawnAsync } from "./_spawn-async.mjs";
|
|
|
63
63
|
import { readRegularJson } from "../lib/regular-file.mjs";
|
|
64
64
|
import { runMain } from "../lib/fatal.mjs";
|
|
65
65
|
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
66
|
-
import {
|
|
66
|
+
import { authHeaderAsync, selectAccount } from "../lib/service-account.mjs";
|
|
67
67
|
import { homedir } from "node:os";
|
|
68
68
|
import { affected } from "./graph-affected.mjs";
|
|
69
69
|
import { loadGraph } from "./graph-query.mjs";
|
|
70
|
-
import { prefsPath } from "../lib/prefs-value.mjs";
|
|
71
70
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
72
71
|
|
|
73
72
|
exitOnHelp(import.meta.url);
|
|
@@ -181,33 +180,31 @@ async function accountEnv(env, account) {
|
|
|
181
180
|
* credential store and travels in the request header only.
|
|
182
181
|
*/
|
|
183
182
|
async function bitbucketPrs(env) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
183
|
+
// Account first, then its host, then a header bound to that host. The
|
|
184
|
+
// transport rule, the basic-or-bearer choice and the environment fallback
|
|
185
|
+
// all live in the resolver now, so this reads one answer instead of
|
|
186
|
+
// assembling four.
|
|
187
|
+
// A host in the environment is a destination, not a setting: it is passed
|
|
188
|
+
// to the resolver, which refuses it when no account covers it and when it
|
|
189
|
+
// is not a host a token may be sent to at all.
|
|
190
|
+
const asked = String(env.MA_BITBUCKET_HOST ?? "").trim();
|
|
191
|
+
const chosen = selectAccount({ service: "bitbucket", url: asked || undefined }, { env });
|
|
192
|
+
if (!chosen.ok) {
|
|
193
|
+
const reason =
|
|
194
|
+
chosen.reason === "not-configured"
|
|
195
|
+
? "not configured"
|
|
196
|
+
: chosen.reason === "insecure-url"
|
|
197
|
+
? "https required"
|
|
198
|
+
: chosen.message;
|
|
199
|
+
return { ok: false, items: [], reason };
|
|
192
200
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
const token =
|
|
201
|
-
env.MA_BITBUCKET_TOKEN ||
|
|
202
|
-
(await resolveTokenAsync("bitbucket_token", "BITBUCKET_TOKEN", { env }));
|
|
203
|
-
if (!token) return { ok: false, items: [], reason: "no token in the credential store" };
|
|
204
|
-
// The same rule as credential-inventory.sh: Basic with the stored user (an
|
|
205
|
-
// app password), else the token as a bearer.
|
|
206
|
-
const user =
|
|
207
|
-
env.MA_BITBUCKET_USER || (await resolveTokenAsync("bitbucket_user", "BITBUCKET_USER", { env }));
|
|
208
|
-
const authorization = user
|
|
209
|
-
? "Basic " + Buffer.from(`${user}:${token}`).toString("base64")
|
|
210
|
-
: `Bearer ${token}`;
|
|
201
|
+
const base = chosen.account.baseUrl ?? `https://${chosen.account.hosts[0]}`;
|
|
202
|
+
const header = await authHeaderAsync(
|
|
203
|
+
{ service: "bitbucket", url: base, scheme: "basic-or-bearer" },
|
|
204
|
+
{ env },
|
|
205
|
+
);
|
|
206
|
+
if (!header.ok) return { ok: false, items: [], reason: header.message };
|
|
207
|
+
const authorization = header.value;
|
|
211
208
|
const items = [];
|
|
212
209
|
try {
|
|
213
210
|
for (const role of ["REVIEWER", "AUTHOR"]) {
|