crysk 0.6.1 → 0.8.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 +28 -22
- package/dist/SKILL-1q3658n0.md +74 -0
- package/dist/SKILL-25j4q9b8.md +143 -0
- package/dist/SKILL-32cmme3j.md +143 -0
- package/dist/SKILL-4747bhne.md +143 -0
- package/dist/SKILL-4jc3sv23.md +74 -0
- package/dist/SKILL-c0492rch.md +540 -0
- package/dist/SKILL-d1nzkhhr.md +74 -0
- package/dist/SKILL-f8p7kvx0.md +143 -0
- package/dist/SKILL-gxd45g38.md +553 -0
- package/dist/SKILL-rec41991.md +66 -0
- package/dist/SKILL-zze8zj5g.md +536 -0
- package/dist/adjudicator-eckqh14e.md +78 -0
- package/dist/ci-admission-qn797a6c.md +128 -0
- package/dist/cli.js +18608 -18523
- package/dist/consolidate-4xw1pkg7.md +24 -0
- package/dist/deep-review-logic-dgr112y1.md +196 -0
- package/dist/deep-review-logic-fck5z4xe.md +197 -0
- package/dist/deep-review-logic-h1fpamfh.md +192 -0
- package/dist/deep-review-logic-m4vk5683.md +196 -0
- package/dist/deep-review-logic-z63kmgmc.md +157 -0
- package/dist/deep-review-parity-7x7s5d81.md +148 -0
- package/dist/deep-review-parity-9wxmynsc.md +115 -0
- package/dist/deep-review-parity-bwwe7cx6.md +152 -0
- package/dist/deep-review-parity-e50pw3pk.md +117 -0
- package/dist/deep-review-parity-ennmm9m1.md +151 -0
- package/{prompts/default/deep-review-parity.md → dist/deep-review-parity-h7y6y2he.md} +14 -16
- package/dist/deep-review-parity-xg6wy69c.md +151 -0
- package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
- package/dist/deep-review-reliability-dcjab69x.md +122 -0
- package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
- package/dist/deep-review-reliability-hvasvmt9.md +153 -0
- package/dist/deep-review-reliability-mjnayxmt.md +158 -0
- package/dist/deep-review-reliability-mm7fnayf.md +124 -0
- package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
- package/dist/deep-review-resilience-0esd5qeh.md +148 -0
- package/dist/deep-review-resilience-envgcmpy.md +115 -0
- package/dist/deep-review-resilience-fgx8ythf.md +151 -0
- package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
- package/dist/deep-review-resilience-pwh1gawp.md +151 -0
- package/dist/deep-review-resilience-s9n21dkx.md +117 -0
- package/dist/deep-review-resilience-vz4qskea.md +119 -0
- package/dist/deep-review-security-1vwjdc9q.md +205 -0
- package/dist/deep-review-security-x1cc1z00.md +205 -0
- package/dist/index.js +590 -485
- package/dist/opencode-ci-jc8mf4wn.md +106 -0
- package/dist/opencode-ci-qrcv7a99.md +106 -0
- package/dist/opencode-ci-rdpcc7xc.md +106 -0
- package/dist/opencode-ci-yt0k74t0.md +106 -0
- package/dist/review-refuter-7qffwtzz.md +77 -0
- package/dist/verifier-tyh8r45v.md +40 -0
- package/dist/verifier-xf4xj701.md +40 -0
- package/dist/workflow-andv2dvm.yml +158 -0
- package/package.json +1 -1
- package/prompts/consolidate.md +1 -1
- package/prompts/default/PROVENANCE.md +6 -0
- package/prompts/default/deep-review-logic.md +56 -15
- package/prompts/default/deep-review-reliability.md +64 -30
- package/prompts/default/deep-review-resilience.md +71 -37
- package/prompts/default/deep-review-security.md +205 -0
- package/prompts/default/review-refuter.md +1 -1
- package/prompts/verifier.md +40 -0
- package/skills/crysk/SKILL.md +6 -6
- package/skills/crysk-ci-setup/SKILL.md +32 -33
- package/skills/crysk-ci-setup/assets/workflow.yml +5 -10
- package/skills/crysk-ci-setup/references/ci-admission.md +5 -5
- package/skills/crysk-ci-setup/references/opencode-ci.md +6 -6
- package/skills/crysk-loop/SKILL.md +37 -54
- package/skills/crysk-loop/adjudicator.md +10 -18
- package/skills/crysk-pr/SKILL.md +1 -1
- package/src/asset-manifest.ts +6 -6
- package/src/assets.ts +4 -4
- package/src/brand.ts +20 -30
- package/src/ci/gates.ts +155 -192
- package/src/ci/outcome.ts +4 -31
- package/src/ci/platform-limits.ts +135 -0
- package/src/ci/platform-report.ts +212 -126
- package/src/ci/platform.ts +28 -26
- package/src/ci/reporter.ts +25 -26
- package/src/ci/review-admission.ts +1 -2
- package/src/ci/review-levels.ts +12 -53
- package/src/ci/setup.ts +96 -66
- package/src/ci/trace-bundle.ts +11 -27
- package/src/ci/trace-transcripts.ts +4 -6
- package/src/ci/trigger.ts +3 -5
- package/src/cli.ts +6 -5
- package/src/commands/ci-setup-questions.ts +2 -55
- package/src/commands/ci-setup.ts +2 -26
- package/src/commands/triage.ts +131 -38
- package/src/commands/usage.ts +0 -1
- package/src/compare/compare.ts +3 -3
- package/src/compare/floor-test.ts +30 -201
- package/src/compare/hunter-exam.ts +631 -0
- package/src/config/config.ts +6 -30
- package/src/diversity/accounting.ts +0 -26
- package/src/diversity/benchmark.ts +1 -17
- package/src/diversity/identity.ts +0 -14
- package/src/diversity/pipeline-integration.ts +0 -29
- package/src/doctor.ts +3 -6
- package/src/execution/claude-session-trace.ts +7 -2
- package/src/execution/contracts.ts +15 -9
- package/src/execution/harness.ts +165 -187
- package/src/execution/spend-limiter.ts +39 -131
- package/src/execution/usage-facts.ts +397 -0
- package/src/execution/usage-normalized.ts +33 -86
- package/src/harness/materiality-judge.ts +0 -5
- package/src/harness/pipeline-plan.ts +0 -3
- package/src/harness/replay-rows.ts +0 -5
- package/src/harness/route-runner.ts +2 -2
- package/src/harness/single-step.ts +3 -9
- package/src/index.ts +1 -1
- package/src/mcp/preflight.ts +2 -2
- package/src/model/catalog.ts +1 -3
- package/src/model/free-discovery.ts +11 -78
- package/src/model/model-name.ts +16 -5
- package/src/model/profiles/claude.ts +1 -2
- package/src/model/profiles/openai.ts +1 -2
- package/src/model/profiles.ts +2 -3
- package/src/model/provider-capabilities.ts +16 -55
- package/src/model/routing.ts +39 -36
- package/src/pr/admission.ts +6 -6
- package/src/pr/answered-findings.ts +8 -4
- package/src/pr/ci-publish.ts +0 -2
- package/src/pr/discovery.ts +4 -25
- package/src/pr/plan.ts +40 -121
- package/src/pr/pr-status.ts +14 -2
- package/src/pr/pr.ts +1 -1
- package/src/pr/preflight.ts +44 -15
- package/src/pr/publish-outcome.ts +1 -19
- package/src/pr/review-pr.ts +15 -47
- package/src/pr/target.ts +76 -82
- package/src/production-runtime.ts +52 -114
- package/src/progress.ts +0 -54
- package/src/rereview/prepare.ts +4 -1
- package/src/rereview/state.ts +1 -1
- package/src/rereview/verify.ts +15 -9
- package/src/review/boundary.ts +5 -8
- package/src/review/drafts.ts +3 -3
- package/src/review/findings-conformance.ts +1 -1
- package/src/review/findings.ts +0 -4
- package/src/review/pipeline.ts +194 -407
- package/src/review/preflight.ts +175 -201
- package/src/review/prompt-set.ts +1 -2
- package/src/review/report.ts +2 -162
- package/src/review/review.ts +25 -74
- package/src/review/route-preflight.ts +19 -35
- package/src/review/run.ts +37 -73
- package/src/review/size-gate.ts +3 -3
- package/src/review/spec.ts +6 -11
- package/src/review/step-runner.ts +4 -4
- package/src/runner-authority.ts +10 -9
- package/src/security/credential-broker.ts +5 -6
- package/src/server/preflight.ts +0 -1
- package/src/server/server.ts +17 -6
- package/src/store/activity.ts +1 -2
- package/src/store/backfill-preflight.ts +0 -3
- package/src/store/backfill.ts +0 -1
- package/src/store/metrics-preflight.ts +4 -14
- package/src/store/metrics.ts +5 -5
- package/src/store/preflight.ts +0 -13
- package/src/store/store.ts +11 -12
- package/src/transport-registry.ts +6 -30
- package/src/transports/claude-code-cli.ts +149 -215
- package/src/transports/opencode-client.ts +4 -24
- package/src/transports/opencode-sdk.ts +17 -112
- package/src/triage/plain-reply.ts +37 -0
- package/src/ui/activity.ts +1 -6
- package/src/ui/config-edit.ts +14 -67
- package/src/ui/config.ts +3 -8
- package/src/ui/plan.ts +11 -198
- package/src/ui/progress.ts +3 -49
- package/src/ui/result.ts +18 -77
- package/src/ui/review-menu.ts +3 -12
- package/src/ui/select.ts +9 -79
- package/src/updater.ts +1 -1
- package/src/usage.ts +1 -7
- package/prompts/scout.md +0 -140
- package/src/ci/platform-estimate.ts +0 -111
- package/src/review/scout.ts +0 -323
package/src/pr/review-pr.ts
CHANGED
|
@@ -93,21 +93,16 @@ import {
|
|
|
93
93
|
resolveMaxConcurrentSteps,
|
|
94
94
|
resolveSharedPrefix,
|
|
95
95
|
} from "#review/preflight";
|
|
96
|
-
import { code
|
|
96
|
+
import { code } from "#review/report";
|
|
97
97
|
import {
|
|
98
98
|
claudeAuthorityRequired,
|
|
99
99
|
isBundledAgentsDir,
|
|
100
100
|
pipelineConsolidateInput,
|
|
101
101
|
pipelineMaterialityInput,
|
|
102
|
-
pipelineScoutInput,
|
|
103
102
|
pipelineSummarizerInput,
|
|
103
|
+
pipelineVerifierInput,
|
|
104
104
|
} from "#review/route-preflight";
|
|
105
|
-
import {
|
|
106
|
-
fullReviewHunterCount,
|
|
107
|
-
prepareRunnerForRoute,
|
|
108
|
-
resolveParityFires,
|
|
109
|
-
validateGotchas,
|
|
110
|
-
} from "#review/run";
|
|
105
|
+
import { prepareRunnerForRoute, validateGotchas } from "#review/run";
|
|
111
106
|
import { sizeGateConfigFor, sizeGateLine } from "#review/size-gate";
|
|
112
107
|
import { registerActiveRun, unregisterActiveRun } from "#store/activity";
|
|
113
108
|
import {
|
|
@@ -116,7 +111,7 @@ import {
|
|
|
116
111
|
CI_ADJUDICATOR_LOGIN,
|
|
117
112
|
trustedAdjudicator,
|
|
118
113
|
} from "#triage/adjudication";
|
|
119
|
-
import {
|
|
114
|
+
import { reviewingLine } from "#ui/plan";
|
|
120
115
|
import { log, styleEnabled, terminalWidth } from "#ui/primitives";
|
|
121
116
|
import { applySizeGate, startProgressRenderer } from "#ui/progress";
|
|
122
117
|
import { parsePrFiles } from "#watch/preflight";
|
|
@@ -361,7 +356,8 @@ export async function reviewPr(
|
|
|
361
356
|
throw error;
|
|
362
357
|
}
|
|
363
358
|
const {
|
|
364
|
-
|
|
359
|
+
ciBillingMode,
|
|
360
|
+
ciRoleBilling,
|
|
365
361
|
ciSizeLimits,
|
|
366
362
|
agents,
|
|
367
363
|
spec,
|
|
@@ -428,15 +424,6 @@ export async function reviewPr(
|
|
|
428
424
|
// dry run that says SKIP for a PR the real per-file run happily accepts
|
|
429
425
|
// reads as a broken tool, not a conservative estimate.
|
|
430
426
|
if (options.dryRun) {
|
|
431
|
-
const hunterCount = dryRunHunterCount(spec, config);
|
|
432
|
-
const estimate = estimateCost(
|
|
433
|
-
target.ghDiffStat,
|
|
434
|
-
hunterCount,
|
|
435
|
-
summary.enabled,
|
|
436
|
-
options.scout,
|
|
437
|
-
0,
|
|
438
|
-
true,
|
|
439
|
-
);
|
|
440
427
|
const dryRunGateConfig = sizeGateConfigFor(
|
|
441
428
|
sizeGateOverrides,
|
|
442
429
|
config,
|
|
@@ -467,8 +454,6 @@ export async function reviewPr(
|
|
|
467
454
|
summary,
|
|
468
455
|
loaded,
|
|
469
456
|
isCi,
|
|
470
|
-
hunterCount,
|
|
471
|
-
estimate,
|
|
472
457
|
dryRunGateConfig,
|
|
473
458
|
perFile,
|
|
474
459
|
});
|
|
@@ -594,7 +579,6 @@ export async function reviewPr(
|
|
|
594
579
|
adjudicationQueue,
|
|
595
580
|
phaseB,
|
|
596
581
|
diffStat,
|
|
597
|
-
prDiffStat,
|
|
598
582
|
sizeGate,
|
|
599
583
|
} = discovery;
|
|
600
584
|
|
|
@@ -703,23 +687,13 @@ export async function reviewPr(
|
|
|
703
687
|
|
|
704
688
|
// 7 — the plan and the paid gate, exactly like local mode but with the
|
|
705
689
|
// real numstat replacing GitHub's counters.
|
|
706
|
-
const parityFires = resolveParityFires(
|
|
707
|
-
effectiveDiff.patch,
|
|
708
|
-
config.parity_trigger_paths,
|
|
709
|
-
);
|
|
710
690
|
const activeHunters = discoveryHunters({
|
|
711
691
|
skipDiscovery,
|
|
712
692
|
agents: spec.agents,
|
|
713
|
-
parityFires,
|
|
714
693
|
});
|
|
715
694
|
const hunterCount = activeHunters.length;
|
|
716
|
-
const fullHunterCount = fullReviewHunterCount(
|
|
717
|
-
spec.agents,
|
|
718
|
-
anchorPatch,
|
|
719
|
-
config.parity_trigger_paths,
|
|
720
|
-
);
|
|
721
695
|
// See resolvePrPlanAndConfirm (src/pr/plan.ts) for the full rationale —
|
|
722
|
-
//
|
|
696
|
+
// route/capability resolution, the plan card, the
|
|
723
697
|
// interactive confirm, and the "committed to spending" commit-status
|
|
724
698
|
// hold that follows a successful one.
|
|
725
699
|
const planResult = await resolvePrPlanAndConfirm({
|
|
@@ -734,7 +708,6 @@ export async function reviewPr(
|
|
|
734
708
|
diffFromSha,
|
|
735
709
|
diffPath,
|
|
736
710
|
diffStat,
|
|
737
|
-
prDiffStat,
|
|
738
711
|
droppedPaths: effectiveDiff.droppedPaths,
|
|
739
712
|
sizeGate,
|
|
740
713
|
sizeGateConfirmed,
|
|
@@ -749,13 +722,11 @@ export async function reviewPr(
|
|
|
749
722
|
isCi,
|
|
750
723
|
ciMode,
|
|
751
724
|
statusContext,
|
|
752
|
-
|
|
725
|
+
ciBillingMode,
|
|
726
|
+
ciRoleBilling,
|
|
753
727
|
claudeRun,
|
|
754
728
|
ciAdmissionLedger,
|
|
755
729
|
skipDiscovery,
|
|
756
|
-
hunterCount,
|
|
757
|
-
fullHunterCount,
|
|
758
|
-
parityFires,
|
|
759
730
|
verifyQueue,
|
|
760
731
|
prepared,
|
|
761
732
|
});
|
|
@@ -766,9 +737,7 @@ export async function reviewPr(
|
|
|
766
737
|
productionAdmission,
|
|
767
738
|
runnerAuthority,
|
|
768
739
|
maxVerificationSteps,
|
|
769
|
-
estimate,
|
|
770
740
|
statusTargetUrl,
|
|
771
|
-
freeRoute,
|
|
772
741
|
} = planResult;
|
|
773
742
|
|
|
774
743
|
let result: PipelineResult | undefined;
|
|
@@ -808,7 +777,7 @@ export async function reviewPr(
|
|
|
808
777
|
// into a group nothing ever closes.
|
|
809
778
|
let started = 0;
|
|
810
779
|
await withCiWorkflowGroup(isCi, "crysk review", log, async () => {
|
|
811
|
-
log(reviewingLine(hunterCount, summary
|
|
780
|
+
log(reviewingLine(hunterCount, summary));
|
|
812
781
|
// runnerAuthority resolved before confirm with the exact-binding gate.
|
|
813
782
|
// A plan with no claude-code route never starts the Claude CLI.
|
|
814
783
|
if (
|
|
@@ -886,15 +855,12 @@ export async function reviewPr(
|
|
|
886
855
|
mcpConfigPath,
|
|
887
856
|
hopBudget: options.hopBudget,
|
|
888
857
|
...(options.model ? { model: options.model } : {}),
|
|
889
|
-
parityTriggerPaths:
|
|
858
|
+
parityTriggerPaths: [],
|
|
890
859
|
suspicionPriors: config.suspicion_priors,
|
|
891
860
|
modelProfile: profile,
|
|
892
861
|
...(skipDiscovery
|
|
893
862
|
? {}
|
|
894
863
|
: pipelineSummarizerInput(summary, { profile })),
|
|
895
|
-
...(skipDiscovery
|
|
896
|
-
? {}
|
|
897
|
-
: pipelineScoutInput(options, { profile })),
|
|
898
864
|
...(skipDiscovery ? {} : pipelineConsolidateInput({ profile })),
|
|
899
865
|
// Gated on skipDiscovery like consolidation: an empty-delta
|
|
900
866
|
// re-review posts no new findings, so there is nothing to judge.
|
|
@@ -902,6 +868,7 @@ export async function reviewPr(
|
|
|
902
868
|
? {}
|
|
903
869
|
: pipelineMaterialityInput(config, { profile })),
|
|
904
870
|
prTitle: target.title,
|
|
871
|
+
prDescription: target.body,
|
|
905
872
|
...(resolveSharedPrefix(options) ? { sharedPrefix: true } : {}),
|
|
906
873
|
// NOT gated on skipDiscovery: an empty-delta re-review still
|
|
907
874
|
// classifies and verifies against this config, and a run whose
|
|
@@ -915,6 +882,9 @@ export async function reviewPr(
|
|
|
915
882
|
...(skipDiscovery ? { skipDiscovery: true } : {}),
|
|
916
883
|
...(rereview === undefined ? {} : { rereview }),
|
|
917
884
|
...(verifyQueue.length > 0 ? { verifyQueue } : {}),
|
|
885
|
+
// Unconditional: an overlap candidate can queue a verify step
|
|
886
|
+
// with an empty verifyQueue.
|
|
887
|
+
...pipelineVerifierInput({ profile }),
|
|
918
888
|
...(overlapCandidates.length > 0 ? { overlapCandidates } : {}),
|
|
919
889
|
...(adjudicationQueue.length > 0 ? { adjudicationQueue } : {}),
|
|
920
890
|
maxVerificationSteps,
|
|
@@ -977,8 +947,6 @@ export async function reviewPr(
|
|
|
977
947
|
isCi,
|
|
978
948
|
ciMode,
|
|
979
949
|
postMinSeverity: config.post_min_severity,
|
|
980
|
-
estimate,
|
|
981
|
-
freeRoute,
|
|
982
950
|
ciAdmissionLedger,
|
|
983
951
|
onPosted: (outcome) => {
|
|
984
952
|
posted = outcome;
|
package/src/pr/target.ts
CHANGED
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
import { existsSync } from "node:fs";
|
|
20
20
|
import os from "node:os";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
budgetUnlimitedNoticeMessage,
|
|
22
|
+
type CiBillingMode,
|
|
24
23
|
type CiSizeLimits,
|
|
25
24
|
deriveCiBillingMode,
|
|
26
|
-
|
|
25
|
+
type ModelRoleBilling,
|
|
27
26
|
resolveCiSizeLimits,
|
|
28
27
|
sizeGateUnlimitedNoticeMessage,
|
|
29
28
|
} from "#ci/gates";
|
|
30
29
|
import { formatWorkflowCommand } from "#ci/reporter";
|
|
31
|
-
import { openCodeRoutesBillMetered } from "#ci/setup";
|
|
30
|
+
import { modelRoleBilling, openCodeRoutesBillMetered } from "#ci/setup";
|
|
32
31
|
import { resolveRepoRoot } from "#git/git";
|
|
32
|
+
import { planRoutes, type ResolvedRoutePlan } from "#model/routing";
|
|
33
33
|
import { ghCurrentBranchPr, ghPrView } from "#pr/pr";
|
|
34
34
|
import {
|
|
35
35
|
type PrTarget,
|
|
@@ -44,9 +44,9 @@ import {
|
|
|
44
44
|
type CliOptions,
|
|
45
45
|
isCiEnvironment,
|
|
46
46
|
type NumstatFile,
|
|
47
|
+
resolveMaterialityGate,
|
|
47
48
|
} from "#review/preflight";
|
|
48
49
|
import type { ParsedAgent, PromptSetIdentity } from "#review/prompt-set";
|
|
49
|
-
import type { estimateCost } from "#review/report";
|
|
50
50
|
import { buildCliRoutePlan, isBundledAgentsDir } from "#review/route-preflight";
|
|
51
51
|
import {
|
|
52
52
|
type LoadedRunConfig,
|
|
@@ -113,16 +113,14 @@ export async function resolvePrRunOptions(
|
|
|
113
113
|
// yet at this point, and a `.crysk/config.json` committed by the PR author
|
|
114
114
|
// must stay unread (O-8). Same loader as local mode, so the two modes
|
|
115
115
|
// cannot drift on precedence.
|
|
116
|
-
const { loaded, config, summary,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
},
|
|
123
|
-
);
|
|
116
|
+
const { loaded, config, summary, post, profile } = await loadRunConfig({
|
|
117
|
+
root: operatorRoot,
|
|
118
|
+
home,
|
|
119
|
+
configFlag: options.config,
|
|
120
|
+
options,
|
|
121
|
+
});
|
|
124
122
|
// ROADMAP Pillar 3 (GitHub Actions CI). isCi folds in HERE, alongside
|
|
125
|
-
//
|
|
123
|
+
// post, so `options.yes` carries the headless bypass (spec 2.1:
|
|
126
124
|
// "MUST run headlessly ... equivalent to --yes") through every downstream
|
|
127
125
|
// read of `options.yes` in one move — the confirm gate, the in-flight
|
|
128
126
|
// TOCTOU check (`if (options.yes) return 0` is the correct CI answer to a
|
|
@@ -137,7 +135,7 @@ export async function resolvePrRunOptions(
|
|
|
137
135
|
prNumber,
|
|
138
136
|
home,
|
|
139
137
|
isCi,
|
|
140
|
-
options: { ...options,
|
|
138
|
+
options: { ...options, post, yes: options.yes || isCi },
|
|
141
139
|
loaded,
|
|
142
140
|
config,
|
|
143
141
|
summary,
|
|
@@ -146,7 +144,13 @@ export async function resolvePrRunOptions(
|
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
export interface ResolvedPrPromptSet {
|
|
149
|
-
|
|
147
|
+
// How the run bills (the engine's own answer: the platform cannot see it).
|
|
148
|
+
// The CI limits gate reads it (src/pr/plan.ts); the size limits resolve from it.
|
|
149
|
+
ciBillingMode: CiBillingMode;
|
|
150
|
+
// Which of the run's model roles bill an API key, for the limits gate's
|
|
151
|
+
// comparison of a mixed setup (S17). Undefined when the routes could not be
|
|
152
|
+
// resolved here: the gate then compares the whole estimate.
|
|
153
|
+
ciRoleBilling: ModelRoleBilling | undefined;
|
|
150
154
|
ciSizeLimits: CiSizeLimits | undefined;
|
|
151
155
|
agents: AgentsDirResolution;
|
|
152
156
|
spec: ReviewSpec;
|
|
@@ -156,30 +160,33 @@ export interface ResolvedPrPromptSet {
|
|
|
156
160
|
gotchasPath: string | undefined;
|
|
157
161
|
}
|
|
158
162
|
|
|
159
|
-
// The
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
async function
|
|
163
|
+
// The run's route plan, fallbacks included, from the same plan builder the run
|
|
164
|
+
// confirms with (buildCliRoutePlan), so each source routing reads counts the way
|
|
165
|
+
// routing reads it. Undefined when the plan cannot be built here; the run itself
|
|
166
|
+
// surfaces that error at confirm.
|
|
167
|
+
async function resolveRoutePlanForBilling(
|
|
164
168
|
input: Parameters<typeof buildCliRoutePlan>[0],
|
|
165
|
-
): Promise<
|
|
166
|
-
let plan: Awaited<ReturnType<typeof buildCliRoutePlan>>;
|
|
169
|
+
): Promise<ResolvedRoutePlan | undefined> {
|
|
167
170
|
try {
|
|
168
|
-
|
|
171
|
+
return await buildCliRoutePlan(input);
|
|
169
172
|
} catch {
|
|
170
173
|
return undefined;
|
|
171
174
|
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The OpenCode providers of every route of the plan, fallbacks included.
|
|
178
|
+
function openCodeRouteProviders(
|
|
179
|
+
plan: ResolvedRoutePlan | undefined,
|
|
180
|
+
): string[] | undefined {
|
|
181
|
+
if (plan === undefined) return undefined;
|
|
172
182
|
const providers = new Set<string>();
|
|
173
|
-
for (const
|
|
174
|
-
|
|
175
|
-
if (route.route.backend === "opencode")
|
|
176
|
-
providers.add(route.route.provider);
|
|
177
|
-
}
|
|
183
|
+
for (const route of planRoutes(plan)) {
|
|
184
|
+
if (route.route.backend === "opencode") providers.add(route.route.provider);
|
|
178
185
|
}
|
|
179
186
|
return [...providers].sort();
|
|
180
187
|
}
|
|
181
188
|
|
|
182
|
-
// Step 1's second half: the
|
|
189
|
+
// Step 1's second half: how the run bills, then the
|
|
183
190
|
// prompt set resolution and the gotchas PATH (never the validation itself —
|
|
184
191
|
// see this module's header). Runs after the caller's own
|
|
185
192
|
// `readLocalIgnoreRules(operatorRoot)` read, before its own
|
|
@@ -215,35 +222,41 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
215
222
|
// invoices nothing for a run whose models do not bill per token. Not
|
|
216
223
|
// envBillsMetered either: that predicate stamps Claude usage and must stay
|
|
217
224
|
// Anthropic-env-only.
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// typed into every other read of `options.budgetUsd` would make it look
|
|
242
|
-
// configured.
|
|
243
|
-
const ciBudgetCeiling = resolveCiBudgetCeiling({
|
|
244
|
-
configured: params.options.budgetUsd,
|
|
245
|
-
billingMode,
|
|
225
|
+
const routePlan = await resolveRoutePlanForBilling({
|
|
226
|
+
spec,
|
|
227
|
+
options: params.options,
|
|
228
|
+
agentFiles,
|
|
229
|
+
bundledAgents: isBundledAgentsDir(agents),
|
|
230
|
+
models: params.config.models,
|
|
231
|
+
summary: params.summary,
|
|
232
|
+
profile: params.profile,
|
|
233
|
+
// The judge step joins the run when the gate is on (plan.ts), so the plan
|
|
234
|
+
// that decides how the run bills must have it too (#551 R002). On, whatever
|
|
235
|
+
// a re-review later skips: counting a judge that may not run is the
|
|
236
|
+
// conservative side.
|
|
237
|
+
materialityEnabled: resolveMaterialityGate(params.config),
|
|
238
|
+
});
|
|
239
|
+
const claudeEnv = params.claudeRun?.env ?? process.env;
|
|
240
|
+
const authFilePresent = existsSync(resolveOpenCodeAuthPath());
|
|
241
|
+
const openCodeSecretNames = readOpenCodeSecretNames();
|
|
242
|
+
const billingMode = deriveCiBillingMode(claudeEnv, {
|
|
243
|
+
openCodeBillsMetered: openCodeRoutesBillMetered({
|
|
244
|
+
providers: openCodeRouteProviders(routePlan),
|
|
245
|
+
authFilePresent,
|
|
246
|
+
openCodeSecretNames,
|
|
247
|
+
}),
|
|
246
248
|
});
|
|
249
|
+
// The same routes, per model role: the platform prices each role and the
|
|
250
|
+
// limits gate compares the ones billed on an API key (S17).
|
|
251
|
+
const ciRoleBilling = modelRoleBilling({
|
|
252
|
+
plan: routePlan,
|
|
253
|
+
agents: spec.agents,
|
|
254
|
+
claudeEnv,
|
|
255
|
+
authFilePresent,
|
|
256
|
+
openCodeSecretNames,
|
|
257
|
+
});
|
|
258
|
+
// Resolved ONCE, here: the size limits below and the platform limits gate
|
|
259
|
+
// far below (src/pr/plan.ts's plan/confirm stage) read this same value.
|
|
247
260
|
// The size gate's half of the same route policy (ci/gates.ts,
|
|
248
261
|
// resolveCiSizeLimits). CI only: a local or watcher run keeps reading the
|
|
249
262
|
// flags and the repo config exactly as before.
|
|
@@ -254,25 +267,9 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
254
267
|
billingMode,
|
|
255
268
|
})
|
|
256
269
|
: undefined;
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
// Emitted here (once, as soon as isCi/budgetUsd are both known) rather
|
|
260
|
-
// than beside the budget-gate check far below, which only runs at all when
|
|
261
|
-
// there IS an estimate to compare against. The subscription notice rides
|
|
262
|
-
// the same reasoning and the same placement, one register quieter: a
|
|
263
|
-
// resolved no-ceiling is not an operator mistake, but it is still a gate
|
|
264
|
-
// that did not run, and this repo does not ship those silently.
|
|
270
|
+
// A gate that did not run is still announced: the size gate's notice for a
|
|
271
|
+
// route where its limits resolved to off.
|
|
265
272
|
if (params.isCi) {
|
|
266
|
-
const disabledWarning = budgetDisabledWarningMessage(
|
|
267
|
-
ciBudgetCeiling.budgetUsd,
|
|
268
|
-
);
|
|
269
|
-
if (disabledWarning !== null) {
|
|
270
|
-
log(formatWorkflowCommand("warning", disabledWarning));
|
|
271
|
-
}
|
|
272
|
-
const unlimitedNotice = budgetUnlimitedNoticeMessage(ciBudgetCeiling);
|
|
273
|
-
if (unlimitedNotice !== null) {
|
|
274
|
-
log(formatWorkflowCommand("notice", unlimitedNotice));
|
|
275
|
-
}
|
|
276
273
|
if (ciSizeLimits !== undefined) {
|
|
277
274
|
const sizeNotice = sizeGateUnlimitedNoticeMessage(ciSizeLimits);
|
|
278
275
|
if (sizeNotice !== null) {
|
|
@@ -295,7 +292,8 @@ export async function resolvePrPromptSetAndBudget(params: {
|
|
|
295
292
|
}
|
|
296
293
|
const gotchasPath = instructions.path;
|
|
297
294
|
return {
|
|
298
|
-
|
|
295
|
+
ciBillingMode: billingMode,
|
|
296
|
+
ciRoleBilling,
|
|
299
297
|
ciSizeLimits,
|
|
300
298
|
agents,
|
|
301
299
|
spec,
|
|
@@ -381,7 +379,7 @@ export async function resolvePrTargetRecord(params: {
|
|
|
381
379
|
|
|
382
380
|
// Step 3's second half: the free dry-run exit's size-gate verdict, plan
|
|
383
381
|
// card, and closing lines. Relocated out of reviewPr()'s `if (options.dryRun)`
|
|
384
|
-
// block; the FIRST half of that block (
|
|
382
|
+
// block; the FIRST half of that block (dryRunGateConfig,
|
|
385
383
|
// then the `resolvePrDryRunNumstat` call just above) stays inline in
|
|
386
384
|
// reviewPr(), unchanged. This half picks up right after `perFile` is known
|
|
387
385
|
// and returns the dry run's exit code (always 0).
|
|
@@ -400,8 +398,6 @@ export function renderPrDryRunPlan(params: {
|
|
|
400
398
|
summary: LoadedRunConfig["summary"];
|
|
401
399
|
loaded: LoadedRunConfig["loaded"];
|
|
402
400
|
isCi: boolean;
|
|
403
|
-
hunterCount: number;
|
|
404
|
-
estimate: ReturnType<typeof estimateCost>;
|
|
405
401
|
dryRunGateConfig: SizeGateConfig;
|
|
406
402
|
perFile: NumstatFile[] | null;
|
|
407
403
|
}): number {
|
|
@@ -441,8 +437,6 @@ export function renderPrDryRunPlan(params: {
|
|
|
441
437
|
spec: params.spec,
|
|
442
438
|
config: params.config,
|
|
443
439
|
summary: params.summary,
|
|
444
|
-
estimate: params.estimate,
|
|
445
|
-
hunterCount: params.hunterCount,
|
|
446
440
|
sizeGate: estimated,
|
|
447
441
|
sizeGateNote,
|
|
448
442
|
droppedPaths: [],
|