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
@@ -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";
@@ -92,7 +93,7 @@ import {
92
93
  resolveMaxConcurrentSteps,
93
94
  resolveSharedPrefix,
94
95
  } from "#review/preflight";
95
- import { estimateCost } from "#review/report";
96
+ import { code, estimateCost } from "#review/report";
96
97
  import {
97
98
  pipelineConsolidateInput,
98
99
  pipelineMaterialityInput,
@@ -121,6 +122,8 @@ 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";
126
+ import { writeGateRecord } from "./gate-record";
124
127
 
125
128
  // The CLI's record for a pipeline whose every hunter failed (cli.json,
126
129
  // odd/tasks/agent-first-ci.md, T2c). reviewPr writes it right after the pipeline's
@@ -141,7 +144,7 @@ export function recordPipelineOutcome(
141
144
  ): void {
142
145
  if (result?.sessionFailed !== true) return;
143
146
  // WHY the causes ride on the record: the publisher names the provider and the model
144
- // when every hunter failed on the provider's side (PRH-MODEL-UNAVAILABLE). A run with
147
+ // when every hunter failed on the provider's side (CRYSK-MODEL-UNAVAILABLE). A run with
145
148
  // no failed hunter list keeps the record as it was before the field existed.
146
149
  const failures = result.hunterFailures ?? [];
147
150
  writeCliRecord(
@@ -228,7 +231,7 @@ export async function postAdjudicationReplies(input: {
228
231
  });
229
232
  const evidence =
230
233
  entry.evidence.length > 0
231
- ? `\n\nEvidence:\n${entry.evidence.map((e) => `- \`${e}\``).join("\n")}`
234
+ ? `\n\nEvidence:\n${entry.evidence.map((e) => `- ${code(e)}`).join("\n")}`
232
235
  : "";
233
236
  const body = `${marker}\n\n${ADJUDICATION_BADGES[entry.verdict]}${evidence}`;
234
237
  let commentId: number | undefined;
@@ -278,6 +281,13 @@ export async function reviewPr(
278
281
  const step1 = await resolvePrRunOptions(options, prArg);
279
282
  options = step1.options;
280
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
+ });
281
291
  // S4 + T3 S7: the run's one posture. Every gate, skip, status, comment and
282
292
  // summary below takes these values; nothing re-resolves them. Both key on the
283
293
  // explicit --ci flag, never on `isCi` (which also folds in the CI/GITHUB_ACTIONS
@@ -300,6 +310,7 @@ export async function reviewPr(
300
310
  config,
301
311
  isCi,
302
312
  operatorRoot,
313
+ claudeRun,
303
314
  });
304
315
  await validateGotchas(step2.gotchasPath);
305
316
  } catch (error) {
@@ -643,6 +654,9 @@ export async function reviewPr(
643
654
  prNumber,
644
655
  headSha,
645
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);
646
660
  // diff.patch is the EFFECTIVE diff — exactly what the hunters read (see
647
661
  // filterDiffByIgnoreRules); diff.raw.patch preserves the unfiltered
648
662
  // bytes, and only when the filter actually dropped something.
@@ -698,6 +712,7 @@ export async function reviewPr(
698
712
  ciMode,
699
713
  statusContext,
700
714
  ciBudgetCeiling,
715
+ claudeRun,
701
716
  ciAdmissionLedger,
702
717
  skipDiscovery,
703
718
  hunterCount,
@@ -916,8 +931,9 @@ export async function reviewPr(
916
931
  onPosted: (outcome) => {
917
932
  posted = outcome;
918
933
  },
919
- onBlockingCount: (count) => {
934
+ onBlockingCount: (count, conclusive) => {
920
935
  blockingCount = count;
936
+ if (conclusive) writeGateRecord(runDir, count);
921
937
  },
922
938
  });
923
939
  // T5b: the verdicts are posted only after the review itself published.
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(process.env, {
167
- openCodeAuthPresent: existsSync(resolveOpenCodeAuthPath()),
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.