crysk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +16 -1
  2. package/dist/SKILL-32cmme3j.md +143 -0
  3. package/dist/SKILL-nncgwkx7.md +553 -0
  4. package/dist/adjudicator-eckqh14e.md +78 -0
  5. package/dist/ci-admission-qn797a6c.md +128 -0
  6. package/dist/cli.js +6471 -5572
  7. package/dist/consolidate-4xw1pkg7.md +24 -0
  8. package/dist/deep-review-logic-dgr112y1.md +196 -0
  9. package/dist/deep-review-logic-fck5z4xe.md +197 -0
  10. package/dist/deep-review-logic-h1fpamfh.md +192 -0
  11. package/dist/deep-review-logic-m4vk5683.md +196 -0
  12. package/dist/deep-review-logic-z63kmgmc.md +157 -0
  13. package/dist/deep-review-parity-7x7s5d81.md +148 -0
  14. package/dist/deep-review-parity-9wxmynsc.md +115 -0
  15. package/dist/deep-review-parity-bwwe7cx6.md +152 -0
  16. package/dist/deep-review-parity-e50pw3pk.md +117 -0
  17. package/dist/deep-review-parity-ennmm9m1.md +151 -0
  18. package/dist/deep-review-parity-h7y6y2he.md +118 -0
  19. package/dist/deep-review-parity-xg6wy69c.md +151 -0
  20. package/dist/deep-review-reliability-6h3c4gmw.md +125 -0
  21. package/dist/deep-review-reliability-dcjab69x.md +122 -0
  22. package/dist/deep-review-reliability-ec7b5pbk.md +159 -0
  23. package/dist/deep-review-reliability-hvasvmt9.md +153 -0
  24. package/dist/deep-review-reliability-mjnayxmt.md +158 -0
  25. package/dist/deep-review-reliability-mm7fnayf.md +124 -0
  26. package/dist/deep-review-reliability-xk4xvc2w.md +158 -0
  27. package/dist/deep-review-resilience-0esd5qeh.md +148 -0
  28. package/dist/deep-review-resilience-envgcmpy.md +115 -0
  29. package/dist/deep-review-resilience-fgx8ythf.md +151 -0
  30. package/dist/deep-review-resilience-mq5qa6ad.md +152 -0
  31. package/dist/deep-review-resilience-pwh1gawp.md +151 -0
  32. package/dist/deep-review-resilience-s9n21dkx.md +117 -0
  33. package/dist/deep-review-resilience-vz4qskea.md +119 -0
  34. package/dist/deep-review-security-1vwjdc9q.md +205 -0
  35. package/dist/deep-review-security-x1cc1z00.md +205 -0
  36. package/dist/index.js +1056 -480
  37. package/dist/opencode-ci-jc8mf4wn.md +106 -0
  38. package/dist/review-refuter-7qffwtzz.md +77 -0
  39. package/dist/verifier-tyh8r45v.md +40 -0
  40. package/dist/verifier-xf4xj701.md +40 -0
  41. package/dist/workflow-ag62s87j.yml +163 -0
  42. package/package.json +1 -1
  43. package/prompts/consolidate.md +1 -1
  44. package/prompts/default/PROVENANCE.md +5 -0
  45. package/prompts/default/deep-review-logic.md +56 -15
  46. package/prompts/default/deep-review-parity.md +71 -39
  47. package/prompts/default/deep-review-reliability.md +64 -30
  48. package/prompts/default/deep-review-resilience.md +71 -37
  49. package/prompts/default/deep-review-security.md +205 -0
  50. package/prompts/default/review-refuter.md +1 -1
  51. package/prompts/verifier.md +40 -0
  52. package/skills/crysk-ci-setup/SKILL.md +3 -3
  53. package/skills/crysk-ci-setup/references/ci-admission.md +1 -1
  54. package/skills/crysk-ci-setup/references/opencode-ci.md +1 -1
  55. package/skills/crysk-loop/SKILL.md +2 -2
  56. package/skills/crysk-loop/adjudicator.md +10 -18
  57. package/src/asset-manifest.ts +6 -0
  58. package/src/assets.ts +37 -11
  59. package/src/ci/gates.ts +13 -26
  60. package/src/ci/platform.ts +50 -0
  61. package/src/ci/review-levels.ts +4 -4
  62. package/src/ci/trigger.ts +64 -4
  63. package/src/commands/ci-setup-questions.ts +1 -1
  64. package/src/commands/status.ts +2 -0
  65. package/src/compare/hunter-exam.ts +631 -0
  66. package/src/index.ts +1 -1
  67. package/src/model/model-name.ts +2 -1
  68. package/src/model/profiles.ts +1 -1
  69. package/src/pr/answered-findings.ts +3 -0
  70. package/src/pr/ci-admission-gate.ts +1 -0
  71. package/src/pr/discovery.ts +1 -0
  72. package/src/pr/pr-status.ts +18 -3
  73. package/src/pr/pr.ts +1 -1
  74. package/src/pr/preflight.ts +29 -3
  75. package/src/pr/publish-outcome.ts +14 -13
  76. package/src/pr/review-pr.ts +22 -2
  77. package/src/rereview/prepare.ts +13 -2
  78. package/src/rereview/verify.ts +15 -9
  79. package/src/review/boundary.ts +1 -0
  80. package/src/review/exit-code.ts +60 -0
  81. package/src/review/findings.ts +3 -3
  82. package/src/review/pipeline.ts +139 -14
  83. package/src/review/preflight.ts +25 -4
  84. package/src/review/prompt-set.ts +7 -1
  85. package/src/review/review.ts +20 -11
  86. package/src/review/route-preflight.ts +16 -0
  87. package/src/triage/adjudication.ts +35 -2
  88. package/src/ui/result.ts +1 -1
  89. package/src/updater.ts +1 -1
  90. package/src/watch/preflight.ts +34 -8
  91. package/src/watch/watch.ts +8 -4
@@ -613,7 +613,15 @@ questions; use it first.
613
613
  The size gate is a COST gate, not a quality gate: past its limits a diff bills
614
614
  several times more with a much wider spread, so Crysk skips it unattended
615
615
  rather than guess at the bill. An interactive run asks first. It says nothing
616
- about how well a large diff reviews.`;
616
+ about how well a large diff reviews.
617
+
618
+ Exit codes of a review (findings never change them):
619
+ 0 the review is complete, with or without findings
620
+ 1 no usable review: every hunter failed, no reviewer ran, or findings
621
+ that should have been posted were dropped
622
+ 2 usage error
623
+ 3 the review is incomplete: a step failed (a hunter, the refuter,
624
+ verify, adjudicate, or the time ceiling). Run it again.`;
617
625
 
618
626
  const VALUE_FLAGS = new Set([
619
627
  "--repo",
@@ -2031,6 +2039,16 @@ const RETIRED_AGENT_HINTS: Record<string, string> = {
2031
2039
  "CRYSK_EXTRA_HUNTERS=lifecycle:deep-review-lifecycle.md",
2032
2040
  };
2033
2041
 
2042
+ // The other direction: a hunter that JOINED the default spec. A custom set
2043
+ // copied from an older default lacks its file, and "the dir does not have it"
2044
+ // alone reads as a broken install after an upgrade.
2045
+ const ADDED_AGENT_HINTS: Record<string, string> = {
2046
+ "deep-review-security.md":
2047
+ "; the security hunter was added to the default spec: copy " +
2048
+ "prompts/default/deep-review-security.md from the crysk package into " +
2049
+ "this directory",
2050
+ };
2051
+
2034
2052
  export function agentsDirProblems(
2035
2053
  specFiles: string[],
2036
2054
  presentFiles: string[],
@@ -2041,7 +2059,8 @@ export function agentsDirProblems(
2041
2059
  for (const file of named) {
2042
2060
  if (!present.has(file)) {
2043
2061
  problems.push(
2044
- `the spec references "${file}" but the dir does not have it`,
2062
+ `the spec references "${file}" but the dir does not have it` +
2063
+ (ADDED_AGENT_HINTS[file] ?? ""),
2045
2064
  );
2046
2065
  }
2047
2066
  }
@@ -2173,9 +2192,10 @@ function parseExtraHunters(read: BrandEnvValue | undefined): AgentSpec[] {
2173
2192
  });
2174
2193
  }
2175
2194
 
2176
- // Local mode's wiring: the three unconditional hunters, the conditional
2195
+ // Local mode's wiring: the four unconditional hunters, the conditional
2177
2196
  // parity hunter, and the refuter. Deliberately NOT defaultReviewSpec() — that
2178
- // one omits the logic hunter, and local mode targets the 5-file clean set. Hunter keys stay inside the findings-schema v1.1.0 Hunter/specialty
2197
+ // one omits the logic and security hunters, and local mode targets the 6-file
2198
+ // clean set. Hunter keys stay inside the findings-schema v1.1.0 Hunter/specialty
2179
2199
  // set, which validateReviewSpec enforces.
2180
2200
  //
2181
2201
  // `env` is injectable (defaults to `process.env`) so PRHERO_EXTRA_HUNTERS can
@@ -2194,6 +2214,7 @@ export function localReviewSpec(
2194
2214
  },
2195
2215
  { key: "resilience", file: "deep-review-resilience.md", role: "hunter" },
2196
2216
  { key: "logic", file: "deep-review-logic.md", role: "hunter" },
2217
+ { key: "security", file: "deep-review-security.md", role: "hunter" },
2197
2218
  {
2198
2219
  key: "parity",
2199
2220
  file: "deep-review-parity.md",
@@ -8,6 +8,7 @@
8
8
  import { EFFORT_LEVELS, type Effort, isEffort } from "#model/catalog";
9
9
  import type { ModelProfile } from "#model/profiles";
10
10
  import { PROFILE_PROMPT_FILES } from "../asset-manifest";
11
+ import { resolveBundledFilePath } from "../assets";
11
12
  import { wrapBlock } from "./boundary";
12
13
 
13
14
  // Fixed order — the lab's promptSetFingerprint hashes the concatenated files
@@ -30,6 +31,7 @@ export const ENGINE_PROMPT_FILES = [
30
31
  "scout.md",
31
32
  "summarizer.md",
32
33
  "materiality.md",
34
+ "verifier.md",
33
35
  ] as const;
34
36
  export type EnginePromptFile = (typeof ENGINE_PROMPT_FILES)[number];
35
37
 
@@ -69,7 +71,11 @@ export function profilePromptSet(
69
71
  `model profile "${profile.id}" names prompt set "${profile.promptSet}", which this build does not have`,
70
72
  );
71
73
  }
72
- for (const [file, filePath] of Object.entries(set)) {
74
+ for (const [file, bundledPath] of Object.entries(set)) {
75
+ // Set paths come from bundled `with { type: "file" }` imports, which an npm
76
+ // build emits as cwd-relative strings; resolve them against the module like
77
+ // every other bundled asset (src/assets.ts).
78
+ const filePath = resolveBundledFilePath(bundledPath);
73
79
  if (defaultAgentFiles.includes(file)) {
74
80
  overrides.agents[file] = filePath;
75
81
  } else if (isEnginePromptFile(file)) {
@@ -26,6 +26,7 @@ import { engineIdentity } from "#git/identity";
26
26
  import { countFreeRouteSteps } from "#model/free-discovery";
27
27
  import { planRoutes } from "#model/routing";
28
28
  import { reviewPr } from "#pr/review-pr";
29
+ import { reviewExitCode } from "#review/exit-code";
29
30
  import type { Telemetry } from "#review/findings";
30
31
  import { type PipelineResult, runPipeline } from "#review/pipeline";
31
32
  import {
@@ -391,16 +392,16 @@ export async function review(options: CliOptions): Promise<number> {
391
392
  // same signal and refuses to start another attempt. Two controllers would
392
393
  // leave the ceiling unable to stop the steps it is waiting on.
393
394
  const ceilingController = new AbortController();
394
- // Local mode has no PR, so the materiality judge reads the reviewed head's
395
- // commit subject as the title (S9). Only asked for when the gate is on, so
396
- // a run with it off spawns exactly the processes it always did. A failed
397
- // read leaves it absent and the pipeline renders its fallback.
395
+ // Local mode has no PR, so the reviewed head's commit subject stands in as
396
+ // the title: the hunters read it as the change's stated intent (S10) and
397
+ // the materiality judge as its title (S9). Local mode has no description.
398
+ // Asked for on every run, so the hunters' request does not depend on the
399
+ // judge being on. A failed read leaves it absent: the hunters get no intent
400
+ // section and the judge's pipeline renders its fallback.
398
401
  let prTitle: string | undefined;
399
- if (resolveMaterialityGate(config)) {
400
- const subject = await git(repoRoot, ["log", "-1", "--format=%s", headSha]);
401
- if (subject.ok && subject.stdout.trim() !== "") {
402
- prTitle = subject.stdout.trim();
403
- }
402
+ const subject = await git(repoRoot, ["log", "-1", "--format=%s", headSha]);
403
+ if (subject.ok && subject.stdout.trim() !== "") {
404
+ prTitle = subject.stdout.trim();
404
405
  }
405
406
  let productionRuntime: ProductionRuntime | undefined;
406
407
  try {
@@ -537,6 +538,14 @@ export async function review(options: CliOptions): Promise<number> {
537
538
  })) {
538
539
  log(line);
539
540
  }
540
- if (result.sessionFailed) return 1;
541
- return 0;
541
+ // The same table as PR and CI mode (src/review/exit-code.ts). Local mode
542
+ // posts nothing, so nothing can be dropped.
543
+ return reviewExitCode({
544
+ sessionFailed: result.sessionFailed,
545
+ ...(result.noReviewerRan === undefined
546
+ ? {}
547
+ : { noReviewerRan: result.noReviewerRan }),
548
+ runStatus: doc.run_status,
549
+ droppedFindingIds: 0,
550
+ });
542
551
  }
@@ -94,6 +94,8 @@ export function enginePromptPath(
94
94
  return assets.summarizerPromptPath;
95
95
  case "materiality.md":
96
96
  return assets.materialityPromptPath;
97
+ case "verifier.md":
98
+ return assets.verifierPromptPath;
97
99
  }
98
100
  }
99
101
 
@@ -160,6 +162,20 @@ export function pipelineConsolidateInput(prompts: RunPromptOptions): {
160
162
  };
161
163
  }
162
164
 
165
+ // The re-review verifier's body is ENGINE-owned like the consolidation
166
+ // prompt. The verifier asks whether an earlier finding's defect is still
167
+ // present at the current head, which is not the refuter's question, so it does
168
+ // not run under the refuter's body. Only the body is its own: model, effort,
169
+ // tools and route stay the refuter agent's (`runVerify`), so a custom
170
+ // `review-refuter.md` still sets those and no longer shapes what the
171
+ // verifier is told. Outside the agents dir on purpose: a `review-verifier.md`
172
+ // there would fall under the two-way rule and break every custom directory.
173
+ export function pipelineVerifierInput(prompts: RunPromptOptions): {
174
+ verifier: { promptPath: string };
175
+ } {
176
+ return { verifier: { promptPath: enginePromptPath("verifier.md", prompts) } };
177
+ }
178
+
163
179
  // The materiality gate (odd/tasks/materiality-gate.md) is ENGINE-owned like
164
180
  // the consolidation pass but OFF by default: it is config-only
165
181
  // (`materiality_gate`), and absent means today's pipeline, byte for byte. The
@@ -4,8 +4,9 @@
4
4
  // `dismissed` reply to a blocking finding, and posts the ruling as a reply on the
5
5
  // finding's thread. That reply is the only CI verdict the gate trusts, and only
6
6
  // when all of these hold:
7
- // - GitHub says the reply's author is CI_ADJUDICATOR_LOGIN. The marker's own
8
- // text proves nothing, since anyone can type it;
7
+ // - GitHub says the reply's author is CI_ADJUDICATOR_LOGIN, or the GitHub App bot
8
+ // that posted the finding itself (trustedAdjudicator). The marker's own text
9
+ // proves nothing, since anyone can type it;
9
10
  // - its `reply=` names the comment id of the thread's LATEST triage reply, so a
10
11
  // newer dismissal is pending again;
11
12
  // - that triage reply is `dismissed`, and the verdict is `upheld` (D5: only a
@@ -21,6 +22,38 @@ export const ADJUDICATION_MARKER_PREFIX = `${MARKER_OPEN}adjudication `;
21
22
  // The login GitHub stamps on comments posted with the workflow's GITHUB_TOKEN.
22
23
  export const CI_ADJUDICATOR_LOGIN = "github-actions[bot]";
23
24
 
25
+ // A GitHub App's bot login. A person's login can never end in `[bot]`.
26
+ const APP_BOT_LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\[bot\]$/;
27
+
28
+ // Who a read trusts to rule (odd/tasks/platform-commands.md in the platform repo, S5).
29
+ // - `ci`: a run's own read, which decides the gate. Standalone only github-actions[bot] rules. A
30
+ // run a Crysk platform dispatched posts as the platform App's bot, the login the platform's
31
+ // token exchange returned (CRYSK_PLATFORM_ACTOR), so that login rules too, on a finding it posted.
32
+ // - `local`: `crysk status` on a developer's machine, which never learns the platform's login. It
33
+ // trusts an App's bot ruling on a finding that same bot posted. That read only advises the next
34
+ // action; the gate's own read is `ci`.
35
+ export type AdjudicatorTrust =
36
+ | { kind: "ci"; platformActor?: string }
37
+ | { kind: "local" };
38
+
39
+ export const CI_ADJUDICATOR_TRUST: AdjudicatorTrust = { kind: "ci" };
40
+
41
+ // WHY the finding's own author: another App installed on the repository can post the marker too,
42
+ // but only the bot that posted the finding rules on it. A person can type the marker under a
43
+ // finding they posted, so the author must be an App's bot.
44
+ export function trustedAdjudicator(
45
+ rulingAuthor: string | undefined,
46
+ findingAuthor: string | undefined,
47
+ trust: AdjudicatorTrust,
48
+ ): boolean {
49
+ if (rulingAuthor === undefined) return false;
50
+ if (rulingAuthor === CI_ADJUDICATOR_LOGIN) return true;
51
+ if (rulingAuthor !== findingAuthor || !APP_BOT_LOGIN.test(rulingAuthor)) {
52
+ return false;
53
+ }
54
+ return trust.kind === "local" || rulingAuthor === trust.platformActor;
55
+ }
56
+
24
57
  // The most adjudicator calls one run makes. A pending dismissal past the cap
25
58
  // stays pending, still counted, and the next recheck takes it.
26
59
  export const MAX_ADJUDICATIONS_PER_RUN = 5;
package/src/ui/result.ts CHANGED
@@ -540,7 +540,7 @@ export function renderResult(input: ResultInput): string[] {
540
540
  );
541
541
  }
542
542
  // The line that outranks every count above it. The exit code is the SHELL's
543
- // (return 1 in local mode, postingExitCode in PR mode) — this only says so.
543
+ // (reviewExitCode, src/review/exit-code.ts: 1 here) — this only says so.
544
544
  if (input.sessionFailed) {
545
545
  lines.push(
546
546
  "",
package/src/updater.ts CHANGED
@@ -55,7 +55,7 @@ export function detectInstallMethod(
55
55
  ): InstallMethod {
56
56
  const home = options.home ?? os.homedir();
57
57
  const execPath = options.execPath ?? process.execPath;
58
- const version = options.version ?? "0.6.0";
58
+ const version = options.version ?? "0.7.0";
59
59
  const exists = options.exists ?? existsSync;
60
60
 
61
61
  const isSource =
@@ -11,6 +11,10 @@
11
11
  import path from "node:path";
12
12
  import { isFullCommitId } from "#git/refs";
13
13
  import { PR_COMMENT_MARKER_PREFIX } from "#pr/preflight";
14
+ import {
15
+ EXIT_REVIEW_COMPLETE,
16
+ EXIT_REVIEW_INCOMPLETE,
17
+ } from "#review/exit-code";
14
18
  import type { NumstatFile } from "#review/preflight";
15
19
  import {
16
20
  DEFAULT_SIZE_GATE,
@@ -1096,9 +1100,21 @@ export function launchedLine(
1096
1100
  return `${ts} launched pr=${pr} repo=${repoBase} head=${headSha.slice(0, 8)}`;
1097
1101
  }
1098
1102
 
1103
+ // What the watcher makes of a review child's exit code, by the review's own
1104
+ // table (src/review/exit-code.ts). "incomplete" is exit 3: the review ran and
1105
+ // may have posted findings, but a step failed, so it is neither a clean "ok"
1106
+ // nor a "failed" whose counts mean nothing.
1107
+ export type ReviewResult = "ok" | "incomplete" | "failed";
1108
+
1109
+ export function reviewOutcomeResult(exitCode: number): ReviewResult {
1110
+ if (exitCode === EXIT_REVIEW_COMPLETE) return "ok";
1111
+ if (exitCode === EXIT_REVIEW_INCOMPLETE) return "incomplete";
1112
+ return "failed";
1113
+ }
1114
+
1099
1115
  export interface ReviewOutcome {
1100
1116
  pr: number;
1101
- ok: boolean;
1117
+ result: ReviewResult;
1102
1118
  exitCode: number;
1103
1119
  counts: { blocking: number; advisory: number } | null;
1104
1120
  }
@@ -1108,13 +1124,17 @@ export function outcomeLine(
1108
1124
  repoBase: string,
1109
1125
  outcome: ReviewOutcome,
1110
1126
  ): string {
1111
- const status = outcome.ok ? "status=ok" : "status=failed";
1112
- const detail = outcome.ok
1113
- ? outcome.counts === null
1127
+ const counts =
1128
+ outcome.counts === null
1114
1129
  ? ""
1115
- : ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}`
1116
- : ` exit=${outcome.exitCode}`;
1117
- return `${ts} outcome pr=${outcome.pr} repo=${repoBase} ${status}${detail}`;
1130
+ : ` blocking=${outcome.counts.blocking} advisory=${outcome.counts.advisory}`;
1131
+ const detail =
1132
+ outcome.result === "ok"
1133
+ ? counts
1134
+ : outcome.result === "incomplete"
1135
+ ? ` exit=${outcome.exitCode}${counts}`
1136
+ : ` exit=${outcome.exitCode}`;
1137
+ return `${ts} outcome pr=${outcome.pr} repo=${repoBase} status=${outcome.result}${detail}`;
1118
1138
  }
1119
1139
 
1120
1140
  // Counts today's launches back out of the raw log text. dayPrefix is the
@@ -1267,9 +1287,15 @@ export function osascriptNotifyArgs(title: string, text: string): string[] {
1267
1287
  }
1268
1288
 
1269
1289
  export function outcomeNotificationText(outcome: ReviewOutcome): string {
1270
- if (!outcome.ok) {
1290
+ if (outcome.result === "failed") {
1271
1291
  return `PR #${outcome.pr} review failed (exit ${outcome.exitCode})`;
1272
1292
  }
1293
+ if (outcome.result === "incomplete") {
1294
+ const prefix = `PR #${outcome.pr} review incomplete, run it again`;
1295
+ return outcome.counts === null
1296
+ ? `${prefix} (counts unavailable)`
1297
+ : `${prefix}: ${outcome.counts.blocking} blocking, ${outcome.counts.advisory} advisory`;
1298
+ }
1273
1299
  if (outcome.counts === null) {
1274
1300
  return `PR #${outcome.pr} reviewed (counts unavailable)`;
1275
1301
  }
@@ -102,6 +102,7 @@ import {
102
102
  removeWatchRepo,
103
103
  renderWatchPlist,
104
104
  renderWatchStatus,
105
+ reviewOutcomeResult,
105
106
  skipLine,
106
107
  type TickDecision,
107
108
  type TickLaunch,
@@ -860,14 +861,17 @@ async function runTick(
860
861
  );
861
862
  const exitCode = await proc.exited;
862
863
 
864
+ // An incomplete review (exit 3) still ran and may have posted findings, so
865
+ // its counts are read like a complete one's; only a failed run has none.
866
+ const result = reviewOutcomeResult(exitCode);
863
867
  const outcome: ReviewOutcome = {
864
868
  pr: launch.pr,
865
- ok: exitCode === 0,
869
+ result,
866
870
  exitCode,
867
871
  counts:
868
- exitCode === 0
869
- ? await readTierCounts(launched?.runsRoot, launch.pr, launch.head)
870
- : null,
872
+ result === "failed"
873
+ ? null
874
+ : await readTierCounts(launched?.runsRoot, launch.pr, launch.head),
871
875
  };
872
876
  await appendLog(
873
877
  paths.logPath,