@north-light/cli 0.3.707 → 0.3.709

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 (278) hide show
  1. package/dist/api/client.d.ts +1 -2
  2. package/dist/api/client.js +3 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/crons.d.ts +3 -0
  6. package/dist/api/dto/human.d.ts +9 -6
  7. package/dist/api/dto/inbox.d.ts +2 -0
  8. package/dist/api/dto/review-comments.d.ts +12 -35
  9. package/dist/api/dto/reviews.d.ts +3 -10
  10. package/dist/api/routes.d.ts +0 -1
  11. package/dist/api/routes.js +1 -1
  12. package/dist/builtin-memory/05-kinds/review/companion/00-base.md +2 -2
  13. package/dist/builtin-memory/crouter-sdk/release-notes.md +6 -0
  14. package/dist/clients/attach/chrome/canvas-panels.d.ts +1 -1
  15. package/dist/clients/attach/chrome/canvas-panels.js +1 -1
  16. package/dist/clients/attach/chrome/inbox-strip.js +1 -1
  17. package/dist/clients/attach/chrome/roster.js +6 -6
  18. package/dist/clients/attach/chrome/status-line.d.ts +1 -1
  19. package/dist/clients/attach/chrome/status-line.js +1 -1
  20. package/dist/clients/attach/chrome/ticket-panel.js +1 -1
  21. package/dist/clients/attach/input/capabilities.js +1 -1
  22. package/dist/clients/attach/input/controller.d.ts +4 -1
  23. package/dist/clients/attach/input/controller.js +3 -3
  24. package/dist/clients/attach/input/overlay-owner.d.ts +0 -1
  25. package/dist/clients/attach/input/overlay-owner.js +1 -1
  26. package/dist/clients/attach/overlays/graph.d.ts +3 -2
  27. package/dist/clients/attach/overlays/graph.js +1 -1
  28. package/dist/clients/attach/render/chat-view.d.ts +2 -0
  29. package/dist/clients/attach/render/chat-view.js +1 -1
  30. package/dist/clients/attach/render/doc-links.d.ts +1 -1
  31. package/dist/clients/attach/session/chrome-refresh.js +1 -1
  32. package/dist/clients/attach/session/connection.d.ts +10 -9
  33. package/dist/clients/attach/session/connection.js +1 -1
  34. package/dist/clients/attach/session/context.d.ts +1 -1
  35. package/dist/clients/attach/session/document-links.d.ts +1 -1
  36. package/dist/clients/attach/session/document-links.js +1 -1
  37. package/dist/clients/attach/session/identity.d.ts +2 -0
  38. package/dist/clients/attach/session/identity.js +1 -1
  39. package/dist/clients/attach/session/input-wiring.d.ts +2 -0
  40. package/dist/clients/attach/session/input-wiring.js +1 -1
  41. package/dist/clients/attach/session/keys.d.ts +2 -2
  42. package/dist/clients/attach/session/keys.js +1 -1
  43. package/dist/clients/attach/session/pane-tag.d.ts +3 -1
  44. package/dist/clients/attach/session/pane-tag.js +1 -1
  45. package/dist/clients/attach/session/reconnect.js +1 -1
  46. package/dist/clients/attach/session/surface-host.d.ts +0 -5
  47. package/dist/clients/attach/session/surface-host.js +1 -1
  48. package/dist/clients/attach/session/teardown.d.ts +2 -2
  49. package/dist/clients/attach/session/teardown.js +9 -7
  50. package/dist/clients/attach/viewer.d.ts +7 -5
  51. package/dist/clients/attach/viewer.js +571 -584
  52. package/dist/clients/editor-roundtrip.js +3 -0
  53. package/dist/clients/inbox/controller.d.ts +1 -6
  54. package/dist/clients/inbox/controller.js +1 -1
  55. package/dist/clients/inbox/dto-adapt.js +1 -1
  56. package/dist/clients/inbox/tui/page-body.js +1 -1
  57. package/dist/clients/inbox/tui/render.js +2 -2
  58. package/dist/clients/open-browser.d.ts +2 -0
  59. package/dist/clients/open-browser.js +1 -0
  60. package/dist/clients/surfaces/host.d.ts +0 -6
  61. package/dist/commands/human/review.js +1 -1
  62. package/dist/commands/node/wait.js +2 -6
  63. package/dist/commands/sys/context/admin/shell.js +1 -1
  64. package/dist/core/broker-client/client.d.ts +6 -3
  65. package/dist/core/broker-client/client.js +1 -1
  66. package/dist/core/canvas/crons.d.ts +11 -1
  67. package/dist/core/canvas/crons.js +14 -14
  68. package/dist/core/canvas/executions.js +1 -1
  69. package/dist/core/canvas/schema-pg/025-review-anchors.sql +19 -0
  70. package/dist/core/canvas/schema-pg/026-cron-deadline-body.sql +9 -0
  71. package/dist/core/canvas/schema-pg/027-cron-fires.sql +4 -0
  72. package/dist/core/canvas/schema-version.d.ts +1 -1
  73. package/dist/core/canvas/schema-version.js +1 -1
  74. package/dist/core/command.js +5 -5
  75. package/dist/core/feed/messages.d.ts +5 -0
  76. package/dist/core/feed/messages.js +5 -5
  77. package/dist/core/human/page-markdown.js +10 -12
  78. package/dist/core/human/tickets.js +1 -1
  79. package/dist/core/human/types.d.ts +4 -6
  80. package/dist/core/keybindings/attach-control.d.ts +0 -3
  81. package/dist/core/keybindings/attach-control.js +1 -1
  82. package/dist/core/keybindings/catalog.d.ts +1 -1
  83. package/dist/core/keybindings/catalog.js +1 -1
  84. package/dist/core/review/anchors.d.ts +28 -0
  85. package/dist/core/review/anchors.js +6 -0
  86. package/dist/core/review/comments.d.ts +2 -2
  87. package/dist/core/review/comments.js +7 -8
  88. package/dist/core/review/companion.d.ts +2 -1
  89. package/dist/core/review/companion.js +1 -1
  90. package/dist/core/review/document.d.ts +4 -17
  91. package/dist/core/review/document.js +1 -2
  92. package/dist/core/review/fork.js +2 -4
  93. package/dist/core/review/project.d.ts +1 -1
  94. package/dist/core/review/project.js +2 -2
  95. package/dist/core/review/realize.js +1 -1
  96. package/dist/core/review/stage.d.ts +2 -9
  97. package/dist/core/review/stage.js +1 -1
  98. package/dist/core/review/types.d.ts +16 -12
  99. package/dist/core/review/types.js +1 -1
  100. package/dist/core/runtime/bearings.js +4 -4
  101. package/dist/core/runtime/boot-root.js +4 -4
  102. package/dist/core/runtime/broker-cli.js +3 -3
  103. package/dist/core/runtime/broker-extension-render.js +1 -1
  104. package/dist/core/runtime/lifecycle.js +2 -2
  105. package/dist/core/runtime/revive.js +2 -2
  106. package/dist/core/runtime/runner/blaxel/client.d.ts +4 -0
  107. package/dist/core/runtime/runner/blaxel/client.js +1 -1
  108. package/dist/core/runtime/runner/blaxel/runner.d.ts +2 -3
  109. package/dist/core/runtime/runner/blaxel/runner.js +3 -3
  110. package/dist/core/runtime/runner/delete-sandboxes.d.ts +5 -0
  111. package/dist/core/runtime/runner/delete-sandboxes.js +6 -1
  112. package/dist/core/runtime/runner/types.d.ts +19 -3
  113. package/dist/core/runtime/tmux-bindings.js +3 -3
  114. package/dist/daemon/api/bridge.d.ts +5 -0
  115. package/dist/daemon/api/bridge.js +3 -3
  116. package/dist/daemon/api/canvas-host.js +1 -1
  117. package/dist/daemon/api/document-page.d.ts +12 -1
  118. package/dist/daemon/api/document-page.js +6 -6
  119. package/dist/daemon/api/handlers/crons.d.ts +2 -0
  120. package/dist/daemon/api/handlers/crons.js +1 -1
  121. package/dist/daemon/api/handlers/inbox.js +1 -1
  122. package/dist/daemon/api/handlers/nodes.js +1 -1
  123. package/dist/daemon/api/handlers/review-comments.js +1 -1
  124. package/dist/daemon/api/handlers/reviews.js +1 -1
  125. package/dist/daemon/api/map.js +2 -2
  126. package/dist/daemon/api/operations.js +1 -1
  127. package/dist/daemon/api/review-page.d.ts +3 -0
  128. package/dist/daemon/api/review-page.js +13 -0
  129. package/dist/daemon/broker-memory-cap.d.ts +9 -0
  130. package/dist/daemon/broker-memory-cap.js +2 -0
  131. package/dist/daemon/broker-signals/bus.d.ts +1 -1
  132. package/dist/daemon/broker-signals/bus.js +1 -1
  133. package/dist/daemon/cron/ended.d.ts +3 -0
  134. package/dist/daemon/cron/ended.js +2 -2
  135. package/dist/daemon/cron/lease-recovery.js +1 -1
  136. package/dist/daemon/cron/machine-fire.d.ts +9 -2
  137. package/dist/daemon/cron/machine-fire.js +1 -1
  138. package/dist/daemon/cron/passes.js +1 -1
  139. package/dist/daemon/cron-run.js +2 -2
  140. package/dist/daemon/crtrd.js +14 -14
  141. package/dist/daemon/machine-daemon.js +1 -1
  142. package/dist/daemon/machine-link/client.js +1 -1
  143. package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
  144. package/dist/daemon/reconcilers/idle-sandbox.d.ts +1 -1
  145. package/dist/daemon/reconcilers/idle-sandbox.js +2 -2
  146. package/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
  147. package/dist/daemon/review/comment-notify.js +2 -2
  148. package/dist/daemon/review/deliver.d.ts +2 -2
  149. package/dist/daemon/review/deliver.js +6 -2
  150. package/dist/daemon/review/finish.js +1 -1
  151. package/dist/doc-editor/Geist-Variable.woff2 +0 -0
  152. package/dist/doc-editor/GeistMono-Variable.woff2 +0 -0
  153. package/dist/doc-editor/editor.css +1 -1
  154. package/dist/doc-editor/review.css +2 -0
  155. package/dist/doc-editor/review.js +149 -0
  156. package/dist/pi-extensions/canvas-review-boundary.js +3 -3
  157. package/docs/sdk/release-notes.md +6 -0
  158. package/package.json +13 -4
  159. package/packages/crouter-api/dist/api/client.js +0 -3
  160. package/packages/crouter-api/dist/api/contract.js +1 -1
  161. package/packages/crouter-api/dist/api/routes.js +0 -1
  162. package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +3 -3
  163. package/packages/crouter-api/dist/clients/attach/chrome/inbox-strip.js +5 -5
  164. package/packages/crouter-api/dist/clients/attach/chrome/roster.js +17 -28
  165. package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +2 -7
  166. package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +1 -1
  167. package/packages/crouter-api/dist/clients/attach/input/capabilities.js +2 -1
  168. package/packages/crouter-api/dist/clients/attach/input/controller.js +17 -3
  169. package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +0 -7
  170. package/packages/crouter-api/dist/clients/attach/overlays/graph.js +4 -3
  171. package/packages/crouter-api/dist/clients/attach/render/chat-view.js +9 -0
  172. package/packages/crouter-api/dist/clients/attach/session/chrome-refresh.js +6 -3
  173. package/packages/crouter-api/dist/clients/attach/session/connection.js +53 -53
  174. package/packages/crouter-api/dist/clients/attach/session/document-links.js +1 -1
  175. package/packages/crouter-api/dist/clients/attach/session/identity.js +1 -0
  176. package/packages/crouter-api/dist/clients/attach/session/input-wiring.js +4 -3
  177. package/packages/crouter-api/dist/clients/attach/session/keys.js +11 -5
  178. package/packages/crouter-api/dist/clients/attach/session/pane-tag.js +7 -1
  179. package/packages/crouter-api/dist/clients/attach/session/reconnect.js +3 -3
  180. package/packages/crouter-api/dist/clients/attach/session/surface-host.js +0 -17
  181. package/packages/crouter-api/dist/clients/attach/session/teardown.js +7 -4
  182. package/packages/crouter-api/dist/clients/attach/viewer.js +77 -67
  183. package/packages/crouter-api/dist/clients/{inbox/review/roundtrip.js → editor-roundtrip.js} +1 -1
  184. package/packages/crouter-api/dist/clients/inbox/controller.js +12 -31
  185. package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +1 -0
  186. package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +0 -7
  187. package/packages/crouter-api/dist/clients/inbox/tui/render.js +0 -7
  188. package/packages/crouter-api/dist/clients/open-browser.js +6 -0
  189. package/packages/crouter-api/dist/commands/human/review.js +17 -18
  190. package/packages/crouter-api/dist/commands/node/wait.js +2 -10
  191. package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +1 -1
  192. package/packages/crouter-api/dist/core/broker-client/client.js +20 -10
  193. package/packages/crouter-api/dist/core/canvas/crons.js +26 -10
  194. package/packages/crouter-api/dist/core/canvas/executions.js +7 -2
  195. package/packages/crouter-api/dist/core/canvas/schema-version.js +1 -1
  196. package/packages/crouter-api/dist/core/command.js +3 -0
  197. package/packages/crouter-api/dist/core/feed/messages.js +15 -0
  198. package/packages/crouter-api/dist/core/human/page-markdown.js +2 -6
  199. package/packages/crouter-api/dist/core/human/tickets.js +2 -11
  200. package/packages/crouter-api/dist/core/keybindings/attach-control.js +0 -1
  201. package/packages/crouter-api/dist/core/keybindings/catalog.js +1 -3
  202. package/packages/crouter-api/dist/core/review/anchors.js +91 -0
  203. package/packages/crouter-api/dist/core/review/comments.js +27 -46
  204. package/packages/crouter-api/dist/core/review/companion.js +5 -9
  205. package/packages/crouter-api/dist/core/review/document.js +17 -89
  206. package/packages/crouter-api/dist/core/review/project.js +2 -1
  207. package/packages/crouter-api/dist/core/review/types.js +2 -2
  208. package/packages/crouter-api/dist/core/runtime/bearings.js +2 -2
  209. package/packages/crouter-api/dist/core/runtime/lifecycle.js +3 -0
  210. package/packages/crouter-api/dist/core/runtime/revive.js +5 -25
  211. package/packages/crouter-api/dist/core/runtime/runner/blaxel/client.js +15 -8
  212. package/packages/crouter-api/dist/core/runtime/runner/blaxel/runner.js +60 -19
  213. package/packages/crouter-api/dist/core/runtime/runner/delete-sandboxes.js +18 -2
  214. package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +0 -5
  215. package/packages/crouter-api/dist/daemon/api/map.js +2 -6
  216. package/packages/crouter-api/dist/daemon/api/operations.js +2 -2
  217. package/packages/crouter-api/dist/daemon/broker-signals/bus.js +1 -1
  218. package/packages/crouter-api/dist/daemon/cron/ended.js +22 -11
  219. package/packages/crouter-api/dist/daemon/cron/machine-fire.js +69 -6
  220. package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +2 -2
  221. package/packages/crouter-api/dist/daemon/review/deliver.js +4 -3
  222. package/packages/crouter-api/dist/daemon/review/finish.js +26 -47
  223. package/packages/crouter-api/package.json +1 -1
  224. package/packages/crouter-identity/package.json +1 -1
  225. package/packages/crouter-plugin/package.json +3 -3
  226. package/runtime.lock.json +1740 -505
  227. package/dist/clients/attach/overlays/file-review.d.ts +0 -10
  228. package/dist/clients/attach/overlays/file-review.js +0 -2
  229. package/dist/clients/inbox/review/anchors.d.ts +0 -41
  230. package/dist/clients/inbox/review/anchors.js +0 -1
  231. package/dist/clients/inbox/review/comments-client.d.ts +0 -74
  232. package/dist/clients/inbox/review/comments-client.js +0 -1
  233. package/dist/clients/inbox/review/companion-pane.d.ts +0 -47
  234. package/dist/clients/inbox/review/companion-pane.js +0 -1
  235. package/dist/clients/inbox/review/document-surface.d.ts +0 -212
  236. package/dist/clients/inbox/review/document-surface.js +0 -2
  237. package/dist/clients/inbox/review/frame.d.ts +0 -57
  238. package/dist/clients/inbox/review/frame.js +0 -1
  239. package/dist/clients/inbox/review/keys.d.ts +0 -69
  240. package/dist/clients/inbox/review/keys.js +0 -1
  241. package/dist/clients/inbox/review/launch.d.ts +0 -16
  242. package/dist/clients/inbox/review/launch.js +0 -1
  243. package/dist/clients/inbox/review/live-source.d.ts +0 -24
  244. package/dist/clients/inbox/review/live-source.js +0 -1
  245. package/dist/clients/inbox/review/nvim.d.ts +0 -15
  246. package/dist/clients/inbox/review/nvim.js +0 -1
  247. package/dist/clients/inbox/review/remap.d.ts +0 -51
  248. package/dist/clients/inbox/review/remap.js +0 -1
  249. package/dist/clients/inbox/review/review-client.d.ts +0 -43
  250. package/dist/clients/inbox/review/review-client.js +0 -1
  251. package/dist/clients/inbox/review/roundtrip.js +0 -3
  252. package/dist/clients/inbox/review/state.d.ts +0 -153
  253. package/dist/clients/inbox/review/state.js +0 -4
  254. package/dist/clients/inbox/review-adapter.d.ts +0 -17
  255. package/dist/clients/inbox/review-adapter.js +0 -1
  256. package/dist/core/review/remap.d.ts +0 -24
  257. package/dist/core/review/remap.js +0 -19
  258. package/dist/core/review/signal.d.ts +0 -5
  259. package/dist/core/review/signal.js +0 -1
  260. package/dist/core/runtime/starting-screen.d.ts +0 -12
  261. package/dist/core/runtime/starting-screen.js +0 -9
  262. package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +0 -146
  263. package/packages/crouter-api/dist/clients/inbox/review/anchors.js +0 -89
  264. package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +0 -103
  265. package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +0 -109
  266. package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +0 -1268
  267. package/packages/crouter-api/dist/clients/inbox/review/frame.js +0 -309
  268. package/packages/crouter-api/dist/clients/inbox/review/keys.js +0 -133
  269. package/packages/crouter-api/dist/clients/inbox/review/launch.js +0 -170
  270. package/packages/crouter-api/dist/clients/inbox/review/live-source.js +0 -160
  271. package/packages/crouter-api/dist/clients/inbox/review/nvim.js +0 -43
  272. package/packages/crouter-api/dist/clients/inbox/review/remap.js +0 -157
  273. package/packages/crouter-api/dist/clients/inbox/review/review-client.js +0 -125
  274. package/packages/crouter-api/dist/clients/inbox/review/state.js +0 -315
  275. package/packages/crouter-api/dist/clients/inbox/review-adapter.js +0 -43
  276. package/packages/crouter-api/dist/core/review/signal.js +0 -12
  277. package/packages/crouter-api/dist/core/termrender/code-doc.js +0 -92
  278. /package/dist/clients/{inbox/review/roundtrip.d.ts → editor-roundtrip.d.ts} +0 -0
@@ -1,89 +0,0 @@
1
- /** Derive leaf anchor units from a mapped render: dedupe runs of consecutive
2
- * rows carrying the identical source span. A mapped row without a leaf span
3
- * (an unmapped block) anchors at its whole block's range, so every content
4
- * row belongs to a unit; separator rows belong to none. */
5
- export function deriveAnchorUnits(doc) {
6
- const units = [];
7
- const rowUnits = new Array(doc.lines.length).fill(null);
8
- for (let r = 0; r < doc.lines.length; r++) {
9
- let span = doc.spans[r] ?? null;
10
- if (span === null) {
11
- const b = doc.rows[r] ?? null;
12
- const block = b !== null ? doc.blocks[b] : undefined;
13
- if (block === undefined)
14
- continue;
15
- span = [block.start, block.end];
16
- }
17
- const prev = units[units.length - 1];
18
- if (prev !== undefined && prev.lastRow === r - 1 && prev.start === span[0] && prev.end === span[1]) {
19
- prev.lastRow = r;
20
- }
21
- else {
22
- units.push({ start: span[0], end: span[1], firstRow: r, lastRow: r });
23
- }
24
- rowUnits[r] = units.length - 1;
25
- }
26
- if (units.length === 0) {
27
- // Degenerate map (nothing anchorable) — one whole-doc unit over all rows.
28
- units.push({
29
- start: doc.blocks[0]?.start ?? 1,
30
- end: doc.blocks[doc.blocks.length - 1]?.end ?? 1,
31
- firstRow: 0,
32
- lastRow: Math.max(0, doc.lines.length - 1),
33
- });
34
- for (let r = 0; r < rowUnits.length; r++)
35
- rowUnits[r] = 0;
36
- }
37
- return { units, rowUnits };
38
- }
39
- /** Best unit for a source line: the NARROWEST unit containing it — code/table
40
- * chrome units carry their whole block's range and sit before the per-line
41
- * content units in rendered order, so "first whose end reaches the line"
42
- * would wrongly pick the chrome over the exact code line. A line no unit
43
- * contains (a blank separator) snaps forward to the next unit; past the end
44
- * clamps to the last. */
45
- export function unitIndexForLine(units, line) {
46
- let best = -1;
47
- for (let i = 0; i < units.length; i++) {
48
- const u = units[i];
49
- if (u.start <= line && u.end >= line) {
50
- if (best === -1 || u.end - u.start < units[best].end - units[best].start)
51
- best = i;
52
- }
53
- }
54
- if (best !== -1)
55
- return best;
56
- for (let i = 0; i < units.length; i++) {
57
- if (units[i].start > line)
58
- return i;
59
- }
60
- return Math.max(0, units.length - 1);
61
- }
62
- /** Remap a unit from an old unit list into a re-derived one: an exact
63
- * source-range match wins (chrome and leaf units can share source lines),
64
- * else the best unit for its first line. */
65
- export function remapUnitIndex(units, prev) {
66
- for (let i = 0; i < units.length; i++) {
67
- if (units[i].start === prev.start && units[i].end === prev.end)
68
- return i;
69
- }
70
- return unitIndexForLine(units, prev.start);
71
- }
72
- /** First/last unit indices overlapping the source range `line..endLine`;
73
- * a range touching no unit snaps like unitIndexForLine. */
74
- export function unitRangeForSpan(units, line, endLine) {
75
- let lo = -1;
76
- let hi = -1;
77
- units.forEach((u, i) => {
78
- if (u.start <= endLine && u.end >= line) {
79
- if (lo === -1)
80
- lo = i;
81
- hi = i;
82
- }
83
- });
84
- if (lo === -1) {
85
- const snap = unitIndexForLine(units, line);
86
- return { lo: snap, hi: snap };
87
- }
88
- return { lo, hi };
89
- }
@@ -1,103 +0,0 @@
1
- import { ApiError } from '../../../api/errors.js';
2
- import { cliClient } from '../../../commands/api-client.js';
3
- import { watchReviewActivity } from '../../../core/review/signal.js';
4
- /** A daemon rejection that leaves the rendered document or comment projection stale. */
5
- export class ReviewDocumentError extends Error {
6
- code;
7
- details;
8
- constructor(code, message, details) {
9
- super(message);
10
- this.name = 'ReviewDocumentError';
11
- this.code = code;
12
- this.details = details;
13
- }
14
- }
15
- /** The terminal's complete daemon seam for one review's comment projection. */
16
- export function createCommentAuthority(reviewId, request) {
17
- return {
18
- async anchorBase() {
19
- const base = await request(() => cliClient().getReviewDocumentBase(reviewId));
20
- return { file: base.file, text: base.anchor_base_text, docHash: base.anchor_base_sha256 };
21
- },
22
- async list() {
23
- const listed = await request(() => cliClient().listReviewComments(reviewId, { status: 'all' }));
24
- return listed.comments.map(projectComment);
25
- },
26
- async create(p) {
27
- const created = await translateDocumentError(() => request(() => cliClient().createReviewComment(reviewId, {
28
- text: p.text,
29
- anchor: { line: p.line, end_line: p.endLine },
30
- doc_hash: p.docHash,
31
- actor_node_id: null,
32
- })));
33
- return created.comment.comment_id;
34
- },
35
- async edit(p) {
36
- await translateDocumentError(() => request(() => cliClient().editReviewComment(p.id, {
37
- text: p.text,
38
- if_revision: p.ifRevision,
39
- actor_node_id: null,
40
- })));
41
- },
42
- async resolve(id) {
43
- await translateDocumentError(() => request(() => cliClient().resolveReviewComment(id, { actor_node_id: null })));
44
- },
45
- async reopen(id) {
46
- await translateDocumentError(() => request(() => cliClient().reopenReviewComment(id, { actor_node_id: null })));
47
- },
48
- async remove(id) {
49
- await translateDocumentError(() => request(() => cliClient().deleteReviewComment(id, { actor_node_id: null })));
50
- },
51
- async remapRanges(p) {
52
- await translateDocumentError(() => request(() => cliClient().updateReviewCommentRanges(reviewId, {
53
- from_doc_hash: p.fromDocHash,
54
- to_doc_hash: p.toDocHash,
55
- entries: p.entries.map((entry) => 'detached' in entry
56
- ? { comment_id: entry.id, detached: true }
57
- : {
58
- comment_id: entry.id,
59
- anchor: { line: entry.anchor.line, end_line: entry.anchor.endLine },
60
- }),
61
- })));
62
- },
63
- async fork(commentId) {
64
- const forked = await request(() => cliClient().forkReviewComment(commentId));
65
- return { nodeId: forked.node_id, cwd: forked.cwd };
66
- },
67
- onChanged(fn) {
68
- return watchReviewActivity(fn);
69
- },
70
- };
71
- }
72
- function projectComment(comment) {
73
- const range = { line: comment.anchor.line, endLine: comment.anchor.end_line };
74
- return {
75
- id: comment.comment_id,
76
- revision: comment.revision,
77
- ...range,
78
- lineText: comment.anchor_line_text,
79
- comment: comment.text,
80
- status: comment.status,
81
- authorKind: comment.author.kind,
82
- createdAt: comment.created_at,
83
- anchorStatus: comment.anchor_state === 'detached' ? 'detached' : 'live',
84
- ...(comment.anchor_state === 'detached' ? { originalRange: range } : {}),
85
- };
86
- }
87
- async function translateDocumentError(operation) {
88
- try {
89
- return await operation();
90
- }
91
- catch (error) {
92
- if (error instanceof ApiError && isDocumentErrorCode(error.code)) {
93
- throw new ReviewDocumentError(error.code, error.message, error.details);
94
- }
95
- throw error;
96
- }
97
- }
98
- function isDocumentErrorCode(code) {
99
- return code === 'stale_document'
100
- || code === 'stale_comment'
101
- || code === 'range_batch_incomplete'
102
- || code === 'range_batch_stale';
103
- }
@@ -1,109 +0,0 @@
1
- // companion-pane.ts — review-side tmux policy for the companion pane.
2
- //
3
- // Pure placement over the existing tmux driver verbs; no daemon calls, no
4
- // review knowledge beyond the ids it is handed.
5
- import { inTmux, liveViewerPanes, paneRunning, paneSize, splitWindow, paneExists, getPaneOption, closePane, } from '../../../core/runtime/placement-tmux.js';
6
- import { viewerEnv } from '../../../commands/surface/node/placement.js';
7
- // Constants
8
- export const SPLIT_MIN_COLS = 99;
9
- export const MIN_COMPANION_COLS = 40;
10
- export const MIN_COMPANION_ROWS = 12;
11
- export const COMPANION_WIDTH_RATIO = 0.42;
12
- export const COMPANION_HEIGHT_RATIO = 0.40;
13
- // Types
14
- /** A fork column narrower than this cannot hold a readable conversation, so the
15
- * split is refused rather than shipping an unusable pane. */
16
- export const MIN_FORK_COLS = 52;
17
- // Pane lifecycle
18
- /** Open or adopt a companion pane for a review. Adoption succeeds only when
19
- * an existing validated-live companion viewer pane exists; otherwise, a
20
- * fresh pane is split beside the caller. */
21
- export function openCompanionPane(args) {
22
- const { companionNodeId, cwd, callerPane } = args;
23
- // 1. Check if we're in tmux.
24
- if (!inTmux())
25
- return { ok: false, reason: 'no_tmux' };
26
- // 2. Adopt: scan for an existing live companion viewer pane.
27
- const allPanes = liveViewerPanes();
28
- const candidatePanes = allPanes
29
- .filter((p) => p.nodeId === companionNodeId && paneRunning(p.pane))
30
- .sort((a, b) => b.stampMs - a.stampMs);
31
- if (candidatePanes.length > 0) {
32
- const adopted = candidatePanes[0];
33
- return { ok: true, paneId: adopted.pane, origin: 'adopted' };
34
- }
35
- // 3. Check for a valid caller pane.
36
- if (callerPane === undefined || callerPane === '') {
37
- return { ok: false, reason: 'no_caller_pane' };
38
- }
39
- // 4. Get the caller pane's size.
40
- const size = paneSize(callerPane);
41
- if (size === null) {
42
- return { ok: false, reason: 'split_refused' };
43
- }
44
- // 5. Decide direction and companion size.
45
- let vertical;
46
- let companionSize;
47
- if (size.cols >= SPLIT_MIN_COLS) {
48
- // Horizontal split: companion on the right.
49
- vertical = false;
50
- companionSize = Math.max(MIN_COMPANION_COLS, Math.round(size.cols * COMPANION_WIDTH_RATIO));
51
- }
52
- else {
53
- // Vertical split: companion below.
54
- vertical = true;
55
- companionSize = Math.max(MIN_COMPANION_ROWS, Math.round(size.rows * COMPANION_HEIGHT_RATIO));
56
- }
57
- // 6. Split the window and get the new pane id.
58
- const newPaneId = splitWindow(callerPane, {
59
- cwd,
60
- env: viewerEnv(),
61
- command: `crtr surface attach to ${companionNodeId}`,
62
- vertical,
63
- size: companionSize,
64
- });
65
- if (newPaneId === null) {
66
- return { ok: false, reason: 'split_refused' };
67
- }
68
- return { ok: true, paneId: newPaneId, origin: 'opened' };
69
- }
70
- /** Open a column for a comment's fork, splitting the rightmost review pane —
71
- * the newest fork, else the companion — so columns accumulate to the right and
72
- * the document keeps its width. */
73
- export function openForkPane(args) {
74
- const { nodeId, cwd, splitFrom } = args;
75
- if (!inTmux())
76
- return { ok: false, reason: 'no_tmux' };
77
- if (splitFrom === undefined || splitFrom === '')
78
- return { ok: false, reason: 'no_caller_pane' };
79
- const size = paneSize(splitFrom);
80
- if (size === null)
81
- return { ok: false, reason: 'split_refused' };
82
- if (Math.floor(size.cols / 2) < MIN_FORK_COLS)
83
- return { ok: false, reason: 'no_room' };
84
- const paneId = splitWindow(splitFrom, {
85
- cwd,
86
- env: viewerEnv(),
87
- command: `crtr surface attach to ${nodeId}`,
88
- vertical: false,
89
- size: Math.floor(size.cols / 2),
90
- });
91
- return paneId === null ? { ok: false, reason: 'split_refused' } : { ok: true, paneId };
92
- }
93
- /** True while tmux can still describe `paneId` and its process is alive.
94
- * Deliberately tag-free: a companion pane carries `@crtr_node` only once its
95
- * viewer has connected, so a tag check would call a still-booting pane dead
96
- * and let a duplicate be split beside it. */
97
- export function companionPaneLive(paneId) {
98
- return paneExists(paneId) && paneRunning(paneId);
99
- }
100
- /** Kill the pane only when it still exists AND still carries
101
- * `@crtr_node === companionNodeId`. */
102
- export function closeCompanionPane(paneId, companionNodeId) {
103
- if (!paneExists(paneId))
104
- return;
105
- const currentNodeId = getPaneOption(paneId, '@crtr_node');
106
- if (currentNodeId !== companionNodeId)
107
- return;
108
- closePane(paneId);
109
- }