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.
Files changed (233) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +611 -3
  3. package/bin/pr-hero.js +166 -0
  4. package/config/models/anthropic.json +5 -0
  5. package/dist/SKILL-7e3725zn.md +496 -0
  6. package/dist/SKILL-7q35wcaz.md +66 -0
  7. package/dist/SKILL-9at22381.md +74 -0
  8. package/dist/SKILL-ex2hxxh3.md +134 -0
  9. package/dist/SKILL-y8rv8msh.md +134 -0
  10. package/dist/SKILL-ygka1bs0.md +515 -0
  11. package/dist/adjudicator-dtg2axnh.md +86 -0
  12. package/dist/admission-config.example-a9vqmmad.json +9 -0
  13. package/dist/ci-admission-camfbx2b.md +122 -0
  14. package/dist/ci-admission-qk9r9taq.md +124 -0
  15. package/dist/cli.js +42501 -0
  16. package/dist/consolidate-ac0mnfyj.md +24 -0
  17. package/dist/deep-review-lifecycle-m698ybjp.md +362 -0
  18. package/dist/deep-review-logic-a6b1gczf.md +156 -0
  19. package/dist/deep-review-parity-0ec904db.md +120 -0
  20. package/dist/deep-review-reliability-qyakbjb9.md +125 -0
  21. package/dist/deep-review-resilience-3tz8y26e.md +118 -0
  22. package/dist/index.js +20190 -0
  23. package/dist/opencode-ci-7b0be64p.md +141 -0
  24. package/dist/review-refuter-j4e9gezy.md +71 -0
  25. package/dist/scout-yvp153q7.md +140 -0
  26. package/dist/summarizer-zca44nxa.md +18 -0
  27. package/dist/workflow-w1g9szna.yml +151 -0
  28. package/package.json +81 -4
  29. package/prompts/consolidate.md +24 -0
  30. package/prompts/default/PROVENANCE.md +18 -0
  31. package/prompts/default/deep-review-lifecycle.md +362 -0
  32. package/prompts/default/deep-review-logic.md +156 -0
  33. package/prompts/default/deep-review-parity.md +120 -0
  34. package/prompts/default/deep-review-reliability.md +125 -0
  35. package/prompts/default/deep-review-resilience.md +118 -0
  36. package/prompts/default/review-refuter.md +71 -0
  37. package/prompts/scout.md +140 -0
  38. package/prompts/summarizer.md +18 -0
  39. package/skills/crysk/SKILL.md +74 -0
  40. package/skills/crysk-ci-setup/SKILL.md +134 -0
  41. package/skills/crysk-ci-setup/assets/admission-config.example.json +9 -0
  42. package/skills/crysk-ci-setup/assets/workflow.yml +151 -0
  43. package/skills/crysk-ci-setup/references/ci-admission.md +124 -0
  44. package/skills/crysk-ci-setup/references/opencode-ci.md +141 -0
  45. package/skills/crysk-loop/SKILL.md +515 -0
  46. package/skills/crysk-loop/adjudicator.md +86 -0
  47. package/skills/crysk-pr/SKILL.md +66 -0
  48. package/src/agent-env.ts +1084 -0
  49. package/src/asset-manifest.ts +83 -0
  50. package/src/assets.d.ts +6 -0
  51. package/src/assets.ts +183 -0
  52. package/src/brand-paths.ts +155 -0
  53. package/src/brand.ts +255 -0
  54. package/src/ci/admission-ledger.ts +350 -0
  55. package/src/ci/classify-error.ts +73 -0
  56. package/src/ci/cli-record.ts +271 -0
  57. package/src/ci/force-comment.ts +39 -0
  58. package/src/ci/gates.ts +945 -0
  59. package/src/ci/outcome.ts +2181 -0
  60. package/src/ci/override.ts +187 -0
  61. package/src/ci/publish.ts +1639 -0
  62. package/src/ci/reporter.ts +626 -0
  63. package/src/ci/review-admission.ts +910 -0
  64. package/src/ci/review-levels.ts +310 -0
  65. package/src/ci/review-policy.ts +18 -0
  66. package/src/ci/review-risk.ts +184 -0
  67. package/src/ci/setup.ts +844 -0
  68. package/src/ci/trigger.ts +1353 -0
  69. package/src/cli.ts +348 -0
  70. package/src/commands/activity.ts +67 -0
  71. package/src/commands/ci-setup-questions.ts +397 -0
  72. package/src/commands/ci-setup.ts +381 -0
  73. package/src/commands/config.ts +99 -0
  74. package/src/commands/doctor.ts +108 -0
  75. package/src/commands/init.ts +139 -0
  76. package/src/commands/mcp.ts +10 -0
  77. package/src/commands/menu.ts +129 -0
  78. package/src/commands/post.ts +302 -0
  79. package/src/commands/skills.ts +83 -0
  80. package/src/commands/status.ts +173 -0
  81. package/src/commands/triage.ts +342 -0
  82. package/src/commands/uninstall.ts +37 -0
  83. package/src/commands/upgrade.ts +214 -0
  84. package/src/commands/usage.ts +98 -0
  85. package/src/compare/compare.ts +28 -0
  86. package/src/compare/floor-test.ts +471 -0
  87. package/src/compare/martian-adapter.ts +80 -0
  88. package/src/config/config.ts +267 -0
  89. package/src/corpus/corpus.ts +1094 -0
  90. package/src/corpus/preflight.ts +1789 -0
  91. package/src/diversity/accounting.ts +90 -0
  92. package/src/diversity/adjudication.ts +145 -0
  93. package/src/diversity/admission.ts +60 -0
  94. package/src/diversity/benchmark.ts +195 -0
  95. package/src/diversity/clustering.ts +285 -0
  96. package/src/diversity/errors.ts +7 -0
  97. package/src/diversity/identity.ts +285 -0
  98. package/src/diversity/index.ts +11 -0
  99. package/src/diversity/pipeline-integration.ts +448 -0
  100. package/src/diversity/projection.ts +57 -0
  101. package/src/diversity/self-contained.ts +68 -0
  102. package/src/diversity/target-validation.ts +179 -0
  103. package/src/doctor-migration.ts +209 -0
  104. package/src/doctor.ts +723 -0
  105. package/src/errors.ts +83 -0
  106. package/src/execution/admission.ts +75 -0
  107. package/src/execution/atomic-write.ts +35 -0
  108. package/src/execution/attempt-evidence.ts +415 -0
  109. package/src/execution/bucket-id.ts +136 -0
  110. package/src/execution/concurrency-limiter.ts +175 -0
  111. package/src/execution/contracts.ts +443 -0
  112. package/src/execution/failure-classification.ts +42 -0
  113. package/src/execution/failure-policy.ts +240 -0
  114. package/src/execution/harness.ts +2548 -0
  115. package/src/execution/settlement.ts +348 -0
  116. package/src/execution/spawned-process.ts +66 -0
  117. package/src/execution/spend-limiter.ts +424 -0
  118. package/src/execution/step-artifacts.ts +55 -0
  119. package/src/execution/usage-normalized.ts +469 -0
  120. package/src/git/git.ts +396 -0
  121. package/src/git/identity.ts +64 -0
  122. package/src/git/refs.ts +140 -0
  123. package/src/home-preflight.ts +443 -0
  124. package/src/home.ts +243 -0
  125. package/src/ignore-file.ts +336 -0
  126. package/src/ignore-read.ts +118 -0
  127. package/src/index.ts +34 -0
  128. package/src/legacy-launchd.ts +29 -0
  129. package/src/mcp/mcp.ts +150 -0
  130. package/src/mcp/preflight.ts +407 -0
  131. package/src/menu-context.ts +192 -0
  132. package/src/model/catalog.ts +251 -0
  133. package/src/model/exec-snapshots.ts +390 -0
  134. package/src/model/free-discovery.ts +302 -0
  135. package/src/model/provider-capabilities.ts +814 -0
  136. package/src/model/routing.ts +600 -0
  137. package/src/pr/admission.ts +984 -0
  138. package/src/pr/answered-findings.ts +169 -0
  139. package/src/pr/ci-admission-gate.ts +743 -0
  140. package/src/pr/ci-publish.ts +76 -0
  141. package/src/pr/discovery.ts +432 -0
  142. package/src/pr/inline.ts +507 -0
  143. package/src/pr/plan.ts +366 -0
  144. package/src/pr/posting.ts +115 -0
  145. package/src/pr/pr-status.ts +845 -0
  146. package/src/pr/pr.ts +3642 -0
  147. package/src/pr/preflight.ts +1031 -0
  148. package/src/pr/publish-outcome.ts +361 -0
  149. package/src/pr/range.ts +119 -0
  150. package/src/pr/reverts-preflight.ts +606 -0
  151. package/src/pr/reverts.ts +377 -0
  152. package/src/pr/review-pr.ts +927 -0
  153. package/src/pr/status.ts +154 -0
  154. package/src/pr/target.ts +388 -0
  155. package/src/pr/teardown.ts +437 -0
  156. package/src/pr/worktree-setup.ts +60 -0
  157. package/src/production-runtime.ts +1877 -0
  158. package/src/progress.ts +487 -0
  159. package/src/rereview/adjudicate.ts +89 -0
  160. package/src/rereview/classify.ts +362 -0
  161. package/src/rereview/identity.ts +211 -0
  162. package/src/rereview/plan.ts +308 -0
  163. package/src/rereview/prepare.ts +1025 -0
  164. package/src/rereview/state.ts +767 -0
  165. package/src/rereview/verify.ts +241 -0
  166. package/src/review/boundary.ts +105 -0
  167. package/src/review/consolidate.ts +246 -0
  168. package/src/review/dedupe.ts +368 -0
  169. package/src/review/drafts.ts +448 -0
  170. package/src/review/findings-conformance.ts +120 -0
  171. package/src/review/findings.ts +714 -0
  172. package/src/review/pipeline.ts +3977 -0
  173. package/src/review/preflight.ts +3575 -0
  174. package/src/review/prompt-set.ts +177 -0
  175. package/src/review/proof-refs.ts +187 -0
  176. package/src/review/report.ts +1821 -0
  177. package/src/review/review.ts +490 -0
  178. package/src/review/root-cause.ts +120 -0
  179. package/src/review/route-preflight.ts +289 -0
  180. package/src/review/run.ts +601 -0
  181. package/src/review/scout.ts +323 -0
  182. package/src/review/size-gate.ts +595 -0
  183. package/src/review/spec.ts +235 -0
  184. package/src/review/step-runner.ts +233 -0
  185. package/src/runner-authority.ts +596 -0
  186. package/src/security/binding-policy.ts +115 -0
  187. package/src/security/credential-broker.ts +773 -0
  188. package/src/security/evidence-redaction.ts +62 -0
  189. package/src/security/execution-authority.ts +27 -0
  190. package/src/security/redact.ts +71 -0
  191. package/src/security/workspace-read-broker.ts +466 -0
  192. package/src/server/client.ts +190 -0
  193. package/src/server/preflight.ts +217 -0
  194. package/src/server/server.ts +327 -0
  195. package/src/signal-handler.ts +50 -0
  196. package/src/store/activity.ts +413 -0
  197. package/src/store/backfill-preflight.ts +49 -0
  198. package/src/store/backfill.ts +141 -0
  199. package/src/store/gc-preflight.ts +206 -0
  200. package/src/store/gc.ts +424 -0
  201. package/src/store/metrics-preflight.ts +229 -0
  202. package/src/store/metrics.ts +236 -0
  203. package/src/store/preflight.ts +748 -0
  204. package/src/store/store.ts +693 -0
  205. package/src/system-tools.ts +355 -0
  206. package/src/transport-registry.ts +1124 -0
  207. package/src/transports/claude-code-cli.ts +1348 -0
  208. package/src/transports/opencode-admission.ts +515 -0
  209. package/src/transports/opencode-client.ts +3328 -0
  210. package/src/transports/opencode-evidence.ts +557 -0
  211. package/src/transports/opencode-mcp.ts +248 -0
  212. package/src/transports/opencode-sdk.ts +2294 -0
  213. package/src/transports/opencode-server.ts +535 -0
  214. package/src/triage/adjudication.ts +113 -0
  215. package/src/triage/reply.ts +125 -0
  216. package/src/triage/triage.ts +255 -0
  217. package/src/ui/activity.ts +173 -0
  218. package/src/ui/config-edit.ts +816 -0
  219. package/src/ui/config.ts +462 -0
  220. package/src/ui/menu.ts +1325 -0
  221. package/src/ui/plan.ts +1039 -0
  222. package/src/ui/primitives.ts +300 -0
  223. package/src/ui/progress.ts +298 -0
  224. package/src/ui/result.ts +552 -0
  225. package/src/ui/review-menu.ts +312 -0
  226. package/src/ui/select.ts +528 -0
  227. package/src/ui/tree.ts +178 -0
  228. package/src/uninstaller.ts +479 -0
  229. package/src/updater.ts +836 -0
  230. package/src/usage.ts +77 -0
  231. package/src/watch/preflight.ts +1389 -0
  232. package/src/watch/watch.ts +1235 -0
  233. package/src/wizard.ts +877 -0
@@ -0,0 +1,179 @@
1
+ import path from "node:path";
2
+ import { DiversityTargetError } from "./errors";
3
+ import type { BenchmarkTarget } from "./identity";
4
+
5
+ const ALLOWED_GH_FLAGS = new Set([
6
+ "--repo",
7
+ "--base",
8
+ "--head",
9
+ "--two-dot",
10
+ "--yes",
11
+ "--json",
12
+ ]);
13
+
14
+ export interface ResolvedTargetIdentity {
15
+ readonly repoRoot: string;
16
+ readonly pr: number;
17
+ readonly baseSha: string;
18
+ readonly headSha: string;
19
+ }
20
+
21
+ export interface GhPrViewFields {
22
+ readonly number: number;
23
+ readonly baseRefOid: string;
24
+ readonly headRefOid: string;
25
+ }
26
+
27
+ function assertArgvOnly(command: readonly string[], label: string): void {
28
+ if (
29
+ !Array.isArray(command) ||
30
+ command.some((part) => typeof part !== "string")
31
+ ) {
32
+ throw new DiversityTargetError(`${label} must be an argv string array`);
33
+ }
34
+ if (command.some((part) => part.includes("\0") || part.includes("\n"))) {
35
+ throw new DiversityTargetError(
36
+ `${label} contains forbidden control characters`,
37
+ );
38
+ }
39
+ const joined = command.join(" ");
40
+ if (joined.includes("&&") || joined.includes("|") || joined.includes(";")) {
41
+ throw new DiversityTargetError(
42
+ `${label} must not be a composed shell command`,
43
+ );
44
+ }
45
+ if (command.some((part) => /^\w+=/.test(part))) {
46
+ throw new DiversityTargetError(
47
+ `${label} must not use environment-prefix injection`,
48
+ );
49
+ }
50
+ }
51
+
52
+ export function resolveGitRepositoryRoot(
53
+ selector: string | readonly string[],
54
+ cwd: string,
55
+ ): string {
56
+ if (Array.isArray(selector)) {
57
+ assertArgvOnly(selector, "git selector");
58
+ if (selector[0] !== "git") {
59
+ throw new DiversityTargetError("git selector must start with git");
60
+ }
61
+ if (selector[1] === "-C" && typeof selector[2] === "string") {
62
+ return path.resolve(cwd, selector[2]);
63
+ }
64
+ throw new DiversityTargetError("unsupported git argv selector");
65
+ }
66
+ if (typeof selector !== "string") {
67
+ throw new DiversityTargetError("unsupported git selector type");
68
+ }
69
+ if (path.isAbsolute(selector)) {
70
+ return path.resolve(selector);
71
+ }
72
+ return path.resolve(cwd, selector);
73
+ }
74
+
75
+ export function assertSameRepositoryRoot(
76
+ roots: readonly string[],
77
+ label: string,
78
+ ): string {
79
+ const normalized = roots.map((root) => path.resolve(root));
80
+ const first = normalized[0];
81
+ if (!first) {
82
+ throw new DiversityTargetError(
83
+ `${label} requires at least one repository root`,
84
+ );
85
+ }
86
+ for (const root of normalized.slice(1)) {
87
+ if (root !== first) {
88
+ throw new DiversityTargetError(
89
+ `${label} selectors resolved different repository roots`,
90
+ );
91
+ }
92
+ }
93
+ return first;
94
+ }
95
+
96
+ export function parseGhPrViewArgv(argv: readonly string[]): GhPrViewFields {
97
+ assertArgvOnly(argv, "gh pr view");
98
+ if (argv[0] !== "gh" || argv[1] !== "pr" || argv[2] !== "view") {
99
+ throw new DiversityTargetError("gh argv must be gh pr view");
100
+ }
101
+ for (let i = 3; i < argv.length; i++) {
102
+ const token = argv[i];
103
+ if (!token.startsWith("--")) continue;
104
+ if (!ALLOWED_GH_FLAGS.has(token)) {
105
+ throw new DiversityTargetError(`gh pr view flag not allowed: ${token}`);
106
+ }
107
+ }
108
+ const jsonIndex = argv.indexOf("--json");
109
+ if (jsonIndex === -1) {
110
+ throw new DiversityTargetError("gh pr view requires --json");
111
+ }
112
+ const fields = argv[jsonIndex + 1];
113
+ if (!fields) {
114
+ throw new DiversityTargetError("gh pr view --json requires field list");
115
+ }
116
+ const required = ["number", "baseRefOid", "headRefOid"];
117
+ for (const field of required) {
118
+ if (
119
+ !fields
120
+ .split(",")
121
+ .map((part) => part.trim())
122
+ .includes(field)
123
+ ) {
124
+ throw new DiversityTargetError(
125
+ `gh pr view --json missing field ${field}`,
126
+ );
127
+ }
128
+ }
129
+ return {
130
+ number: 0,
131
+ baseRefOid: "",
132
+ headRefOid: "",
133
+ };
134
+ }
135
+
136
+ export function validateGhPrViewPayload(
137
+ payload: GhPrViewFields,
138
+ frozen: BenchmarkTarget,
139
+ ): ResolvedTargetIdentity {
140
+ if (payload.number !== frozen.pr) {
141
+ throw new DiversityTargetError(
142
+ `gh pr view number ${payload.number} != frozen pr ${frozen.pr}`,
143
+ );
144
+ }
145
+ if (payload.baseRefOid !== frozen.baseSha) {
146
+ throw new DiversityTargetError(
147
+ "gh pr view baseRefOid drift from frozen baseSha",
148
+ );
149
+ }
150
+ if (payload.headRefOid !== frozen.headSha) {
151
+ throw new DiversityTargetError(
152
+ "gh pr view headRefOid drift from frozen headSha",
153
+ );
154
+ }
155
+ return {
156
+ repoRoot: frozen.repoId,
157
+ pr: frozen.pr,
158
+ baseSha: frozen.baseSha,
159
+ headSha: frozen.headSha,
160
+ };
161
+ }
162
+
163
+ export function validateFrozenExternalTarget(
164
+ frozen: BenchmarkTarget,
165
+ observed: BenchmarkTarget,
166
+ ): void {
167
+ if (frozen.repoId !== observed.repoId) {
168
+ throw new DiversityTargetError("frozen repoId drift");
169
+ }
170
+ if (frozen.pr !== observed.pr) {
171
+ throw new DiversityTargetError("frozen pr drift");
172
+ }
173
+ if (frozen.baseSha !== observed.baseSha) {
174
+ throw new DiversityTargetError("frozen baseSha drift");
175
+ }
176
+ if (frozen.headSha !== observed.headSha) {
177
+ throw new DiversityTargetError("frozen headSha drift");
178
+ }
179
+ }
@@ -0,0 +1,209 @@
1
+ // The pr-hero → Crysk rename never moves a user's files. While an old path is
2
+ // still the one being read, `doctor` says so and prints the complete procedure
3
+ // for THIS machine: a bare `mv` is not enough, because the PATH line, the
4
+ // launchd plists and the MCP registrations all hold the old absolute path.
5
+
6
+ import { spawnSync } from "node:child_process";
7
+ import path from "node:path";
8
+ import type { AgentEnvDetection } from "./agent-env";
9
+ import { BIN_NAME } from "./brand";
10
+ import {
11
+ HOME_DIR_NAME,
12
+ homeHasState,
13
+ IGNORE_FILE_NAME,
14
+ LEGACY_HOME_DIR_NAME,
15
+ LEGACY_IGNORE_FILE_NAME,
16
+ LEGACY_REPO_DIR_NAME,
17
+ REPO_DIR_NAME,
18
+ repoDirHasState,
19
+ } from "./brand-paths";
20
+ import type { DoctorCheckItem } from "./doctor";
21
+ import { GC_LAUNCHD_LABEL } from "./store/gc-preflight";
22
+ import { WATCH_LAUNCHD_LABEL } from "./watch/preflight";
23
+
24
+ export type IsTracked = (repoDir: string, relPath: string) => boolean;
25
+
26
+ // `git ls-files` lists the path only when git tracks it. Any failure (not a
27
+ // repo, no git) reads as "not tracked", which gives the plain `mv` advice.
28
+ export const gitIsTracked: IsTracked = (repoDir, relPath) => {
29
+ const r = spawnSync("git", ["-C", repoDir, "ls-files", "--", relPath], {
30
+ encoding: "utf8",
31
+ });
32
+ return r.status === 0 && r.stdout.trim().length > 0;
33
+ };
34
+
35
+ export interface MigrationInput {
36
+ home: string;
37
+ repoDir: string | undefined;
38
+ exists: (p: string) => boolean;
39
+ readFile: (p: string) => string | undefined;
40
+ envs: readonly AgentEnvDetection[];
41
+ platform: string;
42
+ isTracked: IsTracked;
43
+ }
44
+
45
+ const RC_FILES = [
46
+ [".zshrc"],
47
+ [".bashrc"],
48
+ [".bash_profile"],
49
+ [".config", "fish", "config.fish"],
50
+ ];
51
+
52
+ // The steps `mv ~/.prhero ~/.crysk` leaves undone, limited to those that apply
53
+ // to this machine.
54
+ function homeMigrationSteps(input: MigrationInput): string[] {
55
+ const { home, exists, readFile } = input;
56
+ const oldDir = path.join(home, LEGACY_HOME_DIR_NAME);
57
+ const steps = [`mv ~/${LEGACY_HOME_DIR_NAME} ~/${HOME_DIR_NAME}`];
58
+
59
+ // A review worktree under repos/ is registered by absolute path in the
60
+ // repository it came from; after the move git still points at the old path.
61
+ if (exists(path.join(oldDir, "repos"))) {
62
+ steps.push(
63
+ `in each repository whose \`git worktree list\` shows a path under ~/${LEGACY_HOME_DIR_NAME}/repos, run \`git worktree repair\` with that worktree's new path under ~/${HOME_DIR_NAME}/repos (or \`git worktree prune\` to drop it)`,
64
+ );
65
+ }
66
+
67
+ const rcWithOldPath = RC_FILES.map((parts) => path.join(home, ...parts))
68
+ .filter((p) => exists(p))
69
+ .filter((p) => (readFile(p) ?? "").includes(`${LEGACY_HOME_DIR_NAME}/bin`));
70
+ const standalone = exists(path.join(oldDir, "bin", "pr-hero"));
71
+ if (rcWithOldPath.length > 0) {
72
+ const files = rcWithOldPath.map((p) => `~/${path.relative(home, p)}`);
73
+ steps.push(
74
+ `in ${files.join(", ")} change ${LEGACY_HOME_DIR_NAME}/bin to ${HOME_DIR_NAME}/bin (e.g. sed -i.bak 's#\\${LEGACY_HOME_DIR_NAME}/bin#${HOME_DIR_NAME}/bin#' ${files.join(" ")}) and open a new shell`,
75
+ );
76
+ } else if (standalone) {
77
+ steps.push(
78
+ `the standalone binary now lives in ~/${HOME_DIR_NAME}/bin: put that directory on PATH`,
79
+ );
80
+ }
81
+
82
+ // After the move the binary is at its new path; use it by that path so the
83
+ // agents and registrations below record the new location.
84
+ const run = standalone ? `~/${HOME_DIR_NAME}/bin/pr-hero` : BIN_NAME;
85
+ if (input.platform === "darwin") {
86
+ const agentsDir = path.join(home, "Library", "LaunchAgents");
87
+ const installed = (current: string, legacy: string) =>
88
+ exists(path.join(agentsDir, `${current}.plist`)) ||
89
+ exists(path.join(agentsDir, `${legacy}.plist`));
90
+ if (installed(WATCH_LAUNCHD_LABEL, "io.prhero.watch")) {
91
+ steps.push(
92
+ `${run} watch install (re-creates the launchd agent at the new path; pass --interval if you changed it)`,
93
+ );
94
+ }
95
+ if (installed(GC_LAUNCHD_LABEL, "io.prhero.gc")) {
96
+ steps.push(`${run} gc install (same, for the gc agent)`);
97
+ }
98
+ }
99
+ const mcpRegistered = input.envs.some(
100
+ (env) =>
101
+ env.mcpConfigFile !== undefined &&
102
+ (readFile(env.mcpConfigFile) ?? "").includes("pr-hero"),
103
+ );
104
+ if (mcpRegistered) {
105
+ steps.push(`${run} setup (re-registers the MCP server at the new path)`);
106
+ }
107
+ return steps;
108
+ }
109
+
110
+ const numbered = (steps: string[]) =>
111
+ steps.map((s, i) => `${i + 1}) ${s}`).join("; ");
112
+
113
+ export function migrationChecks(input: MigrationInput): DoctorCheckItem[] {
114
+ const { home, repoDir, exists } = input;
115
+ const out: DoctorCheckItem[] = [];
116
+
117
+ // --- home -----------------------------------------------------------
118
+ const newHome = path.join(home, HOME_DIR_NAME);
119
+ const oldHome = path.join(home, LEGACY_HOME_DIR_NAME);
120
+ if (exists(oldHome)) {
121
+ if (exists(newHome) && homeHasState(newHome, exists)) {
122
+ out.push({
123
+ name: "migrate:home",
124
+ severity: "degraded",
125
+ message: `~/${LEGACY_HOME_DIR_NAME} is ignored because ~/${HOME_DIR_NAME} holds Crysk state`,
126
+ hint: `Merge anything you still need into ~/${HOME_DIR_NAME}, then delete ~/${LEGACY_HOME_DIR_NAME}.`,
127
+ });
128
+ } else if (exists(newHome)) {
129
+ out.push({
130
+ name: "migrate:home",
131
+ severity: "degraded",
132
+ message: `~/${HOME_DIR_NAME} exists but holds no Crysk state, so ~/${LEGACY_HOME_DIR_NAME} is still the one in use`,
133
+ hint: `Check ~/${HOME_DIR_NAME} and remove it, then: ${numbered(homeMigrationSteps(input))}. Until then, do not put files in ~/${HOME_DIR_NAME}.`,
134
+ });
135
+ } else {
136
+ out.push({
137
+ name: "migrate:home",
138
+ severity: "degraded",
139
+ message: `~/${LEGACY_HOME_DIR_NAME} is the legacy name; still read for now, but ~/${HOME_DIR_NAME} is the current one`,
140
+ hint: numbered(homeMigrationSteps(input)),
141
+ });
142
+ }
143
+ }
144
+
145
+ if (repoDir === undefined) return out;
146
+
147
+ // --- repo dir and ignore file ---------------------------------------
148
+ const move = (rel: string, to: string, extra: string): string => {
149
+ const tracked = input.isTracked(repoDir, rel);
150
+ return tracked
151
+ ? `git mv ${rel} ${to}, then commit it`
152
+ : `mv ${rel} ${to}${extra}`;
153
+ };
154
+
155
+ const newRepo = path.join(repoDir, REPO_DIR_NAME);
156
+ const oldRepo = path.join(repoDir, LEGACY_REPO_DIR_NAME);
157
+ if (exists(oldRepo)) {
158
+ if (exists(newRepo) && repoDirHasState(newRepo, exists)) {
159
+ out.push({
160
+ name: "migrate:repo",
161
+ severity: "degraded",
162
+ message: `${LEGACY_REPO_DIR_NAME}/ is ignored because ${REPO_DIR_NAME}/ exists`,
163
+ hint: `Merge anything you still need into ${REPO_DIR_NAME}/, then delete ${LEGACY_REPO_DIR_NAME}/.`,
164
+ });
165
+ } else {
166
+ const how = move(
167
+ LEGACY_REPO_DIR_NAME,
168
+ REPO_DIR_NAME,
169
+ `, then add ${REPO_DIR_NAME}/ to .gitignore in place of ${LEGACY_REPO_DIR_NAME}/ (an untracked ${REPO_DIR_NAME}/ makes the working tree dirty)`,
170
+ );
171
+ if (exists(newRepo)) {
172
+ out.push({
173
+ name: "migrate:repo",
174
+ severity: "degraded",
175
+ message: `${REPO_DIR_NAME}/ holds no config.json or gotchas.md, so ${LEGACY_REPO_DIR_NAME}/ is still the one in use`,
176
+ hint: `Remove the empty ${REPO_DIR_NAME}/ first, then: ${how}`,
177
+ });
178
+ } else {
179
+ out.push({
180
+ name: "migrate:repo",
181
+ severity: "degraded",
182
+ message: `${LEGACY_REPO_DIR_NAME}/ is the legacy name; still read for now, but ${REPO_DIR_NAME}/ is the current one`,
183
+ hint: how,
184
+ });
185
+ }
186
+ }
187
+ }
188
+
189
+ const newIgnore = path.join(repoDir, IGNORE_FILE_NAME);
190
+ const oldIgnore = path.join(repoDir, LEGACY_IGNORE_FILE_NAME);
191
+ if (exists(oldIgnore)) {
192
+ out.push(
193
+ exists(newIgnore)
194
+ ? {
195
+ name: "migrate:ignore",
196
+ severity: "degraded",
197
+ message: `${LEGACY_IGNORE_FILE_NAME} is ignored because ${IGNORE_FILE_NAME} exists`,
198
+ hint: `Merge anything you still need into ${IGNORE_FILE_NAME}, then delete ${LEGACY_IGNORE_FILE_NAME}.`,
199
+ }
200
+ : {
201
+ name: "migrate:ignore",
202
+ severity: "degraded",
203
+ message: `${LEGACY_IGNORE_FILE_NAME} is the legacy name; still read for now, but ${IGNORE_FILE_NAME} is the current one`,
204
+ hint: move(LEGACY_IGNORE_FILE_NAME, IGNORE_FILE_NAME, ""),
205
+ },
206
+ );
207
+ }
208
+ return out;
209
+ }