crysk 0.5.0 → 0.5.1
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/package.json +1 -1
- package/src/assets.ts +1 -1
- package/src/ci/force-comment.ts +14 -1
- package/src/ci/gates.ts +64 -21
- package/src/ci/platform-estimate.ts +111 -0
- package/src/ci/platform-trace.ts +30 -0
- package/src/ci/platform.ts +30 -0
- package/src/ci/reporter.ts +14 -4
- package/src/ci/setup.ts +32 -0
- package/src/ci/trace-bundle.ts +231 -27
- package/src/ci/trace-transcripts.ts +65 -0
- package/src/index.ts +1 -1
- package/src/pr/ci-admission-gate.ts +2 -0
- package/src/pr/discovery.ts +18 -0
- package/src/pr/plan.ts +35 -1
- package/src/pr/review-pr.ts +11 -0
- package/src/pr/target.ts +52 -9
- package/src/review/report.ts +4 -0
- package/src/review/run.ts +16 -0
- package/src/ui/plan.ts +8 -3
- package/src/updater.ts +1 -1
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 } 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;
|
|
@@ -149,6 +152,29 @@ export interface ResolvedPrPromptSet {
|
|
|
149
152
|
gotchasPath: string | undefined;
|
|
150
153
|
}
|
|
151
154
|
|
|
155
|
+
// The OpenCode providers of every route the run resolves, fallbacks included,
|
|
156
|
+
// from the same plan builder the run confirms with (buildCliRoutePlan), so each
|
|
157
|
+
// source routing reads counts the way routing reads it. Undefined when the plan
|
|
158
|
+
// cannot be built here; the run itself surfaces that error at confirm.
|
|
159
|
+
async function openCodeRouteProviders(
|
|
160
|
+
input: Parameters<typeof buildCliRoutePlan>[0],
|
|
161
|
+
): Promise<string[] | undefined> {
|
|
162
|
+
let plan: Awaited<ReturnType<typeof buildCliRoutePlan>>;
|
|
163
|
+
try {
|
|
164
|
+
plan = await buildCliRoutePlan(input);
|
|
165
|
+
} catch {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const providers = new Set<string>();
|
|
169
|
+
for (const step of plan.steps) {
|
|
170
|
+
for (const route of [step, ...(step.fallbacks ?? [])]) {
|
|
171
|
+
if (route.route.backend === "opencode")
|
|
172
|
+
providers.add(route.route.provider);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return [...providers].sort();
|
|
176
|
+
}
|
|
177
|
+
|
|
152
178
|
// Step 1's second half: the CI budget ceiling (+ its notices), then the
|
|
153
179
|
// prompt set resolution and the gotchas PATH (never the validation itself —
|
|
154
180
|
// see this module's header). Runs after the caller's own
|
|
@@ -161,18 +187,41 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
161
187
|
config: LoadedRunConfig["config"];
|
|
162
188
|
isCi: boolean;
|
|
163
189
|
operatorRoot: string;
|
|
190
|
+
// The summarizer's settings, for its route (openCodeRouteProviders).
|
|
191
|
+
summary: LoadedRunConfig["summary"];
|
|
164
192
|
// S5: the run's Claude credential, chosen once at run start (reviewPr). Its env
|
|
165
193
|
// holds only the chosen credential, so the ceiling follows the choice: the
|
|
166
194
|
// subscription has no metered ceiling, the API key keeps it. Absent (tests that
|
|
167
195
|
// pin the older wiring) reads the process env as before.
|
|
168
196
|
claudeRun?: RunClaudeCredential;
|
|
169
197
|
}): Promise<ResolvedPrPromptSet> {
|
|
170
|
-
//
|
|
171
|
-
//
|
|
198
|
+
// The WHOLE resolution, not just its dir: under the compiled binary the
|
|
199
|
+
// prompt set is a map of embedded paths and `dir` is only a display label.
|
|
200
|
+
// Resolved first because the ceiling below reads the models it names.
|
|
201
|
+
const { agents, spec, agentFiles, promptSet } = await resolvePromptSet(
|
|
202
|
+
params.options,
|
|
203
|
+
params.loaded,
|
|
204
|
+
);
|
|
205
|
+
// The OpenCode half from the routes the run can take, not from the auth file
|
|
206
|
+
// existing (cryskai/platform#12): a file built for a ChatGPT subscription, one
|
|
207
|
+
// left on a runner whose HOME persists, or a local `opencode auth login` store
|
|
208
|
+
// invoices nothing for a run whose models do not bill per token. Not
|
|
209
|
+
// envBillsMetered either: that predicate stamps Claude usage and must stay
|
|
210
|
+
// Anthropic-env-only.
|
|
172
211
|
const billingMode = deriveCiBillingMode(
|
|
173
212
|
params.claudeRun?.env ?? process.env,
|
|
174
213
|
{
|
|
175
|
-
|
|
214
|
+
openCodeBillsMetered: openCodeRoutesBillMetered({
|
|
215
|
+
providers: await openCodeRouteProviders({
|
|
216
|
+
spec,
|
|
217
|
+
options: params.options,
|
|
218
|
+
agentFiles,
|
|
219
|
+
models: params.config.models,
|
|
220
|
+
summary: params.summary,
|
|
221
|
+
}),
|
|
222
|
+
authFilePresent: existsSync(resolveOpenCodeAuthPath()),
|
|
223
|
+
openCodeSecretNames: readOpenCodeSecretNames(),
|
|
224
|
+
}),
|
|
176
225
|
},
|
|
177
226
|
);
|
|
178
227
|
// Issue #156: resolve the ceiling ONCE, here, and use this same value at
|
|
@@ -222,12 +271,6 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
222
271
|
}
|
|
223
272
|
}
|
|
224
273
|
}
|
|
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
274
|
const instructions = resolveReviewInstructions(
|
|
232
275
|
params.options.gotchas,
|
|
233
276
|
params.operatorRoot,
|
package/src/review/report.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// come out byte-identical (the lab already replays old findings.json files;
|
|
8
8
|
// a renderer that reached for `new Date()` would make that a lie).
|
|
9
9
|
|
|
10
|
+
import type { PlatformEstimateBasis } from "#ci/platform-estimate";
|
|
10
11
|
import { listPaths } from "#git/refs";
|
|
11
12
|
import type { ResolvedRoutePlan, ResolvedStepRoute } from "#model/routing";
|
|
12
13
|
import type { PostMinSeverity } from "#pr/post-floor";
|
|
@@ -56,6 +57,9 @@ export interface CostEstimate {
|
|
|
56
57
|
// Plain-language statement of how coarse this is, meant to be printed next
|
|
57
58
|
// to the numbers so nobody reads the band as a quote.
|
|
58
59
|
basis: string;
|
|
60
|
+
// Set when the range is the Crysk platform's estimate, not this band: what
|
|
61
|
+
// the platform priced it from (src/ci/platform-estimate.ts).
|
|
62
|
+
platform?: PlatformEstimateBasis;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
// Per-hunter marginal cost, fitted to the measured runs (see BAND below).
|
package/src/review/run.ts
CHANGED
|
@@ -256,6 +256,22 @@ export function resolveParityFires(
|
|
|
256
256
|
return parityTriggered(changedPathsFromDiff(patch), parityTriggerPaths);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
// How many hunters a full review of the whole PR runs: the unconditional ones,
|
|
260
|
+
// plus the parity hunter when the full PR patch touches a trigger path. A
|
|
261
|
+
// narrowed run's own count (none on a verify-only pass, no parity hunter when
|
|
262
|
+
// only the delta was read) would understate a full review, which is what the
|
|
263
|
+
// platform estimate's share divides by (cryskai/platform#12).
|
|
264
|
+
export function fullReviewHunterCount(
|
|
265
|
+
agents: readonly AgentSpec[],
|
|
266
|
+
prPatch: string,
|
|
267
|
+
parityTriggerPaths: string[],
|
|
268
|
+
): number {
|
|
269
|
+
return selectActiveHunters(
|
|
270
|
+
agents,
|
|
271
|
+
resolveParityFires(prPatch, parityTriggerPaths),
|
|
272
|
+
).length;
|
|
273
|
+
}
|
|
274
|
+
|
|
259
275
|
// The diff stat, TWICE and on purpose (moved here from review()'s own WHY
|
|
260
276
|
// comment when reviewPr()'s copy — which never carried it — started sharing
|
|
261
277
|
// this stage):
|
package/src/ui/plan.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { existsSync } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
|
+
import type { PlatformEstimateBasis } from "#ci/platform-estimate";
|
|
9
10
|
import type { EffectiveConfig } from "#config/config";
|
|
10
11
|
import { exclusionLines } from "#git/git";
|
|
11
12
|
import { isFullCommitId } from "#git/refs";
|
|
@@ -492,7 +493,7 @@ export function freeRouteEstimateText(estimate: {
|
|
|
492
493
|
// byte-identical. The band never reads $0 – $0 here: estimateCost clamps the
|
|
493
494
|
// hunter seats (report.ts), so a free route is "not billed", never a zero estimate.
|
|
494
495
|
export function planEstimateLine(input: {
|
|
495
|
-
estimate: { low: number; high: number };
|
|
496
|
+
estimate: { low: number; high: number; platform?: PlatformEstimateBasis };
|
|
496
497
|
hunterCount: number;
|
|
497
498
|
summarizer: boolean;
|
|
498
499
|
freeRoute?: FreeRouteBilling;
|
|
@@ -505,9 +506,13 @@ export function planEstimateLine(input: {
|
|
|
505
506
|
if (billing === "free") {
|
|
506
507
|
return `estimate: ${freeRouteEstimateText(input.estimate)}`;
|
|
507
508
|
}
|
|
509
|
+
// The platform's range is not the band, so the line says where it came from
|
|
510
|
+
// instead of the agent count the band is built on (cryskai/platform#12).
|
|
508
511
|
const line =
|
|
509
|
-
|
|
510
|
-
|
|
512
|
+
input.estimate.platform === undefined
|
|
513
|
+
? `estimate ${low} – ${high} (${input.hunterCount} hunter(s) + refuter ` +
|
|
514
|
+
`${input.summarizer ? "+ summarizer" : "+ summarizer disabled"})`
|
|
515
|
+
: `estimate ${low} – ${high} (platform: ${input.estimate.platform})`;
|
|
511
516
|
return billing === "mixed" ? `${line} ${FREE_STEPS_NOTE}` : line;
|
|
512
517
|
}
|
|
513
518
|
|
package/src/updater.ts
CHANGED
|
@@ -54,7 +54,7 @@ export function detectInstallMethod(
|
|
|
54
54
|
): InstallMethod {
|
|
55
55
|
const home = options.home ?? os.homedir();
|
|
56
56
|
const execPath = options.execPath ?? process.execPath;
|
|
57
|
-
const version = options.version ?? "0.5.
|
|
57
|
+
const version = options.version ?? "0.5.1";
|
|
58
58
|
const exists = options.exists ?? existsSync;
|
|
59
59
|
|
|
60
60
|
const isSource =
|