crysk 0.4.0 → 0.5.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 +26 -17
- package/config/models/anthropic.json +1 -1
- package/dist/SKILL-k4k0zn1w.md +143 -0
- package/dist/SKILL-vhb4c3vv.md +553 -0
- package/dist/SKILL-xpf6kmdw.md +74 -0
- package/dist/ci-admission-0ken6ehx.md +128 -0
- package/dist/cli.js +3056 -1623
- package/dist/index.js +1744 -938
- package/dist/opencode-ci-ac5zksdn.md +106 -0
- package/dist/workflow-4pkyck01.yml +160 -0
- package/package.json +1 -1
- package/prompts/default/PROVENANCE.md +1 -0
- package/skills/crysk/SKILL.md +16 -16
- package/skills/crysk-ci-setup/SKILL.md +41 -38
- package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
- package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
- package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
- package/skills/crysk-loop/SKILL.md +1 -1
- package/src/asset-manifest.ts +0 -4
- package/src/assets.ts +1 -1
- package/src/ci/admission-ledger.ts +4 -0
- package/src/ci/classify-error.ts +21 -24
- package/src/ci/cli-record.ts +53 -1
- package/src/ci/crysk-secrets.ts +409 -0
- package/src/ci/gates.ts +22 -36
- package/src/ci/outcome.ts +421 -330
- package/src/ci/platform-config.ts +2 -2
- package/src/ci/platform-report.ts +274 -41
- package/src/ci/platform-trace.ts +551 -0
- package/src/ci/platform.ts +28 -12
- package/src/ci/publish.ts +19 -6
- package/src/ci/review-levels.ts +8 -7
- package/src/ci/run.ts +88 -0
- package/src/ci/setup.ts +453 -118
- package/src/ci/trace-bundle.ts +1282 -0
- package/src/ci/trace-transcripts.ts +415 -0
- package/src/ci/trigger.ts +176 -33
- package/src/cli.ts +11 -3
- package/src/commands/ci-setup-questions.ts +3 -3
- package/src/commands/ci-setup.ts +152 -6
- package/src/commands/config.ts +3 -0
- package/src/commands/doctor.ts +15 -6
- package/src/config/config.ts +16 -3
- package/src/diversity/clustering.ts +0 -1
- package/src/diversity/identity.ts +4 -5
- package/src/diversity/pipeline-integration.ts +1 -9
- package/src/doctor.ts +3 -3
- package/src/execution/attempt-evidence.ts +10 -5
- package/src/execution/claude-session-trace.ts +480 -0
- package/src/execution/contracts.ts +21 -4
- package/src/execution/harness.ts +105 -8
- package/src/execution/model-fallback.ts +239 -0
- package/src/execution/usage-normalized.ts +6 -4
- package/src/home-preflight.ts +1 -1
- package/src/index.ts +1 -1
- package/src/model/catalog.ts +13 -37
- package/src/model/free-discovery.ts +117 -8
- package/src/model/model-name.ts +404 -0
- package/src/model/provider-capabilities.ts +22 -7
- package/src/model/routing.ts +346 -467
- package/src/pr/admission.ts +18 -0
- package/src/pr/plan.ts +20 -4
- package/src/pr/preflight.ts +1 -1
- package/src/pr/publish-outcome.ts +1 -1
- package/src/pr/review-pr.ts +15 -1
- package/src/pr/target.ts +12 -3
- package/src/production-runtime.ts +760 -331
- package/src/review/pipeline.ts +277 -101
- package/src/review/preflight.ts +201 -294
- package/src/review/report.ts +26 -26
- package/src/review/review.ts +20 -3
- package/src/review/route-preflight.ts +79 -11
- package/src/review/run.ts +28 -6
- package/src/review/scout.ts +1 -1
- package/src/review/spec.ts +3 -3
- package/src/review/step-runner.ts +70 -1
- package/src/runner-authority.ts +127 -9
- package/src/security/binding-policy.ts +1 -2
- package/src/security/claude-credential.ts +355 -0
- package/src/security/credential-broker.ts +56 -40
- package/src/security/evidence-redaction.ts +179 -4
- package/src/security/opencode-secret-manifest.ts +114 -0
- package/src/security/redact.ts +45 -0
- package/src/system-tools.ts +48 -21
- package/src/transport-registry.ts +12 -2
- package/src/transports/claude-code-cli.ts +21 -2
- package/src/transports/opencode-sdk.ts +11 -9
- package/src/transports/opencode-server.ts +7 -10
- package/src/ui/config-edit.ts +9 -20
- package/src/ui/config.ts +32 -27
- package/src/ui/plan.ts +76 -47
- package/src/updater.ts +10 -7
- package/prompts/default/deep-review-lifecycle.md +0 -362
package/src/pr/admission.ts
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
import { publishFinalCommitStatus } from "#pr/status";
|
|
49
49
|
import { log } from "#ui/primitives";
|
|
50
50
|
import { canonicalStatusText, STATUS_CONTEXT } from "../brand";
|
|
51
|
+
import { CredentialRefusalError } from "../security/claude-credential";
|
|
51
52
|
|
|
52
53
|
// ROADMAP Pillar 3 (GitHub Actions CI). The mechanical glue behind a gate
|
|
53
54
|
// skip in CI mode: every DECISION (what to say, which marker, what the
|
|
@@ -180,6 +181,23 @@ export async function settleCiGateSkip(
|
|
|
180
181
|
await settleCiAdmissionLedger(state, "gate-skipped", reason, options);
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
// R003 (#494): a credential refusal at admission (CredentialRefusalError: no Claude
|
|
185
|
+
// credential, or an OpenCode route with no auth record) stops a CI run after the
|
|
186
|
+
// reservation and before any binding or provider call (the OpenCode refusal follows
|
|
187
|
+
// only the token-free free-model probe), so it spent nothing:
|
|
188
|
+
// its row settles as gate-skipped, like the budget gate it follows, with the
|
|
189
|
+
// refusal's own reason. Any other error is left for teardown, which settles it
|
|
190
|
+
// `failed`. The caller rethrows the error unchanged. The name predates the OpenCode
|
|
191
|
+
// refusal and is kept: an architecture test pins its call site.
|
|
192
|
+
export async function settleClaudeCredentialRefusal(
|
|
193
|
+
state: CiAdmissionLedgerState | null,
|
|
194
|
+
error: unknown,
|
|
195
|
+
options?: { spawnFn?: typeof Bun.spawn },
|
|
196
|
+
): Promise<void> {
|
|
197
|
+
if (!(error instanceof CredentialRefusalError)) return;
|
|
198
|
+
await settleCiGateSkip(state, error.ledgerReason, options);
|
|
199
|
+
}
|
|
200
|
+
|
|
183
201
|
export async function reserveCiAdmissionLedger(input: {
|
|
184
202
|
operatorRoot: string;
|
|
185
203
|
prNumber: number;
|
package/src/pr/plan.ts
CHANGED
|
@@ -27,11 +27,12 @@ import {
|
|
|
27
27
|
countFreeRouteSteps,
|
|
28
28
|
type FreeRouteBilling,
|
|
29
29
|
} from "#model/free-discovery";
|
|
30
|
-
import type
|
|
30
|
+
import { planRoutes, type ResolvedRoutePlan } from "#model/routing";
|
|
31
31
|
import {
|
|
32
32
|
type CiAdmissionLedgerState,
|
|
33
33
|
publishCiSkip,
|
|
34
34
|
settleCiGateSkip,
|
|
35
|
+
settleClaudeCredentialRefusal,
|
|
35
36
|
} from "#pr/admission";
|
|
36
37
|
import { ghRepoWebUrl } from "#pr/pr";
|
|
37
38
|
import {
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
type RunnerAuthorityResolution,
|
|
72
73
|
resolveRunnerAuthority,
|
|
73
74
|
} from "../runner-authority";
|
|
75
|
+
import type { RunClaudeCredential } from "../security/claude-credential";
|
|
74
76
|
|
|
75
77
|
export type PrPlanAndConfirmResult =
|
|
76
78
|
| { exitCode: number }
|
|
@@ -128,6 +130,8 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
128
130
|
// run, pr-hero/local otherwise (resolveCiPosture). Passed down, never re-derived.
|
|
129
131
|
statusContext: CommitStatusContext;
|
|
130
132
|
ciBudgetCeiling: { budgetUsd: number | undefined };
|
|
133
|
+
// S5: the run's Claude credential, chosen once at run start (reviewPr).
|
|
134
|
+
claudeRun: RunClaudeCredential;
|
|
131
135
|
ciAdmissionLedger: CiAdmissionLedgerState | null;
|
|
132
136
|
skipDiscovery: boolean;
|
|
133
137
|
hunterCount: number;
|
|
@@ -204,12 +208,12 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
204
208
|
}
|
|
205
209
|
}
|
|
206
210
|
const productionRoute = await resolvePipelineRoute({
|
|
207
|
-
|
|
211
|
+
modelsConfigured: params.config.models !== undefined,
|
|
208
212
|
workspaceRoot: params.worktreePath,
|
|
209
213
|
spec: params.spec,
|
|
210
214
|
options: params.options,
|
|
211
215
|
agentFiles: params.agentFiles,
|
|
212
|
-
|
|
216
|
+
models: params.config.models,
|
|
213
217
|
summary: params.summary,
|
|
214
218
|
summarizerEnabled: params.summary.enabled && !params.skipDiscovery,
|
|
215
219
|
scoutEnabled: params.options.scout && !params.skipDiscovery,
|
|
@@ -218,6 +222,10 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
218
222
|
// re-review that hunts nothing new.
|
|
219
223
|
materialityEnabled:
|
|
220
224
|
resolveMaterialityGate(params.config) && !params.skipDiscovery,
|
|
225
|
+
claudeRun: params.claudeRun,
|
|
226
|
+
}).catch(async (error: unknown) => {
|
|
227
|
+
await settleClaudeCredentialRefusal(params.ciAdmissionLedger, error);
|
|
228
|
+
throw error;
|
|
221
229
|
});
|
|
222
230
|
const routePlan = productionRoute?.routePlan;
|
|
223
231
|
const productionAdmission = productionRoute?.productionAdmission;
|
|
@@ -227,11 +235,19 @@ export async function resolvePrPlanAndConfirm(params: {
|
|
|
227
235
|
routePlan === undefined || productionAdmission === undefined
|
|
228
236
|
? undefined
|
|
229
237
|
: await countFreeRouteSteps({
|
|
230
|
-
steps: routePlan
|
|
238
|
+
steps: planRoutes(routePlan),
|
|
231
239
|
probe: productionAdmission.freeModelProbe,
|
|
240
|
+
// The CRYSK_OPENCODE_* names admission bound each route's kind with,
|
|
241
|
+
// so the card counts free exactly the routes admission probed (U3).
|
|
242
|
+
openCodeSecretNames:
|
|
243
|
+
productionAdmission.authorityOptions.openCodeSecretNames,
|
|
232
244
|
});
|
|
233
245
|
const runnerAuthority = await resolveRunnerAuthority({
|
|
234
246
|
workspaceRoot: params.worktreePath,
|
|
247
|
+
env: params.claudeRun.env,
|
|
248
|
+
...(params.claudeRun.kind === undefined
|
|
249
|
+
? {}
|
|
250
|
+
: { claudeCredential: params.claudeRun.kind }),
|
|
235
251
|
});
|
|
236
252
|
await enforceCapabilityGate({
|
|
237
253
|
routePlan,
|
package/src/pr/preflight.ts
CHANGED
|
@@ -828,7 +828,7 @@ export function settleRequestForCancellation(
|
|
|
828
828
|
lock: HeldCommitStatusLock | null,
|
|
829
829
|
): { operatorRoot: string; sha: string; request: CommitStatusRequest } | null {
|
|
830
830
|
if (lock === null) return null;
|
|
831
|
-
// WHY
|
|
831
|
+
// WHY CRYSK-CANCELLED and not "review did not finish": a signal is a cancel, and the
|
|
832
832
|
// action's cancel-settle step writes the same text when this settle does not land
|
|
833
833
|
// first (src/ci/publish.ts runCancelSettle). Either writer leaves one coded status.
|
|
834
834
|
return {
|
|
@@ -339,7 +339,7 @@ export async function publishRunOutcome(
|
|
|
339
339
|
findings: doc.findings,
|
|
340
340
|
costUsdEst: result.usage.cost_usd_est,
|
|
341
341
|
wallMs,
|
|
342
|
-
model: envelopeModel(input.options, input.agentFiles),
|
|
342
|
+
model: envelopeModel(input.options, input.agentFiles, result.routePlan),
|
|
343
343
|
webUrl,
|
|
344
344
|
delta: posted?.delta,
|
|
345
345
|
runDir: input.runDir,
|
package/src/pr/review-pr.ts
CHANGED
|
@@ -22,6 +22,7 @@ import path from "node:path";
|
|
|
22
22
|
import {
|
|
23
23
|
cliHeadField,
|
|
24
24
|
hunterFailureRecords,
|
|
25
|
+
recordRunDir,
|
|
25
26
|
writeCliRecord,
|
|
26
27
|
} from "#ci/cli-record";
|
|
27
28
|
import { planCiExcludedSkip, planCiSizeSkip } from "#ci/gates";
|
|
@@ -121,6 +122,7 @@ import { acquirePidLock } from "../home";
|
|
|
121
122
|
import { worktreeLockPath } from "../home-preflight";
|
|
122
123
|
import { readLocalIgnoreRules } from "../ignore-read";
|
|
123
124
|
import type { ProductionRuntime } from "../production-runtime";
|
|
125
|
+
import { resolveRunClaudeCredential } from "../security/claude-credential";
|
|
124
126
|
import { writeGateRecord } from "./gate-record";
|
|
125
127
|
|
|
126
128
|
// The CLI's record for a pipeline whose every hunter failed (cli.json,
|
|
@@ -142,7 +144,7 @@ export function recordPipelineOutcome(
|
|
|
142
144
|
): void {
|
|
143
145
|
if (result?.sessionFailed !== true) return;
|
|
144
146
|
// WHY the causes ride on the record: the publisher names the provider and the model
|
|
145
|
-
// when every hunter failed on the provider's side (
|
|
147
|
+
// when every hunter failed on the provider's side (CRYSK-MODEL-UNAVAILABLE). A run with
|
|
146
148
|
// no failed hunter list keeps the record as it was before the field existed.
|
|
147
149
|
const failures = result.hunterFailures ?? [];
|
|
148
150
|
writeCliRecord(
|
|
@@ -279,6 +281,13 @@ export async function reviewPr(
|
|
|
279
281
|
const step1 = await resolvePrRunOptions(options, prArg);
|
|
280
282
|
options = step1.options;
|
|
281
283
|
const { operatorRoot, prNumber, home, isCi, loaded, config, summary } = step1;
|
|
284
|
+
// S5: the Claude credential this run uses, chosen once, here, from
|
|
285
|
+
// `credentials.claude` and what is set. The CI ceiling, the admission, every
|
|
286
|
+
// runner and binding, and the child read its env, which holds that one
|
|
287
|
+
// credential and no other.
|
|
288
|
+
const claudeRun = resolveRunClaudeCredential({
|
|
289
|
+
credentials: config.credentials,
|
|
290
|
+
});
|
|
282
291
|
// S4 + T3 S7: the run's one posture. Every gate, skip, status, comment and
|
|
283
292
|
// summary below takes these values; nothing re-resolves them. Both key on the
|
|
284
293
|
// explicit --ci flag, never on `isCi` (which also folds in the CI/GITHUB_ACTIONS
|
|
@@ -301,6 +310,7 @@ export async function reviewPr(
|
|
|
301
310
|
config,
|
|
302
311
|
isCi,
|
|
303
312
|
operatorRoot,
|
|
313
|
+
claudeRun,
|
|
304
314
|
});
|
|
305
315
|
await validateGotchas(step2.gotchasPath);
|
|
306
316
|
} catch (error) {
|
|
@@ -644,6 +654,9 @@ export async function reviewPr(
|
|
|
644
654
|
prNumber,
|
|
645
655
|
headSha,
|
|
646
656
|
);
|
|
657
|
+
// Action mode only: the trace step reads the run's files from here when
|
|
658
|
+
// the run step publishes no run_dir (src/ci/cli-record.ts recordRunDir).
|
|
659
|
+
recordRunDir(runDir);
|
|
647
660
|
// diff.patch is the EFFECTIVE diff — exactly what the hunters read (see
|
|
648
661
|
// filterDiffByIgnoreRules); diff.raw.patch preserves the unfiltered
|
|
649
662
|
// bytes, and only when the filter actually dropped something.
|
|
@@ -699,6 +712,7 @@ export async function reviewPr(
|
|
|
699
712
|
ciMode,
|
|
700
713
|
statusContext,
|
|
701
714
|
ciBudgetCeiling,
|
|
715
|
+
claudeRun,
|
|
702
716
|
ciAdmissionLedger,
|
|
703
717
|
skipDiscovery,
|
|
704
718
|
hunterCount,
|
package/src/pr/target.ts
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
legacyWorktreePath,
|
|
65
65
|
prWorktreePath,
|
|
66
66
|
} from "../home-preflight";
|
|
67
|
+
import type { RunClaudeCredential } from "../security/claude-credential";
|
|
67
68
|
import { resolveOpenCodeAuthPath } from "../security/credential-broker";
|
|
68
69
|
|
|
69
70
|
export interface ResolvedPrRunOptions {
|
|
@@ -160,12 +161,20 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
160
161
|
config: LoadedRunConfig["config"];
|
|
161
162
|
isCi: boolean;
|
|
162
163
|
operatorRoot: string;
|
|
164
|
+
// S5: the run's Claude credential, chosen once at run start (reviewPr). Its env
|
|
165
|
+
// holds only the chosen credential, so the ceiling follows the choice: the
|
|
166
|
+
// subscription has no metered ceiling, the API key keeps it. Absent (tests that
|
|
167
|
+
// pin the older wiring) reads the process env as before.
|
|
168
|
+
claudeRun?: RunClaudeCredential;
|
|
163
169
|
}): Promise<ResolvedPrPromptSet> {
|
|
164
170
|
// File presence, not envBillsMetered: that predicate stamps Claude
|
|
165
171
|
// usage and must stay Anthropic-env-only.
|
|
166
|
-
const billingMode = deriveCiBillingMode(
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
const billingMode = deriveCiBillingMode(
|
|
173
|
+
params.claudeRun?.env ?? process.env,
|
|
174
|
+
{
|
|
175
|
+
openCodeAuthPresent: existsSync(resolveOpenCodeAuthPath()),
|
|
176
|
+
},
|
|
177
|
+
);
|
|
169
178
|
// Issue #156: resolve the ceiling ONCE, here, and use this same value at
|
|
170
179
|
// the budget gate far below (src/pr/review-pr.ts's plan/confirm stage).
|
|
171
180
|
// Resolving twice invites the announcement and the gate drifting apart.
|