@onpoint-dev-tools/crewcoder-opentui 0.0.0-stage → 0.1.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 (325) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +262 -2
  3. package/THIRD_PARTY_NOTICES.md +51 -0
  4. package/dist/App.d.ts +16 -0
  5. package/dist/App.d.ts.map +1 -0
  6. package/dist/App.js +428 -0
  7. package/dist/App.js.map +1 -0
  8. package/dist/Root.d.ts +11 -0
  9. package/dist/Root.d.ts.map +1 -0
  10. package/dist/Root.js +13 -0
  11. package/dist/Root.js.map +1 -0
  12. package/dist/alert-model.d.ts +31 -0
  13. package/dist/alert-model.d.ts.map +1 -0
  14. package/dist/alert-model.js +34 -0
  15. package/dist/alert-model.js.map +1 -0
  16. package/dist/args.d.ts +13 -0
  17. package/dist/args.d.ts.map +1 -0
  18. package/dist/args.js +63 -0
  19. package/dist/args.js.map +1 -0
  20. package/dist/attachments.d.ts +29 -0
  21. package/dist/attachments.d.ts.map +1 -0
  22. package/dist/attachments.js +38 -0
  23. package/dist/attachments.js.map +1 -0
  24. package/dist/block-panels.d.ts +43 -0
  25. package/dist/block-panels.d.ts.map +1 -0
  26. package/dist/block-panels.js +210 -0
  27. package/dist/block-panels.js.map +1 -0
  28. package/dist/cli.d.ts +3 -0
  29. package/dist/cli.d.ts.map +1 -0
  30. package/dist/cli.js +138 -0
  31. package/dist/cli.js.map +1 -0
  32. package/dist/command-format.d.ts +18 -0
  33. package/dist/command-format.d.ts.map +1 -0
  34. package/dist/command-format.js +66 -0
  35. package/dist/command-format.js.map +1 -0
  36. package/dist/command-runner.d.ts +128 -0
  37. package/dist/command-runner.d.ts.map +1 -0
  38. package/dist/command-runner.js +571 -0
  39. package/dist/command-runner.js.map +1 -0
  40. package/dist/commands.d.ts +47 -0
  41. package/dist/commands.d.ts.map +1 -0
  42. package/dist/commands.js +108 -0
  43. package/dist/commands.js.map +1 -0
  44. package/dist/components/AttachmentRow.d.ts +11 -0
  45. package/dist/components/AttachmentRow.d.ts.map +1 -0
  46. package/dist/components/AttachmentRow.js +17 -0
  47. package/dist/components/AttachmentRow.js.map +1 -0
  48. package/dist/components/Composer.d.ts +23 -0
  49. package/dist/components/Composer.d.ts.map +1 -0
  50. package/dist/components/Composer.js +45 -0
  51. package/dist/components/Composer.js.map +1 -0
  52. package/dist/components/ExtensionQuestion.d.ts +18 -0
  53. package/dist/components/ExtensionQuestion.d.ts.map +1 -0
  54. package/dist/components/ExtensionQuestion.js +45 -0
  55. package/dist/components/ExtensionQuestion.js.map +1 -0
  56. package/dist/components/GoalForm.d.ts +18 -0
  57. package/dist/components/GoalForm.d.ts.map +1 -0
  58. package/dist/components/GoalForm.js +26 -0
  59. package/dist/components/GoalForm.js.map +1 -0
  60. package/dist/components/Home.d.ts +21 -0
  61. package/dist/components/Home.d.ts.map +1 -0
  62. package/dist/components/Home.js +48 -0
  63. package/dist/components/Home.js.map +1 -0
  64. package/dist/components/MentionList.d.ts +14 -0
  65. package/dist/components/MentionList.d.ts.map +1 -0
  66. package/dist/components/MentionList.js +24 -0
  67. package/dist/components/MentionList.js.map +1 -0
  68. package/dist/components/SearchBar.d.ts +19 -0
  69. package/dist/components/SearchBar.d.ts.map +1 -0
  70. package/dist/components/SearchBar.js +28 -0
  71. package/dist/components/SearchBar.js.map +1 -0
  72. package/dist/components/Sidebar.d.ts +19 -0
  73. package/dist/components/Sidebar.d.ts.map +1 -0
  74. package/dist/components/Sidebar.js +35 -0
  75. package/dist/components/Sidebar.js.map +1 -0
  76. package/dist/components/SummaryEditor.d.ts +16 -0
  77. package/dist/components/SummaryEditor.d.ts.map +1 -0
  78. package/dist/components/SummaryEditor.js +21 -0
  79. package/dist/components/SummaryEditor.js.map +1 -0
  80. package/dist/components/Transcript.d.ts +37 -0
  81. package/dist/components/Transcript.d.ts.map +1 -0
  82. package/dist/components/Transcript.js +314 -0
  83. package/dist/components/Transcript.js.map +1 -0
  84. package/dist/components/ui/alert.d.ts +9 -0
  85. package/dist/components/ui/alert.d.ts.map +1 -0
  86. package/dist/components/ui/alert.js +18 -0
  87. package/dist/components/ui/alert.js.map +1 -0
  88. package/dist/components/ui/command-palette.d.ts +15 -0
  89. package/dist/components/ui/command-palette.d.ts.map +1 -0
  90. package/dist/components/ui/command-palette.js +14 -0
  91. package/dist/components/ui/command-palette.js.map +1 -0
  92. package/dist/components/ui/confirm.d.ts +12 -0
  93. package/dist/components/ui/confirm.d.ts.map +1 -0
  94. package/dist/components/ui/confirm.js +16 -0
  95. package/dist/components/ui/confirm.js.map +1 -0
  96. package/dist/components/ui/select.d.ts +11 -0
  97. package/dist/components/ui/select.d.ts.map +1 -0
  98. package/dist/components/ui/select.js +29 -0
  99. package/dist/components/ui/select.js.map +1 -0
  100. package/dist/components/ui/spinner.d.ts +14 -0
  101. package/dist/components/ui/spinner.d.ts.map +1 -0
  102. package/dist/components/ui/spinner.js +17 -0
  103. package/dist/components/ui/spinner.js.map +1 -0
  104. package/dist/components/ui/tool-approval.d.ts +14 -0
  105. package/dist/components/ui/tool-approval.d.ts.map +1 -0
  106. package/dist/components/ui/tool-approval.js +37 -0
  107. package/dist/components/ui/tool-approval.js.map +1 -0
  108. package/dist/components/ui/tool-call.d.ts +12 -0
  109. package/dist/components/ui/tool-call.d.ts.map +1 -0
  110. package/dist/components/ui/tool-call.js +69 -0
  111. package/dist/components/ui/tool-call.js.map +1 -0
  112. package/dist/components/ui/types.d.ts +82 -0
  113. package/dist/components/ui/types.d.ts.map +1 -0
  114. package/dist/components/ui/types.js +2 -0
  115. package/dist/components/ui/types.js.map +1 -0
  116. package/dist/crewcoder-cli.d.ts +51 -0
  117. package/dist/crewcoder-cli.d.ts.map +1 -0
  118. package/dist/crewcoder-cli.js +26 -0
  119. package/dist/crewcoder-cli.js.map +1 -0
  120. package/dist/diff-anchors.d.ts +14 -0
  121. package/dist/diff-anchors.d.ts.map +1 -0
  122. package/dist/diff-anchors.js +43 -0
  123. package/dist/diff-anchors.js.map +1 -0
  124. package/dist/footer-layout.d.ts +49 -0
  125. package/dist/footer-layout.d.ts.map +1 -0
  126. package/dist/footer-layout.js +79 -0
  127. package/dist/footer-layout.js.map +1 -0
  128. package/dist/glyphs.d.ts +32 -0
  129. package/dist/glyphs.d.ts.map +1 -0
  130. package/dist/glyphs.js +35 -0
  131. package/dist/glyphs.js.map +1 -0
  132. package/dist/goal-form.d.ts +47 -0
  133. package/dist/goal-form.d.ts.map +1 -0
  134. package/dist/goal-form.js +59 -0
  135. package/dist/goal-form.js.map +1 -0
  136. package/dist/hooks/use-animation.d.ts +6 -0
  137. package/dist/hooks/use-animation.d.ts.map +1 -0
  138. package/dist/hooks/use-animation.js +52 -0
  139. package/dist/hooks/use-animation.js.map +1 -0
  140. package/dist/hooks/use-app-colors.d.ts +6 -0
  141. package/dist/hooks/use-app-colors.d.ts.map +1 -0
  142. package/dist/hooks/use-app-colors.js +6 -0
  143. package/dist/hooks/use-app-colors.js.map +1 -0
  144. package/dist/hooks/use-glyph-set.d.ts +8 -0
  145. package/dist/hooks/use-glyph-set.d.ts.map +1 -0
  146. package/dist/hooks/use-glyph-set.js +22 -0
  147. package/dist/hooks/use-glyph-set.js.map +1 -0
  148. package/dist/hooks/use-motion.d.ts +6 -0
  149. package/dist/hooks/use-motion.d.ts.map +1 -0
  150. package/dist/hooks/use-motion.js +8 -0
  151. package/dist/hooks/use-motion.js.map +1 -0
  152. package/dist/hooks/use-terminal-focus.d.ts +16 -0
  153. package/dist/hooks/use-terminal-focus.d.ts.map +1 -0
  154. package/dist/hooks/use-terminal-focus.js +30 -0
  155. package/dist/hooks/use-terminal-focus.js.map +1 -0
  156. package/dist/hooks/use-theme.d.ts +6 -0
  157. package/dist/hooks/use-theme.d.ts.map +1 -0
  158. package/dist/hooks/use-theme.js +11 -0
  159. package/dist/hooks/use-theme.js.map +1 -0
  160. package/dist/hunk.d.ts +27 -0
  161. package/dist/hunk.d.ts.map +1 -0
  162. package/dist/hunk.js +43 -0
  163. package/dist/hunk.js.map +1 -0
  164. package/dist/image-view.d.ts +33 -0
  165. package/dist/image-view.d.ts.map +1 -0
  166. package/dist/image-view.js +51 -0
  167. package/dist/image-view.js.map +1 -0
  168. package/dist/keybindings.d.ts +28 -0
  169. package/dist/keybindings.d.ts.map +1 -0
  170. package/dist/keybindings.js +105 -0
  171. package/dist/keybindings.js.map +1 -0
  172. package/dist/lib/terminal-themes/default.d.ts +3 -0
  173. package/dist/lib/terminal-themes/default.d.ts.map +1 -0
  174. package/dist/lib/terminal-themes/default.js +49 -0
  175. package/dist/lib/terminal-themes/default.js.map +1 -0
  176. package/dist/logo-pulse.d.ts +23 -0
  177. package/dist/logo-pulse.d.ts.map +1 -0
  178. package/dist/logo-pulse.js +30 -0
  179. package/dist/logo-pulse.js.map +1 -0
  180. package/dist/markdown-style.d.ts +47 -0
  181. package/dist/markdown-style.d.ts.map +1 -0
  182. package/dist/markdown-style.js +138 -0
  183. package/dist/markdown-style.js.map +1 -0
  184. package/dist/mentions.d.ts +57 -0
  185. package/dist/mentions.d.ts.map +1 -0
  186. package/dist/mentions.js +109 -0
  187. package/dist/mentions.js.map +1 -0
  188. package/dist/palette-model.d.ts +42 -0
  189. package/dist/palette-model.d.ts.map +1 -0
  190. package/dist/palette-model.js +77 -0
  191. package/dist/palette-model.js.map +1 -0
  192. package/dist/path-suggestions.d.ts +50 -0
  193. package/dist/path-suggestions.d.ts.map +1 -0
  194. package/dist/path-suggestions.js +99 -0
  195. package/dist/path-suggestions.js.map +1 -0
  196. package/dist/picker-flows.d.ts +78 -0
  197. package/dist/picker-flows.d.ts.map +1 -0
  198. package/dist/picker-flows.js +444 -0
  199. package/dist/picker-flows.js.map +1 -0
  200. package/dist/pickers.d.ts +34 -0
  201. package/dist/pickers.d.ts.map +1 -0
  202. package/dist/pickers.js +136 -0
  203. package/dist/pickers.js.map +1 -0
  204. package/dist/prompt-history.d.ts +32 -0
  205. package/dist/prompt-history.d.ts.map +1 -0
  206. package/dist/prompt-history.js +40 -0
  207. package/dist/prompt-history.js.map +1 -0
  208. package/dist/providers/app-theme-provider.d.ts +12 -0
  209. package/dist/providers/app-theme-provider.d.ts.map +1 -0
  210. package/dist/providers/app-theme-provider.js +14 -0
  211. package/dist/providers/app-theme-provider.js.map +1 -0
  212. package/dist/providers/theme-provider.d.ts +10 -0
  213. package/dist/providers/theme-provider.d.ts.map +1 -0
  214. package/dist/providers/theme-provider.js +57 -0
  215. package/dist/providers/theme-provider.js.map +1 -0
  216. package/dist/question-model.d.ts +71 -0
  217. package/dist/question-model.d.ts.map +1 -0
  218. package/dist/question-model.js +176 -0
  219. package/dist/question-model.js.map +1 -0
  220. package/dist/search-controller.d.ts +46 -0
  221. package/dist/search-controller.d.ts.map +1 -0
  222. package/dist/search-controller.js +89 -0
  223. package/dist/search-controller.js.map +1 -0
  224. package/dist/search-jump.d.ts +27 -0
  225. package/dist/search-jump.d.ts.map +1 -0
  226. package/dist/search-jump.js +65 -0
  227. package/dist/search-jump.js.map +1 -0
  228. package/dist/session-controller.d.ts +268 -0
  229. package/dist/session-controller.d.ts.map +1 -0
  230. package/dist/session-controller.js +941 -0
  231. package/dist/session-controller.js.map +1 -0
  232. package/dist/sidebar-model.d.ts +45 -0
  233. package/dist/sidebar-model.d.ts.map +1 -0
  234. package/dist/sidebar-model.js +223 -0
  235. package/dist/sidebar-model.js.map +1 -0
  236. package/dist/sidebar.d.ts +49 -0
  237. package/dist/sidebar.d.ts.map +1 -0
  238. package/dist/sidebar.js +106 -0
  239. package/dist/sidebar.js.map +1 -0
  240. package/dist/status-line.d.ts +32 -0
  241. package/dist/status-line.d.ts.map +1 -0
  242. package/dist/status-line.js +69 -0
  243. package/dist/status-line.js.map +1 -0
  244. package/dist/syntax/filetype.d.ts +12 -0
  245. package/dist/syntax/filetype.d.ts.map +1 -0
  246. package/dist/syntax/filetype.js +28 -0
  247. package/dist/syntax/filetype.js.map +1 -0
  248. package/dist/syntax/grammars.d.ts +42 -0
  249. package/dist/syntax/grammars.d.ts.map +1 -0
  250. package/dist/syntax/grammars.js +52 -0
  251. package/dist/syntax/grammars.js.map +1 -0
  252. package/dist/text-offset.d.ts +5 -0
  253. package/dist/text-offset.d.ts.map +1 -0
  254. package/dist/text-offset.js +38 -0
  255. package/dist/text-offset.js.map +1 -0
  256. package/dist/text-wrap.d.ts +12 -0
  257. package/dist/text-wrap.d.ts.map +1 -0
  258. package/dist/text-wrap.js +53 -0
  259. package/dist/text-wrap.js.map +1 -0
  260. package/dist/theme-controller.d.ts +77 -0
  261. package/dist/theme-controller.d.ts.map +1 -0
  262. package/dist/theme-controller.js +178 -0
  263. package/dist/theme-controller.js.map +1 -0
  264. package/dist/theme.d.ts +51 -0
  265. package/dist/theme.d.ts.map +1 -0
  266. package/dist/theme.js +86 -0
  267. package/dist/theme.js.map +1 -0
  268. package/dist/tmux-check.d.ts +35 -0
  269. package/dist/tmux-check.d.ts.map +1 -0
  270. package/dist/tmux-check.js +66 -0
  271. package/dist/tmux-check.js.map +1 -0
  272. package/dist/tmux.d.ts +69 -0
  273. package/dist/tmux.d.ts.map +1 -0
  274. package/dist/tmux.js +135 -0
  275. package/dist/tmux.js.map +1 -0
  276. package/dist/tool-diff.d.ts +51 -0
  277. package/dist/tool-diff.d.ts.map +1 -0
  278. package/dist/tool-diff.js +158 -0
  279. package/dist/tool-diff.js.map +1 -0
  280. package/dist/tool-presentation.d.ts +46 -0
  281. package/dist/tool-presentation.d.ts.map +1 -0
  282. package/dist/tool-presentation.js +148 -0
  283. package/dist/tool-presentation.js.map +1 -0
  284. package/dist/tool-renderer-view.d.ts +14 -0
  285. package/dist/tool-renderer-view.d.ts.map +1 -0
  286. package/dist/tool-renderer-view.js +10 -0
  287. package/dist/tool-renderer-view.js.map +1 -0
  288. package/dist/transcript-search.d.ts +54 -0
  289. package/dist/transcript-search.d.ts.map +1 -0
  290. package/dist/transcript-search.js +160 -0
  291. package/dist/transcript-search.js.map +1 -0
  292. package/dist/transcript.d.ts +59 -0
  293. package/dist/transcript.d.ts.map +1 -0
  294. package/dist/transcript.js +123 -0
  295. package/dist/transcript.js.map +1 -0
  296. package/dist/workflow-tools.d.ts +42 -0
  297. package/dist/workflow-tools.d.ts.map +1 -0
  298. package/dist/workflow-tools.js +89 -0
  299. package/dist/workflow-tools.js.map +1 -0
  300. package/examples/themes/ember.json +75 -0
  301. package/grammars/bash/LICENSE +21 -0
  302. package/grammars/bash/highlights.scm +56 -0
  303. package/grammars/bash/tree-sitter-bash.wasm +0 -0
  304. package/grammars/css/LICENSE +21 -0
  305. package/grammars/css/highlights.scm +76 -0
  306. package/grammars/css/tree-sitter-css.wasm +0 -0
  307. package/grammars/go/LICENSE +21 -0
  308. package/grammars/go/highlights.scm +123 -0
  309. package/grammars/go/tree-sitter-go.wasm +0 -0
  310. package/grammars/html/LICENSE +21 -0
  311. package/grammars/html/highlights.scm +13 -0
  312. package/grammars/html/tree-sitter-html.wasm +0 -0
  313. package/grammars/json/LICENSE +21 -0
  314. package/grammars/json/highlights.scm +16 -0
  315. package/grammars/json/tree-sitter-json.wasm +0 -0
  316. package/grammars/python/LICENSE +21 -0
  317. package/grammars/python/highlights.scm +137 -0
  318. package/grammars/python/tree-sitter-python.wasm +0 -0
  319. package/grammars/rust/LICENSE +21 -0
  320. package/grammars/rust/highlights.scm +161 -0
  321. package/grammars/rust/tree-sitter-rust.wasm +0 -0
  322. package/grammars/yaml/LICENSE +20 -0
  323. package/grammars/yaml/highlights.scm +79 -0
  324. package/grammars/yaml/tree-sitter-yaml.wasm +0 -0
  325. package/package.json +56 -5
package/dist/tmux.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { type CrewCoderCrewTarget } from "@onpoint-dev-tools/crewcoder-tui-core/bridge/crewcoder-process";
2
+ /**
3
+ * Crews in tmux (`docs/CREWS.md#tmux`): `/crew` and `/team` can run in a second
4
+ * CrewCoder UI inside tmux, so the crew keeps going after this UI closes. The
5
+ * user attaches to watch it and answer approvals there.
6
+ *
7
+ * Everything the second UI needs goes in a private handoff file, never on the
8
+ * command line: argv is visible to every user through `ps`, and `CREWCODER_*`
9
+ * variables can hold credentials. The tmux server also has its own environment
10
+ * (not this process's), so the variables travel in the file too.
11
+ */
12
+ /** What the second UI runs, plus the settings and environment it starts with. */
13
+ export type CrewHandoff = {
14
+ version: 1;
15
+ target: CrewCoderCrewTarget;
16
+ task: string;
17
+ /** What the user typed, shown as their message in the second UI. */
18
+ command: string;
19
+ cwd: string;
20
+ provider: string;
21
+ model: string;
22
+ effort: string;
23
+ mode: string;
24
+ systemPrompt?: string;
25
+ fullAccess: boolean;
26
+ /** `CREWCODER_*` variables (agent binary, home, task override, theme, ...) and PATH. */
27
+ env: Record<string, string>;
28
+ };
29
+ /** Where the crew went: a new window in the user's tmux, or a detached session. */
30
+ export type TmuxPlacement = {
31
+ kind: "window";
32
+ name: string;
33
+ } | {
34
+ kind: "session";
35
+ name: string;
36
+ };
37
+ export type TmuxLauncher = {
38
+ /** Start `command` (argv, no shell) in tmux, in `cwd`, named after `label`. */
39
+ launch(command: readonly string[], cwd: string, label: string): Promise<TmuxPlacement>;
40
+ };
41
+ /** Variables the second UI needs from this one. */
42
+ export declare function handoffEnv(env: NodeJS.ProcessEnv): Record<string, string>;
43
+ /** tmux names: the label's safe characters plus a short unique suffix (names are tmux targets). */
44
+ export declare function tmuxName(label: string, suffix: string): string;
45
+ /**
46
+ * Arguments for `tmux`. Inside tmux ($TMUX set) the crew opens as a new window in
47
+ * the user's session; outside, as a detached session to attach to. The command
48
+ * follows `--` as separate arguments, so tmux runs it without a shell.
49
+ */
50
+ export declare function tmuxLaunchArgs(command: readonly string[], cwd: string, name: string, inside: boolean): string[];
51
+ /** How the user reaches the crew. */
52
+ export declare function tmuxAttachHint(placement: TmuxPlacement): string;
53
+ /** Write the handoff file (owner-only) and return its path. */
54
+ export declare function writeCrewHandoff(handoff: CrewHandoff, dir?: string): string;
55
+ /**
56
+ * Read and delete a handoff file. It is our own file, but it sits in a shared temp
57
+ * directory, so it is checked like input: owned by this user, not readable by
58
+ * others, and every field the crew uses is validated.
59
+ */
60
+ export declare function readCrewHandoff(file: string): CrewHandoff;
61
+ export declare function parseCrewHandoff(raw: unknown): CrewHandoff;
62
+ /** Delete handoff files nobody picked up (the second UI failed to start). */
63
+ export declare function removeCrewHandoff(file: string): void;
64
+ /**
65
+ * The real launcher, or undefined when tmux is not installed. Called once at
66
+ * startup (a quick `tmux -V`).
67
+ */
68
+ export declare function systemTmux(env?: NodeJS.ProcessEnv): TmuxLauncher | undefined;
69
+ //# sourceMappingURL=tmux.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../src/tmux.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AAEtH;;;;;;;;;GASG;AAEH,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG,MAAM,MAAM,YAAY,GAAG;IACzB,+EAA+E;IAC/E,MAAM,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACxF,CAAC;AAIF,mDAAmD;AACnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMzE;AAED,mGAAmG;AACnG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAI/G;AAED,qCAAqC;AACrC,wBAAgB,cAAc,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAI/D;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,SAAc,GAAG,MAAM,CAKhF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAYzD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CA+B1D;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,YAAY,GAAG,SAAS,CAmBzF"}
package/dist/tmux.js ADDED
@@ -0,0 +1,135 @@
1
+ import { spawn, spawnSync } from "node:child_process";
2
+ import crypto from "node:crypto";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { isCrewName } from "@onpoint-dev-tools/crewcoder-tui-core/bridge/crewcoder-process";
7
+ const HANDOFF_PREFIX = "crewcoder-crew-";
8
+ /** Variables the second UI needs from this one. */
9
+ export function handoffEnv(env) {
10
+ const picked = {};
11
+ for (const [key, value] of Object.entries(env)) {
12
+ if (value !== undefined && (key.startsWith("CREWCODER_") || key === "PATH"))
13
+ picked[key] = value;
14
+ }
15
+ return picked;
16
+ }
17
+ /** tmux names: the label's safe characters plus a short unique suffix (names are tmux targets). */
18
+ export function tmuxName(label, suffix) {
19
+ const base = label.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "crew";
20
+ return `crew-${base}-${suffix}`;
21
+ }
22
+ /**
23
+ * Arguments for `tmux`. Inside tmux ($TMUX set) the crew opens as a new window in
24
+ * the user's session; outside, as a detached session to attach to. The command
25
+ * follows `--` as separate arguments, so tmux runs it without a shell.
26
+ */
27
+ export function tmuxLaunchArgs(command, cwd, name, inside) {
28
+ return inside
29
+ ? ["new-window", "-d", "-n", name, "-c", cwd, "--", ...command]
30
+ : ["new-session", "-d", "-s", name, "-c", cwd, "--", ...command];
31
+ }
32
+ /** How the user reaches the crew. */
33
+ export function tmuxAttachHint(placement) {
34
+ return placement.kind === "window"
35
+ ? `Opened tmux window ${placement.name}. Switch to it with your tmux prefix + w.`
36
+ : `Started tmux session ${placement.name}. Attach with: tmux attach -t ${placement.name}`;
37
+ }
38
+ /** Write the handoff file (owner-only) and return its path. */
39
+ export function writeCrewHandoff(handoff, dir = os.tmpdir()) {
40
+ const file = path.join(dir, `${HANDOFF_PREFIX}${crypto.randomBytes(8).toString("hex")}.json`);
41
+ // `wx`: never follow or overwrite something already at that path.
42
+ fs.writeFileSync(file, JSON.stringify(handoff), { mode: 0o600, flag: "wx" });
43
+ return file;
44
+ }
45
+ /**
46
+ * Read and delete a handoff file. It is our own file, but it sits in a shared temp
47
+ * directory, so it is checked like input: owned by this user, not readable by
48
+ * others, and every field the crew uses is validated.
49
+ */
50
+ export function readCrewHandoff(file) {
51
+ const stat = fs.lstatSync(file);
52
+ if (!stat.isFile())
53
+ throw new Error(`Crew handoff is not a file: ${file}`);
54
+ if (typeof process.getuid === "function" && stat.uid !== process.getuid())
55
+ throw new Error(`Crew handoff is owned by another user: ${file}`);
56
+ if ((stat.mode & 0o077) !== 0)
57
+ throw new Error(`Crew handoff is readable by other users: ${file}`);
58
+ let raw;
59
+ try {
60
+ raw = JSON.parse(fs.readFileSync(file, "utf8"));
61
+ }
62
+ finally {
63
+ fs.rmSync(file, { force: true });
64
+ }
65
+ return parseCrewHandoff(raw);
66
+ }
67
+ export function parseCrewHandoff(raw) {
68
+ const value = raw;
69
+ const text = (key) => {
70
+ const field = value?.[key];
71
+ if (typeof field !== "string" || !field)
72
+ throw new Error(`Crew handoff has no ${key}`);
73
+ return field;
74
+ };
75
+ if (!value || value.version !== 1)
76
+ throw new Error("Unsupported crew handoff");
77
+ const target = value.target;
78
+ const validTarget = target?.kind === "workers"
79
+ ? Array.isArray(target.workers) && target.workers.length > 0 && target.workers.every((name) => typeof name === "string" && isCrewName(name))
80
+ : target?.kind === "team" && typeof target.team === "string" && isCrewName(target.team);
81
+ if (!target || !validTarget)
82
+ throw new Error("Crew handoff has an invalid worker or team");
83
+ const env = {};
84
+ for (const [key, entry] of Object.entries(value.env ?? {})) {
85
+ if (typeof entry === "string" && (key.startsWith("CREWCODER_") || key === "PATH"))
86
+ env[key] = entry;
87
+ }
88
+ return {
89
+ version: 1,
90
+ target,
91
+ task: text("task"),
92
+ command: text("command"),
93
+ cwd: text("cwd"),
94
+ provider: text("provider"),
95
+ model: text("model"),
96
+ effort: text("effort"),
97
+ mode: text("mode"),
98
+ systemPrompt: typeof value.systemPrompt === "string" && value.systemPrompt ? value.systemPrompt : undefined,
99
+ fullAccess: value.fullAccess === true,
100
+ env
101
+ };
102
+ }
103
+ /** Delete handoff files nobody picked up (the second UI failed to start). */
104
+ export function removeCrewHandoff(file) {
105
+ if (path.basename(file).startsWith(HANDOFF_PREFIX))
106
+ fs.rmSync(file, { force: true });
107
+ }
108
+ /**
109
+ * The real launcher, or undefined when tmux is not installed. Called once at
110
+ * startup (a quick `tmux -V`).
111
+ */
112
+ export function systemTmux(env = process.env) {
113
+ const probe = spawnSync("tmux", ["-V"], { stdio: "ignore", timeout: 2_000 });
114
+ if (probe.error || probe.status !== 0)
115
+ return undefined;
116
+ const inside = Boolean(env.TMUX);
117
+ return {
118
+ launch(command, cwd, label) {
119
+ const name = tmuxName(label, crypto.randomBytes(2).toString("hex"));
120
+ return new Promise((resolve, reject) => {
121
+ const child = spawn("tmux", tmuxLaunchArgs(command, cwd, name, inside), { stdio: ["ignore", "ignore", "pipe"] });
122
+ let stderr = "";
123
+ child.stderr.on("data", (chunk) => { stderr += String(chunk); });
124
+ child.on("error", reject);
125
+ child.on("close", (code) => {
126
+ if (code === 0)
127
+ resolve(inside ? { kind: "window", name } : { kind: "session", name });
128
+ else
129
+ reject(new Error(stderr.trim() || `tmux exited with ${code ?? "a signal"}`));
130
+ });
131
+ });
132
+ }
133
+ };
134
+ }
135
+ //# sourceMappingURL=tmux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tmux.js","sourceRoot":"","sources":["../src/tmux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAA4B,MAAM,gEAAgE,CAAC;AAuCtH,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC,mDAAmD;AACnD,MAAM,UAAU,UAAU,CAAC,GAAsB;IAC/C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,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awnSync } from \"node:child_process\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { isCrewName, type CrewCoderCrewTarget } from \"@onpoint-dev-tools/crewcoder-tui-core/bridge/crewcoder-process\";\n\n/**\n * Crews in tmux (`docs/CREWS.md#tmux`): `/crew` and `/team` can run in a second\n * CrewCoder UI inside tmux, so the crew keeps going after this UI closes. The\n * user attaches to watch it and answer approvals there.\n *\n * Everything the second UI needs goes in a private handoff file, never on the\n * command line: argv is visible to every user through `ps`, and `CREWCODER_*`\n * variables can hold credentials. The tmux server also has its own environment\n * (not this process's), so the variables travel in the file too.\n */\n\n/** What the second UI runs, plus the settings and environment it starts with. */\nexport type CrewHandoff = {\n version: 1;\n target: CrewCoderCrewTarget;\n task: string;\n /** What the user typed, shown as their message in the second UI. */\n command: string;\n cwd: string;\n provider: string;\n model: string;\n effort: string;\n mode: string;\n systemPrompt?: string;\n fullAccess: boolean;\n /** `CREWCODER_*` variables (agent binary, home, task override, theme, ...) and PATH. */\n env: Record<string, string>;\n};\n\n/** Where the crew went: a new window in the user's tmux, or a detached session. */\nexport type TmuxPlacement = { kind: \"window\"; name: string } | { kind: \"session\"; name: string };\n\nexport type TmuxLauncher = {\n /** Start `command` (argv, no shell) in tmux, in `cwd`, named after `label`. */\n launch(command: readonly string[], cwd: string, label: string): Promise<TmuxPlacement>;\n};\n\nconst HANDOFF_PREFIX = \"crewcoder-crew-\";\n\n/** Variables the second UI needs from this one. */\nexport function handoffEnv(env: NodeJS.ProcessEnv): Record<string, string> {\n const picked: Record<string, string> = {};\n for (const [key, value] of Object.entries(env)) {\n if (value !== undefined && (key.startsWith(\"CREWCODER_\") || key === \"PATH\")) picked[key] = value;\n }\n return picked;\n}\n\n/** tmux names: the label's safe characters plus a short unique suffix (names are tmux targets). */\nexport function tmuxName(label: string, suffix: string): string {\n const base = label.replace(/[^A-Za-z0-9_-]+/g, \"-\").replace(/^-+|-+$/g, \"\").slice(0, 32) || \"crew\";\n return `crew-${base}-${suffix}`;\n}\n\n/**\n * Arguments for `tmux`. Inside tmux ($TMUX set) the crew opens as a new window in\n * the user's session; outside, as a detached session to attach to. The command\n * follows `--` as separate arguments, so tmux runs it without a shell.\n */\nexport function tmuxLaunchArgs(command: readonly string[], cwd: string, name: string, inside: boolean): string[] {\n return inside\n ? [\"new-window\", \"-d\", \"-n\", name, \"-c\", cwd, \"--\", ...command]\n : [\"new-session\", \"-d\", \"-s\", name, \"-c\", cwd, \"--\", ...command];\n}\n\n/** How the user reaches the crew. */\nexport function tmuxAttachHint(placement: TmuxPlacement): string {\n return placement.kind === \"window\"\n ? `Opened tmux window ${placement.name}. Switch to it with your tmux prefix + w.`\n : `Started tmux session ${placement.name}. Attach with: tmux attach -t ${placement.name}`;\n}\n\n/** Write the handoff file (owner-only) and return its path. */\nexport function writeCrewHandoff(handoff: CrewHandoff, dir = os.tmpdir()): string {\n const file = path.join(dir, `${HANDOFF_PREFIX}${crypto.randomBytes(8).toString(\"hex\")}.json`);\n // `wx`: never follow or overwrite something already at that path.\n fs.writeFileSync(file, JSON.stringify(handoff), { mode: 0o600, flag: \"wx\" });\n return file;\n}\n\n/**\n * Read and delete a handoff file. It is our own file, but it sits in a shared temp\n * directory, so it is checked like input: owned by this user, not readable by\n * others, and every field the crew uses is validated.\n */\nexport function readCrewHandoff(file: string): CrewHandoff {\n const stat = fs.lstatSync(file);\n if (!stat.isFile()) throw new Error(`Crew handoff is not a file: ${file}`);\n if (typeof process.getuid === \"function\" && stat.uid !== process.getuid()) throw new Error(`Crew handoff is owned by another user: ${file}`);\n if ((stat.mode & 0o077) !== 0) throw new Error(`Crew handoff is readable by other users: ${file}`);\n let raw: unknown;\n try {\n raw = JSON.parse(fs.readFileSync(file, \"utf8\"));\n } finally {\n fs.rmSync(file, { force: true });\n }\n return parseCrewHandoff(raw);\n}\n\nexport function parseCrewHandoff(raw: unknown): CrewHandoff {\n const value = raw as Partial<CrewHandoff> | null;\n const text = (key: keyof CrewHandoff): string => {\n const field = value?.[key];\n if (typeof field !== \"string\" || !field) throw new Error(`Crew handoff has no ${key}`);\n return field;\n };\n if (!value || value.version !== 1) throw new Error(\"Unsupported crew handoff\");\n const target = value.target;\n const validTarget = target?.kind === \"workers\"\n ? Array.isArray(target.workers) && target.workers.length > 0 && target.workers.every((name) => typeof name === \"string\" && isCrewName(name))\n : target?.kind === \"team\" && typeof target.team === \"string\" && isCrewName(target.team);\n if (!target || !validTarget) throw new Error(\"Crew handoff has an invalid worker or team\");\n const env: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value.env ?? {})) {\n if (typeof entry === \"string\" && (key.startsWith(\"CREWCODER_\") || key === \"PATH\")) env[key] = entry;\n }\n return {\n version: 1,\n target,\n task: text(\"task\"),\n command: text(\"command\"),\n cwd: text(\"cwd\"),\n provider: text(\"provider\"),\n model: text(\"model\"),\n effort: text(\"effort\"),\n mode: text(\"mode\"),\n systemPrompt: typeof value.systemPrompt === \"string\" && value.systemPrompt ? value.systemPrompt : undefined,\n fullAccess: value.fullAccess === true,\n env\n };\n}\n\n/** Delete handoff files nobody picked up (the second UI failed to start). */\nexport function removeCrewHandoff(file: string): void {\n if (path.basename(file).startsWith(HANDOFF_PREFIX)) fs.rmSync(file, { force: true });\n}\n\n/**\n * The real launcher, or undefined when tmux is not installed. Called once at\n * startup (a quick `tmux -V`).\n */\nexport function systemTmux(env: NodeJS.ProcessEnv = process.env): TmuxLauncher | undefined {\n const probe = spawnSync(\"tmux\", [\"-V\"], { stdio: \"ignore\", timeout: 2_000 });\n if (probe.error || probe.status !== 0) return undefined;\n const inside = Boolean(env.TMUX);\n return {\n launch(command, cwd, label) {\n const name = tmuxName(label, crypto.randomBytes(2).toString(\"hex\"));\n return new Promise((resolve, reject) => {\n const child = spawn(\"tmux\", tmuxLaunchArgs(command, cwd, name, inside), { stdio: [\"ignore\", \"ignore\", \"pipe\"] });\n let stderr = \"\";\n child.stderr.on(\"data\", (chunk) => { stderr += String(chunk); });\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n if (code === 0) resolve(inside ? { kind: \"window\", name } : { kind: \"session\", name });\n else reject(new Error(stderr.trim() || `tmux exited with ${code ?? \"a signal\"}`));\n });\n });\n }\n };\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { type ToolBlock } from "./transcript.js";
2
+ /** One file's change from a tool call, as a single-file unified diff for OpenTUI's `<diff>`. */
3
+ export type FileDiff = {
4
+ path: string;
5
+ patch: string;
6
+ added: number;
7
+ removed: number;
8
+ /** Diff body lines (context, added, removed), for collapsing and the plain fallback. */
9
+ body: string[];
10
+ /**
11
+ * Whether hunk line numbers are the file's real ones. A snippet edit (Claude
12
+ * `Edit`, CrewCoder `edit`) only knows its real place once it is anchored in
13
+ * the file (see `SessionController`); until then it renders as plain +/- lines.
14
+ */
15
+ exactLines: boolean;
16
+ /** Shown instead of a diff body: binary files, or changes too large to include. */
17
+ note?: string;
18
+ status?: "added" | "modified";
19
+ };
20
+ /** A find/replace edit, as given in the tool's arguments (path not yet resolved). */
21
+ export type SnippetEdit = {
22
+ path: string;
23
+ before: string;
24
+ after: string;
25
+ };
26
+ /** 1-based file line where each snippet edit's new text starts, keyed by `anchorKey`. */
27
+ export type LineAnchors = ReadonlyMap<string, number>;
28
+ export declare function anchorKey(edit: SnippetEdit): string;
29
+ /**
30
+ * The file changes a tool call made, read from its arguments, so it works for
31
+ * every provider without the agent's help:
32
+ * - Codex `Codex file change`: `changes[]` with a unified `diff` (or full content for adds);
33
+ * - Claude `Edit` (`old_string`/`new_string`), `MultiEdit` (`edits[]`), `Write` (`content`);
34
+ * - CrewCoder `edit` (`find`/`replace`), `edit_transaction` (`edits[]` with paths), `write`;
35
+ * - otherwise, output that is itself a unified diff.
36
+ * Only edit/write tools get diffs (never shell commands), and only for files
37
+ * they created or modified; deletions are not shown (owner decision).
38
+ * Returns nothing for other tools and for edits that failed.
39
+ */
40
+ export declare function toolDiffs(block: ToolBlock, cwd?: string, anchors?: LineAnchors): FileDiff[];
41
+ /** A finished-or-running edit/write tool that did not fail. */
42
+ export declare function isEditTool(block: ToolBlock): boolean;
43
+ /**
44
+ * The find/replace edits in a tool call: Claude `Edit`/`MultiEdit`
45
+ * (`old_string`/`new_string`), CrewCoder `edit` and `edit_transaction`
46
+ * (`find`/`replace`).
47
+ */
48
+ export declare function snippetEdits(block: ToolBlock): SnippetEdit[];
49
+ /** 1-based line where `after` starts in the edited file's text, if it is there. */
50
+ export declare function findAnchor(fileText: string, after: string): number | undefined;
51
+ //# sourceMappingURL=tool-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-diff.d.ts","sourceRoot":"","sources":["../src/tool-diff.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5D,gGAAgG;AAChG,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,wFAAwF;IACxF,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;;;OAIG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC/B,CAAC;AAEF,qFAAqF;AACrF,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,yFAAyF;AACzF,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEnD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,EAAE,CAe3F;AAED,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,EAAE,CAU5D;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9E"}
@@ -0,0 +1,158 @@
1
+ import { formatPatch, parsePatch, structuredPatch } from "diff";
2
+ import { relativePath, toolKind } from "./tool-presentation.js";
3
+ import { normalize } from "./transcript.js";
4
+ export function anchorKey(edit) {
5
+ return `${edit.path}\u0000${edit.after}`;
6
+ }
7
+ const CONTEXT_LINES = 3;
8
+ /**
9
+ * The file changes a tool call made, read from its arguments, so it works for
10
+ * every provider without the agent's help:
11
+ * - Codex `Codex file change`: `changes[]` with a unified `diff` (or full content for adds);
12
+ * - Claude `Edit` (`old_string`/`new_string`), `MultiEdit` (`edits[]`), `Write` (`content`);
13
+ * - CrewCoder `edit` (`find`/`replace`), `edit_transaction` (`edits[]` with paths), `write`;
14
+ * - otherwise, output that is itself a unified diff.
15
+ * Only edit/write tools get diffs (never shell commands), and only for files
16
+ * they created or modified; deletions are not shown (owner decision).
17
+ * Returns nothing for other tools and for edits that failed.
18
+ */
19
+ export function toolDiffs(block, cwd, anchors) {
20
+ if (!isEditTool(block))
21
+ return [];
22
+ const display = (path) => relativePath(normalize(path), cwd);
23
+ // The agent's snapshot diffs are exact (real line numbers); arguments are the fallback.
24
+ if (block.fileDiffs?.length)
25
+ return block.fileDiffs.map((file) => agentDiff(file, display));
26
+ const args = block.args ?? {};
27
+ if (Array.isArray(args.changes))
28
+ return args.changes.flatMap((change) => codexChange(change, display));
29
+ const edits = snippetEdits(block);
30
+ if (edits.length > 0) {
31
+ return edits.map((edit) => snippetDiff(display(edit.path), edit.before, edit.after, anchors?.get(anchorKey(edit))));
32
+ }
33
+ const filePath = stringArg(args, "file_path", "path", "filePath", "notebook_path");
34
+ const content = rawArg(args, "content");
35
+ if (filePath && content !== undefined)
36
+ return [snippetDiff(display(filePath), "", content, 1)];
37
+ return outputDiffs(block.text ?? "", display);
38
+ }
39
+ /** A finished-or-running edit/write tool that did not fail. */
40
+ export function isEditTool(block) {
41
+ const kind = toolKind(block.name);
42
+ return block.status !== "error" && (kind === "edit" || kind === "write");
43
+ }
44
+ /**
45
+ * The find/replace edits in a tool call: Claude `Edit`/`MultiEdit`
46
+ * (`old_string`/`new_string`), CrewCoder `edit` and `edit_transaction`
47
+ * (`find`/`replace`).
48
+ */
49
+ export function snippetEdits(block) {
50
+ const args = block.args ?? {};
51
+ const filePath = stringArg(args, "file_path", "path", "filePath", "notebook_path");
52
+ const entries = Array.isArray(args.edits) ? args.edits.filter(isRecord) : [args];
53
+ return entries.flatMap((entry) => {
54
+ const path = stringArg(entry, "path", "file_path") ?? filePath;
55
+ const before = rawArg(entry, "old_string", "find", "oldText");
56
+ const after = rawArg(entry, "new_string", "replace", "newText");
57
+ return path && before !== undefined && after !== undefined ? [{ path, before, after }] : [];
58
+ });
59
+ }
60
+ /** 1-based line where `after` starts in the edited file's text, if it is there. */
61
+ export function findAnchor(fileText, after) {
62
+ if (!after)
63
+ return undefined;
64
+ const index = fileText.indexOf(after);
65
+ return index < 0 ? undefined : fileText.slice(0, index).split("\n").length;
66
+ }
67
+ /** A file from the agent's `file_diff` event: a real git patch, or a note when it has none. */
68
+ function agentDiff(file, display) {
69
+ const path = display(file.path);
70
+ const base = { path, added: file.additions, removed: file.deletions, status: file.status };
71
+ const parsed = file.patch ? parsedDiffs(normalize(file.patch), () => path)[0] : undefined;
72
+ if (parsed)
73
+ return { ...parsed, ...base };
74
+ const note = file.binary ? "binary file" : file.truncated ? "diff too large to show" : "no text changes";
75
+ return { ...base, patch: "", body: [], exactLines: true, note };
76
+ }
77
+ /** A Codex `FileUpdateChange`: `{ path, kind: { type: add | delete | update }, diff }`. */
78
+ function codexChange(change, display) {
79
+ if (!isRecord(change))
80
+ return [];
81
+ const path = stringArg(change, "path");
82
+ const diff = rawArg(change, "diff", "unified_diff");
83
+ if (!path || diff === undefined)
84
+ return [];
85
+ const type = isRecord(change.kind) ? stringArg(change.kind, "type") : stringArg(change, "kind");
86
+ if (type === "add")
87
+ return [{ ...snippetDiff(display(path), "", diff, 1), status: "added" }];
88
+ if (type === "delete")
89
+ return [];
90
+ const text = normalize(diff);
91
+ // Codex sends hunks without file headers; jsdiff needs them to parse.
92
+ const withHeaders = /^(---|diff --git)/m.test(text) ? text : `--- a/${path}\n+++ b/${path}\n${text}`;
93
+ return parsedDiffs(withHeaders, () => display(path));
94
+ }
95
+ function outputDiffs(output, display) {
96
+ const text = normalize(output);
97
+ if (!/^@@ /m.test(text) || !/^(---|diff --git)/m.test(text))
98
+ return [];
99
+ return parsedDiffs(text, (patch) => display(stripPrefix(patch.newFileName ?? patch.oldFileName ?? "")));
100
+ }
101
+ function parsedDiffs(text, pathOf) {
102
+ try {
103
+ return parsePatch(text)
104
+ // Deleted files (new side /dev/null) are not shown.
105
+ .filter((patch) => patch.hunks.length > 0 && patch.newFileName !== "/dev/null")
106
+ .map((patch) => fromPatch(pathOf(patch), patch, true));
107
+ }
108
+ catch {
109
+ return [];
110
+ }
111
+ }
112
+ /**
113
+ * A diff of two snippets. `startLine` is the file line the snippet starts at:
114
+ * hunks are shifted there and get real line numbers. Without it the diff is
115
+ * numbered from the snippet, so it is not exact.
116
+ */
117
+ function snippetDiff(path, before, after, startLine) {
118
+ const patch = structuredPatch(path, path, asLines(before), asLines(after), undefined, undefined, { context: CONTEXT_LINES });
119
+ const shift = (startLine ?? 1) - 1;
120
+ const hunks = patch.hunks.map((hunk) => ({ ...hunk, oldStart: hunk.oldStart + shift, newStart: hunk.newStart + shift }));
121
+ return fromPatch(path, { ...patch, hunks }, startLine !== undefined);
122
+ }
123
+ /** Snippets rarely end in a newline; without one jsdiff adds a misleading "No newline at end of file". */
124
+ function asLines(text) {
125
+ const normalized = normalize(text);
126
+ return normalized && !normalized.endsWith("\n") ? `${normalized}\n` : normalized;
127
+ }
128
+ function fromPatch(path, patch, exactLines) {
129
+ const body = patch.hunks.flatMap((hunk) => hunk.lines).filter((line) => !line.startsWith("\\"));
130
+ return {
131
+ path,
132
+ patch: formatPatch({ ...patch, oldFileName: path, newFileName: path }),
133
+ added: body.filter((line) => line.startsWith("+")).length,
134
+ removed: body.filter((line) => line.startsWith("-")).length,
135
+ body,
136
+ exactLines
137
+ };
138
+ }
139
+ function stripPrefix(name) {
140
+ return name.replace(/^[ab]\//, "");
141
+ }
142
+ function stringArg(args, ...keys) {
143
+ const value = rawArg(args, ...keys);
144
+ return value?.trim() ? value.trim() : undefined;
145
+ }
146
+ /** A string argument as given (edits must keep their whitespace). */
147
+ function rawArg(args, ...keys) {
148
+ for (const key of keys) {
149
+ const value = args[key];
150
+ if (typeof value === "string")
151
+ return value;
152
+ }
153
+ return undefined;
154
+ }
155
+ function isRecord(value) {
156
+ return typeof value === "object" && value !== null && !Array.isArray(value);
157
+ }
158
+ //# sourceMappingURL=tool-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-diff.js","sourceRoot":"","sources":["../src/tool-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAwB,MAAM,MAAM,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAC;AA2B5D,MAAM,UAAU,SAAS,CAAC,IAAiB;IACzC,OAAO,GAAG,IAAI,CAAC,IAAI,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;;;;;;;;GA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AC,MAAM;QAC3D,IAAI;QACJ,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,SAAS,CAAC,IAA6B,EAAE,GAAG,IAAc;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,OAAO,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,qEAAqE;AACrE,SAAS,MAAM,CAAC,IAA6B,EAAE,GAAG,IAAc;IAC9D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import { formatPatch, parsePatch, structuredPatch, type StructuredPatch } from \"diff\";\nimport { relativePath, toolKind } from \"./tool-presentation.js\";\nimport type { TuiFileDiff } from \"@onpoint-dev-tools/crewcoder-tui-core/state/tui-store\";\nimport { normalize, type ToolBlock } from \"./transcript.js\";\n\n/** One file's change from a tool call, as a single-file unified diff for OpenTUI's `<diff>`. */\nexport type FileDiff = {\n path: string;\n patch: string;\n added: number;\n removed: number;\n /** Diff body lines (context, added, removed), for collapsing and the plain fallback. */\n body: string[];\n /**\n * Whether hunk line numbers are the file's real ones. A snippet edit (Claude\n * `Edit`, CrewCoder `edit`) only knows its real place once it is anchored in\n * the file (see `SessionController`); until then it renders as plain +/- lines.\n */\n exactLines: boolean;\n /** Shown instead of a diff body: binary files, or changes too large to include. */\n note?: string;\n status?: \"added\" | \"modified\";\n};\n\n/** A find/replace edit, as given in the tool's arguments (path not yet resolved). */\nexport type SnippetEdit = { path: string; before: string; after: string };\n\n/** 1-based file line where each snippet edit's new text starts, keyed by `anchorKey`. */\nexport type LineAnchors = ReadonlyMap<string, number>;\n\nexport function anchorKey(edit: SnippetEdit): string {\n return `${edit.path}\\u0000${edit.after}`;\n}\n\nconst CONTEXT_LINES = 3;\n\n/**\n * The file changes a tool call made, read from its arguments, so it works for\n * every provider without the agent's help:\n * - Codex `Codex file change`: `changes[]` with a unified `diff` (or full content for adds);\n * - Claude `Edit` (`old_string`/`new_string`), `MultiEdit` (`edits[]`), `Write` (`content`);\n * - CrewCoder `edit` (`find`/`replace`), `edit_transaction` (`edits[]` with paths), `write`;\n * - otherwise, output that is itself a unified diff.\n * Only edit/write tools get diffs (never shell commands), and only for files\n * they created or modified; deletions are not shown (owner decision).\n * Returns nothing for other tools and for edits that failed.\n */\nexport function toolDiffs(block: ToolBlock, cwd?: string, anchors?: LineAnchors): FileDiff[] {\n if (!isEditTool(block)) return [];\n const display = (path: string): string => relativePath(normalize(path), cwd);\n // The agent's snapshot diffs are exact (real line numbers); arguments are the fallback.\n if (block.fileDiffs?.length) return block.fileDiffs.map((file) => agentDiff(file, display));\n const args = block.args ?? {};\n if (Array.isArray(args.changes)) return args.changes.flatMap((change) => codexChange(change, display));\n const edits = snippetEdits(block);\n if (edits.length > 0) {\n return edits.map((edit) => snippetDiff(display(edit.path), edit.before, edit.after, anchors?.get(anchorKey(edit))));\n }\n const filePath = stringArg(args, \"file_path\", \"path\", \"filePath\", \"notebook_path\");\n const content = rawArg(args, \"content\");\n if (filePath && content !== undefined) return [snippetDiff(display(filePath), \"\", content, 1)];\n return outputDiffs(block.text ?? \"\", display);\n}\n\n/** A finished-or-running edit/write tool that did not fail. */\nexport function isEditTool(block: ToolBlock): boolean {\n const kind = toolKind(block.name);\n return block.status !== \"error\" && (kind === \"edit\" || kind === \"write\");\n}\n\n/**\n * The find/replace edits in a tool call: Claude `Edit`/`MultiEdit`\n * (`old_string`/`new_string`), CrewCoder `edit` and `edit_transaction`\n * (`find`/`replace`).\n */\nexport function snippetEdits(block: ToolBlock): SnippetEdit[] {\n const args = block.args ?? {};\n const filePath = stringArg(args, \"file_path\", \"path\", \"filePath\", \"notebook_path\");\n const entries = Array.isArray(args.edits) ? args.edits.filter(isRecord) : [args];\n return entries.flatMap((entry) => {\n const path = stringArg(entry, \"path\", \"file_path\") ?? filePath;\n const before = rawArg(entry, \"old_string\", \"find\", \"oldText\");\n const after = rawArg(entry, \"new_string\", \"replace\", \"newText\");\n return path && before !== undefined && after !== undefined ? [{ path, before, after }] : [];\n });\n}\n\n/** 1-based line where `after` starts in the edited file's text, if it is there. */\nexport function findAnchor(fileText: string, after: string): number | undefined {\n if (!after) return undefined;\n const index = fileText.indexOf(after);\n return index < 0 ? undefined : fileText.slice(0, index).split(\"\\n\").length;\n}\n\n/** A file from the agent's `file_diff` event: a real git patch, or a note when it has none. */\nfunction agentDiff(file: TuiFileDiff, display: (path: string) => string): FileDiff {\n const path = display(file.path);\n const base = { path, added: file.additions, removed: file.deletions, status: file.status };\n const parsed = file.patch ? parsedDiffs(normalize(file.patch), () => path)[0] : undefined;\n if (parsed) return { ...parsed, ...base };\n const note = file.binary ? \"binary file\" : file.truncated ? \"diff too large to show\" : \"no text changes\";\n return { ...base, patch: \"\", body: [], exactLines: true, note };\n}\n\n/** A Codex `FileUpdateChange`: `{ path, kind: { type: add | delete | update }, diff }`. */\nfunction codexChange(change: unknown, display: (path: string) => string): FileDiff[] {\n if (!isRecord(change)) return [];\n const path = stringArg(change, \"path\");\n const diff = rawArg(change, \"diff\", \"unified_diff\");\n if (!path || diff === undefined) return [];\n const type = isRecord(change.kind) ? stringArg(change.kind, \"type\") : stringArg(change, \"kind\");\n if (type === \"add\") return [{ ...snippetDiff(display(path), \"\", diff, 1), status: \"added\" }];\n if (type === \"delete\") return [];\n const text = normalize(diff);\n // Codex sends hunks without file headers; jsdiff needs them to parse.\n const withHeaders = /^(---|diff --git)/m.test(text) ? text : `--- a/${path}\\n+++ b/${path}\\n${text}`;\n return parsedDiffs(withHeaders, () => display(path));\n}\n\nfunction outputDiffs(output: string, display: (path: string) => string): FileDiff[] {\n const text = normalize(output);\n if (!/^@@ /m.test(text) || !/^(---|diff --git)/m.test(text)) return [];\n return parsedDiffs(text, (patch) => display(stripPrefix(patch.newFileName ?? patch.oldFileName ?? \"\")));\n}\n\nfunction parsedDiffs(text: string, pathOf: (patch: StructuredPatch) => string): FileDiff[] {\n try {\n return parsePatch(text)\n // Deleted files (new side /dev/null) are not shown.\n .filter((patch) => patch.hunks.length > 0 && patch.newFileName !== \"/dev/null\")\n .map((patch) => fromPatch(pathOf(patch), patch, true));\n } catch {\n return [];\n }\n}\n\n/**\n * A diff of two snippets. `startLine` is the file line the snippet starts at:\n * hunks are shifted there and get real line numbers. Without it the diff is\n * numbered from the snippet, so it is not exact.\n */\nfunction snippetDiff(path: string, before: string, after: string, startLine: number | undefined): FileDiff {\n const patch = structuredPatch(path, path, asLines(before), asLines(after), undefined, undefined, { context: CONTEXT_LINES });\n const shift = (startLine ?? 1) - 1;\n const hunks = patch.hunks.map((hunk) => ({ ...hunk, oldStart: hunk.oldStart + shift, newStart: hunk.newStart + shift }));\n return fromPatch(path, { ...patch, hunks }, startLine !== undefined);\n}\n\n/** Snippets rarely end in a newline; without one jsdiff adds a misleading \"No newline at end of file\". */\nfunction asLines(text: string): string {\n const normalized = normalize(text);\n return normalized && !normalized.endsWith(\"\\n\") ? `${normalized}\\n` : normalized;\n}\n\nfunction fromPatch(path: string, patch: StructuredPatch, exactLines: boolean): FileDiff {\n const body = patch.hunks.flatMap((hunk) => hunk.lines).filter((line) => !line.startsWith(\"\\\\\"));\n return {\n path,\n patch: formatPatch({ ...patch, oldFileName: path, newFileName: path }),\n added: body.filter((line) => line.startsWith(\"+\")).length,\n removed: body.filter((line) => line.startsWith(\"-\")).length,\n body,\n exactLines\n };\n}\n\nfunction stripPrefix(name: string): string {\n return name.replace(/^[ab]\\//, \"\");\n}\n\nfunction stringArg(args: Record<string, unknown>, ...keys: string[]): string | undefined {\n const value = rawArg(args, ...keys);\n return value?.trim() ? value.trim() : undefined;\n}\n\n/** A string argument as given (edits must keep their whitespace). */\nfunction rawArg(args: Record<string, unknown>, ...keys: string[]): string | undefined {\n for (const key of keys) {\n const value = args[key];\n if (typeof value === \"string\") return value;\n }\n return undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import type { TuiEventBlock } from "@onpoint-dev-tools/crewcoder-tui-core/state/tui-store";
2
+ import type { GlyphSet } from "./glyphs.js";
3
+ type ToolBlock = Extract<TuiEventBlock, {
4
+ type: "tool";
5
+ }>;
6
+ export type ToolKind = "read" | "edit" | "write" | "command" | "search" | "list" | "web" | "tasks" | "agent" | "other";
7
+ /**
8
+ * How one tool call reads in the transcript: an icon and title, the thing it
9
+ * acted on, and output only where it helps. `stacked` puts the target on its
10
+ * own row under the title (`📖 Read File` / `src/App.jsx`); `inline` keeps it
11
+ * on the title row (`± Edit File: src/App.jsx`).
12
+ */
13
+ export type ToolPresentation = {
14
+ kind: ToolKind;
15
+ icon: string;
16
+ title: string;
17
+ target?: string;
18
+ layout: "inline" | "stacked";
19
+ /** The tool's whole output, every kind (the view clamps it, see `clampOutput`). */
20
+ output?: string;
21
+ /** Output lines read as a diff (`+`/`-`/`@@`), for edits and writes. */
22
+ diff: boolean;
23
+ /** Tree-sitter filetype of a read tool's output (from the read path), when it highlights. */
24
+ filetype?: string;
25
+ failed: boolean;
26
+ };
27
+ /** Output lines a collapsed tool shows; the rest open with its toggle or Ctrl+O. */
28
+ export declare const COLLAPSED_OUTPUT_LINES = 12;
29
+ export declare function toolKind(name: string): ToolKind;
30
+ /**
31
+ * `cwd` shortens absolute paths under the workspace to workspace-relative ones.
32
+ * `glyphs` picks the icon set the terminal can draw (`resolveGlyphSet`).
33
+ */
34
+ export declare function toolPresentation(block: ToolBlock, cwd?: string, glyphs?: GlyphSet): ToolPresentation;
35
+ /** The output lines to draw and how many a collapsed view hides. */
36
+ export declare function clampOutput(output: string, expanded: boolean, max?: number): {
37
+ lines: string[];
38
+ hidden: number;
39
+ };
40
+ export type DiffLineTone = "added" | "removed" | "hunk" | "plain";
41
+ /** How a line of edit/write output reads as a diff. File headers (`+++`/`---`) stay plain. */
42
+ export declare function diffLineTone(line: string): DiffLineTone;
43
+ /** `path` relative to `cwd` when it is under it; otherwise unchanged. */
44
+ export declare function relativePath(path: string, cwd?: string): string;
45
+ export {};
46
+ //# sourceMappingURL=tool-presentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-presentation.d.ts","sourceRoot":"","sources":["../src/tool-presentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,KAAK,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE1D,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEvH;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;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