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
@@ -0,0 +1,106 @@
1
+ # OpenCode in CI — operator procedure
2
+
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
+
5
+ Do **not** print, `cat`, or log credential values. Inspect **keys and `type` only**.
6
+
7
+ ## What goes where
8
+
9
+ | GitHub box | Name | Holds |
10
+ |---|---|---|
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. |
17
+
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`).
19
+
20
+ Unset `CRYSK_MODELS` = Claude-only CI.
21
+
22
+ ## Fastest path: `crysk ci init`
23
+
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.
25
+
26
+ ## Models per role
27
+
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):
29
+
30
+ | Role | Steps |
31
+ |---|---|
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` |
37
+
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
41
+
42
+ ```bash
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
46
+ ```
47
+
48
+ Every step runs on DeepSeek. Without a Claude secret, keep `materiality_gate` off: the judge runs only on Claude.
49
+
50
+ ### OpenCode hunters, Claude refuter and summarizer, Claude fallback
51
+
52
+ ```bash
53
+ gh variable set CRYSK_MODELS --body '{"default": ["opencode:deepseek/deepseek-v4-flash", "claude:sonnet-latest"], "refuter": ["claude:opus-latest"], "summary": ["claude:haiku-latest"]}'
54
+ ```
55
+
56
+ Keep `CRYSK_CLAUDE_OAUTH_TOKEN` (or `CRYSK_CLAUDE_API_KEY`) beside the DeepSeek secret. The OpenCode auth file still applies the metered ceiling.
57
+
58
+ ### Two OpenCode providers
59
+
60
+ ```bash
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"]'
63
+ ```
64
+
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`.
66
+
67
+ ## OpenAI
68
+
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`. |
74
+
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`):
76
+
77
+ ```bash
78
+ jq -c .openai ~/.local/share/opencode/auth.json | base64 -w0 | gh secret set CRYSK_OPENCODE_OPENAI_OAUTH # on macOS, drop -w0
79
+ ```
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
+
83
+ ## Workflow
84
+
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:
86
+
87
+ ```yaml
88
+ models: ${{ vars.CRYSK_MODELS }}
89
+ credentials: ${{ vars.CRYSK_CREDENTIALS }}
90
+ ```
91
+
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.
93
+
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.
95
+
96
+ ## Fail-closed edges
97
+
98
+ - Fork pushes still skip (no secrets); a maintainer's `/crysk review` comment reviews a fork.
99
+ - OpenCode-only (only `CRYSK_OPENCODE_*` secrets) counts as a credential and reviews, as long as no step runs a `claude:` model.
100
+ - No credential at all fails the run red, with the `gh secret set` commands in the step summary.
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.
103
+
104
+ ## After setting DATA
105
+
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.
@@ -0,0 +1,160 @@
1
+ # Generated by `crysk setup --ci` (or `crysk ci init`).
2
+ # Customize freely — re-running setup will not overwrite this file again
3
+ # unless you pass --force.
4
+ #
5
+ # This one file is the whole install. It reviews every push to a pull
6
+ # request. A pull request comment that is exactly `/crysk review` runs the
7
+ # review again with the skip gates bypassed, and `/crysk review --full`
8
+ # also re-discovers the whole range. A comment that is exactly
9
+ # `/crysk override` turns the gate green on that head with no review and
10
+ # no cost, and records who did it. A comment that is exactly
11
+ # `/crysk recheck` reviews the head and asks the CI adjudicator to rule on
12
+ # pending dismissals of blocking findings. The action parses the comment and
13
+ # refuses a commenter without write access. The older `/pr-hero ...` forms
14
+ # of these commands still work for one version.
15
+ name: Crysk Review
16
+
17
+ on:
18
+ pull_request:
19
+ types: [opened, synchronize, reopened]
20
+ # GitHub runs a comment-triggered workflow from the DEFAULT branch's copy
21
+ # of this file, never the pull request's. The comment trigger works only
22
+ # once this file is merged there; until then a comment starts nothing.
23
+ issue_comment:
24
+ types: [created]
25
+
26
+ # pull-requests: write lets Crysk post inline comments and a step summary.
27
+ # contents: read is enough for actions/checkout. issues: write lets it
28
+ # resolve/reply on review threads (GitHub models PR conversations as issues).
29
+ # checks: write persists the durable CI admission attempt ledger (WU-02).
30
+ # actions: read lets the admission gate list this workflow's past runs; a
31
+ # public repo serves that without the scope, a private one returns HTTP 403.
32
+ permissions:
33
+ actions: read
34
+ contents: read
35
+ pull-requests: write
36
+ issues: write
37
+ statuses: write
38
+ checks: write
39
+
40
+ jobs:
41
+ review:
42
+ # This `if` routes events; it never checks credentials. The secrets
43
+ # context is unreadable in a job-level `if`, so the action detects a
44
+ # missing credential itself and fails the run with the commands that
45
+ # fix it, instead of a skipped job that reads as a clean review.
46
+ #
47
+ # Fork pull_request runs are skipped: GitHub gives them no secrets, so
48
+ # they could never authenticate. A maintainer comments `/crysk review`
49
+ # instead, and that run (base-branch context, with secrets) reviews the
50
+ # fork's head.
51
+ #
52
+ # A comment starts the job only when it BEGINS with `/crysk review`,
53
+ # `/crysk recheck` or `/crysk override` (or the older `/pr-hero` forms
54
+ # of the three). The action then requires an exact match after
55
+ # trimming, so a near-miss such as "/crysk review please" starts a job the
56
+ # action ends without reviewing or overriding.
57
+ if: >-
58
+ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
59
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk review')) ||
60
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk recheck')) ||
61
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk override')) ||
62
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero review')) ||
63
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero recheck')) ||
64
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero override'))
65
+ # Job-level and keyed on the pull request number. A workflow-level group
66
+ # on `github.head_ref || github.ref` put every comment on every pull
67
+ # request into ONE group, because head_ref is empty on issue_comment, so
68
+ # any comment anywhere could cancel any in-flight review.
69
+ #
70
+ # Only a new push cancels. The group filter is a prefix, so a near-miss
71
+ # comment can claim the pull request's group too; cancelling there would
72
+ # kill a paid in-flight review before the action ignored the comment. A
73
+ # comment run queues instead. A push never waits: it cancels whatever is
74
+ # running, a forced comment run included, because the head it reviewed
75
+ # is gone (comment again on the new head).
76
+ #
77
+ # GitHub keeps one PENDING run per group, and a newer run replaces it. So
78
+ # a comment enters the pull request's group only when it starts with
79
+ # /crysk review, /crysk recheck or /crysk override (or the older /pr-hero forms), and GitHub associates its author
80
+ # with the repository as OWNER, MEMBER or COLLABORATOR; every other comment
81
+ # gets its own group. Without that, anyone who can comment could replace a
82
+ # maintainer's queued review with a run the action then refuses. The job
83
+ # `if:` above does NOT check the association: a writer GitHub reports
84
+ # under another one (a private org member shown as CONTRIBUTOR) still
85
+ # runs, because the action checks the real permission, just in its own
86
+ # group. KNOWN GAP: an associated author's later comment (a writer's
87
+ # near-miss or second real command, or a read-only member's or
88
+ # collaborator's refused one) still replaces a comment run waiting
89
+ # behind a running review, and `--full` followed by a plain
90
+ # `/crysk review` loses the `--full`; comment again to recover. A
91
+ # writer reported under another association runs unserialized, beside
92
+ # any review already running.
93
+ #
94
+ # A fork's push never enters the pull request's group: its job is skipped
95
+ # above, and if a skipped job still claimed the group, the fork author's
96
+ # push would cancel a maintainer's in-flight review of that fork. Every
97
+ # other event gets a unique per-run group for the same reason, so a
98
+ # skipped job can never cancel or replace a review.
99
+ concurrency:
100
+ group: ${{ ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (startsWith(github.event.comment.body, '/crysk review') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/crysk recheck') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/crysk override') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero review') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero recheck') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero override') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association))) && format('pr-hero-review-{0}', github.event.pull_request.number || github.event.issue.number) || format('pr-hero-noop-{0}', github.run_id) }}
101
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
102
+ runs-on: ubuntu-latest
103
+ # Backstop for a HUNG runner, not a second review budget. Crysk already
104
+ # enforces its own 75-minute whole-pipeline ceiling, which closes
105
+ # artifacts and reports before exiting; a CI bound at or below that would
106
+ # kill the job first and throw away the salvage. Above it, this only ever
107
+ # fires when the process is genuinely stuck.
108
+ timeout-minutes: 90
109
+ steps:
110
+ - name: Checkout
111
+ uses: actions/checkout@v4
112
+ with:
113
+ # fetch-depth: 0 is load-bearing, not cosmetic: Crysk computes
114
+ # the pull request's diff range and commit ancestry from full git
115
+ # history. actions/checkout's default is a SHALLOW clone, which
116
+ # cannot produce an accurate diff or blame — trimming this line
117
+ # does not fail loudly, it makes reviews silently miss context.
118
+ fetch-depth: 0
119
+
120
+ - name: Run Crysk
121
+ # The id keeps this step's outputs (`status`, `run-dir`, ...)
122
+ # readable from any step you add below.
123
+ # The action uploads the run directory as an artifact itself, so
124
+ # `crysk triage reply --from` has an input in CI (see action.yml).
125
+ id: pr-hero
126
+ uses: cryskai/crysk@v0
127
+ with:
128
+ github-token: ${{ secrets.GITHUB_TOKEN }}
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 }}
160
+ mode: gate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crysk",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -16,4 +16,5 @@
16
16
  - **Modifications (2026-10-02):** Changed the `model:` frontmatter of all five hunter prompts (`deep-review-lifecycle.md`, `deep-review-logic.md`, `deep-review-parity.md`, `deep-review-reliability.md`, `deep-review-resilience.md`) from `sonnet` to `opus` (an alias the Claude CLI resolves, so no version is pinned). The prompt bodies are untouched; the `model:` line is the only byte that moved in each file. Reason (#299): the CLI alias `sonnet` now resolves to claude-sonnet-5-5, which hunts far too shallowly on the same harness: 4 hunters x 2 replicates on a real diff took 1-5 turns each and 0 of 8 runs returned any finding, while the `opus` alias (claude-opus-5-5) took 3-10 turns and 6 of 8 runs returned findings. Guarded by `test/review/preflight-bundled-prompts.test.ts` ("every bundled hunter prompt declares opus", pinned against `localReviewSpec`'s hunter list). `bun run fixture-eval` passed on this change on 2026-10-02 (hit `src/volume.ts:4`, 1 finding, $0.13 notional), but it runs the fixture's own `haiku` prompts, not these, so it proves the engine path and not the `opus` frontmatter. The model evidence is the 8-replicate harness above. Those findings were not refuter-checked, and they are a single-diff sample. `bun run refuter-probe` is not affected (the refuter was already `opus`).
17
17
  - **Modifications (2026-10-02, effort):** Frontmatter only, in all six bundled agent prompts; the prompt bodies are untouched. The five hunter prompts (`deep-review-lifecycle.md`, `deep-review-logic.md`, `deep-review-parity.md`, `deep-review-reliability.md`, `deep-review-resilience.md`) go from `model: opus` (the entry above, which is kept as history) back to `model: sonnet` and gain `effort: xhigh`. `review-refuter.md` keeps `model: opus` and gains `effort: high`. Root cause (#299): pr-hero never passed `--effort`, so every step ran at the Claude CLI's implicit default, which is `high` except on Sonnet 5.5 and Opus 5.5, where it is `medium` (https://code.claude.com/docs/en/model-config). When the `sonnet` alias moved to claude-sonnet-5-5 the hunters silently dropped a level and stopped exploring, which the earlier `opus` change papered over rather than explained. The engine now owns the level (`src/model/catalog.ts`, `defaultEffortForRole`) and always passes it. Measured on musive pr-1858 (a 280-line PR), Sonnet 5.5, 4 hunters x 2 replicates, varying only the effort: `medium` 0/8 runs with findings (0.5 min per review, 0 of 4 known bugs); `high` 6/8 (1.5 min, 3 of 4); `xhigh` 8/8 (4.5 min, 4 of 4); `max` 7/8 (19 min, 4 of 4). `xhigh` is the cheapest level that found everything, so the hunters pin it. The refuter is `high`, not `medium`: `bun run refuter-probe` passed 16/16 at `medium`, but on the real pr-1858 `xhigh` findings the Opus refuter at `medium` returned `refuted` on the pre-labeled known `updateProject` BLOCKER in 3 of 4 verdicts, which deletes it, while at `high` it was `downgraded-latent` (kept, as advisory) in 3 of 4 and refuted in 1 of 4; the other 5 findings got the same verdicts at both levels, and the original Sonnet-5-at-high refuter corroborated that finding. The cost of `high` is a refuter leg of about 140s instead of about 90s. Guarded by `test/review/preflight-bundled-prompts.test.ts` (hunters declare sonnet + xhigh, the refuter declares opus + high, pinned against `localReviewSpec`'s hunter list). `bun run fixture-eval` result: pending (orchestrator).
18
18
  - **Modifications (2026-11-03, review instructions):** Body change in `review-refuter.md` only: a `## Repository facts` section with a `{{GOTCHAS}}` anchor, rendered by the pipeline with the repository's `REVIEW.md` (or gotchas) text and the run's nonce, as the hunters already get it. The section tells the refuter to use the facts to aim its counterexample hunt, that a fact is never disproof on its own, and that instructions about verdicts or about what not to report do not change its verdict. Owner posting policy goes to the materiality judge instead (user prompt only; `prompts/materiality.md` is unchanged). Passed `bun run refuter-probe` the same day on 7a301cf: 3 replicates x 4 arms, 12/12 verdicts matched (true-claim corroborated 3/3, false-claim refuted 3/3, hard-false-claim refuted 3/3, latent-claim downgraded-latent 3/3), every `refuter.system.md` carrying the fixture's gotchas block; refuter model `opus`, subscription auth ($0 cash; notional not recorded). Recall control, same session: `scripts/refuter-replay.ts` over the 76 Martian cases of the 2026-10-26 replay, dev body vs this body with each corpus's gotchas, Opus high, 1 replicate: same verdict on 74/76, every keep case still corroborated, the 2 changes both toward keeping (grafana-94942 F001, discourse-7 F003); $56.28 notional, $0 cash. Lab ledger: `bench/METRICS.md` 2026-11-03.
19
+ - **Modifications (2026-11-08, lifecycle retired):** Removed `deep-review-lifecycle.md` from the bundled set and its hunter from the default spec. Measured before the decision: on ReviewBench (6 PRs x 2 replicates) dropping it cut cost 39% and wall time 38% for about 2 valid findings lost per run, none high severity; on the Martian 50 judgments it was the only hunter behind 0 of 52 High+Critical true positives and 1 of 111 true positives. Counterevidence: on musive pr-1858 it was the only hunter to find the known BLOCKER K1, in 1 of 2 control runs (0 of 2 without it). The other prompts are unchanged. Lab ledger: `bench/METRICS.md`, 2026-11-06 to 2026-11-08.
19
20
  - **Verification:** The freeze was verified via `bun run refuter-probe` and `bun run fixture-eval`. The stripped revision passed `bun run refuter-probe` on 2026-08-24 (3 replicates x 4 arms, 12/12 verdicts matched: `corroborated`, `refuted` on both false-claim arms, `downgraded-latent`; refuter model `sonnet`, refuter cost $0.8222). `bun run fixture-eval` has not been re-run for the stripped revision.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: crysk
3
- description: "Trigger: use or configure Crysk locally — change the review model or backend (routing, OpenCode, DeepSeek, custom model), effort, credentials, config.json keys, REVIEW.md / gotchas.md, .cryskignore, size gate, run a review, `crysk watch/gc`, `crysk doctor/config`. Not CI (crysk-ci-setup) and not answering findings (crysk-loop)."
3
+ description: "Trigger: use or configure Crysk locally — change the review model or backend per role (models, fallback models, OpenCode, DeepSeek, custom model), effort, credentials order, config.json keys, REVIEW.md / gotchas.md, .cryskignore, size gate, run a review, `crysk watch/gc`, `crysk doctor/config`. Not CI (crysk-ci-setup) and not answering findings (crysk-loop)."
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: juanmaagd
@@ -10,13 +10,13 @@ metadata:
10
10
  ## Activation Contract
11
11
 
12
12
  Load when the user wants to **operate or configure Crysk on their machine or repo**:
13
- - Change which model or backend reviews run on (a custom model, OpenCode, DeepSeek, a pinned snapshot).
13
+ - Change which model or backend a step runs on (per role, with fallbacks: OpenCode, DeepSeek, a pinned Claude version).
14
14
  - Tune effort, caps, the size gate, `.cryskignore`, `REVIEW.md` / `gotchas.md`, or any `config.json` key.
15
15
  - Run a review (local branch or `--pr <n>`), understand its cost, or read its artifacts.
16
16
  - Set up the watcher (`crysk watch`) or worktree GC (`crysk gc`).
17
17
  - Diagnose a broken install or a refused run (`crysk doctor`, `crysk config`).
18
18
 
19
- Route away: GitHub Actions, CI secrets, `CRYSK_ROUTING`, `/crysk review` comments → load `crysk-ci-setup`. Replying to posted `<!-- crysk-finding` comments → load `crysk-loop`.
19
+ Route away: GitHub Actions, `CRYSK_*` secrets, `CRYSK_MODELS`, `/crysk review` comments → load `crysk-ci-setup`. Replying to posted `<!-- crysk-finding` comments → load `crysk-loop`.
20
20
 
21
21
  ## Source of Truth
22
22
 
@@ -31,31 +31,31 @@ If Crysk is not on `PATH`, run every command as `npx -y crysk <command>` (Node i
31
31
 
32
32
  - **Two config files, owned by different people.** `~/.crysk/config.json` is the person's (never committed; `~/.prhero/config.json` on an install from before the rename — never create `~/.crysk` by hand while `~/.prhero` is in use, the CLI would switch homes); `<repo>/.crysk/config.json` is the team's (committed). `~/.crysk/watch.json` holds the watcher.
33
33
  - **The one rule:** the repo file beats the global one, **except on capped keys** (`max_*`, and the on/off switches `summary.enabled`, `scout`, `materiality_gate`, `post`): there the team can only ask for *less*, so a committed file never enlarges a person's bill.
34
- - **Some keys live in exactly one layer** and the parser refuses the other by name: `routing` is person-only; `default_base`, `parity_trigger_paths`, `suspicion_priors` are repo-only. `--config <file>` replaces the repo layer only.
34
+ - **Some keys live in exactly one layer** and the parser refuses the other by name: `models` and `credentials` are person-only; `default_base`, `parity_trigger_paths`, `suspicion_priors` are repo-only. `--config <file>` replaces the repo layer only.
35
35
  - **Flags always win**, and may exceed a cap (`--base`, `--agents`, `--model`, `--summary`/`--no-summary`, `--force`).
36
- - **Models are logical names.** Bundled hunters declare `sonnet`, the refuter `opus`, the summarizer `haiku`, the post-refuter consolidation pass `sonnet` (always on, one claims-only call per review that merges duplicate findings and splits asides; its outcome is `consolidation` in `pipeline.json`). `routing` maps those names to a backend + provider; an unmapped name falls through to the Claude CLI.
37
- - **Crysk never stores a credential.** It reads the Claude CLI's auth, ambient Anthropic keys, or OpenCode's `auth.json`, and projects an ephemeral copy into each step.
36
+ - **Models are assigned per role.** `models` maps a role (`default`, `hunter.<key>` per hunter, `refuter`, which also covers the re-review verifier and the CI adjudicator, `consolidate`, `scout`, `summary`, `judge`) to a list of one to three models tried in order; a role not listed uses `default`. With no `models`, each step runs its prompt's model: hunters, consolidation and scout `claude:sonnet-latest`, the refuter `claude:opus-latest`, the summarizer `claude:haiku-latest`. A model name carries its backend: `claude:<sonnet|opus|haiku|fable>-latest` (newest version), `claude:claude-…` (pinned), `opencode:<provider>/<model>`. The old `routing` key is gone and refused with the `models` form to write; `summary.model` is gone too (`"haiku"`, which `crysk init` used to write, still reads with a warning).
37
+ - **Crysk never stores a credential.** It reads the Claude CLI's login, `CRYSK_CLAUDE_*` (or `ANTHROPIC_API_KEY` / `CLAUDE_CODE_OAUTH_TOKEN`) variables, or OpenCode's `auth.json`, and projects an ephemeral copy into each step. A run uses one Claude credential, the first set in `credentials.claude` (default `["subscription", "api_key"]`).
38
38
 
39
39
  ## Hard Rules
40
40
 
41
41
  - **Never print, `cat`, commit, or log credentials** — Keychain records, API keys, or `auth.json` contents. Inspect `auth.json` provider **keys and `type` only**.
42
- - **Read before writing, verify after:** run `crysk config` before a change and again after it; finish with `crysk doctor`, and `crysk review --dry-run` when the change touches models or routing.
43
- - **Prefer the CLI to hand edits:** scalar keys go through `crysk config set|unset <key> <val> [--person|--team|--watch]` (or `crysk config --edit`). `routing` is an object, so it is the one key written by hand into `~/.crysk/config.json` — keep the file valid JSON and preserve every other key.
42
+ - **Read before writing, verify after:** run `crysk config` before a change and again after it; finish with `crysk doctor`, and `crysk review --dry-run` when the change touches models or credentials.
43
+ - **Prefer the CLI to hand edits:** scalar keys go through `crysk config set|unset <key> <val> [--person|--team|--watch]` (or `crysk config --edit`). `models` and `credentials` are objects, so they are written by hand into `~/.crysk/config.json` — keep the file valid JSON and preserve every other key.
44
44
  - **Never spend without consent:** a real `crysk review`, `crysk watch install` (starts automatic spending) or `--force` past the size gate runs only after the user confirms. `--dry-run` variants are free.
45
- - **Never invent a model id.** The bundled catalog only knows Anthropic aliases; any other provider's model must be spelled exactly as that provider names it, and a typo fails at the provider, not at Crysk.
45
+ - **Never invent a model id.** The bundled catalog only knows the Claude aliases; an OpenCode model must be spelled exactly as `opencode models <provider>` lists it, and a typo fails at the provider, not at Crysk.
46
46
  - **You cannot authenticate `claude` for the user.** If `doctor` reports it missing or unauthenticated, say so and stop.
47
47
 
48
48
  ## Recipes
49
49
 
50
- **Custom model / backend** — [Routing](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#routing)
51
- 1. Ask: which logical names to move (`sonnet` hunters, `opus` refuter, `haiku` summarizer, or a `default` for all), which backend (`claude-code`, `opencode`, …), which provider and exact model id, and whether metered spend is acceptable.
52
- 2. Write `routing.mappings` (or `routing.default`) in `~/.crysk/config.json` (or `~/.prhero/config.json` if that is the home in use). An alias (`sonnet`/`opus`/`haiku`) routed anywhere except `claude-code` over `gateway: "direct"` **requires** `modelSnapshot` — see [modelFamily / modelSnapshot](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#modelfamily--modelsnapshot).
53
- 3. Traps: two mappings matching the same name is an error, not first-wins; all OpenCode mappings in one run must use **one** provider; `disabled: true` / `allowSpend: false` refuse loudly instead of falling back.
54
- 4. Verify: `crysk config`, `crysk doctor`, then a **local** `crysk review --dry-run` (PR-mode dry-run returns before route admission, so it can look clean on a route that will be refused).
50
+ **Models per role** — [Models](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#models), [Fallback models](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#fallback-models)
51
+ 1. Ask: which roles to move (`default` for all, or `hunter.<key>`, `refuter`, `summary`, …), which model for each and which fallbacks, and whether metered spend is acceptable.
52
+ 2. Write `models` in `~/.crysk/config.json` (or `~/.prhero/config.json` if that is the home in use), e.g. `{"models": {"default": ["opencode:deepseek/deepseek-v4-flash", "claude:sonnet-latest"], "refuter": ["claude:opus-latest"]}}`. Write `claude:sonnet-latest`, never a bare `claude:sonnet` (refused); a full `claude-*` id pins a version.
53
+ 3. Traps: at most 3 models per role and none twice; a role not listed uses `default`, except the materiality judge, which runs only `claude:sonnet-latest` or `claude:opus-latest` and never inherits `default`; the next model is tried only on a provider failure (rate limit, quota, network, timeout, model unavailable; a refused login skips the models on the same credential), never on a bad answer; each fallback can bill and take the step's full time again. Several OpenCode providers may be mixed in one review. A local `auth.json` `openai` record must be `type: "oauth"` (the subscription); an `openai` API key there is refused.
54
+ 4. Verify: `crysk config`, `crysk doctor`, then a **local** `crysk review --dry-run` (PR-mode dry-run returns before route admission, so it can look clean on a plan that will be refused).
55
55
 
56
- **Effort** — [Effort](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#effort): set by the `effort:` frontmatter of a prompt in a custom `agents_dir` (`low|medium|high|xhigh|max`), never by a flag or env var. Defaults: hunters `xhigh`, refuter `high`. It applies to `claude-code` only; OpenCode records it as not applied.
56
+ **Effort** — [Effort](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#effort): per model, as a `models` entry `{"model": "claude:opus-latest", "effort": "max"}`; otherwise the `effort:` frontmatter of a prompt in a custom `agents_dir`, then the role default (hunters `xhigh`, refuter `high`). Claude levels are `low|medium|high|xhigh|max` (`ultracode` is refused). On OpenCode the effort is the model's variant, as OpenCode names it; the review refuses, before spending, a variant `opencode models <provider> --verbose` does not list. The `#variant` suffix is gone. `models.judge` and `--model` take no effort.
57
57
 
58
- **Credentials / billing** — [Credentials](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#credentials): on macOS a `claude-code` route runs on the Keychain subscription and strips ambient `ANTHROPIC_API_KEY`; elsewhere an ambient key makes it metered. For OpenCode, only an `openai` entry of `type: "oauth"` is a subscription; every other provider is a metered API token unless its catalog prices the model at $0.
58
+ **Credentials / billing** — [Credentials](https://github.com/cryskai/crysk/blob/main/docs/configuration.md#credentials): one Claude credential per run, the first set in `credentials.claude` (default `["subscription", "api_key"]`; on macOS a Claude login always counts as the subscription). To bill an API key with a login present, write `{"credentials": {"claude": ["api_key", "subscription"]}}`. The Claude child sees only the chosen one. For OpenCode on this machine, only an `openai` entry of `type: "oauth"` is a subscription; every other provider is a metered API token unless its catalog prices the model at $0.
59
59
 
60
60
  **Caps, size gate, exclusions** — [config.json keys](https://github.com/cryskai/crysk/blob/main/README.md#configjson-keys), [size gate](https://github.com/cryskai/crysk/blob/main/README.md#the-size-gate--a-cost-gate-not-a-quality-gate), [.cryskignore](https://github.com/cryskai/crysk/blob/main/README.md#cryskignore--repo-defined-exclusions): `max_changed_lines`/`max_changed_files` skip oversized diffs (a cost gate, not a quality one); `max_concurrent_steps` keeps the fan-out under a provider's rate limit; `max_verification_steps` (default `8`, `0` pauses) caps how many prior open findings a re-review spawns verifier steps for. `post_min_severity` (`suggestion` | `warning` | `blocking`, unset posts everything; `setup --ci` writes `warning`) is the lowest finding a PR review posts: hidden findings get no comment and the summary counts them, the gate is unchanged (a blocking finding always posts), and re-review admission scores only what was posted. Only the repo-root `.cryskignore` is read, and matching is case-sensitive.
61
61