crysk 0.5.0 → 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/force-comment.ts +14 -1
- package/src/ci/gates.ts +64 -21
- package/src/ci/outcome.ts +165 -15
- package/src/ci/platform-estimate.ts +111 -0
- package/src/ci/platform-trace.ts +30 -0
- package/src/ci/platform.ts +183 -5
- package/src/ci/reporter.ts +14 -4
- package/src/ci/setup.ts +96 -6
- package/src/ci/trace-bundle.ts +231 -27
- package/src/ci/trace-transcripts.ts +65 -0
- 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/ci-admission-gate.ts +2 -0
- package/src/pr/discovery.ts +18 -0
- package/src/pr/plan.ts +41 -2
- package/src/pr/review-pr.ts +43 -6
- package/src/pr/target.ts +67 -15
- 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/report.ts +4 -0
- package/src/review/review.ts +21 -11
- package/src/review/route-preflight.ts +117 -67
- package/src/review/run.ts +50 -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/ui/plan.ts +8 -3
- package/src/updater.ts +21 -13
- package/src/wizard.ts +23 -0
package/src/pr/plan.ts
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
import { recordPendingCreatedAt, recordReviewing } from "#ci/cli-record";
|
|
24
24
|
import { planCiBudgetSkip } from "#ci/gates";
|
|
25
25
|
import { actionsRunUrl } from "#ci/outcome";
|
|
26
|
+
import { readPlatformEstimate, runCostEstimate } from "#ci/platform-estimate";
|
|
26
27
|
import {
|
|
27
28
|
countFreeRouteSteps,
|
|
28
29
|
type FreeRouteBilling,
|
|
@@ -52,10 +53,12 @@ import {
|
|
|
52
53
|
} from "#review/preflight";
|
|
53
54
|
import type { ParsedAgent } from "#review/prompt-set";
|
|
54
55
|
import { type DiffStat, estimateCost } from "#review/report";
|
|
56
|
+
import { isBundledAgentsDir } from "#review/route-preflight";
|
|
55
57
|
import {
|
|
56
58
|
enforceCapabilityGate,
|
|
57
59
|
type LoadedRunConfig,
|
|
58
60
|
resolvePipelineRoute,
|
|
61
|
+
routingConfigured,
|
|
59
62
|
} from "#review/run";
|
|
60
63
|
import type { SizeGateVerdict } from "#review/size-gate";
|
|
61
64
|
import type { ReviewSpec } from "#review/spec";
|
|
@@ -112,6 +115,8 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
112
115
|
diffFromSha: string;
|
|
113
116
|
diffPath: string;
|
|
114
117
|
diffStat: DiffStat;
|
|
118
|
+
// The whole PR range's stat under the same filters (discovery's prDiffStat).
|
|
119
|
+
prDiffStat: DiffStat;
|
|
115
120
|
droppedPaths: string[];
|
|
116
121
|
sizeGate: SizeGateVerdict;
|
|
117
122
|
sizeGateConfirmed: boolean;
|
|
@@ -122,6 +127,7 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
122
127
|
config: LoadedRunConfig["config"];
|
|
123
128
|
summary: LoadedRunConfig["summary"];
|
|
124
129
|
loaded: LoadedRunConfig["loaded"];
|
|
130
|
+
profile: LoadedRunConfig["profile"];
|
|
125
131
|
isCi: boolean;
|
|
126
132
|
// The one resolution of the run's CI mode (resolveCiPosture, reviewPr). Passed
|
|
127
133
|
// down, never re-resolved here.
|
|
@@ -135,6 +141,8 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
135
141
|
ciAdmissionLedger: CiAdmissionLedgerState | null;
|
|
136
142
|
skipDiscovery: boolean;
|
|
137
143
|
hunterCount: number;
|
|
144
|
+
// Hunters a full review of the whole PR runs (fullReviewHunterCount).
|
|
145
|
+
fullHunterCount: number;
|
|
138
146
|
parityFires: boolean;
|
|
139
147
|
verifyQueue: ReturnType<typeof buildPhaseBQueue>["queued"];
|
|
140
148
|
prepared: PreparedDiscovery;
|
|
@@ -144,7 +152,18 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
144
152
|
params.verifyQueue.length,
|
|
145
153
|
maxVerificationSteps,
|
|
146
154
|
);
|
|
147
|
-
|
|
155
|
+
// cryskai/platform#12: in a platform run the platform's estimate, priced from
|
|
156
|
+
// the setup's models and its recent reviews, replaces the band, which prices
|
|
157
|
+
// every model as Claude. The platform prices the whole pull request, so a run
|
|
158
|
+
// that covers less of it (a re-review whose discovery reads only the commits
|
|
159
|
+
// or paths since the last review, or one that hunts nothing new) scales it by
|
|
160
|
+
// the share of a full review it does, which the band measures
|
|
161
|
+
// (runCostEstimate). Without a platform estimate (standalone, or nothing
|
|
162
|
+
// priceable) the band decides.
|
|
163
|
+
const platformEstimate = params.isCi
|
|
164
|
+
? readPlatformEstimate(process.env)
|
|
165
|
+
: undefined;
|
|
166
|
+
const band = estimateCost(
|
|
148
167
|
params.diffStat,
|
|
149
168
|
params.hunterCount,
|
|
150
169
|
params.summary.enabled && !params.skipDiscovery,
|
|
@@ -152,6 +171,23 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
152
171
|
queuedVerification,
|
|
153
172
|
!params.skipDiscovery,
|
|
154
173
|
);
|
|
174
|
+
// discoveryPaths is null only when the hunters read the full PR range.
|
|
175
|
+
const narrowed =
|
|
176
|
+
params.skipDiscovery || params.prepared.discoveryPaths !== null;
|
|
177
|
+
const estimate = runCostEstimate(
|
|
178
|
+
platformEstimate,
|
|
179
|
+
band,
|
|
180
|
+
narrowed && platformEstimate !== undefined
|
|
181
|
+
? estimateCost(
|
|
182
|
+
params.prDiffStat,
|
|
183
|
+
params.fullHunterCount,
|
|
184
|
+
params.summary.enabled,
|
|
185
|
+
params.options.scout,
|
|
186
|
+
queuedVerification,
|
|
187
|
+
true,
|
|
188
|
+
)
|
|
189
|
+
: undefined,
|
|
190
|
+
);
|
|
155
191
|
// 7b(CI) — the budget gate, immediately after the estimate it reads and
|
|
156
192
|
// BEFORE the plan card/confirm/"committed to spending" commit-status
|
|
157
193
|
// block below: spec 3.1 ("Review MUST halt before agent spawning") is
|
|
@@ -186,6 +222,7 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
186
222
|
prNumber: params.prNumber,
|
|
187
223
|
force: params.options.force,
|
|
188
224
|
ciMode: params.ciMode,
|
|
225
|
+
platformConnected: process.env.CRYSK_PLATFORM_CONNECTED === "true",
|
|
189
226
|
});
|
|
190
227
|
if (budgetPlan !== null) {
|
|
191
228
|
await settleCiGateSkip(
|
|
@@ -208,12 +245,14 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
208
245
|
}
|
|
209
246
|
}
|
|
210
247
|
const productionRoute = await resolvePipelineRoute({
|
|
211
|
-
modelsConfigured: params.config
|
|
248
|
+
modelsConfigured: routingConfigured(params.config),
|
|
212
249
|
workspaceRoot: params.worktreePath,
|
|
213
250
|
spec: params.spec,
|
|
214
251
|
options: params.options,
|
|
215
252
|
agentFiles: params.agentFiles,
|
|
253
|
+
bundledAgents: isBundledAgentsDir({ source: params.agentsDirSource }),
|
|
216
254
|
models: params.config.models,
|
|
255
|
+
profile: params.profile,
|
|
217
256
|
summary: params.summary,
|
|
218
257
|
summarizerEnabled: params.summary.enabled && !params.skipDiscovery,
|
|
219
258
|
scoutEnabled: params.options.scout && !params.skipDiscovery,
|
package/src/pr/review-pr.ts
CHANGED
|
@@ -95,12 +95,15 @@ import {
|
|
|
95
95
|
} from "#review/preflight";
|
|
96
96
|
import { code, estimateCost } from "#review/report";
|
|
97
97
|
import {
|
|
98
|
+
claudeAuthorityRequired,
|
|
99
|
+
isBundledAgentsDir,
|
|
98
100
|
pipelineConsolidateInput,
|
|
99
101
|
pipelineMaterialityInput,
|
|
100
102
|
pipelineScoutInput,
|
|
101
103
|
pipelineSummarizerInput,
|
|
102
104
|
} from "#review/route-preflight";
|
|
103
105
|
import {
|
|
106
|
+
fullReviewHunterCount,
|
|
104
107
|
prepareRunnerForRoute,
|
|
105
108
|
resolveParityFires,
|
|
106
109
|
validateGotchas,
|
|
@@ -280,7 +283,16 @@ export async function reviewPr(
|
|
|
280
283
|
// module.
|
|
281
284
|
const step1 = await resolvePrRunOptions(options, prArg);
|
|
282
285
|
options = step1.options;
|
|
283
|
-
const {
|
|
286
|
+
const {
|
|
287
|
+
operatorRoot,
|
|
288
|
+
prNumber,
|
|
289
|
+
home,
|
|
290
|
+
isCi,
|
|
291
|
+
loaded,
|
|
292
|
+
config,
|
|
293
|
+
summary,
|
|
294
|
+
profile,
|
|
295
|
+
} = step1;
|
|
284
296
|
// S5: the Claude credential this run uses, chosen once, here, from
|
|
285
297
|
// `credentials.claude` and what is set. The CI ceiling, the admission, every
|
|
286
298
|
// runner and binding, and the child read its env, which holds that one
|
|
@@ -308,6 +320,8 @@ export async function reviewPr(
|
|
|
308
320
|
options,
|
|
309
321
|
loaded,
|
|
310
322
|
config,
|
|
323
|
+
summary,
|
|
324
|
+
profile,
|
|
311
325
|
isCi,
|
|
312
326
|
operatorRoot,
|
|
313
327
|
claudeRun,
|
|
@@ -565,6 +579,7 @@ export async function reviewPr(
|
|
|
565
579
|
adjudicationQueue,
|
|
566
580
|
phaseB,
|
|
567
581
|
diffStat,
|
|
582
|
+
prDiffStat,
|
|
568
583
|
sizeGate,
|
|
569
584
|
} = discovery;
|
|
570
585
|
|
|
@@ -585,6 +600,7 @@ export async function reviewPr(
|
|
|
585
600
|
maxChangedLines: gateConfig.maxChangedLines,
|
|
586
601
|
maxChangedFiles: gateConfig.maxChangedFiles,
|
|
587
602
|
ciMode,
|
|
603
|
+
platformConnected: process.env.CRYSK_PLATFORM_CONNECTED === "true",
|
|
588
604
|
});
|
|
589
605
|
if (sizePlan !== null) {
|
|
590
606
|
await settleCiGateSkip(
|
|
@@ -682,6 +698,11 @@ export async function reviewPr(
|
|
|
682
698
|
parityFires,
|
|
683
699
|
});
|
|
684
700
|
const hunterCount = activeHunters.length;
|
|
701
|
+
const fullHunterCount = fullReviewHunterCount(
|
|
702
|
+
spec.agents,
|
|
703
|
+
anchorPatch,
|
|
704
|
+
config.parity_trigger_paths,
|
|
705
|
+
);
|
|
685
706
|
// See resolvePrPlanAndConfirm (src/pr/plan.ts) for the full rationale —
|
|
686
707
|
// the CI budget gate, route/capability resolution, the plan card, the
|
|
687
708
|
// interactive confirm, and the "committed to spending" commit-status
|
|
@@ -698,6 +719,7 @@ export async function reviewPr(
|
|
|
698
719
|
diffFromSha,
|
|
699
720
|
diffPath,
|
|
700
721
|
diffStat,
|
|
722
|
+
prDiffStat,
|
|
701
723
|
droppedPaths: effectiveDiff.droppedPaths,
|
|
702
724
|
sizeGate,
|
|
703
725
|
sizeGateConfirmed,
|
|
@@ -708,6 +730,7 @@ export async function reviewPr(
|
|
|
708
730
|
config,
|
|
709
731
|
summary,
|
|
710
732
|
loaded,
|
|
733
|
+
profile,
|
|
711
734
|
isCi,
|
|
712
735
|
ciMode,
|
|
713
736
|
statusContext,
|
|
@@ -716,6 +739,7 @@ export async function reviewPr(
|
|
|
716
739
|
ciAdmissionLedger,
|
|
717
740
|
skipDiscovery,
|
|
718
741
|
hunterCount,
|
|
742
|
+
fullHunterCount,
|
|
719
743
|
parityFires,
|
|
720
744
|
verifyQueue,
|
|
721
745
|
prepared,
|
|
@@ -771,7 +795,11 @@ export async function reviewPr(
|
|
|
771
795
|
await withCiWorkflowGroup(isCi, "crysk review", log, async () => {
|
|
772
796
|
log(reviewingLine(hunterCount, summary, options));
|
|
773
797
|
// runnerAuthority resolved before confirm with the exact-binding gate.
|
|
774
|
-
|
|
798
|
+
// A plan with no claude-code route never starts the Claude CLI.
|
|
799
|
+
if (
|
|
800
|
+
runnerAuthority.error !== undefined &&
|
|
801
|
+
claudeAuthorityRequired(routePlan)
|
|
802
|
+
) {
|
|
775
803
|
throw new CliError(
|
|
776
804
|
`execution authority unavailable: ${runnerAuthority.error}`,
|
|
777
805
|
);
|
|
@@ -836,6 +864,8 @@ export async function reviewPr(
|
|
|
836
864
|
gotchasPath,
|
|
837
865
|
agentsDir,
|
|
838
866
|
...(agents.files ? { agentFiles: agents.files } : {}),
|
|
867
|
+
// The same answer the plan was built with (pr/plan.ts).
|
|
868
|
+
...(isBundledAgentsDir(agents) ? { bundledAgents: true } : {}),
|
|
839
869
|
runDir,
|
|
840
870
|
outPath: path.join(runDir, "findings.json"),
|
|
841
871
|
mcpConfigPath,
|
|
@@ -843,12 +873,19 @@ export async function reviewPr(
|
|
|
843
873
|
...(options.model ? { model: options.model } : {}),
|
|
844
874
|
parityTriggerPaths: config.parity_trigger_paths,
|
|
845
875
|
suspicionPriors: config.suspicion_priors,
|
|
846
|
-
|
|
847
|
-
...(skipDiscovery
|
|
848
|
-
|
|
876
|
+
modelProfile: profile,
|
|
877
|
+
...(skipDiscovery
|
|
878
|
+
? {}
|
|
879
|
+
: pipelineSummarizerInput(summary, { profile })),
|
|
880
|
+
...(skipDiscovery
|
|
881
|
+
? {}
|
|
882
|
+
: pipelineScoutInput(options, { profile })),
|
|
883
|
+
...(skipDiscovery ? {} : pipelineConsolidateInput({ profile })),
|
|
849
884
|
// Gated on skipDiscovery like consolidation: an empty-delta
|
|
850
885
|
// re-review posts no new findings, so there is nothing to judge.
|
|
851
|
-
...(skipDiscovery
|
|
886
|
+
...(skipDiscovery
|
|
887
|
+
? {}
|
|
888
|
+
: pipelineMaterialityInput(config, { profile })),
|
|
852
889
|
prTitle: target.title,
|
|
853
890
|
...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
|
|
854
891
|
// NOT gated on skipDiscovery: an empty-delta re-review still
|
package/src/pr/target.ts
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
sizeGateUnlimitedNoticeMessage,
|
|
29
29
|
} from "#ci/gates";
|
|
30
30
|
import { formatWorkflowCommand } from "#ci/reporter";
|
|
31
|
+
import { openCodeRoutesBillMetered } from "#ci/setup";
|
|
31
32
|
import { resolveRepoRoot } from "#git/git";
|
|
32
33
|
import { ghCurrentBranchPr, ghPrView } from "#pr/pr";
|
|
33
34
|
import {
|
|
@@ -46,6 +47,7 @@ import {
|
|
|
46
47
|
} from "#review/preflight";
|
|
47
48
|
import type { ParsedAgent, PromptSetIdentity } from "#review/prompt-set";
|
|
48
49
|
import type { estimateCost } from "#review/report";
|
|
50
|
+
import { buildCliRoutePlan, isBundledAgentsDir } from "#review/route-preflight";
|
|
49
51
|
import {
|
|
50
52
|
type LoadedRunConfig,
|
|
51
53
|
loadRunConfig,
|
|
@@ -66,6 +68,7 @@ import {
|
|
|
66
68
|
} from "../home-preflight";
|
|
67
69
|
import type { RunClaudeCredential } from "../security/claude-credential";
|
|
68
70
|
import { resolveOpenCodeAuthPath } from "../security/credential-broker";
|
|
71
|
+
import { readOpenCodeSecretNames } from "../security/opencode-secret-manifest";
|
|
69
72
|
|
|
70
73
|
export interface ResolvedPrRunOptions {
|
|
71
74
|
operatorRoot: string;
|
|
@@ -76,6 +79,7 @@ export interface ResolvedPrRunOptions {
|
|
|
76
79
|
loaded: LoadedRunConfig["loaded"];
|
|
77
80
|
config: LoadedRunConfig["config"];
|
|
78
81
|
summary: LoadedRunConfig["summary"];
|
|
82
|
+
profile: LoadedRunConfig["profile"];
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
// Step 1's first half: the operator root, the PR number, `home`, and the
|
|
@@ -109,12 +113,14 @@ export async function resolvePrRunOptions(
|
|
|
109
113
|
// yet at this point, and a `.crysk/config.json` committed by the PR author
|
|
110
114
|
// must stay unread (O-8). Same loader as local mode, so the two modes
|
|
111
115
|
// cannot drift on precedence.
|
|
112
|
-
const { loaded, config, summary, scout, post } = await loadRunConfig(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
|
|
117
|
+
{
|
|
118
|
+
root: operatorRoot,
|
|
119
|
+
home,
|
|
120
|
+
configFlag: options.config,
|
|
121
|
+
options,
|
|
122
|
+
},
|
|
123
|
+
);
|
|
118
124
|
// ROADMAP Pillar 3 (GitHub Actions CI). isCi folds in HERE, alongside
|
|
119
125
|
// scout/post, so `options.yes` carries the headless bypass (spec 2.1:
|
|
120
126
|
// "MUST run headlessly ... equivalent to --yes") through every downstream
|
|
@@ -135,6 +141,7 @@ export async function resolvePrRunOptions(
|
|
|
135
141
|
loaded,
|
|
136
142
|
config,
|
|
137
143
|
summary,
|
|
144
|
+
profile,
|
|
138
145
|
};
|
|
139
146
|
}
|
|
140
147
|
|
|
@@ -149,6 +156,29 @@ export interface ResolvedPrPromptSet {
|
|
|
149
156
|
gotchasPath: string | undefined;
|
|
150
157
|
}
|
|
151
158
|
|
|
159
|
+
// The OpenCode providers of every route the run resolves, fallbacks included,
|
|
160
|
+
// from the same plan builder the run confirms with (buildCliRoutePlan), so each
|
|
161
|
+
// source routing reads counts the way routing reads it. Undefined when the plan
|
|
162
|
+
// cannot be built here; the run itself surfaces that error at confirm.
|
|
163
|
+
async function openCodeRouteProviders(
|
|
164
|
+
input: Parameters<typeof buildCliRoutePlan>[0],
|
|
165
|
+
): Promise<string[] | undefined> {
|
|
166
|
+
let plan: Awaited<ReturnType<typeof buildCliRoutePlan>>;
|
|
167
|
+
try {
|
|
168
|
+
plan = await buildCliRoutePlan(input);
|
|
169
|
+
} catch {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
const providers = new Set<string>();
|
|
173
|
+
for (const step of plan.steps) {
|
|
174
|
+
for (const route of [step, ...(step.fallbacks ?? [])]) {
|
|
175
|
+
if (route.route.backend === "opencode")
|
|
176
|
+
providers.add(route.route.provider);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return [...providers].sort();
|
|
180
|
+
}
|
|
181
|
+
|
|
152
182
|
// Step 1's second half: the CI budget ceiling (+ its notices), then the
|
|
153
183
|
// prompt set resolution and the gotchas PATH (never the validation itself —
|
|
154
184
|
// see this module's header). Runs after the caller's own
|
|
@@ -161,18 +191,46 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
161
191
|
config: LoadedRunConfig["config"];
|
|
162
192
|
isCi: boolean;
|
|
163
193
|
operatorRoot: string;
|
|
194
|
+
// The summarizer's settings, for its route (openCodeRouteProviders).
|
|
195
|
+
summary: LoadedRunConfig["summary"];
|
|
196
|
+
// The run's profile (openai-profile S3), for the same routes.
|
|
197
|
+
profile: LoadedRunConfig["profile"];
|
|
164
198
|
// S5: the run's Claude credential, chosen once at run start (reviewPr). Its env
|
|
165
199
|
// holds only the chosen credential, so the ceiling follows the choice: the
|
|
166
200
|
// subscription has no metered ceiling, the API key keeps it. Absent (tests that
|
|
167
201
|
// pin the older wiring) reads the process env as before.
|
|
168
202
|
claudeRun?: RunClaudeCredential;
|
|
169
203
|
}): Promise<ResolvedPrPromptSet> {
|
|
170
|
-
//
|
|
171
|
-
//
|
|
204
|
+
// The WHOLE resolution, not just its dir: under the compiled binary the
|
|
205
|
+
// prompt set is a map of embedded paths and `dir` is only a display label.
|
|
206
|
+
// Resolved first because the ceiling below reads the models it names.
|
|
207
|
+
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
208
|
+
params.options,
|
|
209
|
+
params.loaded,
|
|
210
|
+
{ profile: params.profile },
|
|
211
|
+
);
|
|
212
|
+
// The OpenCode half from the routes the run can take, not from the auth file
|
|
213
|
+
// existing (cryskai/platform#12): a file built for a ChatGPT subscription, one
|
|
214
|
+
// left on a runner whose HOME persists, or a local `opencode auth login` store
|
|
215
|
+
// invoices nothing for a run whose models do not bill per token. Not
|
|
216
|
+
// envBillsMetered either: that predicate stamps Claude usage and must stay
|
|
217
|
+
// Anthropic-env-only.
|
|
172
218
|
const billingMode = deriveCiBillingMode(
|
|
173
219
|
params.claudeRun?.env ?? process.env,
|
|
174
220
|
{
|
|
175
|
-
|
|
221
|
+
openCodeBillsMetered: openCodeRoutesBillMetered({
|
|
222
|
+
providers: await openCodeRouteProviders({
|
|
223
|
+
spec,
|
|
224
|
+
options: params.options,
|
|
225
|
+
agentFiles,
|
|
226
|
+
bundledAgents: isBundledAgentsDir(agents),
|
|
227
|
+
models: params.config.models,
|
|
228
|
+
summary: params.summary,
|
|
229
|
+
profile: params.profile,
|
|
230
|
+
}),
|
|
231
|
+
authFilePresent: existsSync(resolveOpenCodeAuthPath()),
|
|
232
|
+
openCodeSecretNames: readOpenCodeSecretNames(),
|
|
233
|
+
}),
|
|
176
234
|
},
|
|
177
235
|
);
|
|
178
236
|
// Issue #156: resolve the ceiling ONCE, here, and use this same value at
|
|
@@ -222,12 +280,6 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
222
280
|
}
|
|
223
281
|
}
|
|
224
282
|
}
|
|
225
|
-
// The WHOLE resolution, not just its dir: under the compiled binary the
|
|
226
|
-
// prompt set is a map of embedded paths and `dir` is only a display label.
|
|
227
|
-
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
228
|
-
params.options,
|
|
229
|
-
params.loaded,
|
|
230
|
-
);
|
|
231
283
|
const instructions = resolveReviewInstructions(
|
|
232
284
|
params.options.gotchas,
|
|
233
285
|
params.operatorRoot,
|
|
@@ -8,6 +8,12 @@ import {
|
|
|
8
8
|
type ModelVariantsProbe,
|
|
9
9
|
} from "#model/free-discovery";
|
|
10
10
|
import type { ModelsConfig } from "#model/model-name";
|
|
11
|
+
import {
|
|
12
|
+
FALLBACK_PROFILE,
|
|
13
|
+
type ModelProfile,
|
|
14
|
+
profileModelAlias,
|
|
15
|
+
profileRoute,
|
|
16
|
+
} from "#model/profiles";
|
|
11
17
|
import type { ProviderCapabilityReport } from "#model/provider-capabilities";
|
|
12
18
|
import {
|
|
13
19
|
type CapabilityGateDecision,
|
|
@@ -80,6 +86,10 @@ import {
|
|
|
80
86
|
resolveOpenCodeAuthPath,
|
|
81
87
|
} from "./security/credential-broker";
|
|
82
88
|
import { authorizeWorkspaceCwd } from "./security/execution-authority";
|
|
89
|
+
import {
|
|
90
|
+
REVIEW_EXPIRY_MARGIN_MS,
|
|
91
|
+
recordExpiresAt,
|
|
92
|
+
} from "./security/oauth-providers";
|
|
83
93
|
import { readOpenCodeSecretNames } from "./security/opencode-secret-manifest";
|
|
84
94
|
import {
|
|
85
95
|
type AdmitRoutePlanOptions,
|
|
@@ -874,29 +884,68 @@ export async function probeBindingsReadiness(
|
|
|
874
884
|
};
|
|
875
885
|
}
|
|
876
886
|
|
|
877
|
-
// The plan `crysk doctor` probes: the
|
|
878
|
-
//
|
|
879
|
-
// `models` names, fallbacks included, so
|
|
880
|
-
// could open is checked before a review
|
|
881
|
-
// entry: an OpenCode effort is the route's
|
|
882
|
-
// while a Claude effort is not part of
|
|
883
|
-
|
|
887
|
+
// The plan `crysk doctor` probes: the active profile's hunter and refuter (on
|
|
888
|
+
// `claude`, the sonnet hunter and opus refuter a zero-config review runs),
|
|
889
|
+
// plus one step per distinct route `models` names, fallbacks included, so
|
|
890
|
+
// every binding a configured review could open is checked before a review
|
|
891
|
+
// needs it. Distinct by route, not by entry: an OpenCode effort is the route's
|
|
892
|
+
// variant and so a binding of its own, while a Claude effort is not part of
|
|
893
|
+
// the route and is probed once.
|
|
894
|
+
//
|
|
895
|
+
// `claudeRequired: false` (model-profiles S6, doctor.ts reviewNeedsClaude)
|
|
896
|
+
// means `models` sends every step elsewhere, so the profile's two steps, which
|
|
897
|
+
// no review would run, are left out: probing them would demand a Claude binding
|
|
898
|
+
// the configuration never opens. Absent or true keeps them, as before.
|
|
899
|
+
export function buildDoctorRoutePlan(
|
|
900
|
+
models?: ModelsConfig,
|
|
901
|
+
options: {
|
|
902
|
+
readonly claudeRequired?: boolean;
|
|
903
|
+
readonly profile?: ModelProfile;
|
|
904
|
+
} = {},
|
|
905
|
+
): ResolvedRoutePlan {
|
|
906
|
+
const profile = options.profile ?? FALLBACK_PROFILE;
|
|
907
|
+
// A Claude route keeps the alias it always probed. Any other route takes the
|
|
908
|
+
// profile's seat (bundled), so its effort becomes the same OpenCode variant a
|
|
909
|
+
// review's route carries and the probe checks the binding the review opens.
|
|
910
|
+
const agent = (key: string, role: "hunter" | "refuter", seat: string) => {
|
|
911
|
+
const model = profileRoute(profile, seat).model;
|
|
912
|
+
return model.startsWith("claude:")
|
|
913
|
+
? { key, role, model: profileModelAlias(model) }
|
|
914
|
+
: { key, role };
|
|
915
|
+
};
|
|
884
916
|
const base = buildResolvedRoutePlan({
|
|
885
917
|
agents: [
|
|
886
|
-
|
|
887
|
-
|
|
918
|
+
agent("reliability", "hunter", "hunter.reliability"),
|
|
919
|
+
agent("refuter", "refuter", "refuter"),
|
|
888
920
|
],
|
|
921
|
+
bundledAgents: true,
|
|
922
|
+
profile,
|
|
889
923
|
});
|
|
890
924
|
if (models === undefined) return base;
|
|
925
|
+
// A profile step stays when it is not on Claude (openai-profile S6): under
|
|
926
|
+
// `openai` the profile's own steps are the routes a review runs.
|
|
927
|
+
const baseSteps =
|
|
928
|
+
options.claudeRequired === false
|
|
929
|
+
? base.steps.filter((step) => step.route.backend !== "claude-code")
|
|
930
|
+
: base.steps;
|
|
891
931
|
const distinct = new Map<string, ResolvedStepRoute>();
|
|
892
932
|
for (const entry of Object.values(models).flat()) {
|
|
893
933
|
const step = resolveModelEntryRoute("doctor-model", "other", entry);
|
|
934
|
+
// claudeRequired=false means no step the review runs is on Claude (a
|
|
935
|
+
// Claude judge with the gate off, say), so probing it would contradict
|
|
936
|
+
// the "not needed" answer and fail on a machine without the CLI.
|
|
937
|
+
if (
|
|
938
|
+
options.claudeRequired === false &&
|
|
939
|
+
step.route.backend === "claude-code"
|
|
940
|
+
) {
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
894
943
|
if (!distinct.has(step.routeFingerprint)) {
|
|
895
944
|
distinct.set(step.routeFingerprint, step);
|
|
896
945
|
}
|
|
897
946
|
}
|
|
898
947
|
return createResolvedRoutePlan([
|
|
899
|
-
...
|
|
948
|
+
...baseSteps,
|
|
900
949
|
...[...distinct.values()].map((step, i) => ({
|
|
901
950
|
...step,
|
|
902
951
|
stepKey: `doctor-model-${i + 1}`,
|
|
@@ -907,6 +956,11 @@ export function buildDoctorRoutePlan(models?: ModelsConfig): ResolvedRoutePlan {
|
|
|
907
956
|
export async function collectDoctorExactBindingReports(input: {
|
|
908
957
|
readonly workspaceRoot: string;
|
|
909
958
|
readonly models?: ModelsConfig;
|
|
959
|
+
// Whether any step the configuration resolves runs on the Claude CLI
|
|
960
|
+
// (doctor.ts reviewNeedsClaude). Absent: required, as before.
|
|
961
|
+
readonly claudeRequired?: boolean;
|
|
962
|
+
// The configuration's profile (openai-profile S6). Absent: the fallback.
|
|
963
|
+
readonly profile?: ModelProfile;
|
|
910
964
|
readonly authorityDeps?: ResolveRunnerAuthorityDeps;
|
|
911
965
|
readonly env?: RunnerAuthorityOptions["env"];
|
|
912
966
|
readonly observeOpenCodeIdentity?: OpenCodeIdentityObserver;
|
|
@@ -914,7 +968,12 @@ export async function collectDoctorExactBindingReports(input: {
|
|
|
914
968
|
import("./transports/opencode-client").OpenCodeSdkLike
|
|
915
969
|
>;
|
|
916
970
|
}): Promise<readonly ExactBindingCapabilityReport[]> {
|
|
917
|
-
const plan = buildDoctorRoutePlan(input.models
|
|
971
|
+
const plan = buildDoctorRoutePlan(input.models, {
|
|
972
|
+
...(input.claudeRequired === undefined
|
|
973
|
+
? {}
|
|
974
|
+
: { claudeRequired: input.claudeRequired }),
|
|
975
|
+
...(input.profile === undefined ? {} : { profile: input.profile }),
|
|
976
|
+
});
|
|
918
977
|
// U3: the doctor binds OpenCode routes the way a review's admission does, so
|
|
919
978
|
// it reads the setup step's CRYSK_* manifest too.
|
|
920
979
|
const openCodeSecretNames = planRoutes(plan).some(
|
|
@@ -1198,7 +1257,8 @@ export interface OpenCodeCredentialRefusal {
|
|
|
1198
1257
|
readonly message: string;
|
|
1199
1258
|
readonly failureClass:
|
|
1200
1259
|
| "missing_provider_record"
|
|
1201
|
-
| "missing_subscription_record"
|
|
1260
|
+
| "missing_subscription_record"
|
|
1261
|
+
| "subscription_expiring";
|
|
1202
1262
|
readonly params: {
|
|
1203
1263
|
readonly backend: "opencode";
|
|
1204
1264
|
readonly provider: string;
|
|
@@ -1285,6 +1345,7 @@ export async function openCodeCredentialRefusal(
|
|
|
1285
1345
|
openCodeSecretNames: readonly string[] | undefined,
|
|
1286
1346
|
freeVerdicts: ReadonlyMap<string, boolean>,
|
|
1287
1347
|
env: Readonly<Record<string, string | undefined>>,
|
|
1348
|
+
now: number = Date.now(),
|
|
1288
1349
|
): Promise<OpenCodeCredentialRefusal | undefined> {
|
|
1289
1350
|
const needs = new Map<
|
|
1290
1351
|
string,
|
|
@@ -1321,7 +1382,33 @@ export async function openCodeCredentialRefusal(
|
|
|
1321
1382
|
kind === "opencode_chatgpt_oauth"
|
|
1322
1383
|
? await lookupOpenCodeOAuthRecord(reader)
|
|
1323
1384
|
: await lookupOpenCodeApiRecord(reader, provider);
|
|
1324
|
-
if (lookup.ok)
|
|
1385
|
+
if (lookup.ok) {
|
|
1386
|
+
// A subscription login that would expire during the review: the review never
|
|
1387
|
+
// renews it (the broker empties a rotating provider's refresh token), so its
|
|
1388
|
+
// later steps would fail on a dead token. Refused before anything is spent.
|
|
1389
|
+
const expiresAt =
|
|
1390
|
+
kind === "opencode_chatgpt_oauth"
|
|
1391
|
+
? recordExpiresAt(lookup.record)
|
|
1392
|
+
: undefined;
|
|
1393
|
+
if (
|
|
1394
|
+
expiresAt !== undefined &&
|
|
1395
|
+
expiresAt - now <= REVIEW_EXPIRY_MARGIN_MS
|
|
1396
|
+
) {
|
|
1397
|
+
refused.push({
|
|
1398
|
+
sentence: `models name OpenCode provider ${provider} (${stepKeys.join(", ")}), but its subscription login ${expiresAt <= now ? "has expired" : `expires at ${new Date(expiresAt).toISOString()}, before the review would finish`}: the Crysk platform renews it ahead of time, or reconnect it in the Crysk dashboard (locally, run any \`opencode\` request to renew it)`,
|
|
1399
|
+
refusal: {
|
|
1400
|
+
failureClass: "subscription_expiring",
|
|
1401
|
+
params: {
|
|
1402
|
+
backend: "opencode",
|
|
1403
|
+
provider,
|
|
1404
|
+
model: step.route.modelSnapshot,
|
|
1405
|
+
step: stepKeys[0] ?? step.stepKey,
|
|
1406
|
+
},
|
|
1407
|
+
},
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
continue;
|
|
1411
|
+
}
|
|
1325
1412
|
if (
|
|
1326
1413
|
lookup.failureClass !== "missing_provider_record" &&
|
|
1327
1414
|
lookup.failureClass !== "missing_subscription_record"
|