zerg-ztc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) hide show
  1. package/README.md +361 -0
  2. package/dist/App.d.ts +4 -0
  3. package/dist/App.d.ts.map +1 -0
  4. package/dist/App.js +499 -0
  5. package/dist/App.js.map +1 -0
  6. package/dist/agent/agent.d.ts +54 -0
  7. package/dist/agent/agent.d.ts.map +1 -0
  8. package/dist/agent/agent.js +347 -0
  9. package/dist/agent/agent.js.map +1 -0
  10. package/dist/agent/backends/anthropic.d.ts +13 -0
  11. package/dist/agent/backends/anthropic.d.ts.map +1 -0
  12. package/dist/agent/backends/anthropic.js +54 -0
  13. package/dist/agent/backends/anthropic.js.map +1 -0
  14. package/dist/agent/backends/gemini.d.ts +13 -0
  15. package/dist/agent/backends/gemini.d.ts.map +1 -0
  16. package/dist/agent/backends/gemini.js +71 -0
  17. package/dist/agent/backends/gemini.js.map +1 -0
  18. package/dist/agent/backends/inception.d.ts +12 -0
  19. package/dist/agent/backends/inception.d.ts.map +1 -0
  20. package/dist/agent/backends/inception.js +15 -0
  21. package/dist/agent/backends/inception.js.map +1 -0
  22. package/dist/agent/backends/index.d.ts +7 -0
  23. package/dist/agent/backends/index.d.ts.map +1 -0
  24. package/dist/agent/backends/index.js +6 -0
  25. package/dist/agent/backends/index.js.map +1 -0
  26. package/dist/agent/backends/openai.d.ts +12 -0
  27. package/dist/agent/backends/openai.d.ts.map +1 -0
  28. package/dist/agent/backends/openai.js +15 -0
  29. package/dist/agent/backends/openai.js.map +1 -0
  30. package/dist/agent/backends/openai_compatible.d.ts +17 -0
  31. package/dist/agent/backends/openai_compatible.d.ts.map +1 -0
  32. package/dist/agent/backends/openai_compatible.js +95 -0
  33. package/dist/agent/backends/openai_compatible.js.map +1 -0
  34. package/dist/agent/backends/types.d.ts +49 -0
  35. package/dist/agent/backends/types.d.ts.map +1 -0
  36. package/dist/agent/backends/types.js +2 -0
  37. package/dist/agent/backends/types.js.map +1 -0
  38. package/dist/agent/commands/clipboard.d.ts +3 -0
  39. package/dist/agent/commands/clipboard.d.ts.map +1 -0
  40. package/dist/agent/commands/clipboard.js +72 -0
  41. package/dist/agent/commands/clipboard.js.map +1 -0
  42. package/dist/agent/commands/config.d.ts +3 -0
  43. package/dist/agent/commands/config.d.ts.map +1 -0
  44. package/dist/agent/commands/config.js +120 -0
  45. package/dist/agent/commands/config.js.map +1 -0
  46. package/dist/agent/commands/debug.d.ts +3 -0
  47. package/dist/agent/commands/debug.d.ts.map +1 -0
  48. package/dist/agent/commands/debug.js +23 -0
  49. package/dist/agent/commands/debug.js.map +1 -0
  50. package/dist/agent/commands/emulation.d.ts +3 -0
  51. package/dist/agent/commands/emulation.d.ts.map +1 -0
  52. package/dist/agent/commands/emulation.js +78 -0
  53. package/dist/agent/commands/emulation.js.map +1 -0
  54. package/dist/agent/commands/execution.d.ts +3 -0
  55. package/dist/agent/commands/execution.d.ts.map +1 -0
  56. package/dist/agent/commands/execution.js +8 -0
  57. package/dist/agent/commands/execution.js.map +1 -0
  58. package/dist/agent/commands/help.d.ts +3 -0
  59. package/dist/agent/commands/help.d.ts.map +1 -0
  60. package/dist/agent/commands/help.js +19 -0
  61. package/dist/agent/commands/help.js.map +1 -0
  62. package/dist/agent/commands/history.d.ts +3 -0
  63. package/dist/agent/commands/history.d.ts.map +1 -0
  64. package/dist/agent/commands/history.js +12 -0
  65. package/dist/agent/commands/history.js.map +1 -0
  66. package/dist/agent/commands/index.d.ts +4 -0
  67. package/dist/agent/commands/index.d.ts.map +1 -0
  68. package/dist/agent/commands/index.js +19 -0
  69. package/dist/agent/commands/index.js.map +1 -0
  70. package/dist/agent/commands/model.d.ts +3 -0
  71. package/dist/agent/commands/model.d.ts.map +1 -0
  72. package/dist/agent/commands/model.js +10 -0
  73. package/dist/agent/commands/model.js.map +1 -0
  74. package/dist/agent/commands/models.d.ts +3 -0
  75. package/dist/agent/commands/models.d.ts.map +1 -0
  76. package/dist/agent/commands/models.js +110 -0
  77. package/dist/agent/commands/models.js.map +1 -0
  78. package/dist/agent/commands/permissions.d.ts +3 -0
  79. package/dist/agent/commands/permissions.d.ts.map +1 -0
  80. package/dist/agent/commands/permissions.js +58 -0
  81. package/dist/agent/commands/permissions.js.map +1 -0
  82. package/dist/agent/commands/retry.d.ts +3 -0
  83. package/dist/agent/commands/retry.d.ts.map +1 -0
  84. package/dist/agent/commands/retry.js +8 -0
  85. package/dist/agent/commands/retry.js.map +1 -0
  86. package/dist/agent/commands/shell.d.ts +4 -0
  87. package/dist/agent/commands/shell.d.ts.map +1 -0
  88. package/dist/agent/commands/shell.js +66 -0
  89. package/dist/agent/commands/shell.js.map +1 -0
  90. package/dist/agent/commands/skills.d.ts +3 -0
  91. package/dist/agent/commands/skills.d.ts.map +1 -0
  92. package/dist/agent/commands/skills.js +50 -0
  93. package/dist/agent/commands/skills.js.map +1 -0
  94. package/dist/agent/commands/status.d.ts +3 -0
  95. package/dist/agent/commands/status.d.ts.map +1 -0
  96. package/dist/agent/commands/status.js +18 -0
  97. package/dist/agent/commands/status.js.map +1 -0
  98. package/dist/agent/commands/types.d.ts +70 -0
  99. package/dist/agent/commands/types.d.ts.map +1 -0
  100. package/dist/agent/commands/types.js +2 -0
  101. package/dist/agent/commands/types.js.map +1 -0
  102. package/dist/agent/factory.d.ts +13 -0
  103. package/dist/agent/factory.d.ts.map +1 -0
  104. package/dist/agent/factory.js +46 -0
  105. package/dist/agent/factory.js.map +1 -0
  106. package/dist/agent/index.d.ts +14 -0
  107. package/dist/agent/index.d.ts.map +1 -0
  108. package/dist/agent/index.js +10 -0
  109. package/dist/agent/index.js.map +1 -0
  110. package/dist/agent/runtime/capabilities.d.ts +7 -0
  111. package/dist/agent/runtime/capabilities.d.ts.map +1 -0
  112. package/dist/agent/runtime/capabilities.js +8 -0
  113. package/dist/agent/runtime/capabilities.js.map +1 -0
  114. package/dist/agent/runtime/memory.d.ts +13 -0
  115. package/dist/agent/runtime/memory.d.ts.map +1 -0
  116. package/dist/agent/runtime/memory.js +13 -0
  117. package/dist/agent/runtime/memory.js.map +1 -0
  118. package/dist/agent/runtime/policy.d.ts +22 -0
  119. package/dist/agent/runtime/policy.d.ts.map +1 -0
  120. package/dist/agent/runtime/policy.js +29 -0
  121. package/dist/agent/runtime/policy.js.map +1 -0
  122. package/dist/agent/runtime/session.d.ts +11 -0
  123. package/dist/agent/runtime/session.d.ts.map +1 -0
  124. package/dist/agent/runtime/session.js +10 -0
  125. package/dist/agent/runtime/session.js.map +1 -0
  126. package/dist/agent/runtime/tracing.d.ts +13 -0
  127. package/dist/agent/runtime/tracing.d.ts.map +1 -0
  128. package/dist/agent/runtime/tracing.js +6 -0
  129. package/dist/agent/runtime/tracing.js.map +1 -0
  130. package/dist/agent/tools/file.d.ts +5 -0
  131. package/dist/agent/tools/file.d.ts.map +1 -0
  132. package/dist/agent/tools/file.js +162 -0
  133. package/dist/agent/tools/file.js.map +1 -0
  134. package/dist/agent/tools/index.d.ts +13 -0
  135. package/dist/agent/tools/index.d.ts.map +1 -0
  136. package/dist/agent/tools/index.js +34 -0
  137. package/dist/agent/tools/index.js.map +1 -0
  138. package/dist/agent/tools/search.d.ts +3 -0
  139. package/dist/agent/tools/search.d.ts.map +1 -0
  140. package/dist/agent/tools/search.js +124 -0
  141. package/dist/agent/tools/search.js.map +1 -0
  142. package/dist/agent/tools/shell.d.ts +3 -0
  143. package/dist/agent/tools/shell.d.ts.map +1 -0
  144. package/dist/agent/tools/shell.js +60 -0
  145. package/dist/agent/tools/shell.js.map +1 -0
  146. package/dist/agent/tools/skills.d.ts +3 -0
  147. package/dist/agent/tools/skills.d.ts.map +1 -0
  148. package/dist/agent/tools/skills.js +27 -0
  149. package/dist/agent/tools/skills.js.map +1 -0
  150. package/dist/agent/tools/types.d.ts +8 -0
  151. package/dist/agent/tools/types.d.ts.map +1 -0
  152. package/dist/agent/tools/types.js +2 -0
  153. package/dist/agent/tools/types.js.map +1 -0
  154. package/dist/agent/tools/zerg.d.ts +3 -0
  155. package/dist/agent/tools/zerg.d.ts.map +1 -0
  156. package/dist/agent/tools/zerg.js +47 -0
  157. package/dist/agent/tools/zerg.js.map +1 -0
  158. package/dist/cli.d.ts +3 -0
  159. package/dist/cli.d.ts.map +1 -0
  160. package/dist/cli.js +75 -0
  161. package/dist/cli.js.map +1 -0
  162. package/dist/components/FullScreen.d.ts +28 -0
  163. package/dist/components/FullScreen.d.ts.map +1 -0
  164. package/dist/components/FullScreen.js +40 -0
  165. package/dist/components/FullScreen.js.map +1 -0
  166. package/dist/components/Header.d.ts +10 -0
  167. package/dist/components/Header.d.ts.map +1 -0
  168. package/dist/components/Header.js +14 -0
  169. package/dist/components/Header.js.map +1 -0
  170. package/dist/components/InputArea.d.ts +24 -0
  171. package/dist/components/InputArea.d.ts.map +1 -0
  172. package/dist/components/InputArea.js +476 -0
  173. package/dist/components/InputArea.js.map +1 -0
  174. package/dist/components/MessageList.d.ts +12 -0
  175. package/dist/components/MessageList.d.ts.map +1 -0
  176. package/dist/components/MessageList.js +9 -0
  177. package/dist/components/MessageList.js.map +1 -0
  178. package/dist/components/StatusBar.d.ts +18 -0
  179. package/dist/components/StatusBar.d.ts.map +1 -0
  180. package/dist/components/StatusBar.js +21 -0
  181. package/dist/components/StatusBar.js.map +1 -0
  182. package/dist/components/index.d.ts +6 -0
  183. package/dist/components/index.d.ts.map +1 -0
  184. package/dist/components/index.js +7 -0
  185. package/dist/components/index.js.map +1 -0
  186. package/dist/config/types.d.ts +12 -0
  187. package/dist/config/types.d.ts.map +1 -0
  188. package/dist/config/types.js +2 -0
  189. package/dist/config/types.js.map +1 -0
  190. package/dist/config.d.ts +28 -0
  191. package/dist/config.d.ts.map +1 -0
  192. package/dist/config.js +155 -0
  193. package/dist/config.js.map +1 -0
  194. package/dist/debug/logger.d.ts +2 -0
  195. package/dist/debug/logger.d.ts.map +1 -0
  196. package/dist/debug/logger.js +15 -0
  197. package/dist/debug/logger.js.map +1 -0
  198. package/dist/emulation/catalog.d.ts +4 -0
  199. package/dist/emulation/catalog.d.ts.map +1 -0
  200. package/dist/emulation/catalog.js +68 -0
  201. package/dist/emulation/catalog.js.map +1 -0
  202. package/dist/emulation/trace_style.d.ts +3 -0
  203. package/dist/emulation/trace_style.d.ts.map +1 -0
  204. package/dist/emulation/trace_style.js +10 -0
  205. package/dist/emulation/trace_style.js.map +1 -0
  206. package/dist/emulation/types.d.ts +8 -0
  207. package/dist/emulation/types.d.ts.map +1 -0
  208. package/dist/emulation/types.js +2 -0
  209. package/dist/emulation/types.js.map +1 -0
  210. package/dist/skills/index.d.ts +5 -0
  211. package/dist/skills/index.d.ts.map +1 -0
  212. package/dist/skills/index.js +36 -0
  213. package/dist/skills/index.js.map +1 -0
  214. package/dist/skills/loader.d.ts +3 -0
  215. package/dist/skills/loader.d.ts.map +1 -0
  216. package/dist/skills/loader.js +137 -0
  217. package/dist/skills/loader.js.map +1 -0
  218. package/dist/skills/registry.d.ts +3 -0
  219. package/dist/skills/registry.d.ts.map +1 -0
  220. package/dist/skills/registry.js +5 -0
  221. package/dist/skills/registry.js.map +1 -0
  222. package/dist/skills/types.d.ts +11 -0
  223. package/dist/skills/types.d.ts.map +1 -0
  224. package/dist/skills/types.js +2 -0
  225. package/dist/skills/types.js.map +1 -0
  226. package/dist/types.d.ts +93 -0
  227. package/dist/types.d.ts.map +1 -0
  228. package/dist/types.js +5 -0
  229. package/dist/types.js.map +1 -0
  230. package/dist/ui/core/factory.d.ts +4 -0
  231. package/dist/ui/core/factory.d.ts.map +1 -0
  232. package/dist/ui/core/factory.js +7 -0
  233. package/dist/ui/core/factory.js.map +1 -0
  234. package/dist/ui/core/index.d.ts +5 -0
  235. package/dist/ui/core/index.d.ts.map +1 -0
  236. package/dist/ui/core/index.js +4 -0
  237. package/dist/ui/core/index.js.map +1 -0
  238. package/dist/ui/core/input.d.ts +22 -0
  239. package/dist/ui/core/input.d.ts.map +1 -0
  240. package/dist/ui/core/input.js +15 -0
  241. package/dist/ui/core/input.js.map +1 -0
  242. package/dist/ui/core/input_segments.d.ts +19 -0
  243. package/dist/ui/core/input_segments.d.ts.map +1 -0
  244. package/dist/ui/core/input_segments.js +367 -0
  245. package/dist/ui/core/input_segments.js.map +1 -0
  246. package/dist/ui/core/input_state.d.ts +24 -0
  247. package/dist/ui/core/input_state.d.ts.map +1 -0
  248. package/dist/ui/core/input_state.js +2 -0
  249. package/dist/ui/core/input_state.js.map +1 -0
  250. package/dist/ui/core/layout_yoga.d.ts +11 -0
  251. package/dist/ui/core/layout_yoga.d.ts.map +1 -0
  252. package/dist/ui/core/layout_yoga.js +102 -0
  253. package/dist/ui/core/layout_yoga.js.map +1 -0
  254. package/dist/ui/core/style.d.ts +3 -0
  255. package/dist/ui/core/style.d.ts.map +1 -0
  256. package/dist/ui/core/style.js +37 -0
  257. package/dist/ui/core/style.js.map +1 -0
  258. package/dist/ui/core/types.d.ts +50 -0
  259. package/dist/ui/core/types.d.ts.map +1 -0
  260. package/dist/ui/core/types.js +2 -0
  261. package/dist/ui/core/types.js.map +1 -0
  262. package/dist/ui/ink/index.d.ts +2 -0
  263. package/dist/ui/ink/index.d.ts.map +1 -0
  264. package/dist/ui/ink/index.js +2 -0
  265. package/dist/ui/ink/index.js.map +1 -0
  266. package/dist/ui/ink/render.d.ts +6 -0
  267. package/dist/ui/ink/render.d.ts.map +1 -0
  268. package/dist/ui/ink/render.js +14 -0
  269. package/dist/ui/ink/render.js.map +1 -0
  270. package/dist/ui/views/app.d.ts +28 -0
  271. package/dist/ui/views/app.d.ts.map +1 -0
  272. package/dist/ui/views/app.js +59 -0
  273. package/dist/ui/views/app.js.map +1 -0
  274. package/dist/ui/views/header.d.ts +11 -0
  275. package/dist/ui/views/header.d.ts.map +1 -0
  276. package/dist/ui/views/header.js +28 -0
  277. package/dist/ui/views/header.js.map +1 -0
  278. package/dist/ui/views/input_area.d.ts +45 -0
  279. package/dist/ui/views/input_area.d.ts.map +1 -0
  280. package/dist/ui/views/input_area.js +183 -0
  281. package/dist/ui/views/input_area.js.map +1 -0
  282. package/dist/ui/views/message_list.d.ts +12 -0
  283. package/dist/ui/views/message_list.d.ts.map +1 -0
  284. package/dist/ui/views/message_list.js +381 -0
  285. package/dist/ui/views/message_list.js.map +1 -0
  286. package/dist/ui/views/status_bar.d.ts +18 -0
  287. package/dist/ui/views/status_bar.d.ts.map +1 -0
  288. package/dist/ui/views/status_bar.js +72 -0
  289. package/dist/ui/views/status_bar.js.map +1 -0
  290. package/dist/ui/vue/index.d.ts +5 -0
  291. package/dist/ui/vue/index.d.ts.map +1 -0
  292. package/dist/ui/vue/index.js +50 -0
  293. package/dist/ui/vue/index.js.map +1 -0
  294. package/dist/utils/clipboard.d.ts +2 -0
  295. package/dist/utils/clipboard.d.ts.map +1 -0
  296. package/dist/utils/clipboard.js +39 -0
  297. package/dist/utils/clipboard.js.map +1 -0
  298. package/dist/utils/clipboard_image.d.ts +2 -0
  299. package/dist/utils/clipboard_image.d.ts.map +1 -0
  300. package/dist/utils/clipboard_image.js +37 -0
  301. package/dist/utils/clipboard_image.js.map +1 -0
  302. package/dist/utils/diff.d.ts +2 -0
  303. package/dist/utils/diff.d.ts.map +1 -0
  304. package/dist/utils/diff.js +49 -0
  305. package/dist/utils/diff.js.map +1 -0
  306. package/dist/utils/image_preview.d.ts +2 -0
  307. package/dist/utils/image_preview.d.ts.map +1 -0
  308. package/dist/utils/image_preview.js +37 -0
  309. package/dist/utils/image_preview.js.map +1 -0
  310. package/dist/utils/models.d.ts +8 -0
  311. package/dist/utils/models.d.ts.map +1 -0
  312. package/dist/utils/models.js +85 -0
  313. package/dist/utils/models.js.map +1 -0
  314. package/dist/utils/shell.d.ts +4 -0
  315. package/dist/utils/shell.d.ts.map +1 -0
  316. package/dist/utils/shell.js +57 -0
  317. package/dist/utils/shell.js.map +1 -0
  318. package/dist/utils/tool_summary.d.ts +3 -0
  319. package/dist/utils/tool_summary.d.ts.map +1 -0
  320. package/dist/utils/tool_summary.js +54 -0
  321. package/dist/utils/tool_summary.js.map +1 -0
  322. package/dist/utils/tool_trace.d.ts +9 -0
  323. package/dist/utils/tool_trace.d.ts.map +1 -0
  324. package/dist/utils/tool_trace.js +183 -0
  325. package/dist/utils/tool_trace.js.map +1 -0
  326. package/package.json +41 -0
  327. package/src/App.tsx +576 -0
  328. package/src/agent/agent.ts +407 -0
  329. package/src/agent/backends/anthropic.ts +76 -0
  330. package/src/agent/backends/gemini.ts +107 -0
  331. package/src/agent/backends/inception.ts +23 -0
  332. package/src/agent/backends/index.ts +16 -0
  333. package/src/agent/backends/openai.ts +23 -0
  334. package/src/agent/backends/openai_compatible.ts +131 -0
  335. package/src/agent/backends/types.ts +59 -0
  336. package/src/agent/commands/clipboard.ts +77 -0
  337. package/src/agent/commands/config.ts +130 -0
  338. package/src/agent/commands/debug.ts +23 -0
  339. package/src/agent/commands/emulation.ts +80 -0
  340. package/src/agent/commands/execution.ts +9 -0
  341. package/src/agent/commands/help.ts +20 -0
  342. package/src/agent/commands/history.ts +13 -0
  343. package/src/agent/commands/index.ts +40 -0
  344. package/src/agent/commands/model.ts +11 -0
  345. package/src/agent/commands/models.ts +116 -0
  346. package/src/agent/commands/permissions.ts +64 -0
  347. package/src/agent/commands/retry.ts +9 -0
  348. package/src/agent/commands/shell.ts +68 -0
  349. package/src/agent/commands/skills.ts +54 -0
  350. package/src/agent/commands/status.ts +19 -0
  351. package/src/agent/commands/types.ts +78 -0
  352. package/src/agent/factory.ts +60 -0
  353. package/src/agent/index.ts +20 -0
  354. package/src/agent/runtime/capabilities.ts +6 -0
  355. package/src/agent/runtime/memory.ts +23 -0
  356. package/src/agent/runtime/policy.ts +48 -0
  357. package/src/agent/runtime/session.ts +18 -0
  358. package/src/agent/runtime/tracing.ts +23 -0
  359. package/src/agent/tools/file.ts +173 -0
  360. package/src/agent/tools/index.ts +46 -0
  361. package/src/agent/tools/search.ts +137 -0
  362. package/src/agent/tools/shell.ts +65 -0
  363. package/src/agent/tools/skills.ts +28 -0
  364. package/src/agent/tools/types.ts +10 -0
  365. package/src/agent/tools/zerg.ts +50 -0
  366. package/src/cli.tsx +80 -0
  367. package/src/components/FullScreen.tsx +73 -0
  368. package/src/components/Header.tsx +27 -0
  369. package/src/components/InputArea.tsx +551 -0
  370. package/src/components/MessageList.tsx +25 -0
  371. package/src/components/StatusBar.tsx +49 -0
  372. package/src/components/index.tsx +6 -0
  373. package/src/config/types.ts +11 -0
  374. package/src/config.ts +178 -0
  375. package/src/debug/logger.ts +14 -0
  376. package/src/emulation/README.md +24 -0
  377. package/src/emulation/catalog.ts +82 -0
  378. package/src/emulation/trace_style.ts +8 -0
  379. package/src/emulation/types.ts +7 -0
  380. package/src/skills/index.ts +36 -0
  381. package/src/skills/loader.ts +135 -0
  382. package/src/skills/registry.ts +6 -0
  383. package/src/skills/types.ts +10 -0
  384. package/src/types.ts +83 -0
  385. package/src/ui/README.md +44 -0
  386. package/src/ui/core/factory.ts +9 -0
  387. package/src/ui/core/index.ts +4 -0
  388. package/src/ui/core/input.ts +38 -0
  389. package/src/ui/core/input_segments.ts +375 -0
  390. package/src/ui/core/input_state.ts +17 -0
  391. package/src/ui/core/layout_yoga.ts +122 -0
  392. package/src/ui/core/style.ts +38 -0
  393. package/src/ui/core/types.ts +53 -0
  394. package/src/ui/ink/index.tsx +1 -0
  395. package/src/ui/ink/render.tsx +49 -0
  396. package/src/ui/views/app.ts +99 -0
  397. package/src/ui/views/header.ts +42 -0
  398. package/src/ui/views/input_area.ts +244 -0
  399. package/src/ui/views/message_list.ts +427 -0
  400. package/src/ui/views/status_bar.ts +104 -0
  401. package/src/ui/vue/index.ts +53 -0
  402. package/src/utils/clipboard.ts +39 -0
  403. package/src/utils/clipboard_image.ts +40 -0
  404. package/src/utils/diff.ts +52 -0
  405. package/src/utils/image_preview.ts +36 -0
  406. package/src/utils/models.ts +98 -0
  407. package/src/utils/shell.ts +63 -0
  408. package/src/utils/tool_summary.ts +56 -0
  409. package/src/utils/tool_trace.ts +206 -0
  410. package/tsconfig.json +22 -0
  411. package/vite.config.ts +363 -0
@@ -0,0 +1,173 @@
1
+ import { readFile, writeFile, readdir, stat } from 'fs/promises';
2
+ import { dirname, resolve } from 'path';
3
+ import { Tool } from './types.js';
4
+ import { ToolCapability } from '../runtime/capabilities.js';
5
+ import { buildSimpleDiff } from '../../utils/diff.js';
6
+
7
+ // --- File Tools ---
8
+
9
+ export const readFileTool: Tool = {
10
+ capabilities: [ToolCapability.FILE_READ],
11
+ definition: {
12
+ name: 'read_file',
13
+ description: 'Read the contents of a file at the specified path',
14
+ parameters: {
15
+ type: 'object',
16
+ properties: {
17
+ path: {
18
+ type: 'string',
19
+ description: 'Absolute or relative file path to read'
20
+ },
21
+ encoding: {
22
+ type: 'string',
23
+ description: 'File encoding (default: utf-8)',
24
+ enum: ['utf-8', 'ascii', 'base64', 'hex']
25
+ }
26
+ },
27
+ required: ['path']
28
+ }
29
+ },
30
+ execute: async (args) => {
31
+ const path = resolve(String(args.path));
32
+ const encoding = (args.encoding as BufferEncoding) || 'utf-8';
33
+
34
+ try {
35
+ const content = await readFile(path, { encoding });
36
+ const stats = await stat(path);
37
+ return JSON.stringify({
38
+ path,
39
+ size: stats.size,
40
+ content: content.slice(0, 50000), // Limit content size
41
+ truncated: content.length > 50000
42
+ });
43
+ } catch (err) {
44
+ throw new Error(`Failed to read file: ${(err as Error).message}`);
45
+ }
46
+ }
47
+ };
48
+
49
+ export const writeFileTool: Tool = {
50
+ capabilities: [ToolCapability.FILE_WRITE],
51
+ definition: {
52
+ name: 'write_file',
53
+ description: 'Write content to a file, creating directories if needed',
54
+ parameters: {
55
+ type: 'object',
56
+ properties: {
57
+ path: {
58
+ type: 'string',
59
+ description: 'File path to write to'
60
+ },
61
+ content: {
62
+ type: 'string',
63
+ description: 'Content to write to the file'
64
+ },
65
+ append: {
66
+ type: 'string',
67
+ description: 'If "true", append to file instead of overwriting'
68
+ }
69
+ },
70
+ required: ['path', 'content']
71
+ }
72
+ },
73
+ execute: async (args) => {
74
+ const path = resolve(String(args.path));
75
+ const content = String(args.content);
76
+ const append = args.append === 'true';
77
+
78
+ try {
79
+ // Ensure directory exists
80
+ const { mkdir, appendFile } = await import('fs/promises');
81
+ await mkdir(dirname(path), { recursive: true });
82
+
83
+ let beforeContent = '';
84
+ try {
85
+ beforeContent = await readFile(path, { encoding: 'utf-8' });
86
+ } catch {
87
+ beforeContent = '';
88
+ }
89
+
90
+ if (append) {
91
+ await appendFile(path, content, 'utf-8');
92
+ } else {
93
+ await writeFile(path, content, 'utf-8');
94
+ }
95
+
96
+ const stats = await stat(path);
97
+ const afterContent = await readFile(path, { encoding: 'utf-8' });
98
+ const diff = buildSimpleDiff(beforeContent, afterContent);
99
+ return JSON.stringify({
100
+ path,
101
+ size: stats.size,
102
+ action: append ? 'appended' : 'written',
103
+ diff,
104
+ before: beforeContent.slice(0, 5000),
105
+ after: afterContent.slice(0, 5000),
106
+ truncated: beforeContent.length > 5000 || afterContent.length > 5000
107
+ });
108
+ } catch (err) {
109
+ throw new Error(`Failed to write file: ${(err as Error).message}`);
110
+ }
111
+ }
112
+ };
113
+
114
+ export const listDirectoryTool: Tool = {
115
+ capabilities: [ToolCapability.FILE_READ],
116
+ definition: {
117
+ name: 'list_directory',
118
+ description: 'List contents of a directory',
119
+ parameters: {
120
+ type: 'object',
121
+ properties: {
122
+ path: {
123
+ type: 'string',
124
+ description: 'Directory path to list'
125
+ },
126
+ recursive: {
127
+ type: 'string',
128
+ description: 'If "true", list recursively (max 3 levels)'
129
+ }
130
+ },
131
+ required: ['path']
132
+ }
133
+ },
134
+ execute: async (args) => {
135
+ const path = resolve(String(args.path));
136
+ const recursive = args.recursive === 'true';
137
+
138
+ async function listDir(dir: string, depth = 0): Promise<object[]> {
139
+ if (depth > 3) return [];
140
+
141
+ const entries = await readdir(dir, { withFileTypes: true });
142
+ const results: object[] = [];
143
+
144
+ for (const entry of entries.slice(0, 100)) { // Limit entries
145
+ const entryPath = resolve(dir, entry.name);
146
+ const info: Record<string, unknown> = {
147
+ name: entry.name,
148
+ type: entry.isDirectory() ? 'directory' : 'file'
149
+ };
150
+
151
+ if (entry.isFile()) {
152
+ const s = await stat(entryPath);
153
+ info.size = s.size;
154
+ }
155
+
156
+ if (recursive && entry.isDirectory() && !entry.name.startsWith('.')) {
157
+ info.children = await listDir(entryPath, depth + 1);
158
+ }
159
+
160
+ results.push(info);
161
+ }
162
+
163
+ return results;
164
+ }
165
+
166
+ try {
167
+ const entries = await listDir(path);
168
+ return JSON.stringify({ path, entries });
169
+ } catch (err) {
170
+ throw new Error(`Failed to list directory: ${(err as Error).message}`);
171
+ }
172
+ }
173
+ };
@@ -0,0 +1,46 @@
1
+ import { Tool } from './types.js';
2
+ import { ToolDefinition } from '../../types.js';
3
+ import { readFileTool, writeFileTool, listDirectoryTool } from './file.js';
4
+ import { runCommandTool } from './shell.js';
5
+ import { zergQueryTool } from './zerg.js';
6
+ import { searchTool } from './search.js';
7
+ import { listSkillsTool } from './skills.js';
8
+
9
+ // --- Tool Registry ---
10
+
11
+ export const defaultTools: Tool[] = [
12
+ readFileTool,
13
+ writeFileTool,
14
+ listDirectoryTool,
15
+ searchTool,
16
+ listSkillsTool,
17
+ runCommandTool,
18
+ zergQueryTool
19
+ ];
20
+
21
+ export function getToolDefinitions(tools: Tool[] = defaultTools): ToolDefinition[] {
22
+ return tools.map(t => t.definition);
23
+ }
24
+
25
+ export function getTool(name: string, tools: Tool[] = defaultTools): Tool | undefined {
26
+ return tools.find(t => t.definition.name === name);
27
+ }
28
+
29
+ export async function executeTool(
30
+ name: string,
31
+ args: Record<string, unknown>,
32
+ tools: Tool[] = defaultTools
33
+ ): Promise<string> {
34
+ const tool = getTool(name, tools);
35
+ if (!tool) {
36
+ throw new Error(`Unknown tool: ${name}`);
37
+ }
38
+ return tool.execute(args);
39
+ }
40
+
41
+ export { readFileTool, writeFileTool, listDirectoryTool } from './file.js';
42
+ export { searchTool } from './search.js';
43
+ export { listSkillsTool } from './skills.js';
44
+ export { runCommandTool } from './shell.js';
45
+ export { zergQueryTool } from './zerg.js';
46
+ export type { Tool } from './types.js';
@@ -0,0 +1,137 @@
1
+ import { spawn } from 'child_process';
2
+ import { resolve } from 'path';
3
+ import { Tool } from './types.js';
4
+ import { ToolCapability } from '../runtime/capabilities.js';
5
+
6
+ interface RunResult {
7
+ stdout: string;
8
+ stderr: string;
9
+ code: number;
10
+ }
11
+
12
+ function runCommand(command: string, args: string[], cwd: string): Promise<RunResult> {
13
+ return new Promise((resolveResult, reject) => {
14
+ const child = spawn(command, args, { cwd });
15
+ let stdout = '';
16
+ let stderr = '';
17
+ child.stdout.on('data', chunk => { stdout += chunk.toString(); });
18
+ child.stderr.on('data', chunk => { stderr += chunk.toString(); });
19
+ child.on('error', reject);
20
+ child.on('close', (code) => {
21
+ resolveResult({ stdout, stderr, code: code ?? 1 });
22
+ });
23
+ });
24
+ }
25
+
26
+ // --- Search Tool ---
27
+
28
+ export const searchTool: Tool = {
29
+ capabilities: [ToolCapability.FILE_READ],
30
+ definition: {
31
+ name: 'search',
32
+ description: 'Search for a pattern in files (ripgrep preferred)',
33
+ parameters: {
34
+ type: 'object',
35
+ properties: {
36
+ pattern: {
37
+ type: 'string',
38
+ description: 'Regex pattern to search for'
39
+ },
40
+ path: {
41
+ type: 'string',
42
+ description: 'Path to search within (default: .)'
43
+ },
44
+ glob: {
45
+ type: 'string',
46
+ description: 'Optional glob filter (e.g., "*.ts")'
47
+ },
48
+ output_mode: {
49
+ type: 'string',
50
+ description: 'Output mode: content or files',
51
+ enum: ['content', 'files']
52
+ },
53
+ max_results: {
54
+ type: 'string',
55
+ description: 'Maximum number of results (default: 20)'
56
+ }
57
+ },
58
+ required: ['pattern']
59
+ }
60
+ },
61
+ execute: async (args) => {
62
+ const pattern = String(args.pattern || '');
63
+ const path = resolve(String(args.path || '.'));
64
+ const glob = args.glob ? String(args.glob) : undefined;
65
+ const outputMode = args.output_mode === 'files' ? 'files' : 'content';
66
+ const maxResults = Math.max(1, Math.min(200, parseInt(String(args.max_results || '20'), 10)));
67
+
68
+ if (!pattern) {
69
+ throw new Error('Search pattern is required');
70
+ }
71
+
72
+ const rgArgs: string[] = [];
73
+ if (outputMode === 'files') {
74
+ rgArgs.push('-l', '--max-count', String(maxResults));
75
+ } else {
76
+ rgArgs.push('--line-number', '--column', '--with-filename', '--no-heading', '--max-count', String(maxResults));
77
+ }
78
+ if (glob) {
79
+ rgArgs.push('-g', glob);
80
+ }
81
+ rgArgs.push(pattern, path);
82
+
83
+ let result: RunResult | null = null;
84
+ try {
85
+ result = await runCommand('rg', rgArgs, process.cwd());
86
+ } catch {
87
+ result = null;
88
+ }
89
+
90
+ if (!result || (result.code !== 0 && result.code !== 1)) {
91
+ const grepArgs = ['-R', '-n', pattern, path];
92
+ const fallback = await runCommand('grep', grepArgs, process.cwd());
93
+ if (fallback.code !== 0 && fallback.code !== 1) {
94
+ throw new Error(fallback.stderr || 'Search failed');
95
+ }
96
+ result = fallback;
97
+ }
98
+
99
+ const stdout = result.stdout.trim();
100
+ if (!stdout) {
101
+ return JSON.stringify({ pattern, path, matches: [], count: 0, truncated: false });
102
+ }
103
+
104
+ if (outputMode === 'files') {
105
+ const files = stdout.split('\n').slice(0, maxResults);
106
+ return JSON.stringify({
107
+ pattern,
108
+ path,
109
+ files,
110
+ count: files.length,
111
+ truncated: files.length >= maxResults
112
+ });
113
+ }
114
+
115
+ const lines = stdout.split('\n');
116
+ const matches = [];
117
+ for (const line of lines) {
118
+ const match = line.match(/^(.+?):(\d+):(\d+):(.*)$/);
119
+ if (!match) continue;
120
+ matches.push({
121
+ path: match[1],
122
+ line: Number(match[2]),
123
+ column: Number(match[3]),
124
+ text: match[4]
125
+ });
126
+ if (matches.length >= maxResults) break;
127
+ }
128
+
129
+ return JSON.stringify({
130
+ pattern,
131
+ path,
132
+ matches,
133
+ count: matches.length,
134
+ truncated: matches.length >= maxResults
135
+ });
136
+ }
137
+ };
@@ -0,0 +1,65 @@
1
+ import { exec } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { resolve } from 'path';
4
+ import { Tool } from './types.js';
5
+ import { ToolCapability } from '../runtime/capabilities.js';
6
+
7
+ const execAsync = promisify(exec);
8
+
9
+ // --- Shell Tool ---
10
+
11
+ export const runCommandTool: Tool = {
12
+ capabilities: [ToolCapability.SHELL_EXEC],
13
+ definition: {
14
+ name: 'run_command',
15
+ description: 'Execute a shell command and return output',
16
+ parameters: {
17
+ type: 'object',
18
+ properties: {
19
+ command: {
20
+ type: 'string',
21
+ description: 'Shell command to execute'
22
+ },
23
+ cwd: {
24
+ type: 'string',
25
+ description: 'Working directory for the command'
26
+ },
27
+ timeout: {
28
+ type: 'string',
29
+ description: 'Timeout in milliseconds (default: 30000)'
30
+ }
31
+ },
32
+ required: ['command']
33
+ }
34
+ },
35
+ execute: async (args) => {
36
+ const command = String(args.command);
37
+ const cwd = args.cwd ? resolve(String(args.cwd)) : process.cwd();
38
+ const timeout = parseInt(String(args.timeout || '30000'), 10);
39
+
40
+ // Basic safety checks
41
+ const dangerous = ['rm -rf /', 'mkfs', ':(){:|:&};:'];
42
+ if (dangerous.some(d => command.includes(d))) {
43
+ throw new Error('Command rejected for safety reasons');
44
+ }
45
+
46
+ try {
47
+ const { stdout, stderr } = await execAsync(command, {
48
+ cwd,
49
+ timeout,
50
+ maxBuffer: 1024 * 1024 // 1MB
51
+ });
52
+
53
+ return JSON.stringify({
54
+ command,
55
+ cwd,
56
+ stdout: stdout.slice(0, 10000),
57
+ stderr: stderr.slice(0, 10000),
58
+ truncated: stdout.length > 10000 || stderr.length > 10000
59
+ });
60
+ } catch (err) {
61
+ const e = err as Error & { stdout?: string; stderr?: string; code?: number };
62
+ throw new Error(`Command failed: ${e.message}\nstderr: ${e.stderr || ''}`);
63
+ }
64
+ }
65
+ };
@@ -0,0 +1,28 @@
1
+ import { Tool } from './types.js';
2
+ import { ToolCapability } from '../runtime/capabilities.js';
3
+ import { loadSkills } from '../../skills/loader.js';
4
+
5
+ export const listSkillsTool: Tool = {
6
+ capabilities: [ToolCapability.FILE_READ],
7
+ definition: {
8
+ name: 'list_skills',
9
+ description: 'List available skills',
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {},
13
+ required: []
14
+ }
15
+ },
16
+ execute: async () => {
17
+ const skills = await loadSkills();
18
+ return JSON.stringify({
19
+ count: skills.length,
20
+ skills: skills.map(skill => ({
21
+ id: skill.id,
22
+ name: skill.name,
23
+ description: skill.description,
24
+ sourceRoot: skill.sourceRoot
25
+ }))
26
+ });
27
+ }
28
+ };
@@ -0,0 +1,10 @@
1
+ import { ToolDefinition } from '../../types.js';
2
+ import { ToolCapability } from '../runtime/capabilities.js';
3
+
4
+ // --- Tool Interface ---
5
+
6
+ export interface Tool {
7
+ definition: ToolDefinition;
8
+ capabilities?: ToolCapability[];
9
+ execute: (args: Record<string, unknown>) => Promise<string>;
10
+ }
@@ -0,0 +1,50 @@
1
+ import { Tool } from './types.js';
2
+ import { ToolCapability } from '../runtime/capabilities.js';
3
+
4
+ // --- Zerg Integration Tool ---
5
+
6
+ export const zergQueryTool: Tool = {
7
+ capabilities: [ToolCapability.NETWORK],
8
+ definition: {
9
+ name: 'zerg_query',
10
+ description: 'Send a query to the Zerg continual AI system',
11
+ parameters: {
12
+ type: 'object',
13
+ properties: {
14
+ query: {
15
+ type: 'string',
16
+ description: 'Query or instruction for Zerg'
17
+ },
18
+ context: {
19
+ type: 'string',
20
+ description: 'Additional context for the query'
21
+ },
22
+ project: {
23
+ type: 'string',
24
+ description: 'Project identifier within Zerg'
25
+ },
26
+ wait: {
27
+ type: 'string',
28
+ description: 'If "true", wait for completion; otherwise return task ID'
29
+ }
30
+ },
31
+ required: ['query']
32
+ }
33
+ },
34
+ execute: async (args) => {
35
+ // Placeholder - implement actual Zerg API integration
36
+ const query = String(args.query);
37
+ const context = args.context ? String(args.context) : undefined;
38
+ const project = args.project ? String(args.project) : 'default';
39
+
40
+ // TODO: Replace with actual Zerg API call
41
+ return JSON.stringify({
42
+ status: 'placeholder',
43
+ message: 'Zerg integration not yet implemented',
44
+ query,
45
+ context,
46
+ project,
47
+ taskId: `zerg_${Date.now()}`
48
+ });
49
+ }
50
+ };
package/src/cli.tsx ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+ import React from 'react';
3
+ import { render } from 'ink';
4
+ import { resolve } from 'path';
5
+ import { statSync } from 'fs';
6
+ import { App } from './App.js';
7
+
8
+ // --- CLI Entry Point ---
9
+
10
+ // Parse command line args
11
+ const args = process.argv.slice(2);
12
+
13
+ if (args.includes('--help') || args.includes('-h')) {
14
+ console.log(`
15
+ ZTC - Zerg Terminal Client v0.1.0
16
+
17
+ Usage: ztc [options]
18
+
19
+ Options:
20
+ -h, --help Show this help message
21
+ -v, --version Show version number
22
+ --cwd <path> Start in a specific working directory
23
+
24
+ Environment Variables:
25
+ ANTHROPIC_API_KEY API key for Claude (optional, can be set in-app)
26
+
27
+ In-App Commands:
28
+ /help Show available commands
29
+ /config key <key> Set API key
30
+ /config show Show current configuration
31
+ /clear Clear message history
32
+ /status Show current status
33
+ /exit Exit ZTC
34
+
35
+ Keyboard Shortcuts:
36
+ Ctrl+C Exit
37
+ Ctrl+L Clear screen
38
+ Up/Down Navigate command history
39
+ Ctrl+U Clear input line
40
+ Ctrl+W Delete word
41
+ Ctrl+A Move to start of line
42
+ Ctrl+E Move to end of line
43
+ `);
44
+ process.exit(0);
45
+ }
46
+
47
+ if (args.includes('--version') || args.includes('-v')) {
48
+ console.log('ztc v0.1.0');
49
+ process.exit(0);
50
+ }
51
+
52
+ const cwdIndex = args.indexOf('--cwd');
53
+ if (cwdIndex >= 0) {
54
+ const target = args[cwdIndex + 1];
55
+ if (!target) {
56
+ console.error('Error: --cwd requires a path');
57
+ process.exit(1);
58
+ }
59
+ const resolved = resolve(target);
60
+ try {
61
+ const info = statSync(resolved);
62
+ if (!info.isDirectory()) {
63
+ throw new Error('Not a directory');
64
+ }
65
+ process.chdir(resolved);
66
+ } catch {
67
+ console.error(`Error: invalid --cwd path (${resolved})`);
68
+ process.exit(1);
69
+ }
70
+ }
71
+
72
+ // Render the app
73
+ // Note: FullScreen component handles alternate screen buffer
74
+ const { waitUntilExit } = render(<App />);
75
+
76
+ // Handle clean exit
77
+ waitUntilExit().then(() => {
78
+ console.log('Goodbye from ZTC! 👋');
79
+ process.exit(0);
80
+ });
@@ -0,0 +1,73 @@
1
+ import React, { useEffect, PropsWithChildren } from 'react';
2
+ import { Box } from 'ink';
3
+
4
+ /**
5
+ * FullScreen component that uses the alternate screen buffer.
6
+ *
7
+ * This prevents flickering by:
8
+ * 1. Switching to the alternate screen buffer (like vim, htop, less do)
9
+ * 2. Tracking terminal resize events
10
+ * 3. Restoring the original terminal state on exit
11
+ *
12
+ * ANSI escape codes:
13
+ * - \x1b[?1049h - Enter alternate screen buffer
14
+ * - \x1b[?1049l - Exit alternate screen buffer
15
+ * - \x1b[?25l - Hide cursor
16
+ * - \x1b[?25h - Show cursor
17
+ */
18
+
19
+ interface FullScreenProps extends PropsWithChildren {
20
+ debug?: boolean;
21
+ }
22
+
23
+ const initialSize = {
24
+ columns: process.stdout.columns || 80,
25
+ rows: process.stdout.rows || 24,
26
+ };
27
+
28
+ export const FullScreen: React.FC<FullScreenProps> = ({ children, debug = false }) => {
29
+ const isTty = Boolean(process.stdout.isTTY);
30
+ const useAltScreen = isTty && process.env.ZTC_ALT_SCREEN === '1';
31
+
32
+ useEffect(() => {
33
+ if (!useAltScreen) {
34
+ return;
35
+ }
36
+
37
+ // Enter alternate screen buffer
38
+ process.stdout.write('\x1b[?1049h');
39
+ // Hide cursor (we'll draw our own)
40
+ process.stdout.write('\x1b[?25l');
41
+ // Clear the alternate screen
42
+ process.stdout.write('\x1b[2J');
43
+ // Move cursor to top-left
44
+ process.stdout.write('\x1b[H');
45
+
46
+ // Cleanup: restore terminal state
47
+ return () => {
48
+ // Show cursor
49
+ process.stdout.write('\x1b[?25h');
50
+ // Exit alternate screen buffer (restores original content)
51
+ process.stdout.write('\x1b[?1049l');
52
+ };
53
+ }, [useAltScreen]);
54
+
55
+ return (
56
+ <Box
57
+ flexDirection="column"
58
+ borderStyle={debug ? 'single' : undefined}
59
+ borderColor={debug ? 'red' : undefined}
60
+ >
61
+ {children}
62
+ </Box>
63
+ );
64
+ };
65
+
66
+ /**
67
+ * Hook to get current screen size with resize tracking
68
+ */
69
+ export function useScreenSize() {
70
+ return initialSize;
71
+ }
72
+
73
+ export default FullScreen;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { InkNode } from '../ui/ink/index.js';
3
+ import { buildHeaderView } from '../ui/views/header.js';
4
+
5
+ interface HeaderProps {
6
+ title?: string;
7
+ version?: string;
8
+ showHelp?: boolean;
9
+ debug?: boolean;
10
+ }
11
+
12
+ export const Header: React.FC<HeaderProps> = ({
13
+ title = 'Zerg Terminal Client',
14
+ version = '0.1.0',
15
+ showHelp = true,
16
+ debug = false
17
+ }) => {
18
+ const dateLabel = new Date().toLocaleDateString('en-US', {
19
+ month: 'short',
20
+ day: '2-digit',
21
+ year: 'numeric'
22
+ });
23
+ const node = buildHeaderView({ title, version, dateLabel, showHelp, debug });
24
+ return <InkNode node={node} />;
25
+ };
26
+
27
+ export default Header;