@dsh-cc/tui 0.5.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 (363) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +144 -0
  3. package/lib/bash-history.d.ts +31 -0
  4. package/lib/bash-history.d.ts.map +1 -0
  5. package/lib/bash-history.js +94 -0
  6. package/lib/bash-history.js.map +1 -0
  7. package/lib/compact-fold.d.ts +35 -0
  8. package/lib/compact-fold.d.ts.map +1 -0
  9. package/lib/compact-fold.js +60 -0
  10. package/lib/compact-fold.js.map +1 -0
  11. package/lib/components/arg-completers.d.ts +22 -0
  12. package/lib/components/arg-completers.d.ts.map +1 -0
  13. package/lib/components/arg-completers.js +75 -0
  14. package/lib/components/arg-completers.js.map +1 -0
  15. package/lib/components/code-theme.d.ts +25 -0
  16. package/lib/components/code-theme.d.ts.map +1 -0
  17. package/lib/components/code-theme.js +137 -0
  18. package/lib/components/code-theme.js.map +1 -0
  19. package/lib/components/completion.d.ts +50 -0
  20. package/lib/components/completion.d.ts.map +1 -0
  21. package/lib/components/completion.js +279 -0
  22. package/lib/components/completion.js.map +1 -0
  23. package/lib/components/diff-card.d.ts +29 -0
  24. package/lib/components/diff-card.d.ts.map +1 -0
  25. package/lib/components/diff-card.js +175 -0
  26. package/lib/components/diff-card.js.map +1 -0
  27. package/lib/components/diff-hunks.d.ts +44 -0
  28. package/lib/components/diff-hunks.d.ts.map +1 -0
  29. package/lib/components/diff-hunks.js +188 -0
  30. package/lib/components/diff-hunks.js.map +1 -0
  31. package/lib/components/editor-history.d.ts +23 -0
  32. package/lib/components/editor-history.d.ts.map +1 -0
  33. package/lib/components/editor-history.js +29 -0
  34. package/lib/components/editor-history.js.map +1 -0
  35. package/lib/components/markdown-theme.d.ts +11 -0
  36. package/lib/components/markdown-theme.d.ts.map +1 -0
  37. package/lib/components/markdown-theme.js +29 -0
  38. package/lib/components/markdown-theme.js.map +1 -0
  39. package/lib/components/masked-input.d.ts +24 -0
  40. package/lib/components/masked-input.d.ts.map +1 -0
  41. package/lib/components/masked-input.js +168 -0
  42. package/lib/components/masked-input.js.map +1 -0
  43. package/lib/components/overlay-host.d.ts +31 -0
  44. package/lib/components/overlay-host.d.ts.map +1 -0
  45. package/lib/components/overlay-host.js +128 -0
  46. package/lib/components/overlay-host.js.map +1 -0
  47. package/lib/components/overlays.d.ts +94 -0
  48. package/lib/components/overlays.d.ts.map +1 -0
  49. package/lib/components/overlays.js +450 -0
  50. package/lib/components/overlays.js.map +1 -0
  51. package/lib/components/provider-box.d.ts +23 -0
  52. package/lib/components/provider-box.d.ts.map +1 -0
  53. package/lib/components/provider-box.js +164 -0
  54. package/lib/components/provider-box.js.map +1 -0
  55. package/lib/components/read-group.d.ts +51 -0
  56. package/lib/components/read-group.d.ts.map +1 -0
  57. package/lib/components/read-group.js +105 -0
  58. package/lib/components/read-group.js.map +1 -0
  59. package/lib/components/root-bash.d.ts +36 -0
  60. package/lib/components/root-bash.d.ts.map +1 -0
  61. package/lib/components/root-bash.js +112 -0
  62. package/lib/components/root-bash.js.map +1 -0
  63. package/lib/components/root-types.d.ts +42 -0
  64. package/lib/components/root-types.d.ts.map +1 -0
  65. package/lib/components/root-types.js +8 -0
  66. package/lib/components/root-types.js.map +1 -0
  67. package/lib/components/root-utils.d.ts +22 -0
  68. package/lib/components/root-utils.d.ts.map +1 -0
  69. package/lib/components/root-utils.js +45 -0
  70. package/lib/components/root-utils.js.map +1 -0
  71. package/lib/components/root.d.ts +25 -0
  72. package/lib/components/root.d.ts.map +1 -0
  73. package/lib/components/root.js +357 -0
  74. package/lib/components/root.js.map +1 -0
  75. package/lib/components/theme.d.ts +61 -0
  76. package/lib/components/theme.d.ts.map +1 -0
  77. package/lib/components/theme.js +99 -0
  78. package/lib/components/theme.js.map +1 -0
  79. package/lib/components/transcript.d.ts +43 -0
  80. package/lib/components/transcript.d.ts.map +1 -0
  81. package/lib/components/transcript.js +203 -0
  82. package/lib/components/transcript.js.map +1 -0
  83. package/lib/components/working-line.d.ts +35 -0
  84. package/lib/components/working-line.d.ts.map +1 -0
  85. package/lib/components/working-line.js +66 -0
  86. package/lib/components/working-line.js.map +1 -0
  87. package/lib/effort-catalog.d.ts +27 -0
  88. package/lib/effort-catalog.d.ts.map +1 -0
  89. package/lib/effort-catalog.js +36 -0
  90. package/lib/effort-catalog.js.map +1 -0
  91. package/lib/export-markdown.d.ts +18 -0
  92. package/lib/export-markdown.d.ts.map +1 -0
  93. package/lib/export-markdown.js +124 -0
  94. package/lib/export-markdown.js.map +1 -0
  95. package/lib/harness/approval-preview.d.ts +33 -0
  96. package/lib/harness/approval-preview.d.ts.map +1 -0
  97. package/lib/harness/approval-preview.js +179 -0
  98. package/lib/harness/approval-preview.js.map +1 -0
  99. package/lib/harness/boot-banner.d.ts +14 -0
  100. package/lib/harness/boot-banner.d.ts.map +1 -0
  101. package/lib/harness/boot-banner.js +89 -0
  102. package/lib/harness/boot-banner.js.map +1 -0
  103. package/lib/harness/driver-agent.d.ts +78 -0
  104. package/lib/harness/driver-agent.d.ts.map +1 -0
  105. package/lib/harness/driver-agent.js +314 -0
  106. package/lib/harness/driver-agent.js.map +1 -0
  107. package/lib/harness/driver-agents.d.ts +20 -0
  108. package/lib/harness/driver-agents.d.ts.map +1 -0
  109. package/lib/harness/driver-agents.js +123 -0
  110. package/lib/harness/driver-agents.js.map +1 -0
  111. package/lib/harness/driver-approvals.d.ts +38 -0
  112. package/lib/harness/driver-approvals.d.ts.map +1 -0
  113. package/lib/harness/driver-approvals.js +277 -0
  114. package/lib/harness/driver-approvals.js.map +1 -0
  115. package/lib/harness/driver-bash.d.ts +15 -0
  116. package/lib/harness/driver-bash.d.ts.map +1 -0
  117. package/lib/harness/driver-bash.js +73 -0
  118. package/lib/harness/driver-bash.js.map +1 -0
  119. package/lib/harness/driver-catalog.d.ts +84 -0
  120. package/lib/harness/driver-catalog.d.ts.map +1 -0
  121. package/lib/harness/driver-catalog.js +256 -0
  122. package/lib/harness/driver-catalog.js.map +1 -0
  123. package/lib/harness/driver-ctx.d.ts +462 -0
  124. package/lib/harness/driver-ctx.d.ts.map +1 -0
  125. package/lib/harness/driver-ctx.js +11 -0
  126. package/lib/harness/driver-ctx.js.map +1 -0
  127. package/lib/harness/driver-hud.d.ts +31 -0
  128. package/lib/harness/driver-hud.d.ts.map +1 -0
  129. package/lib/harness/driver-hud.js +204 -0
  130. package/lib/harness/driver-hud.js.map +1 -0
  131. package/lib/harness/driver-live.d.ts +36 -0
  132. package/lib/harness/driver-live.d.ts.map +1 -0
  133. package/lib/harness/driver-live.js +44 -0
  134. package/lib/harness/driver-live.js.map +1 -0
  135. package/lib/harness/driver-modal.d.ts +52 -0
  136. package/lib/harness/driver-modal.d.ts.map +1 -0
  137. package/lib/harness/driver-modal.js +78 -0
  138. package/lib/harness/driver-modal.js.map +1 -0
  139. package/lib/harness/driver-mode.d.ts +35 -0
  140. package/lib/harness/driver-mode.d.ts.map +1 -0
  141. package/lib/harness/driver-mode.js +84 -0
  142. package/lib/harness/driver-mode.js.map +1 -0
  143. package/lib/harness/driver-pickers.d.ts +48 -0
  144. package/lib/harness/driver-pickers.d.ts.map +1 -0
  145. package/lib/harness/driver-pickers.js +249 -0
  146. package/lib/harness/driver-pickers.js.map +1 -0
  147. package/lib/harness/driver-promote.d.ts +29 -0
  148. package/lib/harness/driver-promote.d.ts.map +1 -0
  149. package/lib/harness/driver-promote.js +36 -0
  150. package/lib/harness/driver-promote.js.map +1 -0
  151. package/lib/harness/driver-queue.d.ts +19 -0
  152. package/lib/harness/driver-queue.d.ts.map +1 -0
  153. package/lib/harness/driver-queue.js +281 -0
  154. package/lib/harness/driver-queue.js.map +1 -0
  155. package/lib/harness/driver-run-local.d.ts +32 -0
  156. package/lib/harness/driver-run-local.d.ts.map +1 -0
  157. package/lib/harness/driver-run-local.js +366 -0
  158. package/lib/harness/driver-run-local.js.map +1 -0
  159. package/lib/harness/driver-sessions.d.ts +28 -0
  160. package/lib/harness/driver-sessions.d.ts.map +1 -0
  161. package/lib/harness/driver-sessions.js +386 -0
  162. package/lib/harness/driver-sessions.js.map +1 -0
  163. package/lib/harness/driver.d.ts +22 -0
  164. package/lib/harness/driver.d.ts.map +1 -0
  165. package/lib/harness/driver.js +459 -0
  166. package/lib/harness/driver.js.map +1 -0
  167. package/lib/harness/preset.d.ts +32 -0
  168. package/lib/harness/preset.d.ts.map +1 -0
  169. package/lib/harness/preset.js +34 -0
  170. package/lib/harness/preset.js.map +1 -0
  171. package/lib/harness/session-list.d.ts +65 -0
  172. package/lib/harness/session-list.d.ts.map +1 -0
  173. package/lib/harness/session-list.js +91 -0
  174. package/lib/harness/session-list.js.map +1 -0
  175. package/lib/harness/shell-output.d.ts +44 -0
  176. package/lib/harness/shell-output.d.ts.map +1 -0
  177. package/lib/harness/shell-output.js +90 -0
  178. package/lib/harness/shell-output.js.map +1 -0
  179. package/lib/harness/statusline-cc-transcript.d.ts +51 -0
  180. package/lib/harness/statusline-cc-transcript.d.ts.map +1 -0
  181. package/lib/harness/statusline-cc-transcript.js +191 -0
  182. package/lib/harness/statusline-cc-transcript.js.map +1 -0
  183. package/lib/harness/statusline-command.d.ts +54 -0
  184. package/lib/harness/statusline-command.d.ts.map +1 -0
  185. package/lib/harness/statusline-command.js +161 -0
  186. package/lib/harness/statusline-command.js.map +1 -0
  187. package/lib/harness/statusline-payload.d.ts +79 -0
  188. package/lib/harness/statusline-payload.d.ts.map +1 -0
  189. package/lib/harness/statusline-payload.js +93 -0
  190. package/lib/harness/statusline-payload.js.map +1 -0
  191. package/lib/harness/statusline-settings.d.ts +47 -0
  192. package/lib/harness/statusline-settings.d.ts.map +1 -0
  193. package/lib/harness/statusline-settings.js +57 -0
  194. package/lib/harness/statusline-settings.js.map +1 -0
  195. package/lib/harness/statusline-wiring.d.ts +45 -0
  196. package/lib/harness/statusline-wiring.d.ts.map +1 -0
  197. package/lib/harness/statusline-wiring.js +247 -0
  198. package/lib/harness/statusline-wiring.js.map +1 -0
  199. package/lib/harness/usage-view.d.ts +84 -0
  200. package/lib/harness/usage-view.d.ts.map +1 -0
  201. package/lib/harness/usage-view.js +199 -0
  202. package/lib/harness/usage-view.js.map +1 -0
  203. package/lib/harness/worktree-exit.d.ts +105 -0
  204. package/lib/harness/worktree-exit.d.ts.map +1 -0
  205. package/lib/harness/worktree-exit.js +168 -0
  206. package/lib/harness/worktree-exit.js.map +1 -0
  207. package/lib/history.d.ts +50 -0
  208. package/lib/history.d.ts.map +1 -0
  209. package/lib/history.js +139 -0
  210. package/lib/history.js.map +1 -0
  211. package/lib/index.d.ts +63 -0
  212. package/lib/index.d.ts.map +1 -0
  213. package/lib/index.js +54 -0
  214. package/lib/index.js.map +1 -0
  215. package/lib/input.d.ts +158 -0
  216. package/lib/input.d.ts.map +1 -0
  217. package/lib/input.js +400 -0
  218. package/lib/input.js.map +1 -0
  219. package/lib/invariant.d.ts +14 -0
  220. package/lib/invariant.d.ts.map +1 -0
  221. package/lib/invariant.js +20 -0
  222. package/lib/invariant.js.map +1 -0
  223. package/lib/mode-cycle.d.ts +22 -0
  224. package/lib/mode-cycle.d.ts.map +1 -0
  225. package/lib/mode-cycle.js +32 -0
  226. package/lib/mode-cycle.js.map +1 -0
  227. package/lib/model-catalog.d.ts +22 -0
  228. package/lib/model-catalog.d.ts.map +1 -0
  229. package/lib/model-catalog.js +45 -0
  230. package/lib/model-catalog.js.map +1 -0
  231. package/lib/packaged-preset.d.ts +32 -0
  232. package/lib/packaged-preset.d.ts.map +1 -0
  233. package/lib/packaged-preset.js +94 -0
  234. package/lib/packaged-preset.js.map +1 -0
  235. package/lib/plugin.d.ts +11 -0
  236. package/lib/plugin.d.ts.map +1 -0
  237. package/lib/plugin.js +88 -0
  238. package/lib/plugin.js.map +1 -0
  239. package/lib/profile.d.ts +4 -0
  240. package/lib/profile.d.ts.map +1 -0
  241. package/lib/profile.js +7 -0
  242. package/lib/profile.js.map +1 -0
  243. package/lib/project-sessions.d.ts +29 -0
  244. package/lib/project-sessions.d.ts.map +1 -0
  245. package/lib/project-sessions.js +60 -0
  246. package/lib/project-sessions.js.map +1 -0
  247. package/lib/project.d.ts +75 -0
  248. package/lib/project.d.ts.map +1 -0
  249. package/lib/project.js +196 -0
  250. package/lib/project.js.map +1 -0
  251. package/lib/provider-actions.d.ts +37 -0
  252. package/lib/provider-actions.d.ts.map +1 -0
  253. package/lib/provider-actions.js +417 -0
  254. package/lib/provider-actions.js.map +1 -0
  255. package/lib/provider-command.d.ts +109 -0
  256. package/lib/provider-command.d.ts.map +1 -0
  257. package/lib/provider-command.js +220 -0
  258. package/lib/provider-command.js.map +1 -0
  259. package/lib/provider-detail.d.ts +15 -0
  260. package/lib/provider-detail.d.ts.map +1 -0
  261. package/lib/provider-detail.js +201 -0
  262. package/lib/provider-detail.js.map +1 -0
  263. package/lib/provider-flow.d.ts +191 -0
  264. package/lib/provider-flow.d.ts.map +1 -0
  265. package/lib/provider-flow.js +192 -0
  266. package/lib/provider-flow.js.map +1 -0
  267. package/lib/provider-presets.d.ts +32 -0
  268. package/lib/provider-presets.d.ts.map +1 -0
  269. package/lib/provider-presets.js +105 -0
  270. package/lib/provider-presets.js.map +1 -0
  271. package/lib/provider-read.d.ts +63 -0
  272. package/lib/provider-read.d.ts.map +1 -0
  273. package/lib/provider-read.js +115 -0
  274. package/lib/provider-read.js.map +1 -0
  275. package/lib/provider-settings.d.ts +30 -0
  276. package/lib/provider-settings.d.ts.map +1 -0
  277. package/lib/provider-settings.js +65 -0
  278. package/lib/provider-settings.js.map +1 -0
  279. package/lib/resume-target.d.ts +59 -0
  280. package/lib/resume-target.d.ts.map +1 -0
  281. package/lib/resume-target.js +143 -0
  282. package/lib/resume-target.js.map +1 -0
  283. package/lib/slash.d.ts +44 -0
  284. package/lib/slash.d.ts.map +1 -0
  285. package/lib/slash.js +81 -0
  286. package/lib/slash.js.map +1 -0
  287. package/lib/state/driver-types.d.ts +505 -0
  288. package/lib/state/driver-types.d.ts.map +1 -0
  289. package/lib/state/driver-types.js +8 -0
  290. package/lib/state/driver-types.js.map +1 -0
  291. package/lib/state/driver-usage-types.d.ts +59 -0
  292. package/lib/state/driver-usage-types.d.ts.map +1 -0
  293. package/lib/state/driver-usage-types.js +8 -0
  294. package/lib/state/driver-usage-types.js.map +1 -0
  295. package/lib/statusline.d.ts +63 -0
  296. package/lib/statusline.d.ts.map +1 -0
  297. package/lib/statusline.js +97 -0
  298. package/lib/statusline.js.map +1 -0
  299. package/lib/store/pickers.d.ts +34 -0
  300. package/lib/store/pickers.d.ts.map +1 -0
  301. package/lib/store/pickers.js +111 -0
  302. package/lib/store/pickers.js.map +1 -0
  303. package/lib/store/provider-panel.d.ts +107 -0
  304. package/lib/store/provider-panel.d.ts.map +1 -0
  305. package/lib/store/provider-panel.js +151 -0
  306. package/lib/store/provider-panel.js.map +1 -0
  307. package/lib/store/question.d.ts +21 -0
  308. package/lib/store/question.d.ts.map +1 -0
  309. package/lib/store/question.js +59 -0
  310. package/lib/store/question.js.map +1 -0
  311. package/lib/store/queue.d.ts +27 -0
  312. package/lib/store/queue.d.ts.map +1 -0
  313. package/lib/store/queue.js +34 -0
  314. package/lib/store/queue.js.map +1 -0
  315. package/lib/store/session.d.ts +73 -0
  316. package/lib/store/session.d.ts.map +1 -0
  317. package/lib/store/session.js +172 -0
  318. package/lib/store/session.js.map +1 -0
  319. package/lib/store/subagents.d.ts +16 -0
  320. package/lib/store/subagents.d.ts.map +1 -0
  321. package/lib/store/subagents.js +44 -0
  322. package/lib/store/subagents.js.map +1 -0
  323. package/lib/store/todos.d.ts +35 -0
  324. package/lib/store/todos.d.ts.map +1 -0
  325. package/lib/store/todos.js +68 -0
  326. package/lib/store/todos.js.map +1 -0
  327. package/lib/store/usage.d.ts +15 -0
  328. package/lib/store/usage.d.ts.map +1 -0
  329. package/lib/store/usage.js +27 -0
  330. package/lib/store/usage.js.map +1 -0
  331. package/lib/store/views.d.ts +419 -0
  332. package/lib/store/views.d.ts.map +1 -0
  333. package/lib/store/views.js +3 -0
  334. package/lib/store/views.js.map +1 -0
  335. package/lib/store.d.ts +19 -0
  336. package/lib/store.d.ts.map +1 -0
  337. package/lib/store.js +10 -0
  338. package/lib/store.js.map +1 -0
  339. package/lib/terminal/lease.d.ts +33 -0
  340. package/lib/terminal/lease.d.ts.map +1 -0
  341. package/lib/terminal/lease.js +99 -0
  342. package/lib/terminal/lease.js.map +1 -0
  343. package/lib/tool-card.d.ts +75 -0
  344. package/lib/tool-card.d.ts.map +1 -0
  345. package/lib/tool-card.js +109 -0
  346. package/lib/tool-card.js.map +1 -0
  347. package/lib/tool-verbs.d.ts +12 -0
  348. package/lib/tool-verbs.d.ts.map +1 -0
  349. package/lib/tool-verbs.js +29 -0
  350. package/lib/tool-verbs.js.map +1 -0
  351. package/lib/transcript.d.ts +40 -0
  352. package/lib/transcript.d.ts.map +1 -0
  353. package/lib/transcript.js +413 -0
  354. package/lib/transcript.js.map +1 -0
  355. package/lib/working-line.d.ts +44 -0
  356. package/lib/working-line.d.ts.map +1 -0
  357. package/lib/working-line.js +56 -0
  358. package/lib/working-line.js.map +1 -0
  359. package/package.json +72 -0
  360. package/presets/cc/.dsh-cc-managed.json +5 -0
  361. package/presets/cc/agent.cordis.yml +524 -0
  362. package/presets/cc/preset.yml +3 -0
  363. package/scripts/stage-preset.mjs +26 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Status-line command runner: 300 ms-debounced execution of the configured
3
+ * command with the CC-shaped JSON payload on stdin. Kill-in-flight on every
4
+ * new trigger, generation-guarded settles (a superseded run's late result is
5
+ * discarded), update({ immediate: true }) bypass for settings-driven command
6
+ * changes, blank-on-failure (non-zero exit, killed, timeout, overrun, spawn
7
+ * throw, empty stdout), COLUMNS/LINES from the terminal-size getter at spawn
8
+ * time, a 60 s hard cap with a 64 KiB stdout cap, and a dispose that aborts,
9
+ * clears, and quiets.
10
+ * @module @dsh-cc/tui/harness/statusline-command
11
+ */
12
+ /** Debounce delay per the CC contract (C5). */
13
+ const DEFAULT_DEBOUNCE_MS = 300;
14
+ /** dsh-cc's undocumented-by-CC guard against hung scripts. */
15
+ const DEFAULT_TIMEOUT_MS = 60_000;
16
+ /** dsh-cc's stdout hard cap. */
17
+ const DEFAULT_STDOUT_MAX_BYTES = 64 * 1024;
18
+ /** Max rows of the command's stdout kept (multi-row CC status line, capped). */
19
+ const MAX_STATUSLINE_ROWS = 3;
20
+ /**
21
+ * Create the status-line command runner. Pure with respect to the injected
22
+ * executor; owns exactly one debounce timer and one hard-cap timer at a time.
23
+ */
24
+ export function createStatusLineCommand(deps) {
25
+ const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
26
+ const timeoutMs = deps.timeoutMs ?? DEFAULT_TIMEOUT_MS;
27
+ const stdoutMaxBytes = deps.stdoutMaxBytes ?? DEFAULT_STDOUT_MAX_BYTES;
28
+ let disposed = false;
29
+ let generation = 0;
30
+ let latestLine = '';
31
+ let debounceTimer;
32
+ let inFlight;
33
+ /** Abort the in-flight child and forget it (trigger-time kill, C5). */
34
+ function killInFlight() {
35
+ if (inFlight === undefined)
36
+ return;
37
+ clearTimeout(inFlight.capTimer);
38
+ inFlight.controller.abort();
39
+ inFlight = undefined;
40
+ }
41
+ /** Record a blank for the current generation and notify. */
42
+ function blank() {
43
+ latestLine = '';
44
+ deps.onSettled('');
45
+ }
46
+ /** Whether a settled generation may still write state and notify. */
47
+ function isCurrent(gen) {
48
+ return !disposed && gen === generation;
49
+ }
50
+ function spawn(command, payload, workdir, gen) {
51
+ if (disposed || gen !== generation)
52
+ return;
53
+ const controller = new AbortController();
54
+ const { columns, rows } = deps.terminalSize();
55
+ const env = {};
56
+ for (const [key, value] of Object.entries(process.env)) {
57
+ if (typeof value === 'string')
58
+ env[key] = value;
59
+ }
60
+ env.COLUMNS = String(columns);
61
+ env.LINES = String(rows);
62
+ const request = {
63
+ command,
64
+ stdin: `${JSON.stringify(payload)}\n`,
65
+ signal: controller.signal,
66
+ env,
67
+ timeoutMs,
68
+ stdoutMaxBytes,
69
+ ...(workdir === undefined ? {} : { workdir }),
70
+ };
71
+ let spec;
72
+ try {
73
+ spec = deps.executor.resolve(request);
74
+ }
75
+ catch {
76
+ killInFlight();
77
+ if (isCurrent(gen))
78
+ blank();
79
+ return;
80
+ }
81
+ const capTimer = setTimeout(() => {
82
+ // Hung run: cut it and blank immediately — the executor's own settle
83
+ // (if it ever arrives) is discarded by the generation guard.
84
+ controller.abort();
85
+ if (inFlight?.controller === controller) {
86
+ inFlight = undefined;
87
+ if (isCurrent(gen))
88
+ blank();
89
+ }
90
+ }, timeoutMs);
91
+ inFlight = { controller, capTimer };
92
+ deps.executor.run(spec).then((result) => {
93
+ if (inFlight?.controller === controller) {
94
+ clearTimeout(inFlight.capTimer);
95
+ inFlight = undefined;
96
+ }
97
+ if (!isCurrent(gen))
98
+ return;
99
+ const success = result.exitCode === 0 && !result.timedOut && result.stdout.text.length > 0;
100
+ if (success) {
101
+ const rows = result.stdout.text.split('\n').map((row) => row.trimEnd());
102
+ while (rows.length > 0 && rows[rows.length - 1] === '')
103
+ rows.pop();
104
+ if (rows.length > 0 && rows.some((row) => row !== '')) {
105
+ latestLine = rows.slice(0, MAX_STATUSLINE_ROWS).join('\n');
106
+ }
107
+ else {
108
+ blank();
109
+ return;
110
+ }
111
+ }
112
+ else {
113
+ latestLine = '';
114
+ }
115
+ if (latestLine.length === 0) {
116
+ blank();
117
+ return;
118
+ }
119
+ deps.onSettled(latestLine);
120
+ }, () => {
121
+ if (inFlight?.controller === controller) {
122
+ clearTimeout(inFlight.capTimer);
123
+ inFlight = undefined;
124
+ }
125
+ if (isCurrent(gen))
126
+ blank();
127
+ });
128
+ }
129
+ return {
130
+ update(config, payload, options) {
131
+ if (disposed)
132
+ return;
133
+ generation += 1;
134
+ const gen = generation;
135
+ // A new trigger cancels the in-flight child first (C5), then a
136
+ // replacement is scheduled — debounced, or immediate for command swaps.
137
+ killInFlight();
138
+ clearTimeout(debounceTimer);
139
+ if (options?.immediate === true) {
140
+ spawn(config.command, payload, options?.workdir, gen);
141
+ return;
142
+ }
143
+ debounceTimer = setTimeout(() => {
144
+ spawn(config.command, payload, options?.workdir, gen);
145
+ }, debounceMs);
146
+ },
147
+ latest() {
148
+ return latestLine;
149
+ },
150
+ dispose() {
151
+ if (disposed)
152
+ return;
153
+ disposed = true;
154
+ generation += 1;
155
+ clearTimeout(debounceTimer);
156
+ killInFlight();
157
+ latestLine = '';
158
+ },
159
+ };
160
+ }
161
+ //# sourceMappingURL=statusline-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-command.js","sourceRoot":"","sources":["../../src/harness/statusline-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAsCH,+CAA+C;AAC/C,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAC/B,8DAA8D;AAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,gCAAgC;AAChC,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,CAAA;AAC1C,gFAAgF;AAChF,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAE7B;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAA2B;IACjE,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,mBAAmB,CAAA;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAA;IACtD,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,wBAAwB,CAAA;IAEtE,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,UAAU,GAAG,CAAC,CAAA;IAClB,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,aAAwD,CAAA;IAC5D,IAAI,QAA8F,CAAA;IAElG,uEAAuE;IACvE,SAAS,YAAY;QACnB,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAM;QAClC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC/B,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;Q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,SAAS,KAAK,IAAI,EAAE,CAAC;gBAChC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;gBACrD,OAAM;YACR,CAAC;YACD,aAAa,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC9B,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;YACvD,CAAC,EAAE,UAAU,CAAC,CAAA;QAChB,CAAC;QAED,MAAM;YACJ,OAAO,UAAU,CAAA;QACnB,CAAC;QAED,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,UAAU,IAAI,CAAC,CAAA;YACf,YAAY,CAAC,aAAa,CAAC,CAAA;YAC3B,YAAY,EAAE,CAAA;YACd,UAAU,GAAG,EAAE,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Pure payload builder for the custom status line: assembles the CC-shaped
3
+ * JSON session object (§3.4 of the statusline plan) from a structural view of
4
+ * live driver state. Only truthfully-sourced fields are emitted — absent
5
+ * sources drop their field, and a sub-object with no known member is dropped
6
+ * wholesale. `context_window.current_usage` carries the last API step's token
7
+ * buckets (the projection's `tokenUsage.last.buckets`) mapped onto the CC
8
+ * field names; one accepted staleness: those buckets may carry partial usage
9
+ * from a cancelled/failed step. The percentage and exceeds_200k decisions use
10
+ * the currentUsage-derived context length (input + cache write + cache read)
11
+ * when present, falling back to the projected pressure sample — and are
12
+ * omitted when neither source exists. Pure and total: no I/O, no clock, no
13
+ * driver imports.
14
+ * @module @dsh-cc/tui/harness/statusline-payload
15
+ */
16
+ /** Structural view of the driver state the payload is built from. */
17
+ export type StatusLinePayloadView = {
18
+ /**
19
+ * Bundle version of dsh-cc (not a CC version). Optional as a pinned v1
20
+ * omission: the TUI has no truthful runtime source for a bundle version, so
21
+ * the wiring layer never supplies it (recorded as a manifest deviation).
22
+ */
23
+ version?: string;
24
+ /** Driver cwd at payload-fire time; the workspace/cwd fallback. */
25
+ driverCwd?: string;
26
+ /** Session cwd (session.header.cwd). */
27
+ sessionCwd?: string;
28
+ /** Driver project root. */
29
+ projectDir?: string;
30
+ /** Session id. */
31
+ sessionId?: string;
32
+ /** Transcript file path; absent when unlocatable. */
33
+ transcriptPath?: string;
34
+ /** Selected model id (duplicated as display_name — no registry exists). */
35
+ model?: string;
36
+ /** Selected reasoning effort. */
37
+ effort?: string;
38
+ /** Active output style name, when readable. */
39
+ outputStyleName?: string;
40
+ /** Worktree descriptor carried by the session, when present. */
41
+ worktree?: {
42
+ name?: string;
43
+ path?: string;
44
+ branch?: string;
45
+ };
46
+ /** Git worktree name (mirrors the worktree descriptor's name). */
47
+ gitWorktree?: string;
48
+ /** Uncached input-token total (context-window total). */
49
+ inputTokens?: number;
50
+ /** Output-token total (context-window total). */
51
+ outputTokens?: number;
52
+ /**
53
+ * Most recent API step's token buckets (CC `current_usage` semantics);
54
+ * absent when the projection exposes no last step.
55
+ */
56
+ currentUsage?: {
57
+ inputTokens: number;
58
+ outputTokens: number;
59
+ cacheReadTokens?: number;
60
+ cacheWriteTokens?: number;
61
+ };
62
+ /** Context window size in tokens. */
63
+ contextWindowTokens?: number;
64
+ /** Projected context occupancy in tokens. */
65
+ pressureTokens?: number;
66
+ /** Session creation timestamp (ms epoch); falls back to {@link bindTimeMs}. */
67
+ sessionCreatedAtMs?: number;
68
+ /** Bind time of the runner (ms epoch) — the duration fallback clock base. */
69
+ bindTimeMs: number;
70
+ /** Now (ms epoch) at payload-fire time. */
71
+ nowMs: number;
72
+ };
73
+ /**
74
+ * Build the CC-shaped status-line payload from the view. Absent sources drop
75
+ * their field; empty sub-objects are dropped wholesale; unknown extra keys are
76
+ * never fabricated. Serialized structurally — the payload type stays open.
77
+ */
78
+ export declare function buildStatusLinePayload(view: StatusLinePayloadView): Record<string, unknown>;
79
+ //# sourceMappingURL=statusline-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-payload.d.ts","sourceRoot":"","sources":["../../src/harness/statusline-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qEAAqE;AACrE,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kBAAkB;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,gEAAgE;IAChE,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5D,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,YAAY,EAAE,MAAM,CAAA;QACpB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAC1B,CAAA;IACD,qCAAqC;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAA;IAClB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AA8BD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6C3F"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Pure payload builder for the custom status line: assembles the CC-shaped
3
+ * JSON session object (§3.4 of the statusline plan) from a structural view of
4
+ * live driver state. Only truthfully-sourced fields are emitted — absent
5
+ * sources drop their field, and a sub-object with no known member is dropped
6
+ * wholesale. `context_window.current_usage` carries the last API step's token
7
+ * buckets (the projection's `tokenUsage.last.buckets`) mapped onto the CC
8
+ * field names; one accepted staleness: those buckets may carry partial usage
9
+ * from a cancelled/failed step. The percentage and exceeds_200k decisions use
10
+ * the currentUsage-derived context length (input + cache write + cache read)
11
+ * when present, falling back to the projected pressure sample — and are
12
+ * omitted when neither source exists. Pure and total: no I/O, no clock, no
13
+ * driver imports.
14
+ * @module @dsh-cc/tui/harness/statusline-payload
15
+ */
16
+ /** Whether a value is a finite number. */
17
+ function isFiniteNumber(value) {
18
+ return typeof value === 'number' && Number.isFinite(value);
19
+ }
20
+ /** Drop keys whose value is `undefined`, then drop the object when empty. */
21
+ function compact(object) {
22
+ const out = {};
23
+ for (const [key, value] of Object.entries(object)) {
24
+ if (value !== undefined)
25
+ out[key] = value;
26
+ }
27
+ return Object.keys(out).length > 0 ? out : undefined;
28
+ }
29
+ /**
30
+ * The occupancy decision input: the currentUsage-derived context length
31
+ * (input + cache write + cache read) when a currentUsage exists, else the
32
+ * projected pressure sample. Undefined when neither source exists.
33
+ */
34
+ function contextLengthOf(view) {
35
+ if (view.currentUsage !== undefined) {
36
+ return view.currentUsage.inputTokens
37
+ + (view.currentUsage.cacheWriteTokens ?? 0)
38
+ + (view.currentUsage.cacheReadTokens ?? 0);
39
+ }
40
+ return isFiniteNumber(view.pressureTokens) ? view.pressureTokens : undefined;
41
+ }
42
+ /**
43
+ * Build the CC-shaped status-line payload from the view. Absent sources drop
44
+ * their field; empty sub-objects are dropped wholesale; unknown extra keys are
45
+ * never fabricated. Serialized structurally — the payload type stays open.
46
+ */
47
+ export function buildStatusLinePayload(view) {
48
+ const length = contextLengthOf(view);
49
+ const percentages = isFiniteNumber(length) && isFiniteNumber(view.contextWindowTokens) && view.contextWindowTokens > 0
50
+ ? (length / view.contextWindowTokens) * 100
51
+ : undefined;
52
+ const payload = {
53
+ cwd: view.sessionCwd ?? view.driverCwd,
54
+ session_id: view.sessionId,
55
+ transcript_path: view.transcriptPath,
56
+ model: compact({
57
+ id: view.model,
58
+ display_name: view.model,
59
+ }),
60
+ workspace: compact({
61
+ current_dir: view.sessionCwd ?? view.driverCwd,
62
+ project_dir: view.projectDir,
63
+ added_dirs: [],
64
+ git_worktree: view.gitWorktree ?? view.worktree?.name,
65
+ }),
66
+ version: view.version,
67
+ output_style: compact({ name: view.outputStyleName }),
68
+ cost: compact({
69
+ total_duration_ms: view.nowMs - (view.sessionCreatedAtMs ?? view.bindTimeMs),
70
+ }),
71
+ context_window: compact({
72
+ total_input_tokens: view.inputTokens,
73
+ total_output_tokens: view.outputTokens,
74
+ context_window_size: view.contextWindowTokens,
75
+ current_usage: view.currentUsage === undefined
76
+ ? undefined
77
+ : compact({
78
+ input_tokens: view.currentUsage.inputTokens,
79
+ output_tokens: view.currentUsage.outputTokens,
80
+ cache_creation_input_tokens: view.currentUsage.cacheWriteTokens,
81
+ cache_read_input_tokens: view.currentUsage.cacheReadTokens,
82
+ }),
83
+ used_percentage: percentages,
84
+ remaining_percentage: percentages === undefined ? undefined : 100 - percentages,
85
+ }),
86
+ // No occupancy source → the field is omitted (not a literal false).
87
+ exceeds_200k_tokens: isFiniteNumber(length) ? length > 200_000 : undefined,
88
+ effort: compact({ level: view.effort }),
89
+ worktree: view.worktree === undefined ? undefined : compact(view.worktree),
90
+ };
91
+ return compact(payload) ?? {};
92
+ }
93
+ //# sourceMappingURL=statusline-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-payload.js","sourceRoot":"","sources":["../../src/harness/statusline-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAwDH,0CAA0C;AAC1C,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC;AAED,6EAA6E;AAC7E,SAAS,OAAO,CAAC,MAA+B;IAC9C,MAAM,GAAG,GAA4B,EAAE,CAAA;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IAC3C,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAA2B;IAClD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW;cAChC,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,IAAI,CAAC,CAAC;cACzC,CAAC,IAAI,CAAC,YAAY,CAAC,eAAe,IAAI,CAAC,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9E,CAAC;AAED;;;;GA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C,mBAAmB;YAC7C,aAAa,EAAE,IAAI,CAAC,YAAY,KAAK,SAAS;gBAC5C,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,OAAO,CAAC;oBACR,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW;oBAC3C,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,YAAY;oBAC7C,2BAA2B,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB;oBAC/D,uBAAuB,EAAE,IAAI,CAAC,YAAY,CAAC,eAAe;iBAC3D,CAAC;YACJ,eAAe,EAAE,WAAW;YAC5B,oBAAoB,EAAE,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,WAAW;SAChF,CAAC;QACF,oEAAoE;QACpE,mBAAmB,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS;QAC1E,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3E,CAAA;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Pure settings module for the custom status line: the `statusline` settings
3
+ * namespace (the cascade aliases CC's camelCase `statusLine` key onto it), a
4
+ * tolerant schema, and the activation/normalization predicate. No driver or
5
+ * shell imports — this file is the seam-free half of the feature.
6
+ * @module @dsh-cc/tui/harness/statusline-settings
7
+ */
8
+ import z from '@deepseek-ai/schemastery';
9
+ /** Settings namespace carrying the status-line section (kebab-case). */
10
+ export declare const STATUSLINE_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
11
+ /** Raw (unresolved) settings section for the status line, CC-shaped and open. */
12
+ export type StatusLineSection = {
13
+ type?: unknown;
14
+ command?: unknown;
15
+ padding?: unknown;
16
+ refreshInterval?: unknown;
17
+ hideVimModeIndicator?: unknown;
18
+ [key: string]: unknown;
19
+ };
20
+ /**
21
+ * Tolerant schema for the `statusline` section: every known key is optional,
22
+ * unknown sibling keys pass through (schemastery objects are non-strict by
23
+ * default), and a missing section resolves to `{}` — a shared CC settings
24
+ * file never hard-fails the cascade over extra keys.
25
+ */
26
+ export declare const STATUSLINE_SECTION_SCHEMA: z<StatusLineSection>;
27
+ /** Tolerant resolution of a raw section into the known shape (unknown keys kept). */
28
+ export declare function statusLineSectionSchema(raw: StatusLineSection | undefined): StatusLineSection;
29
+ /** Normalized, activated status-line configuration. */
30
+ export type StatusLineDescription = {
31
+ active: true;
32
+ command: string;
33
+ padding: number;
34
+ refreshIntervalSec?: number;
35
+ hideVimModeIndicator?: boolean;
36
+ } | {
37
+ active: false;
38
+ };
39
+ /**
40
+ * Apply the §3.1 activation predicate + clamps to a resolved section:
41
+ * activates iff `type === 'command'` and `command` is a non-empty string;
42
+ * `padding` defaults to 0 with negatives clamped to 0; `refreshInterval` is
43
+ * SECONDS with values < 1 clamped to 1; `hideVimModeIndicator` is parsed but
44
+ * behaviorally inert (no Vim mode in dsh-cc).
45
+ */
46
+ export declare function describeStatusLine(section: StatusLineSection | undefined): StatusLineDescription;
47
+ //# sourceMappingURL=statusline-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-settings.d.ts","sourceRoot":"","sources":["../../src/harness/statusline-settings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,wEAAwE;AACxE,eAAO,MAAM,6BAA6B,uDAAkC,CAAA;AAE5E,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,iBAAiB,CAMzD,CAAA;AAEF,qFAAqF;AACrF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,GAAG,iBAAiB,CAG7F;AAED,uDAAuD;AACvD,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/G;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,CAAA;AAErB;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,qBAAqB,CAgBhG"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Pure settings module for the custom status line: the `statusline` settings
3
+ * namespace (the cascade aliases CC's camelCase `statusLine` key onto it), a
4
+ * tolerant schema, and the activation/normalization predicate. No driver or
5
+ * shell imports — this file is the seam-free half of the feature.
6
+ * @module @dsh-cc/tui/harness/statusline-settings
7
+ */
8
+ import z from '@deepseek-ai/schemastery';
9
+ import { settingsNamespace } from '@deepseek-ai/dsh-settings';
10
+ /** Settings namespace carrying the status-line section (kebab-case). */
11
+ export const STATUSLINE_SETTINGS_NAMESPACE = settingsNamespace('statusline');
12
+ /**
13
+ * Tolerant schema for the `statusline` section: every known key is optional,
14
+ * unknown sibling keys pass through (schemastery objects are non-strict by
15
+ * default), and a missing section resolves to `{}` — a shared CC settings
16
+ * file never hard-fails the cascade over extra keys.
17
+ */
18
+ export const STATUSLINE_SECTION_SCHEMA = z.object({
19
+ type: z.any(),
20
+ command: z.any(),
21
+ padding: z.any(),
22
+ refreshInterval: z.any(),
23
+ hideVimModeIndicator: z.any(),
24
+ });
25
+ /** Tolerant resolution of a raw section into the known shape (unknown keys kept). */
26
+ export function statusLineSectionSchema(raw) {
27
+ if (typeof raw !== 'object' || raw === null)
28
+ return {};
29
+ return STATUSLINE_SECTION_SCHEMA(raw);
30
+ }
31
+ /**
32
+ * Apply the §3.1 activation predicate + clamps to a resolved section:
33
+ * activates iff `type === 'command'` and `command` is a non-empty string;
34
+ * `padding` defaults to 0 with negatives clamped to 0; `refreshInterval` is
35
+ * SECONDS with values < 1 clamped to 1; `hideVimModeIndicator` is parsed but
36
+ * behaviorally inert (no Vim mode in dsh-cc).
37
+ */
38
+ export function describeStatusLine(section) {
39
+ if (typeof section !== 'object' || section === null)
40
+ return { active: false };
41
+ const { type, command, padding, refreshInterval, hideVimModeIndicator } = section;
42
+ if (type !== 'command' || typeof command !== 'string' || command.trim().length === 0) {
43
+ return { active: false };
44
+ }
45
+ const description = {
46
+ active: true,
47
+ command,
48
+ padding: typeof padding === 'number' && Number.isFinite(padding) && padding > 0 ? padding : 0,
49
+ };
50
+ if (typeof refreshInterval === 'number' && Number.isFinite(refreshInterval)) {
51
+ description.refreshIntervalSec = refreshInterval < 1 ? 1 : refreshInterval;
52
+ }
53
+ if (hideVimModeIndicator === true)
54
+ description.hideVimModeIndicator = true;
55
+ return description;
56
+ }
57
+ //# sourceMappingURL=statusline-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-settings.js","sourceRoot":"","sources":["../../src/harness/statusline-settings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,wEAAwE;AACxE,MAAM,CAAC,MAAM,6BAA6B,GA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D,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QAC5E,WAAW,CAAC,kBAAkB,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAA;IAC5E,CAAC;IACD,IAAI,oBAAoB,KAAK,IAAI;QAAE,WAAW,CAAC,oBAAoB,GAAG,IAAI,CAAA;IAC1E,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Driver wiring for the custom status line (plan §4/Slice 4): settings
3
+ * registration (`statusline` namespace via installSettingsSection, tolerant
4
+ * when no settings provider is mounted), the lazily-created command runner,
5
+ * the refreshInterval timer (owned here — a documented deviation from the
6
+ * plan's "inside the runner" phrasing; same observable behavior, and the
7
+ * runner stays timer-free beyond its own debounce/cap), payload assembly at
8
+ * fire time from live state, and the trigger seams: projections onChanged +
9
+ * boot/rebind (hooked by driver-hud.ts), and the emit-diff wrapper (S1) over
10
+ * the driver's listener fan-out diffing permissionMode and the model/effort
11
+ * selection. Feature stays inert when the shell service is absent (D6/N3 —
12
+ * never the execFileAsync fallback).
13
+ * @module @dsh-cc/tui/harness/statusline-wiring
14
+ */
15
+ import type { Context } from '@deepseek-ai/cordis';
16
+ import type { Agent, ModelSelectionRef } from '@deepseek-ai/dsh-agent';
17
+ import type { TuiState } from '../store.ts';
18
+ /** Handle driver-hud.ts uses to consult/trigger the custom status line. */
19
+ export type StatusLineSectionHandle = {
20
+ /** The custom line when active (`' '.repeat(padding) + latest()`); else undefined. */
21
+ override(): string | undefined;
22
+ /** A projection unit changed for the live session (debounced trigger). */
23
+ onProjection(key: string): void;
24
+ /** The session was (re)bound — run once for the new session (C4). */
25
+ onRebind(): void;
26
+ };
27
+ /** The slice of createDriver's closed-over state the wiring needs. */
28
+ export type StatusLineWiringCtx = {
29
+ emit(next: TuiState): void;
30
+ state(): TuiState;
31
+ ctx: Context;
32
+ cwd: string;
33
+ current: {
34
+ agent: Agent;
35
+ };
36
+ selection: ModelSelectionRef;
37
+ /** The driver's emit listener set — the wiring rides it as the S1 diff seam. */
38
+ listeners: Set<(state: TuiState) => void>;
39
+ };
40
+ export declare function createStatusLineWiring(rt: StatusLineWiringCtx, options?: {
41
+ transcriptDir?: string;
42
+ }): StatusLineSectionHandle & {
43
+ dispose(): void;
44
+ };
45
+ //# sourceMappingURL=statusline-wiring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusline-wiring.d.ts","sourceRoot":"","sources":["../../src/harness/statusline-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAmB3C,2EAA2E;AAC3E,MAAM,MAAM,uBAAuB,GAAG;IACpC,sFAAsF;IACtF,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAA;IAC9B,0EAA0E;IAC1E,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,qEAAqE;IACrE,QAAQ,IAAI,IAAI,CAAA;CACjB,CAAA;AAED,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC1B,KAAK,IAAI,QAAQ,CAAA;IACjB,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAA;IACzB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,gFAAgF;IAChF,SAAS,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC,CAAA;CAC1C,CAAA;AAMD,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,mBAAmB,EACvB,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,uBAAuB,GAAG;IAAE,OAAO,IAAI,IAAI,CAAA;CAAE,CA8N/C"}