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/pr/review-pr.ts
CHANGED
|
@@ -95,6 +95,8 @@ 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,
|
|
@@ -281,7 +283,16 @@ export async function reviewPr(
|
|
|
281
283
|
// module.
|
|
282
284
|
const step1 = await resolvePrRunOptions(options, prArg);
|
|
283
285
|
options = step1.options;
|
|
284
|
-
const {
|
|
286
|
+
const {
|
|
287
|
+
operatorRoot,
|
|
288
|
+
prNumber,
|
|
289
|
+
home,
|
|
290
|
+
isCi,
|
|
291
|
+
loaded,
|
|
292
|
+
config,
|
|
293
|
+
summary,
|
|
294
|
+
profile,
|
|
295
|
+
} = step1;
|
|
285
296
|
// S5: the Claude credential this run uses, chosen once, here, from
|
|
286
297
|
// `credentials.claude` and what is set. The CI ceiling, the admission, every
|
|
287
298
|
// runner and binding, and the child read its env, which holds that one
|
|
@@ -310,6 +321,7 @@ export async function reviewPr(
|
|
|
310
321
|
loaded,
|
|
311
322
|
config,
|
|
312
323
|
summary,
|
|
324
|
+
profile,
|
|
313
325
|
isCi,
|
|
314
326
|
operatorRoot,
|
|
315
327
|
claudeRun,
|
|
@@ -718,6 +730,7 @@ export async function reviewPr(
|
|
|
718
730
|
config,
|
|
719
731
|
summary,
|
|
720
732
|
loaded,
|
|
733
|
+
profile,
|
|
721
734
|
isCi,
|
|
722
735
|
ciMode,
|
|
723
736
|
statusContext,
|
|
@@ -782,7 +795,11 @@ export async function reviewPr(
|
|
|
782
795
|
await withCiWorkflowGroup(isCi, "crysk review", log, async () => {
|
|
783
796
|
log(reviewingLine(hunterCount, summary, options));
|
|
784
797
|
// runnerAuthority resolved before confirm with the exact-binding gate.
|
|
785
|
-
|
|
798
|
+
// A plan with no claude-code route never starts the Claude CLI.
|
|
799
|
+
if (
|
|
800
|
+
runnerAuthority.error !== undefined &&
|
|
801
|
+
claudeAuthorityRequired(routePlan)
|
|
802
|
+
) {
|
|
786
803
|
throw new CliError(
|
|
787
804
|
`execution authority unavailable: ${runnerAuthority.error}`,
|
|
788
805
|
);
|
|
@@ -847,6 +864,8 @@ export async function reviewPr(
|
|
|
847
864
|
gotchasPath,
|
|
848
865
|
agentsDir,
|
|
849
866
|
...(agents.files ? { agentFiles: agents.files } : {}),
|
|
867
|
+
// The same answer the plan was built with (pr/plan.ts).
|
|
868
|
+
...(isBundledAgentsDir(agents) ? { bundledAgents: true } : {}),
|
|
850
869
|
runDir,
|
|
851
870
|
outPath: path.join(runDir, "findings.json"),
|
|
852
871
|
mcpConfigPath,
|
|
@@ -854,12 +873,19 @@ export async function reviewPr(
|
|
|
854
873
|
...(options.model ? { model: options.model } : {}),
|
|
855
874
|
parityTriggerPaths: config.parity_trigger_paths,
|
|
856
875
|
suspicionPriors: config.suspicion_priors,
|
|
857
|
-
|
|
858
|
-
...(skipDiscovery
|
|
859
|
-
|
|
876
|
+
modelProfile: profile,
|
|
877
|
+
...(skipDiscovery
|
|
878
|
+
? {}
|
|
879
|
+
: pipelineSummarizerInput(summary, { profile })),
|
|
880
|
+
...(skipDiscovery
|
|
881
|
+
? {}
|
|
882
|
+
: pipelineScoutInput(options, { profile })),
|
|
883
|
+
...(skipDiscovery ? {} : pipelineConsolidateInput({ profile })),
|
|
860
884
|
// Gated on skipDiscovery like consolidation: an empty-delta
|
|
861
885
|
// re-review posts no new findings, so there is nothing to judge.
|
|
862
|
-
...(skipDiscovery
|
|
886
|
+
...(skipDiscovery
|
|
887
|
+
? {}
|
|
888
|
+
: pipelineMaterialityInput(config, { profile })),
|
|
863
889
|
prTitle: target.title,
|
|
864
890
|
...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
|
|
865
891
|
// NOT gated on skipDiscovery: an empty-delta re-review still
|
package/src/pr/target.ts
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
} from "#review/preflight";
|
|
48
48
|
import type { ParsedAgent, PromptSetIdentity } from "#review/prompt-set";
|
|
49
49
|
import type { estimateCost } from "#review/report";
|
|
50
|
-
import { buildCliRoutePlan } from "#review/route-preflight";
|
|
50
|
+
import { buildCliRoutePlan, isBundledAgentsDir } from "#review/route-preflight";
|
|
51
51
|
import {
|
|
52
52
|
type LoadedRunConfig,
|
|
53
53
|
loadRunConfig,
|
|
@@ -79,6 +79,7 @@ export interface ResolvedPrRunOptions {
|
|
|
79
79
|
loaded: LoadedRunConfig["loaded"];
|
|
80
80
|
config: LoadedRunConfig["config"];
|
|
81
81
|
summary: LoadedRunConfig["summary"];
|
|
82
|
+
profile: LoadedRunConfig["profile"];
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// Step 1's first half: the operator root, the PR number, `home`, and the
|
|
@@ -112,12 +113,14 @@ export async function resolvePrRunOptions(
|
|
|
112
113
|
// yet at this point, and a `.crysk/config.json` committed by the PR author
|
|
113
114
|
// must stay unread (O-8). Same loader as local mode, so the two modes
|
|
114
115
|
// cannot drift on precedence.
|
|
115
|
-
const { loaded, config, summary, scout, post } = await loadRunConfig(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
const { loaded, config, summary, scout, post, profile } = await loadRunConfig(
|
|
117
|
+
{
|
|
118
|
+
root: operatorRoot,
|
|
119
|
+
home,
|
|
120
|
+
configFlag: options.config,
|
|
121
|
+
options,
|
|
122
|
+
},
|
|
123
|
+
);
|
|
121
124
|
// ROADMAP Pillar 3 (GitHub Actions CI). isCi folds in HERE, alongside
|
|
122
125
|
// scout/post, so `options.yes` carries the headless bypass (spec 2.1:
|
|
123
126
|
// "MUST run headlessly ... equivalent to --yes") through every downstream
|
|
@@ -138,6 +141,7 @@ export async function resolvePrRunOptions(
|
|
|
138
141
|
loaded,
|
|
139
142
|
config,
|
|
140
143
|
summary,
|
|
144
|
+
profile,
|
|
141
145
|
};
|
|
142
146
|
}
|
|
143
147
|
|
|
@@ -189,6 +193,8 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
189
193
|
operatorRoot: string;
|
|
190
194
|
// The summarizer's settings, for its route (openCodeRouteProviders).
|
|
191
195
|
summary: LoadedRunConfig["summary"];
|
|
196
|
+
// The run's profile (openai-profile S3), for the same routes.
|
|
197
|
+
profile: LoadedRunConfig["profile"];
|
|
192
198
|
// S5: the run's Claude credential, chosen once at run start (reviewPr). Its env
|
|
193
199
|
// holds only the chosen credential, so the ceiling follows the choice: the
|
|
194
200
|
// subscription has no metered ceiling, the API key keeps it. Absent (tests that
|
|
@@ -201,6 +207,7 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
201
207
|
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
202
208
|
params.options,
|
|
203
209
|
params.loaded,
|
|
210
|
+
{ profile: params.profile },
|
|
204
211
|
);
|
|
205
212
|
// The OpenCode half from the routes the run can take, not from the auth file
|
|
206
213
|
// existing (cryskai/platform#12): a file built for a ChatGPT subscription, one
|
|
@@ -216,8 +223,10 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
216
223
|
spec,
|
|
217
224
|
options: params.options,
|
|
218
225
|
agentFiles,
|
|
226
|
+
bundledAgents: isBundledAgentsDir(agents),
|
|
219
227
|
models: params.config.models,
|
|
220
228
|
summary: params.summary,
|
|
229
|
+
profile: params.profile,
|
|
221
230
|
}),
|
|
222
231
|
authFilePresent: existsSync(resolveOpenCodeAuthPath()),
|
|
223
232
|
openCodeSecretNames: readOpenCodeSecretNames(),
|
|
@@ -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"
|