smithers-orchestrator 0.1.18 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/README.md +222 -99
  2. package/bin/cli.ts +93 -45
  3. package/bunfig.toml +2 -4
  4. package/package.json +33 -19
  5. package/preload.ts +6 -66
  6. package/src/commands/cli-utils.test.ts +178 -0
  7. package/src/commands/cli-utils.ts +61 -0
  8. package/src/commands/db/current-view.test.ts +379 -0
  9. package/src/commands/db/current-view.ts +52 -0
  10. package/src/commands/db/executions-view.test.ts +270 -0
  11. package/src/commands/db/executions-view.ts +42 -0
  12. package/src/commands/db/help.test.ts +145 -0
  13. package/src/commands/db/help.ts +16 -0
  14. package/src/commands/db/index.test.ts +118 -0
  15. package/src/commands/db/index.ts +86 -0
  16. package/src/commands/db/memories-view.test.ts +366 -0
  17. package/src/commands/db/memories-view.ts +52 -0
  18. package/src/commands/db/recovery-view.test.ts +279 -0
  19. package/src/commands/db/recovery-view.ts +43 -0
  20. package/src/commands/db/state-view.test.ts +192 -0
  21. package/src/commands/db/state-view.ts +17 -0
  22. package/src/commands/db/stats-view.test.ts +194 -0
  23. package/src/commands/db/stats-view.ts +29 -0
  24. package/src/commands/db/transitions-view.test.ts +243 -0
  25. package/src/commands/db/transitions-view.ts +26 -0
  26. package/src/commands/db/view-utils.ts +39 -0
  27. package/src/commands/db.ts +11 -0
  28. package/src/commands/init.test.ts +263 -0
  29. package/src/commands/init.ts +127 -0
  30. package/src/commands/monitor.test.ts +230 -0
  31. package/src/commands/monitor.ts +167 -0
  32. package/src/commands/run.test.ts +240 -0
  33. package/src/commands/run.ts +84 -0
  34. package/src/commands/test-utils.ts +15 -0
  35. package/src/components/Claude.test.tsx +1932 -11
  36. package/src/components/Claude.tsx +491 -88
  37. package/src/components/ClaudeApi.tsx +7 -4
  38. package/src/components/Constraints.tsx +3 -3
  39. package/src/components/Each.tsx +10 -0
  40. package/src/components/End.test.tsx +421 -0
  41. package/src/components/End.tsx +127 -0
  42. package/src/components/ExecutionContext.tsx +24 -0
  43. package/src/components/ExecutionGate.tsx +20 -0
  44. package/src/components/ExecutionScope.tsx +32 -0
  45. package/src/components/Git/Commit.test.tsx +501 -15
  46. package/src/components/Git/Commit.tsx +63 -29
  47. package/src/components/Git/Notes.test.tsx +511 -16
  48. package/src/components/Git/Notes.tsx +59 -26
  49. package/src/components/Git/index.ts +2 -2
  50. package/src/components/Hooks/OnCIFailure.test.tsx +587 -5
  51. package/src/components/Hooks/OnCIFailure.tsx +89 -64
  52. package/src/components/Hooks/PostCommit.test.tsx +731 -5
  53. package/src/components/Hooks/PostCommit.tsx +77 -38
  54. package/src/components/Hooks/index.ts +2 -2
  55. package/src/components/Human.tsx +50 -3
  56. package/src/components/If.tsx +27 -0
  57. package/src/components/JJ/Commit.test.tsx +164 -5
  58. package/src/components/JJ/Commit.tsx +48 -51
  59. package/src/components/JJ/Describe.test.tsx +96 -5
  60. package/src/components/JJ/Describe.tsx +41 -58
  61. package/src/components/JJ/Rebase.test.tsx +134 -5
  62. package/src/components/JJ/Rebase.tsx +47 -38
  63. package/src/components/JJ/Snapshot.test.tsx +159 -5
  64. package/src/components/JJ/Snapshot.tsx +42 -29
  65. package/src/components/JJ/Status.test.tsx +332 -5
  66. package/src/components/JJ/Status.tsx +47 -35
  67. package/src/components/JJ/index.ts +13 -5
  68. package/src/components/MCP/Sqlite.test.tsx +744 -0
  69. package/src/components/MCP/Sqlite.tsx +3 -3
  70. package/src/components/MCP/index.ts +1 -1
  71. package/src/components/Parallel.test.tsx +743 -0
  72. package/src/components/Parallel.tsx +40 -0
  73. package/src/components/Persona.tsx +4 -4
  74. package/src/components/Phase.test.tsx +827 -0
  75. package/src/components/Phase.tsx +175 -10
  76. package/src/components/PhaseContext.tsx +11 -0
  77. package/src/components/PhaseRegistry.test.tsx +428 -0
  78. package/src/components/PhaseRegistry.tsx +117 -0
  79. package/src/components/Ralph/utils.ts +35 -0
  80. package/src/components/Ralph.test.tsx +732 -21
  81. package/src/components/Ralph.tsx +100 -140
  82. package/src/components/Review/Review.tsx +292 -0
  83. package/src/components/Review/index.ts +2 -0
  84. package/src/components/Review/types.ts +51 -0
  85. package/src/components/Review.test.tsx +388 -4
  86. package/src/components/Review.tsx +3 -324
  87. package/src/components/Smithers.test.tsx +89 -0
  88. package/src/components/Smithers.tsx +395 -0
  89. package/src/components/SmithersProvider.test.ts +422 -0
  90. package/src/components/SmithersProvider.tsx +819 -0
  91. package/src/components/Step.test.tsx +783 -0
  92. package/src/components/Step.tsx +366 -8
  93. package/src/components/StepContext.tsx +11 -0
  94. package/src/components/Stop.tsx +11 -3
  95. package/src/components/Subagent.tsx +3 -3
  96. package/src/components/Task.tsx +3 -3
  97. package/src/components/While.tsx +107 -0
  98. package/src/components/Worktree.test.tsx +243 -0
  99. package/src/components/Worktree.tsx +141 -0
  100. package/src/components/WorktreeProvider.tsx +24 -0
  101. package/src/components/agents/ClaudeCodeCLI.ts +20 -0
  102. package/src/components/agents/SmithersCLI.test.ts +329 -0
  103. package/src/{orchestrator/components → components}/agents/SmithersCLI.ts +15 -6
  104. package/src/components/agents/claude-cli/arg-builder.test.ts +312 -0
  105. package/src/components/agents/claude-cli/arg-builder.ts +101 -0
  106. package/src/components/agents/claude-cli/executor.test.ts +805 -0
  107. package/src/components/agents/claude-cli/executor.ts +369 -0
  108. package/src/components/agents/claude-cli/index.ts +26 -0
  109. package/src/components/agents/claude-cli/message-parser.test.ts +390 -0
  110. package/src/components/agents/claude-cli/message-parser.ts +185 -0
  111. package/src/components/agents/claude-cli/output-parser.test.ts +217 -0
  112. package/src/components/agents/claude-cli/output-parser.ts +184 -0
  113. package/src/components/agents/claude-cli/stop-conditions.test.ts +517 -0
  114. package/src/components/agents/claude-cli/stop-conditions.ts +96 -0
  115. package/src/components/agents/types/agents.ts +251 -0
  116. package/src/components/agents/types/execution.ts +176 -0
  117. package/src/components/agents/types/index.ts +22 -0
  118. package/src/components/agents/types/schema.ts +16 -0
  119. package/src/components/agents/types/tools.ts +19 -0
  120. package/src/components/agents/types.ts +19 -0
  121. package/src/components/components.test.tsx +663 -13
  122. package/src/components/index.ts +77 -16
  123. package/src/core/index.test.ts +123 -0
  124. package/src/core/index.ts +3 -4
  125. package/src/db/agents.test.ts +703 -0
  126. package/src/db/agents.ts +199 -0
  127. package/src/db/artifacts.test.ts +436 -0
  128. package/src/db/artifacts.ts +78 -0
  129. package/src/db/build-state.test.ts +101 -0
  130. package/src/db/build-state.ts +160 -0
  131. package/src/db/execution.test.ts +803 -0
  132. package/src/db/execution.ts +132 -0
  133. package/src/db/human.test.ts +71 -0
  134. package/src/db/human.ts +237 -0
  135. package/src/db/index.test.ts +436 -0
  136. package/src/db/index.ts +316 -0
  137. package/src/db/memories.test.ts +1016 -0
  138. package/src/db/memories.ts +123 -0
  139. package/src/db/phases.test.ts +932 -0
  140. package/src/db/phases.ts +71 -0
  141. package/src/db/query.test.ts +226 -0
  142. package/src/db/query.ts +18 -0
  143. package/src/db/render-frames.test.ts +420 -0
  144. package/src/db/render-frames.ts +149 -0
  145. package/src/{orchestrator/db → db}/schema.sql +254 -97
  146. package/src/db/state.test.ts +667 -0
  147. package/src/db/state.ts +89 -0
  148. package/src/db/steps.test.ts +772 -0
  149. package/src/db/steps.ts +81 -0
  150. package/src/db/tasks.test.ts +600 -0
  151. package/src/db/tasks.ts +151 -0
  152. package/src/db/tools.test.ts +442 -0
  153. package/src/db/tools.ts +89 -0
  154. package/src/{orchestrator/db → db}/types.ts +82 -39
  155. package/src/db/utils.test.ts +191 -0
  156. package/src/db/utils.ts +17 -0
  157. package/src/db/vcs-queue.test.ts +312 -0
  158. package/src/db/vcs-queue.ts +66 -0
  159. package/src/db/vcs.test.ts +569 -0
  160. package/src/db/vcs.ts +344 -0
  161. package/src/debug/index.test.ts +307 -0
  162. package/src/debug/index.ts +230 -2
  163. package/src/hooks/ai-sdk.ts +47 -0
  164. package/src/hooks/index.test.ts +85 -0
  165. package/src/hooks/index.ts +7 -0
  166. package/src/hooks/useCaptureRenderFrame.test.tsx +267 -0
  167. package/src/hooks/useCaptureRenderFrame.ts +29 -0
  168. package/src/hooks/useCommitWithRetry.test.tsx +161 -0
  169. package/src/hooks/useCommitWithRetry.ts +62 -0
  170. package/src/hooks/useHuman.test.ts +138 -0
  171. package/src/hooks/useHuman.test.tsx +159 -0
  172. package/src/hooks/useHuman.ts +115 -0
  173. package/src/hooks/useHumanInteractive.test.ts +446 -0
  174. package/src/hooks/useHumanInteractive.test.tsx +59 -0
  175. package/src/hooks/useHumanInteractive.ts +255 -0
  176. package/src/hooks/useRalphCount.test.tsx +173 -0
  177. package/src/hooks/useRalphCount.ts +20 -0
  178. package/src/index.ts +10 -21
  179. package/src/jsx-runtime.test.ts +43 -206
  180. package/src/jsx-runtime.ts +4 -97
  181. package/src/jsx.d.ts +355 -17
  182. package/src/middleware/caching.ts +96 -0
  183. package/src/middleware/compose.ts +134 -0
  184. package/src/middleware/cost-tracking.ts +34 -0
  185. package/src/middleware/extract-json.ts +42 -0
  186. package/src/middleware/extract-reasoning.ts +41 -0
  187. package/src/middleware/index.ts +32 -0
  188. package/src/middleware/logging.ts +75 -0
  189. package/src/middleware/middleware.test.ts +318 -0
  190. package/src/middleware/rate-limiting.ts +77 -0
  191. package/src/middleware/redact-secrets.ts +38 -0
  192. package/src/middleware/retry.ts +47 -0
  193. package/src/middleware/timeout.ts +36 -0
  194. package/src/middleware/types.ts +39 -0
  195. package/src/middleware/validation.ts +36 -0
  196. package/src/monitor/haiku-summarizer.test.ts +253 -0
  197. package/src/{orchestrator/monitor → monitor}/haiku-summarizer.ts +5 -5
  198. package/src/monitor/index.ts +8 -0
  199. package/src/monitor/log-writer.test.ts +257 -0
  200. package/src/monitor/log-writer.ts +212 -0
  201. package/src/monitor/output-parser.test.ts +424 -0
  202. package/src/{orchestrator/monitor → monitor}/output-parser.ts +4 -4
  203. package/src/monitor/stream-formatter.test.ts +471 -0
  204. package/src/{orchestrator/monitor → monitor}/stream-formatter.ts +11 -11
  205. package/src/rate-limits/index.ts +15 -0
  206. package/src/rate-limits/middleware.test.ts +163 -0
  207. package/src/rate-limits/middleware.ts +28 -0
  208. package/src/rate-limits/monitor.test.ts +38 -0
  209. package/src/rate-limits/monitor.ts +134 -0
  210. package/src/rate-limits/providers/anthropic.test.ts +36 -0
  211. package/src/rate-limits/providers/anthropic.ts +67 -0
  212. package/src/rate-limits/providers/base.ts +1 -0
  213. package/src/rate-limits/providers/openai.test.ts +81 -0
  214. package/src/rate-limits/providers/openai.ts +94 -0
  215. package/src/rate-limits/store.test.ts +139 -0
  216. package/src/rate-limits/store.ts +83 -0
  217. package/src/rate-limits/throttle.test.ts +172 -0
  218. package/src/rate-limits/throttle.ts +66 -0
  219. package/src/rate-limits/types.ts +72 -0
  220. package/src/reactive-sqlite/database.test.ts +787 -0
  221. package/src/reactive-sqlite/database.ts +340 -0
  222. package/src/reactive-sqlite/hooks/context.test.tsx +418 -0
  223. package/src/reactive-sqlite/hooks/context.tsx +79 -0
  224. package/src/reactive-sqlite/hooks/index.ts +12 -0
  225. package/src/reactive-sqlite/hooks/shared.ts +79 -0
  226. package/src/reactive-sqlite/hooks/useMutation.test.tsx +583 -0
  227. package/src/reactive-sqlite/hooks/useMutation.ts +134 -0
  228. package/src/reactive-sqlite/hooks/useQuery.test.tsx +609 -0
  229. package/src/reactive-sqlite/hooks/useQuery.ts +173 -0
  230. package/src/reactive-sqlite/hooks/useQueryOne.test.tsx +419 -0
  231. package/src/reactive-sqlite/hooks/useQueryOne.ts +98 -0
  232. package/src/reactive-sqlite/hooks/useQueryValue.test.tsx +539 -0
  233. package/src/reactive-sqlite/hooks/useQueryValue.ts +95 -0
  234. package/src/reactive-sqlite/hooks.ts +7 -0
  235. package/src/reactive-sqlite/index.ts +58 -0
  236. package/src/reactive-sqlite/parser.test.ts +1330 -0
  237. package/src/reactive-sqlite/parser.ts +263 -0
  238. package/src/reactive-sqlite/row-tracking.test.ts +176 -0
  239. package/src/reactive-sqlite/types.ts +110 -0
  240. package/src/reconciler/README.md +300 -0
  241. package/src/reconciler/hooks-integration.test.tsx +383 -0
  242. package/src/reconciler/hooks.test.tsx +613 -0
  243. package/src/reconciler/hooks.ts +225 -0
  244. package/src/reconciler/host-config.test.ts +568 -0
  245. package/src/reconciler/host-config.ts +319 -0
  246. package/src/reconciler/index.ts +52 -0
  247. package/src/reconciler/jsx-runtime.test.tsx +449 -0
  248. package/src/reconciler/jsx-runtime.ts +51 -0
  249. package/src/reconciler/methods.test.ts +657 -0
  250. package/src/{solid/renderer-methods.ts → reconciler/methods.ts} +32 -8
  251. package/src/reconciler/root.test.tsx +54 -0
  252. package/src/reconciler/root.ts +187 -0
  253. package/src/reconciler/serialize-direct.test.ts +819 -0
  254. package/src/reconciler/serialize.test.ts +679 -0
  255. package/src/{core → reconciler}/serialize.ts +93 -4
  256. package/src/{core → reconciler}/types.ts +9 -7
  257. package/src/streaming/claude-parser.test.ts +207 -0
  258. package/src/streaming/claude-parser.ts +230 -0
  259. package/src/streaming/types.ts +18 -0
  260. package/src/streaming/v3-compat.test.ts +348 -0
  261. package/src/streaming/v3-compat.ts +62 -0
  262. package/src/{orchestrator/tools → tools}/ReportTool.test.ts +128 -73
  263. package/src/{orchestrator/tools → tools}/ReportTool.ts +29 -44
  264. package/src/tools/createSmithersTool.test.ts +75 -0
  265. package/src/tools/createSmithersTool.ts +76 -0
  266. package/src/tools/index.ts +34 -0
  267. package/src/tools/registry.test.ts +556 -0
  268. package/src/{orchestrator/tools → tools}/registry.ts +82 -45
  269. package/src/tools/smithers-mcp-server.test.ts +107 -0
  270. package/src/tools/smithers-mcp-server.ts +23 -0
  271. package/src/tools/tool-to-mcp.test.ts +216 -0
  272. package/src/tools/tool-to-mcp.ts +42 -0
  273. package/src/tools/types.ts +58 -0
  274. package/src/transport/smithers-chat-transport.test.ts +719 -0
  275. package/src/transport/smithers-chat-transport.ts +537 -0
  276. package/src/transport/types.ts +74 -0
  277. package/src/tui/App.test.tsx +356 -0
  278. package/src/tui/App.tsx +127 -0
  279. package/src/tui/README.md +489 -0
  280. package/src/tui/components/index.ts +5 -0
  281. package/src/tui/components/layout/Header.test.tsx +192 -0
  282. package/src/tui/components/layout/Header.tsx +37 -0
  283. package/src/tui/components/layout/StatusBar.test.tsx +211 -0
  284. package/src/tui/components/layout/StatusBar.tsx +45 -0
  285. package/src/tui/components/layout/TabBar.test.tsx +251 -0
  286. package/src/tui/components/layout/TabBar.tsx +49 -0
  287. package/src/tui/components/layout/index.ts +5 -0
  288. package/src/tui/components/shared/ScrollableList.test.tsx +212 -0
  289. package/src/tui/components/shared/ScrollableList.tsx +70 -0
  290. package/src/tui/components/shared/XMLViewer.test.tsx +196 -0
  291. package/src/tui/components/shared/XMLViewer.tsx +50 -0
  292. package/src/tui/components/shared/index.ts +4 -0
  293. package/src/tui/components/views/ChatInterface.test.tsx +33 -0
  294. package/src/tui/components/views/ChatInterface.tsx +131 -0
  295. package/src/tui/components/views/DatabaseExplorer.test.tsx +33 -0
  296. package/src/tui/components/views/DatabaseExplorer.tsx +156 -0
  297. package/src/tui/components/views/ExecutionTimeline.tsx +117 -0
  298. package/src/tui/components/views/HumanInteractionHandler.tsx +204 -0
  299. package/src/tui/components/views/RenderFrameInspector.tsx +110 -0
  300. package/src/tui/components/views/ReportViewer.tsx +158 -0
  301. package/src/tui/components/views/index.ts +8 -0
  302. package/src/tui/hooks/index.ts +9 -0
  303. package/src/tui/hooks/useClaudeChat.test.ts +257 -0
  304. package/src/tui/hooks/useClaudeChat.ts +71 -0
  305. package/src/tui/hooks/useHumanRequests.test.ts +434 -0
  306. package/src/tui/hooks/useHumanRequests.ts +81 -0
  307. package/src/tui/hooks/usePollEvents.test.ts +400 -0
  308. package/src/tui/hooks/usePollEvents.ts +79 -0
  309. package/src/tui/hooks/usePollTableData.test.ts +280 -0
  310. package/src/tui/hooks/usePollTableData.ts +46 -0
  311. package/src/tui/hooks/useRenderFrames.test.ts +449 -0
  312. package/src/tui/hooks/useRenderFrames.ts +75 -0
  313. package/src/tui/hooks/useReportGenerator.test.ts +316 -0
  314. package/src/tui/hooks/useReportGenerator.ts +69 -0
  315. package/src/tui/hooks/useSmithersConnection.test.ts +173 -0
  316. package/src/tui/hooks/useSmithersConnection.ts +102 -0
  317. package/src/tui/index.test.ts +43 -0
  318. package/src/tui/index.tsx +25 -0
  319. package/src/tui/opentui.d.ts +192 -0
  320. package/src/tui/services/claude-assistant.test.ts +56 -0
  321. package/src/tui/services/claude-assistant.ts +95 -0
  322. package/src/tui/services/index.ts +4 -0
  323. package/src/tui/services/report-generator.test.ts +73 -0
  324. package/src/tui/services/report-generator.ts +192 -0
  325. package/src/tui/utils/colors.test.ts +49 -0
  326. package/src/tui/utils/colors.ts +36 -0
  327. package/src/tui/utils/format.test.ts +83 -0
  328. package/src/tui/utils/format.ts +38 -0
  329. package/src/tui/utils/index.ts +4 -0
  330. package/src/utils/capture.test.ts +547 -0
  331. package/src/utils/capture.ts +436 -0
  332. package/src/utils/extract-text.test.ts +161 -0
  333. package/src/utils/extract-text.ts +14 -0
  334. package/src/utils/mcp-config.test.ts +490 -0
  335. package/src/{orchestrator/utils → utils}/mcp-config.ts +11 -9
  336. package/src/utils/scope.test.ts +184 -0
  337. package/src/utils/scope.ts +22 -0
  338. package/src/utils/structured-output/index.ts +14 -0
  339. package/src/utils/structured-output/prompt-generator.test.ts +356 -0
  340. package/src/utils/structured-output/prompt-generator.ts +46 -0
  341. package/src/utils/structured-output/types.ts +20 -0
  342. package/src/utils/structured-output/validator.test.ts +308 -0
  343. package/src/utils/structured-output/validator.ts +84 -0
  344. package/src/utils/structured-output/zod-converter.test.ts +276 -0
  345. package/src/utils/structured-output/zod-converter.ts +126 -0
  346. package/src/{orchestrator/utils → utils}/structured-output.test.ts +1 -1
  347. package/src/utils/structured-output.ts +18 -0
  348. package/src/utils/vcs/git.test.ts +138 -0
  349. package/src/utils/vcs/git.ts +294 -0
  350. package/src/utils/vcs/git.worktree.test.ts +139 -0
  351. package/src/utils/vcs/index.ts +51 -0
  352. package/src/utils/vcs/jj.test.ts +359 -0
  353. package/src/utils/vcs/jj.ts +178 -0
  354. package/src/utils/vcs/parsers.test.ts +441 -0
  355. package/src/utils/vcs/parsers.ts +76 -0
  356. package/src/utils/vcs/types.ts +69 -0
  357. package/src/utils/vcs.test.ts +1 -1
  358. package/src/utils/vcs.ts +2 -339
  359. package/templates/component.tsx.template +104 -0
  360. package/templates/hook.tsx.template +101 -0
  361. package/templates/main.tsx.template +143 -217
  362. package/templates/simple-agent.tsx.template +48 -0
  363. package/bin/cli.js +0 -14269
  364. package/src/core/execute.test.ts +0 -84
  365. package/src/core/execute.ts +0 -72
  366. package/src/core/root.test.ts +0 -83
  367. package/src/core/root.ts +0 -73
  368. package/src/core/serialize-direct.test.ts +0 -323
  369. package/src/core/serialize.test.ts +0 -205
  370. package/src/orchestrator/commands/db.ts +0 -332
  371. package/src/orchestrator/commands/init.ts +0 -86
  372. package/src/orchestrator/commands/monitor.ts +0 -193
  373. package/src/orchestrator/commands/run.ts +0 -95
  374. package/src/orchestrator/components/Claude.tsx +0 -247
  375. package/src/orchestrator/components/Orchestration.tsx +0 -236
  376. package/src/orchestrator/components/Phase.tsx +0 -117
  377. package/src/orchestrator/components/Smithers.tsx +0 -256
  378. package/src/orchestrator/components/SmithersProvider.tsx +0 -204
  379. package/src/orchestrator/components/Step.tsx +0 -173
  380. package/src/orchestrator/components/agents/ClaudeCodeCLI.ts +0 -558
  381. package/src/orchestrator/components/agents/SmithersCLI.test.ts +0 -138
  382. package/src/orchestrator/components/agents/types.ts +0 -449
  383. package/src/orchestrator/components/index.ts +0 -25
  384. package/src/orchestrator/db/execution.ts +0 -711
  385. package/src/orchestrator/db/index.ts +0 -704
  386. package/src/orchestrator/db/live-query.ts +0 -110
  387. package/src/orchestrator/db/memories.ts +0 -272
  388. package/src/orchestrator/db/state.ts +0 -257
  389. package/src/orchestrator/db/vcs.ts +0 -338
  390. package/src/orchestrator/integration.test.ts +0 -325
  391. package/src/orchestrator/monitor/log-writer.ts +0 -78
  392. package/src/orchestrator/monitor/output-parser.test.ts +0 -165
  393. package/src/orchestrator/monitor/stream-formatter.test.ts +0 -224
  394. package/src/orchestrator/tools/index.ts +0 -25
  395. package/src/orchestrator/tools/registry.test.ts +0 -234
  396. package/src/orchestrator/utils/mcp-config.test.ts +0 -143
  397. package/src/orchestrator/utils/structured-output.ts +0 -278
  398. package/src/solid/h.test.ts +0 -163
  399. package/src/solid/h.ts +0 -80
  400. package/src/solid/index.ts +0 -36
  401. package/src/solid/renderer-core.test.ts +0 -195
  402. package/src/solid/renderer.js +0 -141
  403. package/src/solid/renderer.ts +0 -68
  404. package/src/solid/root.ts +0 -89
  405. package/src/solid/simple-renderer.ts +0 -81
package/README.md CHANGED
@@ -18,9 +18,8 @@ I use Smithers for both long-term (weeks) agentic work, as well as one-off scrip
18
18
  ## Table of Contents
19
19
 
20
20
  - [Why](#why)
21
- - [Installation](#installation)
22
- - [Dependencies](#dependencies)
23
- - [Usage](#usage)
21
+ - [Getting Started](#getting-started)
22
+ - [AI SDK React Hooks](#ai-sdk-react-hooks)
24
23
  - [Recipes](#recipes)
25
24
  - [Features](#features)
26
25
  - [Claude Component](#claude-component)
@@ -29,7 +28,11 @@ I use Smithers for both long-term (weeks) agentic work, as well as one-off scrip
29
28
  - [MCP Tool Integration](#mcp-tool-integration)
30
29
  - [Smithers Subagent](#smithers-subagent)
31
30
  - [Git/JJ VCS Integration](#gitjj-vcs-integration)
31
+ - [Orchestration Lifecycle](#orchestration-lifecycle)
32
+ - [PhaseRegistry & Step](#phaseregistry--step)
33
+ - [Parallel Execution](#parallel-execution)
32
34
  - [Database State Management](#database-state-management)
35
+ - [Rate Limit Monitoring](#rate-limit-monitoring)
33
36
  - [Contributing](#contributing)
34
37
 
35
38
  ---
@@ -43,91 +46,66 @@ I wanted a tool that allows me to:
43
46
  - **Persist state across sessions** - pick up where I left off, even days later
44
47
  - **Mix short scripts with long-running workflows** - same syntax for a quick task or a week-long project
45
48
  - **See what my agents are doing** - full observability with database logging and reports
46
- - **Use reactive primitives** - Solid.js signals mean my workflows respond to state changes automatically
49
+ - **Use reactive primitives** - React state means my workflows respond to state changes automatically
47
50
  - **Compose complex behaviors from simple components** - loops, phases, steps, and validation all snap together
48
51
  - **Keep everything in version control** - workflows are just TypeScript files
49
52
 
50
53
  ---
51
54
 
52
- ## Installation
55
+ ## Getting Started
53
56
 
54
- ### Install the Smithers Plugin for Claude Code
57
+ ### Prerequisites
55
58
 
56
- **Step 1:** Add the Smithers marketplace:
57
- ```bash
58
- /plugin marketplace add evmts/smithers
59
- ```
60
-
61
- **Step 2:** Install the plugin:
62
- ```bash
63
- /plugin install smithers@smithers
64
- ```
59
+ - **[Bun](https://bun.sh/)** - JavaScript runtime (v1.0+)
60
+ - **[Claude Code](https://www.npmjs.com/package/@anthropic-ai/claude-code)** - `bun install -g @anthropic-ai/claude-code`
65
61
 
66
- This gives Claude Code the `smithers-orchestrator` skill for creating multi-agent workflows.
62
+ Optional:
63
+ - **[jj (Jujutsu)](https://github.com/martinvonz/jj)** - Alternative VCS with better snapshot support
64
+ - **[Codex CLI](https://github.com/openai/codex)** - Used for post-commit code reviews
67
65
 
68
- ### Optional: Install the npm package for programmatic use
66
+ ### Install into Claude Code
69
67
 
70
- If you want to use Smithers components directly in your own scripts:
68
+ Add to your Claude Code settings (`~/.claude/settings.json`):
71
69
 
72
- ```bash
73
- bun add smithers
70
+ ```json
71
+ {
72
+ "projects": {
73
+ "/path/to/your/project": {
74
+ "mcpServers": {},
75
+ "allowedTools": ["smithers-orchestrator:*"]
76
+ }
77
+ }
78
+ }
74
79
  ```
75
80
 
76
- ---
77
-
78
- ## Dependencies
79
-
80
- ### Required
81
-
82
- - **[Bun](https://bun.sh/)** - JavaScript runtime (v1.0+)
83
- - **[Claude Code](https://www.npmjs.com/package/@anthropic-ai/claude-code)** - `npm install -g @anthropic-ai/claude-code`
84
-
85
- ### Optional
81
+ Then install the package as a dev dependency:
86
82
 
87
- - **[jj (Jujutsu)](https://github.com/martinvonz/jj)** - Alternative VCS with better snapshot support
88
- - **Gemini CLI** - For Gemini model support (coming soon)
89
- - **Codex CLI** - For OpenAI model support (coming soon)
90
-
91
- ---
92
-
93
- ## Usage
83
+ ```bash
84
+ bun add -d smithers-orchestrator
85
+ ```
94
86
 
95
- ### Let Your Agent Write Smithers
87
+ ### Use It
96
88
 
97
- **You don't have to write Smithers yourself.** Tell your agent what you want, and it generates the workflow:
89
+ **You don't have to write Smithers yourself.** Tell Claude what you want:
98
90
 
99
91
  ```
100
- User: "Create a workflow that monitors my CI, fixes failures automatically, and escalates after 3 failed attempts"
92
+ User: "Create a workflow that monitors my CI, fixes failures automatically,
93
+ and escalates after 3 failed attempts"
101
94
 
102
95
  Claude: *generates ci-recovery.tsx*
103
96
  ```
104
97
 
105
- Your agent understands the component model and generates correct, working orchestration scripts.
98
+ Claude understands the component model and generates correct, working orchestration scripts.
106
99
 
107
- ### State Persistence
108
-
109
- All Smithers state is saved in a **PGlite database** on your system that can be easily inspected:
110
-
111
- ```bash
112
- # View execution history
113
- smithers-orchestrator db executions
114
-
115
- # View state for a specific execution
116
- smithers-orchestrator db state --execution-id abc123
117
-
118
- # Query the database directly
119
- smithers-orchestrator db query "SELECT * FROM agents ORDER BY started_at DESC LIMIT 10"
120
- ```
121
-
122
- ### Basic Example
100
+ ### Run a Workflow
123
101
 
124
102
  ```tsx
125
103
  #!/usr/bin/env bun
126
104
 
127
- import { createSmithersRoot } from "smithers";
128
- import { createSmithersDB } from "smithers/smithers-orchestrator/src/db";
129
- import { SmithersProvider } from "smithers/smithers-orchestrator/src/components/SmithersProvider";
130
- import { Claude } from "smithers/smithers-orchestrator/src/components/Claude";
105
+ import { createSmithersRoot } from "smithers-orchestrator";
106
+ import { createSmithersDB } from "smithers-orchestrator/db";
107
+ import { SmithersProvider } from "smithers-orchestrator/components/SmithersProvider";
108
+ import { Claude } from "smithers-orchestrator/components/Claude";
131
109
 
132
110
  const db = await createSmithersDB({ path: ".smithers/my-task" });
133
111
  const executionId = await db.execution.start("My Task", "scripts/my-task.tsx");
@@ -151,12 +129,54 @@ await root.mount(MyWorkflow);
151
129
  await db.close();
152
130
  ```
153
131
 
154
- Run it:
155
-
156
132
  ```bash
157
133
  bun my-workflow.tsx
158
134
  ```
159
135
 
136
+ ### Inspect State
137
+
138
+ All state persists in SQLite:
139
+
140
+ ```bash
141
+ smithers db executions # View execution history
142
+ smithers db state --execution-id abc123 # View specific execution state
143
+ ```
144
+
145
+ ---
146
+
147
+ ## AI SDK React Hooks
148
+
149
+ Smithers re-exports the Vercel AI SDK React hooks so you can import everything
150
+ from a single package:
151
+
152
+ ```tsx
153
+ import { useChat, useCompletion, useSmithers } from "smithers-orchestrator";
154
+
155
+ function ChatUI() {
156
+ const { messages, sendMessage, status } = useChat({ api: "/api/chat" });
157
+ const { db } = useSmithers();
158
+
159
+ return (
160
+ <div>
161
+ <p>Status: {status}</p>
162
+ {messages.map((message) => (
163
+ <div key={message.id}>{message.content}</div>
164
+ ))}
165
+ <button onClick={() => sendMessage({ role: "user", content: "Hi" })}>
166
+ Send
167
+ </button>
168
+ </div>
169
+ );
170
+ }
171
+ ```
172
+
173
+ You can also import directly from the hooks subpath:
174
+
175
+ ```tsx
176
+ import { useChat } from "smithers-orchestrator/hooks";
177
+ import { useChat as useAiChat } from "smithers-orchestrator/hooks/ai-sdk";
178
+ ```
179
+
160
180
  ---
161
181
 
162
182
  ## Recipes
@@ -168,40 +188,38 @@ async function ReviewWorkflow() {
168
188
  const phase = (await db.state.get("phase")) ?? "implement";
169
189
 
170
190
  return (
171
- <SmithersProvider db={db} executionId={executionId}>
191
+ <SmithersProvider db={db} executionId={executionId} maxIterations={10}>
172
192
  <Orchestration globalTimeout={3600000}>
173
- <Ralph maxIterations={10}>
174
- {phase === "implement" && (
175
- <Phase name="Implementation">
176
- <Claude
177
- model="sonnet"
178
- onFinished={() => db.state.set("phase", "review")}
179
- >
180
- Implement the user authentication feature.
181
- </Claude>
182
- </Phase>
183
- )}
184
-
185
- {phase === "review" && (
186
- <Phase name="Code Review">
187
- <Review
188
- target={{ type: "diff", ref: "main" }}
189
- criteria={[
190
- "No security vulnerabilities",
191
- "Tests cover edge cases",
192
- "Types are properly defined",
193
- ]}
194
- onFinished={(review) => {
195
- if (review.approved) {
196
- db.state.set("phase", "complete");
197
- } else {
198
- db.state.set("phase", "implement");
199
- }
200
- }}
201
- />
202
- </Phase>
203
- )}
204
- </Ralph>
193
+ {phase === "implement" && (
194
+ <Phase name="Implementation">
195
+ <Claude
196
+ model="sonnet"
197
+ onFinished={() => db.state.set("phase", "review")}
198
+ >
199
+ Implement the user authentication feature.
200
+ </Claude>
201
+ </Phase>
202
+ )}
203
+
204
+ {phase === "review" && (
205
+ <Phase name="Code Review">
206
+ <Review
207
+ target={{ type: "diff", ref: "main" }}
208
+ criteria={[
209
+ "No security vulnerabilities",
210
+ "Tests cover edge cases",
211
+ "Types are properly defined",
212
+ ]}
213
+ onFinished={(review) => {
214
+ if (review.approved) {
215
+ db.state.set("phase", "complete");
216
+ } else {
217
+ db.state.set("phase", "implement");
218
+ }
219
+ }}
220
+ />
221
+ </Phase>
222
+ )}
205
223
  </Orchestration>
206
224
  </SmithersProvider>
207
225
  );
@@ -293,10 +311,12 @@ The core agent component that executes Claude with full tool access:
293
311
 
294
312
  ### Ralph Loop Controller
295
313
 
314
+ > **Prefer SmithersProvider.** The loop functionality is built into `<SmithersProvider>` with `maxIterations`. Use `<Ralph>` only for nested loops within a workflow.
315
+
296
316
  Named after Ralph Wiggum's "I'm in danger" catchphrase - controls iterative loops that could run away:
297
317
 
298
318
  ```tsx
299
- <Ralph maxIterations={10} onMaxIterations={() => console.log("I'm in danger!")}>
319
+ <SmithersProvider db={db} executionId={executionId} maxIterations={10}>
300
320
  {/* Children re-render on each iteration */}
301
321
  <Claude
302
322
  onFinished={() => {
@@ -305,7 +325,7 @@ Named after Ralph Wiggum's "I'm in danger" catchphrase - controls iterative loop
305
325
  >
306
326
  Keep improving until tests pass.
307
327
  </Claude>
308
- </Ralph>
328
+ </SmithersProvider>
309
329
  ```
310
330
 
311
331
  ### Structured Output with Zod
@@ -337,6 +357,37 @@ Give Claude access to external tools via Model Context Protocol:
337
357
  </Claude>
338
358
  ```
339
359
 
360
+ ### AI SDK Tool Format
361
+
362
+ Define tools with Zod schemas and pass them to Claude:
363
+
364
+ ```tsx
365
+ import { z } from "zod";
366
+ import { createSmithersTool } from "smithers-orchestrator/tools";
367
+
368
+ const reportTool = createSmithersTool({
369
+ name: "report",
370
+ description: "Report progress to the orchestrator",
371
+ inputSchema: z.object({
372
+ message: z.string(),
373
+ severity: z.enum(["info", "warning", "error"]).optional(),
374
+ }),
375
+ execute: async ({ message, severity }, { db }) => {
376
+ await db.vcs.addReport({
377
+ type: "progress",
378
+ title: "Agent Report",
379
+ content: message,
380
+ severity: severity ?? "info",
381
+ });
382
+ return { success: true };
383
+ },
384
+ });
385
+
386
+ <Claude tools={[reportTool]}>
387
+ Report progress as you go.
388
+ </Claude>
389
+ ```
390
+
340
391
  ### Smithers Subagent
341
392
 
342
393
  Spawn a new Smithers instance to plan and execute complex subtasks:
@@ -353,6 +404,16 @@ Spawn a new Smithers instance to plan and execute complex subtasks:
353
404
  </Smithers>
354
405
  ```
355
406
 
407
+ ### Worktree
408
+
409
+ Run agents in isolated git worktrees:
410
+
411
+ ```tsx
412
+ <Worktree branch="feature-auth" cleanup>
413
+ <Claude>Implement user authentication</Claude>
414
+ </Worktree>
415
+ ```
416
+
356
417
  ### Git/JJ VCS Integration
357
418
 
358
419
  First-class version control support:
@@ -366,6 +427,52 @@ First-class version control support:
366
427
  <Commit autoDescribe />
367
428
  ```
368
429
 
430
+ ### Orchestration Lifecycle
431
+
432
+ Global timeout and completion logic for workflows:
433
+
434
+ ```tsx
435
+ <Orchestration
436
+ globalTimeout={3600000} // 1 hour max
437
+ onComplete={() => console.log("Workflow finished")}
438
+ onTimeout={() => console.log("Workflow timed out")}
439
+ >
440
+ {/* Your workflow components */}
441
+ </Orchestration>
442
+ ```
443
+
444
+ ### PhaseRegistry & Step
445
+
446
+ Manage multi-phase sequential execution:
447
+
448
+ ```tsx
449
+ <PhaseRegistry>
450
+ <Phase name="implement">
451
+ <Step name="write-code" snapshotBefore commitAfter commitMessage="feat: Implementation">
452
+ <Claude>Implement the feature</Claude>
453
+ </Step>
454
+ <Step name="write-tests">
455
+ <Claude>Write tests for the implementation</Claude>
456
+ </Step>
457
+ </Phase>
458
+ <Phase name="review">
459
+ <Review target={{ type: "diff", ref: "main" }} />
460
+ </Phase>
461
+ </PhaseRegistry>
462
+ ```
463
+
464
+ ### Parallel Execution
465
+
466
+ Run multiple agents concurrently within a step:
467
+
468
+ ```tsx
469
+ <Parallel>
470
+ <Claude model="haiku">Quick task 1</Claude>
471
+ <Claude model="haiku">Quick task 2</Claude>
472
+ <Claude model="haiku">Quick task 3</Claude>
473
+ </Parallel>
474
+ ```
475
+
369
476
  ### Database State Management
370
477
 
371
478
  Persistent state that survives restarts:
@@ -384,6 +491,22 @@ const history = await db.state.getHistory("phase");
384
491
  const all = await db.state.getAll();
385
492
  ```
386
493
 
494
+ ### Rate Limit Monitoring
495
+
496
+ Track provider rate limit headroom and execution-scoped token usage:
497
+
498
+ ```typescript
499
+ import { createRateLimitMonitor } from "smithers-orchestrator/rate-limits";
500
+
501
+ const monitor = createRateLimitMonitor({
502
+ anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! },
503
+ db,
504
+ });
505
+
506
+ const status = await monitor.getStatus("anthropic", "claude-sonnet-4");
507
+ const usage = await monitor.getUsage(executionId);
508
+ ```
509
+
387
510
  ---
388
511
 
389
512
  ## Contributing
@@ -398,4 +521,4 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
398
521
 
399
522
  ---
400
523
 
401
- **Built with Solid.js, powered by Claude.**
524
+ **Built with React, powered by Claude.**
package/bin/cli.ts CHANGED
@@ -1,69 +1,117 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { Command } from 'commander'
4
- import { init } from '../src/orchestrator/commands/init.ts'
5
- import { run } from '../src/orchestrator/commands/run.ts'
6
- import { monitor } from '../src/orchestrator/commands/monitor.ts'
7
- import { dbCommand } from '../src/orchestrator/commands/db.ts'
3
+ import { Command } from "commander";
4
+ import { init } from "../src/commands/init.ts";
5
+ import { run } from "../src/commands/run.ts";
6
+ import { monitor } from "../src/commands/monitor.ts";
7
+ import { dbCommand } from "../src/commands/db.ts";
8
+ import { launchTUI } from "../src/tui/index.tsx";
9
+ import { DEFAULT_DB_DIR, DEFAULT_MAIN_FILE, resolveDbPaths } from "../src/commands/cli-utils.ts";
8
10
 
9
- const program = new Command()
11
+ const program = new Command();
10
12
 
11
13
  program
12
- .name('smithers')
13
- .description('CLI tool for multi-agent AI orchestration with Smithers framework')
14
- .version('0.1.0')
14
+ .name("smithers")
15
+ .description(
16
+ "CLI tool for multi-agent AI orchestration with Smithers framework",
17
+ )
18
+ .version("0.1.0");
15
19
 
16
20
  program
17
- .command('init')
18
- .description('Create a new Smithers orchestration in .smithers/')
19
- .option('-d, --dir <directory>', 'Directory to create .smithers in', process.cwd())
20
- .action(init)
21
+ .command("init")
22
+ .description("Create a new Smithers orchestration in .smithers/")
23
+ .option(
24
+ "-d, --dir <directory>",
25
+ "Directory to create .smithers in",
26
+ process.cwd(),
27
+ )
28
+ .action(init);
21
29
 
22
30
  program
23
- .command('run [file]')
24
- .description('Run a Smithers orchestration file')
25
- .option('-f, --file <file>', 'Orchestration file to run', '.smithers/main.tsx')
26
- .action(run)
31
+ .command("run [file]")
32
+ .description("Run a Smithers orchestration file (default: .smithers/main.tsx)")
33
+ .action((file?: string) => run(file));
27
34
 
28
35
  program
29
- .command('monitor [file]')
30
- .description('Run with LLM-friendly monitoring (recommended)')
31
- .option('-f, --file <file>', 'Orchestration file to monitor', '.smithers/main.tsx')
32
- .option('--no-summary', 'Disable Haiku summarization')
33
- .action(monitor)
36
+ .command("monitor [file]")
37
+ .description("Run with LLM-friendly monitoring (recommended)")
38
+ .option(
39
+ "-f, --file <file>",
40
+ "Orchestration file to monitor",
41
+ DEFAULT_MAIN_FILE,
42
+ )
43
+ .option("--no-summary", "Disable Haiku summarization")
44
+ .action(monitor);
34
45
 
35
46
  program
36
- .command('db [subcommand]')
37
- .description('Inspect and manage the PGlite database')
38
- .option('--path <path>', 'Database path', '.smithers/data')
39
- .action(dbCommand)
47
+ .command("db [subcommand]")
48
+ .description("Inspect and manage the SQLite database")
49
+ .option("--path <path>", "Database path", DEFAULT_DB_DIR)
50
+ .action(dbCommand);
40
51
 
41
- // Hook trigger command - called by git hooks to notify orchestration
42
52
  program
43
- .command('hook-trigger <type> <data>')
44
- .description('Trigger a hook event (used by git hooks)')
45
- .option('--path <path>', 'Database path', '.smithers/data')
53
+ .command("tui")
54
+ .description("Launch observability TUI dashboard")
55
+ .option("-p, --path <path>", "Database path", ".smithers/data")
56
+ .action(async (options: { path: string }) => {
57
+ try {
58
+ await launchTUI({ dbPath: options.path });
59
+ } catch (error) {
60
+ console.error('❌ Failed to launch TUI:', error instanceof Error ? error.message : error);
61
+ if (!process.stdout.isTTY) {
62
+ console.error(' TUI requires an interactive terminal');
63
+ }
64
+ process.exit(1);
65
+ }
66
+ });
67
+
68
+ const VALID_HOOK_TYPES = ['pre-commit', 'post-commit', 'pre-push', 'post-merge'] as const
69
+
70
+ program
71
+ .command("hook-trigger <type> <data>")
72
+ .description("Trigger a hook event (used by git hooks). Data must be valid JSON.")
73
+ .option("--path <path>", "Database path", DEFAULT_DB_DIR)
46
74
  .action(async (type: string, data: string, options: { path: string }) => {
75
+ if (!VALID_HOOK_TYPES.includes(type as typeof VALID_HOOK_TYPES[number])) {
76
+ console.error(`❌ Invalid hook type: ${type}`)
77
+ console.error(` Valid types: ${VALID_HOOK_TYPES.join(', ')}`)
78
+ process.exit(1)
79
+ }
80
+
81
+ let parsedData: unknown
47
82
  try {
48
- // Dynamically import to avoid loading DB on every CLI call
49
- const { createSmithersDB } = await import('../src/orchestrator/db/index.ts')
83
+ parsedData = JSON.parse(data)
84
+ } catch {
85
+ console.error(`❌ Invalid JSON data: ${data}`)
86
+ console.error(' Data must be valid JSON')
87
+ process.exit(1)
88
+ }
50
89
 
51
- const db = await createSmithersDB({ path: options.path })
90
+ try {
91
+ const { createSmithersDB } = await import(
92
+ "../src/db/index.ts"
93
+ );
94
+
95
+ const { dbFile } = resolveDbPaths(options.path);
96
+ const db = createSmithersDB({ path: dbFile });
52
97
 
53
- // Store the trigger in state
54
- await db.state.set('last_hook_trigger', {
55
- type,
56
- data,
57
- timestamp: Date.now(),
58
- })
98
+ db.state.set(
99
+ "last_hook_trigger",
100
+ {
101
+ type,
102
+ data: parsedData,
103
+ timestamp: Date.now(),
104
+ },
105
+ "hook-trigger",
106
+ );
59
107
 
60
- await db.close()
108
+ db.close();
61
109
 
62
- console.log(`[Hook] Triggered: ${type} with ${data}`)
110
+ console.log(`[Hook] Triggered: ${type}`);
63
111
  } catch (error) {
64
- console.error('[Hook] Error:', error)
65
- process.exit(1)
112
+ console.error("[Hook] Error:", error);
113
+ process.exit(1);
66
114
  }
67
- })
115
+ });
68
116
 
69
- program.parse(process.argv)
117
+ program.parse(process.argv);
package/bunfig.toml CHANGED
@@ -1,11 +1,9 @@
1
1
  # Bun configuration for Smithers
2
2
  # https://bun.sh/docs/runtime/bunfig
3
3
 
4
- # Use bun-plugin-solid for Solid JSX transform
5
- preload = ["./preload.ts"]
6
-
7
4
  [install]
8
5
  auto = "fallback"
9
6
 
10
7
  [test]
11
- preload = ["./preload.ts", "./test/preload.ts"]
8
+ preload = ["./test/preload.ts"]
9
+ exclude = ["**/reference/**", "**/node_modules/**"]