crysk 0.4.0 → 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 (93) 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/gates.ts +22 -36
  26. package/src/ci/outcome.ts +421 -330
  27. package/src/ci/platform-config.ts +2 -2
  28. package/src/ci/platform-report.ts +274 -41
  29. package/src/ci/platform-trace.ts +551 -0
  30. package/src/ci/platform.ts +28 -12
  31. package/src/ci/publish.ts +19 -6
  32. package/src/ci/review-levels.ts +8 -7
  33. package/src/ci/run.ts +88 -0
  34. package/src/ci/setup.ts +453 -118
  35. package/src/ci/trace-bundle.ts +1282 -0
  36. package/src/ci/trace-transcripts.ts +415 -0
  37. package/src/ci/trigger.ts +176 -33
  38. package/src/cli.ts +11 -3
  39. package/src/commands/ci-setup-questions.ts +3 -3
  40. package/src/commands/ci-setup.ts +152 -6
  41. package/src/commands/config.ts +3 -0
  42. package/src/commands/doctor.ts +15 -6
  43. package/src/config/config.ts +16 -3
  44. package/src/diversity/clustering.ts +0 -1
  45. package/src/diversity/identity.ts +4 -5
  46. package/src/diversity/pipeline-integration.ts +1 -9
  47. package/src/doctor.ts +3 -3
  48. package/src/execution/attempt-evidence.ts +10 -5
  49. package/src/execution/claude-session-trace.ts +480 -0
  50. package/src/execution/contracts.ts +21 -4
  51. package/src/execution/harness.ts +105 -8
  52. package/src/execution/model-fallback.ts +239 -0
  53. package/src/execution/usage-normalized.ts +6 -4
  54. package/src/home-preflight.ts +1 -1
  55. package/src/index.ts +1 -1
  56. package/src/model/catalog.ts +13 -37
  57. package/src/model/free-discovery.ts +117 -8
  58. package/src/model/model-name.ts +404 -0
  59. package/src/model/provider-capabilities.ts +22 -7
  60. package/src/model/routing.ts +346 -467
  61. package/src/pr/admission.ts +18 -0
  62. package/src/pr/plan.ts +20 -4
  63. package/src/pr/preflight.ts +1 -1
  64. package/src/pr/publish-outcome.ts +1 -1
  65. package/src/pr/review-pr.ts +15 -1
  66. package/src/pr/target.ts +12 -3
  67. package/src/production-runtime.ts +760 -331
  68. package/src/review/pipeline.ts +277 -101
  69. package/src/review/preflight.ts +201 -294
  70. package/src/review/report.ts +26 -26
  71. package/src/review/review.ts +20 -3
  72. package/src/review/route-preflight.ts +79 -11
  73. package/src/review/run.ts +28 -6
  74. package/src/review/scout.ts +1 -1
  75. package/src/review/spec.ts +3 -3
  76. package/src/review/step-runner.ts +70 -1
  77. package/src/runner-authority.ts +127 -9
  78. package/src/security/binding-policy.ts +1 -2
  79. package/src/security/claude-credential.ts +355 -0
  80. package/src/security/credential-broker.ts +56 -40
  81. package/src/security/evidence-redaction.ts +179 -4
  82. package/src/security/opencode-secret-manifest.ts +114 -0
  83. package/src/security/redact.ts +45 -0
  84. package/src/system-tools.ts +48 -21
  85. package/src/transport-registry.ts +12 -2
  86. package/src/transports/claude-code-cli.ts +21 -2
  87. package/src/transports/opencode-sdk.ts +11 -9
  88. package/src/transports/opencode-server.ts +7 -10
  89. package/src/ui/config-edit.ts +9 -20
  90. package/src/ui/config.ts +32 -27
  91. package/src/ui/plan.ts +76 -47
  92. package/src/updater.ts +10 -7
  93. package/prompts/default/deep-review-lifecycle.md +0 -362
@@ -1,25 +1,26 @@
1
1
  ---
2
2
  name: crysk-ci-setup
3
- description: "Trigger: setup CI, add Crysk to CI, GitHub Actions review, OpenCode, OPENCODE_AUTH_JSON, CRYSK_ROUTING, DeepSeek, admission policy, configure CI workflow, retrigger, force review, skipped review, /crysk review, /crysk override, pr-hero-force, too many findings, noisy review, post_min_severity, materiality_gate. Scaffolds the one workflow, secrets, routing, admission config, and the posting and noise settings."
3
+ description: "Trigger: setup CI, add Crysk to CI, GitHub Actions review, CRYSK_* secrets, crysk-secrets, CRYSK_MODELS, models per role in CI, OpenCode, DeepSeek, CRYSK-INPUT-REMOVED, old OPENCODE_AUTH_JSON / CRYSK_ROUTING workflows, admission policy, configure CI workflow, retrigger, force review, skipped review, /crysk review, /crysk override, pr-hero-force, too many findings, noisy review, post_min_severity, materiality_gate. Scaffolds the one workflow, secrets, models variables, admission config, and the posting and noise settings."
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: juanmaagd
7
- version: "3.3"
7
+ version: "4.0"
8
8
  ---
9
9
 
10
10
  ## Activation Contract
11
11
 
12
12
  Load when the user asks to:
13
13
  - Add Crysk to GitHub Actions CI, scaffold `.github/workflows/crysk.yml`, or configure secrets. No local install is needed: the workflow file is the whole install.
14
- - Configure **OpenCode** in CI (`OPENCODE_AUTH_JSON`, `CRYSK_ROUTING`, DeepSeek, mixed Claude+OpenCode).
14
+ - Configure the models per role in CI, or **OpenCode** (`CRYSK_MODELS`, `CRYSK_OPENCODE_*` secrets, DeepSeek, mixed Claude+OpenCode, fallbacks).
15
+ - Move a workflow off the removed inputs (`CRYSK-INPUT-REMOVED`: `claude-token`, `anthropic-api-key`, `opencode-auth` with the `OPENCODE_AUTH_JSON` secret, `routing` with the `CRYSK_ROUTING` variable).
15
16
  - Tune CI spend / re-review / admission policy.
16
17
  - Retrigger a skipped CI review (size, admission, or budget) without running the review locally.
17
18
  - Reduce review noise: fewer comments (`post_min_severity`) or fewer blocking findings that are real but improbable (`materiality_gate`).
18
19
 
19
20
  ## Hard Rules
20
21
 
21
- - **Zero secret leakage:** NEVER print, `cat`, commit, or log API keys, tokens, or `OPENCODE_AUTH_JSON`. Reference `${{ secrets.* }}` names only. Inspect `auth.json` **keys and `type` only**.
22
- - **No per-provider GitHub secrets:** Do not create `OPENAI_API_KEY` or `DEEPSEEK_API_KEY`. One secret `OPENCODE_AUTH_JSON` (whole store or a CI-only subset) + public variable `CRYSK_ROUTING`. Cap 48 KB each.
22
+ - **Zero secret leakage:** NEVER print, `cat`, commit, or log API keys, tokens, or an OpenCode `auth.json` record. Reference `${{ secrets.* }}` names only. Inspect `auth.json` **keys and `type` only**.
23
+ - **One `CRYSK_*` secret per credential, nothing else:** `CRYSK_CLAUDE_OAUTH_TOKEN` (subscription), `CRYSK_CLAUDE_API_KEY`, `CRYSK_OPENCODE_<P>_API_KEY` per OpenCode provider, `CRYSK_OPENCODE_OPENAI_OAUTH` for an OpenAI subscription. The workflow names each one in its `crysk-secrets` block, never `toJSON(secrets)`. The old `CLAUDE_CODE_OAUTH_TOKEN`, `ANTHROPIC_API_KEY` and `OPENCODE_AUTH_JSON` secrets and the `CRYSK_ROUTING` variable are read by nothing. Models per role go in the public variable `CRYSK_MODELS` (no credentials in it), the Claude order in `CRYSK_CREDENTIALS`, the OpenCode providers in `CRYSK_OPENCODE_PROVIDERS`.
23
24
  - **No install needed:** run every Crysk command as `npx -y crysk <command>` (Node is enough; the package brings its own Bun). A global `crysk` on PATH is the same command. CI itself needs no local CLI at all: the workflow runs the action. `npx -y crysk skills install` installs the Crysk, triage, and CI-setup skills into every detected coding agent, with no TTY and no MCP or launchd registration (neither is needed for the CI loop, and npx's temporary cache refuses them).
24
25
  - **Deterministic scaffolding:** Run `npx -y crysk setup --ci` (or `npx -y crysk ci init`) with the interview's flags. It writes the one workflow file, `.github/workflows/crysk.yml` (a repo that already has `pr-hero.yml` keeps it: `--force` rewrites it in place, and setup refuses to add a second file beside it). Do not fabricate it from memory. Fallback: copy `assets/workflow.yml`. Never scaffold a `pr-hero-force.yml`; it is retired.
25
26
  - **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
@@ -30,48 +31,50 @@ Load when the user asks to:
30
31
  - **`/crysk stop` stops automatic reviews on the PR.** Post it before a push that should not be reviewed: CI admission skips every later automatic review, carrying the last verdict, until a `/crysk review` or `/crysk recheck` comment. It counts only from a user with write access (checked at admission), starts no run, and never turns the gate green. See `docs/github-actions.md` ("Stopping automatic reviews").
31
32
  - **`--force` never widens discovery; `--full` does.** When a prior review of the same head was hollow or wrong and re-runs report "No changes to discover", comment `/crysk review --full`. It passes `--full`, which re-discovers the whole PR range.
32
33
  - **When the comment trigger takes effect:** GitHub reads a comment-triggered workflow from the **default branch** (for this repo, `main`, not `dev`), so `/crysk review` works only once the workflow file (`crysk.yml`, or `pr-hero.yml` in a repo set up before the rename) with its `issue_comment` trigger is merged there; a user repo also needs an action release that handles the comment, through the `@v0` it pins.
33
- - **`/crysk` vs `/pr-hero`:** the commands are `/crysk review`, `/crysk recheck`, `/crysk override` and `/crysk stop`; the action still accepts `/pr-hero …` for one version. A `pr-hero.yml` scaffolded before the rename filters only `/pr-hero …`, so a `/crysk …` comment starts nothing there: re-run `npx -y crysk ci init --force` to accept both. The same rename moved `PRHERO_ROUTING` to `CRYSK_ROUTING` (the new workflow reads it first, then the old name).
34
+ - **`/crysk` vs `/pr-hero`:** the commands are `/crysk review`, `/crysk recheck`, `/crysk override` and `/crysk stop`; the action still accepts `/pr-hero …` for one version. A `pr-hero.yml` scaffolded before the rename filters only `/pr-hero …`, so a `/crysk …` comment starts nothing there: re-run `npx -y crysk ci init --force` to accept both, which also moves the workflow to the `CRYSK_*` secrets.
34
35
  - **Legacy scaffolds:** a `pr-hero.yml` scaffolded before the comment trigger has no `issue_comment` listener, so a comment does nothing. There, use `gh workflow run pr-hero-force.yml -f pr=<n>` (add `-f full=true` to re-discover), or re-scaffold with `npx -y crysk ci init --force`, which leaves `pr-hero-force.yml` in place.
35
36
  - **Minimum action version:** this workflow listens to comments, and only an action release that ships the comment handling checks the command and the commenter's write access. An older action reviews on ANY comment starting with `/crysk review`, from anyone who can comment. Never pair this workflow with an older action; a pinned tag or sha must be at or after that release.
36
37
  - **Older heads (this repo):** a comment run loads the PR head's own `action.yml`, so on a head from before the comment handling it reviews without reading the comment (no force, no `--full`); merge or rebase the PR onto a base that has it first.
37
38
  - **Trust (this repo):** a comment run runs the PR head's code, including its `bun install`, with the workflow's secrets, so write access is checked twice: by the workflow's pre-checkout step (fail closed, before any head code runs) and again by the head's `action.yml`.
38
- - **Admission config is repo-level:** Write `.crysk/config.json` on the default branch. That file **rejects** `routing`. Person-layer only (`$HOME/.crysk/config.json` on the runner, from `vars.CRYSK_ROUTING`).
39
+ - **Admission config is repo-level:** Write `.crysk/config.json` on the default branch. That file **rejects** `models` and `credentials`: they are person-layer only (`$HOME/.crysk/config.json` on the runner, written from `vars.CRYSK_MODELS` and `vars.CRYSK_CREDENTIALS`).
39
40
  - **`.cryskignore` is read from the base ref, not the PR branch, in CI.**
40
- - **OpenCode is DATA:** quoted `routing: "${{ vars.CRYSK_ROUTING || vars.PRHERO_ROUTING }}"` + `opencode-auth: ${{ secrets.OPENCODE_AUTH_JSON }}`. Unset both = Claude CI. Never a per-provider Action input. Never echo the auth blob.
41
- - **OpenCode procedure:** when OpenCode or mixed backends are in scope, follow `references/opencode-ci.md` before setting GitHub DATA (strip personal OAuth, `modelSnapshot`, logical vs role).
41
+ - **Models and OpenCode are DATA:** the scaffold passes `models: ${{ vars.CRYSK_MODELS }}`, `credentials: ${{ vars.CRYSK_CREDENTIALS }}` and five OpenCode slot lines driven by `vars.CRYSK_OPENCODE_PROVIDERS`. Unset `CRYSK_MODELS` = Claude CI. Never a per-provider Action input. A repository connected to the Crysk platform takes its models from the platform, which wins over the inputs.
42
+ - **OpenCode procedure:** when OpenCode or mixed backends are in scope, follow `references/opencode-ci.md` before setting GitHub DATA (roles, model names, one secret per provider, the providers variable).
42
43
 
43
44
  ## Decision Gates
44
45
 
45
46
  | Condition | Action |
46
47
  |---|---|
47
48
  | `gh auth status` succeeds | Offer `gh secret set` / `gh variable set` |
48
- | `gh` missing/unauthenticated | Link to repo Settings → Secrets and variables → Actions (Variables tab for routing) |
49
- | Credential: Claude | **`CLAUDE_CODE_OAUTH_TOKEN`** — subscription (`claude setup-token` only, NOT keychain). **`ANTHROPIC_API_KEY`** — pay-as-you-go. |
50
- | Credential: OpenCode | Read `references/opencode-ci.md`. Secret + variable. Any one of the three secrets counts as a credential; with none, the run fails red with the `gh secret set` commands. |
51
- | openai API key in CI | **Refuse.** openai → ChatGPT OAuth mapping; `type:"api"` is refused. Use a non-openai API token (tested: deepseek). |
52
- | Hunters OpenCode / refuter Claude | DATA can: map only `sonnet`. Routing is by logical model, not role; hunters declare `sonnet`, refuter `opus`, summarizer `haiku`. The unmapped `opus` refuter falls through to the Claude CLI (current behavior), so keep a Claude secret. OpenCode-only (no Claude secret): use a `default` route or map all three aliases, never `sonnet` alone (`references/opencode-ci.md`). |
53
- | Mixed OpenCode providers in one run | Out of scope (#195). One OpenCode provider per run. Mixed `claude-code` + one OpenCode provider is legal. |
54
- | OpenCode CLI pin | Action installs **1.18.30** iff `opencode-auth != ''` OR routing contains `opencode`. Never `latest`. |
55
- | Fork PRs | Their pushes skip (no secrets). A user with write access comments `/crysk review`, and that run (base context, with secrets) reviews the fork head. Review `if` never reads `secrets`; the action checks credentials (Anthropic **or** Claude OAuth **or** `OPENCODE_AUTH_JSON`). |
56
- | Spend gates | Defaults: `budget-usd: 10.00` on metered routes (Anthropic key **or** OpenCode auth file), `max-changed-lines: 4000` and `max-changed-files: 50` on metered routes only; a Claude subscription route has no size limit unless the workflow or `.crysk/config.json` sets one. Claude-only OAuth stays unlimited-subscription unless OpenCode auth is also present. |
49
+ | `gh` missing/unauthenticated | Link to repo Settings → Secrets and variables → Actions (Variables tab for `CRYSK_MODELS`, `CRYSK_CREDENTIALS`, `CRYSK_OPENCODE_PROVIDERS`) |
50
+ | Credential: Claude | **`CRYSK_CLAUDE_OAUTH_TOKEN`** — subscription (`claude setup-token` only, NOT keychain). **`CRYSK_CLAUDE_API_KEY`** — pay-as-you-go. Both set: the subscription runs unless `CRYSK_CREDENTIALS` is `{"claude": ["api_key", "subscription"]}`. |
51
+ | Credential: OpenCode | Read `references/opencode-ci.md`. One `CRYSK_OPENCODE_<P>_API_KEY` per provider + `CRYSK_MODELS` + `CRYSK_OPENCODE_PROVIDERS`. Any `CRYSK_*` credential counts; with none, the run fails red with the `gh secret set` commands. |
52
+ | openai in CI | `CRYSK_OPENCODE_OPENAI_API_KEY` runs metered; `CRYSK_OPENCODE_OPENAI_OAUTH` (base64 of the `openai` record of OpenCode's `auth.json`) is the ChatGPT subscription and wins when both are set. `_OAUTH` works for openai only. |
53
+ | Workflow red with `CRYSK-INPUT-REMOVED` | It still passes `claude-token`, `anthropic-api-key`, `opencode-auth` or `routing`. `npx -y crysk ci init --force`, then set the `CRYSK_*` secrets and variables it prints. |
54
+ | Different models per step | `CRYSK_MODELS` maps roles to lists: `default`, `hunter.<key>`, `refuter`, `consolidate`, `scout`, `summary`, `judge`. Any role left on a `claude:` model needs a Claude secret; OpenCode-only = every role on OpenCode, e.g. `{"default": ["opencode:deepseek/deepseek-v4-flash"]}` (`references/opencode-ci.md`). |
55
+ | Several OpenCode providers in one run | Supported: up to 5 providers through the workflow's slots, each model on its own provider's secret, as primary or fallback. |
56
+ | OpenCode CLI pin | Action installs **1.18.30** iff the setup step wrote an OpenCode auth file OR the models in effect name `opencode:`. Never `latest`. |
57
+ | Fork PRs | Their pushes skip (no secrets). A user with write access comments `/crysk review`, and that run (base context, with secrets) reviews the fork head. Review `if` never reads `secrets`; the action checks for a `CRYSK_*` credential in `crysk-secrets` (or a login file already on the runner). |
58
+ | Spend gates | Defaults: `budget-usd: 10.00` on metered routes (the run chose `CRYSK_CLAUDE_API_KEY`, **or** an OpenCode auth file was built), `max-changed-lines: 4000` and `max-changed-files: 50` on metered routes only; a Claude subscription route has no size limit unless the workflow or `.crysk/config.json` sets one. A subscription run stays unlimited unless an OpenCode auth file is also present. |
57
59
  | Existing workflow | `setup --ci` skips; ask before `--force` |
58
60
  | First-time admission | Recommend `ci_admission_observe_only: true` — `references/ci-admission.md` |
59
61
  | User wants max CI spend | Lower `ci_max_attempts` and/or raise `ci_rereview_min_score` |
60
62
  | Custom bot posts findings | Add login to `ci_trusted_actors` |
61
63
  | Too many advisory comments on PRs | Raise the posting floor: `post_min_severity: "blocking"` in `.crysk/config.json` posts only blocking findings (`"warning"`, the recommended floor setup writes, hides advisory suggestions only). Blocking findings always post; the gate is unchanged. |
62
64
  | Blocking findings that are real but improbable keep PRs red ("an edge case that never happens") | Offer `materiality_gate: true` in `.crysk/config.json` (opt-in, off by default). An isolated judge checks each blocking finding against Crysk's posting policy; one judged not material under normal use posts as advisory and does not block. Security, credential and data-loss findings are never demoted, and any judge failure keeps the finding blocking. Cost: one sonnet call per blocking finding (about 1 per PR, roughly +$0.015 notional and +10 s per review). Pair it with `post_min_severity: "blocking"` to hide the demoted ones entirely. |
63
- | `materiality_gate` is on but nothing is ever demoted | Read the `materiality` record in the run's `pipeline.json` (in the `crysk-run-*` artifact). `unsupported_route`: the judge runs only on the Claude Code CLI talking to Anthropic directly, so a `CRYSK_ROUTING` that sends `sonnet` to OpenCode or through a gateway stands it down; keep a direct Claude route for `sonnet` or accept the gate off. `ceiling`: the pipeline ceiling left no room for one judge wave (about 9 minutes). `ran` with `judged: 0`: the run had no blocking finding the safety guard leaves unprotected, so there was nothing to judge. `skipped` on a re-review with no new commits to review is expected (the judge is left out when nothing new is hunted). `skipped` anywhere else means the key did not reach the run: the repo config must be on the PR's base branch (CI reads it from there) and a global config must not set it `false` (the key is capped). |
65
+ | `materiality_gate` is on but nothing is ever demoted | Read the `materiality` record in the run's `pipeline.json` (in the `crysk-run-*` artifact). `unsupported_route`: the judge runs only on `claude:sonnet-latest` or `claude:opus-latest`, so a `models.judge` in `CRYSK_MODELS` that lists neither stands it down; remove that role or list one of the two. `ceiling`: the pipeline ceiling left no room for one judge wave (about 9 minutes). `ran` with `judged: 0`: the run had no blocking finding the safety guard leaves unprotected, so there was nothing to judge. `skipped` on a re-review with no new commits to review is expected (the judge is left out when nothing new is hunted). `skipped` anywhere else means the key did not reach the run: the repo config must be on the PR's base branch (CI reads it from there) and a global config must not set it `false` (the key is capped). |
64
66
  | CI skipped (size, admission, or budget) | `gh pr comment <n> --body "/crysk review"`. The review runs on GitHub Actions. Do not run `crysk review --force` locally for this. Legacy scaffold (no `issue_comment` trigger): `gh workflow run pr-hero-force.yml -f pr=<n>`. |
65
67
  | Gate is red with blocking findings the team accepts | `gh pr comment <n> --body "/crysk override"` (write access, same-repo PRs only, valid for that head only; a same-head `/crysk review` keeps it red). |
66
68
  | Prior review of the same head was hollow or wrong; re-runs say "No changes to discover" | `gh pr comment <n> --body "/crysk review --full"`. A plain `/crysk review` keeps the narrowed discovery. |
67
69
  | Gate red: `crysk: review partial (N of M hunters failed, set abc123) — /pr-hero review retries it` | Some hunters failed and nothing blocking was found. `gh pr comment <n> --body "/crysk review"`. If the same hunters fail every run, fix their route (model, credential) or override. |
68
70
  | Gate red: `crysk: review partial again (N of M hunters failed, set abc123) — fix the failing route or /pr-hero override` | The previous review of this head was partial with the same hunters failing, so a retry already failed the same way. Fix the failing hunter's route (model, credential), or `gh pr comment <n> --body "/crysk override"`. `crysk status` answers `override-or-fix`. |
69
- | Gate error: `PRH-CANCELLED: not reviewed — /pr-hero review reviews this head` | The review run was cancelled (a newer push, or by hand). Comment `/crysk review` to review the head. |
70
- | `PRH-MODEL-UNAVAILABLE` (lead "Provider <name>:") | Every hunter's route names a model the provider does not serve. Fix the model id in `CRYSK_ROUTING` (check `opencode models`). |
71
- | `PRH-CRED-UNUSABLE` ("The route <provider>/<model> has no usable credential record") | `OPENCODE_AUTH_JSON` has no record for that provider. Add it to the blob, or route that model elsewhere. |
71
+ | Gate error: `CRYSK-CANCELLED: not reviewed — /pr-hero review reviews this head` | The review run was cancelled (a newer push, or by hand). Comment `/crysk review` to review the head. |
72
+ | `CRYSK-MODEL-UNAVAILABLE` (lead "Provider <name>:") | Every hunter's route names a model the provider does not serve. Fix the model id in `CRYSK_MODELS` (check `opencode models <provider>`). |
73
+ | `CRYSK-CRED-UNUSABLE` ("The route <provider>/<model> has no usable credential record") | No `CRYSK_OPENCODE_<P>_API_KEY` reached the run for that provider: set it, add its token to `CRYSK_OPENCODE_PROVIDERS`, or move that model elsewhere in `CRYSK_MODELS`. |
74
+ | `CRYSK-CONFIG-INVALID` naming the `models` or `credentials` input | `CRYSK_MODELS` or `CRYSK_CREDENTIALS` is not valid JSON or breaks a rule (the step's log names the entry). Check the same object locally under `models` / `credentials` in `~/.crysk/config.json` with `npx -y crysk config`, then set the variable again. |
72
75
  | Blocking findings answered `dismissed`, gate still red | `gh pr comment <n> --body "/crysk recheck"`: the CI adjudicator rules on each dismissal (at most 5 per run). On `upheld`, comment `/crysk review`: that next review stops counting it. `deferred` / `misclassified` never clear the gate. |
73
- | Gate error: `PRH-GOTCHAS-MISSING` ("the review instructions file (REVIEW.md or .crysk/gotchas.md) is empty or still the scaffold") | Write real facts into that file and delete the `human-attention-required` marker line (or delete the file to review with the default guidance), commit it to the default branch, then comment `/crysk review`. |
74
- | Gate error: `PRH-HUNTERS-FAILED` (every hunter failed) | Check the route and credential first (the `PRH-CRED-UNUSABLE` and `PRH-MODEL-UNAVAILABLE` rows). Free OpenCode models fail intermittently: comment `/crysk review` to retry. |
76
+ | Gate error: `CRYSK-GOTCHAS-MISSING` ("the review instructions file (REVIEW.md or .crysk/gotchas.md) is empty or still the scaffold") | Write real facts into that file and delete the `human-attention-required` marker line (or delete the file to review with the default guidance), commit it to the default branch, then comment `/crysk review`. |
77
+ | Gate error: `CRYSK-HUNTERS-FAILED` (every hunter failed) | Check the route and credential first (the `CRYSK-CRED-UNUSABLE` and `CRYSK-MODEL-UNAVAILABLE` rows). Free OpenCode models fail intermittently: comment `/crysk review` to retry. |
75
78
  | A `/crysk review` comment did nothing | The workflow is not on the default branch yet, the comment is not exact, the author lacks write access, or the workflow predates the comment trigger (re-scaffold with `--force`). |
76
79
 
77
80
  ## Review Settings Interview (ask the human, never choose for them)
@@ -85,8 +88,8 @@ Before step 4, ask the human these questions in their language. Use the native q
85
88
  - **Manual**: nothing automatic after the first review; every re-review starts with `/crysk review`.
86
89
  2. **Gate or advisory**: gate turns the `crysk` check red on blocking findings (require it in branch protection to block merges); advisory keeps it green.
87
90
  3. **How CI pays**:
88
- - **Claude subscription** (`CLAUDE_CODE_OAUTH_TOKEN`): do not ask for a budget. Tell them no `budget-usd` is written: a subscription review spends quota, not dollars, and CI applies no ceiling while the repo has neither an `ANTHROPIC_API_KEY` nor an `OPENCODE_AUTH_JSON` secret (either one makes CI metered and brings back the $10 ceiling, so a subscription mixed with OpenCode is the API-key answer).
89
- - **API key** (`ANTHROPIC_API_KEY` or an OpenCode provider): ask for the spend ceiling per review in USD (default 10, `0` = none).
91
+ - **Claude subscription** (`CRYSK_CLAUDE_OAUTH_TOKEN`): do not ask for a budget. Tell them no `budget-usd` is written: a subscription review spends quota, not dollars, and CI applies no ceiling while the run uses the subscription and no `CRYSK_OPENCODE_*` secret builds an OpenCode auth file (an OpenCode model brings back the $10 ceiling, so a subscription mixed with OpenCode is the API-key answer). An API key kept beside it is not used unless `CRYSK_CREDENTIALS` puts `api_key` first.
92
+ - **API key** (`CRYSK_CLAUDE_API_KEY` or an OpenCode provider): ask for the spend ceiling per review in USD (default 10, `0` = none).
90
93
  4. **Changed-lines threshold**: a PR with more changed lines is skipped, not reviewed. Ask on any billing (default 4000, `0` = no limit, only if they say so): unlike the budget it matters on a subscription too, where an unset threshold means no limit at all.
91
94
  5. **Advanced settings**: name them, then ask whether to review them now. Each keeps a working default if skipped:
92
95
  - score weights: blocking 2, advisory 1 (integers >= 1; `ci_blocking_weight`, `ci_advisory_weight`), and the score floor 4 (`ci_rereview_min_score`); used only by the risk-aware and thresholded policies;
@@ -95,7 +98,7 @@ Before step 4, ask the human these questions in their language. Use the native q
95
98
  - changed-files limit (`max_changed_files`): a PR touching more files is skipped; unset = none on a subscription, 50 on an API key;
96
99
  - exclusions: patterns in `.cryskignore` (gitignore syntax) the review never reads;
97
100
  - posting floor (`post_min_severity`): `suggestion` posts everything, `warning` (recommended, and what setup writes when the key is absent) hides advisory suggestions, `blocking` posts only blocking findings. Hidden findings are counted in the summary comment, and the gate is unchanged;
98
- - materiality gate (`materiality_gate`, off unless they say yes): blocking findings that are real but not material under normal use are posted as advisory instead of blocking, judged by an isolated sonnet call per blocking finding against Crysk's posting policy; security, credential and data-loss findings are never demoted. Tell them the cost (about one call per PR, +$0.015 notional, +10 s), that it needs a direct Claude route for `sonnet`, and the known limit: on a re-review, a finding that already blocked on an earlier push still counts toward the gate.
101
+ - materiality gate (`materiality_gate`, off unless they say yes): blocking findings that are real but not material under normal use are posted as advisory instead of blocking, judged by an isolated sonnet call per blocking finding against Crysk's posting policy; security, credential and data-loss findings are never demoted. Tell them the cost (about one call per PR, +$0.015 notional, +10 s), that it runs on Claude only (`claude:sonnet-latest`, or `claude:opus-latest` through `models.judge`), so it needs a Claude secret, and the known limit: on a re-review, a finding that already blocked on an earlier push still counts toward the gate.
99
102
 
100
103
  **On a re-run** (`.crysk/config.json` already has re-review keys, or the workflow already exists), first show the human the current values (`npx -y crysk config`) and offer **Keep current settings** for the level and for the line threshold. When they keep them, omit `--level` / `--max-changed-lines`: passing a flag overwrites that group, including a tuned `max_verification_steps`.
101
104
 
@@ -110,22 +113,22 @@ It writes the workflow, merges the level's keys into `.crysk/config.json` (keepi
110
113
  ## Execution Steps
111
114
 
112
115
  1. **Inspect repo:** `git rev-parse --is-inside-work-tree`, `git remote get-url origin`, `gh auth status`.
113
- 2. **Credential path:** Claude-only → skip OpenCode. OpenCode or mix → **read `references/opencode-ci.md`** and execute it (metadata inspect, CI-only blob, secret, routing with `modelSnapshot`).
114
- 3. **Claude secret (if used):** `gh secret set CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY` (secure input, never print).
115
- 4. **Workflow:** run the interview above, then `npx -y crysk setup --ci` with its flags. It writes `.github/workflows/crysk.yml` (or rewrites an existing `pr-hero.yml` in place) and the level keys in `.crysk/config.json`. Confirm `checks: write` and `actions: read`, both `pull_request` and `issue_comment` triggers, quoted `routing` / `opencode-auth`. `--force` if an old template lacks them (an old `credentials` job or a missing `issue_comment` trigger means it predates the single workflow).
116
- 5. **Review instructions (optional, recommended before the first review):** if the default branch has neither a root `REVIEW.md` nor `.crysk/gotchas.md`, run `npx -y crysk init` in the clone; it scaffolds `REVIEW.md` (an existing `.crysk/gotchas.md` is kept, and no `REVIEW.md` is written beside it). The agent writes the facts from the repository it has in context, not from the template: the deliberate oddity that looks like a bug, the invariant enforced outside the diff, the ownership rule a newcomer would break. The hunters and the refuter read the file as facts; the "Not blocking here" section is applied only by the materiality judge (`materiality_gate: true`, blocking findings only, and only to style, naming, test-hygiene, generated-code and dev-script findings), so fill it only when the human asked for that gate, and delete it otherwise. Delete the `human-attention-required` marker line (Crysk refuses to review while it is there), then commit the file to the default branch. With no file the review runs on the default guidance; an empty or scaffold file fails the run `PRH-GOTCHAS-MISSING`.
116
+ 2. **Credential path:** Claude-only → skip OpenCode. OpenCode or mix → **read `references/opencode-ci.md`** and execute it (models per role, one secret per provider, the providers variable).
117
+ 3. **Claude secret (if used):** `gh secret set CRYSK_CLAUDE_OAUTH_TOKEN` or `CRYSK_CLAUDE_API_KEY` (secure input, never print).
118
+ 4. **Workflow:** run the interview above, then `npx -y crysk setup --ci` with its flags. It writes `.github/workflows/crysk.yml` (or rewrites an existing `pr-hero.yml` in place) and the level keys in `.crysk/config.json`, and its next steps print the `gh secret set` / `gh variable set` commands for the person's `~/.crysk/config.json` (models, credentials, OpenCode providers); run the ones the human agrees to. Confirm `checks: write` and `actions: read`, both `pull_request` and `issue_comment` triggers, the `crysk-secrets: |` block and the `models` / `credentials` lines. `--force` if an old template lacks them (an old `credentials` job, a missing `issue_comment` trigger, or `claude-token` / `routing` lines mean it predates the current workflow).
119
+ 5. **Review instructions (optional, recommended before the first review):** if the default branch has neither a root `REVIEW.md` nor `.crysk/gotchas.md`, run `npx -y crysk init` in the clone; it scaffolds `REVIEW.md` (an existing `.crysk/gotchas.md` is kept, and no `REVIEW.md` is written beside it). The agent writes the facts from the repository it has in context, not from the template: the deliberate oddity that looks like a bug, the invariant enforced outside the diff, the ownership rule a newcomer would break. The hunters and the refuter read the file as facts; the "Not blocking here" section is applied only by the materiality judge (`materiality_gate: true`, blocking findings only, and only to style, naming, test-hygiene, generated-code and dev-script findings), so fill it only when the human asked for that gate, and delete it otherwise. Delete the `human-attention-required` marker line (Crysk refuses to review while it is there), then commit the file to the default branch. With no file the review runs on the default guidance; an empty or scaffold file fails the run `CRYSK-GOTCHAS-MISSING`.
117
120
  6. **Require the check:** in branch protection, require the `crysk` status check (the gate), not the `review` job. The legacy `pr-hero` status is no longer posted, so a repository that still requires it is blocked until the rule moves to `crysk`. A private repository on GitHub Free cannot require status checks (HTTP 403): report that the gate is advisory there. With `gh`, and only after asking the human: read the current protection first (`gh api repos/<o>/<r>/branches/<default>/protection`), because the PUT replaces all of it; then `gh api -X PUT repos/<o>/<r>/branches/<default>/protection` with `required_status_checks` contexts `["crysk"]`.
118
- 7. **Advanced settings:** write the answers from interview question 5 into `.crysk/config.json` (and `.cryskignore`), including `post_min_severity` when they chose a floor other than `warning` and `materiality_gate: true` only when they said yes; commit both to the default branch, and to any other branch PRs target (CI reads the config from the PR's base branch, so it applies from the next PR after the merge). **No `routing` key.** `npx -y crysk config` to verify.
119
- 8. **Verify:** `npx -y crysk doctor`. `git status`. Confirm no openai `type:"api"` blob, no echoed auth, `modelSnapshot` matches `opencode models` when OpenCode is on.
121
+ 7. **Advanced settings:** write the answers from interview question 5 into `.crysk/config.json` (and `.cryskignore`), including `post_min_severity` when they chose a floor other than `warning` and `materiality_gate: true` only when they said yes; commit both to the default branch, and to any other branch PRs target (CI reads the config from the PR's base branch, so it applies from the next PR after the merge). **No `models` or `credentials` key there** (the repo parser refuses them). `npx -y crysk config` to verify.
122
+ 8. **Verify:** `npx -y crysk doctor`. `git status`. Confirm no echoed secret, and when OpenCode is on, that every `opencode:` model id in `CRYSK_MODELS` is one `opencode models <provider>` lists and each provider's token is in `CRYSK_OPENCODE_PROVIDERS`.
120
123
  9. **Deploy:** Offer commit. Open a **same-repo** test PR (forks skip).
121
124
 
122
125
  ## Output Contract
123
126
 
124
127
  Report:
125
- - Secret status (set or manual link). Names only: which of `CLAUDE_CODE_OAUTH_TOKEN` / `ANTHROPIC_API_KEY` / `OPENCODE_AUTH_JSON` exist. Never values.
126
- - OpenCode (if in scope): `OPENCODE_AUTH_JSON` set; blob providers **names + type only**; whether the blob was stripped to one CI provider; `CRYSK_ROUTING` JSON (no credentials); `modelSnapshot` vs `opencode models`.
127
- - Workflow path (`crysk.yml`, or the pre-rename `pr-hero.yml`; both present means two reviews per PR, delete one) and whether `checks: write`, `actions: read`, the `issue_comment` trigger, and quoted `routing` / `opencode-auth` are present.
128
- - The review settings summary `setup --ci` printed (level, gate, budget, advanced settings), and which ones the human chose, including the posting floor (`post_min_severity`) and whether `materiality_gate` is on. Confirm repo `.crysk/config.json` has no `routing` key.
128
+ - Secret status (set or manual link). Names only: which `CRYSK_*` secrets exist (`gh secret list`). Never values.
129
+ - Models (if set): the `CRYSK_MODELS` and `CRYSK_CREDENTIALS` JSON (no credentials in them), and for OpenCode the `CRYSK_OPENCODE_PROVIDERS` tokens and that each model id matches `opencode models <provider>`.
130
+ - Workflow path (`crysk.yml`, or the pre-rename `pr-hero.yml`; both present means two reviews per PR, delete one) and whether `checks: write`, `actions: read`, the `issue_comment` trigger, the `crysk-secrets` block and the `models` / `credentials` lines are present, with no removed input left.
131
+ - The review settings summary `setup --ci` printed (level, gate, budget, advanced settings), and which ones the human chose, including the posting floor (`post_min_severity`) and whether `materiality_gate` is on. Confirm repo `.crysk/config.json` has no `models` or `credentials` key.
129
132
  - `npx -y crysk doctor` / `npx -y crysk config` outcome.
130
133
  - Whether the default branch has a real `REVIEW.md` or `.crysk/gotchas.md` (no `human-attention-required` marker line), or neither (reviews run on the default guidance).
131
134
  - Whether `crysk` is a required check (or only the legacy `pr-hero`, which should move to `crysk`), or that the repository cannot require one (private repository on GitHub Free).
@@ -136,5 +139,5 @@ Report:
136
139
  - `assets/workflow.yml` — the one review workflow (`pull_request` + `issue_comment` for `/crysk review`).
137
140
  - `assets/admission-config.example.json` — starter `.crysk/config.json`.
138
141
  - `references/ci-admission.md` — admission keys, modes, rollout, ledger.
139
- - `references/opencode-ci.md` — OpenCode secret/variable procedure, routing, pin, openai vs deepseek.
142
+ - `references/opencode-ci.md` — OpenCode secrets and variables, models per role, pin, openai vs deepseek.
140
143
  - `docs/github-actions.md` — full CI integration docs.
@@ -126,26 +126,35 @@ jobs:
126
126
  uses: cryskai/crysk@v0
127
127
  with:
128
128
  github-token: ${{ secrets.GITHUB_TOKEN }}
129
- # Provide a Claude credential and/or OpenCode auth (never leave every
130
- # credential blank). Inputs are wired unconditionally: an unset secret
131
- # or var expands to empty, which the action treats as absent, so
132
- # leaving the one you do not use in place costs nothing. Deleting the
133
- # line for the secret you DID set is what breaks — the credential
134
- # never reaches the action, and it fails to authenticate silently.
135
- # ANTHROPIC_API_KEY — pay-as-you-go key (billed per token via Anthropic Console), or
136
- # CLAUDE_CODE_OAUTH_TOKEN — from `claude setup-token`: a long-lived
137
- # (~1 year) token that draws on your Claude subscription at no
138
- # extra API cost. It must come from that command. The session
139
- # token `/login` leaves in the keychain expires in HOURS and is
140
- # kept alive by a refresh token CI does not have, so pasting that
141
- # one here yields a secret that works for a day and then breaks
142
- # reviews with no signal.
143
- # OPENCODE_AUTH_JSON — whole OpenCode auth.json store
144
- # vars.CRYSK_ROUTING — person-layer routing JSON; quoted so an
145
- # unset var is the empty string rather than broken YAML. The
146
- # older vars.PRHERO_ROUTING is read when this one is unset.
147
- anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
148
- claude-token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
149
- routing: "${{ vars.CRYSK_ROUTING || vars.PRHERO_ROUTING }}"
150
- opencode-auth: ${{ secrets.OPENCODE_AUTH_JSON }}
129
+ # The Crysk credentials: one CRYSK_* secret per line, each named
130
+ # explicitly (never the whole secrets context, which would hand the
131
+ # action every secret of the repository). A secret the repository does not have
132
+ # arrives empty and counts as absent, so every line stays. With
133
+ # both Claude secrets set, credentials.claude picks one (the subscription first).
134
+ # CRYSK_CLAUDE_OAUTH_TOKEN — from `claude setup-token`: a long-lived
135
+ # (~1 year) token that draws on your Claude subscription. The
136
+ # session token `/login` leaves in the keychain expires in hours.
137
+ # CRYSK_CLAUDE_API_KEY — pay-as-you-go key (billed per token).
138
+ # CRYSK_OPENCODE_OPENAI_OAUTH — an OpenAI (ChatGPT) subscription for
139
+ # OpenCode: the openai record of OpenCode's auth.json, base64 on one line.
140
+ # CRYSK_OPENCODE_<PROVIDER>_API_KEY — an OpenCode provider's API key,
141
+ # <PROVIDER> being its id uppercased with - and . as _. The 5
142
+ # lines after the fixed ones forward the providers listed in
143
+ # vars.CRYSK_OPENCODE_PROVIDERS (a JSON array, e.g. ["DEEPSEEK"]);
144
+ # an unused line renders as CRYSK_OPENCODE__API_KEY= and is skipped.
145
+ # `crysk ci init` prints the commands that set these secrets and variables.
146
+ crysk-secrets: |
147
+ CRYSK_CLAUDE_OAUTH_TOKEN=${{ secrets.CRYSK_CLAUDE_OAUTH_TOKEN }}
148
+ CRYSK_CLAUDE_API_KEY=${{ secrets.CRYSK_CLAUDE_API_KEY }}
149
+ CRYSK_OPENCODE_OPENAI_OAUTH=${{ secrets.CRYSK_OPENCODE_OPENAI_OAUTH }}
150
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[0] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[0])] }}
151
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[1] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[1])] }}
152
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[2] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[2])] }}
153
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[3] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[3])] }}
154
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[4] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[4])] }}
155
+ # The models per role and the Claude credential order, as JSON, from
156
+ # repository variables. Unset, every role runs the default Claude model
157
+ # and the subscription is tried first.
158
+ models: ${{ vars.CRYSK_MODELS }}
159
+ credentials: ${{ vars.CRYSK_CREDENTIALS }}
151
160
  mode: gate
@@ -41,7 +41,7 @@ Read this when configuring `.crysk/config.json` during CI setup. Full operator d
41
41
  | `thorough` | `every_push` | 4 | (unset) | 8 |
42
42
  | `manual` | `manual_only` | 1 | (unset) | 8 |
43
43
 
44
- Billing: `--billing subscription` writes no `budget-usd` (a subscription spends quota, not dollars, and CI applies no ceiling while the repo has neither `ANTHROPIC_API_KEY` nor `OPENCODE_AUTH_JSON`, either of which makes the route metered; an explicit 0 would warn on every run and outlive a later API key); `--billing api` writes `--budget-usd` or the $10 default. `--budget-usd` alone implies `api`, and `--budget-usd` with `subscription` is refused.
44
+ Billing: `--billing subscription` writes no `budget-usd` (a subscription spends quota, not dollars, and CI applies no ceiling while the run uses the subscription and no `CRYSK_OPENCODE_*` secret builds an OpenCode auth file; a run on `CRYSK_CLAUDE_API_KEY`, which `credentials.claude` decides, or with an OpenCode auth file is metered; an explicit 0 would warn on every run and outlive a later move to an API key); `--billing api` writes `--budget-usd` or the $10 default. `--budget-usd` alone implies `api`, and `--budget-usd` with `subscription` is refused.
45
45
 
46
46
  Re-runs: a group (the level's keys, or `max_changed_lines`) is overwritten only when someone chose it this run (a flag or a terminal answer); otherwise it fills the file only if absent, and setup prints `Changed` and `Kept existing` lines. A `--force` refresh keeps the old workflow's `mode` and `budget-usd` unless a flag names them, and in a terminal every question defaults to the current value (a tuned level that matches no preset gets a "Keep current settings" option).
47
47
 
@@ -1,141 +1,106 @@
1
1
  # OpenCode in CI — operator procedure
2
2
 
3
- Read this when the operator wants OpenCode, DeepSeek, mixed Claude+OpenCode, or GitHub `OPENCODE_AUTH_JSON` / `CRYSK_ROUTING`. Full narrative: `docs/github-actions.md` (section **OpenCode in CI**).
3
+ Read this when the operator wants OpenCode, DeepSeek, mixed Claude+OpenCode, fallback models, or different models per step in GitHub Actions. Full narrative: `docs/github-actions.md` (sections **OpenCode in CI** and **`CRYSK_*` secrets**); model rules: `docs/configuration.md` (section **Models**).
4
4
 
5
5
  Do **not** print, `cat`, or log credential values. Inspect **keys and `type` only**.
6
6
 
7
- ## Two GitHub boxes
7
+ ## What goes where
8
8
 
9
9
  | GitHub box | Name | Holds |
10
10
  |---|---|---|
11
- | **Secrets** (hidden) | `CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY` | Claude. Unchanged. |
12
- | **Secrets** | `OPENCODE_AUTH_JSON` | One JSON object: the OpenCode `auth.json` store (or a **CI-only** subset). Cap 48 KB. |
13
- | **Variables** (public) | `CRYSK_ROUTING` | Routing object only (`default` / `mappings` / `disabled`). No credentials. Cap 48 KB. Quoted in workflow `with.routing`. |
11
+ | **Secrets** (hidden) | `CRYSK_CLAUDE_OAUTH_TOKEN` or `CRYSK_CLAUDE_API_KEY` | Claude, when any step runs a `claude:` model. |
12
+ | **Secrets** | `CRYSK_OPENCODE_<P>_API_KEY` | One per OpenCode provider the models name. `<P>` is the provider id upper case, `-` and `.` as `_` (`deepseek` → `DEEPSEEK`, `github-copilot` → `GITHUB_COPILOT`). |
13
+ | **Secrets** | `CRYSK_OPENCODE_OPENAI_OAUTH` | Only for an OpenAI (ChatGPT) subscription: the `openai` record of OpenCode's `auth.json`, base64 on one line. |
14
+ | **Variables** (public) | `CRYSK_MODELS` | The `models` object: role → ordered list of models. No credentials. |
15
+ | **Variables** | `CRYSK_OPENCODE_PROVIDERS` | JSON array of the `<P>` tokens whose API keys the workflow forwards, at most 5, e.g. `["DEEPSEEK"]`. |
16
+ | **Variables** | `CRYSK_CREDENTIALS` (optional) | The Claude order, e.g. `{"claude": ["api_key", "subscription"]}`. Unset: subscription first. |
14
17
 
15
- Do **not** create `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, or any other per-provider GitHub secret. The Action has no per-provider inputs. Provider tokens live **inside** `OPENCODE_AUTH_JSON`.
18
+ Do **not** create `OPENAI_API_KEY`, `DEEPSEEK_API_KEY`, or any other secret outside the `CRYSK_*` names: the workflow forwards only the names in its `crysk-secrets` block, never `toJSON(secrets)`. The old `OPENCODE_AUTH_JSON` secret and `CRYSK_ROUTING` variable are read by nothing, and the `opencode-auth` / `routing` inputs that carried them stop the run (`CRYSK-INPUT-REMOVED`).
16
19
 
17
- Unset both OpenCode names = Claude-only CI.
20
+ Unset `CRYSK_MODELS` = Claude-only CI.
18
21
 
19
- ## Local store (metadata only)
22
+ ## Fastest path: `crysk ci init`
20
23
 
21
- Default path: `$XDG_DATA_HOME/opencode/auth.json` or `~/.local/share/opencode/auth.json`.
24
+ If the operator already has `models` in `~/.crysk/config.json`, `npx -y crysk ci init` (or `setup --ci`) prints every `gh secret set` / `gh variable set` command for it: the Claude secret, one `CRYSK_OPENCODE_<P>_API_KEY` per provider (plus the `_OAUTH` line for openai), `CRYSK_MODELS`, `CRYSK_CREDENTIALS` and `CRYSK_OPENCODE_PROVIDERS`. It never runs them. It refuses, writing nothing, when the models name more than 5 OpenCode providers. Run the commands the human agrees to; `gh secret set` asks for each value, so it never appears in the chat.
22
25
 
23
- ```bash
24
- python3 - <<'PY'
25
- import json, os
26
- p = os.path.join(os.environ.get("XDG_DATA_HOME") or os.path.join(os.path.expanduser("~"), ".local", "share"), "opencode", "auth.json")
27
- print("exists", os.path.isfile(p))
28
- if not os.path.isfile(p):
29
- raise SystemExit(0)
30
- with open(p) as f:
31
- data = json.load(f)
32
- print("providers", ",".join(sorted(data)))
33
- for name, rec in data.items():
34
- t = rec.get("type") if isinstance(rec, dict) else "?"
35
- print(f"{name} type={t}")
36
- PY
37
- ```
38
-
39
- If the store is missing, have the operator authenticate the **CI provider** in OpenCode locally first (`opencode` auth/login for that provider). Do not collect the key in chat.
26
+ ## Models per role
40
27
 
41
- ## What may go in the blob
28
+ `CRYSK_MODELS` maps a **role** to a list of one to three models, tried in order (the next one only on a provider failure: rate limit, quota, network, timeout, model unavailable):
42
29
 
43
- | `auth.json` entry | CI |
30
+ | Role | Steps |
44
31
  |---|---|
45
- | Non-openai `type: "api"` (tested: **deepseek**) | Executable metered path. Default spend ceiling applies. |
46
- | `openai` `type: "api"` | **Refuse.** Engine maps `openai` to ChatGPT OAuth; a pay-as-you-go key is not remapped. |
47
- | `openai` `type: "oauth"` | Do **not** put a personal ChatGPT session in a repository secret. |
48
- | Several OpenCode providers in **one run** | Out of scope (#195). One OpenCode provider per run. |
49
- | `claude-code` + **one** OpenCode provider | Legal. Keep a Claude secret and one OpenCode API record. |
32
+ | `default` | every role not listed (not the judge) |
33
+ | `hunter.<key>` | one hunter: `logic`, `parity`, `reliability`, `resilience` |
34
+ | `refuter` | refuter, re-review verifier, CI adjudicator |
35
+ | `consolidate`, `scout`, `summary` | those steps |
36
+ | `judge` | materiality judge: only `claude:sonnet-latest` or `claude:opus-latest`, never `default` |
50
37
 
51
- If the personal store has extra providers (ChatGPT OAuth, zai, …), **do not upload it whole**. Write a 0600 temp object with **only** the CI provider, `gh secret set` from that file, delete the temp file.
38
+ Model names: `claude:sonnet-latest` / `opus-latest` / `haiku-latest` / `fable-latest` (newest), a full `claude:claude-…` id (pinned), or `opencode:<provider>/<model>`. There is no `modelSnapshot`, `gateway` or alias mapping any more: the provider's model id is part of the name. Confirm the id with `opencode models <provider>`; do not guess `deepseek-chat` if the CLI lists `deepseek-v4-flash` / `deepseek-v4-pro`. An entry may be `{"model": "...", "effort": "..."}`; on OpenCode the effort must be one of the model's variants (`opencode models <provider> --verbose`), or the review stops before spending.
39
+
40
+ ### OpenCode-only
52
41
 
53
42
  ```bash
54
- # After writing a 0600 CI-only auth.json (deepseek-only). Never cat it.
55
- gh secret set OPENCODE_AUTH_JSON < /path/to/ci-only-auth.json
43
+ gh variable set CRYSK_MODELS --body '{"default": ["opencode:deepseek/deepseek-v4-flash"]}'
44
+ gh variable set CRYSK_OPENCODE_PROVIDERS --body '["DEEPSEEK"]'
45
+ gh secret set CRYSK_OPENCODE_DEEPSEEK_API_KEY
56
46
  ```
57
47
 
58
- `gh` missing/unauthenticated: Settings → Secrets and variables → Actions. Paste the JSON into secret `OPENCODE_AUTH_JSON`. Never paste it into the workflow YAML or the chat.
59
-
60
- ## Routing is logical model, not role
61
-
62
- `CRYSK_ROUTING` maps **logical model identity** (`sonnet`, `haiku`), not hunter vs refuter.
48
+ Every step runs on DeepSeek. Without a Claude secret, keep `materiality_gate` off: the judge runs only on Claude.
63
49
 
64
- Default prompt set:
65
-
66
- | Step | Logical model |
67
- |---|---|
68
- | Hunters | `sonnet` |
69
- | Refuter | `opus` |
70
- | Summarizer | `haiku` |
71
-
72
- A mapping moves only the steps whose logical model it names: a `sonnet` mapping moves the hunters and leaves the refuter alone. An alias with **no** mapping and **no** `default` route currently falls through to the Claude CLI (`claude-code` / `direct`), so that step needs Claude credentials in the run. A `default` route covers every alias, the refuter included.
73
-
74
- | Routing shape | Hunters (`sonnet`) | Refuter (`opus`) |
75
- |---|---|---|
76
- | `default` route only | default route | default route (same model as the hunters) |
77
- | Only a `sonnet` mapping to OpenCode | OpenCode | Claude CLI (needs a Claude secret) |
78
- | `sonnet` and `opus` mappings to OpenCode | OpenCode | OpenCode |
79
-
80
- OpenCode does not resolve Crysk aliases. Any `opencode` route for `sonnet`/`opus`/`haiku` **must** set `modelSnapshot` to the provider model id. Confirm with `opencode models` (optionally `opencode models <provider>`). Do not guess `deepseek-chat` if the CLI lists `deepseek-v4-flash` / `deepseek-v4-pro`.
81
-
82
- `gateway`: `"configured"` for OpenCode; `"direct"` for Claude CLI.
83
-
84
- Do not wrap the variable in `{"routing": ...}`. Do not put keys in the variable (it is public).
85
-
86
- ### OpenCode-only (all logicals)
50
+ ### OpenCode hunters, Claude refuter and summarizer, Claude fallback
87
51
 
88
52
  ```bash
89
- gh variable set CRYSK_ROUTING --body '{"default":{"backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-flash"}}'
53
+ gh variable set CRYSK_MODELS --body '{"default": ["opencode:deepseek/deepseek-v4-flash", "claude:sonnet-latest"], "refuter": ["claude:opus-latest"], "summary": ["claude:haiku-latest"]}'
90
54
  ```
91
55
 
92
- Replace `deepseek-v4-flash` with an id `opencode models` actually lists. The `default` route covers hunters (`sonnet`) and the refuter (`opus`) alike, so the refuter runs on this same model.
93
-
94
- ### Mixed: OpenCode default + Claude summarizer (legal DATA mix)
56
+ Keep `CRYSK_CLAUDE_OAUTH_TOKEN` (or `CRYSK_CLAUDE_API_KEY`) beside the DeepSeek secret. The OpenCode auth file still applies the metered ceiling.
95
57
 
96
- Hunters (`sonnet`) and refuter (`opus`) → the OpenCode default route, one API provider. Summarizer (`haiku`) → Claude.
58
+ ### Two OpenCode providers
97
59
 
98
60
  ```bash
99
- gh variable set CRYSK_ROUTING --body '{"default":{"backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-flash"},"mappings":[{"logical":"haiku","backend":"claude-code","provider":"anthropic","gateway":"direct"}]}'
61
+ gh variable set CRYSK_MODELS --body '{"default": ["opencode:deepseek/deepseek-v4-pro", "opencode:openai/gpt-5"]}'
62
+ gh variable set CRYSK_OPENCODE_PROVIDERS --body '["DEEPSEEK"]'
100
63
  ```
101
64
 
102
- Keep `CLAUDE_CODE_OAUTH_TOKEN` (or `ANTHROPIC_API_KEY`) for the Claude mapping. Presence of `OPENCODE_AUTH_JSON` still applies the metered ceiling.
65
+ Each model runs on its own provider's secret, through its own OpenCode server. Here OpenAI is the ChatGPT subscription through `CRYSK_OPENCODE_OPENAI_OAUTH`, which has its own fixed line, so only DeepSeek needs a token; for an OpenAI API key instead, list `"OPENAI"` too and set `CRYSK_OPENCODE_OPENAI_API_KEY`.
103
66
 
104
- ### Mixed: OpenCode hunters + Claude refuter (legal DATA mix)
67
+ ## OpenAI
105
68
 
106
- Map **only** `sonnet`. Hunters go to OpenCode; the unmapped `opus` refuter and the `haiku` summarizer (on unless `summary.enabled` is false) fall through to the Claude CLI (current behavior), so keep a Claude secret next to `OPENCODE_AUTH_JSON`.
107
-
108
- ```bash
109
- gh variable set CRYSK_ROUTING --body '{"mappings":[{"logical":"sonnet","backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-flash"}]}'
110
- ```
69
+ | Secret | CI |
70
+ |---|---|
71
+ | `CRYSK_OPENCODE_OPENAI_API_KEY` | Metered API key. Runs. |
72
+ | `CRYSK_OPENCODE_OPENAI_OAUTH` | The ChatGPT subscription. Wins when both are set. |
73
+ | `_OAUTH` for any other provider the models use | **Refused**, naming the secret. Use that provider's `_API_KEY`. |
111
74
 
112
- Do **not** use this shape in an OpenCode-only run (no Claude secret): the refuter and the summarizer are still routed to the Claude CLI and have no credentials to run them. For OpenCode-only, use the `default` route above, or map all three aliases (`sonnet`, `opus`, `haiku`), each with its own `modelSnapshot` (`opencode models` ids, same single OpenCode provider):
75
+ Setting the subscription (the record keeps its refresh token, so OpenCode renews the access token during a run; the renewed token is not saved, so re-run this after an `opencode auth login`):
113
76
 
114
77
  ```bash
115
- gh variable set CRYSK_ROUTING --body '{"mappings":[{"logical":"sonnet","backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-flash"},{"logical":"opus","backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-pro"},{"logical":"haiku","backend":"opencode","provider":"deepseek","gateway":"configured","modelSnapshot":"deepseek-v4-flash"}]}'
78
+ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH # on macOS, drop -w0
116
79
  ```
117
80
 
81
+ Ask the human before putting a personal ChatGPT session in a repository secret: anyone who can change the workflow on the default branch can use it.
82
+
118
83
  ## Workflow
119
84
 
120
- Generated `with:` must keep:
85
+ The scaffold's `with:` must keep the `crysk-secrets: |` block (the fixed Claude and OpenAI lines plus the five `CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[i] }}_API_KEY=…` slots) and:
121
86
 
122
87
  ```yaml
123
- routing: "${{ vars.CRYSK_ROUTING || vars.PRHERO_ROUTING }}"
124
- opencode-auth: ${{ secrets.OPENCODE_AUTH_JSON }}
88
+ models: ${{ vars.CRYSK_MODELS }}
89
+ credentials: ${{ vars.CRYSK_CREDENTIALS }}
125
90
  ```
126
91
 
127
- Quotes around the routing var are load-bearing (unset → empty string). Re-scaffold with `crysk setup --ci --force` if an old template lacks them.
92
+ Copy it from `assets/workflow.yml` or re-scaffold with `npx -y crysk ci init --force`; never write it from memory. An unused slot renders as `CRYSK_OPENCODE__API_KEY=` and is skipped.
128
93
 
129
- The Action installs OpenCode CLI **1.18.30** in its **own** step when `opencode-auth` is non-empty **or** routing contains `opencode`. Never `latest`. Claude-only (both OpenCode inputs empty / no `opencode` in routing) skips that install.
94
+ The Action installs OpenCode CLI **1.18.30** in its **own** step when the setup step built an OpenCode auth file **or** the models in effect name `opencode:`. Never `latest`. Claude-only skips that install.
130
95
 
131
96
  ## Fail-closed edges
132
97
 
133
98
  - Fork pushes still skip (no secrets); a maintainer's `/crysk review` comment reviews a fork.
134
- - OpenCode-only (only `OPENCODE_AUTH_JSON`) counts as a credential and reviews.
99
+ - OpenCode-only (only `CRYSK_OPENCODE_*` secrets) counts as a credential and reviews, as long as no step runs a `claude:` model.
135
100
  - No credential at all fails the run red, with the `gh secret set` commands in the step summary.
136
- - Claude credentials + OpenCode routing **without** `OPENCODE_AUTH_JSON` starts then **fails**.
137
- - Invalid routing/auth JSON fails loud.
101
+ - An OpenCode model whose provider has no secret starts, then **fails** for the missing record (unless the provider serves that model free).
102
+ - A `CRYSK_MODELS` or `CRYSK_CREDENTIALS` value the parser refuses fails the run (`CRYSK-CONFIG-INVALID`), naming the input, never its content.
138
103
 
139
104
  ## After setting DATA
140
105
 
141
- Open a **same-repo** PR (fork pushes skip). Confirm the review job materializes person-layer `$HOME/.crysk/config.json` and 0600 auth, and that spend notices show metered when the OpenCode file is present.
106
+ Open a **same-repo** PR (fork pushes skip). In the review job's log, the setup step prints one notice per OpenCode provider naming the secret it used, and the spend notices show metered when the OpenCode auth file is present.
@@ -83,7 +83,7 @@ a maintainer decides between `/crysk review` and `/crysk override`.
83
83
  **`/crysk override` is a maintainer's, and only for what answers cannot unlock.** Never post it,
84
84
  and never ask for it because the review budget ran out, except to answer a manual-review hold. Ask
85
85
  a maintainer for it only when:
86
- - the CI review itself is broken (every hunter failing, credit or credentials, `PRH-HUNTERS-FAILED`):
86
+ - the CI review itself is broken (every hunter failing, credit or credentials, `CRYSK-HUNTERS-FAILED`):
87
87
  stop the loop and report what is failing, never route around it;
88
88
  - a `deferred` or `misclassified` finding should merge unfixed: it names a real defect, so
89
89
  accepting it is the maintainer's call;
@@ -5,9 +5,6 @@
5
5
  // compile.assets is a silent no-op on Bun 1.3.14 — this manifest is the permanent mechanism.
6
6
 
7
7
  import consolidatePrompt from "../prompts/consolidate.md" with { type: "file" };
8
- import lifecyclePrompt from "../prompts/default/deep-review-lifecycle.md" with {
9
- type: "file",
10
- };
11
8
  import logicPrompt from "../prompts/default/deep-review-logic.md" with {
12
9
  type: "file",
13
10
  };
@@ -49,7 +46,6 @@ import triageSkill from "../skills/crysk-loop/SKILL.md" with { type: "file" };
49
46
  import prSkill from "../skills/crysk-pr/SKILL.md" with { type: "file" };
50
47
 
51
48
  export const BUNDLED_AGENT_FILES: Record<string, string> = {
52
- "deep-review-lifecycle.md": lifecyclePrompt,
53
49
  "deep-review-logic.md": logicPrompt,
54
50
  "deep-review-parity.md": parityPrompt,
55
51
  "deep-review-reliability.md": reliabilityPrompt,
package/src/assets.ts CHANGED
@@ -74,7 +74,7 @@ function resolveVersion(): string {
74
74
  // Ignore read errors
75
75
  }
76
76
 
77
- return "0.4.0";
77
+ return "0.5.0";
78
78
  }
79
79
 
80
80
  export function resolveEngineAssets(): EngineAssets {
@@ -97,6 +97,10 @@ const TERMINAL_BUDGET_STATUSES: ReadonlySet<AdmissionAttemptStatus> = new Set([
97
97
  // - `"gate-skipped"` also comes from recordCiConfigErrorSkip (pr/ci-admission-gate.ts),
98
98
  // called from the pre-reservation catch in pr/review-pr.ts when gotchas or the
99
99
  // prompt set is misconfigured. It runs before any reservation or provider call.
100
+ // - `"gate-skipped"` also comes from settleClaudeCredentialRefusal (pr/admission.ts),
101
+ // called from pr/plan.ts on a credential refusal (no listed Claude credential, or
102
+ // an OpenCode route with no auth record): after the budget gate and before any
103
+ // binding or provider call.
100
104
  // - `"yielded"`: written only by yieldToInFlightReview (pr/ci-admission-gate.ts:380),
101
105
  // whose sole caller is pr/review-pr.ts:359, again before the `"provider-started"`
102
106
  // settle at pr/review-pr.ts:516.