@agentprojectcontext/apx 1.25.0 → 1.27.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 (718) hide show
  1. package/package.json +42 -12
  2. package/skills/apx/SKILL.md +50 -119
  3. package/skills/apx-agency-agents/SKILL.md +141 -0
  4. package/skills/apx-agent/SKILL.md +100 -0
  5. package/skills/apx-mcp/SKILL.md +114 -0
  6. package/skills/apx-mcp-builder/SKILL.md +186 -0
  7. package/skills/apx-project/SKILL.md +100 -0
  8. package/skills/apx-routine/SKILL.md +138 -0
  9. package/skills/apx-runtime/SKILL.md +115 -0
  10. package/skills/apx-sessions/SKILL.md +281 -0
  11. package/skills/apx-skill-builder/SKILL.md +149 -0
  12. package/skills/apx-task/SKILL.md +95 -0
  13. package/skills/apx-telegram/SKILL.md +115 -0
  14. package/skills/apx-voice/SKILL.md +135 -0
  15. package/src/core/agent/constants.js +3 -0
  16. package/src/core/agent/ghost-guard.js +24 -0
  17. package/src/core/agent/index.js +35 -0
  18. package/src/core/agent/model-router.js +257 -0
  19. package/src/core/agent/prompt-builder.js +313 -0
  20. package/src/core/agent/prompts/channels/api.md +7 -0
  21. package/src/core/agent/prompts/channels/cli.md +6 -0
  22. package/src/core/agent/prompts/channels/code.md +20 -0
  23. package/src/core/agent/prompts/channels/deck.md +6 -0
  24. package/src/core/agent/prompts/channels/desktop.md +24 -0
  25. package/src/core/agent/prompts/channels/routine.md +9 -0
  26. package/src/core/agent/prompts/channels/telegram.md +9 -0
  27. package/src/core/agent/prompts/channels/terminal.md +16 -0
  28. package/src/core/agent/prompts/channels/web.md +7 -0
  29. package/src/core/agent/prompts/channels/web_sidebar.md +7 -0
  30. package/src/core/agent/prompts/modes/voice.md +4 -0
  31. package/src/core/agent/prompts/super-agent-base.md +42 -0
  32. package/src/core/agent/pseudo-tools.js +40 -0
  33. package/src/core/agent/retry.js +85 -0
  34. package/src/core/agent/run-agent.js +423 -0
  35. package/src/core/agent/self-memory.js +155 -0
  36. package/src/{daemon → core/agent}/tool-call-parser.js +83 -10
  37. package/src/core/agent/tools-overlap.js +66 -0
  38. package/src/core/apc-skill-sync.js +97 -0
  39. package/src/core/code-sessions-store.js +150 -0
  40. package/src/core/config.js +473 -11
  41. package/src/core/desktop/autostart.js +162 -0
  42. package/src/core/engines/_health.js +63 -0
  43. package/src/{daemon → core}/engines/anthropic.js +16 -0
  44. package/src/core/engines/gemini.js +168 -0
  45. package/src/core/engines/groq.js +8 -0
  46. package/src/{daemon → core}/engines/index.js +3 -1
  47. package/src/{daemon → core}/engines/mock.js +22 -0
  48. package/src/{daemon → core}/engines/ollama.js +35 -0
  49. package/src/core/engines/openai-compatible.js +145 -0
  50. package/src/core/engines/openai.js +8 -0
  51. package/src/core/engines/openrouter.js +8 -0
  52. package/src/core/git-baseline.js +147 -0
  53. package/src/core/identity.js +21 -0
  54. package/src/core/logging.js +1 -1
  55. package/src/core/mcp/index.js +14 -0
  56. package/src/{daemon/mcp-runner.js → core/mcp/runner.js} +18 -6
  57. package/src/core/mcp/sources.js +246 -0
  58. package/src/core/memory/active-threads.js +124 -0
  59. package/src/core/memory/broker.js +144 -0
  60. package/src/core/memory/compactor.js +186 -0
  61. package/src/core/memory/embed-engines/gemini.js +62 -0
  62. package/src/core/memory/embed-engines/index.js +148 -0
  63. package/src/core/memory/embed-engines/ollama.js +55 -0
  64. package/src/core/memory/embed-engines/openai.js +64 -0
  65. package/src/core/memory/embed-engines/tf.js +20 -0
  66. package/src/core/memory/embeddings.js +132 -0
  67. package/src/core/memory/index.js +161 -0
  68. package/src/core/memory/indexer.js +257 -0
  69. package/src/core/memory/store.js +231 -0
  70. package/src/core/messages-store.js +143 -25
  71. package/src/core/parser.js +78 -16
  72. package/src/core/scaffold.js +175 -79
  73. package/src/core/tasks-store.js +264 -0
  74. package/src/core/telegram-identity.js +126 -0
  75. package/src/core/tools/index.js +6 -0
  76. package/src/core/voice/engines/elevenlabs.js +96 -0
  77. package/src/core/voice/engines/gemini.js +148 -0
  78. package/src/core/voice/engines/index.js +144 -0
  79. package/src/core/voice/engines/mock.js +59 -0
  80. package/src/core/voice/engines/openai.js +82 -0
  81. package/src/core/voice/engines/piper.js +93 -0
  82. package/src/core/voice/index.js +3 -0
  83. package/src/core/voice/tts.js +89 -0
  84. package/src/{daemon → host/daemon}/apc-runtime-context.js +1 -1
  85. package/src/host/daemon/api/admin-config.js +159 -0
  86. package/src/host/daemon/api/admin.js +72 -0
  87. package/src/host/daemon/api/agents.js +284 -0
  88. package/src/host/daemon/api/artifacts.js +52 -0
  89. package/src/host/daemon/api/code.js +351 -0
  90. package/src/host/daemon/api/config.js +104 -0
  91. package/src/host/daemon/api/connections.js +42 -0
  92. package/src/host/daemon/api/conversations.js +161 -0
  93. package/src/host/daemon/api/deck.js +511 -0
  94. package/src/host/daemon/api/desktop.js +71 -0
  95. package/src/host/daemon/api/embeddings.js +65 -0
  96. package/src/host/daemon/api/engines.js +80 -0
  97. package/src/host/daemon/api/exec.js +193 -0
  98. package/src/host/daemon/api/health.js +10 -0
  99. package/src/host/daemon/api/identity.js +36 -0
  100. package/src/host/daemon/api/mcps.js +205 -0
  101. package/src/host/daemon/api/messages.js +83 -0
  102. package/src/host/daemon/api/pairing.js +194 -0
  103. package/src/host/daemon/api/plugins.js +19 -0
  104. package/src/host/daemon/api/projects.js +35 -0
  105. package/src/host/daemon/api/routines.js +84 -0
  106. package/src/host/daemon/api/run.js +55 -0
  107. package/src/host/daemon/api/runtimes.js +219 -0
  108. package/src/host/daemon/api/sessions-search.js +177 -0
  109. package/src/host/daemon/api/sessions.js +115 -0
  110. package/src/host/daemon/api/shared.js +217 -0
  111. package/src/host/daemon/api/super-agent.js +208 -0
  112. package/src/host/daemon/api/tasks.js +118 -0
  113. package/src/host/daemon/api/telegram.js +325 -0
  114. package/src/host/daemon/api/tools.js +21 -0
  115. package/src/host/daemon/api/top-level.js +131 -0
  116. package/src/host/daemon/api/transcribe.js +35 -0
  117. package/src/host/daemon/api/tts.js +44 -0
  118. package/src/host/daemon/api/voice.js +519 -0
  119. package/src/host/daemon/api/web.js +123 -0
  120. package/src/host/daemon/api.js +152 -0
  121. package/src/{daemon → host/daemon}/compact.js +1 -1
  122. package/src/{daemon → host/daemon}/db.js +19 -5
  123. package/src/{daemon/overlay-ws.js → host/daemon/desktop-ws.js} +7 -7
  124. package/src/host/daemon/engine-sessions.js +245 -0
  125. package/src/{daemon → host/daemon}/index.js +27 -10
  126. package/src/{daemon/plugins/overlay.js → host/daemon/plugins/desktop.js} +36 -28
  127. package/src/{daemon → host/daemon}/plugins/index.js +2 -2
  128. package/src/{daemon → host/daemon}/plugins/telegram.js +165 -33
  129. package/src/{daemon → host/daemon}/project-config.js +31 -7
  130. package/src/{daemon → host/daemon}/routines.js +27 -8
  131. package/src/{daemon → host/daemon}/skills-loader.js +4 -2
  132. package/src/{daemon → host/daemon}/smoke.js +9 -5
  133. package/src/{daemon → host/daemon}/super-agent-tools/helpers.js +1 -1
  134. package/src/host/daemon/super-agent-tools/index.js +157 -0
  135. package/src/{daemon → host/daemon}/super-agent-tools/registry-bridge.js +1 -1
  136. package/src/{daemon → host/daemon}/super-agent-tools/tools/add-project.js +2 -2
  137. package/src/{daemon → host/daemon}/super-agent-tools/tools/ask-questions.js +4 -0
  138. package/src/{daemon → host/daemon}/super-agent-tools/tools/call-agent.js +5 -2
  139. package/src/{daemon → host/daemon}/super-agent-tools/tools/call-runtime.js +117 -8
  140. package/src/host/daemon/super-agent-tools/tools/create-task.js +52 -0
  141. package/src/{daemon → host/daemon}/super-agent-tools/tools/import-agent.js +2 -3
  142. package/src/{daemon → host/daemon}/super-agent-tools/tools/list-agents.js +1 -1
  143. package/src/host/daemon/super-agent-tools/tools/list-tasks.js +52 -0
  144. package/src/{daemon → host/daemon}/super-agent-tools/tools/list-vault-agents.js +1 -1
  145. package/src/host/daemon/super-agent-tools/tools/read-self-memory.js +21 -0
  146. package/src/host/daemon/super-agent-tools/tools/remember.js +40 -0
  147. package/src/{daemon → host/daemon}/super-agent-tools/tools/search-messages.js +1 -1
  148. package/src/host/daemon/super-agent-tools/tools/search-sessions.js +134 -0
  149. package/src/{daemon → host/daemon}/super-agent-tools/tools/send-telegram.js +2 -2
  150. package/src/{daemon → host/daemon}/super-agent-tools/tools/set-identity.js +1 -1
  151. package/src/{daemon → host/daemon}/super-agent-tools/tools/set-permission-mode.js +1 -1
  152. package/src/{daemon → host/daemon}/super-agent-tools/tools/tail-messages.js +1 -1
  153. package/src/host/daemon/super-agent.js +129 -0
  154. package/src/host/daemon/token-store.js +118 -0
  155. package/src/host/daemon/tool-call-parser.js +2 -0
  156. package/src/{daemon → host/daemon}/transcription.js +1 -1
  157. package/src/{daemon → host/daemon}/wakeup.js +2 -2
  158. package/src/interfaces/cli/claude-permissions.js +33 -0
  159. package/src/{cli → interfaces/cli}/commands/agent.js +43 -8
  160. package/src/{cli → interfaces/cli}/commands/command.js +1 -1
  161. package/src/{cli → interfaces/cli}/commands/config.js +1 -1
  162. package/src/{cli → interfaces/cli}/commands/daemon.js +67 -0
  163. package/src/interfaces/cli/commands/desktop.js +335 -0
  164. package/src/interfaces/cli/commands/exec.js +92 -0
  165. package/src/{cli → interfaces/cli}/commands/identity.js +6 -63
  166. package/src/{cli → interfaces/cli}/commands/init.js +1 -1
  167. package/src/{cli → interfaces/cli}/commands/mcp.js +69 -10
  168. package/src/{cli → interfaces/cli}/commands/memory.js +2 -2
  169. package/src/interfaces/cli/commands/model.js +136 -0
  170. package/src/interfaces/cli/commands/pair.js +170 -0
  171. package/src/interfaces/cli/commands/project-config.js +131 -0
  172. package/src/{cli → interfaces/cli}/commands/project.js +1 -1
  173. package/src/{cli → interfaces/cli}/commands/search.js +1 -1
  174. package/src/interfaces/cli/commands/session.js +892 -0
  175. package/src/interfaces/cli/commands/sessions.js +997 -0
  176. package/src/{cli → interfaces/cli}/commands/setup.js +98 -4
  177. package/src/{cli → interfaces/cli}/commands/skills.js +117 -9
  178. package/src/{cli → interfaces/cli}/commands/status.js +9 -1
  179. package/src/{cli → interfaces/cli}/commands/sys.js +96 -17
  180. package/src/interfaces/cli/commands/task.js +179 -0
  181. package/src/interfaces/cli/commands/telegram.js +366 -0
  182. package/src/{cli → interfaces/cli}/commands/update.js +1 -1
  183. package/src/interfaces/cli/commands/voice.js +258 -0
  184. package/src/{cli → interfaces/cli}/http.js +6 -2
  185. package/src/{cli → interfaces/cli}/index.js +955 -63
  186. package/src/interfaces/cli/postinstall.js +34 -0
  187. package/src/interfaces/desktop/assets/app-icon-180.png +0 -0
  188. package/src/interfaces/desktop/assets/app-icon-32.png +0 -0
  189. package/src/interfaces/desktop/assets/app-icon.png +0 -0
  190. package/src/interfaces/desktop/assets/apx-logo.png +0 -0
  191. package/src/interfaces/desktop/assets/superagent.png +0 -0
  192. package/src/interfaces/desktop/assets/tray-icon.png +0 -0
  193. package/src/interfaces/desktop/index.html +18 -0
  194. package/src/interfaces/desktop/main.js +652 -0
  195. package/src/interfaces/desktop/preload.js +48 -0
  196. package/src/interfaces/desktop/renderer.js +1006 -0
  197. package/src/interfaces/desktop/style.css +400 -0
  198. package/src/{mcp → interfaces/mcp-server}/index.js +2 -2
  199. package/src/interfaces/tui/_shims/util-which.ts +53 -0
  200. package/src/{tui → interfaces/tui}/app.tsx +2 -2
  201. package/src/{tui → interfaces/tui}/component/prompt/index.tsx +4 -1
  202. package/src/{tui → interfaces/tui}/context/sdk-apx.tsx +84 -16
  203. package/src/interfaces/tui/context/sync-apx.tsx +398 -0
  204. package/src/interfaces/tui/routes/session/index.tsx +368 -0
  205. package/src/interfaces/tui/routes/session/message-actions.tsx +58 -0
  206. package/src/interfaces/tui/routes/session/sidebar-apx.tsx +114 -0
  207. package/src/{tui → interfaces/tui}/tsconfig.json +1 -0
  208. package/src/{tui → interfaces/tui}/util/clipboard.ts +1 -1
  209. package/src/interfaces/web/README.md +102 -0
  210. package/src/interfaces/web/coming-soon.html +65 -0
  211. package/src/interfaces/web/components.json +25 -0
  212. package/src/interfaces/web/dist/assets/index-BDUsA6L6.css +1 -0
  213. package/src/interfaces/web/dist/assets/index-CfWyjPBa.js +548 -0
  214. package/src/interfaces/web/dist/assets/index-CfWyjPBa.js.map +1 -0
  215. package/src/interfaces/web/dist/favicon/dark/android-chrome-192x192.png +0 -0
  216. package/src/interfaces/web/dist/favicon/dark/android-chrome-512x512.png +0 -0
  217. package/src/interfaces/web/dist/favicon/dark/apple-touch-icon.png +0 -0
  218. package/src/interfaces/web/dist/favicon/dark/favicon-16x16.png +0 -0
  219. package/src/interfaces/web/dist/favicon/dark/favicon-32x32.png +0 -0
  220. package/src/interfaces/web/dist/favicon/dark/favicon-48x48.png +0 -0
  221. package/src/interfaces/web/dist/favicon/dark/favicon.ico +0 -0
  222. package/src/interfaces/web/dist/favicon/dark/favicon.webp +0 -0
  223. package/src/interfaces/web/dist/favicon/dark/site.webmanifest +18 -0
  224. package/src/interfaces/web/dist/favicon/white/android-chrome-192x192.png +0 -0
  225. package/src/interfaces/web/dist/favicon/white/android-chrome-512x512.png +0 -0
  226. package/src/interfaces/web/dist/favicon/white/apple-touch-icon.png +0 -0
  227. package/src/interfaces/web/dist/favicon/white/favicon-16x16.png +0 -0
  228. package/src/interfaces/web/dist/favicon/white/favicon-32x32.png +0 -0
  229. package/src/interfaces/web/dist/favicon/white/favicon-48x48.png +0 -0
  230. package/src/interfaces/web/dist/favicon/white/favicon.ico +0 -0
  231. package/src/interfaces/web/dist/favicon/white/favicon.webp +0 -0
  232. package/src/interfaces/web/dist/favicon/white/site.webmanifest +18 -0
  233. package/src/interfaces/web/dist/index.html +27 -0
  234. package/src/interfaces/web/dist/logo/logo_dark.webp +0 -0
  235. package/src/interfaces/web/dist/logo/logo_only_dark.webp +0 -0
  236. package/src/interfaces/web/dist/logo/logo_only_white.webp +0 -0
  237. package/src/interfaces/web/dist/logo/logo_vertical_dark.webp +0 -0
  238. package/src/interfaces/web/dist/logo/logo_vertical_white.webp +0 -0
  239. package/src/interfaces/web/dist/logo/logo_white.webp +0 -0
  240. package/src/interfaces/web/dist/modules/superagent.png +0 -0
  241. package/src/interfaces/web/index.html +26 -0
  242. package/src/interfaces/web/package-lock.json +4253 -0
  243. package/src/interfaces/web/package.json +55 -0
  244. package/src/interfaces/web/playwright.config.ts +45 -0
  245. package/src/interfaces/web/pnpm-lock.yaml +2946 -0
  246. package/src/interfaces/web/public/favicon/dark/android-chrome-192x192.png +0 -0
  247. package/src/interfaces/web/public/favicon/dark/android-chrome-512x512.png +0 -0
  248. package/src/interfaces/web/public/favicon/dark/apple-touch-icon.png +0 -0
  249. package/src/interfaces/web/public/favicon/dark/favicon-16x16.png +0 -0
  250. package/src/interfaces/web/public/favicon/dark/favicon-32x32.png +0 -0
  251. package/src/interfaces/web/public/favicon/dark/favicon-48x48.png +0 -0
  252. package/src/interfaces/web/public/favicon/dark/favicon.ico +0 -0
  253. package/src/interfaces/web/public/favicon/dark/favicon.webp +0 -0
  254. package/src/interfaces/web/public/favicon/dark/site.webmanifest +18 -0
  255. package/src/interfaces/web/public/favicon/white/android-chrome-192x192.png +0 -0
  256. package/src/interfaces/web/public/favicon/white/android-chrome-512x512.png +0 -0
  257. package/src/interfaces/web/public/favicon/white/apple-touch-icon.png +0 -0
  258. package/src/interfaces/web/public/favicon/white/favicon-16x16.png +0 -0
  259. package/src/interfaces/web/public/favicon/white/favicon-32x32.png +0 -0
  260. package/src/interfaces/web/public/favicon/white/favicon-48x48.png +0 -0
  261. package/src/interfaces/web/public/favicon/white/favicon.ico +0 -0
  262. package/src/interfaces/web/public/favicon/white/favicon.webp +0 -0
  263. package/src/interfaces/web/public/favicon/white/site.webmanifest +18 -0
  264. package/src/interfaces/web/public/logo/logo_dark.webp +0 -0
  265. package/src/interfaces/web/public/logo/logo_only_dark.webp +0 -0
  266. package/src/interfaces/web/public/logo/logo_only_white.webp +0 -0
  267. package/src/interfaces/web/public/logo/logo_vertical_dark.webp +0 -0
  268. package/src/interfaces/web/public/logo/logo_vertical_white.webp +0 -0
  269. package/src/interfaces/web/public/logo/logo_white.webp +0 -0
  270. package/src/interfaces/web/public/modules/superagent.png +0 -0
  271. package/src/interfaces/web/src/App.tsx +199 -0
  272. package/src/interfaces/web/src/components/AddProjectDialog.tsx +121 -0
  273. package/src/interfaces/web/src/components/ModelCombobox.tsx +96 -0
  274. package/src/interfaces/web/src/components/RobyBubble.tsx +213 -0
  275. package/src/interfaces/web/src/components/Section.tsx +44 -0
  276. package/src/interfaces/web/src/components/TelegramChannelDialog.tsx +97 -0
  277. package/src/interfaces/web/src/components/TelegramSendDialog.tsx +48 -0
  278. package/src/interfaces/web/src/components/Toast.tsx +84 -0
  279. package/src/interfaces/web/src/components/UiSelect.tsx +74 -0
  280. package/src/interfaces/web/src/components/chat/Composer.tsx +43 -0
  281. package/src/interfaces/web/src/components/chat/ContextBar.tsx +111 -0
  282. package/src/interfaces/web/src/components/chat/MessageBubble.tsx +95 -0
  283. package/src/interfaces/web/src/components/chat/MessageList.tsx +35 -0
  284. package/src/interfaces/web/src/components/chat/ModelPicker.tsx +145 -0
  285. package/src/interfaces/web/src/components/chat/ToolCall.tsx +141 -0
  286. package/src/interfaces/web/src/components/code/CodeChangesTab.tsx +87 -0
  287. package/src/interfaces/web/src/components/code/CodeComposer.tsx +87 -0
  288. package/src/interfaces/web/src/components/code/CodeContextTab.tsx +83 -0
  289. package/src/interfaces/web/src/components/code/CodeProjectPicker.tsx +39 -0
  290. package/src/interfaces/web/src/components/code/CodeSessionList.tsx +97 -0
  291. package/src/interfaces/web/src/components/code/CodeSidePanel.tsx +44 -0
  292. package/src/interfaces/web/src/components/code/CodeToolTrail.tsx +29 -0
  293. package/src/interfaces/web/src/components/code/DiffView.tsx +67 -0
  294. package/src/interfaces/web/src/components/common/Qr.tsx +27 -0
  295. package/src/interfaces/web/src/components/common/TabLayout.tsx +46 -0
  296. package/src/interfaces/web/src/components/common/TabNav.tsx +113 -0
  297. package/src/interfaces/web/src/components/config/ConfigTabsEditor.tsx +202 -0
  298. package/src/interfaces/web/src/components/config/GlobalConfigEditor.tsx +42 -0
  299. package/src/interfaces/web/src/components/config/global-config-sections.ts +60 -0
  300. package/src/interfaces/web/src/components/config/project-config-sections.ts +58 -0
  301. package/src/interfaces/web/src/components/deck/DaemonCard.tsx +58 -0
  302. package/src/interfaces/web/src/components/deck/DesktopGroup.tsx +33 -0
  303. package/src/interfaces/web/src/components/deck/WidgetRow.tsx +100 -0
  304. package/src/interfaces/web/src/components/layout/Logo.tsx +59 -0
  305. package/src/interfaces/web/src/components/layout/ProjectAvatar.tsx +116 -0
  306. package/src/interfaces/web/src/components/layout/ProjectSidebar.tsx +151 -0
  307. package/src/interfaces/web/src/components/settings/AdvancedPanel.tsx +45 -0
  308. package/src/interfaces/web/src/components/settings/AppearancePanel.tsx +72 -0
  309. package/src/interfaces/web/src/components/settings/DefaultRouterCard.tsx +232 -0
  310. package/src/interfaces/web/src/components/settings/DevicesPanel.tsx +60 -0
  311. package/src/interfaces/web/src/components/settings/EnginesPanel.tsx +127 -0
  312. package/src/interfaces/web/src/components/settings/IdentityPanel.tsx +69 -0
  313. package/src/interfaces/web/src/components/settings/MemoryPanel.tsx +226 -0
  314. package/src/interfaces/web/src/components/settings/PairDeviceDialog.tsx +175 -0
  315. package/src/interfaces/web/src/components/settings/SuperAgentPanel.tsx +93 -0
  316. package/src/interfaces/web/src/components/settings/TelegramChannelsPanel.tsx +90 -0
  317. package/src/interfaces/web/src/components/settings/TelegramContactsPanel.tsx +101 -0
  318. package/src/interfaces/web/src/components/settings/TelegramGlobalPanel.tsx +100 -0
  319. package/src/interfaces/web/src/components/settings/TelegramRolesPanel.tsx +108 -0
  320. package/src/interfaces/web/src/components/settings/TelegramSettingsTabs.tsx +55 -0
  321. package/src/interfaces/web/src/components/settings/providers/ProviderCard.tsx +95 -0
  322. package/src/interfaces/web/src/components/settings/providers/ProviderModal.tsx +405 -0
  323. package/src/interfaces/web/src/components/settings/providers/typeStyles.ts +155 -0
  324. package/src/interfaces/web/src/components/settings/providers/types.ts +26 -0
  325. package/src/interfaces/web/src/components/ui/accordion.tsx +72 -0
  326. package/src/interfaces/web/src/components/ui/alert-dialog.tsx +187 -0
  327. package/src/interfaces/web/src/components/ui/alert.tsx +76 -0
  328. package/src/interfaces/web/src/components/ui/aspect-ratio.tsx +22 -0
  329. package/src/interfaces/web/src/components/ui/avatar.tsx +107 -0
  330. package/src/interfaces/web/src/components/ui/badge.tsx +52 -0
  331. package/src/interfaces/web/src/components/ui/breadcrumb.tsx +125 -0
  332. package/src/interfaces/web/src/components/ui/button-group.tsx +87 -0
  333. package/src/interfaces/web/src/components/ui/button.tsx +58 -0
  334. package/src/interfaces/web/src/components/ui/calendar.tsx +221 -0
  335. package/src/interfaces/web/src/components/ui/card.tsx +103 -0
  336. package/src/interfaces/web/src/components/ui/carousel.tsx +242 -0
  337. package/src/interfaces/web/src/components/ui/chart.tsx +371 -0
  338. package/src/interfaces/web/src/components/ui/chat-input.tsx +122 -0
  339. package/src/interfaces/web/src/components/ui/checkbox.tsx +29 -0
  340. package/src/interfaces/web/src/components/ui/collapsible.tsx +19 -0
  341. package/src/interfaces/web/src/components/ui/combobox.tsx +295 -0
  342. package/src/interfaces/web/src/components/ui/command.tsx +196 -0
  343. package/src/interfaces/web/src/components/ui/context-menu.tsx +271 -0
  344. package/src/interfaces/web/src/components/ui/dialog.tsx +158 -0
  345. package/src/interfaces/web/src/components/ui/direction.tsx +4 -0
  346. package/src/interfaces/web/src/components/ui/drawer.tsx +134 -0
  347. package/src/interfaces/web/src/components/ui/dropdown-menu.tsx +266 -0
  348. package/src/interfaces/web/src/components/ui/empty.tsx +104 -0
  349. package/src/interfaces/web/src/components/ui/field.tsx +236 -0
  350. package/src/interfaces/web/src/components/ui/hover-card.tsx +51 -0
  351. package/src/interfaces/web/src/components/ui/input-group.tsx +158 -0
  352. package/src/interfaces/web/src/components/ui/input-otp.tsx +85 -0
  353. package/src/interfaces/web/src/components/ui/input.tsx +20 -0
  354. package/src/interfaces/web/src/components/ui/item.tsx +201 -0
  355. package/src/interfaces/web/src/components/ui/kbd.tsx +26 -0
  356. package/src/interfaces/web/src/components/ui/label.tsx +20 -0
  357. package/src/interfaces/web/src/components/ui/menubar.tsx +280 -0
  358. package/src/interfaces/web/src/components/ui/native-select.tsx +61 -0
  359. package/src/interfaces/web/src/components/ui/navigation-menu.tsx +168 -0
  360. package/src/interfaces/web/src/components/ui/pagination.tsx +130 -0
  361. package/src/interfaces/web/src/components/ui/popover.tsx +88 -0
  362. package/src/interfaces/web/src/components/ui/progress.tsx +83 -0
  363. package/src/interfaces/web/src/components/ui/radio-group.tsx +36 -0
  364. package/src/interfaces/web/src/components/ui/resizable.tsx +50 -0
  365. package/src/interfaces/web/src/components/ui/scroll-area.tsx +53 -0
  366. package/src/interfaces/web/src/components/ui/select.tsx +201 -0
  367. package/src/interfaces/web/src/components/ui/separator.tsx +23 -0
  368. package/src/interfaces/web/src/components/ui/sheet.tsx +138 -0
  369. package/src/interfaces/web/src/components/ui/sidebar.tsx +723 -0
  370. package/src/interfaces/web/src/components/ui/skeleton.tsx +13 -0
  371. package/src/interfaces/web/src/components/ui/slider.tsx +52 -0
  372. package/src/interfaces/web/src/components/ui/sonner.tsx +49 -0
  373. package/src/interfaces/web/src/components/ui/spinner.tsx +10 -0
  374. package/src/interfaces/web/src/components/ui/switch.tsx +30 -0
  375. package/src/interfaces/web/src/components/ui/table.tsx +116 -0
  376. package/src/interfaces/web/src/components/ui/tabs.tsx +72 -0
  377. package/src/interfaces/web/src/components/ui/textarea.tsx +18 -0
  378. package/src/interfaces/web/src/components/ui/tip.tsx +21 -0
  379. package/src/interfaces/web/src/components/ui/toggle-group.tsx +87 -0
  380. package/src/interfaces/web/src/components/ui/toggle.tsx +45 -0
  381. package/src/interfaces/web/src/components/ui/tooltip.tsx +64 -0
  382. package/src/interfaces/web/src/components/ui.tsx +211 -0
  383. package/src/interfaces/web/src/components/voice/VoiceProviderList.tsx +197 -0
  384. package/src/interfaces/web/src/components/voice/VoiceProviderModal.tsx +213 -0
  385. package/src/interfaces/web/src/components/voice/VoiceSttCard.tsx +72 -0
  386. package/src/interfaces/web/src/components/voice/VoiceTestCard.tsx +112 -0
  387. package/src/interfaces/web/src/components/voice/useTtsPlayer.ts +59 -0
  388. package/src/interfaces/web/src/constants/index.ts +91 -0
  389. package/src/interfaces/web/src/hooks/use-mobile.ts +19 -0
  390. package/src/interfaces/web/src/hooks/useChat.ts +276 -0
  391. package/src/interfaces/web/src/hooks/useDaemonStatus.ts +12 -0
  392. package/src/interfaces/web/src/hooks/useDevices.ts +12 -0
  393. package/src/interfaces/web/src/hooks/useEngines.ts +10 -0
  394. package/src/interfaces/web/src/hooks/useGlobalConfig.ts +24 -0
  395. package/src/interfaces/web/src/hooks/useIdentity.ts +16 -0
  396. package/src/interfaces/web/src/hooks/useProjects.ts +27 -0
  397. package/src/interfaces/web/src/hooks/useTelegram.ts +35 -0
  398. package/src/interfaces/web/src/hooks/useTheme.tsx +57 -0
  399. package/src/interfaces/web/src/hooks/useTokenBootstrap.ts +122 -0
  400. package/src/interfaces/web/src/i18n/en.ts +767 -0
  401. package/src/interfaces/web/src/i18n/es.ts +770 -0
  402. package/src/interfaces/web/src/i18n/index.ts +86 -0
  403. package/src/interfaces/web/src/lib/api/admin.ts +30 -0
  404. package/src/interfaces/web/src/lib/api/agents.ts +46 -0
  405. package/src/interfaces/web/src/lib/api/code.ts +122 -0
  406. package/src/interfaces/web/src/lib/api/conversations.ts +16 -0
  407. package/src/interfaces/web/src/lib/api/deck.ts +106 -0
  408. package/src/interfaces/web/src/lib/api/desktop.ts +54 -0
  409. package/src/interfaces/web/src/lib/api/embeddings.ts +44 -0
  410. package/src/interfaces/web/src/lib/api/engines.ts +17 -0
  411. package/src/interfaces/web/src/lib/api/filesystem.ts +12 -0
  412. package/src/interfaces/web/src/lib/api/health.ts +6 -0
  413. package/src/interfaces/web/src/lib/api/identity.ts +7 -0
  414. package/src/interfaces/web/src/lib/api/mcps.ts +29 -0
  415. package/src/interfaces/web/src/lib/api/messages.ts +24 -0
  416. package/src/interfaces/web/src/lib/api/projects.ts +29 -0
  417. package/src/interfaces/web/src/lib/api/routines.ts +14 -0
  418. package/src/interfaces/web/src/lib/api/sessions.ts +16 -0
  419. package/src/interfaces/web/src/lib/api/super_agent.ts +29 -0
  420. package/src/interfaces/web/src/lib/api/tasks.ts +19 -0
  421. package/src/interfaces/web/src/lib/api/telegram.ts +57 -0
  422. package/src/interfaces/web/src/lib/api/tools.ts +13 -0
  423. package/src/interfaces/web/src/lib/api/voice.ts +169 -0
  424. package/src/interfaces/web/src/lib/api.ts +48 -0
  425. package/src/interfaces/web/src/lib/cn.ts +6 -0
  426. package/src/interfaces/web/src/lib/code-context.ts +83 -0
  427. package/src/interfaces/web/src/lib/config-values.ts +29 -0
  428. package/src/interfaces/web/src/lib/device.ts +10 -0
  429. package/src/interfaces/web/src/lib/http.ts +104 -0
  430. package/src/interfaces/web/src/lib/secrets.ts +15 -0
  431. package/src/interfaces/web/src/lib/utils.ts +6 -0
  432. package/src/interfaces/web/src/main.tsx +16 -0
  433. package/src/interfaces/web/src/screens/ApxAdminScreen.tsx +174 -0
  434. package/src/interfaces/web/src/screens/PairingScreen.tsx +105 -0
  435. package/src/interfaces/web/src/screens/ProjectScreen.tsx +178 -0
  436. package/src/interfaces/web/src/screens/SettingsScreen.tsx +111 -0
  437. package/src/interfaces/web/src/screens/base/AgentDefaultsTab.tsx +274 -0
  438. package/src/interfaces/web/src/screens/base/ComingSoon.tsx +16 -0
  439. package/src/interfaces/web/src/screens/base/GlobalTasksTab.tsx +53 -0
  440. package/src/interfaces/web/src/screens/base/LogsTab.tsx +188 -0
  441. package/src/interfaces/web/src/screens/base/ModelsTab.tsx +13 -0
  442. package/src/interfaces/web/src/screens/base/SessionsTab.tsx +58 -0
  443. package/src/interfaces/web/src/screens/base/WorkspacesTab.tsx +49 -0
  444. package/src/interfaces/web/src/screens/modules/CodeScreen.tsx +295 -0
  445. package/src/interfaces/web/src/screens/modules/DeckScreen.tsx +173 -0
  446. package/src/interfaces/web/src/screens/modules/DesktopScreen.tsx +304 -0
  447. package/src/interfaces/web/src/screens/modules/VoiceScreen.tsx +174 -0
  448. package/src/interfaces/web/src/screens/project/AgentBrainGraph.tsx +152 -0
  449. package/src/interfaces/web/src/screens/project/AgentDetailScreen.tsx +455 -0
  450. package/src/interfaces/web/src/screens/project/AgentsTab.tsx +364 -0
  451. package/src/interfaces/web/src/screens/project/ChatTab.tsx +198 -0
  452. package/src/interfaces/web/src/screens/project/ConfigTab.tsx +94 -0
  453. package/src/interfaces/web/src/screens/project/McpsTab.tsx +149 -0
  454. package/src/interfaces/web/src/screens/project/MemoriesTab.tsx +134 -0
  455. package/src/interfaces/web/src/screens/project/Overview.tsx +37 -0
  456. package/src/interfaces/web/src/screens/project/RoutinesTab.tsx +386 -0
  457. package/src/interfaces/web/src/screens/project/TasksTab.tsx +116 -0
  458. package/src/interfaces/web/src/screens/project/TelegramTab.tsx +126 -0
  459. package/src/interfaces/web/src/screens/project/ThreadsTab.tsx +100 -0
  460. package/src/interfaces/web/src/styles.css +128 -0
  461. package/src/interfaces/web/src/types/daemon.ts +289 -0
  462. package/src/interfaces/web/tailwind.config.js +53 -0
  463. package/src/interfaces/web/tsconfig.json +24 -0
  464. package/src/interfaces/web/vite.config.ts +50 -0
  465. package/src/cli/commands/exec.js +0 -56
  466. package/src/cli/commands/overlay.js +0 -253
  467. package/src/cli/commands/session.js +0 -395
  468. package/src/cli/commands/sessions.js +0 -517
  469. package/src/cli/commands/telegram.js +0 -77
  470. package/src/cli/postinstall.js +0 -75
  471. package/src/cli-ts/commands/agent.ts +0 -173
  472. package/src/cli-ts/commands/chat.ts +0 -119
  473. package/src/cli-ts/commands/daemon.ts +0 -112
  474. package/src/cli-ts/commands/exec.ts +0 -109
  475. package/src/cli-ts/commands/mcp.ts +0 -235
  476. package/src/cli-ts/commands/session.ts +0 -224
  477. package/src/cli-ts/commands/status.ts +0 -61
  478. package/src/cli-ts/http.ts +0 -36
  479. package/src/cli-ts/index.ts +0 -73
  480. package/src/cli-ts/ui.ts +0 -107
  481. package/src/daemon/api.js +0 -1558
  482. package/src/daemon/engines/gemini.js +0 -56
  483. package/src/daemon/engines/openai.js +0 -79
  484. package/src/daemon/mcp-sources.js +0 -114
  485. package/src/daemon/super-agent-tools/index.js +0 -84
  486. package/src/daemon/super-agent-tools.js +0 -1
  487. package/src/daemon/super-agent.js +0 -541
  488. package/src/overlay/index.html +0 -44
  489. package/src/overlay/main.js +0 -480
  490. package/src/overlay/preload.js +0 -34
  491. package/src/overlay/renderer.js +0 -371
  492. package/src/overlay/style.css +0 -250
  493. package/src/tui/context/sync-apx.tsx +0 -284
  494. package/src/tui/routes/session/index.tsx +0 -274
  495. package/src/tui/routes/session/sidebar-apx.tsx +0 -90
  496. /package/src/{daemon → core}/tools/browser.js +0 -0
  497. /package/src/{daemon → core}/tools/fetch.js +0 -0
  498. /package/src/{daemon → core}/tools/glob.js +0 -0
  499. /package/src/{daemon → core}/tools/grep.js +0 -0
  500. /package/src/{daemon → core}/tools/registry.js +0 -0
  501. /package/src/{daemon → core}/tools/search.js +0 -0
  502. /package/src/{daemon → host/daemon}/conversations.js +0 -0
  503. /package/src/{daemon → host/daemon}/env-detect.js +0 -0
  504. /package/src/{daemon → host/daemon}/runtimes/_spawn.js +0 -0
  505. /package/src/{daemon → host/daemon}/runtimes/aider.js +0 -0
  506. /package/src/{daemon → host/daemon}/runtimes/claude-code.js +0 -0
  507. /package/src/{daemon → host/daemon}/runtimes/codex.js +0 -0
  508. /package/src/{daemon → host/daemon}/runtimes/cursor-agent.js +0 -0
  509. /package/src/{daemon → host/daemon}/runtimes/gemini-cli.js +0 -0
  510. /package/src/{daemon → host/daemon}/runtimes/index.js +0 -0
  511. /package/src/{daemon → host/daemon}/runtimes/opencode.js +0 -0
  512. /package/src/{daemon → host/daemon}/runtimes/qwen-code.js +0 -0
  513. /package/src/{daemon → host/daemon}/super-agent-tools/tools/call-mcp.js +0 -0
  514. /package/src/{daemon → host/daemon}/super-agent-tools/tools/edit-file.js +0 -0
  515. /package/src/{daemon → host/daemon}/super-agent-tools/tools/list-files.js +0 -0
  516. /package/src/{daemon → host/daemon}/super-agent-tools/tools/list-mcps.js +0 -0
  517. /package/src/{daemon → host/daemon}/super-agent-tools/tools/list-projects.js +0 -0
  518. /package/src/{daemon → host/daemon}/super-agent-tools/tools/list-skills.js +0 -0
  519. /package/src/{daemon → host/daemon}/super-agent-tools/tools/load-skill.js +0 -0
  520. /package/src/{daemon → host/daemon}/super-agent-tools/tools/read-agent-memory.js +0 -0
  521. /package/src/{daemon → host/daemon}/super-agent-tools/tools/read-file.js +0 -0
  522. /package/src/{daemon → host/daemon}/super-agent-tools/tools/run-shell.js +0 -0
  523. /package/src/{daemon → host/daemon}/super-agent-tools/tools/search-files.js +0 -0
  524. /package/src/{daemon → host/daemon}/super-agent-tools/tools/transcribe-audio.js +0 -0
  525. /package/src/{daemon → host/daemon}/super-agent-tools/tools/write-file.js +0 -0
  526. /package/src/{daemon → host/daemon}/thinking.js +0 -0
  527. /package/src/{daemon → host/daemon}/whisper-server.py +0 -0
  528. /package/src/{daemon → host/daemon}/whisper-transcribe.py +0 -0
  529. /package/src/{cli → interfaces/cli}/commands/a2a.js +0 -0
  530. /package/src/{cli → interfaces/cli}/commands/artifact.js +0 -0
  531. /package/src/{cli → interfaces/cli}/commands/chat.js +0 -0
  532. /package/src/{cli → interfaces/cli}/commands/log.js +0 -0
  533. /package/src/{cli → interfaces/cli}/commands/messages.js +0 -0
  534. /package/src/{cli → interfaces/cli}/commands/plugins.js +0 -0
  535. /package/src/{cli → interfaces/cli}/commands/routine.js +0 -0
  536. /package/src/{cli → interfaces/cli}/commands/runtime.js +0 -0
  537. /package/src/{cli → interfaces/cli}/terminal-chat/renderer.js +0 -0
  538. /package/src/{overlay → interfaces/desktop}/package.json +0 -0
  539. /package/src/{tui → interfaces/tui}/_shims/cli-error.ts +0 -0
  540. /package/src/{tui → interfaces/tui}/_shims/cli-logo.ts +0 -0
  541. /package/src/{tui → interfaces/tui}/_shims/cli-ui.ts +0 -0
  542. /package/src/{tui → interfaces/tui}/_shims/config-console-state.ts +0 -0
  543. /package/src/{tui → interfaces/tui}/_shims/core-any.ts +0 -0
  544. /package/src/{tui → interfaces/tui}/_shims/core-binary.ts +0 -0
  545. /package/src/{tui → interfaces/tui}/_shims/core-flag.ts +0 -0
  546. /package/src/{tui → interfaces/tui}/_shims/core-log.ts +0 -0
  547. /package/src/{tui → interfaces/tui}/_shims/lsp-language.ts +0 -0
  548. /package/src/{tui → interfaces/tui}/_shims/opencode-any.ts +0 -0
  549. /package/src/{tui → interfaces/tui}/_shims/opencode-sdk-v2.ts +0 -0
  550. /package/src/{tui → interfaces/tui}/_shims/plugin-tui.ts +0 -0
  551. /package/src/{tui → interfaces/tui}/_shims/prompt-display.ts +0 -0
  552. /package/src/{tui → interfaces/tui}/_shims/provider-provider.ts +0 -0
  553. /package/src/{tui → interfaces/tui}/_shims/session-retry.ts +0 -0
  554. /package/src/{tui → interfaces/tui}/_shims/session-schema.ts +0 -0
  555. /package/src/{tui → interfaces/tui}/_shims/session-session.ts +0 -0
  556. /package/src/{tui → interfaces/tui}/_shims/snapshot.ts +0 -0
  557. /package/src/{tui → interfaces/tui}/_shims/tool-any.ts +0 -0
  558. /package/src/{tui → interfaces/tui}/_shims/util-error.ts +0 -0
  559. /package/src/{tui → interfaces/tui}/_shims/util-filesystem.ts +0 -0
  560. /package/src/{tui → interfaces/tui}/_shims/util-format.ts +0 -0
  561. /package/src/{tui → interfaces/tui}/_shims/util-iife.ts +0 -0
  562. /package/src/{tui → interfaces/tui}/_shims/util-locale.ts +0 -0
  563. /package/src/{tui → interfaces/tui}/_shims/util-process.ts +0 -0
  564. /package/src/{tui → interfaces/tui}/asset/charge.wav +0 -0
  565. /package/src/{tui → interfaces/tui}/asset/pulse-a.wav +0 -0
  566. /package/src/{tui → interfaces/tui}/asset/pulse-b.wav +0 -0
  567. /package/src/{tui → interfaces/tui}/asset/pulse-c.wav +0 -0
  568. /package/src/{tui → interfaces/tui}/attach.ts +0 -0
  569. /package/src/{tui → interfaces/tui}/component/bg-pulse-render.ts +0 -0
  570. /package/src/{tui → interfaces/tui}/component/bg-pulse.tsx +0 -0
  571. /package/src/{tui → interfaces/tui}/component/border.tsx +0 -0
  572. /package/src/{tui → interfaces/tui}/component/dialog-agent.tsx +0 -0
  573. /package/src/{tui → interfaces/tui}/component/dialog-console-org.tsx +0 -0
  574. /package/src/{tui → interfaces/tui}/component/dialog-mcp.tsx +0 -0
  575. /package/src/{tui → interfaces/tui}/component/dialog-model.tsx +0 -0
  576. /package/src/{tui → interfaces/tui}/component/dialog-provider.tsx +0 -0
  577. /package/src/{tui → interfaces/tui}/component/dialog-retry-action.tsx +0 -0
  578. /package/src/{tui → interfaces/tui}/component/dialog-session-delete-failed.tsx +0 -0
  579. /package/src/{tui → interfaces/tui}/component/dialog-session-list.tsx +0 -0
  580. /package/src/{tui → interfaces/tui}/component/dialog-session-rename.tsx +0 -0
  581. /package/src/{tui → interfaces/tui}/component/dialog-skill.tsx +0 -0
  582. /package/src/{tui → interfaces/tui}/component/dialog-stash.tsx +0 -0
  583. /package/src/{tui → interfaces/tui}/component/dialog-status.tsx +0 -0
  584. /package/src/{tui → interfaces/tui}/component/dialog-tag.tsx +0 -0
  585. /package/src/{tui → interfaces/tui}/component/dialog-theme-list.tsx +0 -0
  586. /package/src/{tui → interfaces/tui}/component/dialog-variant.tsx +0 -0
  587. /package/src/{tui → interfaces/tui}/component/dialog-workspace-create.tsx +0 -0
  588. /package/src/{tui → interfaces/tui}/component/dialog-workspace-file-changes.tsx +0 -0
  589. /package/src/{tui → interfaces/tui}/component/dialog-workspace-unavailable.tsx +0 -0
  590. /package/src/{tui → interfaces/tui}/component/error-component.tsx +0 -0
  591. /package/src/{tui → interfaces/tui}/component/logo.tsx +0 -0
  592. /package/src/{tui → interfaces/tui}/component/plugin-route-missing.tsx +0 -0
  593. /package/src/{tui → interfaces/tui}/component/prompt/autocomplete.tsx +0 -0
  594. /package/src/{tui → interfaces/tui}/component/prompt/cwd.ts +0 -0
  595. /package/src/{tui → interfaces/tui}/component/prompt/frecency.tsx +0 -0
  596. /package/src/{tui → interfaces/tui}/component/prompt/history.tsx +0 -0
  597. /package/src/{tui → interfaces/tui}/component/prompt/part.ts +0 -0
  598. /package/src/{tui → interfaces/tui}/component/prompt/stash.tsx +0 -0
  599. /package/src/{tui → interfaces/tui}/component/prompt/traits.ts +0 -0
  600. /package/src/{tui → interfaces/tui}/component/spinner.tsx +0 -0
  601. /package/src/{tui → interfaces/tui}/component/startup-loading.tsx +0 -0
  602. /package/src/{tui → interfaces/tui}/component/todo-item.tsx +0 -0
  603. /package/src/{tui → interfaces/tui}/component/use-connected.tsx +0 -0
  604. /package/src/{tui → interfaces/tui}/component/workspace-label.tsx +0 -0
  605. /package/src/{tui → interfaces/tui}/config/cwd.ts +0 -0
  606. /package/src/{tui → interfaces/tui}/config/keybind.ts +0 -0
  607. /package/src/{tui → interfaces/tui}/config/tui-migrate.ts +0 -0
  608. /package/src/{tui → interfaces/tui}/config/tui-schema.ts +0 -0
  609. /package/src/{tui → interfaces/tui}/config/tui.ts +0 -0
  610. /package/src/{tui → interfaces/tui}/context/aggregate-failures.ts +0 -0
  611. /package/src/{tui → interfaces/tui}/context/args.tsx +0 -0
  612. /package/src/{tui → interfaces/tui}/context/command-palette.tsx +0 -0
  613. /package/src/{tui → interfaces/tui}/context/directory.ts +0 -0
  614. /package/src/{tui → interfaces/tui}/context/editor-zed.ts +0 -0
  615. /package/src/{tui → interfaces/tui}/context/editor.ts +0 -0
  616. /package/src/{tui → interfaces/tui}/context/event-apx.ts +0 -0
  617. /package/src/{tui → interfaces/tui}/context/event.ts +0 -0
  618. /package/src/{tui → interfaces/tui}/context/exit.tsx +0 -0
  619. /package/src/{tui → interfaces/tui}/context/helper.tsx +0 -0
  620. /package/src/{tui → interfaces/tui}/context/kv.tsx +0 -0
  621. /package/src/{tui → interfaces/tui}/context/local.tsx +0 -0
  622. /package/src/{tui → interfaces/tui}/context/path-format.tsx +0 -0
  623. /package/src/{tui → interfaces/tui}/context/project-apx.tsx +0 -0
  624. /package/src/{tui → interfaces/tui}/context/project.tsx +0 -0
  625. /package/src/{tui → interfaces/tui}/context/prompt.tsx +0 -0
  626. /package/src/{tui → interfaces/tui}/context/route.tsx +0 -0
  627. /package/src/{tui → interfaces/tui}/context/sdk.tsx +0 -0
  628. /package/src/{tui → interfaces/tui}/context/sync-v2.tsx +0 -0
  629. /package/src/{tui → interfaces/tui}/context/sync.tsx +0 -0
  630. /package/src/{tui → interfaces/tui}/context/theme/aura.json +0 -0
  631. /package/src/{tui → interfaces/tui}/context/theme/ayu.json +0 -0
  632. /package/src/{tui → interfaces/tui}/context/theme/carbonfox.json +0 -0
  633. /package/src/{tui → interfaces/tui}/context/theme/catppuccin-frappe.json +0 -0
  634. /package/src/{tui → interfaces/tui}/context/theme/catppuccin-macchiato.json +0 -0
  635. /package/src/{tui → interfaces/tui}/context/theme/catppuccin.json +0 -0
  636. /package/src/{tui → interfaces/tui}/context/theme/cobalt2.json +0 -0
  637. /package/src/{tui → interfaces/tui}/context/theme/cursor.json +0 -0
  638. /package/src/{tui → interfaces/tui}/context/theme/dracula.json +0 -0
  639. /package/src/{tui → interfaces/tui}/context/theme/everforest.json +0 -0
  640. /package/src/{tui → interfaces/tui}/context/theme/flexoki.json +0 -0
  641. /package/src/{tui → interfaces/tui}/context/theme/github.json +0 -0
  642. /package/src/{tui → interfaces/tui}/context/theme/gruvbox.json +0 -0
  643. /package/src/{tui → interfaces/tui}/context/theme/kanagawa.json +0 -0
  644. /package/src/{tui → interfaces/tui}/context/theme/lucent-orng.json +0 -0
  645. /package/src/{tui → interfaces/tui}/context/theme/material.json +0 -0
  646. /package/src/{tui → interfaces/tui}/context/theme/matrix.json +0 -0
  647. /package/src/{tui → interfaces/tui}/context/theme/mercury.json +0 -0
  648. /package/src/{tui → interfaces/tui}/context/theme/monokai.json +0 -0
  649. /package/src/{tui → interfaces/tui}/context/theme/nightowl.json +0 -0
  650. /package/src/{tui → interfaces/tui}/context/theme/nord.json +0 -0
  651. /package/src/{tui → interfaces/tui}/context/theme/one-dark.json +0 -0
  652. /package/src/{tui → interfaces/tui}/context/theme/opencode.json +0 -0
  653. /package/src/{tui → interfaces/tui}/context/theme/orng.json +0 -0
  654. /package/src/{tui → interfaces/tui}/context/theme/osaka-jade.json +0 -0
  655. /package/src/{tui → interfaces/tui}/context/theme/palenight.json +0 -0
  656. /package/src/{tui → interfaces/tui}/context/theme/rosepine.json +0 -0
  657. /package/src/{tui → interfaces/tui}/context/theme/solarized.json +0 -0
  658. /package/src/{tui → interfaces/tui}/context/theme/synthwave84.json +0 -0
  659. /package/src/{tui → interfaces/tui}/context/theme/tokyonight.json +0 -0
  660. /package/src/{tui → interfaces/tui}/context/theme/vercel.json +0 -0
  661. /package/src/{tui → interfaces/tui}/context/theme/vesper.json +0 -0
  662. /package/src/{tui → interfaces/tui}/context/theme/zenburn.json +0 -0
  663. /package/src/{tui → interfaces/tui}/context/theme.tsx +0 -0
  664. /package/src/{tui → interfaces/tui}/context/tui-config.tsx +0 -0
  665. /package/src/{tui → interfaces/tui}/event.ts +0 -0
  666. /package/src/{tui → interfaces/tui}/feature-plugins/home/footer.tsx +0 -0
  667. /package/src/{tui → interfaces/tui}/feature-plugins/home/tips-view.tsx +0 -0
  668. /package/src/{tui → interfaces/tui}/feature-plugins/home/tips.tsx +0 -0
  669. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/context.tsx +0 -0
  670. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/files.tsx +0 -0
  671. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/footer.tsx +0 -0
  672. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/lsp.tsx +0 -0
  673. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/mcp.tsx +0 -0
  674. /package/src/{tui → interfaces/tui}/feature-plugins/sidebar/todo.tsx +0 -0
  675. /package/src/{tui → interfaces/tui}/feature-plugins/system/plugins.tsx +0 -0
  676. /package/src/{tui → interfaces/tui}/feature-plugins/system/session-v2.tsx +0 -0
  677. /package/src/{tui → interfaces/tui}/feature-plugins/system/which-key.tsx +0 -0
  678. /package/src/{tui → interfaces/tui}/keymap.tsx +0 -0
  679. /package/src/{tui → interfaces/tui}/layer.ts +0 -0
  680. /package/src/{tui → interfaces/tui}/plugin/api.tsx +0 -0
  681. /package/src/{tui → interfaces/tui}/plugin/command-shim.ts +0 -0
  682. /package/src/{tui → interfaces/tui}/plugin/internal.ts +0 -0
  683. /package/src/{tui → interfaces/tui}/plugin/runtime.ts +0 -0
  684. /package/src/{tui → interfaces/tui}/plugin/slots.tsx +0 -0
  685. /package/src/{tui → interfaces/tui}/routes/home.tsx +0 -0
  686. /package/src/{tui → interfaces/tui}/routes/session/dialog-fork-from-timeline.tsx +0 -0
  687. /package/src/{tui → interfaces/tui}/routes/session/dialog-message.tsx +0 -0
  688. /package/src/{tui → interfaces/tui}/routes/session/dialog-subagent.tsx +0 -0
  689. /package/src/{tui → interfaces/tui}/routes/session/dialog-timeline.tsx +0 -0
  690. /package/src/{tui → interfaces/tui}/routes/session/footer.tsx +0 -0
  691. /package/src/{tui → interfaces/tui}/routes/session/permission.tsx +0 -0
  692. /package/src/{tui → interfaces/tui}/routes/session/question.tsx +0 -0
  693. /package/src/{tui → interfaces/tui}/routes/session/sidebar.tsx +0 -0
  694. /package/src/{tui → interfaces/tui}/routes/session/subagent-footer.tsx +0 -0
  695. /package/src/{tui → interfaces/tui}/run.ts +0 -0
  696. /package/src/{tui → interfaces/tui}/thread.ts +0 -0
  697. /package/src/{tui → interfaces/tui}/ui/dialog-alert.tsx +0 -0
  698. /package/src/{tui → interfaces/tui}/ui/dialog-confirm.tsx +0 -0
  699. /package/src/{tui → interfaces/tui}/ui/dialog-export-options.tsx +0 -0
  700. /package/src/{tui → interfaces/tui}/ui/dialog-help.tsx +0 -0
  701. /package/src/{tui → interfaces/tui}/ui/dialog-prompt.tsx +0 -0
  702. /package/src/{tui → interfaces/tui}/ui/dialog-select.tsx +0 -0
  703. /package/src/{tui → interfaces/tui}/ui/dialog.tsx +0 -0
  704. /package/src/{tui → interfaces/tui}/ui/link.tsx +0 -0
  705. /package/src/{tui → interfaces/tui}/ui/spinner.ts +0 -0
  706. /package/src/{tui → interfaces/tui}/ui/toast.tsx +0 -0
  707. /package/src/{tui → interfaces/tui}/util/editor.ts +0 -0
  708. /package/src/{tui → interfaces/tui}/util/model.ts +0 -0
  709. /package/src/{tui → interfaces/tui}/util/provider-origin.ts +0 -0
  710. /package/src/{tui → interfaces/tui}/util/revert-diff.ts +0 -0
  711. /package/src/{tui → interfaces/tui}/util/scroll.ts +0 -0
  712. /package/src/{tui → interfaces/tui}/util/selection.ts +0 -0
  713. /package/src/{tui → interfaces/tui}/util/signal.ts +0 -0
  714. /package/src/{tui → interfaces/tui}/util/sound.ts +0 -0
  715. /package/src/{tui → interfaces/tui}/util/transcript.ts +0 -0
  716. /package/src/{tui → interfaces/tui}/validate-session.ts +0 -0
  717. /package/src/{tui → interfaces/tui}/win32.ts +0 -0
  718. /package/src/{tui → interfaces/tui}/worker.ts +0 -0
@@ -3,7 +3,13 @@ import path from "node:path";
3
3
  import os from "node:os";
4
4
  import crypto from "node:crypto";
5
5
  import { fileURLToPath } from "node:url";
6
- import { readAgents, readAgentsFromDir, VAULT_DIR } from "./parser.js";
6
+ import {
7
+ VAULT_DIR,
8
+ BUNDLED_VAULT_DIR,
9
+ readVaultTombstones,
10
+ writeVaultTombstones,
11
+ } from "./parser.js";
12
+ import { readApcContextSkill } from "./apc-skill-sync.js";
7
13
 
8
14
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
15
  const PACKAGE_ROOT = path.resolve(__dirname, "..", "..");
@@ -15,10 +21,16 @@ export const SPEC_VERSION = "0.1.0";
15
21
  // ---------------------------------------------------------------------------
16
22
  // Bundled skills — single source of truth lives at <packageRoot>/skills/<slug>/SKILL.md
17
23
  // with proper frontmatter. The `apc-context` copy is refreshed on every
18
- // install/update from the canonical APC repo (see src/cli/postinstall.js).
24
+ // install/update from the canonical APC repo (see src/interfaces/cli/postinstall.js).
19
25
  // ---------------------------------------------------------------------------
20
26
 
27
+ // Bundled skills — apx lives in skills/apx/. apc-context is synced from
28
+ // the canonical APC repo (../apc or GitHub) — never edited in APX.
21
29
  function readBundledSkill(slug) {
30
+ if (slug === "apc-context") {
31
+ const synced = readApcContextSkill();
32
+ return synced?.text || null;
33
+ }
22
34
  const file = path.join(BUNDLED_SKILLS_DIR, slug, "SKILL.md");
23
35
  if (!fs.existsSync(file)) return null;
24
36
  return fs.readFileSync(file, "utf8");
@@ -176,51 +188,141 @@ export function installIdeSkills(root, targetIds = null) {
176
188
  return results;
177
189
  }
178
190
 
179
- // Install bundled APX/APC skills to global ~/.../skills/ dirs.
180
- // Only apx and apc-context are installed everywhere they teach IDE tools
181
- // (Claude Code, Cursor, Codex) about the APX CLI and APC project standard.
182
- // Runtime CLI skills (claude-code, codex-cli, etc.) are APX-internal; APX
183
- // loads them from src/daemon/runtime-skills/ at startup and does NOT push
184
- // them to other tools' global skill dirs.
185
- // Returns an array of result objects with { dir, skill, status }.
186
- export function installGlobalSkills() {
187
- const results = [];
191
+ // Discover every bundled skill under skills/<slug>/SKILL.md. Used by
192
+ // installGlobalSkills() so a new skill added to the repo automatically lands
193
+ // on the user's machine after `npm install -g .` (or `npm update -g apx`)
194
+ // without anyone having to touch this file.
195
+ //
196
+ // Excluded: directory names starting with "." (e.g. .DS_Store), and any
197
+ // runtime-only CLI skill that lives under src/core/runtime-skills/ those
198
+ // are loaded in-process at daemon startup and are NOT for IDE consumption.
199
+ // Public: bundled skill slugs grouped by scope.
200
+ // public → pushed to every global skill dir on install / sync (default).
201
+ // optional → not pushed by default; user opts in with --include-optional
202
+ // or `apx skills add <slug> --global` for one-off install.
203
+ // internal → APX-developer skills (mcp-builder, skill-builder, etc.); never
204
+ // pushed globally, only available to APX itself via the bundled
205
+ // copy. Avoids cluttering other IDEs with stuff their users won't
206
+ // run.
207
+ export function listBundledSkillSlugs() {
208
+ return discoverBundledSkills().map((s) => s.slug);
209
+ }
188
210
 
189
- const skills = [];
190
- const apxRaw = readBundledSkill("apx");
191
- const apcRaw = readBundledSkill("apc-context");
192
- if (apxRaw) skills.push({ slug: "apx", md: apxRaw });
193
- if (apcRaw) skills.push({ slug: "apc-context", md: apcRaw });
194
- // Runtime skills (claude-code, codex-cli, opencode-cli, openrouter, …) are
195
- // NOT included here — they are APX-only internals, not for IDE consumption.
211
+ export function listBundledSkills() {
212
+ return discoverBundledSkills().map(({ slug, scope }) => ({ slug, scope }));
213
+ }
214
+
215
+ // Tiny frontmatter peek we only need the `scope:` field. Avoids pulling in
216
+ // a full YAML parser for one optional line.
217
+ function parseFrontmatterScope(md) {
218
+ if (!md.startsWith("---\n")) return "public";
219
+ const end = md.indexOf("\n---", 4);
220
+ if (end === -1) return "public";
221
+ const m = md.slice(4, end).match(/^scope:\s*(\w+)/m);
222
+ if (!m) return "public";
223
+ const s = m[1].toLowerCase();
224
+ if (s === "internal" || s === "optional" || s === "public") return s;
225
+ return "public";
226
+ }
227
+
228
+ function discoverBundledSkills() {
229
+ const root = BUNDLED_SKILLS_DIR;
230
+ if (!fs.existsSync(root)) return [];
231
+ const out = [];
232
+ for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
233
+ if (!entry.isDirectory()) continue;
234
+ if (entry.name.startsWith(".")) continue;
235
+ const skillFile = path.join(root, entry.name, "SKILL.md");
236
+ if (!fs.existsSync(skillFile)) continue;
237
+ const md = fs.readFileSync(skillFile, "utf8");
238
+ out.push({ slug: entry.name, md, scope: parseFrontmatterScope(md) });
239
+ }
240
+ return out.sort((a, b) => a.slug.localeCompare(b.slug));
241
+ }
196
242
 
243
+ // Install bundled skills to every global ~/.../skills/ dir so Claude Code,
244
+ // Cursor, Codex, and other IDEs see them.
245
+ //
246
+ // By default only `scope: public` skills land globally. Pass
247
+ // includeOptional / includeInternal to push the other tiers (or call
248
+ // `apx skills add <slug> --global` for a single one).
249
+ //
250
+ // Pruning: if a slug that was previously installed has since been demoted to
251
+ // internal/optional (or marked as non-public for the current call), we remove
252
+ // the stale global copy unless prune=false. Keeps IDE skill lists clean.
253
+ //
254
+ // Returns an array of { dir, skill, file, status, scope }.
255
+ // status ∈ {created, updated, unchanged, pruned, skipped}
256
+ export function installGlobalSkills({
257
+ includeOptional = false,
258
+ includeInternal = false,
259
+ prune = true,
260
+ } = {}) {
261
+ const all = discoverBundledSkills();
262
+ const wanted = all.filter((s) => {
263
+ if (s.scope === "internal") return includeInternal;
264
+ if (s.scope === "optional") return includeOptional;
265
+ return true; // public
266
+ });
267
+ const wantedSlugs = new Set(wanted.map((s) => s.slug));
268
+ const knownSlugs = new Set(all.map((s) => s.slug));
269
+
270
+ const results = [];
197
271
  for (const base of GLOBAL_SKILL_DIRS) {
198
- for (const { slug, md } of skills) {
272
+ // Push the wanted set.
273
+ for (const { slug, md, scope } of wanted) {
199
274
  const dest = path.join(base, slug, "SKILL.md");
200
275
  fs.mkdirSync(path.dirname(dest), { recursive: true });
201
276
  const existed = fs.existsSync(dest);
277
+ const previous = existed ? fs.readFileSync(dest, "utf8") : null;
278
+ if (previous === md) {
279
+ results.push({ dir: base, skill: slug, file: dest, status: "unchanged", scope });
280
+ continue;
281
+ }
202
282
  fs.writeFileSync(dest, md, "utf8");
203
- results.push({ dir: base, skill: slug, file: dest, status: existed ? "updated" : "created" });
283
+ results.push({ dir: base, skill: slug, file: dest, status: existed ? "updated" : "created", scope });
284
+ }
285
+ // Prune anything WE shipped previously but should no longer be there
286
+ // (slug exists in the bundle but isn't `wanted` this run).
287
+ if (prune) {
288
+ for (const { slug, scope } of all) {
289
+ if (wantedSlugs.has(slug)) continue;
290
+ if (!knownSlugs.has(slug)) continue;
291
+ const dest = path.join(base, slug, "SKILL.md");
292
+ if (!fs.existsSync(dest)) continue;
293
+ fs.unlinkSync(dest);
294
+ // Best-effort: drop the now-empty <slug>/ dir too.
295
+ try { fs.rmdirSync(path.dirname(dest)); } catch {}
296
+ results.push({ dir: base, skill: slug, file: dest, status: "pruned", scope });
297
+ }
204
298
  }
205
299
  }
206
300
  return results;
207
301
  }
208
302
 
209
303
 
210
- const AGENTS_MD_TEMPLATE = `# Agents
304
+ // Generic starter written ONCE at `apx init`. AGENTS.md is the project's
305
+ // startup-rules file — read by Claude, Codex, APX and other AGENTS.md-aware
306
+ // tools when they begin working here. It is NOT an agent registry (APX agents
307
+ // live in `.apc/agents/<slug>.md`). After init it belongs to the user; APX
308
+ // never rewrites it.
309
+ const AGENTS_MD_TEMPLATE = `# AGENTS.md
211
310
 
212
- > This file is the contract for agents in this project.
213
- > It follows the APC spec (https://github.com/agentprojectcontext/agentprojectcontext).
311
+ > Startup rules and conventions for AI agents working in this project.
312
+ > Read by Claude, Codex, APX and other AGENTS.md-aware tools. Edit freely —
313
+ > this file is yours; APX won't overwrite it.
214
314
 
215
- <!-- Add an agent like this:
315
+ ## Overview
216
316
 
217
- ## sofia
218
- - **Role**: Support
219
- - **Model**: claude-haiku-4-5
220
- - **Skills**: customer-support
221
- - **Language**: es-AR
317
+ <!-- What is this project? Tech stack, entry points, how to run it. -->
222
318
 
223
- -->
319
+ ## Conventions
320
+
321
+ <!-- Code style, structure, naming, testing — how to write code that fits. -->
322
+
323
+ ## Rules
324
+
325
+ <!-- Hard constraints: what agents must always / never do here. -->
224
326
  `;
225
327
 
226
328
  const APC_GITIGNORE = `# APC runtime data — never in the repository
@@ -409,6 +511,44 @@ export function writeVaultAgentFile(slug, fields, body = "") {
409
511
  lines.push("---");
410
512
  if (body) lines.push("", body);
411
513
  fs.writeFileSync(dest, lines.join("\n") + "\n");
514
+ // Writing always clears a tombstone — the user is explicitly putting this
515
+ // slug back, even if it was previously removed.
516
+ const tombs = readVaultTombstones();
517
+ if (tombs.delete(slug)) writeVaultTombstones(tombs);
518
+ }
519
+
520
+ // Remove a vault agent. If the slug has a user-layer file we delete it; if
521
+ // the slug ALSO exists in the bundle (or the user file didn't exist but the
522
+ // bundled one does), we add a tombstone so it stays hidden. Returns one of:
523
+ // { removed: "user" } — user file deleted, bundled NOT present
524
+ // { removed: "user+tomb" } — user file deleted AND bundled hidden by tombstone
525
+ // { removed: "tomb" } — bundled-only slug, hidden by tombstone
526
+ // { removed: null } — slug not found anywhere
527
+ export function removeVaultAgent(slug) {
528
+ const userPath = path.join(VAULT_DIR, `${slug}.md`);
529
+ const bundledPath = path.join(BUNDLED_VAULT_DIR, `${slug}.md`);
530
+ const hadUser = fs.existsSync(userPath);
531
+ const hasBundled = fs.existsSync(bundledPath);
532
+ if (!hadUser && !hasBundled) return { removed: null };
533
+ if (hadUser) fs.rmSync(userPath);
534
+ if (hasBundled) {
535
+ const tombs = readVaultTombstones();
536
+ tombs.add(slug);
537
+ writeVaultTombstones(tombs);
538
+ }
539
+ return {
540
+ removed: hadUser && hasBundled ? "user+tomb" : hadUser ? "user" : "tomb",
541
+ };
542
+ }
543
+
544
+ // Un-tombstone a bundled slug so it becomes visible again. Returns whether a
545
+ // tombstone existed before. No-op if there was nothing to restore.
546
+ export function restoreVaultAgent(slug) {
547
+ const tombs = readVaultTombstones();
548
+ if (!tombs.has(slug)) return { restored: false };
549
+ tombs.delete(slug);
550
+ writeVaultTombstones(tombs);
551
+ return { restored: true };
412
552
  }
413
553
 
414
554
  // Add a slug to the project's agents.imported list in project.json
@@ -422,52 +562,8 @@ export function addImportedAgent(root, slug) {
422
562
  fs.writeFileSync(p, JSON.stringify(cfg, null, 2) + "\n");
423
563
  }
424
564
 
425
- // Regenerate AGENTS.md from .apc/agents/*.md for Codex/Antigravity compat.
426
- export function regenerateAgentsMd(root) {
427
- const agents = readAgents(root);
428
- const header = [
429
- "# Agents",
430
- "",
431
- "> Auto-generated from .apc/agents/*.md — edit individual agent files, not this file.",
432
- "> Read by Codex, Antigravity, and other tools that follow the AGENTS.md convention.",
433
- "",
434
- ].join("\n");
435
-
436
- if (agents.length === 0) {
437
- fs.writeFileSync(path.join(root, "AGENTS.md"), header);
438
- return;
439
- }
440
-
441
- const blocks = agents.map((a) => {
442
- const tag = a.source === "vault" ? " <!-- vault -->" : "";
443
- return renderAgentBlock(a.slug, a.fields) + tag;
444
- });
445
- fs.writeFileSync(path.join(root, "AGENTS.md"), header + blocks.join("\n\n") + "\n");
446
- }
447
-
448
- export function appendAgentToAgentsMd(root, slug, fields) {
449
- const agentsMdPath = path.join(root, "AGENTS.md");
450
- let text = fs.existsSync(agentsMdPath)
451
- ? fs.readFileSync(agentsMdPath, "utf8")
452
- : AGENTS_MD_TEMPLATE;
453
-
454
- if (!/^#\s+Agents\s*$/im.test(text)) {
455
- text = `# Agents\n\n${text}`;
456
- }
457
-
458
- const block = renderAgentBlock(slug, fields);
459
-
460
- if (!text.endsWith("\n")) text += "\n";
461
- text += `\n${block}\n`;
462
- fs.writeFileSync(agentsMdPath, text);
463
- }
464
-
465
- export function renderAgentBlock(slug, fields) {
466
- const lines = [`## ${slug}`];
467
- for (const [k, v] of Object.entries(fields)) {
468
- if (v === undefined || v === null || v === "") continue;
469
- const value = Array.isArray(v) ? v.join(", ") : v;
470
- lines.push(`- **${k}**: ${value}`);
471
- }
472
- return lines.join("\n");
473
- }
565
+ // NOTE: AGENTS.md is created once at `apx init` (see AGENTS_MD_TEMPLATE) and is
566
+ // thereafter owned by the user — APX never regenerates it. Agents live in
567
+ // `.apc/agents/<slug>.md` (read by parser.js readAgents); they are NOT listed
568
+ // in AGENTS.md. The project's AGENTS.md is loaded INTO the super-agent prompt
569
+ // by buildSuperAgentSystem() in src/core/agent/prompt-builder.js.
@@ -0,0 +1,264 @@
1
+ // Tasks (TODOs) per project.
2
+ //
3
+ // Append-only JSONL event log, one file per month under
4
+ // ~/.apx/projects/<apxId>/tasks/YYYY-MM.jsonl
5
+ //
6
+ // Each line is a `{ id, ts, op, ... }` event. The current state of a task is
7
+ // the result of folding every event with that id in chronological order:
8
+ //
9
+ // create — sets initial fields (title, body, tags, due, agent, source, meta)
10
+ // update — shallow-merge patch (`patch` field)
11
+ // done — closes the task (`by` field optional)
12
+ // drop — archives without "completed" semantics (`by` field optional)
13
+ //
14
+ // State values: "open" (after create) → "done" or "dropped". Once dropped or
15
+ // done, further updates are recorded but the state is sticky unless the
16
+ // caller explicitly re-opens with op="reopen".
17
+ import fs from "node:fs";
18
+ import path from "node:path";
19
+ import { randomUUID } from "node:crypto";
20
+
21
+ function tasksDir(storagePath) {
22
+ return path.join(storagePath, "tasks");
23
+ }
24
+
25
+ function monthlyFile(storagePath, date = new Date()) {
26
+ const ym = date.toISOString().slice(0, 7); // YYYY-MM
27
+ return path.join(tasksDir(storagePath), `${ym}.jsonl`);
28
+ }
29
+
30
+ function nowIso() {
31
+ return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
32
+ }
33
+
34
+ function shortId() {
35
+ // 6 base36 chars from randomUUID's first 8 hex chars → 32 bits → ~4B keyspace.
36
+ const hex = randomUUID().replace(/-/g, "").slice(0, 8);
37
+ return "t_" + parseInt(hex, 16).toString(36).padStart(6, "0").slice(-6);
38
+ }
39
+
40
+ function appendEvent(storagePath, event) {
41
+ const file = monthlyFile(storagePath);
42
+ fs.mkdirSync(path.dirname(file), { recursive: true });
43
+ fs.appendFileSync(file, JSON.stringify(event) + "\n");
44
+ }
45
+
46
+ function readAllEvents(storagePath) {
47
+ const dir = tasksDir(storagePath);
48
+ if (!fs.existsSync(dir)) return [];
49
+ const files = fs.readdirSync(dir).filter((f) => f.endsWith(".jsonl")).sort();
50
+ const events = [];
51
+ for (const f of files) {
52
+ const text = fs.readFileSync(path.join(dir, f), "utf8");
53
+ for (const line of text.split("\n")) {
54
+ if (!line.trim()) continue;
55
+ try {
56
+ const ev = JSON.parse(line);
57
+ if (ev && ev.id && ev.op) events.push(ev);
58
+ } catch {
59
+ // Skip corrupt lines; one bad write shouldn't break the projection.
60
+ // We could log here; for now we silently drop.
61
+ }
62
+ }
63
+ }
64
+ events.sort((a, b) => (a.ts || "").localeCompare(b.ts || ""));
65
+ return events;
66
+ }
67
+
68
+ function projectState(events) {
69
+ const tasks = new Map();
70
+ for (const ev of events) {
71
+ const existing = tasks.get(ev.id);
72
+ switch (ev.op) {
73
+ case "create": {
74
+ if (existing) break; // duplicate create — keep first
75
+ tasks.set(ev.id, {
76
+ id: ev.id,
77
+ created_at: ev.ts,
78
+ updated_at: ev.ts,
79
+ state: "open",
80
+ title: ev.title || "",
81
+ body: ev.body || null,
82
+ tags: Array.isArray(ev.tags) ? [...ev.tags] : [],
83
+ due: ev.due || null,
84
+ agent: ev.agent || null,
85
+ source: ev.source || null,
86
+ meta: ev.meta && typeof ev.meta === "object" ? { ...ev.meta } : {},
87
+ });
88
+ break;
89
+ }
90
+ case "update": {
91
+ if (!existing) break;
92
+ const patch = ev.patch && typeof ev.patch === "object" ? ev.patch : {};
93
+ for (const k of Object.keys(patch)) {
94
+ if (k === "id" || k === "state" || k === "created_at") continue;
95
+ existing[k] = patch[k];
96
+ }
97
+ existing.updated_at = ev.ts;
98
+ break;
99
+ }
100
+ case "done": {
101
+ if (!existing) break;
102
+ existing.state = "done";
103
+ existing.done_at = ev.ts;
104
+ existing.done_by = ev.by || null;
105
+ existing.updated_at = ev.ts;
106
+ break;
107
+ }
108
+ case "drop": {
109
+ if (!existing) break;
110
+ existing.state = "dropped";
111
+ existing.dropped_at = ev.ts;
112
+ existing.dropped_by = ev.by || null;
113
+ existing.updated_at = ev.ts;
114
+ break;
115
+ }
116
+ case "reopen": {
117
+ if (!existing) break;
118
+ existing.state = "open";
119
+ existing.reopened_at = ev.ts;
120
+ existing.updated_at = ev.ts;
121
+ break;
122
+ }
123
+ default:
124
+ // unknown op — record nothing, but don't throw
125
+ break;
126
+ }
127
+ }
128
+ return tasks;
129
+ }
130
+
131
+ // ────────────────────────────────────────────────────────────────────────────
132
+ // Public API
133
+ // ────────────────────────────────────────────────────────────────────────────
134
+
135
+ /**
136
+ * Create a new task. Returns the freshly projected task object.
137
+ * fields: { title (required), body?, tags?, due?, agent?, source?, meta? }
138
+ */
139
+ export function createTask(storagePath, fields) {
140
+ if (!fields || typeof fields !== "object") throw new Error("createTask: fields required");
141
+ if (!fields.title || typeof fields.title !== "string") throw new Error("createTask: title required");
142
+ const id = shortId();
143
+ const ev = {
144
+ id,
145
+ ts: nowIso(),
146
+ op: "create",
147
+ title: fields.title.trim(),
148
+ body: fields.body || null,
149
+ tags: Array.isArray(fields.tags) ? fields.tags.filter((t) => typeof t === "string") : [],
150
+ due: fields.due || null,
151
+ agent: fields.agent || null,
152
+ source: fields.source || null,
153
+ meta: fields.meta && typeof fields.meta === "object" ? fields.meta : {},
154
+ };
155
+ appendEvent(storagePath, ev);
156
+ return getTask(storagePath, id);
157
+ }
158
+
159
+ /** List tasks with optional filters. */
160
+ export function listTasks(storagePath, opts = {}) {
161
+ const events = readAllEvents(storagePath);
162
+ const tasks = [...projectState(events).values()];
163
+
164
+ let out = tasks;
165
+ if (opts.state && opts.state !== "all") {
166
+ out = out.filter((t) => t.state === opts.state);
167
+ } else if (!opts.state) {
168
+ out = out.filter((t) => t.state === "open");
169
+ }
170
+ if (opts.tag) {
171
+ out = out.filter((t) => Array.isArray(t.tags) && t.tags.includes(opts.tag));
172
+ }
173
+ if (opts.agent) {
174
+ out = out.filter((t) => t.agent === opts.agent);
175
+ }
176
+ if (opts.due_before) {
177
+ out = out.filter((t) => t.due && t.due <= opts.due_before);
178
+ }
179
+ if (opts.due_after) {
180
+ out = out.filter((t) => t.due && t.due >= opts.due_after);
181
+ }
182
+ out.sort((a, b) => (b.created_at || "").localeCompare(a.created_at || ""));
183
+ if (opts.limit && Number.isFinite(opts.limit)) {
184
+ out = out.slice(0, opts.limit);
185
+ }
186
+ return out;
187
+ }
188
+
189
+ /** Get a single task by id or by id prefix (≥ 3 chars, must be unique). */
190
+ export function getTask(storagePath, idOrPrefix) {
191
+ if (!idOrPrefix || typeof idOrPrefix !== "string") return null;
192
+ const events = readAllEvents(storagePath);
193
+ const tasks = projectState(events);
194
+ if (tasks.has(idOrPrefix)) return tasks.get(idOrPrefix);
195
+ if (idOrPrefix.length < 3) return null;
196
+ const matches = [...tasks.values()].filter((t) => t.id.startsWith(idOrPrefix));
197
+ if (matches.length === 1) return matches[0];
198
+ return null;
199
+ }
200
+
201
+ /** Patch a task. Returns the projected task; null if id not found. */
202
+ export function patchTask(storagePath, idOrPrefix, patch) {
203
+ const existing = getTask(storagePath, idOrPrefix);
204
+ if (!existing) return null;
205
+ if (!patch || typeof patch !== "object") return existing;
206
+ appendEvent(storagePath, {
207
+ id: existing.id,
208
+ ts: nowIso(),
209
+ op: "update",
210
+ patch,
211
+ });
212
+ return getTask(storagePath, existing.id);
213
+ }
214
+
215
+ /** Mark done. */
216
+ export function doneTask(storagePath, idOrPrefix, by = null) {
217
+ const existing = getTask(storagePath, idOrPrefix);
218
+ if (!existing) return null;
219
+ appendEvent(storagePath, {
220
+ id: existing.id,
221
+ ts: nowIso(),
222
+ op: "done",
223
+ by,
224
+ });
225
+ return getTask(storagePath, existing.id);
226
+ }
227
+
228
+ /** Drop (archive without completion). */
229
+ export function dropTask(storagePath, idOrPrefix, by = null) {
230
+ const existing = getTask(storagePath, idOrPrefix);
231
+ if (!existing) return null;
232
+ appendEvent(storagePath, {
233
+ id: existing.id,
234
+ ts: nowIso(),
235
+ op: "drop",
236
+ by,
237
+ });
238
+ return getTask(storagePath, existing.id);
239
+ }
240
+
241
+ /** Re-open a done/dropped task. */
242
+ export function reopenTask(storagePath, idOrPrefix) {
243
+ const existing = getTask(storagePath, idOrPrefix);
244
+ if (!existing) return null;
245
+ appendEvent(storagePath, {
246
+ id: existing.id,
247
+ ts: nowIso(),
248
+ op: "reopen",
249
+ });
250
+ return getTask(storagePath, existing.id);
251
+ }
252
+
253
+ /** Counts for status displays. */
254
+ export function countTasks(storagePath) {
255
+ const tasks = [...projectState(readAllEvents(storagePath)).values()];
256
+ const today = new Date().toISOString().slice(0, 10);
257
+ return {
258
+ open: tasks.filter((t) => t.state === "open").length,
259
+ done: tasks.filter((t) => t.state === "done").length,
260
+ dropped: tasks.filter((t) => t.state === "dropped").length,
261
+ overdue: tasks.filter((t) => t.state === "open" && t.due && t.due < today).length,
262
+ total: tasks.length,
263
+ };
264
+ }