crysk 0.3.2 → 0.3.3
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.
- package/README.md +52 -32
- package/dist/SKILL-12as0f3q.md +74 -0
- package/dist/SKILL-2h445snn.md +140 -0
- package/dist/SKILL-6vy283pt.md +140 -0
- package/dist/SKILL-ebn0fqaq.md +140 -0
- package/dist/ci-admission-a6d0wk1c.md +128 -0
- package/dist/cli.js +11559 -11422
- package/dist/index.js +123 -40
- package/dist/review-refuter-btpgnkcd.md +77 -0
- package/package.json +1 -1
- package/prompts/default/PROVENANCE.md +1 -0
- package/prompts/default/review-refuter.md +6 -0
- package/skills/crysk/SKILL.md +3 -3
- package/skills/crysk-ci-setup/SKILL.md +3 -3
- package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
- package/src/assets.ts +1 -1
- package/src/ci/outcome.ts +4 -4
- package/src/commands/ci-setup.ts +21 -18
- package/src/commands/init.ts +21 -12
- package/src/doctor.ts +48 -29
- package/src/index.ts +1 -1
- package/src/menu-context.ts +1 -1
- package/src/pr/target.ts +16 -3
- package/src/review/boundary.ts +2 -1
- package/src/review/materiality-gate.ts +25 -1
- package/src/review/pipeline.ts +60 -15
- package/src/review/preflight.ts +132 -28
- package/src/review/prompt-set.ts +12 -8
- package/src/review/review.ts +14 -5
- package/src/review/run.ts +54 -18
- package/src/updater.ts +1 -1
- package/src/wizard.ts +35 -9
package/README.md
CHANGED
|
@@ -53,15 +53,15 @@ to install it (macOS with Homebrew) and to run `gh auth login`. It never blocks
|
|
|
53
53
|
advanced settings (score weights, observe-only, trusted actors, files limit, exclusions). Then it runs
|
|
54
54
|
`npx -y crysk setup --ci` with your answers (writes `.github/workflows/crysk.yml`, or updates an existing `pr-hero.yml` in place, and the
|
|
55
55
|
level's keys in `.crysk/config.json`, and prints a summary) and `npx -y crysk init`
|
|
56
|
-
(writes
|
|
56
|
+
(writes a `REVIEW.md` scaffold when the repo has no review instructions), writes the repository's review instructions, and stores
|
|
57
57
|
one secret with `gh secret set`: `CLAUDE_CODE_OAUTH_TOKEN` (subscription; `claude setup-token`
|
|
58
58
|
prints it on any machine that has the Claude Code CLI, so this one does not need it) or
|
|
59
59
|
`ANTHROPIC_API_KEY` (pay as you go). Without an agent, run the same
|
|
60
60
|
commands yourself and follow the [Quick path](docs/github-actions.md#quick-path).
|
|
61
61
|
|
|
62
|
-
3. **Merge the workflow
|
|
63
|
-
(`/crysk review`) reads
|
|
64
|
-
there, and
|
|
62
|
+
3. **Merge the workflow, `.crysk/` and `REVIEW.md` into the default branch.** A comment-triggered run
|
|
63
|
+
(`/crysk review`) reads them from the base branch, so it starts nothing until the workflow is
|
|
64
|
+
there, and reviews without your instructions until `REVIEW.md` (or `.crysk/gotchas.md`) is.
|
|
65
65
|
Then require the `crysk` status check in branch protection if you want it to block merges. The legacy `pr-hero` status is no longer posted, so a rule that requires it must move to `crysk`.
|
|
66
66
|
|
|
67
67
|
4. **Open pull requests as usual.** Every new PR gets a review posted as PR comments; later pushes
|
|
@@ -159,12 +159,13 @@ crysk doctor
|
|
|
159
159
|
# 4. Skills + MCP registration, and — inside a git repo — scaffold .crysk/.
|
|
160
160
|
cd /path/to/your-repo && crysk setup
|
|
161
161
|
|
|
162
|
-
# 5. Track that scaffold, or ignore
|
|
163
|
-
# tree, and an untracked .crysk/ is a dirty tree.
|
|
164
|
-
git add .crysk && git
|
|
162
|
+
# 5. Track that scaffold, or ignore .crysk/. Local review refuses to run on a
|
|
163
|
+
# dirty tree, and an untracked .crysk/ or REVIEW.md is a dirty tree.
|
|
164
|
+
git add .crysk && git add REVIEW.md # REVIEW.md only if setup wrote one
|
|
165
|
+
git commit -m "chore: crysk config"
|
|
165
166
|
|
|
166
|
-
# 6. Replace the placeholder
|
|
167
|
-
$EDITOR .crysk/gotchas.md
|
|
167
|
+
# 6. Replace the placeholder review instructions with real ones. Not paperwork — see below.
|
|
168
|
+
$EDITOR REVIEW.md # or the .crysk/gotchas.md the repo already had
|
|
168
169
|
|
|
169
170
|
# 7. Review the checked-out branch against its merge base.
|
|
170
171
|
crysk review
|
|
@@ -188,12 +189,13 @@ npx skills add cryskai/crysk # pick interactively
|
|
|
188
189
|
npx skills add cryskai/crysk --skill crysk # or crysk-pr, crysk-loop, crysk-ci-setup
|
|
189
190
|
```
|
|
190
191
|
|
|
191
|
-
**On step 6.** `
|
|
192
|
+
**On step 6.** `REVIEW.md` is injected verbatim into every hunter's system prompt, and
|
|
192
193
|
what `setup`/`init` write there is a placeholder: `- <subsystem>: <the thing that looks
|
|
193
194
|
like a bug but is deliberate, and why>`. A review that reads *that* is a review billed in
|
|
194
195
|
full by hunters who know nothing about your repo, and it comes back looking clean. So
|
|
195
196
|
Crysk refuses to run while the scaffold's `human-attention-required` marker line is
|
|
196
|
-
still present. Write a handful of true lines
|
|
197
|
+
still present. Write a handful of true lines and delete the marker — or delete the file
|
|
198
|
+
to review with the default guidance only.
|
|
197
199
|
|
|
198
200
|
Other entry points, once the above works:
|
|
199
201
|
|
|
@@ -215,11 +217,11 @@ Four things go wrong when an agent runs the sequence above:
|
|
|
215
217
|
1. **Step 2 is not optional, and not deferrable.** If each of your commands runs in its own
|
|
216
218
|
shell, an `export PATH=...` in one does not reach the next. Either prepend the export to
|
|
217
219
|
every Crysk invocation, or call the binary by absolute path: `~/.crysk/bin/crysk` (`~/.prhero/bin/pr-hero` on an install from before the rename).
|
|
218
|
-
2. **Step 5 is yours.** `crysk setup` scaffolds `.crysk/` and neither commits
|
|
219
|
-
ignores
|
|
220
|
-
itself created. Commit them or add `.crysk/` to `.gitignore` before reviewing.
|
|
221
|
-
3. **Write the
|
|
222
|
-
you the best
|
|
220
|
+
2. **Step 5 is yours.** `crysk setup` scaffolds `.crysk/` and `REVIEW.md` and neither commits
|
|
221
|
+
nor ignores them, so the next `crysk review` fails the clean-tree gate — on files `setup`
|
|
222
|
+
itself created. Commit them (or add `.crysk/` to `.gitignore`) before reviewing.
|
|
223
|
+
3. **Write the review instructions yourself (step 6).** You have the repository in context, which
|
|
224
|
+
makes you the best author available. Read the code and write the real ones: the
|
|
223
225
|
deliberate oddity that looks like a bug, the invariant enforced in a file the diff never
|
|
224
226
|
shows, the ownership rule a newcomer would violate. Leaving the placeholder is not a
|
|
225
227
|
softer option — the review is refused until you replace it and delete the
|
|
@@ -238,11 +240,13 @@ There are two config files, and the difference between them is *who they belong
|
|
|
238
240
|
| `~/.crysk/config.json` (or `~/.prhero/config.json` on an install from before the rename) | **yours**, across every repo on this machine | no — it is your machine |
|
|
239
241
|
| `<repo>/.crysk/config.json` | **the team's** | yes, normally — it is shared through git |
|
|
240
242
|
|
|
241
|
-
`crysk init` creates the repo file and
|
|
242
|
-
`
|
|
243
|
-
|
|
244
|
-
the
|
|
245
|
-
|
|
243
|
+
`crysk init` creates the repo file and, when the repo has no review instructions, a root
|
|
244
|
+
`REVIEW.md`; it never overwrites existing files, and a repo that already has
|
|
245
|
+
`.crysk/gotchas.md` keeps it and gets no `REVIEW.md` (one would shadow it). `crysk setup`
|
|
246
|
+
scaffolds the same files when it runs inside a git repo, so a repo you set up needs no separate
|
|
247
|
+
`init`. (Running `init` afterwards is harmless: it keeps what exists and reprints the git
|
|
248
|
+
reminder.) Commit `.crysk/` (or add it to `.gitignore`) and `REVIEW.md` — an untracked one trips
|
|
249
|
+
local mode's clean-tree gate.
|
|
246
250
|
|
|
247
251
|
**Old directory names.** The directories used to be `~/.prhero/` and `<repo>/.prhero/`, and the ignore file
|
|
248
252
|
`.prheroignore`. Those are still read, for one version, when the new name does not exist. Nothing is moved for
|
|
@@ -296,15 +300,31 @@ which is a different thing from a committed file asking on your behalf. `--agent
|
|
|
296
300
|
`agents_dir` (then the repo file, then the global, then `CRYSK_AGENTS_DIR`, or `PRHERO_AGENTS_DIR` on an install from before the rename); `--base` overrides
|
|
297
301
|
`default_base`; `--summary` / `--no-summary` and `--model` override the summary keys.
|
|
298
302
|
|
|
299
|
-
### `gotchas.md`
|
|
300
|
-
|
|
301
|
-
Repo-specific
|
|
302
|
-
|
|
303
|
-
`
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
303
|
+
### `REVIEW.md` and `gotchas.md`
|
|
304
|
+
|
|
305
|
+
Repo-specific facts the hunters must know (fragile invariants, deliberate oddities, past incidents),
|
|
306
|
+
in a root `REVIEW.md` — the file name Claude Code Review reads. Without one, Crysk reads
|
|
307
|
+
`.crysk/gotchas.md` (or the legacy `.prhero/gotchas.md`); when both exist, `REVIEW.md` wins and
|
|
308
|
+
the run and `crysk doctor` say `gotchas.md ignored: REVIEW.md takes precedence`. The hunters and
|
|
309
|
+
the refuter read the file as facts about the codebase (the refuter still needs code to refute a
|
|
310
|
+
claim). With `materiality_gate` on, the materiality judge also applies its "Not blocking here" rules
|
|
311
|
+
to blocking findings, but only for style, naming, test hygiene, generated code and dev scripts: it
|
|
312
|
+
never demotes a logic, correctness, data, contract or security finding, whatever the file says.
|
|
313
|
+
Nothing filters advisory findings by it.
|
|
314
|
+
|
|
315
|
+
**Optional, but a file that exists must be real** — not merely non-empty. With neither file the
|
|
316
|
+
review runs on the default guidance and `doctor` reports it as degraded. The file `init`/`setup`
|
|
317
|
+
scaffold carries a `human-attention-required` marker line, and `review` and `doctor` both refuse it
|
|
318
|
+
by name, as they refuse an empty file: a placeholder passes any emptiness check while telling every
|
|
319
|
+
hunter nothing, which buys a full-price review that reports clean. Replace the `<subsystem>` lines
|
|
320
|
+
with facts about your repo, then delete the marker line. Reviewing a tree you cannot write to?
|
|
321
|
+
Supply a file from outside with `--gotchas <file>` (and `--config <file>`); it overrides both.
|
|
322
|
+
|
|
323
|
+
**Where it is read from.** Local `crysk review` reads the working tree. `crysk review --pr` and the
|
|
324
|
+
watcher read the operator checkout (`--repo`), never the PR worktree. In GitHub Actions it is the
|
|
325
|
+
workflow's checkout: a `pull_request` run reads the PR merged onto its base, so a PR that edits the
|
|
326
|
+
file is reviewed with its own edit; a `/crysk review` comment run on the generated workflow reads the
|
|
327
|
+
default branch.
|
|
308
328
|
|
|
309
329
|
## Commands
|
|
310
330
|
|
|
@@ -315,7 +335,7 @@ the marker line. Reviewing a tree you cannot write to? Supply it from outside wi
|
|
|
315
335
|
| `crysk review --pr [n]` | Review a GitHub PR: by number, or — bare, no number — the PR that belongs to the current branch (errors loudly if it has none). Resolves the range through `gh`, runs in a detached worktree with its own codegraph index, then records the result in the run's `findings.json`. |
|
|
316
336
|
| `crysk review --pr <n> --post` | Same, then publish the report as **one** marked PR comment — re-runs update it in place, never stack. |
|
|
317
337
|
| `crysk doctor` | Run diagnostic environment and dependency checks (git, claude auth, gh, codegraph, config). Works inside or outside a repository. |
|
|
318
|
-
| `crysk setup` | Machine-level onboarding: skill synchronization and MCP registration — and, when run inside a git repo, it also scaffolds that repo's `.crysk/config.json` and
|
|
338
|
+
| `crysk setup` | Machine-level onboarding: skill synchronization and MCP registration — and, when run inside a git repo, it also scaffolds that repo's `.crysk/config.json` and, when the repo has no review instructions, a root `REVIEW.md`, so no separate `init` is needed there. Fully non-interactive. It does **not** commit or `.gitignore` what it scaffolds; do that yourself before reviewing. |
|
|
319
339
|
| `crysk activity [--kill <pid>]` | Inspect running reviews (with elapsed time, PID, repo/PR), watcher spend against daily cap, and completed run history. `--kill <pid>` safely terminates a running review. |
|
|
320
340
|
| `crysk post --pr <n> --from <run-dir>` | Replay-publish a previous run's findings onto the PR (same plan as `--pr --post`). `--dry-run` previews at $0. |
|
|
321
341
|
| `crysk triage reply --pr <n> --from <run-dir> --finding F00N --tag <tag> --body-file <path>` | Post one triage reply. The driver picks the parent from the posted `<!-- crysk-finding` marker (never path/line), renders the marker + badge, posts, and resolves the inline review thread. Reads `anchor.patch` (else `diff.patch`) from the run dir to remap post lines the same way `--post` does. `--body-file` is reasoning only. |
|
|
@@ -438,7 +458,7 @@ plain JSON you may tune directly:
|
|
|
438
458
|
|
|
439
459
|
| Key | Default | What it does |
|
|
440
460
|
| --- | --- | --- |
|
|
441
|
-
| `repos[].path` | — | Operator checkout of a repo to watch (its `.crysk/` config and
|
|
461
|
+
| `repos[].path` | — | Operator checkout of a repo to watch (its `.crysk/` config and review instructions are used, exactly like `review --pr`). Managed by `watch add`/`remove`. |
|
|
442
462
|
| `repos[].post` | `false` | Pass `--post` to the spawned review — publish each result as the PR's one marked comment. Managed by `watch add [--post]`. |
|
|
443
463
|
| `repos[].on_push` | `false` | Re-review the repo's PRs on every new push. Default: one review per PR — see below. Managed by `watch add [--on-push]`. |
|
|
444
464
|
| `daily_cap` | `5` | Global max reviews launched per local calendar day, across all repos. `0` pauses launching entirely. |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
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)."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: juanmaagd
|
|
7
|
+
version: "1.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Activation Contract
|
|
11
|
+
|
|
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).
|
|
14
|
+
- Tune effort, caps, the size gate, `.cryskignore`, `REVIEW.md` / `gotchas.md`, or any `config.json` key.
|
|
15
|
+
- Run a review (local branch or `--pr <n>`), understand its cost, or read its artifacts.
|
|
16
|
+
- Set up the watcher (`crysk watch`) or worktree GC (`crysk gc`).
|
|
17
|
+
- Diagnose a broken install or a refused run (`crysk doctor`, `crysk config`).
|
|
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`.
|
|
20
|
+
|
|
21
|
+
## Source of Truth
|
|
22
|
+
|
|
23
|
+
This skill holds the mental model and the traps, not the reference. Before acting, read the live state, and for detail follow the linked section — do not answer from memory:
|
|
24
|
+
- `crysk config` — every key, its effective value, and **which layer decided it**. Read-only, $0.
|
|
25
|
+
- `crysk --help` — the installed version's real commands and flags.
|
|
26
|
+
- The docs on GitHub (they are not shipped in the npm package): [README](https://github.com/cryskai/crysk/blob/main/README.md), [configuration.md](https://github.com/cryskai/crysk/blob/main/docs/configuration.md).
|
|
27
|
+
|
|
28
|
+
If Crysk is not on `PATH`, run every command as `npx -y crysk <command>` (Node is enough). An install from before the rename (the package used to be `pr-hero`) still answers to `pr-hero`; either command is the same program.
|
|
29
|
+
|
|
30
|
+
## Mental Model
|
|
31
|
+
|
|
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
|
+
- **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.
|
|
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.
|
|
38
|
+
|
|
39
|
+
## Hard Rules
|
|
40
|
+
|
|
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.
|
|
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.
|
|
46
|
+
- **You cannot authenticate `claude` for the user.** If `doctor` reports it missing or unauthenticated, say so and stop.
|
|
47
|
+
|
|
48
|
+
## Recipes
|
|
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).
|
|
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.
|
|
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.
|
|
59
|
+
|
|
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
|
+
|
|
62
|
+
**REVIEW.md / gotchas.md** — [REVIEW.md and gotchas.md](https://github.com/cryskai/crysk/blob/main/README.md#reviewmd-and-gotchasmd): optional; a root `REVIEW.md` wins over `.crysk/gotchas.md`. A file that exists must be real: read the code and write the actual traps, then delete the `human-attention-required` marker line, or `review` and `doctor` refuse it. With neither file the review runs on the default guidance.
|
|
63
|
+
|
|
64
|
+
**Running a review** — [Commands](https://github.com/cryskai/crysk/blob/main/README.md#commands): `.crysk/` must be committed or gitignored (clean-tree gate). Expect roughly $2–5 and ~10 minutes per typical PR; the printed band ignores billing mode. Artifacts land in `~/.crysk/repos/<origin>/runs/<run>/`. To check or wait on a PR's CI review state deterministically ($0, via `gh`), run `pr-hero status --pr <n> [--wait] [--json]`.
|
|
65
|
+
|
|
66
|
+
**Watcher / GC** — [crysk watch](https://github.com/cryskai/crysk/blob/main/README.md#watching-prs-automatically--crysk-watch): `watch add [--post]`, preview with `watch --once --dry-run`, and only then `watch install`. `daily_cap` and `window` live in `~/.crysk/watch.json`. GC is separate: `crysk gc install`.
|
|
67
|
+
|
|
68
|
+
## Output Contract
|
|
69
|
+
|
|
70
|
+
Report back to the user:
|
|
71
|
+
1. What changed: the file and layer, and the keys touched (never credential values).
|
|
72
|
+
2. The `crysk config` lines proving the new effective value and its layer.
|
|
73
|
+
3. `doctor` / `--dry-run` result, and whether the next real run is subscription, metered, or free.
|
|
74
|
+
4. Anything left for the human: authenticating `claude`, committing `.crysk/`, confirming spend.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
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."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: juanmaagd
|
|
7
|
+
version: "3.3"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Activation Contract
|
|
11
|
+
|
|
12
|
+
Load when the user asks to:
|
|
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).
|
|
15
|
+
- Tune CI spend / re-review / admission policy.
|
|
16
|
+
- Retrigger a skipped CI review (size, admission, or budget) without running the review locally.
|
|
17
|
+
- Reduce review noise: fewer comments (`post_min_severity`) or fewer blocking findings that are real but improbable (`materiality_gate`).
|
|
18
|
+
|
|
19
|
+
## Hard Rules
|
|
20
|
+
|
|
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.
|
|
23
|
+
- **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
|
+
- **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
|
+
- **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
|
|
26
|
+
- **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is no longer posted). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
|
|
27
|
+
- **Required permissions:** `contents: read`, `pull-requests: write`, `issues: write`, `statuses: write`, **`checks: write`**, **`actions: read`** (the admission gate lists past runs; a private repo 403s without it). Template in `assets/workflow.yml` includes all six.
|
|
28
|
+
- **Retrigger is a PR comment: `gh pr comment <n> --body "/crysk review"`.** GitHub Actions runs the review on the runner with `--force`. The comment must be exactly `/crysk review` (or `/crysk review --full`; `/pr-hero review` on a workflow scaffolded before the rename, see the `/crysk` vs `/pr-hero` bullet), and its author needs write access; the action refuses anyone else. Do not run `crysk review --force` locally when the review should happen in CI. `gh run rerun` on a skipped run re-evaluates the gates and does not force. In this repo a comment run checks out the PR head commit before `uses: ./`, so it runs the PR's own engine, not the default branch's.
|
|
29
|
+
- **`/crysk recheck` re-reviews the head and asks the CI adjudicator to rule on pending dismissals.** It is `/crysk review` plus `--adjudicate`, with the same permission check and reaction; refused on fork pull requests. See `docs/github-actions.md` ("Rechecking a dismissal").
|
|
30
|
+
- **`/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
|
+
- **`--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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **`.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).
|
|
42
|
+
|
|
43
|
+
## Decision Gates
|
|
44
|
+
|
|
45
|
+
| Condition | Action |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `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. |
|
|
57
|
+
| Existing workflow | `setup --ci` skips; ask before `--force` |
|
|
58
|
+
| First-time admission | Recommend `ci_admission_observe_only: true` — `references/ci-admission.md` |
|
|
59
|
+
| User wants max CI spend | Lower `ci_max_attempts` and/or raise `ci_rereview_min_score` |
|
|
60
|
+
| Custom bot posts findings | Add login to `ci_trusted_actors` |
|
|
61
|
+
| 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
|
+
| 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). |
|
|
64
|
+
| 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
|
+
| 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
|
+
| 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
|
+
| 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
|
+
| 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. |
|
|
72
|
+
| 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. |
|
|
75
|
+
| 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
|
+
|
|
77
|
+
## Review Settings Interview (ask the human, never choose for them)
|
|
78
|
+
|
|
79
|
+
Before step 4, ask the human these questions in their language. Use the native question UI when available (one grouped interaction is fine). Do not pick an answer for them, and do not skip a question because a default exists: the point is that they know these settings exist.
|
|
80
|
+
|
|
81
|
+
1. **Re-review level** (how Crysk reviews new pushes on an open PR):
|
|
82
|
+
- **Minimal**: one automatic review per PR; later pushes only on a `/crysk review` comment.
|
|
83
|
+
- **Balanced (recommended)**: re-review when the push touches risky files or the previous pass found enough (score >= 4); at most 2 automatic passes.
|
|
84
|
+
- **Thorough**: review every push, up to 4 automatic passes. Most coverage, most cost.
|
|
85
|
+
- **Manual**: nothing automatic after the first review; every re-review starts with `/crysk review`.
|
|
86
|
+
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
|
+
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).
|
|
90
|
+
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
|
+
5. **Advanced settings**: name them, then ask whether to review them now. Each keeps a working default if skipped:
|
|
92
|
+
- 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;
|
|
93
|
+
- observe only (`ci_admission_observe_only`): log what the rules would skip, but review every push; good for one PR cycle;
|
|
94
|
+
- trusted actors (`ci_trusted_actors`): extra GitHub logins whose Crysk markers count;
|
|
95
|
+
- changed-files limit (`max_changed_files`): a PR touching more files is skipped; unset = none on a subscription, 50 on an API key;
|
|
96
|
+
- exclusions: patterns in `.cryskignore` (gitignore syntax) the review never reads;
|
|
97
|
+
- 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.
|
|
99
|
+
|
|
100
|
+
**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
|
+
|
|
102
|
+
Then pass the answers to the scaffold as flags, never as hand-written YAML:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npx -y crysk setup --ci --level <minimal|balanced|thorough|manual> --ci-mode <gate|advisory> --billing <subscription|api> --max-changed-lines <n> [--budget-usd <n>]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
It writes the workflow, merges the level's keys into `.crysk/config.json` (keeping other keys), and prints a summary of every setting. **Never run it without these flags**: with none it applies balanced and gate, and its summary says nobody chose them. Write any advanced answers into `.crysk/config.json` (and `.cryskignore`) afterwards. The summary `setup --ci` printed predates those edits, so when there were any, show the human the effective settings from `npx -y crysk config` instead. Otherwise show the printed summary, including any `Changed` and `Kept existing` lines: on a re-run (for example `--force` to refresh an old workflow) only the groups a flag names are overwritten, and keys nobody chose stay as the file had them; the workflow keeps its old `mode` and `budget-usd` unless `--ci-mode` or `--billing` / `--budget-usd` is passed. In a terminal, every question defaults to the repository's current value. Details: `references/ci-admission.md`.
|
|
109
|
+
|
|
110
|
+
## Execution Steps
|
|
111
|
+
|
|
112
|
+
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`.
|
|
117
|
+
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.
|
|
120
|
+
9. **Deploy:** Offer commit. Open a **same-repo** test PR (forks skip).
|
|
121
|
+
|
|
122
|
+
## Output Contract
|
|
123
|
+
|
|
124
|
+
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.
|
|
129
|
+
- `npx -y crysk doctor` / `npx -y crysk config` outcome.
|
|
130
|
+
- 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
|
+
- 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).
|
|
132
|
+
- Next steps: merge the workflow to the default branch (the comment trigger needs it there), open a same-repo test PR, when to turn off observe-only. If CI skipped, the override is `gh pr comment <n> --body "/crysk review"`.
|
|
133
|
+
|
|
134
|
+
## References
|
|
135
|
+
|
|
136
|
+
- `assets/workflow.yml` — the one review workflow (`pull_request` + `issue_comment` for `/crysk review`).
|
|
137
|
+
- `assets/admission-config.example.json` — starter `.crysk/config.json`.
|
|
138
|
+
- `references/ci-admission.md` — admission keys, modes, rollout, ledger.
|
|
139
|
+
- `references/opencode-ci.md` — OpenCode secret/variable procedure, routing, pin, openai vs deepseek.
|
|
140
|
+
- `docs/github-actions.md` — full CI integration docs.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
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."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: juanmaagd
|
|
7
|
+
version: "3.3"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Activation Contract
|
|
11
|
+
|
|
12
|
+
Load when the user asks to:
|
|
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).
|
|
15
|
+
- Tune CI spend / re-review / admission policy.
|
|
16
|
+
- Retrigger a skipped CI review (size, admission, or budget) without running the review locally.
|
|
17
|
+
- Reduce review noise: fewer comments (`post_min_severity`) or fewer blocking findings that are real but improbable (`materiality_gate`).
|
|
18
|
+
|
|
19
|
+
## Hard Rules
|
|
20
|
+
|
|
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.
|
|
23
|
+
- **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
|
+
- **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
|
+
- **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
|
|
26
|
+
- **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is no longer posted). The scaffold writes `mode: gate` explicitly: blocking findings, a size or spend-ceiling skip, and a crash set it red. Every review rule that skips a push (low-risk delta, once per PR, `/crysk stop`, the attempt budget used up, `manual_only`) carries the last verdict; answered blocking findings turn a carried red green, marked unverified. `mode: advisory` keeps it green for a finished review. The job's exit code stays `0` on findings either way, so do not gate on the job.
|
|
27
|
+
- **Required permissions:** `contents: read`, `pull-requests: write`, `issues: write`, `statuses: write`, **`checks: write`**, **`actions: read`** (the admission gate lists past runs; a private repo 403s without it). Template in `assets/workflow.yml` includes all six.
|
|
28
|
+
- **Retrigger is a PR comment: `gh pr comment <n> --body "/crysk review"`.** GitHub Actions runs the review on the runner with `--force`. The comment must be exactly `/crysk review` (or `/crysk review --full`; `/pr-hero review` on a workflow scaffolded before the rename, see the `/crysk` vs `/pr-hero` bullet), and its author needs write access; the action refuses anyone else. Do not run `crysk review --force` locally when the review should happen in CI. `gh run rerun` on a skipped run re-evaluates the gates and does not force. In this repo a comment run checks out the PR head commit before `uses: ./`, so it runs the PR's own engine, not the default branch's.
|
|
29
|
+
- **`/crysk recheck` re-reviews the head and asks the CI adjudicator to rule on pending dismissals.** It is `/crysk review` plus `--adjudicate`, with the same permission check and reaction; refused on fork pull requests. See `docs/github-actions.md` ("Rechecking a dismissal").
|
|
30
|
+
- **`/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
|
+
- **`--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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **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
|
+
- **`.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).
|
|
42
|
+
|
|
43
|
+
## Decision Gates
|
|
44
|
+
|
|
45
|
+
| Condition | Action |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `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. |
|
|
57
|
+
| Existing workflow | `setup --ci` skips; ask before `--force` |
|
|
58
|
+
| First-time admission | Recommend `ci_admission_observe_only: true` — `references/ci-admission.md` |
|
|
59
|
+
| User wants max CI spend | Lower `ci_max_attempts` and/or raise `ci_rereview_min_score` |
|
|
60
|
+
| Custom bot posts findings | Add login to `ci_trusted_actors` |
|
|
61
|
+
| 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
|
+
| 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). |
|
|
64
|
+
| 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
|
+
| 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
|
+
| 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
|
+
| 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
|
+
| 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. |
|
|
72
|
+
| 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. |
|
|
75
|
+
| 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
|
+
|
|
77
|
+
## Review Settings Interview (ask the human, never choose for them)
|
|
78
|
+
|
|
79
|
+
Before step 4, ask the human these questions in their language. Use the native question UI when available (one grouped interaction is fine). Do not pick an answer for them, and do not skip a question because a default exists: the point is that they know these settings exist.
|
|
80
|
+
|
|
81
|
+
1. **Re-review level** (how Crysk reviews new pushes on an open PR):
|
|
82
|
+
- **Minimal**: one automatic review per PR; later pushes only on a `/crysk review` comment.
|
|
83
|
+
- **Balanced (recommended)**: re-review when the push touches risky files or the previous pass found enough (score >= 4); at most 2 automatic passes.
|
|
84
|
+
- **Thorough**: review every push, up to 4 automatic passes. Most coverage, most cost.
|
|
85
|
+
- **Manual**: nothing automatic after the first review; every re-review starts with `/crysk review`.
|
|
86
|
+
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
|
+
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).
|
|
90
|
+
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
|
+
5. **Advanced settings**: name them, then ask whether to review them now. Each keeps a working default if skipped:
|
|
92
|
+
- 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;
|
|
93
|
+
- observe only (`ci_admission_observe_only`): log what the rules would skip, but review every push; good for one PR cycle;
|
|
94
|
+
- trusted actors (`ci_trusted_actors`): extra GitHub logins whose Crysk markers count;
|
|
95
|
+
- changed-files limit (`max_changed_files`): a PR touching more files is skipped; unset = none on a subscription, 50 on an API key;
|
|
96
|
+
- exclusions: patterns in `.cryskignore` (gitignore syntax) the review never reads;
|
|
97
|
+
- 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.
|
|
99
|
+
|
|
100
|
+
**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
|
+
|
|
102
|
+
Then pass the answers to the scaffold as flags, never as hand-written YAML:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npx -y crysk setup --ci --level <minimal|balanced|thorough|manual> --ci-mode <gate|advisory> --billing <subscription|api> --max-changed-lines <n> [--budget-usd <n>]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
It writes the workflow, merges the level's keys into `.crysk/config.json` (keeping other keys), and prints a summary of every setting. **Never run it without these flags**: with none it applies balanced and gate, and its summary says nobody chose them. Write any advanced answers into `.crysk/config.json` (and `.cryskignore`) afterwards. The summary `setup --ci` printed predates those edits, so when there were any, show the human the effective settings from `npx -y crysk config` instead. Otherwise show the printed summary, including any `Changed` and `Kept existing` lines: on a re-run (for example `--force` to refresh an old workflow) only the groups a flag names are overwritten, and keys nobody chose stay as the file had them; the workflow keeps its old `mode` and `budget-usd` unless `--ci-mode` or `--billing` / `--budget-usd` is passed. In a terminal, every question defaults to the repository's current value. Details: `references/ci-admission.md`.
|
|
109
|
+
|
|
110
|
+
## Execution Steps
|
|
111
|
+
|
|
112
|
+
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 "What counts as blocking here" and "Do not report" sections are applied only by the materiality judge (`materiality_gate: true`, blocking findings only), so fill them only when the human asked for that gate, and delete them 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`.
|
|
117
|
+
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.
|
|
120
|
+
9. **Deploy:** Offer commit. Open a **same-repo** test PR (forks skip).
|
|
121
|
+
|
|
122
|
+
## Output Contract
|
|
123
|
+
|
|
124
|
+
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.
|
|
129
|
+
- `npx -y crysk doctor` / `npx -y crysk config` outcome.
|
|
130
|
+
- 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
|
+
- 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).
|
|
132
|
+
- Next steps: merge the workflow to the default branch (the comment trigger needs it there), open a same-repo test PR, when to turn off observe-only. If CI skipped, the override is `gh pr comment <n> --body "/crysk review"`.
|
|
133
|
+
|
|
134
|
+
## References
|
|
135
|
+
|
|
136
|
+
- `assets/workflow.yml` — the one review workflow (`pull_request` + `issue_comment` for `/crysk review`).
|
|
137
|
+
- `assets/admission-config.example.json` — starter `.crysk/config.json`.
|
|
138
|
+
- `references/ci-admission.md` — admission keys, modes, rollout, ledger.
|
|
139
|
+
- `references/opencode-ci.md` — OpenCode secret/variable procedure, routing, pin, openai vs deepseek.
|
|
140
|
+
- `docs/github-actions.md` — full CI integration docs.
|