crysk 0.4.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.
Files changed (98) hide show
  1. package/README.md +26 -17
  2. package/config/models/anthropic.json +1 -1
  3. package/dist/SKILL-k4k0zn1w.md +143 -0
  4. package/dist/SKILL-vhb4c3vv.md +553 -0
  5. package/dist/SKILL-xpf6kmdw.md +74 -0
  6. package/dist/ci-admission-0ken6ehx.md +128 -0
  7. package/dist/cli.js +3056 -1623
  8. package/dist/index.js +1744 -938
  9. package/dist/opencode-ci-ac5zksdn.md +106 -0
  10. package/dist/workflow-4pkyck01.yml +160 -0
  11. package/package.json +1 -1
  12. package/prompts/default/PROVENANCE.md +1 -0
  13. package/skills/crysk/SKILL.md +16 -16
  14. package/skills/crysk-ci-setup/SKILL.md +41 -38
  15. package/skills/crysk-ci-setup/assets/workflow.yml +31 -22
  16. package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
  17. package/skills/crysk-ci-setup/references/opencode-ci.md +53 -88
  18. package/skills/crysk-loop/SKILL.md +1 -1
  19. package/src/asset-manifest.ts +0 -4
  20. package/src/assets.ts +1 -1
  21. package/src/ci/admission-ledger.ts +4 -0
  22. package/src/ci/classify-error.ts +21 -24
  23. package/src/ci/cli-record.ts +53 -1
  24. package/src/ci/crysk-secrets.ts +409 -0
  25. package/src/ci/force-comment.ts +14 -1
  26. package/src/ci/gates.ts +86 -57
  27. package/src/ci/outcome.ts +421 -330
  28. package/src/ci/platform-config.ts +2 -2
  29. package/src/ci/platform-estimate.ts +111 -0
  30. package/src/ci/platform-report.ts +274 -41
  31. package/src/ci/platform-trace.ts +581 -0
  32. package/src/ci/platform.ts +58 -12
  33. package/src/ci/publish.ts +19 -6
  34. package/src/ci/reporter.ts +14 -4
  35. package/src/ci/review-levels.ts +8 -7
  36. package/src/ci/run.ts +88 -0
  37. package/src/ci/setup.ts +485 -118
  38. package/src/ci/trace-bundle.ts +1486 -0
  39. package/src/ci/trace-transcripts.ts +480 -0
  40. package/src/ci/trigger.ts +176 -33
  41. package/src/cli.ts +11 -3
  42. package/src/commands/ci-setup-questions.ts +3 -3
  43. package/src/commands/ci-setup.ts +152 -6
  44. package/src/commands/config.ts +3 -0
  45. package/src/commands/doctor.ts +15 -6
  46. package/src/config/config.ts +16 -3
  47. package/src/diversity/clustering.ts +0 -1
  48. package/src/diversity/identity.ts +4 -5
  49. package/src/diversity/pipeline-integration.ts +1 -9
  50. package/src/doctor.ts +3 -3
  51. package/src/execution/attempt-evidence.ts +10 -5
  52. package/src/execution/claude-session-trace.ts +480 -0
  53. package/src/execution/contracts.ts +21 -4
  54. package/src/execution/harness.ts +105 -8
  55. package/src/execution/model-fallback.ts +239 -0
  56. package/src/execution/usage-normalized.ts +6 -4
  57. package/src/home-preflight.ts +1 -1
  58. package/src/index.ts +1 -1
  59. package/src/model/catalog.ts +13 -37
  60. package/src/model/free-discovery.ts +117 -8
  61. package/src/model/model-name.ts +404 -0
  62. package/src/model/provider-capabilities.ts +22 -7
  63. package/src/model/routing.ts +346 -467
  64. package/src/pr/admission.ts +18 -0
  65. package/src/pr/ci-admission-gate.ts +2 -0
  66. package/src/pr/discovery.ts +18 -0
  67. package/src/pr/plan.ts +55 -5
  68. package/src/pr/preflight.ts +1 -1
  69. package/src/pr/publish-outcome.ts +1 -1
  70. package/src/pr/review-pr.ts +26 -1
  71. package/src/pr/target.ts +63 -11
  72. package/src/production-runtime.ts +760 -331
  73. package/src/review/pipeline.ts +277 -101
  74. package/src/review/preflight.ts +201 -294
  75. package/src/review/report.ts +30 -26
  76. package/src/review/review.ts +20 -3
  77. package/src/review/route-preflight.ts +79 -11
  78. package/src/review/run.ts +44 -6
  79. package/src/review/scout.ts +1 -1
  80. package/src/review/spec.ts +3 -3
  81. package/src/review/step-runner.ts +70 -1
  82. package/src/runner-authority.ts +127 -9
  83. package/src/security/binding-policy.ts +1 -2
  84. package/src/security/claude-credential.ts +355 -0
  85. package/src/security/credential-broker.ts +56 -40
  86. package/src/security/evidence-redaction.ts +179 -4
  87. package/src/security/opencode-secret-manifest.ts +114 -0
  88. package/src/security/redact.ts +45 -0
  89. package/src/system-tools.ts +48 -21
  90. package/src/transport-registry.ts +12 -2
  91. package/src/transports/claude-code-cli.ts +21 -2
  92. package/src/transports/opencode-sdk.ts +11 -9
  93. package/src/transports/opencode-server.ts +7 -10
  94. package/src/ui/config-edit.ts +9 -20
  95. package/src/ui/config.ts +32 -27
  96. package/src/ui/plan.ts +84 -50
  97. package/src/updater.ts +10 -7
  98. package/prompts/default/deep-review-lifecycle.md +0 -362
@@ -21,6 +21,13 @@
21
21
 
22
22
  import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
23
23
  import path from "node:path";
24
+ // A sibling with no imports of its own, so the builtins-only rule still holds.
25
+ import {
26
+ PLATFORM_ESTIMATE_CAPABILITY,
27
+ type PlatformEstimate,
28
+ parsePlatformEstimate,
29
+ serializePlatformEstimate,
30
+ } from "./platform-estimate";
24
31
 
25
32
  export const PLATFORM_API_URL = "https://api.crysk.dev";
26
33
 
@@ -104,13 +111,19 @@ export type PlatformTokenResult =
104
111
  // `config` is absent when the platform sent none or only empty objects.
105
112
  // `dataMode` is absent when the platform sent none or anything but exactly
106
113
  // `full` or `metadata_only`; the connect step reads absence as metadata_only.
114
+ // `traceContent` is present, and true, only when the platform sent exactly
115
+ // `true`; the connect step reads absence as false.
116
+ // `estimate` is present only for the first connect step (refresh steps do not
117
+ // ask for one) and only when the platform sent a usable range.
107
118
  | {
108
119
  ok: true;
109
120
  githubToken: string;
110
121
  runToken: string;
111
122
  githubActor?: string;
112
123
  dataMode?: PlatformDataMode;
124
+ traceContent?: true;
113
125
  config?: PlatformConfig;
126
+ estimate?: PlatformEstimate;
114
127
  }
115
128
  // `message` names the HTTP status and the API's own `message` when there was
116
129
  // one. It never carries a token.
@@ -232,6 +245,11 @@ export async function exchangePlatformToken(
232
245
  headers: {
233
246
  Authorization: `Bearer ${oidc}`,
234
247
  "X-Crysk-Dispatch-Id": dispatchId,
248
+ // Only the first connect step asks: its estimate is the one the budget
249
+ // gate reads, and the platform records each estimate it sends.
250
+ ...(deps.ignoreConfig === true
251
+ ? {}
252
+ : { "X-Crysk-Capabilities": PLATFORM_ESTIMATE_CAPABILITY }),
235
253
  },
236
254
  signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
237
255
  });
@@ -247,7 +265,9 @@ export async function exchangePlatformToken(
247
265
  run_token?: unknown;
248
266
  github_actor?: unknown;
249
267
  data_mode?: unknown;
268
+ trace_content?: unknown;
250
269
  config?: unknown;
270
+ estimate?: unknown;
251
271
  };
252
272
  const {
253
273
  github_token: githubToken,
@@ -281,6 +301,12 @@ export async function exchangePlatformToken(
281
301
  [...secrets, githubToken, runToken],
282
302
  );
283
303
  }
304
+ // An estimate is advice: one that does not parse is dropped and the
305
+ // engine's own band decides, never a failed exchange.
306
+ const estimate =
307
+ deps.ignoreConfig === true
308
+ ? undefined
309
+ : parsePlatformEstimate(body.estimate);
284
310
  return {
285
311
  ok: true,
286
312
  githubToken,
@@ -291,7 +317,12 @@ export async function exchangePlatformToken(
291
317
  ...(dataMode === "full" || dataMode === "metadata_only"
292
318
  ? { dataMode }
293
319
  : {}),
320
+ // WHY fail closed: whether a review trace may carry the customer's code
321
+ // is the platform's decision (`trace_content`, today its data mode), so
322
+ // an absent or malformed value sends metadata only.
323
+ ...(body.trace_content === true ? { traceContent: true as const } : {}),
294
324
  ...(config.config === undefined ? {} : { config: config.config }),
325
+ ...(estimate === undefined ? {} : { estimate }),
295
326
  };
296
327
  } catch (error) {
297
328
  const detail = error instanceof Error ? error.message : String(error);
@@ -376,6 +407,10 @@ export async function runPlatformConnect(
376
407
  // run token always left its mode, and the report never pairs a fresh
377
408
  // token with the stale first-exchange mode.
378
409
  deps.appendOutput(`data-mode=${result.dataMode ?? "metadata_only"}\n`);
410
+ // The trace step (src/ci/platform-trace.ts) pairs it with this exchange's
411
+ // run token, like the report step does data-mode, so it is written before
412
+ // the tokens for the same reason.
413
+ deps.appendOutput(`trace-content=${result.traceContent === true}\n`);
379
414
  if (result.dataMode === undefined) {
380
415
  deps.stdout(
381
416
  "::notice title=crysk::The Crysk platform sent no recognised data_mode; treating this repository as metadata_only, so no finding text is uploaded.\n",
@@ -390,23 +425,34 @@ export async function runPlatformConnect(
390
425
  if (result.githubActor !== undefined) {
391
426
  deps.appendOutput(`github-actor=${result.githubActor}\n`);
392
427
  }
428
+ // Not a secret: two validated numbers and a basis. The run step's budget
429
+ // gate reads it as CRYSK_PLATFORM_ESTIMATE in place of the engine's band.
430
+ if (result.estimate !== undefined) {
431
+ deps.appendOutput(
432
+ `estimate=${serializePlatformEstimate(result.estimate)}\n`,
433
+ );
434
+ }
393
435
  // Present only when there is configuration to apply: the setup step and the
394
436
  // run step are gated on it, so a standalone run (no platform step, no
395
437
  // output) and an empty config both skip everything.
396
438
  if (configFile !== undefined) {
397
439
  deps.appendOutput(`config-file=${configFile}\n`);
398
- // The same test the OpenCode install step makes of the routing input
399
- // (`contains(inputs.routing, 'opencode')`): platform routing that names
400
- // OpenCode needs the CLI installed too. Present whenever the platform
401
- // sent a routing, `false` included, because platform routing wins over
402
- // the input: action.yml reads an empty output as "use the input's" and
403
- // any value as the platform's answer, so a platform routing that does not
404
- // name OpenCode overrides an input that does.
405
- const routing = result.config?.person.routing;
406
- if (routing !== undefined) {
407
- deps.appendOutput(
408
- `routing-opencode=${JSON.stringify(routing).toLowerCase().includes("opencode")}\n`,
409
- );
440
+ // Whether the models in effect name OpenCode (S1): an `opencode:` model
441
+ // needs the CLI installed. Present whenever the platform sent a non-empty
442
+ // person layer, `false` included, because that layer wins whole over the
443
+ // `models` and `credentials` inputs (D1; the setup step ignores them),
444
+ // so a layer with no models leaves the default models in effect. The
445
+ // trigger's backend flag in action.yml reads an empty output as "use the
446
+ // input's" (`contains(inputs.models, 'opencode:')`) and any value as the
447
+ // platform's answer. The OpenCode install step also reads the setup
448
+ // step's `opencode-models`, its own reading of the models in effect. A
449
+ // platform `routing` is refused by the setup step's person parser.
450
+ const person = result.config?.person ?? {};
451
+ if (Object.keys(person).length > 0) {
452
+ const models = person.models;
453
+ const opencode =
454
+ models !== undefined && JSON.stringify(models).includes('"opencode:');
455
+ deps.appendOutput(`routing-opencode=${opencode}\n`);
410
456
  }
411
457
  }
412
458
  } catch (error) {
package/src/ci/publish.ts CHANGED
@@ -215,7 +215,7 @@ export function decidePublication(input: {
215
215
  return { kind: "none" };
216
216
  }
217
217
  // WHY before the outcome fallthrough below: an override is not an error, and
218
- // rendering it as one would publish a false PRH-INSTALL-FAILED.
218
+ // rendering it as one would publish a false CRYSK-INSTALL-FAILED.
219
219
  if (record.decision === "override") return decideOverride(record);
220
220
  if (record.decision === "review" && input.cliStarted) {
221
221
  return decideCliOutcome(record, input.cliRecord, input.latestStatusState);
@@ -412,7 +412,7 @@ function huntersFailedRendering(
412
412
  if (rendered !== undefined) return rendered;
413
413
  }
414
414
  return renderCode(
415
- "PRH-HUNTERS-FAILED",
415
+ "CRYSK-HUNTERS-FAILED",
416
416
  { ...runParams, step: REVIEW_STEP, detail: sharedDetail ?? HUNTERS_DETAIL },
417
417
  "action",
418
418
  // Every hunter was refused for the size of the request: the fix is a smaller review.
@@ -474,6 +474,15 @@ function renderRecordOutcome(
474
474
  "action",
475
475
  );
476
476
  }
477
+ // The record's detail names the removed inputs; the class is the publisher's own,
478
+ // like a missing credential's.
479
+ if (record.decision === "removed-inputs") {
480
+ return renderError(
481
+ { kind: "trigger", check: "removed-input" },
482
+ params,
483
+ "action",
484
+ );
485
+ }
477
486
  if (record.decision === "unverifiable") {
478
487
  // WHY the step name: a lookup with no captured status has no class to
479
488
  // render, and "stopped at this step" needs a step to name.
@@ -516,7 +525,7 @@ function clipStatusDescription(text: string): string {
516
525
  // before its signal settle lands, so the publisher writes this instead of leaving the head
517
526
  // pending. It names the cancel and the way to review the head again.
518
527
  export const CANCELLED_STATUS_DESCRIPTION =
519
- "PRH-CANCELLED: not reviewed — /pr-hero review reviews this head";
528
+ "CRYSK-CANCELLED: not reviewed — /crysk review reviews this head";
520
529
 
521
530
  // The run URL identifies the pending (SB3 follow-up). A pending the CLI posted in Actions carries
522
531
  // its run's attempt URL (actionsRunUrl, src/ci/cli-record.ts), and the settle is this run's only
@@ -662,7 +671,7 @@ function statusWriteFailure(
662
671
  ? "server"
663
672
  : undefined;
664
673
  return renderCode(
665
- "PRH-STATUS-WRITE-FAILED",
674
+ "CRYSK-STATUS-WRITE-FAILED",
666
675
  {
667
676
  detail:
668
677
  httpStatus === undefined
@@ -1313,7 +1322,11 @@ export function runPublish(deps: PublishDeps): number {
1313
1322
  if (cliStarted) return 0;
1314
1323
  report(
1315
1324
  deps,
1316
- renderCode("PRH-UNCLASSIFIED", { step: "the outcome record" }, "action"),
1325
+ renderCode(
1326
+ "CRYSK-UNCLASSIFIED",
1327
+ { step: "the outcome record" },
1328
+ "action",
1329
+ ),
1317
1330
  );
1318
1331
  return 1;
1319
1332
  }
@@ -1525,7 +1538,7 @@ export function runCancelSettle(deps: PublishDeps): number {
1525
1538
  deps.stdout(
1526
1539
  workflowCommand(
1527
1540
  "notice",
1528
- "the review was cancelled; the crysk status is now PRH-CANCELLED",
1541
+ "the review was cancelled; the crysk status is now CRYSK-CANCELLED",
1529
1542
  ),
1530
1543
  );
1531
1544
  } else {
@@ -150,6 +150,9 @@ interface CiSkipSizeSummary {
150
150
  changedFiles: number;
151
151
  maxChangedLines: number;
152
152
  maxChangedFiles: number;
153
+ // A platform-connected run: the limits live in the Crysk dashboard, not in
154
+ // workflow inputs, so the summary says so like the comment does.
155
+ platformConnected?: true;
153
156
  }
154
157
 
155
158
  interface CiSkipBudgetSummary {
@@ -157,6 +160,8 @@ interface CiSkipBudgetSummary {
157
160
  prNumber: number;
158
161
  estimatedCostUsd: number;
159
162
  budgetUsd: number;
163
+ // A platform repository has no `--budget-usd` to raise (cryskai/platform#12).
164
+ platformConnected?: true;
160
165
  }
161
166
 
162
167
  interface CiSkipExcludedSummary {
@@ -327,8 +332,11 @@ function skipSizeLines(data: CiSkipSizeSummary): string[] {
327
332
  `| Changed lines | ${data.changedLines} (${sizeLimitText(data.maxChangedLines)}) |`,
328
333
  `| Changed files | ${data.changedFiles} (${sizeLimitText(data.maxChangedFiles)}) |`,
329
334
  "",
330
- "Crysk did not run to avoid reviewing an unbounded diff. Split the " +
331
- "PR or raise `max-changed-lines` / `max-changed-files`.",
335
+ data.platformConnected === true
336
+ ? "Crysk did not run to avoid reviewing an unbounded diff. Split the " +
337
+ "PR or raise the size limits in the Crysk dashboard."
338
+ : "Crysk did not run to avoid reviewing an unbounded diff. Split the " +
339
+ "PR or raise `max-changed-lines` / `max-changed-files`.",
332
340
  ];
333
341
  }
334
342
 
@@ -342,8 +350,10 @@ function skipBudgetLines(data: CiSkipBudgetSummary): string[] {
342
350
  "| --- | --- |",
343
351
  `| Estimated cost | ${usd(data.estimatedCostUsd)} (budget ${usd(data.budgetUsd)}) |`,
344
352
  "",
345
- "Crysk did not run to stay within the configured `--budget-usd` " +
346
- "ceiling.",
353
+ data.platformConnected === true
354
+ ? "To change what reviews cost, change the model setup in the Crysk dashboard."
355
+ : "Crysk did not run to stay within the configured `--budget-usd` " +
356
+ "ceiling.",
347
357
  ];
348
358
  }
349
359
 
@@ -214,12 +214,13 @@ export function defaultChoices(): CiSetupChoices {
214
214
  }
215
215
 
216
216
  // The `budget-usd` workflow input for these choices, or undefined to write none.
217
- // A subscription writes none. CI bills as metered only when a non-empty
218
- // ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN) is present (envBillsMetered), so
219
- // a subscription-only repo already gets no ceiling. An explicit 0 would print
220
- // the disabled-ceiling warning on every run and, worse, stay an operator
221
- // override if an API key is added later, defeating the $10 fail-safe that the
222
- // key's mere presence is meant to bring back (gates.ts, CiBillingMode).
217
+ // A subscription writes none. CI bills as metered only when the run's chosen
218
+ // Claude credential is the API key (S5: the first of `credentials.claude` that is
219
+ // present, default subscription then api_key; gates.ts, CiBillingMode), so a
220
+ // subscription run already gets no ceiling. An explicit 0 would print the
221
+ // disabled-ceiling warning on every run and, worse, stay an operator override if
222
+ // the run later moves to an API key, defeating the $10 fail-safe a metered run
223
+ // brings back.
223
224
  export function budgetInput(choices: CiSetupChoices): string | undefined {
224
225
  if (choices.billing === "api") {
225
226
  return String(choices.budgetUsd ?? CI_DEFAULT_METERED_BUDGET_USD);
@@ -301,7 +302,7 @@ export function renderChoicesSummary(
301
302
  ` budget ${
302
303
  budget === undefined
303
304
  ? choices.billing === "subscription"
304
- ? "not set: no ceiling while the repo has no ANTHROPIC_API_KEY or OPENCODE_AUTH_JSON secret (a subscription spends quota, not dollars); adding either brings back the $10 ceiling"
305
+ ? "not set: no ceiling while the review runs on CRYSK_CLAUDE_OAUTH_TOKEN and no OpenCode model (a subscription spends quota, not dollars); CRYSK_CLAUDE_API_KEY chosen in its place, or an OpenCode model with its CRYSK_OPENCODE_* secret, brings back the $10 ceiling"
305
306
  : "not set: resolved from how the review is paid (no ceiling on a subscription, $10 on an API key)"
306
307
  : Number(budget) <= 0
307
308
  ? `none (budget-usd: ${budget}; 0 or less disables the ceiling)`
package/src/ci/run.ts ADDED
@@ -0,0 +1,88 @@
1
+ // The Run Crysk step's entry (odd/tasks/role-model-routing.md, S8, L27, U5).
2
+ //
3
+ // The workflow passes its Crysk credentials as the `crysk-secrets` input, one
4
+ // `CRYSK_*=value` line per secret. action.yml pipes that input to this script on
5
+ // stdin (`printf '%s' "$CRYSK_SECRETS_INPUT" | CRYSK_SECRETS_INPUT= bun run.ts ...`),
6
+ // the way the trigger and the setup step take it, and runs bun with the variable
7
+ // emptied: Bun hands a child the environment it STARTED with, so a variable bun
8
+ // received would reach every git, gh and agent child of the review.
9
+ //
10
+ // This script parses the input with the setup step's own grammar
11
+ // (parseCryskSecrets), masks every value again (the setup step already did, in the
12
+ // same job; this keeps the mask even if a later edit reorders the steps), hands the
13
+ // Claude values to the credential intake (src/security/claude-credential.ts), and
14
+ // runs the CLI with its own arguments. Nothing is written to process.env. The
15
+ // OpenCode secrets are not read here: the setup step already built the OpenCode
16
+ // auth file and its manifest from them (U3).
17
+ //
18
+ // The intake is taken even when the input holds no Claude secret, so in the action
19
+ // the review reads its Claude credential only from this input (or a login on the
20
+ // runner), never from a job-level ANTHROPIC_API_KEY nobody passed in it.
21
+
22
+ import { runCli } from "../cli";
23
+ import { takeCryskClaudeSecrets } from "../security/claude-credential";
24
+ import {
25
+ inheritedOpenCodeSecretNames,
26
+ inheritedOpenCodeSecretWarning,
27
+ parseCryskSecrets,
28
+ } from "./crysk-secrets";
29
+
30
+ export interface CiRunDeps {
31
+ // The crysk-secrets input, read from stdin by the entry point below.
32
+ readonly cryskSecrets: string;
33
+ // The CLI's arguments, as the step built them (`review --pr <n> --ci --yes ...`).
34
+ readonly argv: readonly string[];
35
+ // This process's environment, read only for the names of CRYSK_OPENCODE_*
36
+ // variables a job set (E-f F5). Absent: nothing to warn about.
37
+ readonly env?: Readonly<Record<string, string | undefined>>;
38
+ readonly stdout: (text: string) => void;
39
+ readonly runCli: (argv: string[]) => Promise<void>;
40
+ }
41
+
42
+ // Workflow-command data escaping, as the runner's own toolkit does it.
43
+ function escapeCommandData(text: string): string {
44
+ return text.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
45
+ }
46
+
47
+ export async function runCiReview(deps: CiRunDeps): Promise<void> {
48
+ const parsed = parseCryskSecrets(deps.cryskSecrets);
49
+ for (const value of parsed.masks) {
50
+ deps.stdout(`::add-mask::${escapeCommandData(value)}\n`);
51
+ }
52
+ // E-f F5: action.yml cannot empty a per-provider name, and the review's children
53
+ // inherit this process's environment, so a job-level one is named here.
54
+ for (const name of inheritedOpenCodeSecretNames(deps.env ?? {})) {
55
+ deps.stdout(
56
+ `::warning title=crysk::${escapeCommandData(inheritedOpenCodeSecretWarning(name))}\n`,
57
+ );
58
+ }
59
+ takeCryskClaudeSecrets(parsed.secrets.claude);
60
+ await deps.runCli([...deps.argv]);
61
+ }
62
+
63
+ // The env variable action.yml binds the input to in this step. A non-empty one
64
+ // here means the step was wired wrongly, and the script refuses to run.
65
+ const CRYSK_SECRETS_ENV = "CRYSK_SECRETS_INPUT";
66
+
67
+ if (import.meta.main) {
68
+ if ((process.env[CRYSK_SECRETS_ENV] ?? "") !== "") {
69
+ process.stderr.write(
70
+ `crysk: the crysk-secrets input reached run.ts through its environment, which every child it spawns would inherit; pipe it on stdin and run bun with ${CRYSK_SECRETS_ENV} empty.\n`,
71
+ );
72
+ process.exit(1);
73
+ }
74
+ // WHY read to EOF first, before anything else: the step pipes printf into this
75
+ // process under `pipefail`, and a reader that exits without draining the pipe
76
+ // could leave printf with SIGPIPE, making the step's exit something other than
77
+ // the CLI's.
78
+ const cryskSecrets = await Bun.stdin.text();
79
+ await runCiReview({
80
+ cryskSecrets,
81
+ argv: process.argv.slice(2),
82
+ env: process.env,
83
+ stdout: (text) => {
84
+ process.stdout.write(text);
85
+ },
86
+ runCli,
87
+ });
88
+ }