cocheck 0.0.0-stage → 0.4.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 (305) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +104 -2
  3. package/THIRD_PARTY_NOTICES.md +279 -0
  4. package/bin/cocheck.mjs +8 -0
  5. package/dist/agent-transcripts.js +541 -0
  6. package/dist/attribution/basis.js +31 -0
  7. package/dist/attribution/evidence.js +311 -0
  8. package/dist/attribution/hooks/cocheck-preload.cjs +254 -0
  9. package/dist/attribution/hooks/sitecustomize.py +245 -0
  10. package/dist/attribution/names.js +163 -0
  11. package/dist/attribution/reconstruct.js +128 -0
  12. package/dist/attribution/tag.js +246 -0
  13. package/dist/attribution/write-scope-win.js +615 -0
  14. package/dist/attribution/write-scope.js +1668 -0
  15. package/dist/build-info.json +1 -0
  16. package/dist/cli-main.js +8 -0
  17. package/dist/cli.js +193 -0
  18. package/dist/codex-config.js +107 -0
  19. package/dist/connector/after-gap.js +56 -0
  20. package/dist/connector/after-snapshot.js +244 -0
  21. package/dist/connector/before-snapshot.js +168 -0
  22. package/dist/connector/builtins.js +93 -0
  23. package/dist/connector/changes-v1.js +276 -0
  24. package/dist/connector/claimed-state.js +40 -0
  25. package/dist/connector/claimed.js +86 -0
  26. package/dist/connector/conformance.js +458 -0
  27. package/dist/connector/diff-object.js +81 -0
  28. package/dist/connector/diff-samples.js +64 -0
  29. package/dist/connector/diff.js +273 -0
  30. package/dist/connector/doc-level.js +20 -0
  31. package/dist/connector/enabled-types.js +87 -0
  32. package/dist/connector/export-view.js +13 -0
  33. package/dist/connector/file-capture.js +265 -0
  34. package/dist/connector/frozen.js +213 -0
  35. package/dist/connector/installed-manifests.js +72 -0
  36. package/dist/connector/installed-match.js +161 -0
  37. package/dist/connector/local-process.js +119 -0
  38. package/dist/connector/nothing-changed-rule.js +23 -0
  39. package/dist/connector/old-rows.js +66 -0
  40. package/dist/connector/png-pixels.js +4 -0
  41. package/dist/connector/registry.js +78 -0
  42. package/dist/connector/requires.js +30 -0
  43. package/dist/connector/row-doc.js +54 -0
  44. package/dist/connector/run-argv.js +25 -0
  45. package/dist/connector/runner.js +325 -0
  46. package/dist/connector/schema.js +242 -0
  47. package/dist/connector/subject.js +8 -0
  48. package/dist/connector/subjects.js +113 -0
  49. package/dist/connector/validate.js +200 -0
  50. package/dist/connector-auth.js +101 -0
  51. package/dist/connector-create.js +55 -0
  52. package/dist/connector-doctor.js +167 -0
  53. package/dist/connector-test-cli.js +627 -0
  54. package/dist/connector-types-cli.js +43 -0
  55. package/dist/connectors/microsoft-excel/cocheck-connector.json +13 -0
  56. package/dist/connectors/microsoft-excel/connector.mjs +11 -0
  57. package/dist/connectors/microsoft-powerpoint/cocheck-connector.json +13 -0
  58. package/dist/connectors/microsoft-powerpoint/connector.mjs +11 -0
  59. package/dist/connectors/microsoft-word/cocheck-connector.json +13 -0
  60. package/dist/connectors/microsoft-word/connector.mjs +11 -0
  61. package/dist/copies.js +151 -0
  62. package/dist/copilot-helpers.js +246 -0
  63. package/dist/coverage.js +277 -0
  64. package/dist/credit-guard.js +330 -0
  65. package/dist/display.js +78 -0
  66. package/dist/file-lock.js +145 -0
  67. package/dist/fingerprint.js +25 -0
  68. package/dist/formats/files/align.js +84 -0
  69. package/dist/formats/files/csv.js +78 -0
  70. package/dist/formats/files/layer.js +274 -0
  71. package/dist/formats/files/scan.js +86 -0
  72. package/dist/formats/files/textlike.js +21 -0
  73. package/dist/formats/layer.js +48 -0
  74. package/dist/helpers/pdfpages +0 -0
  75. package/dist/home-page.js +173 -0
  76. package/dist/home-perms.js +59 -0
  77. package/dist/hook-adapter.js +3415 -0
  78. package/dist/hook-cli.js +505 -0
  79. package/dist/hook-journal.js +147 -0
  80. package/dist/hook.js +25 -0
  81. package/dist/hosts/claude.js +250 -0
  82. package/dist/hosts/codex-bin-macos.js +2 -0
  83. package/dist/hosts/codex-bin.js +35 -0
  84. package/dist/hosts/codex-trust-probe.js +52 -0
  85. package/dist/hosts/codex-trust.js +46 -0
  86. package/dist/hosts/codex.js +355 -0
  87. package/dist/hosts/copilot.js +236 -0
  88. package/dist/hosts/index.js +52 -0
  89. package/dist/hosts/session-titles.js +327 -0
  90. package/dist/hosts/shared.js +31 -0
  91. package/dist/hosts/types.js +26 -0
  92. package/dist/html.js +4 -0
  93. package/dist/install.js +676 -0
  94. package/dist/items.js +105 -0
  95. package/dist/ledger.js +2097 -0
  96. package/dist/narration.js +202 -0
  97. package/dist/normalize.js +82 -0
  98. package/dist/office/connector/apps.js +34 -0
  99. package/dist/office/connector/docx/layer.js +247 -0
  100. package/dist/office/connector/docx/reader.js +284 -0
  101. package/dist/office/connector/excel/align.js +284 -0
  102. package/dist/office/connector/excel/answer.js +352 -0
  103. package/dist/office/connector/excel/diff.js +1310 -0
  104. package/dist/office/connector/excel/errors.js +44 -0
  105. package/dist/office/connector/excel/look.js +121 -0
  106. package/dist/office/connector/excel/print-boxes.js +432 -0
  107. package/dist/office/connector/excel/print-grid-previous.js +206 -0
  108. package/dist/office/connector/excel/print-setup.js +168 -0
  109. package/dist/office/connector/excel/workbook.js +374 -0
  110. package/dist/office/connector/export-driver.js +9 -0
  111. package/dist/office/connector/helpers/cocheck-screen +0 -0
  112. package/dist/office/connector/issues.js +31 -0
  113. package/dist/office/connector/mac-guard.js +16 -0
  114. package/dist/office/connector/main.js +23 -0
  115. package/dist/office/connector/nothing-changed.js +18 -0
  116. package/dist/office/connector/office-job.js +416 -0
  117. package/dist/office/connector/office-macos.js +473 -0
  118. package/dist/office/connector/office-win-export.js +107 -0
  119. package/dist/office/connector/office-win-lifecycle.js +194 -0
  120. package/dist/office/connector/office-win.js +209 -0
  121. package/dist/office/connector/office-win.ps1 +451 -0
  122. package/dist/office/connector/open-watch.js +46 -0
  123. package/dist/office/connector/pictures.js +156 -0
  124. package/dist/office/connector/pptx/diff.js +589 -0
  125. package/dist/office/connector/pptx/frames.js +105 -0
  126. package/dist/office/connector/pptx/layer.js +148 -0
  127. package/dist/office/connector/pptx/links.js +59 -0
  128. package/dist/office/connector/pptx/reader.js +744 -0
  129. package/dist/office/connector/pptx/spans.js +70 -0
  130. package/dist/office/connector/pptx/tags.js +86 -0
  131. package/dist/office/connector/pptx/xml.js +96 -0
  132. package/dist/office/connector/pptx/zip.js +223 -0
  133. package/dist/office/connector/pptx-boxes.js +238 -0
  134. package/dist/office/connector/print-copy-cap.js +19 -0
  135. package/dist/office/connector/print-copy.js +13 -0
  136. package/dist/office/connector/program.js +291 -0
  137. package/dist/office/connector/reach.js +27 -0
  138. package/dist/office/connector/refusal.js +16 -0
  139. package/dist/office/connector/screen-macos.js +193 -0
  140. package/dist/office/connector/screen-windows.js +34 -0
  141. package/dist/office/connector/shared/chart-diff.js +376 -0
  142. package/dist/office/connector/shared/docprops-noise.js +13 -0
  143. package/dist/office/connector/shared/lock.js +107 -0
  144. package/dist/office/connector/shared/ooxml-names.js +347 -0
  145. package/dist/office/connector/shared/owner.js +57 -0
  146. package/dist/office/connector/shared/package-media.js +703 -0
  147. package/dist/office/connector/shared/preflight.js +226 -0
  148. package/dist/office/connector/shared/structure-check.js +623 -0
  149. package/dist/office/connector/word-boxes.js +364 -0
  150. package/dist/office/connector/word-print-copy.js +234 -0
  151. package/dist/office/connector/xlsx/diff.js +1038 -0
  152. package/dist/office/connector/xlsx/formula.js +410 -0
  153. package/dist/office/connector/xlsx/layer.js +621 -0
  154. package/dist/office/connector/xlsx/memo.js +39 -0
  155. package/dist/office/connector/xlsx/numbers.js +31 -0
  156. package/dist/office/connector/xlsx/numfmt.js +913 -0
  157. package/dist/office/connector/xlsx/parts.js +66 -0
  158. package/dist/office/connector/xlsx/reader.js +394 -0
  159. package/dist/office/connector/xlsx/types.js +20 -0
  160. package/dist/office/connector/xlsx/written.js +446 -0
  161. package/dist/open-pick.js +99 -0
  162. package/dist/patch-secrets.js +194 -0
  163. package/dist/paths.js +65 -0
  164. package/dist/platform/darwin.js +179 -0
  165. package/dist/platform/index.js +61 -0
  166. package/dist/platform/spawn.js +115 -0
  167. package/dist/platform/stub.js +21 -0
  168. package/dist/platform/task-folder.js +41 -0
  169. package/dist/platform/types.js +20 -0
  170. package/dist/platform/win32-docrender.js +7 -0
  171. package/dist/platform/win32.js +265 -0
  172. package/dist/preferences.js +49 -0
  173. package/dist/reason.js +103 -0
  174. package/dist/region-delivery.js +148 -0
  175. package/dist/registry.js +68 -0
  176. package/dist/reveal.js +45 -0
  177. package/dist/review-process.js +154 -0
  178. package/dist/review-refresh-process.js +17 -0
  179. package/dist/review-refresh.js +120 -0
  180. package/dist/review-server.js +2079 -0
  181. package/dist/review-view-server.js +106 -0
  182. package/dist/review.js +8 -0
  183. package/dist/seal.js +315 -0
  184. package/dist/secret-files.js +34 -0
  185. package/dist/secret-hashes.js +27 -0
  186. package/dist/secret-rules.generated.js +3519 -0
  187. package/dist/secret-scan.js +127 -0
  188. package/dist/session-context.js +18 -0
  189. package/dist/signoff.js +419 -0
  190. package/dist/skill.js +110 -0
  191. package/dist/states.js +192 -0
  192. package/dist/tasks.js +1001 -0
  193. package/dist/timeline/attribution.js +207 -0
  194. package/dist/timeline/broken.js +55 -0
  195. package/dist/timeline/describe.js +413 -0
  196. package/dist/timeline/generic.js +195 -0
  197. package/dist/timeline/load.js +464 -0
  198. package/dist/timeline/loading.js +49 -0
  199. package/dist/timeline/notes.js +208 -0
  200. package/dist/timeline/page.js +178 -0
  201. package/dist/timeline/picture.js +303 -0
  202. package/dist/timeline/rail/assets/cocheck-icon.svg +1 -0
  203. package/dist/timeline/rail/assets/files-view.js +198 -0
  204. package/dist/timeline/rail/assets/loaders/icon-intro.json +1 -0
  205. package/dist/timeline/rail/assets/loaders/loader-orbit.json +1 -0
  206. package/dist/timeline/rail/assets/loaders/loader-spin.json +1 -0
  207. package/dist/timeline/rail/assets/review.css +992 -0
  208. package/dist/timeline/rail/assets/review.js +3365 -0
  209. package/dist/timeline/rail/assets/view-table.js +683 -0
  210. package/dist/timeline/rail/failure-line.js +26 -0
  211. package/dist/timeline/rail/files-model.js +45 -0
  212. package/dist/timeline/rail/live.js +49 -0
  213. package/dist/timeline/rail/made-pictures.js +48 -0
  214. package/dist/timeline/rail/mcp-card.js +307 -0
  215. package/dist/timeline/rail/model.js +1317 -0
  216. package/dist/timeline/rail/page.js +167 -0
  217. package/dist/timeline/rail/passes.js +106 -0
  218. package/dist/timeline/rail/regions.js +26 -0
  219. package/dist/timeline/rail/send-back.js +154 -0
  220. package/dist/timeline/rail/stop-status.js +164 -0
  221. package/dist/timeline/read-signal.js +743 -0
  222. package/dist/timeline/render/claimed.js +13 -0
  223. package/dist/timeline/render/fallback.js +36 -0
  224. package/dist/timeline/render/pdf-helper.js +71 -0
  225. package/dist/timeline/render/pdf.js +410 -0
  226. package/dist/timeline/render/pixel-pages.js +168 -0
  227. package/dist/timeline/render/png-crop.js +281 -0
  228. package/dist/timeline/render/registry.js +7 -0
  229. package/dist/timeline/render/text.js +366 -0
  230. package/dist/timeline/render/types.js +1 -0
  231. package/dist/timeline/render/view-v1.js +148 -0
  232. package/dist/timeline/render/whole.js +6 -0
  233. package/dist/timeline/rollout-failures.js +40 -0
  234. package/dist/timeline/runs.js +836 -0
  235. package/dist/timeline/stored-image.js +34 -0
  236. package/dist/timeline/subject-display.js +44 -0
  237. package/dist/timeline/timeline.js +1114 -0
  238. package/dist/timeline/write-signal.js +403 -0
  239. package/dist/tool-label.js +201 -0
  240. package/dist/tracking.js +87 -0
  241. package/dist/vendor/pdfjs/LICENSE +177 -0
  242. package/dist/vendor/pdfjs/pdf.min.mjs +27 -0
  243. package/dist/vendor/pdfjs/pdf.worker.min.mjs +27 -0
  244. package/package.json +66 -4
  245. package/public-kit/GUIDE.md +189 -0
  246. package/public-kit/README.md +10 -0
  247. package/public-kit/conformance/README.md +13 -0
  248. package/public-kit/conformance/cases/C1.json +12 -0
  249. package/public-kit/conformance/cases/C10.json +15 -0
  250. package/public-kit/conformance/cases/C11.json +16 -0
  251. package/public-kit/conformance/cases/C12.json +18 -0
  252. package/public-kit/conformance/cases/C13.json +23 -0
  253. package/public-kit/conformance/cases/C14.json +16 -0
  254. package/public-kit/conformance/cases/C16.json +15 -0
  255. package/public-kit/conformance/cases/C17.json +25 -0
  256. package/public-kit/conformance/cases/C2.json +13 -0
  257. package/public-kit/conformance/cases/C3.json +44 -0
  258. package/public-kit/conformance/cases/C4.json +13 -0
  259. package/public-kit/conformance/cases/C5.json +16 -0
  260. package/public-kit/conformance/cases/C6.json +58 -0
  261. package/public-kit/conformance/generate-large.mjs +15 -0
  262. package/public-kit/examples/toy-export/cocheck-connector.json +10 -0
  263. package/public-kit/examples/toy-export/connector.mjs +28 -0
  264. package/public-kit/examples/toy-helpers/cocheck-connector.json +10 -0
  265. package/public-kit/examples/toy-helpers/connector.mjs +69 -0
  266. package/public-kit/examples/toy-level-1/cocheck-connector.json +10 -0
  267. package/public-kit/examples/toy-level-1/connector.mjs +61 -0
  268. package/public-kit/examples/toy-level-3/cocheck-connector.json +10 -0
  269. package/public-kit/examples/toy-level-3/connector.mjs +82 -0
  270. package/public-kit/examples/toy-tracker/cocheck-connector.json +14 -0
  271. package/public-kit/examples/toy-tracker/connector.mjs +46 -0
  272. package/public-kit/examples/toy-tracker/samples/history.json +10 -0
  273. package/public-kit/examples/toy-tracker/samples/samples.json +7 -0
  274. package/public-kit/examples/toy-vendor/cocheck-connector.json +15 -0
  275. package/public-kit/examples/toy-vendor/connector.mjs +62 -0
  276. package/public-kit/helpers/pdf-text-layout.d.mts +35 -0
  277. package/public-kit/helpers/pdf-text-layout.mjs +602 -0
  278. package/public-kit/helpers/pdf-text.d.mts +56 -0
  279. package/public-kit/helpers/pdf-text.mjs +375 -0
  280. package/public-kit/helpers/pdf.d.mts +61 -0
  281. package/public-kit/helpers/pdf.mjs +251 -0
  282. package/public-kit/helpers/png.d.mts +15 -0
  283. package/public-kit/helpers/png.mjs +88 -0
  284. package/public-kit/helpers/spec.d.mts +4 -0
  285. package/public-kit/helpers/spec.mjs +2 -0
  286. package/public-kit/scaffold/README.md +23 -0
  287. package/public-kit/scaffold/template/README.md +13 -0
  288. package/public-kit/scaffold/template/cocheck-connector.json +10 -0
  289. package/public-kit/scaffold/template/connector.mjs +50 -0
  290. package/public-kit/spec/README.md +408 -0
  291. package/public-kit/spec/v1.md +598 -0
  292. package/public-kit/toy-product/README.md +7 -0
  293. package/public-kit/toy-product/notes-store.mjs +30 -0
  294. package/public-kit/toy-product/states/create.after.json +16 -0
  295. package/public-kit/toy-product/states/create.before.json +12 -0
  296. package/public-kit/toy-product/states/delete.after.json +8 -0
  297. package/public-kit/toy-product/states/delete.before.json +12 -0
  298. package/public-kit/toy-product/states/edit.after.json +12 -0
  299. package/public-kit/toy-product/states/edit.before.json +12 -0
  300. package/public-kit/toy-product/states/malformed.after.json +1 -0
  301. package/public-kit/toy-product/states/malformed.before.json +12 -0
  302. package/public-kit/toy-product/states/no-change.after.json +12 -0
  303. package/public-kit/toy-product/states/no-change.before.json +12 -0
  304. package/scripts/hook-launch.mjs +58 -0
  305. package/scripts/hook-launch.sh +52 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy oat milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1 @@
1
+ { "notes": [ { "id": "n1", "text": "buy milk"
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "notes": [
3
+ {
4
+ "id": "n1",
5
+ "text": "buy milk"
6
+ },
7
+ {
8
+ "id": "n2",
9
+ "text": "call the plumber"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,58 @@
1
+ // The Windows twin of scripts/hook-launch.sh. The host runs `node hook-launch.mjs COCHECK_MANAGED=1 --home <dir> [--node <path>] <hook.js> [hook args]`
2
+ // with the payload on stdin, so no /bin/sh is needed; cmd and PowerShell both start `node` and read the double-quoted paths the same way.
3
+ // Same contract as the shell launcher: stdin, stdout and the exit status pass through; stderr is captured and re-emitted. On a non-zero exit it
4
+ // writes the reason to <home>/not-recording.txt (the same wording), and the next hook that exits 0 deletes the file.
5
+ // Bound: "Node was not found" is not handled here. This file runs under Node, so when the host cannot start `node` nothing of CoCheck runs
6
+ // and nothing can be written; `cocheck status` shows that case as a stale last-recorded time instead.
7
+ import { spawnSync } from "node:child_process";
8
+ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
9
+ import path from "node:path";
10
+
11
+ const args = process.argv.slice(2);
12
+ const env = { ...process.env };
13
+ let home = env.COCHECK_HOME ?? "";
14
+ let pinned = env.COCHECK_NODE ?? "";
15
+ for (;;) {
16
+ const a = args[0];
17
+ if (a === "COCHECK_MANAGED=1") env.COCHECK_MANAGED = "1";
18
+ else if (a === "--home" && args.length > 1) {
19
+ home = args[1];
20
+ args.shift();
21
+ } else if (a === "--node" && args.length > 1) {
22
+ pinned = args[1];
23
+ args.shift();
24
+ } else break;
25
+ args.shift();
26
+ }
27
+ env.COCHECK_HOME = home;
28
+ if (pinned !== "") env.COCHECK_NODE = pinned;
29
+ const note = home === "" ? "" : path.join(home, "not-recording.txt");
30
+
31
+ function record(text) {
32
+ if (note === "") return;
33
+ try {
34
+ mkdirSync(home, { recursive: true });
35
+ writeFileSync(note, `${new Date().toISOString().replace(/\.\d+Z$/, "Z")}\n${text}\n`);
36
+ } catch {
37
+ // best effort, like the shell launcher
38
+ }
39
+ }
40
+
41
+ const hook = args.shift();
42
+ if (hook === undefined) {
43
+ process.stderr.write("usage: hook-launch.mjs [COCHECK_MANAGED=1] [--home <dir>] [--node <path>] <hook.js> [hook args]\n");
44
+ process.exit(1);
45
+ }
46
+ const node = pinned !== "" && existsSync(pinned) ? pinned : process.execPath;
47
+ const r = spawnSync(node, [hook, ...args], { env, stdio: ["inherit", "inherit", "pipe"], encoding: "utf8" });
48
+ const err = r.stderr ?? "";
49
+ const status = r.status ?? 1;
50
+ if (r.error !== undefined || status !== 0) {
51
+ const why = r.error !== undefined ? `could not start the hook: ${r.error.message}` : "";
52
+ const version = spawnSync(node, ["--version"], { encoding: "utf8" }).stdout?.trim();
53
+ record(`The hook exited ${status} under Node ${version || "unknown"} (CoCheck needs 22.18 or newer): ${why || err.slice(-400)}`);
54
+ if (err !== "") process.stderr.write(err.endsWith("\n") ? err : `${err}\n`);
55
+ process.exit(status);
56
+ }
57
+ if (note !== "") rmSync(note, { force: true });
58
+ if (err !== "") process.stderr.write(err.endsWith("\n") ? err : `${err}\n`);
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ # The command Claude Code runs for every CoCheck hook event: `sh hook-launch.sh <hook.js> [hook args]`, payload on stdin.
3
+ # It finds Node when the hook fires, not when CoCheck was installed, so a Node upgrade (a new Homebrew Cellar path) cannot leave the
4
+ # hook pointing at a binary that is gone. When the hook cannot record (no Node, or the hook exits non-zero) it writes the reason to
5
+ # <COCHECK_HOME>/not-recording.txt, which `cocheck status` and `cocheck open` print; the next hook that does record deletes the file.
6
+ # Node is taken from, in order: COCHECK_NODE (the Homebrew wrapper's stable opt/node path, recorded in the hook command), PATH, then
7
+ # COCHECK_NODE_SEARCH (space separated), default Homebrew's stable opt/node paths and the plain Homebrew and nodejs.org locations.
8
+ # Last of all, the Node the installer resolved, recorded in <COCHECK_HOME>/installed-node.txt, so a Node from nvm, volta or fnm still runs
9
+ # under a host started with a minimal PATH. PATH and the locations above win; a recorded Node that is gone falls through to "not found".
10
+ # It adds no Node start on the success path. Exit status, stdout and stderr of the hook pass through unchanged.
11
+ hook="$1"
12
+ shift
13
+ home="${COCHECK_HOME:-}"
14
+ note="$home/not-recording.txt"
15
+
16
+ record() {
17
+ [ -n "$home" ] || return 0
18
+ mkdir -p "$home" 2>/dev/null || return 0
19
+ { printf '%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)"; printf '%s\n' "$1"; } >"$note" 2>/dev/null || true
20
+ }
21
+
22
+ node=
23
+ if [ -n "${COCHECK_NODE:-}" ] && [ -x "$COCHECK_NODE" ]; then node=$COCHECK_NODE; fi
24
+ [ -n "$node" ] || node=$(command -v node 2>/dev/null)
25
+ if [ -z "$node" ] || [ ! -x "$node" ]; then
26
+ node=
27
+ for candidate in ${COCHECK_NODE_SEARCH:-/opt/homebrew/opt/node/bin/node /usr/local/opt/node/bin/node /opt/homebrew/bin/node /usr/local/bin/node}; do
28
+ if [ -x "$candidate" ]; then node=$candidate; break; fi
29
+ done
30
+ fi
31
+ if [ -z "$node" ] && [ -n "$home" ] && [ -r "$home/installed-node.txt" ]; then
32
+ IFS= read -r candidate <"$home/installed-node.txt" 2>/dev/null
33
+ if [ -n "$candidate" ] && [ -x "$candidate" ]; then node=$candidate; fi
34
+ fi
35
+ if [ -z "$node" ]; then
36
+ record "Node was not found. CoCheck needs Node 22.18 or newer (install it from nodejs.org), then restart Claude Code."
37
+ echo "CoCheck: Node was not found, so this tool call was not recorded." >&2
38
+ exit 1
39
+ fi
40
+
41
+ # The hook's stdout passes straight through (fd 3): it is empty except for the UserPromptSubmit context text. Its stderr is captured.
42
+ { err=$("$node" "$hook" "$@" 2>&1 1>&3 3>&-); status=$?; } 3>&1
43
+ if [ "$status" -ne 0 ]; then
44
+ version=$("$node" --version 2>/dev/null)
45
+ tail=$(printf '%s' "$err" | tail -c 400)
46
+ record "The hook exited $status under Node ${version:-unknown} (CoCheck needs 22.18 or newer): $tail"
47
+ [ -n "$err" ] && printf '%s\n' "$err" >&2
48
+ exit "$status"
49
+ fi
50
+ [ -n "$home" ] && [ -e "$note" ] && rm -f "$note"
51
+ [ -n "$err" ] && printf '%s\n' "$err" >&2
52
+ exit 0