crysk 0.0.0 → 0.3.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.
- package/LICENSE +176 -0
- package/README.md +611 -3
- package/bin/pr-hero.js +166 -0
- package/config/models/anthropic.json +5 -0
- package/dist/SKILL-7e3725zn.md +496 -0
- package/dist/SKILL-7q35wcaz.md +66 -0
- package/dist/SKILL-9at22381.md +74 -0
- package/dist/SKILL-ex2hxxh3.md +134 -0
- package/dist/SKILL-y8rv8msh.md +134 -0
- package/dist/SKILL-ygka1bs0.md +515 -0
- package/dist/adjudicator-dtg2axnh.md +86 -0
- package/dist/admission-config.example-a9vqmmad.json +9 -0
- package/dist/ci-admission-camfbx2b.md +122 -0
- package/dist/ci-admission-qk9r9taq.md +124 -0
- package/dist/cli.js +42501 -0
- package/dist/consolidate-ac0mnfyj.md +24 -0
- package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
- package/dist/deep-review-logic-a6b1gczf.md +156 -0
- package/dist/deep-review-parity-0ec904db.md +120 -0
- package/dist/deep-review-reliability-qyakbjb9.md +125 -0
- package/dist/deep-review-resilience-3tz8y26e.md +118 -0
- package/dist/index.js +20190 -0
- package/dist/opencode-ci-7b0be64p.md +141 -0
- package/dist/review-refuter-j4e9gezy.md +71 -0
- package/dist/scout-yvp153q7.md +140 -0
- package/dist/summarizer-zca44nxa.md +18 -0
- package/dist/workflow-w1g9szna.yml +151 -0
- package/package.json +81 -4
- package/prompts/consolidate.md +24 -0
- package/prompts/default/PROVENANCE.md +18 -0
- package/prompts/default/deep-review-lifecycle.md +362 -0
- package/prompts/default/deep-review-logic.md +156 -0
- package/prompts/default/deep-review-parity.md +120 -0
- package/prompts/default/deep-review-reliability.md +125 -0
- package/prompts/default/deep-review-resilience.md +118 -0
- package/prompts/default/review-refuter.md +71 -0
- package/prompts/scout.md +140 -0
- package/prompts/summarizer.md +18 -0
- package/skills/crysk/SKILL.md +74 -0
- package/skills/crysk-ci-setup/SKILL.md +134 -0
- package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
- package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
- package/skills/crysk-ci-setup/references/ci-admission.md +124 -0
- package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
- package/skills/crysk-loop/SKILL.md +515 -0
- package/skills/crysk-loop/adjudicator.md +86 -0
- package/skills/crysk-pr/SKILL.md +66 -0
- package/src/agent-env.ts +1084 -0
- package/src/asset-manifest.ts +83 -0
- package/src/assets.d.ts +6 -0
- package/src/assets.ts +183 -0
- package/src/brand-paths.ts +155 -0
- package/src/brand.ts +255 -0
- package/src/ci/admission-ledger.ts +350 -0
- package/src/ci/classify-error.ts +73 -0
- package/src/ci/cli-record.ts +271 -0
- package/src/ci/force-comment.ts +39 -0
- package/src/ci/gates.ts +945 -0
- package/src/ci/outcome.ts +2181 -0
- package/src/ci/override.ts +187 -0
- package/src/ci/publish.ts +1639 -0
- package/src/ci/reporter.ts +626 -0
- package/src/ci/review-admission.ts +910 -0
- package/src/ci/review-levels.ts +310 -0
- package/src/ci/review-policy.ts +18 -0
- package/src/ci/review-risk.ts +184 -0
- package/src/ci/setup.ts +844 -0
- package/src/ci/trigger.ts +1353 -0
- package/src/cli.ts +348 -0
- package/src/commands/activity.ts +67 -0
- package/src/commands/ci-setup-questions.ts +397 -0
- package/src/commands/ci-setup.ts +381 -0
- package/src/commands/config.ts +99 -0
- package/src/commands/doctor.ts +108 -0
- package/src/commands/init.ts +139 -0
- package/src/commands/mcp.ts +10 -0
- package/src/commands/menu.ts +129 -0
- package/src/commands/post.ts +302 -0
- package/src/commands/skills.ts +83 -0
- package/src/commands/status.ts +173 -0
- package/src/commands/triage.ts +342 -0
- package/src/commands/uninstall.ts +37 -0
- package/src/commands/upgrade.ts +214 -0
- package/src/commands/usage.ts +98 -0
- package/src/compare/compare.ts +28 -0
- package/src/compare/floor-test.ts +471 -0
- package/src/compare/martian-adapter.ts +80 -0
- package/src/config/config.ts +267 -0
- package/src/corpus/corpus.ts +1094 -0
- package/src/corpus/preflight.ts +1789 -0
- package/src/diversity/accounting.ts +90 -0
- package/src/diversity/adjudication.ts +145 -0
- package/src/diversity/admission.ts +60 -0
- package/src/diversity/benchmark.ts +195 -0
- package/src/diversity/clustering.ts +285 -0
- package/src/diversity/errors.ts +7 -0
- package/src/diversity/identity.ts +285 -0
- package/src/diversity/index.ts +11 -0
- package/src/diversity/pipeline-integration.ts +448 -0
- package/src/diversity/projection.ts +57 -0
- package/src/diversity/self-contained.ts +68 -0
- package/src/diversity/target-validation.ts +179 -0
- package/src/doctor-migration.ts +209 -0
- package/src/doctor.ts +723 -0
- package/src/errors.ts +83 -0
- package/src/execution/admission.ts +75 -0
- package/src/execution/atomic-write.ts +35 -0
- package/src/execution/attempt-evidence.ts +415 -0
- package/src/execution/bucket-id.ts +136 -0
- package/src/execution/concurrency-limiter.ts +175 -0
- package/src/execution/contracts.ts +443 -0
- package/src/execution/failure-classification.ts +42 -0
- package/src/execution/failure-policy.ts +240 -0
- package/src/execution/harness.ts +2548 -0
- package/src/execution/settlement.ts +348 -0
- package/src/execution/spawned-process.ts +66 -0
- package/src/execution/spend-limiter.ts +424 -0
- package/src/execution/step-artifacts.ts +55 -0
- package/src/execution/usage-normalized.ts +469 -0
- package/src/git/git.ts +396 -0
- package/src/git/identity.ts +64 -0
- package/src/git/refs.ts +140 -0
- package/src/home-preflight.ts +443 -0
- package/src/home.ts +243 -0
- package/src/ignore-file.ts +336 -0
- package/src/ignore-read.ts +118 -0
- package/src/index.ts +34 -0
- package/src/legacy-launchd.ts +29 -0
- package/src/mcp/mcp.ts +150 -0
- package/src/mcp/preflight.ts +407 -0
- package/src/menu-context.ts +192 -0
- package/src/model/catalog.ts +251 -0
- package/src/model/exec-snapshots.ts +390 -0
- package/src/model/free-discovery.ts +302 -0
- package/src/model/provider-capabilities.ts +814 -0
- package/src/model/routing.ts +600 -0
- package/src/pr/admission.ts +984 -0
- package/src/pr/answered-findings.ts +169 -0
- package/src/pr/ci-admission-gate.ts +743 -0
- package/src/pr/ci-publish.ts +76 -0
- package/src/pr/discovery.ts +432 -0
- package/src/pr/inline.ts +507 -0
- package/src/pr/plan.ts +366 -0
- package/src/pr/posting.ts +115 -0
- package/src/pr/pr-status.ts +845 -0
- package/src/pr/pr.ts +3642 -0
- package/src/pr/preflight.ts +1031 -0
- package/src/pr/publish-outcome.ts +361 -0
- package/src/pr/range.ts +119 -0
- package/src/pr/reverts-preflight.ts +606 -0
- package/src/pr/reverts.ts +377 -0
- package/src/pr/review-pr.ts +927 -0
- package/src/pr/status.ts +154 -0
- package/src/pr/target.ts +388 -0
- package/src/pr/teardown.ts +437 -0
- package/src/pr/worktree-setup.ts +60 -0
- package/src/production-runtime.ts +1877 -0
- package/src/progress.ts +487 -0
- package/src/rereview/adjudicate.ts +89 -0
- package/src/rereview/classify.ts +362 -0
- package/src/rereview/identity.ts +211 -0
- package/src/rereview/plan.ts +308 -0
- package/src/rereview/prepare.ts +1025 -0
- package/src/rereview/state.ts +767 -0
- package/src/rereview/verify.ts +241 -0
- package/src/review/boundary.ts +105 -0
- package/src/review/consolidate.ts +246 -0
- package/src/review/dedupe.ts +368 -0
- package/src/review/drafts.ts +448 -0
- package/src/review/findings-conformance.ts +120 -0
- package/src/review/findings.ts +714 -0
- package/src/review/pipeline.ts +3977 -0
- package/src/review/preflight.ts +3575 -0
- package/src/review/prompt-set.ts +177 -0
- package/src/review/proof-refs.ts +187 -0
- package/src/review/report.ts +1821 -0
- package/src/review/review.ts +490 -0
- package/src/review/root-cause.ts +120 -0
- package/src/review/route-preflight.ts +289 -0
- package/src/review/run.ts +601 -0
- package/src/review/scout.ts +323 -0
- package/src/review/size-gate.ts +595 -0
- package/src/review/spec.ts +235 -0
- package/src/review/step-runner.ts +233 -0
- package/src/runner-authority.ts +596 -0
- package/src/security/binding-policy.ts +115 -0
- package/src/security/credential-broker.ts +773 -0
- package/src/security/evidence-redaction.ts +62 -0
- package/src/security/execution-authority.ts +27 -0
- package/src/security/redact.ts +71 -0
- package/src/security/workspace-read-broker.ts +466 -0
- package/src/server/client.ts +190 -0
- package/src/server/preflight.ts +217 -0
- package/src/server/server.ts +327 -0
- package/src/signal-handler.ts +50 -0
- package/src/store/activity.ts +413 -0
- package/src/store/backfill-preflight.ts +49 -0
- package/src/store/backfill.ts +141 -0
- package/src/store/gc-preflight.ts +206 -0
- package/src/store/gc.ts +424 -0
- package/src/store/metrics-preflight.ts +229 -0
- package/src/store/metrics.ts +236 -0
- package/src/store/preflight.ts +748 -0
- package/src/store/store.ts +693 -0
- package/src/system-tools.ts +355 -0
- package/src/transport-registry.ts +1124 -0
- package/src/transports/claude-code-cli.ts +1348 -0
- package/src/transports/opencode-admission.ts +515 -0
- package/src/transports/opencode-client.ts +3328 -0
- package/src/transports/opencode-evidence.ts +557 -0
- package/src/transports/opencode-mcp.ts +248 -0
- package/src/transports/opencode-sdk.ts +2294 -0
- package/src/transports/opencode-server.ts +535 -0
- package/src/triage/adjudication.ts +113 -0
- package/src/triage/reply.ts +125 -0
- package/src/triage/triage.ts +255 -0
- package/src/ui/activity.ts +173 -0
- package/src/ui/config-edit.ts +816 -0
- package/src/ui/config.ts +462 -0
- package/src/ui/menu.ts +1325 -0
- package/src/ui/plan.ts +1039 -0
- package/src/ui/primitives.ts +300 -0
- package/src/ui/progress.ts +298 -0
- package/src/ui/result.ts +552 -0
- package/src/ui/review-menu.ts +312 -0
- package/src/ui/select.ts +528 -0
- package/src/ui/tree.ts +178 -0
- package/src/uninstaller.ts +479 -0
- package/src/updater.ts +836 -0
- package/src/usage.ts +77 -0
- package/src/watch/preflight.ts +1389 -0
- package/src/watch/watch.ts +1235 -0
- package/src/wizard.ts +877 -0
|
@@ -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, 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`, `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`, `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. Only the repo-root `.cryskignore` is read, and matching is case-sensitive.
|
|
61
|
+
|
|
62
|
+
**gotchas.md** — [gotchas.md](https://github.com/cryskai/crysk/blob/main/README.md#gotchasmd): required and 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.
|
|
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,134 @@
|
|
|
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. Scaffolds the one workflow, secrets, routing, and admission config."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: juanmaagd
|
|
7
|
+
version: "3.2"
|
|
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
|
+
|
|
18
|
+
## Hard Rules
|
|
19
|
+
|
|
20
|
+
- **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**.
|
|
21
|
+
- **No per-provider GitHub secrets:** Do not create `OPENAI_API_KEY` or `DEEPSEEK_API_KEY`. One secret `OPENCODE_AUTH_JSON` (whole store or a CI-only subset) + public variable `CRYSK_ROUTING`. Cap 48 KB each.
|
|
22
|
+
- **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).
|
|
23
|
+
- **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.
|
|
24
|
+
- **`fetch-depth: 0` is mandatory** on `actions/checkout@v4`.
|
|
25
|
+
- **Gate mode:** the `crysk` commit status is the required check (the legacy `pr-hero` status is still posted for one version). 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.
|
|
26
|
+
- **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.
|
|
27
|
+
- **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.
|
|
28
|
+
- **`/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").
|
|
29
|
+
- **`/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").
|
|
30
|
+
- **`--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.
|
|
31
|
+
- **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.
|
|
32
|
+
- **`/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).
|
|
33
|
+
- **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.
|
|
34
|
+
- **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.
|
|
35
|
+
- **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.
|
|
36
|
+
- **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`.
|
|
37
|
+
- **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`).
|
|
38
|
+
- **`.cryskignore` is read from the base ref, not the PR branch, in CI.**
|
|
39
|
+
- **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.
|
|
40
|
+
- **OpenCode procedure:** when OpenCode or mixed backends are in scope, follow `references/opencode-ci.md` before setting GitHub DATA (strip personal OAuth, `modelSnapshot`, logical vs role).
|
|
41
|
+
|
|
42
|
+
## Decision Gates
|
|
43
|
+
|
|
44
|
+
| Condition | Action |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `gh auth status` succeeds | Offer `gh secret set` / `gh variable set` |
|
|
47
|
+
| `gh` missing/unauthenticated | Link to repo Settings → Secrets and variables → Actions (Variables tab for routing) |
|
|
48
|
+
| Credential: Claude | **`CLAUDE_CODE_OAUTH_TOKEN`** — subscription (`claude setup-token` only, NOT keychain). **`ANTHROPIC_API_KEY`** — pay-as-you-go. |
|
|
49
|
+
| 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. |
|
|
50
|
+
| openai API key in CI | **Refuse.** openai → ChatGPT OAuth mapping; `type:"api"` is refused. Use a non-openai API token (tested: deepseek). |
|
|
51
|
+
| 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`). |
|
|
52
|
+
| Mixed OpenCode providers in one run | Out of scope (#195). One OpenCode provider per run. Mixed `claude-code` + one OpenCode provider is legal. |
|
|
53
|
+
| OpenCode CLI pin | Action installs **1.18.30** iff `opencode-auth != ''` OR routing contains `opencode`. Never `latest`. |
|
|
54
|
+
| 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`). |
|
|
55
|
+
| 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. |
|
|
56
|
+
| Existing workflow | `setup --ci` skips; ask before `--force` |
|
|
57
|
+
| First-time admission | Recommend `ci_admission_observe_only: true` — `references/ci-admission.md` |
|
|
58
|
+
| User wants max CI spend | Lower `ci_max_attempts` and/or raise `ci_rereview_min_score` |
|
|
59
|
+
| Custom bot posts findings | Add login to `ci_trusted_actors` |
|
|
60
|
+
| 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>`. |
|
|
61
|
+
| 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). |
|
|
62
|
+
| 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. |
|
|
63
|
+
| 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. |
|
|
64
|
+
| 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`. |
|
|
65
|
+
| 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. |
|
|
66
|
+
| `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`). |
|
|
67
|
+
| `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. |
|
|
68
|
+
| 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. |
|
|
69
|
+
| Gate error: `PRH-GOTCHAS-MISSING` ("`.crysk/gotchas.md` is missing or still the scaffold") | Run `npx -y crysk init`, write real gotchas, delete the `human-attention-required` marker line, commit `.crysk/` to the default branch, then comment `/crysk review`. |
|
|
70
|
+
| 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. |
|
|
71
|
+
| 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`). |
|
|
72
|
+
|
|
73
|
+
## Review Settings Interview (ask the human, never choose for them)
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
1. **Re-review level** (how Crysk reviews new pushes on an open PR):
|
|
78
|
+
- **Minimal**: one automatic review per PR; later pushes only on a `/crysk review` comment.
|
|
79
|
+
- **Balanced (recommended)**: re-review when the push touches risky files or the previous pass found enough (score >= 4); at most 2 automatic passes.
|
|
80
|
+
- **Thorough**: review every push, up to 4 automatic passes. Most coverage, most cost.
|
|
81
|
+
- **Manual**: nothing automatic after the first review; every re-review starts with `/crysk review`.
|
|
82
|
+
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.
|
|
83
|
+
3. **How CI pays**:
|
|
84
|
+
- **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).
|
|
85
|
+
- **API key** (`ANTHROPIC_API_KEY` or an OpenCode provider): ask for the spend ceiling per review in USD (default 10, `0` = none).
|
|
86
|
+
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.
|
|
87
|
+
5. **Advanced settings**: name them, then ask whether to review them now. Each keeps a working default if skipped:
|
|
88
|
+
- 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;
|
|
89
|
+
- observe only (`ci_admission_observe_only`): log what the rules would skip, but review every push; good for one PR cycle;
|
|
90
|
+
- trusted actors (`ci_trusted_actors`): extra GitHub logins whose Crysk markers count;
|
|
91
|
+
- changed-files limit (`max_changed_files`): a PR touching more files is skipped; unset = none on a subscription, 50 on an API key;
|
|
92
|
+
- exclusions: patterns in `.cryskignore` (gitignore syntax) the review never reads.
|
|
93
|
+
|
|
94
|
+
**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`.
|
|
95
|
+
|
|
96
|
+
Then pass the answers to the scaffold as flags, never as hand-written YAML:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npx -y crysk setup --ci --level <minimal|balanced|thorough|manual> --ci-mode <gate|advisory> --billing <subscription|api> --max-changed-lines <n> [--budget-usd <n>]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
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`.
|
|
103
|
+
|
|
104
|
+
## Execution Steps
|
|
105
|
+
|
|
106
|
+
1. **Inspect repo:** `git rev-parse --is-inside-work-tree`, `git remote get-url origin`, `gh auth status`.
|
|
107
|
+
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`).
|
|
108
|
+
3. **Claude secret (if used):** `gh secret set CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY` (secure input, never print).
|
|
109
|
+
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).
|
|
110
|
+
5. **Gotchas (required before the first review):** if `.crysk/` is missing on the default branch, run `npx -y crysk init` in the clone. The agent writes the gotchas 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. Each line is injected verbatim into every hunter's prompt. Delete the `human-attention-required` marker line (Crysk refuses to review while it is there), then commit `.crysk/` to the default branch. Without it the run fails `PRH-GOTCHAS-MISSING`.
|
|
111
|
+
6. **Require the check:** in branch protection, require the `crysk` status check (the gate), not the `review` job. The legacy `pr-hero` status is still posted for one version, so a repository that already requires it keeps working; move the rule 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"]`.
|
|
112
|
+
7. **Advanced settings:** write the answers from interview question 5 into `.crysk/config.json` (and `.cryskignore`); commit both to the default branch. **No `routing` key.** `npx -y crysk config` to verify.
|
|
113
|
+
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.
|
|
114
|
+
9. **Deploy:** Offer commit. Open a **same-repo** test PR (forks skip).
|
|
115
|
+
|
|
116
|
+
## Output Contract
|
|
117
|
+
|
|
118
|
+
Report:
|
|
119
|
+
- Secret status (set or manual link). Names only: which of `CLAUDE_CODE_OAUTH_TOKEN` / `ANTHROPIC_API_KEY` / `OPENCODE_AUTH_JSON` exist. Never values.
|
|
120
|
+
- 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`.
|
|
121
|
+
- 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.
|
|
122
|
+
- The review settings summary `setup --ci` printed (level, gate, budget, advanced settings), and which ones the human chose. Confirm repo `.crysk/config.json` has no `routing` key.
|
|
123
|
+
- `npx -y crysk doctor` / `npx -y crysk config` outcome.
|
|
124
|
+
- Whether `.crysk/` exists on the default branch with real gotchas (no `human-attention-required` marker line).
|
|
125
|
+
- 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).
|
|
126
|
+
- 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"`.
|
|
127
|
+
|
|
128
|
+
## References
|
|
129
|
+
|
|
130
|
+
- `assets/workflow.yml` — the one review workflow (`pull_request` + `issue_comment` for `/crysk review`).
|
|
131
|
+
- `assets/admission-config.example.json` — starter `.crysk/config.json`.
|
|
132
|
+
- `references/ci-admission.md` — admission keys, modes, rollout, ledger.
|
|
133
|
+
- `references/opencode-ci.md` — OpenCode secret/variable procedure, routing, pin, openai vs deepseek.
|
|
134
|
+
- `docs/github-actions.md` — full CI integration docs.
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
# Provide a Claude credential and/or OpenCode auth (never leave every
|
|
130
|
+
# credential blank). Inputs are wired unconditionally: an unset secret
|
|
131
|
+
# or var expands to empty, which the action treats as absent, so
|
|
132
|
+
# leaving the one you do not use in place costs nothing. Deleting the
|
|
133
|
+
# line for the secret you DID set is what breaks — the credential
|
|
134
|
+
# never reaches the action, and it fails to authenticate silently.
|
|
135
|
+
# ANTHROPIC_API_KEY — pay-as-you-go key (billed per token via Anthropic Console), or
|
|
136
|
+
# CLAUDE_CODE_OAUTH_TOKEN — from `claude setup-token`: a long-lived
|
|
137
|
+
# (~1 year) token that draws on your Claude subscription at no
|
|
138
|
+
# extra API cost. It must come from that command. The session
|
|
139
|
+
# token `/login` leaves in the keychain expires in HOURS and is
|
|
140
|
+
# kept alive by a refresh token CI does not have, so pasting that
|
|
141
|
+
# one here yields a secret that works for a day and then breaks
|
|
142
|
+
# reviews with no signal.
|
|
143
|
+
# OPENCODE_AUTH_JSON — whole OpenCode auth.json store
|
|
144
|
+
# vars.CRYSK_ROUTING — person-layer routing JSON; quoted so an
|
|
145
|
+
# unset var is the empty string rather than broken YAML. The
|
|
146
|
+
# older vars.PRHERO_ROUTING is read when this one is unset.
|
|
147
|
+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
148
|
+
claude-token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
149
|
+
routing: "${{ vars.CRYSK_ROUTING || vars.PRHERO_ROUTING }}"
|
|
150
|
+
opencode-auth: ${{ secrets.OPENCODE_AUTH_JSON }}
|
|
151
|
+
mode: gate
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# CI review admission — setup reference
|
|
2
|
+
|
|
3
|
+
Read this when configuring `.crysk/config.json` during CI setup. Full operator docs:
|
|
4
|
+
`docs/github-actions.md` (section **CI review admission**).
|
|
5
|
+
|
|
6
|
+
## Where config lives
|
|
7
|
+
|
|
8
|
+
- **Repository** `.crysk/config.json` on the default branch — authoritative.
|
|
9
|
+
- NOT in the PR branch worktree. Authors cannot change admission to suppress their own PR.
|
|
10
|
+
- Verify with `crysk config` after editing.
|
|
11
|
+
|
|
12
|
+
## Keys and defaults
|
|
13
|
+
|
|
14
|
+
| Key | Default | Meaning |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `ci_review_policy` | `risk_aware` | When to spend on `synchronize` pushes |
|
|
17
|
+
| `ci_max_attempts` | `2` | Automatic attempt budget per PR |
|
|
18
|
+
| `ci_rereview_min_score` | `4` | Prior score floor for re-review |
|
|
19
|
+
| `ci_blocking_weight` | `2` | Score weight per blocking-tier finding |
|
|
20
|
+
| `ci_advisory_weight` | `1` | Score weight per advisory-tier finding |
|
|
21
|
+
| `ci_trusted_actors` | `[]` | Extra GitHub logins for authoritative markers (+ `GITHUB_ACTOR`) |
|
|
22
|
+
| `ci_admission_observe_only` | `false` | Log would-be skip/manual decisions but always run |
|
|
23
|
+
| `max_verification_steps` | `8` | Max prior open findings verified per re-review (`0` pauses verification; capped key) |
|
|
24
|
+
|
|
25
|
+
`ci_max_reviews` is legacy — use `ci_max_attempts` (same fallback).
|
|
26
|
+
|
|
27
|
+
**Score:** `blocking × ci_blocking_weight + advisory × ci_advisory_weight`
|
|
28
|
+
|
|
29
|
+
**How a re-review depends on the previous pass:**
|
|
30
|
+
- **Whether it runs (admission):** in `risk_aware` and `thresholded` modes, the previous review's finding score (`blocking × 2 + advisory × 1` by default) is compared against `ci_rereview_min_score`, bounded by `ci_max_attempts` total automatic passes per PR.
|
|
31
|
+
- **What it does when it runs:** discovery is incremental by default (hunters examine only commits since the last completed review's head SHA; `/crysk review --full` widens to the full PR), and up to `max_verification_steps` verifier steps check whether prior open findings were fixed by the new push.
|
|
32
|
+
|
|
33
|
+
## Review levels (what setup --ci asks)
|
|
34
|
+
|
|
35
|
+
`setup --ci` (and `ci init`) asks for a level and always writes its keys. An agent asks the human and passes `--level`, `--ci-mode`, `--billing`, `--max-changed-lines` and `--budget-usd`; a terminal user gets the same questions from the CLI; with neither, `balanced` and `gate` apply and the summary says nobody chose them.
|
|
36
|
+
|
|
37
|
+
| Level | `ci_review_policy` | `ci_max_attempts` | `ci_rereview_min_score` | `max_verification_steps` |
|
|
38
|
+
|---|---|---|---|---|
|
|
39
|
+
| `minimal` | `once_per_pr` | 1 | (unset) | 8 |
|
|
40
|
+
| `balanced` (default) | `risk_aware` | 2 | 4 | 8 |
|
|
41
|
+
| `thorough` | `every_push` | 4 | (unset) | 8 |
|
|
42
|
+
| `manual` | `manual_only` | 1 | (unset) | 8 |
|
|
43
|
+
|
|
44
|
+
Billing: `--billing subscription` writes no `budget-usd` (a subscription spends quota, not dollars, and CI applies no ceiling while the repo has neither `ANTHROPIC_API_KEY` nor `OPENCODE_AUTH_JSON`, either of which makes the route metered; an explicit 0 would warn on every run and outlive a later API key); `--billing api` writes `--budget-usd` or the $10 default. `--budget-usd` alone implies `api`, and `--budget-usd` with `subscription` is refused.
|
|
45
|
+
|
|
46
|
+
Re-runs: a group (the level's keys, or `max_changed_lines`) is overwritten only when someone chose it this run (a flag or a terminal answer); otherwise it fills the file only if absent, and setup prints `Changed` and `Kept existing` lines. A `--force` refresh keeps the old workflow's `mode` and `budget-usd` unless a flag names them, and in a terminal every question defaults to the current value (a tuned level that matches no preset gets a "Keep current settings" option).
|
|
47
|
+
|
|
48
|
+
Size threshold: `max_changed_lines` is always written (default 4000, `--max-changed-lines`, `0` = no limit). Unlike the budget it applies on any billing: left unset, a subscription route reviews a PR of any size.
|
|
49
|
+
|
|
50
|
+
## Policy modes
|
|
51
|
+
|
|
52
|
+
| Mode | Use when |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `risk_aware` | Default — re-review on risky delta OR score ≥ floor |
|
|
55
|
+
| `thresholded` | Score-only; ignore path risk classification |
|
|
56
|
+
| `once_per_pr` | One automatic review; later pushes reported as not reviewed |
|
|
57
|
+
| `every_push` | Review every push (still capped by `ci_max_attempts`) |
|
|
58
|
+
| `manual_only` | No automatic re-review; operator override only |
|
|
59
|
+
|
|
60
|
+
## Outcomes users see
|
|
61
|
+
|
|
62
|
+
| Outcome | Meaning |
|
|
63
|
+
|---|---|
|
|
64
|
+
| Review runs | Normal pipeline |
|
|
65
|
+
| **Skipped** | Push did not justify spend (same head, low score, docs-only delta, etc.) — **not** “clean” |
|
|
66
|
+
| **Automatic reviews done** | Budget exhausted or `manual_only` — the gate keeps the last verdict, answered findings turn a red green (marked unverified), and `/crysk review` runs another round |
|
|
67
|
+
|
|
68
|
+
Skipped and automatic-reviews-done posts include admission metadata in the step summary. The automatic-reviews-done
|
|
69
|
+
comment explains the end of the budget by the repository's rules (policy, attempts used, last reviewed head) and how to
|
|
70
|
+
ask for more rounds.
|
|
71
|
+
|
|
72
|
+
## Durable ledger
|
|
73
|
+
|
|
74
|
+
- Check Runs named `crysk/ci-admission` on the reviewed commit (`pr-hero/ci-admission` on a commit first reviewed by an older release; both are read).
|
|
75
|
+
- Requires workflow permission **`checks: write`** (template includes it).
|
|
76
|
+
- Requires **`actions: read`** too: the gate lists this workflow's past runs, which a private repo refuses without it (HTTP 403).
|
|
77
|
+
- PR comments are presentation. The ledger counts a run that reached the provider (completed, failed, or still provider-started) and an admission skip. It does not count a run that yielded to an in-flight review, a size or budget gate skip, or a cancelled row (#164). A workflow run that concluded success or failure is dropped from the attempt count only when every ledger row on its head is a gate skip or a yield, because both are written before any provider spend. A cancelled row is not that proof: the signal handler that writes it can run after the provider started, so a run killed by `timeout-minutes` (concluded `failure`) still counts. A run whose row is still `reserved` stays counted too, because the provider-started write is best-effort and the run may have spent anyway.
|
|
78
|
+
|
|
79
|
+
## Rollout (recommended)
|
|
80
|
+
|
|
81
|
+
1. Ship workflow + secrets first.
|
|
82
|
+
2. Add `.crysk/config.json` with `"ci_admission_observe_only": true`.
|
|
83
|
+
3. Open a test PR; read `::notice::` lines for would-be skip/manual decisions.
|
|
84
|
+
4. Set `ci_admission_observe_only` to `false` when behavior matches intent.
|
|
85
|
+
|
|
86
|
+
## Example config
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"ci_review_policy": "risk_aware",
|
|
91
|
+
"ci_max_attempts": 2,
|
|
92
|
+
"ci_rereview_min_score": 4,
|
|
93
|
+
"ci_blocking_weight": 2,
|
|
94
|
+
"ci_advisory_weight": 1,
|
|
95
|
+
"ci_trusted_actors": [],
|
|
96
|
+
"ci_admission_observe_only": true
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Manual override
|
|
101
|
+
|
|
102
|
+
Comment `/crysk review` on the pull request. GitHub Actions runs the review with `--force`. Posting the comment does not review anything on the machine that sends it:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
gh pr comment <n> --body "/crysk review"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`/crysk review --full` also re-discovers the whole range. The comment must be exactly one of those two, and it 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 on the default branch.
|
|
109
|
+
|
|
110
|
+
It bypasses the size gate, the admission rules (same commit, `once_per_pr`, score, low-risk delta, exhausted attempts, `manual_only`), and the budget ceiling. It does not reset the ledger.
|
|
111
|
+
|
|
112
|
+
Who can force: anyone with write access to the repository; a comment from anyone else is refused. A fork PR is reviewed only this way, since its own pushes are skipped. `gh run rerun` on a skipped run re-evaluates the gates and does not force.
|
|
113
|
+
|
|
114
|
+
A workflow scaffolded before the comment trigger has no `issue_comment` listener. There, use the legacy `gh workflow run pr-hero-force.yml -f pr=<n>`, or re-scaffold with `crysk ci init --force`.
|
|
115
|
+
|
|
116
|
+
A local agent posts the comment. It does not run `crysk review --pr <n> --force` when the review should happen in CI.
|
|
117
|
+
|
|
118
|
+
A red gate with blocking findings that the team accepts is unlocked by commenting exactly `/crysk override` on the pull request, not by `/crysk review`. In gate mode a same-head review re-runs the same blocking count and leaves the `failure` in place, so the gate clears only when a pushed fix is verified gone or the override is posted:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
gh pr comment <n> --body "/crysk override"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The override sets the `crysk` status on that head to `success` with no review, no spend, and no credential, and only a user with write or admin access may post it. Each override is recorded: the status names who acted, and a `<!-- crysk-override` comment names who, which head, and when. It is valid only for the head it names, so a new push or a later `/crysk review` on that head replaces it, and it works only on pull requests from this repository, never on forks.
|