crysk 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +15 -1
  2. package/dist/SKILL-nncgwkx7.md +553 -0
  3. package/dist/cli.js +6379 -5561
  4. package/dist/index.js +967 -467
  5. package/dist/workflow-ag62s87j.yml +163 -0
  6. package/package.json +3 -2
  7. package/skills/crysk-ci-setup/assets/workflow.yml +3 -0
  8. package/skills/crysk-loop/SKILL.md +2 -2
  9. package/src/asset-manifest.ts +11 -0
  10. package/src/assets.ts +34 -11
  11. package/src/ci/credential-refresh.ts +524 -0
  12. package/src/ci/crysk-secrets.ts +20 -6
  13. package/src/ci/gates.ts +2 -24
  14. package/src/ci/outcome.ts +165 -15
  15. package/src/ci/platform.ts +205 -7
  16. package/src/ci/setup.ts +64 -6
  17. package/src/ci/trigger.ts +84 -8
  18. package/src/commands/ci-setup.ts +12 -3
  19. package/src/commands/doctor.ts +25 -23
  20. package/src/commands/status.ts +2 -0
  21. package/src/diversity/identity.ts +11 -1
  22. package/src/diversity/pipeline-integration.ts +19 -6
  23. package/src/doctor.ts +133 -4
  24. package/src/execution/contracts.ts +15 -3
  25. package/src/harness/materiality-judge.ts +153 -0
  26. package/src/harness/pipeline-plan.ts +133 -0
  27. package/src/harness/replay-rows.ts +172 -0
  28. package/src/harness/route-runner.ts +288 -0
  29. package/src/harness/single-step.ts +153 -0
  30. package/src/index.ts +1 -1
  31. package/src/model/catalog.ts +10 -7
  32. package/src/model/model-name.ts +14 -0
  33. package/src/model/profiles/claude.ts +34 -0
  34. package/src/model/profiles/openai.ts +44 -0
  35. package/src/model/profiles.ts +213 -0
  36. package/src/model/routing.ts +155 -50
  37. package/src/pr/answered-findings.ts +3 -0
  38. package/src/pr/ci-admission-gate.ts +1 -0
  39. package/src/pr/discovery.ts +1 -0
  40. package/src/pr/plan.ts +6 -1
  41. package/src/pr/pr-status.ts +18 -3
  42. package/src/pr/publish-outcome.ts +14 -13
  43. package/src/pr/review-pr.ts +49 -8
  44. package/src/pr/target.ts +16 -7
  45. package/src/production-runtime.ts +100 -13
  46. package/src/rereview/prepare.ts +13 -2
  47. package/src/review/exit-code.ts +60 -0
  48. package/src/review/findings.ts +3 -3
  49. package/src/review/pipeline.ts +193 -58
  50. package/src/review/preflight.ts +100 -10
  51. package/src/review/prompt-set.ts +73 -0
  52. package/src/review/review.ts +32 -13
  53. package/src/review/route-preflight.ts +117 -67
  54. package/src/review/run.ts +34 -4
  55. package/src/security/credential-broker.ts +21 -9
  56. package/src/security/oauth-providers.ts +101 -0
  57. package/src/transport-registry.ts +33 -0
  58. package/src/transports/opencode-sdk.ts +33 -1
  59. package/src/triage/adjudication.ts +35 -2
  60. package/src/ui/config-edit.ts +9 -0
  61. package/src/ui/config.ts +1 -0
  62. package/src/ui/menu.ts +9 -2
  63. package/src/ui/result.ts +1 -1
  64. package/src/updater.ts +21 -13
  65. package/src/watch/preflight.ts +34 -8
  66. package/src/watch/watch.ts +8 -4
  67. package/src/wizard.ts +23 -0
@@ -0,0 +1,163 @@
1
+ # Generated by `crysk setup --ci` (or `crysk ci init`).
2
+ # Customize freely — re-running setup will not overwrite this file again
3
+ # unless you pass --force.
4
+ #
5
+ # This one file is the whole install. It reviews every push to a pull
6
+ # request. A pull request comment that is exactly `/crysk review` runs the
7
+ # review again with the skip gates bypassed, and `/crysk review --full`
8
+ # also re-discovers the whole range. A comment that is exactly
9
+ # `/crysk override` turns the gate green on that head with no review and
10
+ # no cost, and records who did it. A comment that is exactly
11
+ # `/crysk recheck` reviews the head and asks the CI adjudicator to rule on
12
+ # pending dismissals of blocking findings. The action parses the comment and
13
+ # refuses a commenter without write access. The older `/pr-hero ...` forms
14
+ # of these commands still work for one version.
15
+ name: Crysk Review
16
+
17
+ on:
18
+ pull_request:
19
+ types: [opened, synchronize, reopened]
20
+ # GitHub runs a comment-triggered workflow from the DEFAULT branch's copy
21
+ # of this file, never the pull request's. The comment trigger works only
22
+ # once this file is merged there; until then a comment starts nothing.
23
+ issue_comment:
24
+ types: [created]
25
+
26
+ # pull-requests: write lets Crysk post inline comments and a step summary.
27
+ # contents: read is enough for actions/checkout. issues: write lets it
28
+ # resolve/reply on review threads (GitHub models PR conversations as issues).
29
+ # checks: write persists the durable CI admission attempt ledger (WU-02).
30
+ # actions: read lets the admission gate list this workflow's past runs; a
31
+ # public repo serves that without the scope, a private one returns HTTP 403.
32
+ permissions:
33
+ actions: read
34
+ contents: read
35
+ pull-requests: write
36
+ issues: write
37
+ statuses: write
38
+ checks: write
39
+
40
+ jobs:
41
+ review:
42
+ # This `if` routes events; it never checks credentials. The secrets
43
+ # context is unreadable in a job-level `if`, so the action detects a
44
+ # missing credential itself and fails the run with the commands that
45
+ # fix it, instead of a skipped job that reads as a clean review.
46
+ #
47
+ # Fork pull_request runs are skipped: GitHub gives them no secrets, so
48
+ # they could never authenticate. A maintainer comments `/crysk review`
49
+ # instead, and that run (base-branch context, with secrets) reviews the
50
+ # fork's head.
51
+ #
52
+ # A comment starts the job only when it BEGINS with `/crysk review`,
53
+ # `/crysk recheck` or `/crysk override` (or the older `/pr-hero` forms
54
+ # of the three). The action then requires an exact match after
55
+ # trimming, so a near-miss such as "/crysk review please" starts a job the
56
+ # action ends without reviewing or overriding.
57
+ if: >-
58
+ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
59
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk review')) ||
60
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk recheck')) ||
61
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/crysk override')) ||
62
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero review')) ||
63
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero recheck')) ||
64
+ (github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pr-hero override'))
65
+ # Job-level and keyed on the pull request number. A workflow-level group
66
+ # on `github.head_ref || github.ref` put every comment on every pull
67
+ # request into ONE group, because head_ref is empty on issue_comment, so
68
+ # any comment anywhere could cancel any in-flight review.
69
+ #
70
+ # Only a new push cancels. The group filter is a prefix, so a near-miss
71
+ # comment can claim the pull request's group too; cancelling there would
72
+ # kill a paid in-flight review before the action ignored the comment. A
73
+ # comment run queues instead. A push never waits: it cancels whatever is
74
+ # running, a forced comment run included, because the head it reviewed
75
+ # is gone (comment again on the new head).
76
+ #
77
+ # GitHub keeps one PENDING run per group, and a newer run replaces it. So
78
+ # a comment enters the pull request's group only when it starts with
79
+ # /crysk review, /crysk recheck or /crysk override (or the older /pr-hero forms), and GitHub associates its author
80
+ # with the repository as OWNER, MEMBER or COLLABORATOR; every other comment
81
+ # gets its own group. Without that, anyone who can comment could replace a
82
+ # maintainer's queued review with a run the action then refuses. The job
83
+ # `if:` above does NOT check the association: a writer GitHub reports
84
+ # under another one (a private org member shown as CONTRIBUTOR) still
85
+ # runs, because the action checks the real permission, just in its own
86
+ # group. KNOWN GAP: an associated author's later comment (a writer's
87
+ # near-miss or second real command, or a read-only member's or
88
+ # collaborator's refused one) still replaces a comment run waiting
89
+ # behind a running review, and `--full` followed by a plain
90
+ # `/crysk review` loses the `--full`; comment again to recover. A
91
+ # writer reported under another association runs unserialized, beside
92
+ # any review already running.
93
+ #
94
+ # A fork's push never enters the pull request's group: its job is skipped
95
+ # above, and if a skipped job still claimed the group, the fork author's
96
+ # push would cancel a maintainer's in-flight review of that fork. Every
97
+ # other event gets a unique per-run group for the same reason, so a
98
+ # skipped job can never cancel or replace a review.
99
+ concurrency:
100
+ group: ${{ ((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (startsWith(github.event.comment.body, '/crysk review') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/crysk recheck') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/crysk override') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero review') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero recheck') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)) || (startsWith(github.event.comment.body, '/pr-hero override') && contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association))) && format('pr-hero-review-{0}', github.event.pull_request.number || github.event.issue.number) || format('pr-hero-noop-{0}', github.run_id) }}
101
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
102
+ runs-on: ubuntu-latest
103
+ # Backstop for a HUNG runner, not a second review budget. Crysk already
104
+ # enforces its own 75-minute whole-pipeline ceiling, which closes
105
+ # artifacts and reports before exiting; a CI bound at or below that would
106
+ # kill the job first and throw away the salvage. Above it, this only ever
107
+ # fires when the process is genuinely stuck.
108
+ timeout-minutes: 90
109
+ steps:
110
+ - name: Checkout
111
+ uses: actions/checkout@v4
112
+ with:
113
+ # fetch-depth: 0 is load-bearing, not cosmetic: Crysk computes
114
+ # the pull request's diff range and commit ancestry from full git
115
+ # history. actions/checkout's default is a SHALLOW clone, which
116
+ # cannot produce an accurate diff or blame — trimming this line
117
+ # does not fail loudly, it makes reviews silently miss context.
118
+ fetch-depth: 0
119
+
120
+ - name: Run Crysk
121
+ # The id keeps this step's outputs (`status`, `run-dir`, ...)
122
+ # readable from any step you add below.
123
+ # The action uploads the run directory as an artifact itself, so
124
+ # `crysk triage reply --from` has an input in CI (see action.yml).
125
+ id: pr-hero
126
+ uses: cryskai/crysk@v0
127
+ with:
128
+ github-token: ${{ secrets.GITHUB_TOKEN }}
129
+ # The Crysk credentials: one CRYSK_* secret per line, each named
130
+ # explicitly (never the whole secrets context, which would hand the
131
+ # action every secret of the repository). A secret the repository does not have
132
+ # arrives empty and counts as absent, so every line stays. With
133
+ # both Claude secrets set, credentials.claude picks one (the subscription first).
134
+ # CRYSK_CLAUDE_OAUTH_TOKEN — from `claude setup-token`: a long-lived
135
+ # (~1 year) token that draws on your Claude subscription. The
136
+ # session token `/login` leaves in the keychain expires in hours.
137
+ # CRYSK_CLAUDE_API_KEY — pay-as-you-go key (billed per token).
138
+ # CRYSK_OPENCODE_OPENAI_OAUTH — an OpenAI (ChatGPT) subscription for
139
+ # OpenCode: the openai record of OpenCode's auth.json, base64 on one line.
140
+ # CRYSK_OPENCODE_<PROVIDER>_API_KEY — an OpenCode provider's API key,
141
+ # <PROVIDER> being its id uppercased with - and . as _. The 5
142
+ # lines after the fixed ones forward the providers listed in
143
+ # vars.CRYSK_OPENCODE_PROVIDERS (a JSON array, e.g. ["DEEPSEEK"]);
144
+ # an unused line renders as CRYSK_OPENCODE__API_KEY= and is skipped.
145
+ # `crysk ci init` prints the commands that set these secrets and variables.
146
+ crysk-secrets: |
147
+ CRYSK_CLAUDE_OAUTH_TOKEN=${{ secrets.CRYSK_CLAUDE_OAUTH_TOKEN }}
148
+ CRYSK_CLAUDE_API_KEY=${{ secrets.CRYSK_CLAUDE_API_KEY }}
149
+ CRYSK_OPENCODE_OPENAI_OAUTH=${{ secrets.CRYSK_OPENCODE_OPENAI_OAUTH }}
150
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[0] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[0])] }}
151
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[1] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[1])] }}
152
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[2] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[2])] }}
153
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[3] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[3])] }}
154
+ CRYSK_OPENCODE_${{ fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[4] }}_API_KEY=${{ secrets[format('CRYSK_OPENCODE_{0}_API_KEY', fromJSON(vars.CRYSK_OPENCODE_PROVIDERS || '[]')[4])] }}
155
+ # The models per role and the Claude credential order, as JSON, from
156
+ # repository variables. Unset, every role runs the default Claude model
157
+ # and the subscription is tried first.
158
+ models: ${{ vars.CRYSK_MODELS }}
159
+ credentials: ${{ vars.CRYSK_CREDENTIALS }}
160
+ # The model profile (claude or openai) from a repository variable.
161
+ # Unset, the claude profile. models still wins role by role.
162
+ profile: ${{ vars.CRYSK_PROFILE }}
163
+ mode: gate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crysk",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -70,7 +70,8 @@
70
70
  "check": "biome check src test benchmarks"
71
71
  },
72
72
  "dependencies": {
73
- "@opencode-ai/sdk": "1.18.25"
73
+ "@opencode-ai/sdk": "1.18.25",
74
+ "libsodium-wrappers": "0.8.4"
74
75
  },
75
76
  "devDependencies": {
76
77
  "@biomejs/biome": "^2",
@@ -157,4 +157,7 @@ jobs:
157
157
  # and the subscription is tried first.
158
158
  models: ${{ vars.CRYSK_MODELS }}
159
159
  credentials: ${{ vars.CRYSK_CREDENTIALS }}
160
+ # The model profile (claude or openai) from a repository variable.
161
+ # Unset, the claude profile. models still wins role by role.
162
+ profile: ${{ vars.CRYSK_PROFILE }}
160
163
  mode: gate
@@ -66,7 +66,7 @@ exactly two ways:
66
66
  - **A fix**, pushed to the head and verified gone by the next review.
67
67
  - **A dismissal the CI adjudicator upholds.** You reply `dismissed`, comment `/crysk recheck`, an
68
68
  adjudicator running in CI rules on your argument, and only its `upheld` (posted by
69
- `github-actions[bot]` on that head) lets the next review stop counting the finding. See
69
+ `github-actions[bot]`, or by the Crysk App's bot on a platform-managed repository, on that head) lets the next review stop counting the finding. See
70
70
  "Closing a dismissal" below.
71
71
 
72
72
  **When no review is left, answers unlock the gate.** Every review rule that skips a push (the
@@ -297,7 +297,7 @@ adjudicator. When step 0 says `recheck`:
297
297
  reads your argument and the repository at that head. You may comment it yourself: you only supply
298
298
  the argument, the CI adjudicator rules. (`/crysk override` is the opposite: never yours to post.)
299
299
  2. Wait with `npx -y crysk status --pr <n> --wait --json` until the run settles. Each ruling is a reply on the finding's thread,
300
- from `github-actions[bot]`, whose first line is
300
+ from `github-actions[bot]` (the Crysk App's bot on a platform-managed repository), whose first line is
301
301
  `<!-- crysk-adjudication verdict=<v> reply=<your reply's id> head=<sha> -->`. Step 0's
302
302
  `ci_verdict` reads it for you.
303
303
  3. Act on the verdict:
@@ -53,6 +53,17 @@ export const BUNDLED_AGENT_FILES: Record<string, string> = {
53
53
  "review-refuter.md": refuterPrompt,
54
54
  };
55
55
 
56
+ // Model-profile prompt sets (odd/tasks/model-profiles.md S4): set name ->
57
+ // logical filename -> path, read from `prompts/profiles/<set>/<file>`. A set
58
+ // holds only the files that differ from the default set; every other file
59
+ // falls back to it (profilePromptSet, src/review/prompt-set.ts). Bun embeds
60
+ // only what is imported, so each override needs its own `with { type: "file" }`
61
+ // import above and an entry here; test/assets.test.ts checks this map against
62
+ // the disk. No profile ships a set yet.
63
+ export const PROFILE_PROMPT_FILES: Readonly<
64
+ Record<string, Readonly<Record<string, string>>>
65
+ > = {};
66
+
56
67
  export const CONSOLIDATE_PROMPT_PATH = consolidatePrompt;
57
68
  export const MATERIALITY_PROMPT_PATH = materialityPrompt;
58
69
  export const SCOUT_PROMPT_PATH = scoutPrompt;
package/src/assets.ts CHANGED
@@ -74,14 +74,37 @@ function resolveVersion(): string {
74
74
  // Ignore read errors
75
75
  }
76
76
 
77
- return "0.5.1";
77
+ return "0.6.1";
78
+ }
79
+
80
+ // Bun file imports can emit "./name-hash.ext" in bundled npm builds.
81
+ // Resolve those filenames against the emitting module, never the consumer CWD.
82
+ export function resolveBundledFilePath(
83
+ filePath: string,
84
+ moduleDir: string = import.meta.dir,
85
+ ): string {
86
+ return path.isAbsolute(filePath)
87
+ ? filePath
88
+ : path.resolve(moduleDir, filePath);
89
+ }
90
+
91
+ function resolveBundledFileMap(
92
+ files: Record<string, string>,
93
+ ): Record<string, string> {
94
+ return Object.fromEntries(
95
+ Object.entries(files).map(([name, file]) => [
96
+ name,
97
+ resolveBundledFilePath(file),
98
+ ]),
99
+ );
78
100
  }
79
101
 
80
102
  export function resolveEngineAssets(): EngineAssets {
81
103
  const mode = detectAssetMode();
82
104
  const version = resolveVersion();
83
105
 
84
- let defaultAgentsDir = path.dirname(BUNDLED_AGENT_FILES["review-refuter.md"]);
106
+ const bundledAgentFiles = resolveBundledFileMap(BUNDLED_AGENT_FILES);
107
+ let defaultAgentsDir = path.dirname(bundledAgentFiles["review-refuter.md"]);
85
108
  if (mode !== "compiled") {
86
109
  const fsDefaultDir = path.resolve(import.meta.dir, "../prompts/default");
87
110
  if (existsSync(fsDefaultDir)) {
@@ -91,16 +114,16 @@ export function resolveEngineAssets(): EngineAssets {
91
114
 
92
115
  return {
93
116
  mode,
94
- bundledAgentFiles: BUNDLED_AGENT_FILES,
117
+ bundledAgentFiles,
95
118
  defaultAgentsDir,
96
- consolidatePromptPath: CONSOLIDATE_PROMPT_PATH,
97
- materialityPromptPath: MATERIALITY_PROMPT_PATH,
98
- scoutPromptPath: SCOUT_PROMPT_PATH,
99
- summarizerPromptPath: SUMMARIZER_PROMPT_PATH,
100
- triageSkillFiles: TRIAGE_SKILL_FILES,
101
- ciSetupSkillFiles: CI_SETUP_SKILL_FILES,
102
- prSkillFiles: PR_SKILL_FILES,
103
- generalSkillFiles: GENERAL_SKILL_FILES,
119
+ consolidatePromptPath: resolveBundledFilePath(CONSOLIDATE_PROMPT_PATH),
120
+ materialityPromptPath: resolveBundledFilePath(MATERIALITY_PROMPT_PATH),
121
+ scoutPromptPath: resolveBundledFilePath(SCOUT_PROMPT_PATH),
122
+ summarizerPromptPath: resolveBundledFilePath(SUMMARIZER_PROMPT_PATH),
123
+ triageSkillFiles: resolveBundledFileMap(TRIAGE_SKILL_FILES),
124
+ ciSetupSkillFiles: resolveBundledFileMap(CI_SETUP_SKILL_FILES),
125
+ prSkillFiles: resolveBundledFileMap(PR_SKILL_FILES),
126
+ generalSkillFiles: resolveBundledFileMap(GENERAL_SKILL_FILES),
104
127
  version,
105
128
  };
106
129
  }