@dyyz1993/create-agent 1.9.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 (358) hide show
  1. package/package.json +25 -0
  2. package/src/__tests__/cli.test.ts +85 -0
  3. package/src/__tests__/copy.test.ts +168 -0
  4. package/src/__tests__/templates.test.ts +87 -0
  5. package/src/cli.ts +65 -0
  6. package/src/commands/create.ts +49 -0
  7. package/src/commands/list.ts +12 -0
  8. package/src/commands/status.ts +85 -0
  9. package/src/commands/workspace.ts +129 -0
  10. package/src/lib/copy.ts +285 -0
  11. package/src/lib/templates.ts +57 -0
  12. package/src/lib/types.ts +6 -0
  13. package/templates/agent/.env.example +7 -0
  14. package/templates/agent/LICENSE +21 -0
  15. package/templates/agent/README.md +87 -0
  16. package/templates/agent/bun.lock +1279 -0
  17. package/templates/agent/electrobun.config.ts +27 -0
  18. package/templates/agent/eslint.config.mjs +63 -0
  19. package/templates/agent/llms.txt +24 -0
  20. package/templates/agent/package-lock.json +3670 -0
  21. package/templates/agent/package.json +59 -0
  22. package/templates/agent/postcss.config.js +6 -0
  23. package/templates/agent/scripts/dev.ts +138 -0
  24. package/templates/agent/src/__tests__/server-config.test.ts +59 -0
  25. package/templates/agent/src/bun/index.ts +73 -0
  26. package/templates/agent/src/gateway/__tests__/ws-handler.test.ts +48 -0
  27. package/templates/agent/src/gateway/http-routes.ts +1 -0
  28. package/templates/agent/src/gateway/ipc-transport.ts +68 -0
  29. package/templates/agent/src/gateway/ws-handler.ts +86 -0
  30. package/templates/agent/src/mainview/App.tsx +41 -0
  31. package/templates/agent/src/mainview/__tests__/components/ChatPanel.test.tsx +114 -0
  32. package/templates/agent/src/mainview/__tests__/components/ExplorerSidebar.test.tsx +141 -0
  33. package/templates/agent/src/mainview/__tests__/components/MessageBubble.test.tsx +72 -0
  34. package/templates/agent/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
  35. package/templates/agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +217 -0
  36. package/templates/agent/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
  37. package/templates/agent/src/mainview/__tests__/i18n/i18n.test.ts +48 -0
  38. package/templates/agent/src/mainview/__tests__/setup.ts +37 -0
  39. package/templates/agent/src/mainview/__tests__/stores/use-chat-store.test.ts +83 -0
  40. package/templates/agent/src/mainview/__tests__/stores/use-sidebar-store.test.ts +85 -0
  41. package/templates/agent/src/mainview/components/activity-bar/ActivityBar.tsx +36 -0
  42. package/templates/agent/src/mainview/components/activity-bar/MobileTabBar.tsx +36 -0
  43. package/templates/agent/src/mainview/components/activity-bar/__tests__/ActivityBar.test.tsx +44 -0
  44. package/templates/agent/src/mainview/components/activity-bar/__tests__/MobileTabBar.test.tsx +44 -0
  45. package/templates/agent/src/mainview/components/bash/BashPanel.tsx +206 -0
  46. package/templates/agent/src/mainview/components/bash/__tests__/BashPanel.test.tsx +103 -0
  47. package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +102 -0
  48. package/templates/agent/src/mainview/components/chat/MessageBubble.tsx +86 -0
  49. package/templates/agent/src/mainview/components/common/ErrorBoundary.tsx +58 -0
  50. package/templates/agent/src/mainview/components/common/LanguageSwitcher.tsx +14 -0
  51. package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +24 -0
  52. package/templates/agent/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
  53. package/templates/agent/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
  54. package/templates/agent/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
  55. package/templates/agent/src/mainview/components/debug/DebugPanel.tsx +120 -0
  56. package/templates/agent/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +102 -0
  57. package/templates/agent/src/mainview/components/diff/DiffViewerPanel.tsx +106 -0
  58. package/templates/agent/src/mainview/components/diff/__tests__/DiffViewerPanel.test.tsx +73 -0
  59. package/templates/agent/src/mainview/components/explorer/ConfirmDialog.tsx +53 -0
  60. package/templates/agent/src/mainview/components/explorer/ContextMenu.tsx +82 -0
  61. package/templates/agent/src/mainview/components/explorer/ExplorerSidebar.tsx +221 -0
  62. package/templates/agent/src/mainview/components/explorer/InlineInput.tsx +55 -0
  63. package/templates/agent/src/mainview/components/explorer/TreeNodeItem.tsx +121 -0
  64. package/templates/agent/src/mainview/components/explorer/__tests__/ConfirmDialog.test.tsx +37 -0
  65. package/templates/agent/src/mainview/components/explorer/__tests__/ContextMenu.test.tsx +49 -0
  66. package/templates/agent/src/mainview/components/explorer/__tests__/InlineInput.test.tsx +48 -0
  67. package/templates/agent/src/mainview/components/explorer/__tests__/TreeNodeItem.test.tsx +146 -0
  68. package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +239 -0
  69. package/templates/agent/src/mainview/components/feed/__tests__/FeedPanel.test.tsx +108 -0
  70. package/templates/agent/src/mainview/components/file-preview/FilePreviewOverlay.tsx +56 -0
  71. package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +99 -0
  72. package/templates/agent/src/mainview/components/file-preview/__tests__/FilePreviewOverlay.test.tsx +96 -0
  73. package/templates/agent/src/mainview/components/file-preview/__tests__/VirtualizedCodeView.test.tsx +58 -0
  74. package/templates/agent/src/mainview/components/git/GitBranchSelector.tsx +98 -0
  75. package/templates/agent/src/mainview/components/git/GitCommitInput.tsx +60 -0
  76. package/templates/agent/src/mainview/components/git/GitPanel.tsx +528 -0
  77. package/templates/agent/src/mainview/components/git/__tests__/GitBranchSelector.test.tsx +76 -0
  78. package/templates/agent/src/mainview/components/git/__tests__/GitCommitInput.test.tsx +91 -0
  79. package/templates/agent/src/mainview/components/git/__tests__/GitPanel.test.tsx +174 -0
  80. package/templates/agent/src/mainview/components/layout/AppLayout.tsx +170 -0
  81. package/templates/agent/src/mainview/components/layout/__tests__/AppLayout.test.tsx +163 -0
  82. package/templates/agent/src/mainview/components/rules/RulesPanel.tsx +117 -0
  83. package/templates/agent/src/mainview/components/rules/__tests__/RulesPanel.test.tsx +91 -0
  84. package/templates/agent/src/mainview/components/search/SearchPanel.tsx +404 -0
  85. package/templates/agent/src/mainview/components/search/__tests__/SearchPanel.test.tsx +50 -0
  86. package/templates/agent/src/mainview/components/sidebar/PinButton.tsx +20 -0
  87. package/templates/agent/src/mainview/components/sidebar/__tests__/PinButton.test.tsx +48 -0
  88. package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +141 -0
  89. package/templates/agent/src/mainview/components/todo/__tests__/TodoPanel.test.tsx +91 -0
  90. package/templates/agent/src/mainview/global.d.ts +13 -0
  91. package/templates/agent/src/mainview/hooks/__tests__/use-breakpoint.test.ts +147 -0
  92. package/templates/agent/src/mainview/hooks/use-breakpoint.ts +34 -0
  93. package/templates/agent/src/mainview/hooks/use-input-history.ts +84 -0
  94. package/templates/agent/src/mainview/hooks/use-rpc-init.ts +61 -0
  95. package/templates/agent/src/mainview/hooks/use-sidebar-resize.ts +40 -0
  96. package/templates/agent/src/mainview/index.css +61 -0
  97. package/templates/agent/src/mainview/index.html +12 -0
  98. package/templates/agent/src/mainview/lib/api-client.ts +192 -0
  99. package/templates/agent/src/mainview/lib/i18n/index.ts +30 -0
  100. package/templates/agent/src/mainview/lib/i18n/locales/en.json +157 -0
  101. package/templates/agent/src/mainview/lib/i18n/locales/zh.json +157 -0
  102. package/templates/agent/src/mainview/lib/rpc-cache.ts +94 -0
  103. package/templates/agent/src/mainview/main.tsx +24 -0
  104. package/templates/agent/src/mainview/stores/__tests__/use-app-store.test.ts +86 -0
  105. package/templates/agent/src/mainview/stores/__tests__/use-bash-store.test.ts +99 -0
  106. package/templates/agent/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
  107. package/templates/agent/src/mainview/stores/__tests__/use-explorer-store.test.ts +130 -0
  108. package/templates/agent/src/mainview/stores/__tests__/use-feed-store.test.ts +132 -0
  109. package/templates/agent/src/mainview/stores/__tests__/use-git-store.test.ts +161 -0
  110. package/templates/agent/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
  111. package/templates/agent/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
  112. package/templates/agent/src/mainview/stores/__tests__/use-notification-store.test.ts +102 -0
  113. package/templates/agent/src/mainview/stores/__tests__/use-rules-store.test.ts +75 -0
  114. package/templates/agent/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
  115. package/templates/agent/src/mainview/stores/__tests__/use-todo-store.test.ts +75 -0
  116. package/templates/agent/src/mainview/stores/message-batcher.ts +25 -0
  117. package/templates/agent/src/mainview/stores/use-app-store.ts +99 -0
  118. package/templates/agent/src/mainview/stores/use-bash-store.ts +93 -0
  119. package/templates/agent/src/mainview/stores/use-chat-store.ts +37 -0
  120. package/templates/agent/src/mainview/stores/use-connection-store.ts +42 -0
  121. package/templates/agent/src/mainview/stores/use-explorer-store.ts +320 -0
  122. package/templates/agent/src/mainview/stores/use-feed-store.ts +129 -0
  123. package/templates/agent/src/mainview/stores/use-git-store.ts +291 -0
  124. package/templates/agent/src/mainview/stores/use-locale-store.ts +27 -0
  125. package/templates/agent/src/mainview/stores/use-log-store.ts +16 -0
  126. package/templates/agent/src/mainview/stores/use-notification-store.ts +82 -0
  127. package/templates/agent/src/mainview/stores/use-rules-store.ts +54 -0
  128. package/templates/agent/src/mainview/stores/use-sidebar-store.ts +99 -0
  129. package/templates/agent/src/mainview/stores/use-theme-store.ts +46 -0
  130. package/templates/agent/src/mainview/stores/use-todo-store.ts +54 -0
  131. package/templates/agent/src/mainview/types/index.ts +33 -0
  132. package/templates/agent/src/mainview/utils/constants.ts +1 -0
  133. package/templates/agent/src/mainview/utils/drop-handler.ts +150 -0
  134. package/templates/agent/src/mainview/utils/file-icon.tsx +24 -0
  135. package/templates/agent/src/mainview/utils/file-utils.ts +35 -0
  136. package/templates/agent/src/server-config.ts +43 -0
  137. package/templates/agent/src/server.ts +89 -0
  138. package/templates/agent/src/shared/handlers/__tests__/bash-handler.test.ts +135 -0
  139. package/templates/agent/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
  140. package/templates/agent/src/shared/handlers/__tests__/feed-handler.test.ts +108 -0
  141. package/templates/agent/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
  142. package/templates/agent/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
  143. package/templates/agent/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
  144. package/templates/agent/src/shared/handlers/bash.ts +89 -0
  145. package/templates/agent/src/shared/handlers/chat.ts +179 -0
  146. package/templates/agent/src/shared/handlers/feed.ts +53 -0
  147. package/templates/agent/src/shared/handlers/file.ts +99 -0
  148. package/templates/agent/src/shared/handlers/git.ts +263 -0
  149. package/templates/agent/src/shared/handlers/index.ts +10 -0
  150. package/templates/agent/src/shared/handlers/rules.ts +45 -0
  151. package/templates/agent/src/shared/handlers/system.ts +27 -0
  152. package/templates/agent/src/shared/handlers/timer.ts +34 -0
  153. package/templates/agent/src/shared/handlers/todo.ts +45 -0
  154. package/templates/agent/src/shared/lib/__tests__/bash-security.test.ts +125 -0
  155. package/templates/agent/src/shared/lib/__tests__/logger.test.ts +92 -0
  156. package/templates/agent/src/shared/lib/__tests__/path-security.test.ts +77 -0
  157. package/templates/agent/src/shared/lib/bash-security.ts +64 -0
  158. package/templates/agent/src/shared/lib/logger.ts +130 -0
  159. package/templates/agent/src/shared/lib/path-security.ts +38 -0
  160. package/templates/agent/src/shared/lib/port-registry.ts +103 -0
  161. package/templates/agent/src/shared/modules/bash.ts +19 -0
  162. package/templates/agent/src/shared/modules/chat.ts +20 -0
  163. package/templates/agent/src/shared/modules/feed.ts +30 -0
  164. package/templates/agent/src/shared/modules/file.ts +40 -0
  165. package/templates/agent/src/shared/modules/git.ts +81 -0
  166. package/templates/agent/src/shared/modules/rules.ts +25 -0
  167. package/templates/agent/src/shared/modules/system.ts +8 -0
  168. package/templates/agent/src/shared/modules/timer.ts +11 -0
  169. package/templates/agent/src/shared/modules/todo.ts +27 -0
  170. package/templates/agent/src/shared/register-all-handlers.ts +36 -0
  171. package/templates/agent/src/shared/rpc-schema.ts +35 -0
  172. package/templates/agent/tailwind.config.js +15 -0
  173. package/templates/agent/tsconfig.json +26 -0
  174. package/templates/agent/vite.config.ts +3 -0
  175. package/templates/agent/vitest.config.ts +3 -0
  176. package/templates/chat/.env.example +6 -0
  177. package/templates/chat/LICENSE +21 -0
  178. package/templates/chat/README.md +56 -0
  179. package/templates/chat/bun.lock +1203 -0
  180. package/templates/chat/electrobun.config.ts +27 -0
  181. package/templates/chat/eslint.config.mjs +56 -0
  182. package/templates/chat/llms.txt +24 -0
  183. package/templates/chat/package-lock.json +3670 -0
  184. package/templates/chat/package.json +58 -0
  185. package/templates/chat/postcss.config.js +6 -0
  186. package/templates/chat/scripts/dev.ts +138 -0
  187. package/templates/chat/src/__tests__/server-config.test.ts +59 -0
  188. package/templates/chat/src/bun/index.ts +72 -0
  189. package/templates/chat/src/gateway/__tests__/ws-handler.test.ts +48 -0
  190. package/templates/chat/src/gateway/http-routes.ts +1 -0
  191. package/templates/chat/src/gateway/ipc-transport.ts +68 -0
  192. package/templates/chat/src/gateway/ws-handler.ts +86 -0
  193. package/templates/chat/src/mainview/App.tsx +108 -0
  194. package/templates/chat/src/mainview/__tests__/components/ChatPanel.test.tsx +76 -0
  195. package/templates/chat/src/mainview/__tests__/components/MessageBubble.test.tsx +48 -0
  196. package/templates/chat/src/mainview/__tests__/i18n/i18n.test.ts +48 -0
  197. package/templates/chat/src/mainview/__tests__/setup-verify.test.ts +8 -0
  198. package/templates/chat/src/mainview/__tests__/setup.ts +37 -0
  199. package/templates/chat/src/mainview/__tests__/stores/use-app-store.test.ts +46 -0
  200. package/templates/chat/src/mainview/__tests__/stores/use-chat-store.test.ts +104 -0
  201. package/templates/chat/src/mainview/__tests__/stores/use-connection-store.test.ts +35 -0
  202. package/templates/chat/src/mainview/__tests__/stores/use-log-store.test.ts +45 -0
  203. package/templates/chat/src/mainview/__tests__/stores/use-notification-store.test.ts +102 -0
  204. package/templates/chat/src/mainview/__tests__/stores/use-sidebar-store.test.ts +89 -0
  205. package/templates/chat/src/mainview/components/activity-bar/ActivityBar.tsx +26 -0
  206. package/templates/chat/src/mainview/components/activity-bar/MobileTabBar.tsx +20 -0
  207. package/templates/chat/src/mainview/components/chat/ChatPanel.tsx +66 -0
  208. package/templates/chat/src/mainview/components/chat/MessageBubble.tsx +85 -0
  209. package/templates/chat/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
  210. package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +24 -0
  211. package/templates/chat/src/mainview/components/sidebar/PinButton.tsx +20 -0
  212. package/templates/chat/src/mainview/global.d.ts +13 -0
  213. package/templates/chat/src/mainview/hooks/use-breakpoint.ts +34 -0
  214. package/templates/chat/src/mainview/hooks/use-input-history.ts +84 -0
  215. package/templates/chat/src/mainview/index.css +61 -0
  216. package/templates/chat/src/mainview/index.html +12 -0
  217. package/templates/chat/src/mainview/lib/api-client.ts +175 -0
  218. package/templates/chat/src/mainview/lib/i18n/index.ts +30 -0
  219. package/templates/chat/src/mainview/lib/i18n/locales/en.json +157 -0
  220. package/templates/chat/src/mainview/lib/i18n/locales/zh.json +157 -0
  221. package/templates/chat/src/mainview/main.tsx +20 -0
  222. package/templates/chat/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
  223. package/templates/chat/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
  224. package/templates/chat/src/mainview/stores/message-batcher.ts +25 -0
  225. package/templates/chat/src/mainview/stores/use-app-store.ts +50 -0
  226. package/templates/chat/src/mainview/stores/use-chat-store.ts +37 -0
  227. package/templates/chat/src/mainview/stores/use-connection-store.ts +42 -0
  228. package/templates/chat/src/mainview/stores/use-locale-store.ts +27 -0
  229. package/templates/chat/src/mainview/stores/use-log-store.ts +16 -0
  230. package/templates/chat/src/mainview/stores/use-notification-store.ts +82 -0
  231. package/templates/chat/src/mainview/stores/use-sidebar-store.ts +98 -0
  232. package/templates/chat/src/mainview/stores/use-theme-store.ts +46 -0
  233. package/templates/chat/src/mainview/types/index.ts +8 -0
  234. package/templates/chat/src/mainview/utils/constants.ts +1 -0
  235. package/templates/chat/src/server-config.ts +42 -0
  236. package/templates/chat/src/server.ts +89 -0
  237. package/templates/chat/src/shared/__tests__/chat-handler.test.ts +71 -0
  238. package/templates/chat/src/shared/__tests__/system-handler.test.ts +70 -0
  239. package/templates/chat/src/shared/handlers/chat.ts +186 -0
  240. package/templates/chat/src/shared/handlers/index.ts +2 -0
  241. package/templates/chat/src/shared/handlers/system.ts +27 -0
  242. package/templates/chat/src/shared/lib/logger.ts +130 -0
  243. package/templates/chat/src/shared/lib/path-security.ts +38 -0
  244. package/templates/chat/src/shared/lib/port-registry.ts +103 -0
  245. package/templates/chat/src/shared/modules/chat.ts +20 -0
  246. package/templates/chat/src/shared/modules/system.ts +8 -0
  247. package/templates/chat/src/shared/register-all-handlers.ts +36 -0
  248. package/templates/chat/src/shared/rpc-schema.ts +11 -0
  249. package/templates/chat/tailwind.config.js +15 -0
  250. package/templates/chat/tsconfig.json +26 -0
  251. package/templates/chat/vite.config.ts +3 -0
  252. package/templates/chat/vitest.config.ts +3 -0
  253. package/templates/general/.env.example +7 -0
  254. package/templates/general/LICENSE +21 -0
  255. package/templates/general/README.md +113 -0
  256. package/templates/general/bun.lock +1266 -0
  257. package/templates/general/electrobun.config.ts +27 -0
  258. package/templates/general/eslint.config.mjs +56 -0
  259. package/templates/general/llms.txt +24 -0
  260. package/templates/general/package-lock.json +3670 -0
  261. package/templates/general/package.json +59 -0
  262. package/templates/general/postcss.config.js +6 -0
  263. package/templates/general/scripts/dev.ts +138 -0
  264. package/templates/general/src/__tests__/server-config.test.ts +59 -0
  265. package/templates/general/src/bun/index.ts +72 -0
  266. package/templates/general/src/gateway/http-routes.ts +1 -0
  267. package/templates/general/src/gateway/ipc-transport.ts +68 -0
  268. package/templates/general/src/gateway/ws-handler.ts +86 -0
  269. package/templates/general/src/mainview/App.tsx +40 -0
  270. package/templates/general/src/mainview/__tests__/components/ChatPanel.test.tsx +82 -0
  271. package/templates/general/src/mainview/__tests__/components/FeedPanel.test.tsx +109 -0
  272. package/templates/general/src/mainview/__tests__/components/GitPanel.test.tsx +151 -0
  273. package/templates/general/src/mainview/__tests__/i18n/i18n.test.ts +48 -0
  274. package/templates/general/src/mainview/__tests__/setup-verify.test.ts +8 -0
  275. package/templates/general/src/mainview/__tests__/setup.ts +37 -0
  276. package/templates/general/src/mainview/components/activity-bar/ActivityBar.tsx +40 -0
  277. package/templates/general/src/mainview/components/activity-bar/MobileTabBar.tsx +29 -0
  278. package/templates/general/src/mainview/components/chat/ChatPanel.tsx +66 -0
  279. package/templates/general/src/mainview/components/chat/MessageBubble.tsx +85 -0
  280. package/templates/general/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
  281. package/templates/general/src/mainview/components/common/ThemeToggle.tsx +24 -0
  282. package/templates/general/src/mainview/components/debug/DebugPanel.tsx +176 -0
  283. package/templates/general/src/mainview/components/diff/DiffViewerPanel.tsx +108 -0
  284. package/templates/general/src/mainview/components/explorer/ConfirmDialog.tsx +52 -0
  285. package/templates/general/src/mainview/components/explorer/ContextMenu.tsx +82 -0
  286. package/templates/general/src/mainview/components/explorer/ExplorerSidebar.tsx +225 -0
  287. package/templates/general/src/mainview/components/explorer/InlineInput.tsx +55 -0
  288. package/templates/general/src/mainview/components/explorer/TreeNodeItem.tsx +121 -0
  289. package/templates/general/src/mainview/components/feed/FeedPanel.tsx +248 -0
  290. package/templates/general/src/mainview/components/file-preview/FilePreviewOverlay.tsx +55 -0
  291. package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +99 -0
  292. package/templates/general/src/mainview/components/git/GitBranchSelector.tsx +93 -0
  293. package/templates/general/src/mainview/components/git/GitCommitInput.tsx +60 -0
  294. package/templates/general/src/mainview/components/git/GitPanel.tsx +533 -0
  295. package/templates/general/src/mainview/components/layout/AppLayout.tsx +146 -0
  296. package/templates/general/src/mainview/components/search/SearchPanel.tsx +405 -0
  297. package/templates/general/src/mainview/components/sidebar/PinButton.tsx +20 -0
  298. package/templates/general/src/mainview/global.d.ts +13 -0
  299. package/templates/general/src/mainview/hooks/use-breakpoint.ts +34 -0
  300. package/templates/general/src/mainview/hooks/use-input-history.ts +84 -0
  301. package/templates/general/src/mainview/hooks/use-rpc-init.ts +61 -0
  302. package/templates/general/src/mainview/hooks/use-sidebar-resize.ts +40 -0
  303. package/templates/general/src/mainview/index.css +61 -0
  304. package/templates/general/src/mainview/index.html +12 -0
  305. package/templates/general/src/mainview/lib/api-client.ts +175 -0
  306. package/templates/general/src/mainview/lib/i18n/index.ts +30 -0
  307. package/templates/general/src/mainview/lib/i18n/locales/en.json +157 -0
  308. package/templates/general/src/mainview/lib/i18n/locales/zh.json +157 -0
  309. package/templates/general/src/mainview/main.tsx +20 -0
  310. package/templates/general/src/mainview/stores/__tests__/use-chat-store.test.ts +104 -0
  311. package/templates/general/src/mainview/stores/__tests__/use-connection-store.test.ts +35 -0
  312. package/templates/general/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
  313. package/templates/general/src/mainview/stores/__tests__/use-log-store.test.ts +45 -0
  314. package/templates/general/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
  315. package/templates/general/src/mainview/stores/message-batcher.ts +25 -0
  316. package/templates/general/src/mainview/stores/use-app-store.ts +104 -0
  317. package/templates/general/src/mainview/stores/use-chat-store.ts +37 -0
  318. package/templates/general/src/mainview/stores/use-connection-store.ts +42 -0
  319. package/templates/general/src/mainview/stores/use-explorer-store.ts +315 -0
  320. package/templates/general/src/mainview/stores/use-feed-store.ts +129 -0
  321. package/templates/general/src/mainview/stores/use-git-store.ts +284 -0
  322. package/templates/general/src/mainview/stores/use-locale-store.ts +27 -0
  323. package/templates/general/src/mainview/stores/use-log-store.ts +16 -0
  324. package/templates/general/src/mainview/stores/use-notification-store.ts +82 -0
  325. package/templates/general/src/mainview/stores/use-sidebar-store.ts +99 -0
  326. package/templates/general/src/mainview/stores/use-theme-store.ts +46 -0
  327. package/templates/general/src/mainview/types/index.ts +33 -0
  328. package/templates/general/src/mainview/utils/constants.ts +1 -0
  329. package/templates/general/src/mainview/utils/drop-handler.ts +150 -0
  330. package/templates/general/src/mainview/utils/file-icon.tsx +24 -0
  331. package/templates/general/src/mainview/utils/file-utils.ts +35 -0
  332. package/templates/general/src/server-config.ts +42 -0
  333. package/templates/general/src/server.ts +89 -0
  334. package/templates/general/src/shared/handlers/__tests__/chat.test.ts +183 -0
  335. package/templates/general/src/shared/handlers/__tests__/system.test.ts +94 -0
  336. package/templates/general/src/shared/handlers/__tests__/timer.test.ts +113 -0
  337. package/templates/general/src/shared/handlers/chat.ts +179 -0
  338. package/templates/general/src/shared/handlers/feed.ts +53 -0
  339. package/templates/general/src/shared/handlers/file.ts +99 -0
  340. package/templates/general/src/shared/handlers/git.ts +263 -0
  341. package/templates/general/src/shared/handlers/index.ts +7 -0
  342. package/templates/general/src/shared/handlers/system.ts +27 -0
  343. package/templates/general/src/shared/handlers/timer.ts +34 -0
  344. package/templates/general/src/shared/lib/logger.ts +130 -0
  345. package/templates/general/src/shared/lib/path-security.ts +38 -0
  346. package/templates/general/src/shared/lib/port-registry.ts +103 -0
  347. package/templates/general/src/shared/modules/chat.ts +20 -0
  348. package/templates/general/src/shared/modules/feed.ts +30 -0
  349. package/templates/general/src/shared/modules/file.ts +40 -0
  350. package/templates/general/src/shared/modules/git.ts +81 -0
  351. package/templates/general/src/shared/modules/system.ts +8 -0
  352. package/templates/general/src/shared/modules/timer.ts +11 -0
  353. package/templates/general/src/shared/register-all-handlers.ts +36 -0
  354. package/templates/general/src/shared/rpc-schema.ts +31 -0
  355. package/templates/general/tailwind.config.js +15 -0
  356. package/templates/general/tsconfig.json +26 -0
  357. package/templates/general/vite.config.ts +3 -0
  358. package/templates/general/vitest.config.ts +3 -0
@@ -0,0 +1,92 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdirSync, existsSync, readdirSync, readFileSync, writeFileSync, rmSync, utimesSync } from "fs";
3
+ import { join } from "path";
4
+
5
+ const TEST_LOG_DIR = join(process.cwd(), "test-logs");
6
+
7
+ describe("Logger", () => {
8
+ beforeEach(async () => {
9
+ if (existsSync(TEST_LOG_DIR)) {
10
+ rmSync(TEST_LOG_DIR, { recursive: true, force: true });
11
+ }
12
+ mkdirSync(TEST_LOG_DIR, { recursive: true });
13
+ });
14
+
15
+ afterEach(() => {
16
+ if (existsSync(TEST_LOG_DIR)) {
17
+ rmSync(TEST_LOG_DIR, { recursive: true, force: true });
18
+ }
19
+ });
20
+
21
+ it("should write logs asynchronously", async () => {
22
+ const { createLogger, configureLogDir, flushLogs } = await import("../logger");
23
+ await configureLogDir(TEST_LOG_DIR);
24
+
25
+ const logger = createLogger("test");
26
+ logger.info("test message");
27
+
28
+ await flushLogs();
29
+ await new Promise((r) => setTimeout(r, 100));
30
+
31
+ const files = readdirSync(TEST_LOG_DIR);
32
+ expect(files.length).toBeGreaterThan(0);
33
+
34
+ const content = readFileSync(join(TEST_LOG_DIR, files[0]), "utf-8");
35
+ expect(content).toContain("test message");
36
+ });
37
+
38
+ it("should support multiple log levels", async () => {
39
+ const { createLogger, configureLogDir, flushLogs } = await import("../logger");
40
+ await configureLogDir(TEST_LOG_DIR);
41
+
42
+ const logger = createLogger("test");
43
+ logger.debug("debug msg");
44
+ logger.info("info msg");
45
+ logger.warn("warn msg");
46
+ logger.error("error msg");
47
+
48
+ await flushLogs();
49
+
50
+ const files = readdirSync(TEST_LOG_DIR);
51
+ const content = readFileSync(join(TEST_LOG_DIR, files[0]), "utf-8");
52
+ expect(content).toContain("info msg");
53
+ expect(content).toContain("warn msg");
54
+ expect(content).toContain("error msg");
55
+ });
56
+
57
+ it("should clean up old log files based on maxAgeDays", async () => {
58
+ const { configureLogDir } = await import("../logger");
59
+
60
+ const oldDate = new Date(Date.now() - 10 * 86400000).toISOString().slice(0, 10);
61
+ const oldPath = join(TEST_LOG_DIR, `${oldDate}.log`);
62
+ writeFileSync(oldPath, "old log");
63
+ const oldTime = new Date(Date.now() - 10 * 86400000);
64
+ utimesSync(oldPath, oldTime, oldTime);
65
+
66
+ const todayFile = new Date().toISOString().slice(0, 10);
67
+ writeFileSync(join(TEST_LOG_DIR, `${todayFile}.log`), "today log");
68
+
69
+ await configureLogDir(TEST_LOG_DIR, { maxAgeDays: 5 });
70
+
71
+ const files = readdirSync(TEST_LOG_DIR);
72
+ expect(files.find((f) => f.includes(oldDate))).toBeUndefined();
73
+ expect(files.find((f) => f.includes(todayFile))).toBeDefined();
74
+ });
75
+
76
+ it("should flush all pending writes", async () => {
77
+ const { createLogger, configureLogDir, flushLogs } = await import("../logger");
78
+ await configureLogDir(TEST_LOG_DIR);
79
+
80
+ const logger = createLogger("test");
81
+ for (let i = 0; i < 100; i++) {
82
+ logger.info(`msg ${i}`);
83
+ }
84
+
85
+ await flushLogs();
86
+
87
+ const files = readdirSync(TEST_LOG_DIR);
88
+ const content = readFileSync(join(TEST_LOG_DIR, files[0]), "utf-8");
89
+ expect(content).toContain("msg 0");
90
+ expect(content).toContain("msg 99");
91
+ });
92
+ });
@@ -0,0 +1,77 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { validatePath, isRpcPathAllowed, setAllowedRoots } from "../path-security";
3
+
4
+ describe("path-security", () => {
5
+ const originalCwd = process.cwd();
6
+ const originalEnv = process.env.NODE_ENV;
7
+
8
+ beforeEach(() => {
9
+ setAllowedRoots([process.cwd()]);
10
+ });
11
+
12
+ afterEach(() => {
13
+ process.env.NODE_ENV = originalEnv;
14
+ });
15
+
16
+ describe("isRpcPathAllowed", () => {
17
+ it("should allow paths within project root", () => {
18
+ expect(isRpcPathAllowed(`${originalCwd}/src/main.ts`)).toBe(true);
19
+ });
20
+
21
+ it("should allow project root itself", () => {
22
+ expect(isRpcPathAllowed(originalCwd)).toBe(true);
23
+ });
24
+
25
+ it("should reject paths outside project root", () => {
26
+ expect(isRpcPathAllowed("/etc/passwd")).toBe(false);
27
+ expect(isRpcPathAllowed("/etc/shadow")).toBe(false);
28
+ });
29
+
30
+ it("should reject path traversal attempts", () => {
31
+ expect(isRpcPathAllowed(`${originalCwd}/../../../etc/passwd`)).toBe(false);
32
+ });
33
+
34
+ it("should reject paths with encoded traversal", () => {
35
+ expect(isRpcPathAllowed(`${originalCwd}/%2e%2e/etc/passwd`)).toBe(false);
36
+ });
37
+
38
+ it("should handle relative paths", () => {
39
+ expect(isRpcPathAllowed("./src/main.ts")).toBe(true);
40
+ expect(isRpcPathAllowed("../../etc/passwd")).toBe(false);
41
+ });
42
+
43
+ it("should handle null bytes", () => {
44
+ expect(isRpcPathAllowed(`${originalCwd}/file.txt\0/etc/passwd`)).toBe(false);
45
+ });
46
+
47
+ it("should work with multiple allowed roots", () => {
48
+ setAllowedRoots([originalCwd, "/tmp/test"]);
49
+ expect(isRpcPathAllowed("/tmp/test/file.txt")).toBe(true);
50
+ expect(isRpcPathAllowed("/tmp/other/file.txt")).toBe(false);
51
+ });
52
+ });
53
+
54
+ describe("validatePath", () => {
55
+ it("should return resolved path for allowed paths", () => {
56
+ const result = validatePath("./src/main.ts");
57
+ expect(result).toContain("src/main.ts");
58
+ });
59
+
60
+ it("should throw for paths outside allowed roots", () => {
61
+ expect(() => validatePath("/etc/passwd")).toThrow("Access denied");
62
+ });
63
+
64
+ it("should throw for path traversal attempts", () => {
65
+ expect(() => validatePath("../../../etc/passwd")).toThrow("Access denied");
66
+ });
67
+
68
+ it("should throw for null byte injection", () => {
69
+ expect(() => validatePath("file.txt\0/evil")).toThrow("Access denied");
70
+ });
71
+
72
+ it("should normalize the returned path", () => {
73
+ const result = validatePath("./src/../src/./main.ts");
74
+ expect(result).toBe(`${originalCwd}/src/main.ts`);
75
+ });
76
+ });
77
+ });
@@ -0,0 +1,64 @@
1
+ export interface CommandPolicy {
2
+ enabled: boolean;
3
+ blockedPatterns: RegExp[];
4
+ allowedCommands: string[] | null;
5
+ }
6
+
7
+ let policy: CommandPolicy = {
8
+ enabled: true,
9
+ blockedPatterns: [
10
+ /rm\s+-rf\s+(.*\s)?\/($|\s)/,
11
+ /rm\s+-rf\s+--no-preserve-root/,
12
+ /mkfs/,
13
+ /dd\s+if=/,
14
+ />\s*\/dev\//,
15
+ /:()\s*\{.*\|.*&\s*\}/,
16
+ /shutdown/,
17
+ /reboot/,
18
+ ],
19
+ allowedCommands: null,
20
+ };
21
+
22
+ export function setCommandPolicy(p: CommandPolicy): void {
23
+ policy = p;
24
+ }
25
+
26
+ export function isCommandAllowed(command: string): boolean {
27
+ if (!policy.enabled) return false;
28
+
29
+ const trimmed = command.trim();
30
+ if (!trimmed) return false;
31
+
32
+ for (const pattern of policy.blockedPatterns) {
33
+ if (pattern.test(trimmed)) return false;
34
+ }
35
+
36
+ if (policy.allowedCommands) {
37
+ const baseCommand = trimmed.split(/\s+/)[0];
38
+ return policy.allowedCommands.some(
39
+ (allowed) => baseCommand === allowed || baseCommand.startsWith(allowed),
40
+ );
41
+ }
42
+
43
+ return true;
44
+ }
45
+
46
+ export function validateCommand(command: string): string {
47
+ if (!policy.enabled) {
48
+ throw new Error("Bash execution is disabled");
49
+ }
50
+
51
+ const trimmed = command.trim();
52
+ if (!trimmed) {
53
+ throw new Error("Command cannot be empty");
54
+ }
55
+
56
+ if (!isCommandAllowed(trimmed)) {
57
+ if (policy.allowedCommands) {
58
+ throw new Error(`Command not in whitelist: "${trimmed}"`);
59
+ }
60
+ throw new Error(`Command blocked for safety: "${trimmed}"`);
61
+ }
62
+
63
+ return trimmed;
64
+ }
@@ -0,0 +1,130 @@
1
+ import { appendFile, mkdir as mkdirAsync, readdir as readdirAsync, unlink as unlinkAsync, stat as statAsync } from "fs/promises";
2
+ import { mkdirSync, existsSync } from "fs";
3
+ import { join } from "path";
4
+
5
+ export type LogModule = "server" | "gateway" | "system" | "chat" | "file" | "timer" | "git" | "feed";
6
+ type LogLevel = "debug" | "info" | "warn" | "error";
7
+
8
+ interface LogEntry {
9
+ timestamp: string;
10
+ level: LogLevel;
11
+ module: LogModule;
12
+ message: string;
13
+ data?: Record<string, unknown>;
14
+ }
15
+
16
+ let _logDir: string | null = null;
17
+ let _maxAgeDays = 30;
18
+
19
+ export async function configureLogDir(dir: string, options?: { maxAgeDays?: number }): Promise<void> {
20
+ _logDir = dir;
21
+ if (options?.maxAgeDays !== undefined) {
22
+ _maxAgeDays = options.maxAgeDays;
23
+ }
24
+ if (!existsSync(dir)) {
25
+ mkdirSync(dir, { recursive: true });
26
+ }
27
+ await cleanOldLogs(dir, _maxAgeDays);
28
+ }
29
+
30
+ function getLogDir(): string {
31
+ if (!_logDir) {
32
+ _logDir = "logs";
33
+ if (!existsSync(_logDir)) {
34
+ mkdirSync(_logDir, { recursive: true });
35
+ }
36
+ }
37
+ return _logDir;
38
+ }
39
+
40
+ async function cleanOldLogs(dir: string, maxAgeDays: number): Promise<void> {
41
+ try {
42
+ if (!existsSync(dir)) return;
43
+ const files = await readdirAsync(dir);
44
+ const cutoff = Date.now() - maxAgeDays * 86400000;
45
+ for (const f of files) {
46
+ if (!f.endsWith(".log")) continue;
47
+ const filePath = join(dir, f);
48
+ const s = await statAsync(filePath);
49
+ if (s.mtimeMs < cutoff) {
50
+ await unlinkAsync(filePath);
51
+ }
52
+ }
53
+ } catch { /* ignore */ }
54
+ }
55
+
56
+ function formatLine(entry: LogEntry): string {
57
+ const base = `[${entry.timestamp}] [${entry.level.toUpperCase()}] [${entry.module}] ${entry.message}`;
58
+ return entry.data ? `${base} ${JSON.stringify(entry.data)}` : base;
59
+ }
60
+
61
+ let writeQueue: Promise<void> = Promise.resolve();
62
+
63
+ function writeToFile(line: string): void {
64
+ writeQueue = writeQueue.then(async () => {
65
+ try {
66
+ const date = new Date().toISOString().slice(0, 10);
67
+ const dir = getLogDir();
68
+ if (!existsSync(dir)) {
69
+ await mkdirAsync(dir, { recursive: true });
70
+ }
71
+ await appendFile(join(dir, `${date}.log`), `${line}\n`);
72
+ } catch { /* ignore */ }
73
+ });
74
+ }
75
+
76
+ export function flushLogs(): Promise<void> {
77
+ return writeQueue;
78
+ }
79
+
80
+ export class Logger {
81
+ private readonly module: LogModule;
82
+
83
+ constructor(module: LogModule) {
84
+ this.module = module;
85
+ }
86
+
87
+ debug(message: string, data?: Record<string, unknown>): void {
88
+ this.write("debug", message, data);
89
+ }
90
+
91
+ info(message: string, data?: Record<string, unknown>): void {
92
+ this.write("info", message, data);
93
+ }
94
+
95
+ warn(message: string, data?: Record<string, unknown>): void {
96
+ this.write("warn", message, data);
97
+ }
98
+
99
+ error(message: string, data?: Record<string, unknown>): void {
100
+ this.write("error", message, data);
101
+ }
102
+
103
+ private write(level: LogLevel, message: string, data?: Record<string, unknown>): void {
104
+ const entry: LogEntry = {
105
+ timestamp: new Date().toISOString(),
106
+ level,
107
+ module: this.module,
108
+ message,
109
+ ...(data ? { data } : {}),
110
+ };
111
+
112
+ const line = formatLine(entry);
113
+
114
+ if (level === "error") {
115
+ console.error(line);
116
+ } else if (level === "warn") {
117
+ console.warn(line);
118
+ } else {
119
+ console.log(line);
120
+ }
121
+
122
+ if (process.env.NODE_ENV !== "production" || level !== "debug") {
123
+ writeToFile(line);
124
+ }
125
+ }
126
+ }
127
+
128
+ export function createLogger(module: LogModule): Logger {
129
+ return new Logger(module);
130
+ }
@@ -0,0 +1,38 @@
1
+ import { resolve } from "path";
2
+
3
+ let allowedRoots: string[] = [process.cwd()];
4
+
5
+ export function setAllowedRoots(roots: string[]): void {
6
+ allowedRoots = roots.map((r) => resolve(r));
7
+ }
8
+
9
+ export function isRpcPathAllowed(requestedPath: string): boolean {
10
+ try {
11
+ if (requestedPath.includes("\0")) return false;
12
+
13
+ const decoded = decodeURIComponent(requestedPath);
14
+ const resolved = resolve(decoded);
15
+ return allowedRoots.some(
16
+ (root) => resolved === root || resolved.startsWith(root + "/")
17
+ );
18
+ } catch {
19
+ return false;
20
+ }
21
+ }
22
+
23
+ export function validatePath(requestedPath: string): string {
24
+ if (requestedPath.includes("\0")) {
25
+ throw new Error(`Access denied: path contains null bytes`);
26
+ }
27
+
28
+ const decoded = decodeURIComponent(requestedPath);
29
+ const resolved = resolve(decoded);
30
+
31
+ if (!isRpcPathAllowed(resolved)) {
32
+ throw new Error(
33
+ `Access denied: path "${requestedPath}" is outside allowed roots`
34
+ );
35
+ }
36
+
37
+ return resolved;
38
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Global port registry — tracks all running pi-agent instances.
3
+ *
4
+ * File: ~/.pi-agent/ports.json
5
+ *
6
+ * Format:
7
+ * {
8
+ * "/absolute/project/path": {
9
+ * "port": 3101,
10
+ * "pid": 12345,
11
+ * "startedAt": "2026-04-29T08:00:00.000Z",
12
+ * "name": "my-project"
13
+ * }
14
+ * }
15
+ */
16
+
17
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
18
+ import { join, basename } from "path";
19
+ import { homedir } from "os";
20
+
21
+ const REGISTRY_DIR = join(homedir(), ".pi-agent");
22
+ const REGISTRY_FILE = join(REGISTRY_DIR, "ports.json");
23
+
24
+ export interface PortEntry {
25
+ port: number;
26
+ pid: number;
27
+ startedAt: string;
28
+ name: string;
29
+ }
30
+
31
+ export type PortRegistry = Record<string, PortEntry>;
32
+
33
+ function ensureDir() {
34
+ if (!existsSync(REGISTRY_DIR)) {
35
+ mkdirSync(REGISTRY_DIR, { recursive: true });
36
+ }
37
+ }
38
+
39
+ export function readRegistry(): PortRegistry {
40
+ try {
41
+ if (!existsSync(REGISTRY_FILE)) return {};
42
+ return JSON.parse(readFileSync(REGISTRY_FILE, "utf-8"));
43
+ } catch {
44
+ return {};
45
+ }
46
+ }
47
+
48
+ function writeRegistry(registry: PortRegistry): void {
49
+ ensureDir();
50
+ writeFileSync(REGISTRY_FILE, JSON.stringify(registry, null, 2), "utf-8");
51
+ }
52
+
53
+ export function registerPort(projectPath: string, port: number, name: string): void {
54
+ const registry = readRegistry();
55
+ registry[projectPath] = {
56
+ port,
57
+ pid: process.pid,
58
+ startedAt: new Date().toISOString(),
59
+ name: name || basename(projectPath),
60
+ };
61
+ writeRegistry(registry);
62
+ }
63
+
64
+ export function unregisterPort(projectPath: string): void {
65
+ const registry = readRegistry();
66
+ delete registry[projectPath];
67
+ if (Object.keys(registry).length === 0) {
68
+ writeRegistry(registry);
69
+ } else {
70
+ writeRegistry(registry);
71
+ }
72
+ }
73
+
74
+ export function cleanupStaleEntries(): void {
75
+ const registry = readRegistry();
76
+ let changed = false;
77
+ for (const [path, entry] of Object.entries(registry)) {
78
+ try {
79
+ process.kill(entry.pid, 0);
80
+ } catch {
81
+ delete registry[path];
82
+ changed = true;
83
+ }
84
+ }
85
+ if (changed) writeRegistry(registry);
86
+ }
87
+
88
+ export function formatRegistryForOutput(): string {
89
+ cleanupStaleEntries();
90
+ const registry = readRegistry();
91
+ const entries = Object.entries(registry);
92
+ if (entries.length === 0) return "No active instances.";
93
+
94
+ const lines = entries.map(([path, entry]) => {
95
+ const uptime = Math.round((Date.now() - new Date(entry.startedAt).getTime()) / 1000);
96
+ const uptimeStr = uptime < 60 ? `${uptime}s` : uptime < 3600 ? `${Math.floor(uptime / 60)}m ${uptime % 60}s` : `${Math.floor(uptime / 3600)}h ${Math.floor((uptime % 3600) / 60)}m`;
97
+ return ` ${entry.name} → http://localhost:${entry.port} (PID ${entry.pid}, up ${uptimeStr})\n ${path}`;
98
+ });
99
+
100
+ return `Active pi-agent instances (${entries.length}):\n${lines.join("\n\n")}\n\nRegistry: ${REGISTRY_FILE}`;
101
+ }
102
+
103
+ export { REGISTRY_FILE };
@@ -0,0 +1,19 @@
1
+ export interface BashMethods {
2
+ "bash.execute": {
3
+ params: { command: string; cwd?: string };
4
+ result: { pid: number; output: string };
5
+ };
6
+ "bash.kill": {
7
+ params: { pid: number };
8
+ result: { success: boolean };
9
+ };
10
+ "bash.listProcesses": {
11
+ params: {};
12
+ result: { processes: Array<{ pid: number; command: string; running: boolean }> };
13
+ };
14
+ }
15
+
16
+ export interface BashEvents {
17
+ "bash.output": { pid: number; data: string; stream: "stdout" | "stderr" };
18
+ "bash.exit": { pid: number; code: number | null };
19
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Chat 模块 — 聊天消息
3
+ */
4
+ export interface ChatMethods {
5
+ "chat.list": {
6
+ params: { limit?: number; cursor?: string };
7
+ result: {
8
+ messages: { id: string; role: "user" | "assistant"; content: string; timestamp: number }[];
9
+ hasMore: boolean;
10
+ };
11
+ };
12
+ "chat.send": {
13
+ params: { content: string };
14
+ result: { ok: boolean };
15
+ };
16
+ }
17
+
18
+ export interface ChatEvents {
19
+ "chat.message": { id: string; role: "user" | "assistant"; content: string; timestamp: number };
20
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Feed 模块 — 帖子 & 频道订阅过滤
3
+ */
4
+
5
+ type FeedCategory = "tech" | "news" | "general";
6
+
7
+ interface FeedPost {
8
+ id: string;
9
+ content: string;
10
+ category: FeedCategory;
11
+ author: string;
12
+ timestamp: number;
13
+ }
14
+
15
+ export interface FeedMethods {
16
+ "feed.post": {
17
+ params: { content: string; category: FeedCategory; author?: string };
18
+ result: { id: string };
19
+ };
20
+ "feed.list": {
21
+ params: { category?: FeedCategory; limit?: number };
22
+ result: { posts: FeedPost[] };
23
+ };
24
+ }
25
+
26
+ export interface FeedEvents {
27
+ "feed.update": FeedPost;
28
+ }
29
+
30
+ export type { FeedCategory, FeedPost };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * File 模块 — 文件系统操作
3
+ */
4
+ export interface FileMethods {
5
+ "file.findProjectRoot": {
6
+ params: Record<string, never>;
7
+ result: { path: string };
8
+ };
9
+ "file.listDir": {
10
+ params: { path: string };
11
+ result: {
12
+ entries: { name: string; path: string; type: "file" | "directory"; size?: number }[];
13
+ basePath: string;
14
+ };
15
+ };
16
+ "file.createFile": {
17
+ params: { dirPath: string; name: string };
18
+ result: { path: string };
19
+ };
20
+ "file.createDir": {
21
+ params: { dirPath: string; name: string };
22
+ result: { path: string };
23
+ };
24
+ "file.rename": {
25
+ params: { oldPath: string; newName: string };
26
+ result: { newPath: string };
27
+ };
28
+ "file.delete": {
29
+ params: { path: string };
30
+ result: { ok: boolean };
31
+ };
32
+ "file.copy": {
33
+ params: { srcPath: string; destDir: string };
34
+ result: { path: string };
35
+ };
36
+ "file.readFile": {
37
+ params: { path: string };
38
+ result: { content: string; size: number };
39
+ };
40
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Git 模块 — 版本控制操作
3
+ */
4
+ export interface GitMethods {
5
+ "git.status": {
6
+ params: { repoPath: string };
7
+ result: {
8
+ staged: GitFileChange[];
9
+ changed: GitFileChange[];
10
+ untracked: string[];
11
+ branch: string;
12
+ ahead: number;
13
+ behind: number;
14
+ };
15
+ };
16
+ "git.diff": {
17
+ params: { repoPath: string; filePath: string; staged?: boolean };
18
+ result: { filePath: string; diff: string; oldContent: string; newContent: string };
19
+ };
20
+ "git.log": {
21
+ params: { repoPath: string; maxCount?: number };
22
+ result: {
23
+ commits: {
24
+ hash: string;
25
+ shortHash: string;
26
+ message: string;
27
+ author: string;
28
+ date: string;
29
+ }[];
30
+ };
31
+ };
32
+ "git.commitFiles": {
33
+ params: { repoPath: string; hash: string };
34
+ result: { files: GitFileChange[] };
35
+ };
36
+ "git.commitFileDiff": {
37
+ params: { repoPath: string; hash: string; filePath: string };
38
+ result: { filePath: string; diff: string; oldContent: string; newContent: string };
39
+ };
40
+ "git.branches": {
41
+ params: { repoPath: string };
42
+ result: {
43
+ branches: { name: string; isCurrent: boolean; isRemote: boolean }[];
44
+ };
45
+ };
46
+ "git.checkout": {
47
+ params: { repoPath: string; branch: string };
48
+ result: { ok: boolean };
49
+ };
50
+ "git.add": {
51
+ params: { repoPath: string; paths: string[] };
52
+ result: { ok: boolean };
53
+ };
54
+ "git.reset": {
55
+ params: { repoPath: string; paths: string[] };
56
+ result: { ok: boolean };
57
+ };
58
+ "git.commit": {
59
+ params: { repoPath: string; message: string };
60
+ result: { hash: string; shortHash: string };
61
+ };
62
+ "git.push": {
63
+ params: { repoPath: string };
64
+ result: { ok: boolean };
65
+ };
66
+ "git.pull": {
67
+ params: { repoPath: string };
68
+ result: { ok: boolean };
69
+ };
70
+ "git.worktreeList": {
71
+ params: { repoPath: string };
72
+ result: {
73
+ worktrees: { path: string; branch: string; isMain: boolean }[];
74
+ };
75
+ };
76
+ }
77
+
78
+ export interface GitFileChange {
79
+ path: string;
80
+ status: "modified" | "added" | "deleted" | "renamed" | "copied";
81
+ }