dual-brain 0.2.30 → 0.3.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 (309) hide show
  1. package/.dual-brain/docs/claude-code-extension-points.md +32 -0
  2. package/.dual-brain/docs/data-tools-capabilities.md +181 -0
  3. package/.dual-brain/docs/ecosystem-tools.md +91 -0
  4. package/.dual-brain/docs/panel-handoff.md +124 -0
  5. package/.dual-brain/docs/ruflo-analysis.md +48 -0
  6. package/bin/dual-brain.mjs +56 -56
  7. package/dist/mcp-server/index.d.ts +27 -0
  8. package/dist/mcp-server/index.js +359 -0
  9. package/dist/mcp-server/index.js.map +1 -0
  10. package/dist/src/agent-protocol.d.ts +163 -0
  11. package/dist/src/agent-protocol.js +368 -0
  12. package/dist/src/agent-protocol.js.map +1 -0
  13. package/dist/src/agents/registry.d.ts +52 -0
  14. package/dist/src/agents/registry.js +393 -0
  15. package/dist/src/agents/registry.js.map +1 -0
  16. package/dist/src/awareness.d.ts +93 -0
  17. package/dist/src/awareness.js +406 -0
  18. package/dist/src/awareness.js.map +1 -0
  19. package/dist/src/brief.d.ts +48 -0
  20. package/dist/src/brief.js +179 -0
  21. package/dist/src/brief.js.map +1 -0
  22. package/dist/src/calibration.d.ts +32 -0
  23. package/dist/src/calibration.js +133 -0
  24. package/dist/src/calibration.js.map +1 -0
  25. package/dist/src/checkpoint.d.ts +33 -0
  26. package/dist/src/checkpoint.js +99 -0
  27. package/dist/src/checkpoint.js.map +1 -0
  28. package/dist/src/ci-triage.d.ts +33 -0
  29. package/dist/src/ci-triage.js +193 -0
  30. package/dist/src/ci-triage.js.map +1 -0
  31. package/dist/src/cognitive-loop.d.ts +56 -0
  32. package/dist/src/cognitive-loop.js +495 -0
  33. package/dist/src/cognitive-loop.js.map +1 -0
  34. package/dist/src/collaboration.d.ts +147 -0
  35. package/dist/src/collaboration.js +438 -0
  36. package/dist/src/collaboration.js.map +1 -0
  37. package/dist/src/context-intel.d.ts +47 -0
  38. package/dist/src/context-intel.js +156 -0
  39. package/dist/src/context-intel.js.map +1 -0
  40. package/dist/src/context.d.ts +53 -0
  41. package/dist/src/context.js +332 -0
  42. package/dist/src/context.js.map +1 -0
  43. package/dist/src/continuity.d.ts +89 -0
  44. package/dist/src/continuity.js +230 -0
  45. package/dist/src/continuity.js.map +1 -0
  46. package/dist/src/cost-tracker.d.ts +47 -0
  47. package/dist/src/cost-tracker.js +170 -0
  48. package/dist/src/cost-tracker.js.map +1 -0
  49. package/dist/src/debrief.d.ts +53 -0
  50. package/dist/src/debrief.js +222 -0
  51. package/dist/src/debrief.js.map +1 -0
  52. package/dist/src/decide.d.ts +96 -0
  53. package/dist/src/decide.js +744 -0
  54. package/dist/src/decide.js.map +1 -0
  55. package/dist/src/decompose.d.ts +39 -0
  56. package/dist/src/decompose.js +218 -0
  57. package/dist/src/decompose.js.map +1 -0
  58. package/dist/src/detect.d.ts +91 -0
  59. package/dist/src/detect.js +544 -0
  60. package/dist/src/detect.js.map +1 -0
  61. package/dist/src/dispatch.d.ts +154 -0
  62. package/dist/src/dispatch.js +1306 -0
  63. package/dist/src/dispatch.js.map +1 -0
  64. package/dist/src/doctor.d.ts +421 -0
  65. package/dist/src/doctor.js +1689 -0
  66. package/dist/src/doctor.js.map +1 -0
  67. package/dist/src/engine.d.ts +70 -0
  68. package/dist/src/engine.js +155 -0
  69. package/dist/src/engine.js.map +1 -0
  70. package/dist/src/envelope.d.ts +36 -0
  71. package/dist/src/envelope.js +80 -0
  72. package/dist/src/envelope.js.map +1 -0
  73. package/dist/src/failure-memory.d.ts +55 -0
  74. package/dist/src/failure-memory.js +175 -0
  75. package/dist/src/failure-memory.js.map +1 -0
  76. package/dist/src/fx.d.ts +87 -0
  77. package/dist/src/fx.js +272 -0
  78. package/dist/src/fx.js.map +1 -0
  79. package/dist/src/governance.d.ts +93 -0
  80. package/dist/src/governance.js +261 -0
  81. package/dist/src/governance.js.map +1 -0
  82. package/dist/src/handoff.d.ts +11 -0
  83. package/dist/src/handoff.js +90 -0
  84. package/dist/src/handoff.js.map +1 -0
  85. package/dist/src/head-protocol.d.ts +76 -0
  86. package/dist/src/head-protocol.js +109 -0
  87. package/dist/src/head-protocol.js.map +1 -0
  88. package/dist/src/head.d.ts +222 -0
  89. package/dist/src/head.js +765 -0
  90. package/dist/src/head.js.map +1 -0
  91. package/dist/src/health.d.ts +132 -0
  92. package/dist/src/health.js +435 -0
  93. package/dist/src/health.js.map +1 -0
  94. package/dist/src/inbox.d.ts +70 -0
  95. package/dist/src/inbox.js +218 -0
  96. package/dist/src/inbox.js.map +1 -0
  97. package/dist/src/index.d.ts +33 -0
  98. package/dist/src/index.js +38 -0
  99. package/dist/src/index.js.map +1 -0
  100. package/dist/src/install-hooks.d.ts +13 -0
  101. package/dist/src/install-hooks.js +88 -0
  102. package/dist/src/install-hooks.js.map +1 -0
  103. package/dist/src/integrity.d.ts +59 -0
  104. package/dist/src/integrity.js +206 -0
  105. package/dist/src/integrity.js.map +1 -0
  106. package/dist/src/intelligence.d.ts +104 -0
  107. package/dist/src/intelligence.js +391 -0
  108. package/dist/src/intelligence.js.map +1 -0
  109. package/dist/src/ledger.d.ts +54 -0
  110. package/dist/src/ledger.js +179 -0
  111. package/dist/src/ledger.js.map +1 -0
  112. package/dist/src/living-docs.d.ts +14 -0
  113. package/dist/src/living-docs.js +197 -0
  114. package/dist/src/living-docs.js.map +1 -0
  115. package/dist/src/memory-tiers.d.ts +37 -0
  116. package/dist/src/memory-tiers.js +160 -0
  117. package/dist/src/memory-tiers.js.map +1 -0
  118. package/dist/src/model-profiles.d.ts +65 -0
  119. package/dist/src/model-profiles.js +568 -0
  120. package/dist/src/model-profiles.js.map +1 -0
  121. package/dist/src/models.d.ts +58 -0
  122. package/dist/src/models.js +327 -0
  123. package/dist/src/models.js.map +1 -0
  124. package/dist/src/narrative.d.ts +54 -0
  125. package/dist/src/narrative.js +163 -0
  126. package/dist/src/narrative.js.map +1 -0
  127. package/dist/src/nextstep.d.ts +16 -0
  128. package/dist/src/nextstep.js +103 -0
  129. package/dist/src/nextstep.js.map +1 -0
  130. package/dist/src/observer.d.ts +18 -0
  131. package/dist/src/observer.js +251 -0
  132. package/dist/src/observer.js.map +1 -0
  133. package/dist/src/outcome.d.ts +110 -0
  134. package/dist/src/outcome.js +377 -0
  135. package/dist/src/outcome.js.map +1 -0
  136. package/dist/src/pipeline.d.ts +167 -0
  137. package/dist/src/pipeline.js +1503 -0
  138. package/dist/src/pipeline.js.map +1 -0
  139. package/dist/src/playbook.d.ts +59 -0
  140. package/dist/src/playbook.js +238 -0
  141. package/dist/src/playbook.js.map +1 -0
  142. package/dist/src/pr-agent.d.ts +97 -0
  143. package/dist/src/pr-agent.js +195 -0
  144. package/dist/src/pr-agent.js.map +1 -0
  145. package/dist/src/predictive.d.ts +57 -0
  146. package/dist/src/predictive.js +230 -0
  147. package/dist/src/predictive.js.map +1 -0
  148. package/dist/src/profile.d.ts +294 -0
  149. package/dist/src/profile.js +1347 -0
  150. package/dist/src/profile.js.map +1 -0
  151. package/dist/src/prompt-audit.d.ts +22 -0
  152. package/dist/src/prompt-audit.js +194 -0
  153. package/dist/src/prompt-audit.js.map +1 -0
  154. package/dist/src/prompt-intel.d.ts +12 -0
  155. package/dist/src/prompt-intel.js +321 -0
  156. package/dist/src/prompt-intel.js.map +1 -0
  157. package/dist/src/provider-context.d.ts +121 -0
  158. package/dist/src/provider-context.js +222 -0
  159. package/dist/src/provider-context.js.map +1 -0
  160. package/dist/src/provider-manager.d.ts +92 -0
  161. package/dist/src/provider-manager.js +428 -0
  162. package/dist/src/provider-manager.js.map +1 -0
  163. package/dist/src/receipt.d.ts +87 -0
  164. package/dist/src/receipt.js +326 -0
  165. package/dist/src/receipt.js.map +1 -0
  166. package/dist/src/recommendations.d.ts +13 -0
  167. package/dist/src/recommendations.js +291 -0
  168. package/dist/src/recommendations.js.map +1 -0
  169. package/dist/src/redact.d.ts +15 -0
  170. package/dist/src/redact.js +129 -0
  171. package/dist/src/redact.js.map +1 -0
  172. package/dist/src/replit.d.ts +397 -0
  173. package/dist/src/replit.js +1160 -0
  174. package/dist/src/replit.js.map +1 -0
  175. package/dist/src/repo.d.ts +149 -0
  176. package/dist/src/repo.js +416 -0
  177. package/dist/src/repo.js.map +1 -0
  178. package/dist/src/revert.d.ts +30 -0
  179. package/dist/src/revert.js +166 -0
  180. package/dist/src/revert.js.map +1 -0
  181. package/dist/src/room.d.ts +102 -0
  182. package/dist/src/room.js +212 -0
  183. package/dist/src/room.js.map +1 -0
  184. package/dist/src/routing-advisor.d.ts +57 -0
  185. package/dist/src/routing-advisor.js +221 -0
  186. package/dist/src/routing-advisor.js.map +1 -0
  187. package/dist/src/self-correct.d.ts +40 -0
  188. package/dist/src/self-correct.js +137 -0
  189. package/dist/src/self-correct.js.map +1 -0
  190. package/dist/src/session-lock.d.ts +35 -0
  191. package/dist/src/session-lock.js +134 -0
  192. package/dist/src/session-lock.js.map +1 -0
  193. package/dist/src/session.d.ts +267 -0
  194. package/dist/src/session.js +1660 -0
  195. package/dist/src/session.js.map +1 -0
  196. package/dist/src/settings-tui.d.ts +5 -0
  197. package/dist/src/settings-tui.js +422 -0
  198. package/dist/src/settings-tui.js.map +1 -0
  199. package/dist/src/setup-flow.d.ts +63 -0
  200. package/dist/src/setup-flow.js +233 -0
  201. package/dist/src/setup-flow.js.map +1 -0
  202. package/dist/src/signal.d.ts +19 -0
  203. package/dist/src/signal.js +122 -0
  204. package/dist/src/signal.js.map +1 -0
  205. package/dist/src/simmer.d.ts +85 -0
  206. package/dist/src/simmer.js +224 -0
  207. package/dist/src/simmer.js.map +1 -0
  208. package/dist/src/state-export.d.ts +129 -0
  209. package/dist/src/state-export.js +233 -0
  210. package/dist/src/state-export.js.map +1 -0
  211. package/dist/src/strategy.d.ts +54 -0
  212. package/dist/src/strategy.js +95 -0
  213. package/dist/src/strategy.js.map +1 -0
  214. package/dist/src/subscription.d.ts +40 -0
  215. package/dist/src/subscription.js +189 -0
  216. package/dist/src/subscription.js.map +1 -0
  217. package/dist/src/templates.d.ts +208 -0
  218. package/dist/src/templates.js +238 -0
  219. package/dist/src/templates.js.map +1 -0
  220. package/dist/src/test.d.ts +9 -0
  221. package/dist/src/test.js +1173 -0
  222. package/dist/src/test.js.map +1 -0
  223. package/dist/src/think-engine.d.ts +67 -0
  224. package/dist/src/think-engine.js +412 -0
  225. package/dist/src/think-engine.js.map +1 -0
  226. package/dist/src/tui.d.ts +71 -0
  227. package/dist/src/tui.js +242 -0
  228. package/dist/src/tui.js.map +1 -0
  229. package/dist/src/types.d.ts +177 -0
  230. package/dist/src/types.js +6 -0
  231. package/dist/src/types.js.map +1 -0
  232. package/dist/src/update-check.d.ts +7 -0
  233. package/dist/src/update-check.js +36 -0
  234. package/dist/src/update-check.js.map +1 -0
  235. package/dist/src/wave-planner.d.ts +30 -0
  236. package/dist/src/wave-planner.js +281 -0
  237. package/dist/src/wave-planner.js.map +1 -0
  238. package/hooks/head-guard.sh +41 -0
  239. package/hooks/task-classifier.mjs +328 -0
  240. package/hooks/vibe-router.mjs +387 -0
  241. package/package.json +29 -153
  242. package/src/agents/registry.mjs +0 -405
  243. package/src/awareness.mjs +0 -425
  244. package/src/brief.mjs +0 -266
  245. package/src/calibration.mjs +0 -148
  246. package/src/checkpoint.mjs +0 -109
  247. package/src/ci-triage.mjs +0 -191
  248. package/src/cognitive-loop.mjs +0 -562
  249. package/src/collaboration.mjs +0 -545
  250. package/src/context-intel.mjs +0 -158
  251. package/src/context.mjs +0 -389
  252. package/src/continuity.mjs +0 -298
  253. package/src/cost-tracker.mjs +0 -184
  254. package/src/debrief.mjs +0 -228
  255. package/src/decide.mjs +0 -1099
  256. package/src/decompose.mjs +0 -331
  257. package/src/detect.mjs +0 -702
  258. package/src/dispatch.mjs +0 -1447
  259. package/src/doctor.mjs +0 -1607
  260. package/src/envelope.mjs +0 -139
  261. package/src/failure-memory.mjs +0 -178
  262. package/src/fx.mjs +0 -276
  263. package/src/governance.mjs +0 -279
  264. package/src/handoff.mjs +0 -87
  265. package/src/head-protocol.mjs +0 -128
  266. package/src/head.mjs +0 -952
  267. package/src/health.mjs +0 -528
  268. package/src/inbox.mjs +0 -195
  269. package/src/index.mjs +0 -44
  270. package/src/install-hooks.mjs +0 -100
  271. package/src/integrity.mjs +0 -245
  272. package/src/intelligence.mjs +0 -447
  273. package/src/ledger.mjs +0 -196
  274. package/src/living-docs.mjs +0 -210
  275. package/src/memory-tiers.mjs +0 -193
  276. package/src/models.mjs +0 -363
  277. package/src/narrative.mjs +0 -169
  278. package/src/nextstep.mjs +0 -100
  279. package/src/observer.mjs +0 -241
  280. package/src/outcome.mjs +0 -400
  281. package/src/pipeline.mjs +0 -1711
  282. package/src/playbook.mjs +0 -257
  283. package/src/pr-agent.mjs +0 -214
  284. package/src/predictive.mjs +0 -250
  285. package/src/profile.mjs +0 -1411
  286. package/src/prompt-audit.mjs +0 -231
  287. package/src/prompt-intel.mjs +0 -325
  288. package/src/provider-context.mjs +0 -257
  289. package/src/receipt.mjs +0 -344
  290. package/src/recommendations.mjs +0 -296
  291. package/src/redact.mjs +0 -192
  292. package/src/replit.mjs +0 -1210
  293. package/src/repo.mjs +0 -445
  294. package/src/revert.mjs +0 -149
  295. package/src/routing-advisor.mjs +0 -204
  296. package/src/self-correct.mjs +0 -147
  297. package/src/session-lock.mjs +0 -160
  298. package/src/session.mjs +0 -1655
  299. package/src/settings-tui.mjs +0 -373
  300. package/src/setup-flow.mjs +0 -223
  301. package/src/signal.mjs +0 -115
  302. package/src/simmer.mjs +0 -241
  303. package/src/strategy.mjs +0 -235
  304. package/src/subscription.mjs +0 -212
  305. package/src/templates.mjs +0 -260
  306. package/src/think-engine.mjs +0 -428
  307. package/src/tui.mjs +0 -276
  308. package/src/update-check.mjs +0 -35
  309. package/src/wave-planner.mjs +0 -294
@@ -0,0 +1,71 @@
1
+ /**
2
+ * tui.mjs — Zero-dependency terminal UI renderer for the dual-brain CLI.
3
+ * All functions return strings; callers use console.log to print.
4
+ */
5
+ export declare const useUnicode: boolean;
6
+ /** Strip ANSI escape codes from a string. */
7
+ export declare function stripAnsi(str: string): string;
8
+ /**
9
+ * Visible display length of a string.
10
+ * Strips ANSI codes and counts each emoji as 2 columns wide.
11
+ */
12
+ export declare function visibleLength(str: string): number;
13
+ /**
14
+ * Right-pad `str` with spaces so that its visible width equals `width`.
15
+ * Accounts for emoji (2-wide) and ANSI codes.
16
+ */
17
+ export declare function pad(str: string, width: number): string;
18
+ /**
19
+ * Renders a Unicode (or ASCII) box with a title bar.
20
+ * @param {string} title
21
+ * @param {string[]} lines
22
+ * @param {{ width?: number }} opts
23
+ * @returns {string}
24
+ */
25
+ export declare function box(title: string, lines?: string[], opts?: {
26
+ width?: number;
27
+ }): string;
28
+ /**
29
+ * Renders a percentage bar.
30
+ * @param {number} percent 0–100
31
+ * @param {number} width bar width in chars (default 20)
32
+ * @param {{ label?: string }} opts
33
+ * @returns {string}
34
+ */
35
+ export declare function bar(percent: number, width?: number, opts?: {
36
+ label?: string;
37
+ }): string;
38
+ /**
39
+ * Returns a status badge emoji/symbol.
40
+ * @param {string} status
41
+ * @returns {string}
42
+ */
43
+ export declare function badge(status: string): string;
44
+ /**
45
+ * Returns a section separator line.
46
+ * @param {string} label
47
+ * @returns {string}
48
+ */
49
+ export declare function separator(label?: string): string;
50
+ /**
51
+ * Renders a numbered/lettered menu grouped by section.
52
+ * @param {{ key: string, label: string, section?: string }[]} options
53
+ * @param {object} opts (reserved)
54
+ * @returns {string}
55
+ */
56
+ export declare function menu(options: Array<{
57
+ key: string;
58
+ label: string;
59
+ section?: string;
60
+ }>, opts?: Record<string, unknown>): string;
61
+ export declare function panel(title: string, content: string | string[], opts?: {
62
+ width?: number;
63
+ titleColor?: string;
64
+ borderColor?: string;
65
+ reset?: string;
66
+ }): string;
67
+ export declare function divider(width?: number): string;
68
+ export declare function statusChip(label: string, healthy: boolean, opts?: Record<string, unknown>): string;
69
+ export declare function headerBar(left: string, right: string, width?: number): string;
70
+ export declare function prompt(text?: string): string;
71
+ export declare function signalLine(type: string, text: string, meta?: string): string;
@@ -0,0 +1,242 @@
1
+ /**
2
+ * tui.mjs — Zero-dependency terminal UI renderer for the dual-brain CLI.
3
+ * All functions return strings; callers use console.log to print.
4
+ */
5
+ import { fileURLToPath } from 'node:url';
6
+ import { readFileSync } from 'node:fs';
7
+ import { join, dirname } from 'node:path';
8
+ // ─── Unicode / ASCII mode ─────────────────────────────────────────────────────
9
+ export const useUnicode = process.env.DUALBRAIN_ASCII !== '1' && process.stdout.isTTY !== false;
10
+ const CH = useUnicode
11
+ ? { tl: '╔', tr: '╗', bl: '╚', br: '╝', h: '═', v: '║', ts: '╠', te: '╣', fill: '█', empty: '░' }
12
+ : { tl: '+', tr: '+', bl: '+', br: '+', h: '-', v: '|', ts: '+', te: '+', fill: '#', empty: '.' };
13
+ // ─── ANSI / emoji helpers ─────────────────────────────────────────────────────
14
+ /** Strip ANSI escape codes from a string. */
15
+ export function stripAnsi(str) {
16
+ // eslint-disable-next-line no-control-regex
17
+ return String(str).replace(/\x1B\[[0-9;]*[A-Za-z]/g, '');
18
+ }
19
+ /**
20
+ * Visible display length of a string.
21
+ * Strips ANSI codes and counts each emoji as 2 columns wide.
22
+ */
23
+ export function visibleLength(str) {
24
+ const plain = stripAnsi(String(str));
25
+ let len = 0;
26
+ for (const ch of plain) {
27
+ const cp = ch.codePointAt(0) ?? 0;
28
+ // Emoji / wide symbol ranges (covers most common emoji)
29
+ if ((cp >= 0x1f300 && cp <= 0x1faff) || // Misc symbols, emoji
30
+ (cp >= 0x2600 && cp <= 0x27bf) || // Misc symbols
31
+ (cp >= 0xfe00 && cp <= 0xfe0f) || // Variation selectors
32
+ (cp >= 0x1f1e0 && cp <= 0x1f1ff) || // Flags
33
+ cp === 0x20e3 // Combining enclosing keycap
34
+ ) {
35
+ len += 2;
36
+ }
37
+ else {
38
+ len += 1;
39
+ }
40
+ }
41
+ return len;
42
+ }
43
+ /**
44
+ * Right-pad `str` with spaces so that its visible width equals `width`.
45
+ * Accounts for emoji (2-wide) and ANSI codes.
46
+ */
47
+ export function pad(str, width) {
48
+ const vl = visibleLength(str);
49
+ const spaces = Math.max(0, width - vl);
50
+ return String(str) + ' '.repeat(spaces);
51
+ }
52
+ // ─── box ─────────────────────────────────────────────────────────────────────
53
+ /**
54
+ * Renders a Unicode (or ASCII) box with a title bar.
55
+ * @param {string} title
56
+ * @param {string[]} lines
57
+ * @param {{ width?: number }} opts
58
+ * @returns {string}
59
+ */
60
+ export function box(title, lines = [], opts = {}) {
61
+ const inner = opts.width ?? 56;
62
+ const total = inner + 2; // 2 spaces padding on each side counted inside border
63
+ const top = CH.tl + CH.h.repeat(total) + CH.tr;
64
+ const divider = CH.ts + CH.h.repeat(total) + CH.te;
65
+ const bottom = CH.bl + CH.h.repeat(total) + CH.br;
66
+ // Title row: 2-space left pad
67
+ const titleContent = ' ' + title;
68
+ const titleRow = CH.v + pad(titleContent, total) + CH.v;
69
+ const bodyRows = lines.map(line => {
70
+ const content = ' ' + line;
71
+ return CH.v + pad(content, total) + CH.v;
72
+ });
73
+ return [top, titleRow, divider, ...bodyRows, bottom].join('\n');
74
+ }
75
+ // ─── bar ─────────────────────────────────────────────────────────────────────
76
+ /**
77
+ * Renders a percentage bar.
78
+ * @param {number} percent 0–100
79
+ * @param {number} width bar width in chars (default 20)
80
+ * @param {{ label?: string }} opts
81
+ * @returns {string}
82
+ */
83
+ export function bar(percent, width = 20, opts = {}) {
84
+ const pct = Math.max(0, Math.min(100, percent));
85
+ const filled = Math.round((pct / 100) * width);
86
+ const empty = width - filled;
87
+ const track = CH.fill.repeat(filled) + CH.empty.repeat(empty);
88
+ const pctStr = String(Math.round(pct)).padStart(3) + '%';
89
+ const label = opts.label ? ` ${opts.label}` : '';
90
+ return `${track} ${pctStr}${label}`;
91
+ }
92
+ // ─── badge ────────────────────────────────────────────────────────────────────
93
+ /**
94
+ * Returns a status badge emoji/symbol.
95
+ * @param {string} status
96
+ * @returns {string}
97
+ */
98
+ export function badge(status) {
99
+ const map = {
100
+ healthy: '🟢',
101
+ degraded: '🟡',
102
+ hot: '🔴',
103
+ probing: '🟠',
104
+ connected: '✅',
105
+ missing: '❌',
106
+ warning: '⚠️',
107
+ };
108
+ return map[status] ?? '❓';
109
+ }
110
+ // ─── separator ───────────────────────────────────────────────────────────────
111
+ /**
112
+ * Returns a section separator line.
113
+ * @param {string} label
114
+ * @returns {string}
115
+ */
116
+ export function separator(label = '') {
117
+ const dash = useUnicode ? '─' : '-';
118
+ return label
119
+ ? ` ${dash}${dash}${dash} ${label}`
120
+ : ` ${dash}${dash}${dash}`;
121
+ }
122
+ // ─── menu ────────────────────────────────────────────────────────────────────
123
+ /**
124
+ * Renders a numbered/lettered menu grouped by section.
125
+ * @param {{ key: string, label: string, section?: string }[]} options
126
+ * @param {object} opts (reserved)
127
+ * @returns {string}
128
+ */
129
+ export function menu(options, opts = {}) {
130
+ const rows = [];
131
+ let lastSection = Symbol('none');
132
+ for (const opt of options) {
133
+ const section = opt.section ?? '';
134
+ if (section !== lastSection) {
135
+ if (section) {
136
+ rows.push(separator(section));
137
+ }
138
+ else {
139
+ rows.push(separator());
140
+ }
141
+ lastSection = section;
142
+ }
143
+ rows.push(` [${opt.key}] ${opt.label}`);
144
+ }
145
+ return rows.join('\n');
146
+ }
147
+ // ── Modern box rendering with rounded corners ────────────────────────────────
148
+ const ROUNDED = { tl: '╭', tr: '╮', bl: '╰', br: '╯', h: '─', v: '│', ml: '├', mr: '┤' };
149
+ export function panel(title, content, opts = {}) {
150
+ const { width = 70, titleColor = '\x1b[36m', borderColor = '\x1b[2m', reset = '\x1b[0m' } = opts;
151
+ const lines = [];
152
+ const innerW = width - 2;
153
+ // Top border with title
154
+ if (title) {
155
+ const titleStr = ` ${title} `;
156
+ const remaining = innerW - titleStr.length - 1;
157
+ lines.push(`${borderColor}${ROUNDED.tl}${ROUNDED.h} ${titleColor}${title}${borderColor} ${ROUNDED.h.repeat(Math.max(0, remaining))}${ROUNDED.tr}${reset}`);
158
+ }
159
+ else {
160
+ lines.push(`${borderColor}${ROUNDED.tl}${ROUNDED.h.repeat(innerW)}${ROUNDED.tr}${reset}`);
161
+ }
162
+ // Content lines
163
+ const contentLines = (typeof content === 'string' ? content.split('\n') : content);
164
+ for (const line of contentLines) {
165
+ const stripped = line.replace(/\x1b\[[0-9;]*m/g, '');
166
+ const pad = Math.max(0, innerW - stripped.length);
167
+ lines.push(`${borderColor}${ROUNDED.v}${reset} ${line}${' '.repeat(pad)}${borderColor}${ROUNDED.v}${reset}`);
168
+ }
169
+ // Bottom border
170
+ lines.push(`${borderColor}${ROUNDED.bl}${ROUNDED.h.repeat(innerW)}${ROUNDED.br}${reset}`);
171
+ return lines.join('\n');
172
+ }
173
+ export function divider(width = 70) {
174
+ const borderColor = '\x1b[2m';
175
+ const reset = '\x1b[0m';
176
+ return `${borderColor}${ROUNDED.ml}${ROUNDED.h.repeat(width - 2)}${ROUNDED.mr}${reset}`;
177
+ }
178
+ export function statusChip(label, healthy, opts = {}) {
179
+ const green = '\x1b[32m';
180
+ const red = '\x1b[31m';
181
+ const dim = '\x1b[2m';
182
+ const reset = '\x1b[0m';
183
+ const icon = healthy ? `${green}●${reset}` : `${red}●${reset}`;
184
+ return `${icon} ${dim}${label}${reset}`;
185
+ }
186
+ export function headerBar(left, right, width = 70) {
187
+ const leftStripped = left.replace(/\x1b\[[0-9;]*m/g, '');
188
+ const rightStripped = right.replace(/\x1b\[[0-9;]*m/g, '');
189
+ const gap = Math.max(1, width - leftStripped.length - rightStripped.length);
190
+ return `${left}${' '.repeat(gap)}${right}`;
191
+ }
192
+ export function prompt(text = '> task or /help') {
193
+ const cyan = '\x1b[36m';
194
+ const dim = '\x1b[2m';
195
+ const reset = '\x1b[0m';
196
+ return `${cyan}>${reset} ${dim}${text.replace(/^>\s*/, '')}${reset}`;
197
+ }
198
+ export function signalLine(type, text, meta = '') {
199
+ const green = '\x1b[32m';
200
+ const yellow = '\x1b[33m';
201
+ const dim = '\x1b[2m';
202
+ const reset = '\x1b[0m';
203
+ let icon;
204
+ switch (type) {
205
+ case 'success':
206
+ icon = `${green}✓${reset}`;
207
+ break;
208
+ case 'warning':
209
+ icon = `${yellow}!${reset}`;
210
+ break;
211
+ case 'info':
212
+ icon = `${dim}·${reset}`;
213
+ break;
214
+ default: icon = `${dim}·${reset}`;
215
+ }
216
+ const metaStr = meta ? `${dim}${meta}${reset}` : '';
217
+ return `${icon} ${text}${metaStr ? ' ' + metaStr : ''}`;
218
+ }
219
+ // ─── Self-test ────────────────────────────────────────────────────────────────
220
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
221
+ // Read version dynamically from package.json
222
+ let selfTestVersion = '0.0.0';
223
+ try {
224
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
225
+ selfTestVersion = JSON.parse(readFileSync(pkgPath, 'utf8')).version;
226
+ }
227
+ catch { /* fallback to 0.0.0 */ }
228
+ console.log(box(`🧠 Dual-Brain v${selfTestVersion}`, [
229
+ '🟢 Claude ✅ 🟢 OpenAI ✅',
230
+ '🌀 Replit + replit-tools',
231
+ ]));
232
+ console.log(bar(75, 20, { label: 'Claude' }));
233
+ console.log(bar(25, 20, { label: 'OpenAI' }));
234
+ console.log(menu([
235
+ { key: 'c', label: 'Continue last session', section: 'Sessions' },
236
+ { key: 'n', label: 'New session', section: 'Sessions' },
237
+ { key: 'a', label: 'Auth management', section: 'Settings' },
238
+ { key: 'p', label: 'Profile settings', section: 'Settings' },
239
+ { key: 's', label: 'Exit to shell', section: '' },
240
+ ]));
241
+ }
242
+ //# sourceMappingURL=tui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tui.js","sourceRoot":"","sources":["../../src/tui.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,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E,KAAK,EAAE,eAAe,EAAU,OAAO,EAAE,EAAE,EAAE;KAC1D,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Core shared types for the dual-brain orchestrator.
3
+ * These represent the data shapes flowing through the pipeline.
4
+ */
5
+ export type Provider = 'claude' | 'openai';
6
+ export type Tier = 'search' | 'execute' | 'think' | 'review';
7
+ export type Risk = 'low' | 'medium' | 'high' | 'critical';
8
+ export type Complexity = 'simple' | 'moderate' | 'complex';
9
+ export type LatencyTier = 'fast' | 'medium' | 'slow';
10
+ export type CostTier = 'cheap' | 'moderate' | 'expensive';
11
+ export interface ModelTraits {
12
+ [key: string]: number;
13
+ reasoningDepth: number;
14
+ codeGeneration: number;
15
+ codeReview: number;
16
+ editPrecision: number;
17
+ architecture: number;
18
+ instructionFollowing: number;
19
+ structuredOutput: number;
20
+ steerability: number;
21
+ refactoring: number;
22
+ testGeneration: number;
23
+ documentation: number;
24
+ }
25
+ export interface ModelLanguages {
26
+ [key: string]: number;
27
+ systems: number;
28
+ scripting: number;
29
+ markup: number;
30
+ niche: number;
31
+ }
32
+ export interface ModelOps {
33
+ latencyTier: LatencyTier;
34
+ costTier: CostTier;
35
+ contextDegradation: number;
36
+ parameterSensitive: boolean;
37
+ }
38
+ export type Modality = 'text' | 'vision';
39
+ export type ToolUse = 'native' | 'function-calling' | 'none';
40
+ export type Autonomy = 'agent-loop' | 'single-turn' | 'multi-turn';
41
+ export interface ModelProfile {
42
+ id: string;
43
+ name: string;
44
+ provider: Provider;
45
+ tier: number;
46
+ contextWindow: number;
47
+ maxOutput: number;
48
+ supportedModes: string[];
49
+ toolUse: ToolUse;
50
+ autonomy: Autonomy;
51
+ multimodal: Modality[];
52
+ traits: ModelTraits;
53
+ languages: ModelLanguages;
54
+ ops: ModelOps;
55
+ quirks: string[];
56
+ }
57
+ export interface DispatchDecision {
58
+ provider: Provider;
59
+ model: string;
60
+ effort: string;
61
+ tier: Tier;
62
+ dualBrain: boolean;
63
+ degradedDualBrain?: boolean;
64
+ challengerModel?: string | null;
65
+ workStyle: string;
66
+ modes: string[];
67
+ sandbox: boolean;
68
+ explanation: string;
69
+ _advisorOverride?: {
70
+ from: string;
71
+ to: string;
72
+ reason: string;
73
+ explored: boolean;
74
+ } | null;
75
+ }
76
+ export interface RoutingState {
77
+ provider: Provider;
78
+ model: string;
79
+ tier: Tier;
80
+ risk: Risk;
81
+ complexity: Complexity;
82
+ intent: string;
83
+ effort: string;
84
+ dualBrain: boolean;
85
+ healthScores: Record<Provider, number>;
86
+ }
87
+ export interface TokenUsage {
88
+ input?: number;
89
+ output?: number;
90
+ total?: number;
91
+ }
92
+ export interface TaskOutcome {
93
+ success: boolean;
94
+ status?: 'complete' | 'partial' | 'failed';
95
+ tier: Tier;
96
+ durationMs: number;
97
+ filesChanged?: string[] | number;
98
+ tokensUsed?: TokenUsage;
99
+ error?: string;
100
+ stderr?: string;
101
+ stdout?: string;
102
+ output?: string;
103
+ quality?: number;
104
+ score?: number;
105
+ }
106
+ export interface SignalScore {
107
+ name: string;
108
+ value: number | null;
109
+ weight: number;
110
+ }
111
+ export interface CompositeScore {
112
+ score: number;
113
+ signals: SignalScore[];
114
+ confidence: number;
115
+ }
116
+ export type FailureType = 'rate-limit' | 'timeout' | 'context-overflow' | 'specification' | 'capability' | 'unknown';
117
+ export interface FailureClassification {
118
+ type: FailureType;
119
+ confidence: number;
120
+ retryable: boolean;
121
+ }
122
+ export type RetryStrategyName = 'escalate' | 'wait-retry' | 'compress' | 'split' | 'give-up';
123
+ export interface RetryStrategy {
124
+ strategy: RetryStrategyName;
125
+ reason: string;
126
+ newDecision?: DispatchDecision;
127
+ }
128
+ export type HandoffStage = 'think' | 'thinker' | 'work' | 'worker' | 'review' | 'reviewer' | 'head';
129
+ export type HandoffType = 'think-to-work' | 'work-to-review' | 'review-to-head';
130
+ export interface HandoffContract {
131
+ fromStage: HandoffStage;
132
+ toStage: HandoffStage;
133
+ runId: string;
134
+ createdAt: string;
135
+ data: HandoffData;
136
+ }
137
+ export type HandoffData = ThinkToWorkData | WorkToReviewData | ReviewToHeadData;
138
+ export interface ThinkToWorkData {
139
+ objective: string;
140
+ files: string[];
141
+ criteria: string[];
142
+ context?: string;
143
+ confidence?: number;
144
+ }
145
+ export interface WorkToReviewData {
146
+ filesChanged: string[];
147
+ objective: string;
148
+ diff?: string;
149
+ criteria?: string | string[];
150
+ testsRun?: string;
151
+ }
152
+ export interface ReviewToHeadData {
153
+ pass: boolean;
154
+ findings?: string[];
155
+ recommendation?: string;
156
+ severity?: string;
157
+ }
158
+ export interface TaskDetection {
159
+ intent: string;
160
+ risk: Risk;
161
+ complexity: Complexity;
162
+ effort: string;
163
+ tier: Tier;
164
+ designImpact?: boolean;
165
+ }
166
+ export interface ProviderHealth {
167
+ score: number;
168
+ cooldownUntil?: number;
169
+ lastError?: string;
170
+ degraded?: boolean;
171
+ }
172
+ export interface FailoverOption {
173
+ provider: Provider;
174
+ model: string;
175
+ plan: string;
176
+ label: string;
177
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Core shared types for the dual-brain orchestrator.
3
+ * These represent the data shapes flowing through the pipeline.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,7 @@
1
+ export declare function getLocalVersion(): string | null;
2
+ export declare function getLatestVersion(): string | null;
3
+ export declare function checkForUpdate(): {
4
+ updateAvailable: boolean;
5
+ local: string | null;
6
+ latest: string | null;
7
+ };
@@ -0,0 +1,36 @@
1
+ import { execSync } from 'child_process';
2
+ import { readFileSync } from 'fs';
3
+ import { join, dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ export function getLocalVersion() {
7
+ try {
8
+ const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
9
+ return pkg.version;
10
+ }
11
+ catch {
12
+ return null;
13
+ }
14
+ }
15
+ export function getLatestVersion() {
16
+ try {
17
+ const result = execSync('npm view dual-brain version 2>/dev/null', { encoding: 'utf8', timeout: 5000 });
18
+ return result.trim();
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ export function checkForUpdate() {
25
+ const local = getLocalVersion();
26
+ const latest = getLatestVersion();
27
+ if (!local || !latest)
28
+ return { updateAvailable: false, local, latest };
29
+ const localParts = local.split('.').map(Number);
30
+ const latestParts = latest.split('.').map(Number);
31
+ const updateAvailable = latestParts[0] > localParts[0]
32
+ || (latestParts[0] === localParts[0] && latestParts[1] > localParts[1])
33
+ || (latestParts[0] === localParts[0] && latestParts[1] === localParts[1] && latestParts[2] > localParts[2]);
34
+ return { updateAvailable, local, latest };
35
+ }
36
+ //# sourceMappingURL=update-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-check.js","sourceRoot":"","sources":["../../src/update-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QACpF,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;AAC1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2
+ tier: string;
3
+ objective: string;
4
+ scope: string[];
5
+ conditionalPivot?: {
6
+ if: unknown;
7
+ then: string;
8
+ };
9
+ }
10
+ interface Wave {
11
+ id: string;
12
+ phase: string;
13
+ agents: AgentSpec[];
14
+ dependsOn: string[];
15
+ gateCondition?: string;
16
+ parallel: boolean;
17
+ completed?: boolean;
18
+ }
19
+ /** Plan waves from HEAD's deliberation output. */
20
+ export declare function planWaves(deliberation: Record<string, unknown>, context?: Record<string, unknown>): Record<string, unknown>;
21
+ /** Decide if the remaining plan is still valid after a wave debrief. */
22
+ export declare function shouldReplan(currentPlan: Record<string, unknown>, newDebrief: Record<string, unknown> | null | undefined): boolean;
23
+ /** Produce a new plan incorporating what was learned. Preserves completed waves. */
24
+ export declare function replan(currentPlan: Record<string, unknown>, waveSummary: Record<string, unknown>, originalDeliberation: Record<string, unknown>): Record<string, unknown>;
25
+ /** Rough cost estimate for a single wave. */
26
+ export declare function estimateWaveCost(wave: Wave): {
27
+ tokens: number;
28
+ time: string;
29
+ };
30
+ export {};