@afaik-lab/weigh 0.0.0 → 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 (349) hide show
  1. package/.env.example +49 -0
  2. package/LICENSE +373 -0
  3. package/README.md +103 -1
  4. package/dist/agent.d.ts +83 -0
  5. package/dist/agent.d.ts.map +1 -0
  6. package/dist/agent.js +204 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/ceilings.d.ts +32 -0
  9. package/dist/ceilings.d.ts.map +1 -0
  10. package/dist/ceilings.js +61 -0
  11. package/dist/ceilings.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +530 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/config-cli.d.ts +15 -0
  17. package/dist/config-cli.d.ts.map +1 -0
  18. package/dist/config-cli.js +141 -0
  19. package/dist/config-cli.js.map +1 -0
  20. package/dist/config.d.ts +198 -0
  21. package/dist/config.d.ts.map +1 -0
  22. package/dist/config.js +373 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/context-cli.d.ts +35 -0
  25. package/dist/context-cli.d.ts.map +1 -0
  26. package/dist/context-cli.js +251 -0
  27. package/dist/context-cli.js.map +1 -0
  28. package/dist/context.d.ts +118 -0
  29. package/dist/context.d.ts.map +1 -0
  30. package/dist/context.js +159 -0
  31. package/dist/context.js.map +1 -0
  32. package/dist/corrections/correction-set.d.ts +67 -0
  33. package/dist/corrections/correction-set.d.ts.map +1 -0
  34. package/dist/corrections/correction-set.js +104 -0
  35. package/dist/corrections/correction-set.js.map +1 -0
  36. package/dist/corrections/correction.d.ts +74 -0
  37. package/dist/corrections/correction.d.ts.map +1 -0
  38. package/dist/corrections/correction.js +154 -0
  39. package/dist/corrections/correction.js.map +1 -0
  40. package/dist/corrections/follow-up.d.ts +69 -0
  41. package/dist/corrections/follow-up.d.ts.map +1 -0
  42. package/dist/corrections/follow-up.js +217 -0
  43. package/dist/corrections/follow-up.js.map +1 -0
  44. package/dist/corrections/index.d.ts +31 -0
  45. package/dist/corrections/index.d.ts.map +1 -0
  46. package/dist/corrections/index.js +31 -0
  47. package/dist/corrections/index.js.map +1 -0
  48. package/dist/corrections/ledger.d.ts +78 -0
  49. package/dist/corrections/ledger.d.ts.map +1 -0
  50. package/dist/corrections/ledger.js +117 -0
  51. package/dist/corrections/ledger.js.map +1 -0
  52. package/dist/corrections/promotion.d.ts +119 -0
  53. package/dist/corrections/promotion.d.ts.map +1 -0
  54. package/dist/corrections/promotion.js +221 -0
  55. package/dist/corrections/promotion.js.map +1 -0
  56. package/dist/corrections/schema.d.ts +125 -0
  57. package/dist/corrections/schema.d.ts.map +1 -0
  58. package/dist/corrections/schema.js +100 -0
  59. package/dist/corrections/schema.js.map +1 -0
  60. package/dist/corrections-cli.d.ts +28 -0
  61. package/dist/corrections-cli.d.ts.map +1 -0
  62. package/dist/corrections-cli.js +157 -0
  63. package/dist/corrections-cli.js.map +1 -0
  64. package/dist/diff.d.ts +105 -0
  65. package/dist/diff.d.ts.map +1 -0
  66. package/dist/diff.js +202 -0
  67. package/dist/diff.js.map +1 -0
  68. package/dist/doctor.d.ts +38 -0
  69. package/dist/doctor.d.ts.map +1 -0
  70. package/dist/doctor.js +197 -0
  71. package/dist/doctor.js.map +1 -0
  72. package/dist/events.d.ts +21 -0
  73. package/dist/events.d.ts.map +1 -0
  74. package/dist/events.js +5 -0
  75. package/dist/events.js.map +1 -0
  76. package/dist/findings.d.ts +510 -0
  77. package/dist/findings.d.ts.map +1 -0
  78. package/dist/findings.js +645 -0
  79. package/dist/findings.js.map +1 -0
  80. package/dist/follow-up-cli.d.ts +88 -0
  81. package/dist/follow-up-cli.d.ts.map +1 -0
  82. package/dist/follow-up-cli.js +208 -0
  83. package/dist/follow-up-cli.js.map +1 -0
  84. package/dist/harness.d.ts +64 -0
  85. package/dist/harness.d.ts.map +1 -0
  86. package/dist/harness.js +71 -0
  87. package/dist/harness.js.map +1 -0
  88. package/dist/help/command-help.d.ts +9 -0
  89. package/dist/help/command-help.d.ts.map +1 -0
  90. package/dist/help/command-help.js +21 -0
  91. package/dist/help/command-help.js.map +1 -0
  92. package/dist/help/commands/answer.d.ts +3 -0
  93. package/dist/help/commands/answer.d.ts.map +1 -0
  94. package/dist/help/commands/answer.js +39 -0
  95. package/dist/help/commands/answer.js.map +1 -0
  96. package/dist/help/commands/config.d.ts +3 -0
  97. package/dist/help/commands/config.d.ts.map +1 -0
  98. package/dist/help/commands/config.js +25 -0
  99. package/dist/help/commands/config.js.map +1 -0
  100. package/dist/help/commands/context.d.ts +3 -0
  101. package/dist/help/commands/context.d.ts.map +1 -0
  102. package/dist/help/commands/context.js +44 -0
  103. package/dist/help/commands/context.js.map +1 -0
  104. package/dist/help/commands/corrections.d.ts +3 -0
  105. package/dist/help/commands/corrections.d.ts.map +1 -0
  106. package/dist/help/commands/corrections.js +30 -0
  107. package/dist/help/commands/corrections.js.map +1 -0
  108. package/dist/help/commands/doctor.d.ts +3 -0
  109. package/dist/help/commands/doctor.d.ts.map +1 -0
  110. package/dist/help/commands/doctor.js +12 -0
  111. package/dist/help/commands/doctor.js.map +1 -0
  112. package/dist/help/commands/index.d.ts +4 -0
  113. package/dist/help/commands/index.d.ts.map +1 -0
  114. package/dist/help/commands/index.js +27 -0
  115. package/dist/help/commands/index.js.map +1 -0
  116. package/dist/help/commands/memory.d.ts +3 -0
  117. package/dist/help/commands/memory.d.ts.map +1 -0
  118. package/dist/help/commands/memory.js +33 -0
  119. package/dist/help/commands/memory.js.map +1 -0
  120. package/dist/help/commands/models.d.ts +3 -0
  121. package/dist/help/commands/models.d.ts.map +1 -0
  122. package/dist/help/commands/models.js +17 -0
  123. package/dist/help/commands/models.js.map +1 -0
  124. package/dist/help/commands/options.d.ts +4 -0
  125. package/dist/help/commands/options.d.ts.map +1 -0
  126. package/dist/help/commands/options.js +13 -0
  127. package/dist/help/commands/options.js.map +1 -0
  128. package/dist/help/commands/review.d.ts +3 -0
  129. package/dist/help/commands/review.d.ts.map +1 -0
  130. package/dist/help/commands/review.js +50 -0
  131. package/dist/help/commands/review.js.map +1 -0
  132. package/dist/help/commands/sessions.d.ts +3 -0
  133. package/dist/help/commands/sessions.d.ts.map +1 -0
  134. package/dist/help/commands/sessions.js +23 -0
  135. package/dist/help/commands/sessions.js.map +1 -0
  136. package/dist/help/commands/show.d.ts +3 -0
  137. package/dist/help/commands/show.d.ts.map +1 -0
  138. package/dist/help/commands/show.js +18 -0
  139. package/dist/help/commands/show.js.map +1 -0
  140. package/dist/help/help.d.ts +16 -0
  141. package/dist/help/help.d.ts.map +1 -0
  142. package/dist/help/help.js +68 -0
  143. package/dist/help/help.js.map +1 -0
  144. package/dist/help/index.d.ts +4 -0
  145. package/dist/help/index.d.ts.map +1 -0
  146. package/dist/help/index.js +7 -0
  147. package/dist/help/index.js.map +1 -0
  148. package/dist/index.d.ts +80 -0
  149. package/dist/index.d.ts.map +1 -0
  150. package/dist/index.js +51 -0
  151. package/dist/index.js.map +1 -0
  152. package/dist/knowledge/block.d.ts +65 -0
  153. package/dist/knowledge/block.d.ts.map +1 -0
  154. package/dist/knowledge/block.js +89 -0
  155. package/dist/knowledge/block.js.map +1 -0
  156. package/dist/knowledge/claim.d.ts +143 -0
  157. package/dist/knowledge/claim.d.ts.map +1 -0
  158. package/dist/knowledge/claim.js +303 -0
  159. package/dist/knowledge/claim.js.map +1 -0
  160. package/dist/knowledge/index.d.ts +32 -0
  161. package/dist/knowledge/index.d.ts.map +1 -0
  162. package/dist/knowledge/index.js +29 -0
  163. package/dist/knowledge/index.js.map +1 -0
  164. package/dist/knowledge/novelty.d.ts +65 -0
  165. package/dist/knowledge/novelty.d.ts.map +1 -0
  166. package/dist/knowledge/novelty.js +100 -0
  167. package/dist/knowledge/novelty.js.map +1 -0
  168. package/dist/knowledge/recall.d.ts +134 -0
  169. package/dist/knowledge/recall.d.ts.map +1 -0
  170. package/dist/knowledge/recall.js +229 -0
  171. package/dist/knowledge/recall.js.map +1 -0
  172. package/dist/knowledge/recalled-claim.d.ts +35 -0
  173. package/dist/knowledge/recalled-claim.d.ts.map +1 -0
  174. package/dist/knowledge/recalled-claim.js +67 -0
  175. package/dist/knowledge/recalled-claim.js.map +1 -0
  176. package/dist/knowledge/recalled.d.ts +70 -0
  177. package/dist/knowledge/recalled.d.ts.map +1 -0
  178. package/dist/knowledge/recalled.js +149 -0
  179. package/dist/knowledge/recalled.js.map +1 -0
  180. package/dist/knowledge/schema.d.ts +83 -0
  181. package/dist/knowledge/schema.d.ts.map +1 -0
  182. package/dist/knowledge/schema.js +96 -0
  183. package/dist/knowledge/schema.js.map +1 -0
  184. package/dist/knowledge/staleness.d.ts +48 -0
  185. package/dist/knowledge/staleness.d.ts.map +1 -0
  186. package/dist/knowledge/staleness.js +85 -0
  187. package/dist/knowledge/staleness.js.map +1 -0
  188. package/dist/knowledge/store.d.ts +100 -0
  189. package/dist/knowledge/store.d.ts.map +1 -0
  190. package/dist/knowledge/store.js +184 -0
  191. package/dist/knowledge/store.js.map +1 -0
  192. package/dist/memory/compose-file.d.ts +14 -0
  193. package/dist/memory/compose-file.d.ts.map +1 -0
  194. package/dist/memory/compose-file.js +25 -0
  195. package/dist/memory/compose-file.js.map +1 -0
  196. package/dist/memory/index.d.ts +43 -0
  197. package/dist/memory/index.d.ts.map +1 -0
  198. package/dist/memory/index.js +119 -0
  199. package/dist/memory/index.js.map +1 -0
  200. package/dist/memory/oss.d.ts +62 -0
  201. package/dist/memory/oss.d.ts.map +1 -0
  202. package/dist/memory/oss.js +230 -0
  203. package/dist/memory/oss.js.map +1 -0
  204. package/dist/memory/platform.d.ts +37 -0
  205. package/dist/memory/platform.d.ts.map +1 -0
  206. package/dist/memory/platform.js +131 -0
  207. package/dist/memory/platform.js.map +1 -0
  208. package/dist/memory/scope.d.ts +49 -0
  209. package/dist/memory/scope.d.ts.map +1 -0
  210. package/dist/memory/scope.js +70 -0
  211. package/dist/memory/scope.js.map +1 -0
  212. package/dist/memory/types.d.ts +113 -0
  213. package/dist/memory/types.d.ts.map +1 -0
  214. package/dist/memory/types.js +18 -0
  215. package/dist/memory/types.js.map +1 -0
  216. package/dist/memory-cli.d.ts +17 -0
  217. package/dist/memory-cli.d.ts.map +1 -0
  218. package/dist/memory-cli.js +107 -0
  219. package/dist/memory-cli.js.map +1 -0
  220. package/dist/models-cli.d.ts +12 -0
  221. package/dist/models-cli.d.ts.map +1 -0
  222. package/dist/models-cli.js +54 -0
  223. package/dist/models-cli.js.map +1 -0
  224. package/dist/models.d.ts +111 -0
  225. package/dist/models.d.ts.map +1 -0
  226. package/dist/models.js +228 -0
  227. package/dist/models.js.map +1 -0
  228. package/dist/paths.d.ts +35 -0
  229. package/dist/paths.d.ts.map +1 -0
  230. package/dist/paths.js +65 -0
  231. package/dist/paths.js.map +1 -0
  232. package/dist/profile.d.ts +28 -0
  233. package/dist/profile.d.ts.map +1 -0
  234. package/dist/profile.js +154 -0
  235. package/dist/profile.js.map +1 -0
  236. package/dist/progress.d.ts +70 -0
  237. package/dist/progress.d.ts.map +1 -0
  238. package/dist/progress.js +132 -0
  239. package/dist/progress.js.map +1 -0
  240. package/dist/quiet.d.ts +2 -0
  241. package/dist/quiet.d.ts.map +1 -0
  242. package/dist/quiet.js +21 -0
  243. package/dist/quiet.js.map +1 -0
  244. package/dist/reconcile/continuation.d.ts +132 -0
  245. package/dist/reconcile/continuation.d.ts.map +1 -0
  246. package/dist/reconcile/continuation.js +306 -0
  247. package/dist/reconcile/continuation.js.map +1 -0
  248. package/dist/reconcile/index.d.ts +26 -0
  249. package/dist/reconcile/index.d.ts.map +1 -0
  250. package/dist/reconcile/index.js +28 -0
  251. package/dist/reconcile/index.js.map +1 -0
  252. package/dist/reconcile/outcome-set.d.ts +53 -0
  253. package/dist/reconcile/outcome-set.d.ts.map +1 -0
  254. package/dist/reconcile/outcome-set.js +124 -0
  255. package/dist/reconcile/outcome-set.js.map +1 -0
  256. package/dist/reconcile/outcome.d.ts +56 -0
  257. package/dist/reconcile/outcome.d.ts.map +1 -0
  258. package/dist/reconcile/outcome.js +60 -0
  259. package/dist/reconcile/outcome.js.map +1 -0
  260. package/dist/reconcile/reconciliation.d.ts +49 -0
  261. package/dist/reconcile/reconciliation.d.ts.map +1 -0
  262. package/dist/reconcile/reconciliation.js +88 -0
  263. package/dist/reconcile/reconciliation.js.map +1 -0
  264. package/dist/reconcile/schema.d.ts +157 -0
  265. package/dist/reconcile/schema.d.ts.map +1 -0
  266. package/dist/reconcile/schema.js +97 -0
  267. package/dist/reconcile/schema.js.map +1 -0
  268. package/dist/record/index.d.ts +23 -0
  269. package/dist/record/index.d.ts.map +1 -0
  270. package/dist/record/index.js +25 -0
  271. package/dist/record/index.js.map +1 -0
  272. package/dist/record/review-record.d.ts +28 -0
  273. package/dist/record/review-record.d.ts.map +1 -0
  274. package/dist/record/review-record.js +78 -0
  275. package/dist/record/review-record.js.map +1 -0
  276. package/dist/record/schema.d.ts +153 -0
  277. package/dist/record/schema.d.ts.map +1 -0
  278. package/dist/record/schema.js +87 -0
  279. package/dist/record/schema.js.map +1 -0
  280. package/dist/record/store.d.ts +83 -0
  281. package/dist/record/store.d.ts.map +1 -0
  282. package/dist/record/store.js +162 -0
  283. package/dist/record/store.js.map +1 -0
  284. package/dist/record/stored-review.d.ts +36 -0
  285. package/dist/record/stored-review.d.ts.map +1 -0
  286. package/dist/record/stored-review.js +90 -0
  287. package/dist/record/stored-review.js.map +1 -0
  288. package/dist/refute.d.ts +318 -0
  289. package/dist/refute.d.ts.map +1 -0
  290. package/dist/refute.js +513 -0
  291. package/dist/refute.js.map +1 -0
  292. package/dist/render.d.ts +212 -0
  293. package/dist/render.d.ts.map +1 -0
  294. package/dist/render.js +544 -0
  295. package/dist/render.js.map +1 -0
  296. package/dist/review-cli.d.ts +181 -0
  297. package/dist/review-cli.d.ts.map +1 -0
  298. package/dist/review-cli.js +598 -0
  299. package/dist/review-cli.js.map +1 -0
  300. package/dist/reviewer.d.ts +297 -0
  301. package/dist/reviewer.d.ts.map +1 -0
  302. package/dist/reviewer.js +584 -0
  303. package/dist/reviewer.js.map +1 -0
  304. package/dist/session-cli.d.ts +17 -0
  305. package/dist/session-cli.d.ts.map +1 -0
  306. package/dist/session-cli.js +62 -0
  307. package/dist/session-cli.js.map +1 -0
  308. package/dist/session.d.ts +36 -0
  309. package/dist/session.d.ts.map +1 -0
  310. package/dist/session.js +105 -0
  311. package/dist/session.js.map +1 -0
  312. package/dist/settings.d.ts +68 -0
  313. package/dist/settings.d.ts.map +1 -0
  314. package/dist/settings.js +175 -0
  315. package/dist/settings.js.map +1 -0
  316. package/dist/show-cli.d.ts +39 -0
  317. package/dist/show-cli.d.ts.map +1 -0
  318. package/dist/show-cli.js +56 -0
  319. package/dist/show-cli.js.map +1 -0
  320. package/dist/stdout.d.ts +28 -0
  321. package/dist/stdout.d.ts.map +1 -0
  322. package/dist/stdout.js +44 -0
  323. package/dist/stdout.js.map +1 -0
  324. package/dist/target.d.ts +58 -0
  325. package/dist/target.d.ts.map +1 -0
  326. package/dist/target.js +96 -0
  327. package/dist/target.js.map +1 -0
  328. package/dist/tools/index.d.ts +93 -0
  329. package/dist/tools/index.d.ts.map +1 -0
  330. package/dist/tools/index.js +146 -0
  331. package/dist/tools/index.js.map +1 -0
  332. package/dist/tools/root.d.ts +62 -0
  333. package/dist/tools/root.d.ts.map +1 -0
  334. package/dist/tools/root.js +51 -0
  335. package/dist/tools/root.js.map +1 -0
  336. package/dist/usage.d.ts +75 -0
  337. package/dist/usage.d.ts.map +1 -0
  338. package/dist/usage.js +100 -0
  339. package/dist/usage.js.map +1 -0
  340. package/dist/version.d.ts +14 -0
  341. package/dist/version.d.ts.map +1 -0
  342. package/dist/version.js +26 -0
  343. package/dist/version.js.map +1 -0
  344. package/dist/workspace.d.ts +48 -0
  345. package/dist/workspace.d.ts.map +1 -0
  346. package/dist/workspace.js +126 -0
  347. package/dist/workspace.js.map +1 -0
  348. package/docker-compose.yml +61 -0
  349. package/package.json +72 -1
package/dist/diff.js ADDED
@@ -0,0 +1,202 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ import parseDiff from 'parse-diff';
5
+ import { spawnSync } from 'child_process';
6
+ function git(cwd, args) {
7
+ const proc = spawnSync('git', args, { cwd, encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 });
8
+ return { ok: proc.status === 0, out: proc.stdout ?? '', err: (proc.stderr ?? '').trim() };
9
+ }
10
+ /**
11
+ * Diff options that keep a reviewed repository from running code.
12
+ *
13
+ * `.gitattributes` can route a path through a textconv or an external diff
14
+ * command, which git would then execute while we are only trying to read a
15
+ * patch. Both are refused. `--find-renames` is what turns a delete-plus-add
16
+ * pair into one reviewable rename.
17
+ */
18
+ const SAFE_DIFF = ['--no-ext-diff', '--no-textconv', '--no-color', '--find-renames'];
19
+ /**
20
+ * The branch this work would merge into.
21
+ *
22
+ * origin/HEAD is the honest answer when it exists — it is what the remote says
23
+ * its default branch is. The rest is a guess, so the guess is narrow and its
24
+ * failure is a clear message rather than an empty diff.
25
+ */
26
+ export function defaultBase(root) {
27
+ const symbolic = git(root, ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD']);
28
+ if (symbolic.ok && symbolic.out.trim())
29
+ return symbolic.out.trim();
30
+ for (const candidate of ['origin/main', 'origin/master', 'main', 'master']) {
31
+ if (git(root, ['rev-parse', '--verify', '--quiet', `${candidate}^{commit}`]).ok)
32
+ return candidate;
33
+ }
34
+ throw new Error('Could not determine a base branch (no origin/HEAD, main or master). Pass --base explicitly.');
35
+ }
36
+ /** What is in the working tree but not yet in a commit. */
37
+ export function workingState(root) {
38
+ const staged = [];
39
+ const unstaged = [];
40
+ const untracked = [];
41
+ // -z keeps paths with spaces or quotes intact, which the porcelain format
42
+ // would otherwise escape and we would have to unescape.
43
+ const status = git(root, ['status', '--porcelain=v1', '-z', '--untracked-files=all']);
44
+ const fields = status.out.split('\0').filter(Boolean);
45
+ for (let i = 0; i < fields.length; i++) {
46
+ const entry = fields[i];
47
+ const code = entry.slice(0, 2);
48
+ const path = entry.slice(3);
49
+ if (code === '??') {
50
+ untracked.push(path);
51
+ continue;
52
+ }
53
+ // A rename entry is followed by its source path as a separate field.
54
+ if (code[0] === 'R' || code[0] === 'C')
55
+ i++;
56
+ if (code[0] !== ' ' && code[0] !== '?')
57
+ staged.push(path);
58
+ if (code[1] !== ' ' && code[1] !== '?')
59
+ unstaged.push(path);
60
+ }
61
+ return {
62
+ staged,
63
+ unstaged,
64
+ untracked,
65
+ get clean() {
66
+ return this.staged.length === 0 && this.unstaged.length === 0 && this.untracked.length === 0;
67
+ },
68
+ };
69
+ }
70
+ /**
71
+ * Splits a raw diff into one section per file, so binary files can be spotted.
72
+ *
73
+ * parse-diff reports a binary file as a file with no hunks, which is also what
74
+ * an empty new file looks like. The raw text distinguishes them, and the
75
+ * sections come back in the same order parse-diff returns files.
76
+ */
77
+ function fileSections(raw) {
78
+ return raw
79
+ .split(/^diff --git /m)
80
+ .slice(1)
81
+ .map((section) => `diff --git ${section}`);
82
+ }
83
+ function toHunks(file) {
84
+ return file.chunks.map((chunk) => ({
85
+ header: chunk.content,
86
+ oldStart: chunk.oldStart,
87
+ oldLines: chunk.oldLines,
88
+ newStart: chunk.newStart,
89
+ newLines: chunk.newLines,
90
+ addedLines: chunk.changes.filter((c) => c.type === 'add').map((c) => c.ln),
91
+ text: [chunk.content, ...chunk.changes.map((c) => c.content)].join('\n'),
92
+ }));
93
+ }
94
+ function toChangedFile(file, section) {
95
+ const from = file.from && file.from !== '/dev/null' ? file.from : null;
96
+ const to = file.to && file.to !== '/dev/null' ? file.to : null;
97
+ const status = file.new
98
+ ? 'added'
99
+ : file.deleted
100
+ ? 'deleted'
101
+ : from && to && from !== to
102
+ ? 'renamed'
103
+ : 'modified';
104
+ return {
105
+ path: to ?? from ?? '',
106
+ previousPath: status === 'renamed' ? from : null,
107
+ status,
108
+ additions: file.additions,
109
+ deletions: file.deletions,
110
+ binary: section ? /^Binary files |^GIT binary patch/m.test(section) : false,
111
+ hunks: toHunks(file),
112
+ };
113
+ }
114
+ /**
115
+ * Renders an untracked file as an addition.
116
+ *
117
+ * `--no-index` makes git diff two paths it does not track; against /dev/null
118
+ * that yields exactly the patch an added file would have. It exits 1 when the
119
+ * files differ, which is the normal outcome here rather than a failure.
120
+ */
121
+ function untrackedFiles(root, paths, context) {
122
+ const out = [];
123
+ for (const path of paths) {
124
+ const proc = spawnSync('git', ['diff', ...SAFE_DIFF, ...context, '--no-index', '--', '/dev/null', path], { cwd: root, encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 });
125
+ const raw = proc.stdout ?? '';
126
+ if (!raw.trim())
127
+ continue;
128
+ const sections = fileSections(raw);
129
+ for (const [i, file] of parseDiff(raw).entries()) {
130
+ const changed = toChangedFile(file, sections[i]);
131
+ // --no-index reports the path as given; keep it repo-relative and say
132
+ // plainly that this file is new rather than inferring it from /dev/null.
133
+ out.push({ ...changed, path, previousPath: null, status: 'added' });
134
+ }
135
+ }
136
+ return out;
137
+ }
138
+ /**
139
+ * Resolves a ref to the commit it names, or explains why it cannot.
140
+ *
141
+ * Exported because the workspace has to be checked out at the same commit the
142
+ * diff is taken against, and it is built before `collectDiff` runs — so the
143
+ * resolution happens once, here, rather than twice with a chance of differing.
144
+ */
145
+ export function resolveCommit(root, ref, label) {
146
+ const rev = git(root, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
147
+ if (!rev.ok || !rev.out.trim()) {
148
+ throw new Error(`${label} is not a commit in this repository: ${ref}`);
149
+ }
150
+ return rev.out.trim();
151
+ }
152
+ /**
153
+ * Collects the changes to review.
154
+ *
155
+ * The comparison is three-dot — against the merge base, not the tip of the base
156
+ * branch — so commits that landed on the base after this branch left it are not
157
+ * attributed to it. That is the same thing GitHub renders on a pull request, so
158
+ * a local review and a PR review are looking at the same set of changes.
159
+ */
160
+ export function collectDiff(req) {
161
+ const { root } = req;
162
+ const base = req.base ?? defaultBase(root);
163
+ const baseSha = resolveCommit(root, base, 'Base');
164
+ const head = req.head ?? 'HEAD';
165
+ const headSha = resolveCommit(root, head, 'Head');
166
+ const merged = git(root, ['merge-base', baseSha, headSha]);
167
+ if (!merged.ok || !merged.out.trim()) {
168
+ throw new Error(`${base} and ${head} share no history, so there is nothing to compare.`);
169
+ }
170
+ const mergeBase = merged.out.trim();
171
+ const since = req.since ? resolveCommit(root, req.since, 'The last reviewed commit') : undefined;
172
+ const context = ['-U' + String(req.context ?? 3)];
173
+ // Against the merge base in both modes. With a commit head that is the
174
+ // three-dot comparison; with the working tree it is the same question asked
175
+ // of uncommitted work, and `git diff <commit>` compares the tree to it.
176
+ // With `since`, the same two modes, from that commit instead.
177
+ const raw = since
178
+ ? git(root, ['diff', ...SAFE_DIFF, ...context, since, ...(req.includeUncommitted ? [] : [headSha])])
179
+ : req.includeUncommitted
180
+ ? git(root, ['diff', ...SAFE_DIFF, ...context, mergeBase])
181
+ : git(root, ['diff', ...SAFE_DIFF, ...context, '--merge-base', baseSha, headSha]);
182
+ if (!raw.ok)
183
+ throw new Error(`Could not read the diff: ${raw.err || 'git failed'}`);
184
+ const sections = fileSections(raw.out);
185
+ const files = parseDiff(raw.out).map((file, i) => toChangedFile(file, sections[i]));
186
+ // `git diff <commit>` never shows untracked files, and a brand-new file is
187
+ // the most review-worthy thing in uncommitted work. Omitting them silently
188
+ // would mean reporting full coverage of a change we had not read.
189
+ if (req.includeUncommitted) {
190
+ files.push(...untrackedFiles(root, workingState(root).untracked, context));
191
+ }
192
+ return {
193
+ base,
194
+ baseSha,
195
+ headSha: req.includeUncommitted ? null : headSha,
196
+ mergeBase,
197
+ uncommitted: Boolean(req.includeUncommitted),
198
+ ...(since && { since }),
199
+ files,
200
+ };
201
+ }
202
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.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QACvB,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ type Status = 'ok' | 'warn' | 'fail';
2
+ export interface Check {
3
+ name: string;
4
+ status: Status;
5
+ detail: string;
6
+ fix?: string;
7
+ }
8
+ /**
9
+ * The check a skill reads first. A version that could not be read cannot be
10
+ * compared against the one a skill was written for, so it fails rather than
11
+ * passing an install the skill has no way to judge.
12
+ */
13
+ export declare function versionCheck(version: string): Check;
14
+ /**
15
+ * Whether prompt runs on the self-hosted backend can remember what they learn.
16
+ *
17
+ * A warning, not a failure: without the key, reviews, claims and rulings all
18
+ * work, and only capture after a prompt run fails. But it fails on every run,
19
+ * so the warning belongs here rather than as the first sign of it.
20
+ */
21
+ export declare function captureCheck(memory: {
22
+ autoCapture: boolean;
23
+ oss: {
24
+ openRouterApiKey: string;
25
+ };
26
+ }): Check | undefined;
27
+ /**
28
+ * `weigh doctor` — turns "it doesn't work" into a list of things to fix.
29
+ *
30
+ * For a distributed tool this is the difference between a user diagnosing their
31
+ * own setup and filing an issue. Every check names the fix, and nothing here
32
+ * prints a secret: presence and provenance only.
33
+ */
34
+ export declare function runDoctor(options: {
35
+ json: boolean;
36
+ }): Promise<number>;
37
+ export {};
38
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAaA,KAAK,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AACrC,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAsBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAKnD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,KAAK,GAAG,SAAS,CAMnH;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAwJ3E"}
package/dist/doctor.js ADDED
@@ -0,0 +1,197 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ import { existsSync } from 'fs';
5
+ import { spawnSync } from 'child_process';
6
+ import { loadConfigDetailed } from './config.js';
7
+ import { repoRootOf } from './target.js';
8
+ import { ModelCatalogue, isStale } from './models.js';
9
+ import { paths, ensureDir } from './paths.js';
10
+ import { UNKNOWN_VERSION, VERSION } from './version.js';
11
+ import { writeOut } from './stdout.js';
12
+ const MARK = { ok: '✓', warn: '!', fail: '✗' };
13
+ async function reachable(url, timeoutMs = 2500) {
14
+ try {
15
+ const res = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
16
+ return res.ok;
17
+ }
18
+ catch {
19
+ return false;
20
+ }
21
+ }
22
+ async function sh(cmd) {
23
+ try {
24
+ const proc = spawnSync(cmd[0], cmd.slice(1), { encoding: 'utf-8' });
25
+ return { ok: proc.status === 0, out: (proc.stdout ?? '').trim() };
26
+ }
27
+ catch {
28
+ return { ok: false, out: '' };
29
+ }
30
+ }
31
+ /**
32
+ * The check a skill reads first. A version that could not be read cannot be
33
+ * compared against the one a skill was written for, so it fails rather than
34
+ * passing an install the skill has no way to judge.
35
+ */
36
+ export function versionCheck(version) {
37
+ return version === UNKNOWN_VERSION
38
+ ? { name: 'weigh', status: 'fail', detail: 'version unknown — package.json could not be read',
39
+ fix: 'reinstall Weigh: npm install -g @afaik-lab/weigh' }
40
+ : { name: 'weigh', status: 'ok', detail: version };
41
+ }
42
+ /**
43
+ * Whether prompt runs on the self-hosted backend can remember what they learn.
44
+ *
45
+ * A warning, not a failure: without the key, reviews, claims and rulings all
46
+ * work, and only capture after a prompt run fails. But it fails on every run,
47
+ * so the warning belongs here rather than as the first sign of it.
48
+ */
49
+ export function captureCheck(memory) {
50
+ if (!memory.autoCapture)
51
+ return undefined;
52
+ return memory.oss.openRouterApiKey
53
+ ? { name: 'capture', status: 'ok', detail: 'OpenRouter key present' }
54
+ : { name: 'capture', status: 'warn', detail: 'no OPENROUTER_API_KEY: prompt runs will not remember facts',
55
+ fix: 'set OPENROUTER_API_KEY, or weigh config set memory.autoCapture false' };
56
+ }
57
+ /**
58
+ * `weigh doctor` — turns "it doesn't work" into a list of things to fix.
59
+ *
60
+ * For a distributed tool this is the difference between a user diagnosing their
61
+ * own setup and filing an issue. Every check names the fix, and nothing here
62
+ * prints a secret: presence and provenance only.
63
+ */
64
+ export async function runDoctor(options) {
65
+ // First, because it is the one a caller acts on before reading the rest:
66
+ // the plugin's skills compare it against the version they were written for.
67
+ const checks = [versionCheck(VERSION)];
68
+ // ── Config ────────────────────────────────────────────────────────
69
+ // With the shared file of the repository it is run in, so a bad key there is
70
+ // reported here rather than first met by a review.
71
+ const repoRoot = repoRootOf();
72
+ const { config, warnings, provenance } = loadConfigDetailed({}, { skipApiKey: true, ...(repoRoot && { repoRoot }) });
73
+ checks.push(warnings.length
74
+ ? { name: 'config', status: 'warn', detail: `${warnings.length} warning(s): ${warnings[0]}`,
75
+ fix: 'weigh config list' }
76
+ : { name: 'config', status: 'ok', detail: existsSync(paths.config()) ? paths.config() : 'defaults only' });
77
+ // ── Writable state ────────────────────────────────────────────────
78
+ try {
79
+ ensureDir(paths.sessions());
80
+ ensureDir(paths.workspaces());
81
+ checks.push({ name: 'paths', status: 'ok', detail: `${paths.home()} · cache ${paths.cache()}` });
82
+ }
83
+ catch (err) {
84
+ checks.push({ name: 'paths', status: 'fail', detail: err.message, fix: 'set WEIGH_HOME to a writable directory' });
85
+ }
86
+ // ── Model access ──────────────────────────────────────────────────
87
+ // There are two ways to be authenticated and only one of them is visible
88
+ // from here. A key can be checked; a Claude Code subscription login lives in
89
+ // the binary's own credential store, so the check is whether the binary is
90
+ // there and reports itself logged in — not whether we can see a secret.
91
+ if (config.apiKey) {
92
+ checks.push({
93
+ name: 'auth',
94
+ status: 'ok',
95
+ detail: `ANTHROPIC_API_KEY set (from ${provenance.get('apiKey')})`,
96
+ });
97
+ }
98
+ else {
99
+ // `--version` proves the binary is there, not that it holds a live login —
100
+ // that lives in a credential store this has no business reading. A run is
101
+ // still the only thing that settles it, so this says what it checked.
102
+ const claude = await sh(['claude', '--version']);
103
+ checks.push(claude.ok
104
+ ? { name: 'auth', status: 'ok', detail: `no key — deferring to Claude Code (${claude.out})` }
105
+ : {
106
+ name: 'auth',
107
+ status: 'fail',
108
+ detail: 'no API key and no Claude Code binary',
109
+ fix: `run \`claude setup-token\`, or add ANTHROPIC_API_KEY to ${paths.envFile()}`,
110
+ });
111
+ }
112
+ // ── Model catalogue ───────────────────────────────────────────────
113
+ // Reported because a stale one is invisible otherwise: short names keep
114
+ // resolving, just to whatever was current when the cache was written.
115
+ const catalogue = ModelCatalogue.load();
116
+ const days = catalogue.ageMs() === undefined ? undefined : Math.floor(catalogue.ageMs() / 86_400_000);
117
+ checks.push(catalogue.empty
118
+ ? { name: 'models', status: 'warn', detail: 'never fetched — short names resolve from the built-in list',
119
+ fix: 'weigh models' }
120
+ : isStale(catalogue)
121
+ ? { name: 'models', status: 'warn', detail: `${catalogue.rows.length} model(s), last fetched ${days}d ago`,
122
+ fix: 'weigh models' }
123
+ : { name: 'models', status: 'ok', detail: `${catalogue.rows.length} model(s) · ${config.model}` });
124
+ // ── Memory ────────────────────────────────────────────────────────
125
+ if (!config.memory.enabled) {
126
+ checks.push({ name: 'memory', status: 'warn', detail: 'disabled', fix: 'unset WEIGH_MEMORY=0 to enable' });
127
+ }
128
+ else if (config.memory.backend === 'platform') {
129
+ checks.push(config.memory.platform.apiKey
130
+ ? { name: 'memory', status: 'ok', detail: 'hosted Mem0, key present' }
131
+ : { name: 'memory', status: 'fail', detail: 'platform backend without MEM0_API_KEY',
132
+ fix: 'set MEM0_API_KEY, or WEIGH_MEMORY_BACKEND=oss' });
133
+ }
134
+ else {
135
+ const { qdrantUrl, ollamaUrl, embeddingProvider, embeddingModel } = config.memory.oss;
136
+ checks.push((await reachable(`${qdrantUrl}/readyz`))
137
+ ? { name: 'qdrant', status: 'ok', detail: qdrantUrl }
138
+ : { name: 'qdrant', status: 'fail', detail: `unreachable at ${qdrantUrl}`,
139
+ fix: 'weigh memory compose | docker compose -f - up -d qdrant' });
140
+ if (embeddingProvider === 'ollama') {
141
+ const up = await reachable(`${ollamaUrl}/api/tags`);
142
+ let hasModel = false;
143
+ if (up) {
144
+ const tags = await fetch(`${ollamaUrl}/api/tags`).then((r) => r.json()).catch(() => null);
145
+ hasModel = Boolean(tags?.models?.some((m) => m.name?.startsWith(embeddingModel)));
146
+ }
147
+ checks.push(!up
148
+ ? { name: 'ollama', status: 'fail', detail: `unreachable at ${ollamaUrl}`, fix: 'weigh memory compose | docker compose -f - up -d ollama' }
149
+ : hasModel
150
+ ? { name: 'ollama', status: 'ok', detail: `${ollamaUrl} · ${embeddingModel}` }
151
+ : { name: 'ollama', status: 'warn', detail: `${embeddingModel} not pulled`,
152
+ fix: `ollama pull ${embeddingModel}` });
153
+ }
154
+ else if (!config.memory.oss.openAiApiKey) {
155
+ checks.push({ name: 'embedder', status: 'fail', detail: 'openai embedder without OPENAI_API_KEY',
156
+ fix: 'set OPENAI_API_KEY, or WEIGH_EMBEDDER=ollama' });
157
+ }
158
+ const capture = captureCheck(config.memory);
159
+ if (capture)
160
+ checks.push(capture);
161
+ }
162
+ // ── GitHub ────────────────────────────────────────────────────────
163
+ if (process.env.GH_TOKEN) {
164
+ checks.push({ name: 'github', status: 'ok', detail: 'GH_TOKEN set' });
165
+ }
166
+ else {
167
+ const gh = await sh(['gh', 'auth', 'status']);
168
+ const accounts = [...gh.out.matchAll(/account (\S+)/g)].map((m) => m[1]);
169
+ checks.push(!gh.ok
170
+ ? { name: 'github', status: 'warn', detail: 'gh not authenticated', fix: 'gh auth login, or set GH_TOKEN' }
171
+ : { name: 'github', status: 'ok', detail: `gh accounts: ${accounts.join(', ') || 'one'}` });
172
+ }
173
+ // ── git ───────────────────────────────────────────────────────────
174
+ const git = await sh(['git', '--version']);
175
+ checks.push(git.ok
176
+ ? { name: 'git', status: 'ok', detail: git.out }
177
+ : { name: 'git', status: 'fail', detail: 'git not found', fix: 'install git' });
178
+ // ── Linear ────────────────────────────────────────────────────────
179
+ checks.push(config.linear?.apiKey
180
+ ? { name: 'linear', status: 'ok', detail: 'key present' }
181
+ : { name: 'linear', status: 'warn', detail: 'no key — spec assessment will be skipped',
182
+ fix: 'set LINEAR_API_KEY (read scope)' });
183
+ if (options.json) {
184
+ await writeOut(JSON.stringify({ version: VERSION, checks }) + '\n');
185
+ }
186
+ else {
187
+ const width = Math.max(...checks.map((c) => c.name.length));
188
+ const lines = checks.flatMap((c) => [
189
+ `${MARK[c.status]} ${c.name.padEnd(width)} ${c.detail}`,
190
+ ...(c.fix && c.status !== 'ok' ? [`${' '.repeat(width + 4)}→ ${c.fix}`] : []),
191
+ ]);
192
+ const failed = checks.filter((c) => c.status === 'fail').length;
193
+ await writeOut([...lines, '', `${checks.length - failed}/${checks.length} checks passed`, ''].join('\n'));
194
+ }
195
+ return checks.some((c) => c.status === 'fail') ? 1 : 0;
196
+ }
197
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EA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AAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QAChE,MAAM,QAAQ,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,gBAAgB,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What a run tells its watcher while it is running.
3
+ *
4
+ * In its own module because three things now depend on it and none of them
5
+ * depends on the others: the reviewer and the refuter emit these, and the
6
+ * progress reporter consumes them. Left on the reviewer, the refuter had to
7
+ * import from the module that will import it back.
8
+ */
9
+ export type ReviewEvent = {
10
+ type: 'tool_call';
11
+ name: string;
12
+ detail?: string;
13
+ } | {
14
+ type: 'coverage_nudge';
15
+ read: number;
16
+ expected: number;
17
+ } | {
18
+ type: 'done';
19
+ findings: number;
20
+ };
21
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/dist/events.js ADDED
@@ -0,0 +1,5 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ export {};
5
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,sEAAsE;AACtE,4DAA4D"}