crysk 0.3.3 → 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.
Files changed (116) hide show
  1. package/README.md +26 -17
  2. package/config/models/anthropic.json +1 -1
  3. package/dist/SKILL-dsnffnfp.md +140 -0
  4. package/dist/SKILL-gnrbph72.md +140 -0
  5. package/dist/SKILL-k4k0zn1w.md +143 -0
  6. package/dist/SKILL-kq0xejn3.md +553 -0
  7. package/dist/SKILL-qaqsbygw.md +66 -0
  8. package/dist/SKILL-vhb4c3vv.md +553 -0
  9. package/dist/SKILL-vws0aqb8.md +553 -0
  10. package/dist/SKILL-xpf6kmdw.md +74 -0
  11. package/dist/ci-admission-0ken6ehx.md +128 -0
  12. package/dist/ci-admission-t0f5qwth.md +128 -0
  13. package/dist/cli.js +3366 -1680
  14. package/dist/index.js +1884 -947
  15. package/dist/opencode-ci-ac5zksdn.md +106 -0
  16. package/dist/workflow-4pkyck01.yml +160 -0
  17. package/package.json +2 -2
  18. package/prompts/default/PROVENANCE.md +1 -0
  19. package/skills/crysk/SKILL.md +16 -16
  20. package/skills/crysk-ci-setup/SKILL.md +42 -39
  21. package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
  22. package/skills/crysk-ci-setup/references/ci-admission.md +2 -2
  23. package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
  24. package/skills/crysk-loop/SKILL.md +20 -9
  25. package/skills/crysk-pr/SKILL.md +1 -1
  26. package/src/asset-manifest.ts +0 -4
  27. package/src/assets.ts +2 -2
  28. package/src/ci/admission-ledger.ts +4 -0
  29. package/src/ci/classify-error.ts +21 -24
  30. package/src/ci/cli-record.ts +53 -1
  31. package/src/ci/crysk-secrets.ts +409 -0
  32. package/src/ci/gates.ts +31 -42
  33. package/src/ci/outcome.ts +421 -330
  34. package/src/ci/platform-config.ts +127 -0
  35. package/src/ci/platform-report.ts +935 -0
  36. package/src/ci/platform-trace.ts +551 -0
  37. package/src/ci/platform.ts +465 -0
  38. package/src/ci/publish.ts +19 -6
  39. package/src/ci/reporter.ts +9 -7
  40. package/src/ci/review-admission.ts +8 -4
  41. package/src/ci/review-levels.ts +8 -7
  42. package/src/ci/run.ts +88 -0
  43. package/src/ci/setup.ts +547 -109
  44. package/src/ci/trace-bundle.ts +1282 -0
  45. package/src/ci/trace-transcripts.ts +415 -0
  46. package/src/ci/trigger.ts +176 -33
  47. package/src/cli.ts +11 -3
  48. package/src/commands/ci-setup-questions.ts +3 -3
  49. package/src/commands/ci-setup.ts +152 -6
  50. package/src/commands/config.ts +3 -0
  51. package/src/commands/doctor.ts +15 -6
  52. package/src/compare/loop.ts +9 -1
  53. package/src/compare/martian-adapter.ts +1 -1
  54. package/src/config/config.ts +16 -3
  55. package/src/diversity/clustering.ts +0 -1
  56. package/src/diversity/identity.ts +4 -5
  57. package/src/diversity/pipeline-integration.ts +1 -9
  58. package/src/doctor.ts +3 -3
  59. package/src/execution/attempt-evidence.ts +10 -5
  60. package/src/execution/claude-session-trace.ts +480 -0
  61. package/src/execution/contracts.ts +21 -4
  62. package/src/execution/harness.ts +105 -8
  63. package/src/execution/model-fallback.ts +239 -0
  64. package/src/execution/usage-normalized.ts +6 -4
  65. package/src/home-preflight.ts +1 -1
  66. package/src/index.ts +1 -1
  67. package/src/model/catalog.ts +13 -37
  68. package/src/model/free-discovery.ts +117 -8
  69. package/src/model/model-name.ts +404 -0
  70. package/src/model/provider-capabilities.ts +22 -7
  71. package/src/model/routing.ts +346 -467
  72. package/src/pr/admission.ts +71 -11
  73. package/src/pr/ci-admission-gate.ts +2 -1
  74. package/src/pr/finding-state-record.ts +58 -0
  75. package/src/pr/gate-record.ts +22 -0
  76. package/src/pr/inline.ts +3 -0
  77. package/src/pr/plan.ts +20 -4
  78. package/src/pr/posting.ts +4 -0
  79. package/src/pr/pr-status.ts +27 -7
  80. package/src/pr/pr.ts +39 -8
  81. package/src/pr/preflight.ts +44 -2
  82. package/src/pr/publish-outcome.ts +11 -3
  83. package/src/pr/review-pr.ts +20 -4
  84. package/src/pr/target.ts +12 -3
  85. package/src/production-runtime.ts +760 -331
  86. package/src/rereview/classify.ts +4 -0
  87. package/src/rereview/prepare.ts +47 -22
  88. package/src/rereview/state.ts +34 -8
  89. package/src/review/pipeline.ts +277 -101
  90. package/src/review/preflight.ts +201 -294
  91. package/src/review/report.ts +60 -40
  92. package/src/review/review.ts +20 -3
  93. package/src/review/route-preflight.ts +79 -11
  94. package/src/review/run.ts +28 -6
  95. package/src/review/scout.ts +1 -1
  96. package/src/review/spec.ts +3 -3
  97. package/src/review/step-runner.ts +70 -1
  98. package/src/runner-authority.ts +127 -9
  99. package/src/security/binding-policy.ts +1 -2
  100. package/src/security/claude-credential.ts +355 -0
  101. package/src/security/credential-broker.ts +56 -40
  102. package/src/security/evidence-redaction.ts +179 -4
  103. package/src/security/opencode-secret-manifest.ts +114 -0
  104. package/src/security/published-text.ts +161 -0
  105. package/src/security/redact.ts +45 -0
  106. package/src/system-tools.ts +48 -21
  107. package/src/transport-registry.ts +12 -2
  108. package/src/transports/claude-code-cli.ts +21 -2
  109. package/src/transports/opencode-sdk.ts +11 -9
  110. package/src/transports/opencode-server.ts +7 -10
  111. package/src/triage/triage.ts +2 -1
  112. package/src/ui/config-edit.ts +9 -20
  113. package/src/ui/config.ts +32 -27
  114. package/src/ui/plan.ts +76 -47
  115. package/src/updater.ts +10 -7
  116. package/prompts/default/deep-review-lifecycle.md +0 -362
@@ -1,6 +1,6 @@
1
1
  import os from "node:os";
2
2
  import { loadEffectiveConfig, resolveOptionalRepoRoot } from "#config/config";
3
- import { type RoutingConfig, routingNeedsOpenCodeSdk } from "#model/routing";
3
+ import { type ModelsConfig, modelsNeedOpenCode } from "#model/model-name";
4
4
  import type { CliOptions } from "#review/preflight";
5
5
  import { styleEnabled, terminalWidth } from "#ui/primitives";
6
6
  import {
@@ -38,7 +38,7 @@ export async function runDoctorCommand(input: {
38
38
  // the loader share. Tests pass a version without resolving a package.
39
39
  readSdkVersion?: () => Promise<string | undefined>;
40
40
  }): Promise<{ report: DoctorReport; lines: string[] }> {
41
- let routingConfig: RoutingConfig | undefined;
41
+ let models: ModelsConfig | undefined;
42
42
  let configCheck: DoctorCheckItem | undefined;
43
43
  try {
44
44
  const loaded = await loadEffectiveConfig({
@@ -46,7 +46,16 @@ export async function runDoctorCommand(input: {
46
46
  home: input.home,
47
47
  configFlag: input.configFlag,
48
48
  });
49
- routingConfig = loaded.effective.routing;
49
+ models = loaded.effective.models;
50
+ // A config that loads with warnings works today and will not after the
51
+ // key it uses is removed: degraded, with the warning as its message.
52
+ if (loaded.warnings.length > 0) {
53
+ configCheck = {
54
+ name: "config",
55
+ severity: "degraded",
56
+ message: loaded.warnings.join("\n"),
57
+ };
58
+ }
50
59
  } catch (error) {
51
60
  configCheck = {
52
61
  name: "config",
@@ -63,7 +72,7 @@ export async function runDoctorCommand(input: {
63
72
  probeExactBindings: () =>
64
73
  collectDoctorExactBindingReports({
65
74
  workspaceRoot: input.workspaceRoot,
66
- routingConfig,
75
+ models,
67
76
  }),
68
77
  });
69
78
  // Same home the command was given. The no-arg reader uses os.homedir().
@@ -73,9 +82,9 @@ export async function runDoctorCommand(input: {
73
82
  readInstalledOpenCodeSdkVersion({
74
83
  nodeModulesDir: prheroLayout(input.home).nodeModulesDir,
75
84
  }));
76
- const sdkCheck = routingNeedsOpenCodeSdk(routingConfig)
85
+ const sdkCheck = modelsNeedOpenCode(models)
77
86
  ? openCodeRoutingSdkCheck({
78
- routing: routingConfig,
87
+ models,
79
88
  sdkVersion: await readSdkVersion(),
80
89
  })
81
90
  : undefined;
@@ -7,6 +7,8 @@
7
7
  // "carried from <sha>" is a prior verdict copied to a new head (not a review),
8
8
  // "overridden" and "stopped by a maintainer" are a human ending the loop.
9
9
 
10
+ import { isManualReviewHold } from "#pr/preflight";
11
+
10
12
  export interface RawStatus {
11
13
  createdAt: string;
12
14
  context: string;
@@ -40,6 +42,7 @@ type GateEvent =
40
42
  | "unverified-fixes"
41
43
  | "budget-carried"
42
44
  | "error"
45
+ | "held"
43
46
  | "pending"
44
47
  | "other-success"
45
48
  | "other-failure";
@@ -55,7 +58,11 @@ export function classifyStatus(status: RawStatus): GateEvent {
55
58
  const d = status.description ?? "";
56
59
  switch (status.state) {
57
60
  case "pending":
58
- return "pending";
61
+ // Since Stage 2 #12 a capped rule (budget used up, manual_only) holds the head pending until a
62
+ // human acts. No run holds it, so it is not a review in flight: it is a head that is not green.
63
+ return isManualReviewHold({ state: status.state, description: d })
64
+ ? "held"
65
+ : "pending";
59
66
  case "error":
60
67
  return "error";
61
68
  case "success":
@@ -145,6 +152,7 @@ const NOT_GREEN = new Set<GateEvent>([
145
152
  "budget-exhausted",
146
153
  "size-skipped",
147
154
  "error",
155
+ "held",
148
156
  "other-failure",
149
157
  ]);
150
158
 
@@ -1,6 +1,6 @@
1
1
  // Project a pr-hero findings.json onto Martian's offline candidate shape.
2
2
  // Pure: no I/O, no judge, no precision/recall. The judge is theirs; this
3
- // only makes our artifacts injectable. See docs/martian-bench.md.
3
+ // only makes our artifacts injectable. See benchmarks/martian/README.md.
4
4
 
5
5
  import type { Finding } from "#review/findings";
6
6
 
@@ -158,6 +158,10 @@ export interface EffectiveConfig {
158
158
  // Returned from the same stat the read used, so the artifact cannot
159
159
  // disagree with what was actually loaded.
160
160
  globalPresent: boolean;
161
+ // What the two files said that still works but is on its way out (today,
162
+ // `summary.model: "haiku"`), one line each, file named. Every shell that
163
+ // loads config for a run prints them; the parsers never print.
164
+ warnings: string[];
161
165
  }
162
166
 
163
167
  // C5 §3.4 — the two-layer read, and the ONLY place either config file is
@@ -201,15 +205,19 @@ export interface EffectiveConfig {
201
205
  export async function loadGlobalConfigLayer(home: string): Promise<{
202
206
  filePath: string;
203
207
  layer: ConfigLayer | undefined;
208
+ warnings: string[];
204
209
  }> {
205
210
  const filePath = prheroLayout(home).reviewConfigPath;
206
- if (!existsSync(filePath)) return { filePath, layer: undefined };
211
+ const warnings: string[] = [];
212
+ if (!existsSync(filePath)) return { filePath, layer: undefined, warnings };
207
213
  return {
208
214
  filePath,
209
215
  layer: parseGlobalConfig(
210
216
  await Bun.file(filePath).text(),
211
217
  `~/${path.basename(path.dirname(filePath))}/config.json`,
218
+ warnings,
212
219
  ),
220
+ warnings,
213
221
  };
214
222
  }
215
223
 
@@ -226,8 +234,11 @@ export async function loadEffectiveConfig(input: {
226
234
  if (input.configFlag && !existsSync(repoConfigPath)) {
227
235
  throw new CliError(`config file not found: ${repoConfigPath}`);
228
236
  }
229
- const { filePath: globalConfigPath, layer: global } =
230
- await loadGlobalConfigLayer(input.home);
237
+ const {
238
+ filePath: globalConfigPath,
239
+ layer: global,
240
+ warnings,
241
+ } = await loadGlobalConfigLayer(input.home);
231
242
  // `global !== undefined` and not a second stat: the helper returns a layer
232
243
  // exactly when the file was there and read, so the artifact's
233
244
  // `global_present` cannot disagree with what was actually loaded — which is
@@ -240,6 +251,7 @@ export async function loadEffectiveConfig(input: {
240
251
  input.configFlag
241
252
  ? undefined
242
253
  : `${path.basename(path.dirname(repoConfigPath))}/config.json`,
254
+ warnings,
243
255
  )
244
256
  : {};
245
257
  return {
@@ -247,6 +259,7 @@ export async function loadEffectiveConfig(input: {
247
259
  repoConfigPath,
248
260
  globalConfigPath,
249
261
  globalPresent,
262
+ warnings,
250
263
  };
251
264
  }
252
265
 
@@ -7,7 +7,6 @@ export interface FindingObservation {
7
7
  readonly legId: string;
8
8
  readonly backend: string;
9
9
  readonly provider: string;
10
- readonly gateway?: string;
11
10
  readonly modelFamily: string;
12
11
  readonly modelSnapshot: string;
13
12
  readonly modelVariant?: string;
@@ -1,9 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { modelNameFromAlias } from "#model/model-name";
2
3
  import {
3
4
  agentStepKey,
4
- parseLogicalIdentity,
5
5
  type ResolvedStepRoute,
6
- type RoutingConfig,
7
6
  resolveStepRoute,
8
7
  } from "#model/routing";
9
8
  import {
@@ -106,7 +105,6 @@ export function freezeDiversityPlan(
106
105
  export interface BuildDiversityPlanInput {
107
106
  readonly spec: ReviewSpec;
108
107
  readonly c2SchemaVersion: string;
109
- readonly routingConfig?: RoutingConfig;
110
108
  readonly cliModel?: string;
111
109
  readonly frontmatterModel?: (agentKey: string) => string | undefined;
112
110
  readonly target?: BenchmarkTarget;
@@ -131,7 +129,9 @@ export function buildDiversityPlan(
131
129
  if (!models || models.length === 0) continue;
132
130
  const specialty = resolveSpecialty(agent);
133
131
  for (const model of models) {
134
- const parsed = parseLogicalIdentity(model);
132
+ // A leg's model is internal: a bare alias or a full model name. Its
133
+ // own model always wins over `models`, so the plan needs no `models`.
134
+ const parsed = { canonical: modelNameFromAlias(model).raw };
135
135
  const provisionalKey = diversityLegAgentKey(
136
136
  agent.key,
137
137
  deriveLegId(specialty, parsed.canonical, "pending"),
@@ -142,7 +142,6 @@ export function buildDiversityPlan(
142
142
  cliModel: input.cliModel,
143
143
  specModel: model,
144
144
  frontmatterModel: input.frontmatterModel?.(agent.key),
145
- routingConfig: input.routingConfig,
146
145
  });
147
146
  const legId = deriveLegId(
148
147
  specialty,
@@ -1,4 +1,4 @@
1
- import type { ResolvedRoutePlan, RoutingConfig } from "#model/routing";
1
+ import type { ResolvedRoutePlan } from "#model/routing";
2
2
  import type { DraftFinding } from "#review/drafts";
3
3
  import { SCHEMA_VERSION_V1_1 } from "#review/findings";
4
4
  import type { AgentSpec, ReviewSpec } from "#review/spec";
@@ -60,7 +60,6 @@ export interface DiversityExecutionContext {
60
60
  export interface PrepareDiversityInput {
61
61
  readonly reviewSpec: ReviewSpec;
62
62
  readonly cliModel?: string;
63
- readonly routingConfig?: RoutingConfig;
64
63
  readonly frontmatterModel?: (agentKey: string) => string | undefined;
65
64
  readonly target?: BenchmarkTarget;
66
65
  readonly runtimeTarget?: BenchmarkTarget;
@@ -88,7 +87,6 @@ export function prepareDiversityExecution(
88
87
  spec: input.reviewSpec,
89
88
  c2SchemaVersion: SCHEMA_VERSION_V1_1,
90
89
  cliModel: input.cliModel,
91
- routingConfig: input.routingConfig,
92
90
  frontmatterModel: input.frontmatterModel,
93
91
  target: frozenTarget,
94
92
  promptFingerprint: input.promptFingerprint,
@@ -307,9 +305,6 @@ export function recordDiversityHunterResult(
307
305
  legId: resolvedLeg.legId,
308
306
  backend: routeProvenance.backend,
309
307
  provider: routeProvenance.provider,
310
- ...(routeProvenance.gateway === undefined
311
- ? {}
312
- : { gateway: routeProvenance.gateway }),
313
308
  modelFamily: routeProvenance.modelFamily,
314
309
  modelSnapshot: routeProvenance.modelSnapshot,
315
310
  ...(routeProvenance.modelVariant === undefined
@@ -435,9 +430,6 @@ export function diversityDebugFromLedger(
435
430
  path: record.observation.path,
436
431
  backend: record.observation.backend,
437
432
  provider: record.observation.provider,
438
- ...(record.observation.gateway === undefined
439
- ? {}
440
- : { gateway: record.observation.gateway }),
441
433
  modelFamily: record.observation.modelFamily,
442
434
  modelSnapshot: record.observation.modelSnapshot,
443
435
  ...(record.observation.modelVariant === undefined
package/src/doctor.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
+ import { type ModelsConfig, modelsNeedOpenCode } from "#model/model-name";
4
5
  import {
5
6
  exactBindingCapabilityIssues,
6
7
  type ProviderCapabilityReport,
7
8
  } from "#model/provider-capabilities";
8
- import { type RoutingConfig, routingNeedsOpenCodeSdk } from "#model/routing";
9
9
  import {
10
10
  agentFilePath,
11
11
  GOTCHAS_PLACEHOLDER_MARKER,
@@ -161,10 +161,10 @@ function pushProviderIssues(
161
161
  }
162
162
 
163
163
  export function openCodeRoutingSdkCheck(input: {
164
- routing: RoutingConfig | undefined;
164
+ models: ModelsConfig | undefined;
165
165
  sdkVersion: string | undefined;
166
166
  }): DoctorCheckItem | undefined {
167
- if (!routingNeedsOpenCodeSdk(input.routing)) return undefined;
167
+ if (!modelsNeedOpenCode(input.models)) return undefined;
168
168
  const version =
169
169
  typeof input.sdkVersion === "string" ? input.sdkVersion.trim() : "";
170
170
  if (version === SUPPORTED_OPENCODE_SDK_VERSION) return undefined;
@@ -8,7 +8,11 @@ import {
8
8
  redactEvidenceText,
9
9
  } from "../security/evidence-redaction";
10
10
  import { writeJsonAtomically } from "./atomic-write";
11
- import type { TransportOutcome, TransportRequest } from "./contracts";
11
+ import {
12
+ effortApplied,
13
+ type TransportOutcome,
14
+ type TransportRequest,
15
+ } from "./contracts";
12
16
  import type { SettlementReceipt } from "./settlement";
13
17
  import { attemptEvidencePath } from "./step-artifacts";
14
18
 
@@ -378,12 +382,13 @@ export async function freezeAttemptEvidenceIdentity(
378
382
  // #299: the effort the engine REQUESTED, and whether this backend
379
383
  // could apply it. The CLI's implicit default (medium on the 5.5
380
384
  // family) is what the artifacts could not show before. OpenCode has
381
- // no `--effort`, so there the level is intent only, and
382
- // `effortApplied: false` keeps a reader from taking it as a fact
383
- // about the run. Additive, and deliberately NOT in `identity` or the
385
+ // no `--effort`: there the level is intent only, and an effort reaches
386
+ // it only as the variant a `models` entry sets (S7, `route.modelVariant`
387
+ // above), so `effortApplied` is true only then (effortApplied,
388
+ // contracts.ts). Additive, and deliberately NOT in `identity` or the
384
389
  // route fingerprint: those are compared across runs by the lab.
385
390
  effort: request.effort,
386
- effortApplied: request.route.backend === "claude-code",
391
+ effortApplied: effortApplied(request.route),
387
392
  ...frozen,
388
393
  };
389
394
  await mkdir(path.dirname(file), { recursive: true });