crysk 0.5.1 → 0.6.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/README.md +2 -1
- package/package.json +3 -2
- package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
- package/src/asset-manifest.ts +11 -0
- package/src/assets.ts +1 -1
- package/src/ci/credential-refresh.ts +524 -0
- package/src/ci/crysk-secrets.ts +20 -6
- package/src/ci/outcome.ts +165 -15
- package/src/ci/platform.ts +155 -7
- package/src/ci/setup.ts +64 -6
- package/src/ci/trigger.ts +20 -4
- package/src/commands/ci-setup.ts +12 -3
- package/src/commands/doctor.ts +25 -23
- package/src/diversity/identity.ts +11 -1
- package/src/diversity/pipeline-integration.ts +19 -6
- package/src/doctor.ts +133 -4
- package/src/execution/contracts.ts +15 -3
- package/src/harness/materiality-judge.ts +153 -0
- package/src/harness/pipeline-plan.ts +133 -0
- package/src/harness/replay-rows.ts +172 -0
- package/src/harness/route-runner.ts +288 -0
- package/src/harness/single-step.ts +153 -0
- package/src/index.ts +1 -1
- package/src/model/catalog.ts +10 -7
- package/src/model/model-name.ts +14 -0
- package/src/model/profiles/claude.ts +34 -0
- package/src/model/profiles/openai.ts +44 -0
- package/src/model/profiles.ts +213 -0
- package/src/model/routing.ts +155 -50
- package/src/pr/plan.ts +6 -1
- package/src/pr/review-pr.ts +32 -6
- package/src/pr/target.ts +16 -7
- package/src/production-runtime.ts +100 -13
- package/src/review/pipeline.ts +193 -58
- package/src/review/preflight.ts +91 -9
- package/src/review/prompt-set.ts +68 -0
- package/src/review/review.ts +21 -11
- package/src/review/route-preflight.ts +117 -67
- package/src/review/run.ts +34 -4
- package/src/security/credential-broker.ts +21 -9
- package/src/security/oauth-providers.ts +101 -0
- package/src/transport-registry.ts +33 -0
- package/src/transports/opencode-sdk.ts +33 -1
- package/src/ui/config-edit.ts +9 -0
- package/src/ui/config.ts +1 -0
- package/src/ui/menu.ts +9 -2
- package/src/updater.ts +21 -13
- package/src/wizard.ts +23 -0
package/src/review/preflight.ts
CHANGED
|
@@ -18,9 +18,22 @@ import {
|
|
|
18
18
|
type ModelsConfig,
|
|
19
19
|
parseModelsConfig,
|
|
20
20
|
} from "#model/model-name";
|
|
21
|
+
import {
|
|
22
|
+
FALLBACK_PROFILE,
|
|
23
|
+
type ModelProfile,
|
|
24
|
+
profileIdProblem,
|
|
25
|
+
profileJudgeModels,
|
|
26
|
+
profileModelAlias,
|
|
27
|
+
profileRoute,
|
|
28
|
+
resolveProfile,
|
|
29
|
+
} from "#model/profiles";
|
|
21
30
|
import { judgeModelChoice } from "#model/routing";
|
|
22
31
|
import { POST_MIN_SEVERITIES, type PostMinSeverity } from "#pr/post-floor";
|
|
23
|
-
import
|
|
32
|
+
import {
|
|
33
|
+
type ProfilePromptSets,
|
|
34
|
+
profilePromptSet,
|
|
35
|
+
type SuspicionPrior,
|
|
36
|
+
} from "#review/prompt-set";
|
|
24
37
|
import { type AgentSpec, isSafeSlug, type ReviewSpec } from "#review/spec";
|
|
25
38
|
import {
|
|
26
39
|
ADJUDICATED_TAGS,
|
|
@@ -60,10 +73,12 @@ export const DEFAULT_GC_INTERVAL_MIN = 360;
|
|
|
60
73
|
|
|
61
74
|
export const DEFAULT_HEAD_REF = "HEAD";
|
|
62
75
|
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
// only the honest model label shown in a preflight plan.
|
|
66
|
-
export const DEFAULT_SUMMARY_MODEL =
|
|
76
|
+
// The `claude` profile's summary model as a CLI alias (model-profiles S2),
|
|
77
|
+
// which prompts/summarizer.md's frontmatter also names while it keeps the
|
|
78
|
+
// line. This value is only the honest model label shown in a preflight plan.
|
|
79
|
+
export const DEFAULT_SUMMARY_MODEL = profileModelAlias(
|
|
80
|
+
profileRoute(FALLBACK_PROFILE, "summary").model,
|
|
81
|
+
);
|
|
67
82
|
|
|
68
83
|
export interface CliOptions {
|
|
69
84
|
// Relative on purpose: parseArgs is pure, so "resolve against cwd" is the
|
|
@@ -1609,6 +1624,11 @@ export interface AgentsDirResolution {
|
|
|
1609
1624
|
kind: "dir" | "bundled";
|
|
1610
1625
|
// Logical filename -> readable path. Present iff `kind === "bundled"`.
|
|
1611
1626
|
files?: Record<string, string>;
|
|
1627
|
+
// The model profile's prompt set merged over the default one
|
|
1628
|
+
// (model-profiles S4), present only when that set overrides an agent file.
|
|
1629
|
+
// It names the merged set in provenance, as a directory basename names a
|
|
1630
|
+
// user set. Absent: the default set itself, exactly as before profiles.
|
|
1631
|
+
promptSet?: string;
|
|
1612
1632
|
}
|
|
1613
1633
|
|
|
1614
1634
|
// The label the shipped binary shows wherever a prompt-set path would go.
|
|
@@ -1686,6 +1706,11 @@ export function resolveAgentsDirSetting(input: {
|
|
|
1686
1706
|
// inside the default branch so an explicit flag, config or env never pays
|
|
1687
1707
|
// for asset detection.
|
|
1688
1708
|
assets?: EngineAssets | undefined;
|
|
1709
|
+
// The active model profile (model-profiles S4). Absent: `claude`, whose
|
|
1710
|
+
// default set is the bundled one. `promptSets` is injected by tests only:
|
|
1711
|
+
// no profile ships a set yet (asset-manifest.ts PROFILE_PROMPT_FILES).
|
|
1712
|
+
profile?: ModelProfile | undefined;
|
|
1713
|
+
promptSets?: ProfilePromptSets | undefined;
|
|
1689
1714
|
}): AgentsDirResolution {
|
|
1690
1715
|
if (input.flag) {
|
|
1691
1716
|
return {
|
|
@@ -1709,6 +1734,28 @@ export function resolveAgentsDirSetting(input: {
|
|
|
1709
1734
|
};
|
|
1710
1735
|
}
|
|
1711
1736
|
const assets = input.assets ?? resolveEngineAssets();
|
|
1737
|
+
// The active profile's prompt set, file by file over the default set (S4).
|
|
1738
|
+
// Only here, in the default branch: a person's `--agents`, `agents_dir` or
|
|
1739
|
+
// env set above outranks the profile and is never mixed with it. With no
|
|
1740
|
+
// agent override (`claude`, or a set that only changes root prompts) the
|
|
1741
|
+
// resolution below is today's, byte for byte.
|
|
1742
|
+
const overrides = profilePromptSet(
|
|
1743
|
+
input.profile ?? FALLBACK_PROFILE,
|
|
1744
|
+
Object.keys(assets.bundledAgentFiles),
|
|
1745
|
+
input.promptSets,
|
|
1746
|
+
).agents;
|
|
1747
|
+
const setName = (input.profile ?? FALLBACK_PROFILE).promptSet;
|
|
1748
|
+
if (Object.keys(overrides).length > 0 && setName !== undefined) {
|
|
1749
|
+
// A MAP, like the compiled binary's: the files now live in two places, so
|
|
1750
|
+
// there is no single directory to join a basename onto.
|
|
1751
|
+
return {
|
|
1752
|
+
dir: `${BUNDLED_AGENTS_DIR_LABEL}, prompt set ${setName}`,
|
|
1753
|
+
source: "default",
|
|
1754
|
+
kind: "bundled",
|
|
1755
|
+
files: { ...assets.bundledAgentFiles, ...overrides },
|
|
1756
|
+
promptSet: setName,
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1712
1759
|
// The compiled binary's default set is a MAP, never a directory: its
|
|
1713
1760
|
// `defaultAgentsDir` is `path.dirname(<embedded path>)`, i.e. "/$bunfs/root",
|
|
1714
1761
|
// which no `existsSync` accepts and no `Bun.Glob` can scan. Handing that
|
|
@@ -2021,6 +2068,12 @@ export function resolveAgentsDir(
|
|
|
2021
2068
|
// detectAssetMode() reads `import.meta.dir` and always reports "dev" under
|
|
2022
2069
|
// `bun test`.
|
|
2023
2070
|
assets?: EngineAssets,
|
|
2071
|
+
// The active model profile and, in tests only, its prompt sets
|
|
2072
|
+
// (model-profiles S4). Absent: `claude`, today's resolution.
|
|
2073
|
+
prompts: Pick<
|
|
2074
|
+
Parameters<typeof resolveAgentsDirSetting>[0],
|
|
2075
|
+
"profile" | "promptSets"
|
|
2076
|
+
> = {},
|
|
2024
2077
|
): AgentsDirResolution {
|
|
2025
2078
|
const seat = agentsDirSeat({
|
|
2026
2079
|
config: loaded.effective,
|
|
@@ -2034,6 +2087,7 @@ export function resolveAgentsDir(
|
|
|
2034
2087
|
env: readBrandEnv(process.env, "AGENTS_DIR")?.value,
|
|
2035
2088
|
cwd: process.cwd(),
|
|
2036
2089
|
...(assets === undefined ? {} : { assets }),
|
|
2090
|
+
...prompts,
|
|
2037
2091
|
});
|
|
2038
2092
|
// Only a DIRECTORY can be checked for existence, and this gate running
|
|
2039
2093
|
// unconditionally is the whole shipped defect: the compiled binary's bundled
|
|
@@ -2193,6 +2247,9 @@ export const CONFIG_DIRECTION: Record<keyof LocalConfig, ConfigDirection> = {
|
|
|
2193
2247
|
// model or another bill. Both are PERSON_ONLY_KEYS, refused in a repo file.
|
|
2194
2248
|
models: "person",
|
|
2195
2249
|
credentials: "person",
|
|
2250
|
+
// Which model profile the review runs (openai-profile S1): it picks every
|
|
2251
|
+
// step's model and so the bill, like `models`, so it is person-only too.
|
|
2252
|
+
profile: "person",
|
|
2196
2253
|
max_verification_steps: "capped",
|
|
2197
2254
|
max_concurrent_steps: "capped",
|
|
2198
2255
|
max_changed_lines: "capped",
|
|
@@ -2238,6 +2295,9 @@ export interface LocalConfig {
|
|
|
2238
2295
|
models?: ModelsConfig;
|
|
2239
2296
|
// Which Claude credential is used, in order (S5).
|
|
2240
2297
|
credentials?: CredentialsConfig;
|
|
2298
|
+
// The model profile id (openai-profile S1). Absent: the fallback profile.
|
|
2299
|
+
// `models` still outranks it role by role.
|
|
2300
|
+
profile?: string;
|
|
2241
2301
|
// Item 7: unattended bound on the verify queue. Absent means
|
|
2242
2302
|
// DEFAULT_MAX_VERIFICATION_STEPS. 0 is legal — every queued prior lands
|
|
2243
2303
|
// `unconfirmed` (the pause switch, same shape as watch daily_cap).
|
|
@@ -2315,8 +2375,8 @@ const KNOWN_CONFIG_KEYS = new Set<string>(Object.keys(CONFIG_DIRECTION));
|
|
|
2315
2375
|
|
|
2316
2376
|
// Keys a committed repo file may never set. Wider than "direction is person":
|
|
2317
2377
|
// `agents_dir` and `post_min_severity` are person-direction keys a repo file
|
|
2318
|
-
// may still name. These
|
|
2319
|
-
const PERSON_ONLY_KEYS = new Set<string>(["models", "credentials"]);
|
|
2378
|
+
// may still name. These three choose a model or a bill.
|
|
2379
|
+
const PERSON_ONLY_KEYS = new Set<string>(["models", "credentials", "profile"]);
|
|
2320
2380
|
|
|
2321
2381
|
const LOCAL_CONFIG_KEYS = new Set<string>(
|
|
2322
2382
|
Object.keys(CONFIG_DIRECTION).filter((key) => !PERSON_ONLY_KEYS.has(key)),
|
|
@@ -2493,6 +2553,7 @@ function parseConfigLayer(
|
|
|
2493
2553
|
throw new CliUsageError(`suspicion_priors[${i}].reason required`);
|
|
2494
2554
|
}
|
|
2495
2555
|
}
|
|
2556
|
+
const profile = parseProfile(config.profile, file);
|
|
2496
2557
|
const summaryParse = parseSummaryConfig(config.summary, file);
|
|
2497
2558
|
const summary = summaryParse?.summary;
|
|
2498
2559
|
let models = parseModels(config.models, file);
|
|
@@ -2517,11 +2578,14 @@ function parseConfigLayer(
|
|
|
2517
2578
|
}
|
|
2518
2579
|
// The judge's list is kept as written (the plan skips what it cannot
|
|
2519
2580
|
// use), but a model it will never run on is said out loud here, once.
|
|
2581
|
+
// Checked against this file's own profile: `profile` and `models` are both
|
|
2582
|
+
// person-only, so they are always read from the same file.
|
|
2520
2583
|
if (models?.judge !== undefined) {
|
|
2521
|
-
const
|
|
2584
|
+
const active = resolveProfile(profile);
|
|
2585
|
+
const { model, dropped } = judgeModelChoice(models, active);
|
|
2522
2586
|
if (dropped.length > 0) {
|
|
2523
2587
|
warnings?.push(
|
|
2524
|
-
`${file}: models.judge skips ${dropped.join(", ")}: the materiality judge runs only on
|
|
2588
|
+
`${file}: models.judge skips ${dropped.join(", ")}: the materiality judge runs only on ${profileJudgeModels(active).join(" or ")}${model === undefined ? ", so it stands down" : ""}.`,
|
|
2525
2589
|
);
|
|
2526
2590
|
}
|
|
2527
2591
|
}
|
|
@@ -2611,6 +2675,7 @@ function parseConfigLayer(
|
|
|
2611
2675
|
...(summary === undefined ? {} : { summary }),
|
|
2612
2676
|
...(models === undefined ? {} : { models }),
|
|
2613
2677
|
...(credentials === undefined ? {} : { credentials }),
|
|
2678
|
+
...(profile === undefined ? {} : { profile }),
|
|
2614
2679
|
...(maxVerificationSteps === undefined
|
|
2615
2680
|
? {}
|
|
2616
2681
|
: { max_verification_steps: maxVerificationSteps }),
|
|
@@ -2654,6 +2719,16 @@ function parseConfigLayer(
|
|
|
2654
2719
|
};
|
|
2655
2720
|
}
|
|
2656
2721
|
|
|
2722
|
+
// The `profile` id (openai-profile S1): one of the registered profiles.
|
|
2723
|
+
function parseProfile(value: unknown, file: string): string | undefined {
|
|
2724
|
+
if (value === undefined) return undefined;
|
|
2725
|
+
const problem = profileIdProblem(value);
|
|
2726
|
+
if (problem === undefined) return value as string;
|
|
2727
|
+
const got =
|
|
2728
|
+
typeof value === "string" ? ` (got "${redactConfigValue(value)}")` : "";
|
|
2729
|
+
throw new CliUsageError(`${file} ${problem}${got}`);
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2657
2732
|
// The `models` object (S1, S3). Its rules live in model/model-name.ts; this
|
|
2658
2733
|
// adds the file to every message, as every other key's error does.
|
|
2659
2734
|
function parseModels(value: unknown, file: string): ModelsConfig | undefined {
|
|
@@ -3072,6 +3147,11 @@ export function mergeConfig(
|
|
|
3072
3147
|
CONFIG_DIRECTION.credentials,
|
|
3073
3148
|
(layer) => layer.credentials,
|
|
3074
3149
|
);
|
|
3150
|
+
const profile = foldKey(
|
|
3151
|
+
layers,
|
|
3152
|
+
CONFIG_DIRECTION.profile,
|
|
3153
|
+
(layer) => layer.profile,
|
|
3154
|
+
);
|
|
3075
3155
|
const ciReviewPolicy = foldKey(
|
|
3076
3156
|
layers,
|
|
3077
3157
|
CONFIG_DIRECTION.ci_review_policy,
|
|
@@ -3137,6 +3217,7 @@ export function mergeConfig(
|
|
|
3137
3217
|
...(credentials.value === undefined
|
|
3138
3218
|
? {}
|
|
3139
3219
|
: { credentials: credentials.value }),
|
|
3220
|
+
...(profile.value === undefined ? {} : { profile: profile.value }),
|
|
3140
3221
|
...(maxSteps.value === undefined
|
|
3141
3222
|
? {}
|
|
3142
3223
|
: { max_verification_steps: maxSteps.value }),
|
|
@@ -3192,6 +3273,7 @@ export function mergeConfig(
|
|
|
3192
3273
|
summary: { enabled: summaryEnabled.source },
|
|
3193
3274
|
models: models.source,
|
|
3194
3275
|
credentials: credentials.source,
|
|
3276
|
+
profile: profile.source,
|
|
3195
3277
|
max_verification_steps: maxSteps.source,
|
|
3196
3278
|
max_concurrent_steps: maxConcurrentSteps.source,
|
|
3197
3279
|
max_changed_lines: maxLines.source,
|
package/src/review/prompt-set.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// spawn time moves into the driver (renderAgentBody).
|
|
7
7
|
|
|
8
8
|
import { EFFORT_LEVELS, type Effort, isEffort } from "#model/catalog";
|
|
9
|
+
import type { ModelProfile } from "#model/profiles";
|
|
10
|
+
import { PROFILE_PROMPT_FILES } from "../asset-manifest";
|
|
9
11
|
import { wrapBlock } from "./boundary";
|
|
10
12
|
|
|
11
13
|
// Fixed order — the lab's promptSetFingerprint hashes the concatenated files
|
|
@@ -19,6 +21,72 @@ export const AGENT_NAMES = [
|
|
|
19
21
|
"review-refuter",
|
|
20
22
|
] as const;
|
|
21
23
|
|
|
24
|
+
// The engine-owned prompts at `prompts/` root: not part of the fingerprinted
|
|
25
|
+
// agent set (a user `agents_dir` never holds them), but looked up through the
|
|
26
|
+
// active profile's prompt set like every other step's prompt
|
|
27
|
+
// (model-profiles S4).
|
|
28
|
+
export const ENGINE_PROMPT_FILES = [
|
|
29
|
+
"consolidate.md",
|
|
30
|
+
"scout.md",
|
|
31
|
+
"summarizer.md",
|
|
32
|
+
"materiality.md",
|
|
33
|
+
] as const;
|
|
34
|
+
export type EnginePromptFile = (typeof ENGINE_PROMPT_FILES)[number];
|
|
35
|
+
|
|
36
|
+
// Profile prompt sets by name: logical filename -> readable path, holding ONLY
|
|
37
|
+
// the files that differ from the default set (`prompts/profiles/<set>/`,
|
|
38
|
+
// embedded through asset-manifest.ts like every other prompt).
|
|
39
|
+
export type ProfilePromptSets = Readonly<
|
|
40
|
+
Record<string, Readonly<Record<string, string>>>
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
export interface ProfilePromptOverrides {
|
|
44
|
+
// Agent files (`deep-review-*.md`, `review-refuter.md`) the set overrides.
|
|
45
|
+
agents: Record<string, string>;
|
|
46
|
+
// Engine-owned root prompts the set overrides.
|
|
47
|
+
engine: Partial<Record<EnginePromptFile, string>>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The ONE lookup of a profile's prompt set, split into the two places a
|
|
51
|
+
// prompt is read from: the agents (merged over the default set by
|
|
52
|
+
// resolveAgentsDirSetting) and the engine-owned root prompts
|
|
53
|
+
// (enginePromptPath). Any file the set does not hold falls back to the default
|
|
54
|
+
// set's. A profile with no `promptSet` (`claude`) overrides nothing.
|
|
55
|
+
//
|
|
56
|
+
// A set name this build lacks, or a file that overrides nothing in the default
|
|
57
|
+
// set, throws: either is a build defect, and a silent fallback would run the
|
|
58
|
+
// default prompt while the profile reads as tuned.
|
|
59
|
+
export function profilePromptSet(
|
|
60
|
+
profile: Pick<ModelProfile, "id" | "promptSet">,
|
|
61
|
+
defaultAgentFiles: readonly string[],
|
|
62
|
+
sets: ProfilePromptSets = PROFILE_PROMPT_FILES,
|
|
63
|
+
): ProfilePromptOverrides {
|
|
64
|
+
const overrides: ProfilePromptOverrides = { agents: {}, engine: {} };
|
|
65
|
+
if (profile.promptSet === undefined) return overrides;
|
|
66
|
+
const set = sets[profile.promptSet];
|
|
67
|
+
if (set === undefined) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`model profile "${profile.id}" names prompt set "${profile.promptSet}", which this build does not have`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
for (const [file, filePath] of Object.entries(set)) {
|
|
73
|
+
if (defaultAgentFiles.includes(file)) {
|
|
74
|
+
overrides.agents[file] = filePath;
|
|
75
|
+
} else if (isEnginePromptFile(file)) {
|
|
76
|
+
overrides.engine[file] = filePath;
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`prompt set "${profile.promptSet}" holds "${file}", which overrides no file of the default set`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return overrides;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isEnginePromptFile(file: string): file is EnginePromptFile {
|
|
87
|
+
return (ENGINE_PROMPT_FILES as readonly string[]).includes(file);
|
|
88
|
+
}
|
|
89
|
+
|
|
22
90
|
export interface ParsedAgent {
|
|
23
91
|
name: string;
|
|
24
92
|
description: string;
|
package/src/review/review.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from "#review/preflight";
|
|
40
40
|
import { estimateCost } from "#review/report";
|
|
41
41
|
import {
|
|
42
|
+
isBundledAgentsDir,
|
|
42
43
|
pipelineConsolidateInput,
|
|
43
44
|
pipelineMaterialityInput,
|
|
44
45
|
pipelineScoutInput,
|
|
@@ -56,6 +57,7 @@ import {
|
|
|
56
57
|
resolvePipelineRoute,
|
|
57
58
|
resolvePromptSet,
|
|
58
59
|
resolveReviewInstructions,
|
|
60
|
+
routingConfigured,
|
|
59
61
|
selectActiveHunters,
|
|
60
62
|
shadowedGotchasNotice,
|
|
61
63
|
validateGotchas,
|
|
@@ -100,12 +102,14 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
100
102
|
// Two layers since C5, folded by loadEffectiveConfig into the one
|
|
101
103
|
// LocalConfig everything below already expected. The --config missing-file
|
|
102
104
|
// error and the boundary rules live there.
|
|
103
|
-
const { loaded, config, summary, scout, post } = await loadRunConfig(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
|
|
106
|
+
{
|
|
107
|
+
root: repoRoot,
|
|
108
|
+
home: os.homedir(),
|
|
109
|
+
configFlag: options.config,
|
|
110
|
+
options,
|
|
111
|
+
},
|
|
112
|
+
);
|
|
109
113
|
options = { ...options, scout, post };
|
|
110
114
|
// S5: the Claude credential this run uses, chosen once, here, from
|
|
111
115
|
// `credentials.claude` and what is set. Every runner, binding and child below
|
|
@@ -158,6 +162,7 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
158
162
|
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
159
163
|
options,
|
|
160
164
|
loaded,
|
|
165
|
+
{ profile },
|
|
161
166
|
);
|
|
162
167
|
const { dir: agentsDir, source: agentsDirSource } = agents;
|
|
163
168
|
|
|
@@ -250,12 +255,14 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
250
255
|
true,
|
|
251
256
|
);
|
|
252
257
|
const productionRoute = await resolvePipelineRoute({
|
|
253
|
-
modelsConfigured: config
|
|
258
|
+
modelsConfigured: routingConfigured(config),
|
|
254
259
|
workspaceRoot: repoRoot,
|
|
255
260
|
spec,
|
|
256
261
|
options,
|
|
257
262
|
agentFiles,
|
|
263
|
+
bundledAgents: isBundledAgentsDir(agents),
|
|
258
264
|
models: config.models,
|
|
265
|
+
profile,
|
|
259
266
|
summary,
|
|
260
267
|
materialityEnabled: resolveMaterialityGate(config),
|
|
261
268
|
claudeRun: options.dryRun ? undefined : claudeRun,
|
|
@@ -425,6 +432,8 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
425
432
|
gotchasPath,
|
|
426
433
|
agentsDir,
|
|
427
434
|
...(agents.files ? { agentFiles: agents.files } : {}),
|
|
435
|
+
// The same answer the plan was built with (resolvePipelineRoute).
|
|
436
|
+
...(isBundledAgentsDir(agents) ? { bundledAgents: true } : {}),
|
|
428
437
|
runDir,
|
|
429
438
|
outPath: path.join(runDir, "findings.json"),
|
|
430
439
|
mcpConfigPath,
|
|
@@ -432,10 +441,11 @@ export async function review(options: CliOptions): Promise<number> {
|
|
|
432
441
|
...(options.model ? { model: options.model } : {}),
|
|
433
442
|
parityTriggerPaths: config.parity_trigger_paths,
|
|
434
443
|
suspicionPriors: config.suspicion_priors,
|
|
435
|
-
|
|
436
|
-
...
|
|
437
|
-
...
|
|
438
|
-
...
|
|
444
|
+
modelProfile: profile,
|
|
445
|
+
...pipelineSummarizerInput(summary, { profile }),
|
|
446
|
+
...pipelineScoutInput(options, { profile }),
|
|
447
|
+
...pipelineConsolidateInput({ profile }),
|
|
448
|
+
...pipelineMaterialityInput(config, { profile }),
|
|
439
449
|
...(prTitle === undefined ? {} : { prTitle }),
|
|
440
450
|
...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
|
|
441
451
|
...pipelineConfigInput(loaded),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// routes across Claude and OpenCode runners before confirming or spending tokens.
|
|
4
4
|
|
|
5
5
|
import type { ModelsConfig } from "#model/model-name";
|
|
6
|
+
import { FALLBACK_PROFILE, type ModelProfile } from "#model/profiles";
|
|
6
7
|
import {
|
|
7
8
|
capabilityGateDecision,
|
|
8
9
|
produceClaudeCapabilityReport,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
planRoutes,
|
|
14
15
|
type ResolvedRoutePlan,
|
|
15
16
|
} from "#model/routing";
|
|
16
|
-
import { resolveEngineAssets } from "../assets";
|
|
17
|
+
import { type EngineAssets, resolveEngineAssets } from "../assets";
|
|
17
18
|
import { CliError } from "../errors";
|
|
18
19
|
import type { RunnerBackend } from "../execution/contracts";
|
|
19
20
|
import {
|
|
@@ -40,26 +41,79 @@ import {
|
|
|
40
41
|
type TransportRegistry,
|
|
41
42
|
} from "../transport-registry";
|
|
42
43
|
import type { OpenCodeSdkLike } from "../transports/opencode-client";
|
|
43
|
-
import { DEFAULT_CONSOLIDATE_MODEL, DEFAULT_SCOUT_MODEL } from "./pipeline";
|
|
44
44
|
import {
|
|
45
|
+
type AgentsDirResolution,
|
|
45
46
|
type CliOptions,
|
|
46
47
|
type ConfigLayer,
|
|
47
48
|
resolveMaterialityGate,
|
|
48
49
|
type SummarySettings,
|
|
49
50
|
} from "./preflight";
|
|
50
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
type EnginePromptFile,
|
|
53
|
+
type ParsedAgent,
|
|
54
|
+
type ProfilePromptSets,
|
|
55
|
+
profilePromptSet,
|
|
56
|
+
} from "./prompt-set";
|
|
51
57
|
import type { ReviewSpec } from "./spec";
|
|
52
58
|
|
|
59
|
+
// Where the engine-owned root prompts are looked up (model-profiles S4). All
|
|
60
|
+
// optional: production passes nothing, which is the `claude` profile over the
|
|
61
|
+
// runtime's own assets. `promptSets` is injected by tests only, since no
|
|
62
|
+
// profile ships a set yet.
|
|
63
|
+
export interface EnginePromptOptions {
|
|
64
|
+
profile?: ModelProfile;
|
|
65
|
+
promptSets?: ProfilePromptSets;
|
|
66
|
+
assets?: EngineAssets;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// What a production caller hands the pipeline*Input helpers: the run's
|
|
70
|
+
// profile is required (openai-profile S3), so a caller cannot forget it and
|
|
71
|
+
// silently read the fallback profile's prompts.
|
|
72
|
+
export type RunPromptOptions = EnginePromptOptions & { profile: ModelProfile };
|
|
73
|
+
|
|
74
|
+
// THE read site for an engine-owned root prompt: the active profile's set,
|
|
75
|
+
// falling back to the default file. A user `agents_dir` never reaches here:
|
|
76
|
+
// it covers the five agent files only, as it always did.
|
|
77
|
+
export function enginePromptPath(
|
|
78
|
+
file: EnginePromptFile,
|
|
79
|
+
options: EnginePromptOptions = {},
|
|
80
|
+
): string {
|
|
81
|
+
const assets = options.assets ?? resolveEngineAssets();
|
|
82
|
+
const override = profilePromptSet(
|
|
83
|
+
options.profile ?? FALLBACK_PROFILE,
|
|
84
|
+
Object.keys(assets.bundledAgentFiles),
|
|
85
|
+
options.promptSets,
|
|
86
|
+
).engine[file];
|
|
87
|
+
if (override !== undefined) return override;
|
|
88
|
+
switch (file) {
|
|
89
|
+
case "consolidate.md":
|
|
90
|
+
return assets.consolidatePromptPath;
|
|
91
|
+
case "scout.md":
|
|
92
|
+
return assets.scoutPromptPath;
|
|
93
|
+
case "summarizer.md":
|
|
94
|
+
return assets.summarizerPromptPath;
|
|
95
|
+
case "materiality.md":
|
|
96
|
+
return assets.materialityPromptPath;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Every input below marks its prompt `bundled`: it is the engine's own, so its
|
|
101
|
+
// model and effort come from the active profile and never from its
|
|
102
|
+
// frontmatter (S3), in the plan and in the step alike. The materiality judge
|
|
103
|
+
// needs no mark: its model is pinned (judgeModelChoice) and its frontmatter
|
|
104
|
+
// was never read for routing.
|
|
53
105
|
export function pipelineSummarizerInput(
|
|
54
106
|
summary: SummarySettings,
|
|
107
|
+
prompts: RunPromptOptions,
|
|
55
108
|
):
|
|
56
|
-
| { summarizer: { promptPath: string; model?: string } }
|
|
109
|
+
| { summarizer: { promptPath: string; model?: string; bundled: true } }
|
|
57
110
|
| Record<string, never> {
|
|
58
111
|
return summary.enabled
|
|
59
112
|
? {
|
|
60
113
|
summarizer: {
|
|
61
|
-
promptPath:
|
|
114
|
+
promptPath: enginePromptPath("summarizer.md", prompts),
|
|
62
115
|
...(summary.model === undefined ? {} : { model: summary.model }),
|
|
116
|
+
bundled: true,
|
|
63
117
|
},
|
|
64
118
|
}
|
|
65
119
|
: {};
|
|
@@ -73,14 +127,18 @@ export function pipelineSummarizerInput(
|
|
|
73
127
|
// than argued. `prompts/` is the door the summarizer already walked through.
|
|
74
128
|
export function pipelineScoutInput(
|
|
75
129
|
options: Pick<CliOptions, "scout" | "scoutModel">,
|
|
76
|
-
|
|
130
|
+
prompts: RunPromptOptions,
|
|
131
|
+
):
|
|
132
|
+
| { scout: { promptPath: string; model?: string; bundled: true } }
|
|
133
|
+
| Record<string, never> {
|
|
77
134
|
return options.scout
|
|
78
135
|
? {
|
|
79
136
|
scout: {
|
|
80
|
-
promptPath:
|
|
137
|
+
promptPath: enginePromptPath("scout.md", prompts),
|
|
81
138
|
...(options.scoutModel === undefined
|
|
82
139
|
? {}
|
|
83
140
|
: { model: options.scoutModel }),
|
|
141
|
+
bundled: true,
|
|
84
142
|
},
|
|
85
143
|
}
|
|
86
144
|
: {};
|
|
@@ -91,11 +149,14 @@ export function pipelineScoutInput(
|
|
|
91
149
|
// gain on the Martian 50 (lab bench/METRICS.md 2026-10-27), and a failed pass
|
|
92
150
|
// falls back to the unconsolidated findings. The lab's direct `runPipeline`
|
|
93
151
|
// callers do not go through here, so their pipeline is unchanged.
|
|
94
|
-
export function pipelineConsolidateInput(): {
|
|
95
|
-
consolidate: { promptPath: string; model?: string };
|
|
152
|
+
export function pipelineConsolidateInput(prompts: RunPromptOptions): {
|
|
153
|
+
consolidate: { promptPath: string; model?: string; bundled: true };
|
|
96
154
|
} {
|
|
97
155
|
return {
|
|
98
|
-
consolidate: {
|
|
156
|
+
consolidate: {
|
|
157
|
+
promptPath: enginePromptPath("consolidate.md", prompts),
|
|
158
|
+
bundled: true,
|
|
159
|
+
},
|
|
99
160
|
};
|
|
100
161
|
}
|
|
101
162
|
|
|
@@ -106,20 +167,37 @@ export function pipelineConsolidateInput(): {
|
|
|
106
167
|
// travels here.
|
|
107
168
|
export function pipelineMaterialityInput(
|
|
108
169
|
config: Pick<ConfigLayer, "materiality_gate">,
|
|
170
|
+
prompts: RunPromptOptions,
|
|
109
171
|
): { materiality: { promptPath: string } } | Record<string, never> {
|
|
110
172
|
return resolveMaterialityGate(config)
|
|
111
173
|
? {
|
|
112
174
|
materiality: {
|
|
113
|
-
promptPath:
|
|
175
|
+
promptPath: enginePromptPath("materiality.md", prompts),
|
|
114
176
|
},
|
|
115
177
|
}
|
|
116
178
|
: {};
|
|
117
179
|
}
|
|
118
180
|
|
|
181
|
+
// Whether a run's agents are the engine's bundled prompt set, the one input
|
|
182
|
+
// that decides whether their routing comes from the model profile or from
|
|
183
|
+
// their frontmatter (model-profiles S3). The resolution's SOURCE, not its
|
|
184
|
+
// `kind`: `kind === "bundled"` is the compiled binary only, while dev and npm
|
|
185
|
+
// resolve the same bundled set to a real directory with source "default".
|
|
186
|
+
// Every product path reads it here, for the plan and the pipeline alike, so the
|
|
187
|
+
// two can never disagree about it.
|
|
188
|
+
export function isBundledAgentsDir(
|
|
189
|
+
agents: Pick<AgentsDirResolution, "source">,
|
|
190
|
+
): boolean {
|
|
191
|
+
return agents.source === "default";
|
|
192
|
+
}
|
|
193
|
+
|
|
119
194
|
export async function buildCliRoutePlan(params: {
|
|
120
195
|
spec: ReviewSpec;
|
|
121
196
|
options: CliOptions;
|
|
122
197
|
agentFiles: Map<string, ParsedAgent>;
|
|
198
|
+
// isBundledAgentsDir of the run's agents. Required so no caller can drop it
|
|
199
|
+
// and build a plan that disagrees with the steps the pipeline composes.
|
|
200
|
+
bundledAgents: boolean;
|
|
123
201
|
models?: ModelsConfig;
|
|
124
202
|
summary: SummarySettings;
|
|
125
203
|
summarizerEnabled?: boolean;
|
|
@@ -131,80 +209,50 @@ export async function buildCliRoutePlan(params: {
|
|
|
131
209
|
// Defaults OFF, unlike consolidation: the gate is opt-in, and a judge key in
|
|
132
210
|
// the plan changes its fingerprint, so absent must mean today's plan.
|
|
133
211
|
materialityEnabled?: boolean;
|
|
212
|
+
// The active model profile (openai-profile S3): the config's `profile`,
|
|
213
|
+
// resolved once (resolveProfile). Required so the compiler finds every
|
|
214
|
+
// caller: a missed one would silently plan the fallback profile.
|
|
215
|
+
profile: ModelProfile;
|
|
134
216
|
}): Promise<ResolvedRoutePlan> {
|
|
135
217
|
const summarizerEnabled = params.summarizerEnabled ?? params.summary.enabled;
|
|
136
218
|
const scoutEnabled = params.scoutEnabled ?? params.options.scout;
|
|
137
219
|
const consolidateEnabled = params.consolidateEnabled ?? true;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const parsed = await parseAgentFile(
|
|
142
|
-
resolveEngineAssets().summarizerPromptPath,
|
|
143
|
-
);
|
|
144
|
-
summarizerFrontmatter = parsed.model;
|
|
145
|
-
} catch {
|
|
146
|
-
// Engine-owned prompt may be unreadable in tests; route resolution still
|
|
147
|
-
// falls through CLI > spec > frontmatter precedence without it.
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
let scoutFrontmatter: string | undefined;
|
|
151
|
-
if (scoutEnabled) {
|
|
152
|
-
try {
|
|
153
|
-
const parsed = await parseAgentFile(
|
|
154
|
-
resolveEngineAssets().scoutPromptPath,
|
|
155
|
-
);
|
|
156
|
-
scoutFrontmatter = parsed.model;
|
|
157
|
-
} catch {
|
|
158
|
-
// Same contract as the summarizer branch above.
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
let consolidateFrontmatter: string | undefined;
|
|
162
|
-
if (consolidateEnabled) {
|
|
163
|
-
try {
|
|
164
|
-
const parsed = await parseAgentFile(
|
|
165
|
-
resolveEngineAssets().consolidatePromptPath,
|
|
166
|
-
);
|
|
167
|
-
consolidateFrontmatter = parsed.model;
|
|
168
|
-
} catch {
|
|
169
|
-
// Same contract as the summarizer branch above.
|
|
170
|
-
}
|
|
171
|
-
}
|
|
220
|
+
// The root prompts are the engine's own (pipeline*Input marks them), so
|
|
221
|
+
// their frontmatter is not read: the profile holds their seat (S3), the
|
|
222
|
+
// same seat the pipeline gives each step, and the two cannot disagree.
|
|
172
223
|
return buildResolvedRoutePlan({
|
|
173
224
|
agents: params.spec.agents,
|
|
174
225
|
cliModel: params.options.model,
|
|
175
226
|
models: params.models,
|
|
227
|
+
profile: params.profile,
|
|
228
|
+
...(params.bundledAgents ? { bundledAgents: true } : {}),
|
|
176
229
|
frontmatterModel: (agentKey) => params.agentFiles.get(agentKey)?.model,
|
|
177
230
|
...(summarizerEnabled
|
|
178
|
-
? {
|
|
179
|
-
summarizer: {
|
|
180
|
-
model: params.summary.model,
|
|
181
|
-
frontmatterModel: summarizerFrontmatter,
|
|
182
|
-
},
|
|
183
|
-
}
|
|
231
|
+
? { summarizer: { model: params.summary.model, bundled: true } }
|
|
184
232
|
: {}),
|
|
185
233
|
...(scoutEnabled
|
|
186
|
-
? {
|
|
187
|
-
scout: {
|
|
188
|
-
model: params.options.scoutModel,
|
|
189
|
-
frontmatterModel: scoutFrontmatter,
|
|
190
|
-
defaultModel: DEFAULT_SCOUT_MODEL,
|
|
191
|
-
},
|
|
192
|
-
}
|
|
193
|
-
: {}),
|
|
194
|
-
...(consolidateEnabled
|
|
195
|
-
? {
|
|
196
|
-
consolidate: {
|
|
197
|
-
frontmatterModel: consolidateFrontmatter,
|
|
198
|
-
defaultModel: DEFAULT_CONSOLIDATE_MODEL,
|
|
199
|
-
},
|
|
200
|
-
}
|
|
234
|
+
? { scout: { model: params.options.scoutModel, bundled: true } }
|
|
201
235
|
: {}),
|
|
236
|
+
...(consolidateEnabled ? { consolidate: { bundled: true } } : {}),
|
|
202
237
|
...(params.materialityEnabled === true
|
|
203
238
|
? { materiality: true as const }
|
|
204
239
|
: {}),
|
|
205
240
|
});
|
|
206
241
|
}
|
|
207
242
|
|
|
243
|
+
// Whether a run needs the Claude binary's execution authority: always for the
|
|
244
|
+
// legacy no-plan runner (it is the Claude CLI), otherwise only when some route
|
|
245
|
+
// or fallback runs on claude-code. CI skips the Claude install exactly when no
|
|
246
|
+
// step routes to it (routing-claude=false), so this check must agree.
|
|
247
|
+
export function claudeAuthorityRequired(
|
|
248
|
+
routePlan: ResolvedRoutePlan | undefined,
|
|
249
|
+
): boolean {
|
|
250
|
+
if (routePlan === undefined) return true;
|
|
251
|
+
return planRoutes(routePlan).some(
|
|
252
|
+
(step) => step.route.backend === "claude-code",
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
208
256
|
// Whether a plan that failed to build may fall back to the legacy no-plan
|
|
209
257
|
// path (a prompt or `--model` naming a raw Claude id the CLI resolves itself).
|
|
210
258
|
// Never when `models` is set, and never for a model written in the new form:
|
|
@@ -244,7 +292,9 @@ export class OpenCodeCredentialRefusalError extends CredentialRefusalError {
|
|
|
244
292
|
refusal.message,
|
|
245
293
|
{ kind: "credential", failureClass: refusal.failureClass },
|
|
246
294
|
refusal.params,
|
|
247
|
-
|
|
295
|
+
refusal.failureClass === "subscription_expiring"
|
|
296
|
+
? `subscription login for OpenCode provider ${refusal.params.provider} expires within the review; refused before any provider spend`
|
|
297
|
+
: `no credential record for OpenCode provider ${refusal.params.provider}; refused before any provider spend`,
|
|
248
298
|
);
|
|
249
299
|
}
|
|
250
300
|
}
|