@agentprojectcontext/apx 1.77.3 → 1.78.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 (293) hide show
  1. package/README.md +23 -9
  2. package/package.json +12 -12
  3. package/src/core/agent/build-agent-system.js +3 -2
  4. package/src/core/agent/constants.js +3 -2
  5. package/src/core/agent/loop/greeting-guard.js +55 -0
  6. package/src/core/agent/loop/side-effects.js +52 -0
  7. package/src/core/agent/prompt-builder.js +49 -8
  8. package/src/core/agent/run-agent.js +13 -48
  9. package/src/core/agent/security.js +1 -1
  10. package/src/core/agent/self-memory.js +4 -2
  11. package/src/core/agent/skills/index-store.js +2 -2
  12. package/src/core/agent/skills/loader.js +3 -22
  13. package/src/core/agent/super-agent.js +0 -2
  14. package/src/core/agent/tools/handlers/call-runtime.js +4 -4
  15. package/src/core/agent/tools/handlers/search-sessions.js +1 -1
  16. package/src/core/agent/tools/handlers/set-permission-mode.js +11 -4
  17. package/src/core/agent/tools/names.js +58 -0
  18. package/src/core/apc/context-copy.js +1 -1
  19. package/src/core/apc/frontmatter.js +85 -0
  20. package/src/core/apc/parser.js +9 -21
  21. package/src/core/apc/paths.js +8 -8
  22. package/src/core/apc/scaffold.js +5 -4
  23. package/src/core/channels/telegram/config.js +201 -0
  24. package/src/core/config/index.js +25 -183
  25. package/src/core/config/paths.js +54 -1
  26. package/src/core/confirmation/adapters/web.js +1 -1
  27. package/src/core/deck/manifest.js +12 -12
  28. package/src/core/desktop/autostart.js +3 -2
  29. package/src/core/desktop/process.js +4 -4
  30. package/src/core/engines/presets.js +2 -2
  31. package/src/core/http-tools/browser.js +1 -1
  32. package/src/core/http-tools/catalog.js +551 -0
  33. package/src/core/http-tools/fetch.js +1 -1
  34. package/src/core/http-tools/glob.js +3 -3
  35. package/src/core/http-tools/grep.js +2 -9
  36. package/src/core/http-tools/inline-handlers.js +59 -0
  37. package/src/core/http-tools/registry.js +31 -615
  38. package/src/core/http-tools/search.js +2 -2
  39. package/src/core/identity/self.js +6 -7
  40. package/src/core/identity/telegram.js +3 -3
  41. package/src/core/logging.js +6 -5
  42. package/src/core/mcp/sources.js +12 -16
  43. package/src/core/memory/indexer.js +2 -5
  44. package/src/core/profiles/lifecycle.js +0 -2
  45. package/src/core/profiles/store.js +2 -7
  46. package/src/core/routines/runner.js +1 -1
  47. package/src/core/runtime-skills/apx-agency-agents/SKILL.md +2 -2
  48. package/src/core/runtime-skills/apx-profile/SKILL.md +3 -3
  49. package/src/core/runtime-skills/apx-project/SKILL.md +1 -1
  50. package/src/core/runtime-skills/apx-task/SKILL.md +8 -8
  51. package/src/core/runtime-skills/apx-telegram/SKILL.md +4 -4
  52. package/src/core/runtime-skills/apx-voice/SKILL.md +4 -4
  53. package/src/core/runtimes/detect.js +2 -2
  54. package/src/core/sessions/index.js +800 -0
  55. package/src/core/stores/code-sessions.js +3 -14
  56. package/src/core/stores/engine-sessions.js +0 -4
  57. package/src/core/stores/messages.js +0 -5
  58. package/src/core/stores/organization.js +9 -11
  59. package/src/core/stores/routines.js +6 -11
  60. package/src/core/stores/runtime-callbacks.js +2 -1
  61. package/src/core/util/json-file.js +128 -0
  62. package/src/core/vars/sources.js +14 -21
  63. package/src/core/voice/stt-models.js +1 -1
  64. package/src/core/voice/tts.js +5 -4
  65. package/src/host/daemon/api/admin-config.js +5 -5
  66. package/src/host/daemon/api/admin.js +8 -7
  67. package/src/host/daemon/api/agents.js +16 -16
  68. package/src/host/daemon/api/artifact-preview.js +8 -8
  69. package/src/host/daemon/api/artifacts.js +7 -7
  70. package/src/host/daemon/api/code.js +8 -8
  71. package/src/host/daemon/api/config.js +6 -6
  72. package/src/host/daemon/api/confirm.js +2 -2
  73. package/src/host/daemon/api/connections.js +2 -2
  74. package/src/host/daemon/api/conversations.js +12 -12
  75. package/src/host/daemon/api/deck.js +6 -6
  76. package/src/host/daemon/api/desktop.js +8 -8
  77. package/src/host/daemon/api/embeddings.js +4 -4
  78. package/src/host/daemon/api/engines.js +8 -7
  79. package/src/host/daemon/api/exec.js +5 -4
  80. package/src/host/daemon/api/files-project.js +6 -6
  81. package/src/host/daemon/api/health.js +2 -2
  82. package/src/host/daemon/api/identity.js +3 -3
  83. package/src/host/daemon/api/inbox.js +2 -2
  84. package/src/host/daemon/api/integrations.js +23 -19
  85. package/src/host/daemon/api/mcps.js +16 -12
  86. package/src/host/daemon/api/messages.js +5 -5
  87. package/src/host/daemon/api/organization.js +8 -8
  88. package/src/host/daemon/api/pairing.js +6 -6
  89. package/src/host/daemon/api/plugins.js +3 -3
  90. package/src/host/daemon/api/prefix.js +20 -0
  91. package/src/host/daemon/api/profiles.js +9 -9
  92. package/src/host/daemon/api/projects.js +5 -5
  93. package/src/host/daemon/api/routines.js +8 -8
  94. package/src/host/daemon/api/run.js +2 -2
  95. package/src/host/daemon/api/runtimes.js +6 -6
  96. package/src/host/daemon/api/sessions-search.js +18 -11
  97. package/src/host/daemon/api/sessions.js +6 -6
  98. package/src/host/daemon/api/shared.js +59 -13
  99. package/src/host/daemon/api/skills.js +12 -12
  100. package/src/host/daemon/api/super-agent.js +4 -4
  101. package/src/host/daemon/api/tasks.js +11 -11
  102. package/src/host/daemon/api/telegram.js +19 -20
  103. package/src/host/daemon/api/tools.js +7 -7
  104. package/src/host/daemon/api/top-level.js +7 -7
  105. package/src/host/daemon/api/transcribe.js +6 -6
  106. package/src/host/daemon/api/tts.js +3 -3
  107. package/src/host/daemon/api/vars.js +11 -8
  108. package/src/host/daemon/api/voice.js +6 -6
  109. package/src/host/daemon/api/web.js +28 -32
  110. package/src/host/daemon/api.js +77 -48
  111. package/src/host/daemon/db.js +1 -1
  112. package/src/host/daemon/desktop-ws.js +7 -3
  113. package/src/host/daemon/index.js +11 -5
  114. package/src/host/daemon/plugins/desktop/index.js +1 -1
  115. package/src/host/daemon/plugins/telegram/index.js +1 -1
  116. package/src/host/daemon/stt-venv.js +20 -81
  117. package/src/host/daemon/wakeup.js +1 -1
  118. package/src/interfaces/acp/index.js +3 -3
  119. package/src/interfaces/acp/session.js +2 -2
  120. package/src/interfaces/cli/commands/a2a.js +2 -2
  121. package/src/interfaces/cli/commands/agent.js +3 -3
  122. package/src/interfaces/cli/commands/artifact.js +13 -13
  123. package/src/interfaces/cli/commands/chat.js +3 -3
  124. package/src/interfaces/cli/commands/command.js +2 -2
  125. package/src/interfaces/cli/commands/config.js +4 -4
  126. package/src/interfaces/cli/commands/daemon.js +17 -18
  127. package/src/interfaces/cli/commands/desktop.js +7 -14
  128. package/src/interfaces/cli/commands/exec.js +2 -2
  129. package/src/interfaces/cli/commands/log.js +3 -4
  130. package/src/interfaces/cli/commands/mcp.js +9 -9
  131. package/src/interfaces/cli/commands/memory.js +2 -2
  132. package/src/interfaces/cli/commands/messages.js +5 -5
  133. package/src/interfaces/cli/commands/model.js +0 -18
  134. package/src/interfaces/cli/commands/obsidian.js +5 -5
  135. package/src/interfaces/cli/commands/org.js +5 -5
  136. package/src/interfaces/cli/commands/pair.js +6 -6
  137. package/src/interfaces/cli/commands/plugins.js +2 -2
  138. package/src/interfaces/cli/commands/profile.js +10 -10
  139. package/src/interfaces/cli/commands/project-config.js +6 -6
  140. package/src/interfaces/cli/commands/project.js +10 -10
  141. package/src/interfaces/cli/commands/routine.js +8 -9
  142. package/src/interfaces/cli/commands/runtime.js +2 -2
  143. package/src/interfaces/cli/commands/search.js +0 -1
  144. package/src/interfaces/cli/commands/session.js +12 -40
  145. package/src/interfaces/cli/commands/sessions.js +21 -798
  146. package/src/interfaces/cli/commands/setup.js +16 -6
  147. package/src/interfaces/cli/commands/skills.js +1 -2
  148. package/src/interfaces/cli/commands/status.js +3 -3
  149. package/src/interfaces/cli/commands/task.js +8 -8
  150. package/src/interfaces/cli/commands/telegram.js +21 -21
  151. package/src/interfaces/cli/commands/voice.js +6 -6
  152. package/src/interfaces/cli/help/index.js +2245 -0
  153. package/src/interfaces/cli/http.js +9 -4
  154. package/src/interfaces/cli/index.js +14 -2857
  155. package/src/interfaces/cli/routes/acp.js +13 -0
  156. package/src/interfaces/cli/routes/agent.js +27 -0
  157. package/src/interfaces/cli/routes/artifact.js +28 -0
  158. package/src/interfaces/cli/routes/chat.js +11 -0
  159. package/src/interfaces/cli/routes/code.js +11 -0
  160. package/src/interfaces/cli/routes/command.js +21 -0
  161. package/src/interfaces/cli/routes/config.js +16 -0
  162. package/src/interfaces/cli/routes/connections.js +11 -0
  163. package/src/interfaces/cli/routes/conversations.js +21 -0
  164. package/src/interfaces/cli/routes/daemon.js +19 -0
  165. package/src/interfaces/cli/routes/desktop.js +20 -0
  166. package/src/interfaces/cli/routes/env.js +13 -0
  167. package/src/interfaces/cli/routes/exec.js +11 -0
  168. package/src/interfaces/cli/routes/identity.js +11 -0
  169. package/src/interfaces/cli/routes/index.js +71 -0
  170. package/src/interfaces/cli/routes/init.js +11 -0
  171. package/src/interfaces/cli/routes/log.js +20 -0
  172. package/src/interfaces/cli/routes/mcp.js +22 -0
  173. package/src/interfaces/cli/routes/memory.js +11 -0
  174. package/src/interfaces/cli/routes/messages.js +16 -0
  175. package/src/interfaces/cli/routes/model.js +11 -0
  176. package/src/interfaces/cli/routes/obsidian.js +17 -0
  177. package/src/interfaces/cli/routes/org.js +34 -0
  178. package/src/interfaces/cli/routes/overlay.js +10 -0
  179. package/src/interfaces/cli/routes/pair.js +17 -0
  180. package/src/interfaces/cli/routes/panel.js +16 -0
  181. package/src/interfaces/cli/routes/permission.js +11 -0
  182. package/src/interfaces/cli/routes/plugins.js +21 -0
  183. package/src/interfaces/cli/routes/profile.js +27 -0
  184. package/src/interfaces/cli/routes/project.js +41 -0
  185. package/src/interfaces/cli/routes/restart.js +15 -0
  186. package/src/interfaces/cli/routes/routine.js +28 -0
  187. package/src/interfaces/cli/routes/run.js +11 -0
  188. package/src/interfaces/cli/routes/search.js +11 -0
  189. package/src/interfaces/cli/routes/send.js +11 -0
  190. package/src/interfaces/cli/routes/session.js +26 -0
  191. package/src/interfaces/cli/routes/sessions.js +15 -0
  192. package/src/interfaces/cli/routes/setup.js +18 -0
  193. package/src/interfaces/cli/routes/skills.js +20 -0
  194. package/src/interfaces/cli/routes/status.js +12 -0
  195. package/src/interfaces/cli/routes/task.js +26 -0
  196. package/src/interfaces/cli/routes/telegram.js +39 -0
  197. package/src/interfaces/cli/routes/update.js +24 -0
  198. package/src/interfaces/cli/routes/voice.js +17 -0
  199. package/src/interfaces/desktop/main.js +6 -7
  200. package/src/interfaces/desktop/renderer.js +0 -5
  201. package/src/interfaces/mcp-server/index.js +15 -14
  202. package/src/interfaces/tui/_shims/globals.d.ts +8 -0
  203. package/src/interfaces/tui/tsconfig.json +4 -1
  204. package/src/interfaces/web/README.md +6 -6
  205. package/src/interfaces/web/dist/assets/{index-BptlbKjU.js → index-CBR_-QyA.js} +52 -52
  206. package/src/interfaces/web/dist/assets/index-CBR_-QyA.js.map +1 -0
  207. package/src/interfaces/web/dist/index.html +1 -1
  208. package/src/interfaces/web/src/components/AddProjectDialog.tsx +1 -1
  209. package/src/interfaces/web/src/components/agents/AgentFormFields.tsx +1 -1
  210. package/src/interfaces/web/src/components/chat/ChatList.tsx +2 -2
  211. package/src/interfaces/web/src/components/chat/SkillPicker.tsx +1 -1
  212. package/src/interfaces/web/src/components/code/CodeFileTree.tsx +1 -1
  213. package/src/interfaces/web/src/components/code/CodeTerminal.tsx +1 -1
  214. package/src/interfaces/web/src/components/desktop/DesktopStatusCard.tsx +1 -1
  215. package/src/interfaces/web/src/components/files/FileBrowser.tsx +2 -2
  216. package/src/interfaces/web/src/components/memory/MemoryBrowser.tsx +2 -2
  217. package/src/interfaces/web/src/components/routines/ExecutionsList.tsx +1 -1
  218. package/src/interfaces/web/src/components/routines/RoutineEditor.tsx +2 -2
  219. package/src/interfaces/web/src/components/settings/DesktopSettingsPanel.tsx +1 -1
  220. package/src/interfaces/web/src/components/settings/MemoryPanel.tsx +1 -1
  221. package/src/interfaces/web/src/components/settings/SkillsInspectorPanel.tsx +1 -1
  222. package/src/interfaces/web/src/components/settings/SkillsManager.tsx +2 -2
  223. package/src/interfaces/web/src/components/tasks/TaskDetailPanel.tsx +1 -1
  224. package/src/interfaces/web/src/hooks/useDaemonStatus.ts +1 -1
  225. package/src/interfaces/web/src/hooks/useDevices.ts +1 -1
  226. package/src/interfaces/web/src/hooks/useEngines.ts +1 -1
  227. package/src/interfaces/web/src/hooks/useGlobalConfig.ts +2 -2
  228. package/src/interfaces/web/src/hooks/useIdentity.ts +1 -1
  229. package/src/interfaces/web/src/hooks/useInbox.ts +1 -1
  230. package/src/interfaces/web/src/hooks/useProfiles.ts +3 -3
  231. package/src/interfaces/web/src/hooks/useProjects.ts +1 -1
  232. package/src/interfaces/web/src/hooks/useTelegram.ts +3 -3
  233. package/src/interfaces/web/src/hooks/useTokenBootstrap.ts +3 -3
  234. package/src/interfaces/web/src/lib/api/admin.ts +11 -11
  235. package/src/interfaces/web/src/lib/api/agents.ts +14 -14
  236. package/src/interfaces/web/src/lib/api/artifacts.ts +11 -11
  237. package/src/interfaces/web/src/lib/api/code.ts +1 -1
  238. package/src/interfaces/web/src/lib/api/conversations.ts +8 -8
  239. package/src/interfaces/web/src/lib/api/deck.ts +3 -3
  240. package/src/interfaces/web/src/lib/api/desktop.ts +8 -8
  241. package/src/interfaces/web/src/lib/api/embeddings.ts +3 -3
  242. package/src/interfaces/web/src/lib/api/engines.ts +3 -3
  243. package/src/interfaces/web/src/lib/api/filesystem.ts +2 -2
  244. package/src/interfaces/web/src/lib/api/health.ts +1 -1
  245. package/src/interfaces/web/src/lib/api/identity.ts +2 -2
  246. package/src/interfaces/web/src/lib/api/inbox.ts +1 -1
  247. package/src/interfaces/web/src/lib/api/integrations.ts +8 -8
  248. package/src/interfaces/web/src/lib/api/mcps.ts +6 -6
  249. package/src/interfaces/web/src/lib/api/messages.ts +3 -3
  250. package/src/interfaces/web/src/lib/api/organization.ts +7 -7
  251. package/src/interfaces/web/src/lib/api/profiles.ts +8 -8
  252. package/src/interfaces/web/src/lib/api/projectFiles.ts +5 -5
  253. package/src/interfaces/web/src/lib/api/projects.ts +12 -12
  254. package/src/interfaces/web/src/lib/api/routines.ts +7 -7
  255. package/src/interfaces/web/src/lib/api/sessions.ts +2 -2
  256. package/src/interfaces/web/src/lib/api/skills.ts +11 -11
  257. package/src/interfaces/web/src/lib/api/super_agent.ts +3 -3
  258. package/src/interfaces/web/src/lib/api/tasks.ts +12 -12
  259. package/src/interfaces/web/src/lib/api/telegram.ts +14 -14
  260. package/src/interfaces/web/src/lib/api/tools.ts +1 -1
  261. package/src/interfaces/web/src/lib/api/vars.ts +4 -4
  262. package/src/interfaces/web/src/lib/api/voice.ts +6 -6
  263. package/src/interfaces/web/src/screens/base/AgentDefaultsTab.tsx +1 -1
  264. package/src/interfaces/web/src/screens/base/GlobalTasksTab.tsx +1 -1
  265. package/src/interfaces/web/src/screens/base/LogsTab.tsx +3 -3
  266. package/src/interfaces/web/src/screens/base/SessionsTab.tsx +1 -1
  267. package/src/interfaces/web/src/screens/modules/CodeScreen.tsx +1 -1
  268. package/src/interfaces/web/src/screens/modules/DeckScreen.tsx +1 -1
  269. package/src/interfaces/web/src/screens/modules/DesktopScreen.tsx +1 -1
  270. package/src/interfaces/web/src/screens/modules/VoiceScreen.tsx +1 -1
  271. package/src/interfaces/web/src/screens/project/AgentDetailScreen.tsx +8 -8
  272. package/src/interfaces/web/src/screens/project/AgentsTab.tsx +2 -2
  273. package/src/interfaces/web/src/screens/project/ChatTab.tsx +3 -3
  274. package/src/interfaces/web/src/screens/project/ConfigTab.tsx +1 -1
  275. package/src/interfaces/web/src/screens/project/McpsTab.tsx +3 -3
  276. package/src/interfaces/web/src/screens/project/Overview.tsx +6 -6
  277. package/src/interfaces/web/src/screens/project/RoutinesTab.tsx +2 -2
  278. package/src/interfaces/web/src/screens/project/StructureTab.tsx +1 -1
  279. package/src/interfaces/web/src/screens/project/TasksTab.tsx +1 -1
  280. package/src/interfaces/web/src/screens/project/VarsTab.tsx +1 -1
  281. package/src/interfaces/web/vite.config.ts +13 -18
  282. package/src/interfaces/web/dist/assets/index-BptlbKjU.js.map +0 -1
  283. package/src/skills/apc-context/SKILL.md +0 -159
  284. /package/src/{host/daemon → core}/runtimes/_spawn.js +0 -0
  285. /package/src/{host/daemon → core}/runtimes/aider.js +0 -0
  286. /package/src/{host/daemon → core}/runtimes/antigravity.js +0 -0
  287. /package/src/{host/daemon → core}/runtimes/claude-code.js +0 -0
  288. /package/src/{host/daemon → core}/runtimes/codex.js +0 -0
  289. /package/src/{host/daemon → core}/runtimes/cursor-agent.js +0 -0
  290. /package/src/{host/daemon → core}/runtimes/gemini-cli.js +0 -0
  291. /package/src/{host/daemon → core}/runtimes/index.js +0 -0
  292. /package/src/{host/daemon → core}/runtimes/opencode.js +0 -0
  293. /package/src/{host/daemon → core}/runtimes/qwen-code.js +0 -0
@@ -0,0 +1,13 @@
1
+ // apx acp — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdAcp } from "../commands/acp.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ // ACP server owns stdio until the client closes the pipe.
11
+ await cmdAcp(parseArgs(rest));
12
+ return;
13
+ }
@@ -0,0 +1,27 @@
1
+ // apx agent — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdAgentAdd, cmdAgentGet, cmdAgentImport, cmdAgentList, cmdAgentRemove, cmdAgentVaultAdd, cmdAgentVaultList, cmdAgentVaultRestore, cmdAgentVaultRm } from "../commands/agent.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (sub === "add") await cmdAgentAdd(a);
13
+ else if (sub === "list" || sub === "ls") cmdAgentList();
14
+ else if (sub === "get" || sub === "show") cmdAgentGet(a);
15
+ else if (sub === "remove" || sub === "rm" || sub === "delete") await cmdAgentRemove(a);
16
+ else if (sub === "import") await cmdAgentImport(a);
17
+ else if (sub === "vault") {
18
+ const vsub = a._[0];
19
+ const va = { ...a, _: a._.slice(1) };
20
+ if (vsub === "list" || vsub === "ls") cmdAgentVaultList(va);
21
+ else if (vsub === "add") await cmdAgentVaultAdd(va);
22
+ else if (vsub === "rm" || vsub === "remove") cmdAgentVaultRm(va);
23
+ else if (vsub === "restore") cmdAgentVaultRestore(va);
24
+ else die(`unknown vault subcommand: ${vsub || "(none)"} — try: list, add, rm, restore`);
25
+ }
26
+ else die(`unknown agent subcommand: ${sub || "(none)"}`);
27
+ }
@@ -0,0 +1,28 @@
1
+ // apx artifact — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdArtifactCreate, cmdArtifactList, cmdArtifactPreview, cmdArtifactPreviews, cmdArtifactRemove, cmdArtifactRun, cmdArtifactShare, cmdArtifactShow, cmdArtifactStop } from "../commands/artifact.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["artifacts"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ if (!sub || sub === "list" || sub === "ls") await cmdArtifactList(a);
19
+ else if (sub === "create" || sub === "new") await cmdArtifactCreate(a);
20
+ else if (sub === "show" || sub === "get") await cmdArtifactShow(a);
21
+ else if (sub === "remove" || sub === "rm") await cmdArtifactRemove(a);
22
+ else if (sub === "run") await cmdArtifactRun(a);
23
+ else if (sub === "preview" || sub === "serve") await cmdArtifactPreview(a);
24
+ else if (sub === "share") await cmdArtifactShare(a);
25
+ else if (sub === "previews") await cmdArtifactPreviews(a);
26
+ else if (sub === "stop") await cmdArtifactStop(a);
27
+ else die(`unknown artifact subcommand: ${sub}`);
28
+ }
@@ -0,0 +1,11 @@
1
+ // apx chat — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdChat } from "../commands/chat.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdChat(parseArgs(rest));
11
+ }
@@ -0,0 +1,11 @@
1
+ // apx code — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdCode } from "../commands/code.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdCode(parseArgs(rest));
11
+ }
@@ -0,0 +1,21 @@
1
+ // apx command — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdCommandList, cmdCommandShow } from "../commands/command.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["commands"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ if (!sub || sub === "list" || sub === "ls") await cmdCommandList(a);
19
+ else if (sub === "show" || sub === "get") await cmdCommandShow(a);
20
+ else die(`unknown command subcommand: ${sub}`);
21
+ }
@@ -0,0 +1,16 @@
1
+ // apx config — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdConfigSet, cmdConfigShow, cmdConfigUnset } from "../commands/config.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (sub === "show" || sub === "ls" || sub === undefined) await cmdConfigShow(a);
13
+ else if (sub === "set") await cmdConfigSet(a);
14
+ else if (sub === "unset" || sub === "rm") await cmdConfigUnset(a);
15
+ else die(`unknown config subcommand: ${sub}`);
16
+ }
@@ -0,0 +1,11 @@
1
+ // apx connections — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdConnections } from "../commands/a2a.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdConnections(parseArgs(rest));
11
+ }
@@ -0,0 +1,21 @@
1
+ // apx conversations — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdConversationsGet, cmdConversationsList } from "../commands/chat.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["conv"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ if (sub === "list" || sub === "ls") await cmdConversationsList(a);
19
+ else if (sub === "get" || sub === "show") await cmdConversationsGet(a);
20
+ else die(`unknown conversations subcommand: ${sub || "(none)"}`);
21
+ }
@@ -0,0 +1,19 @@
1
+ // apx daemon — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdDaemonLogs, cmdDaemonReload, cmdDaemonRestart, cmdDaemonStart, cmdDaemonStatus, cmdDaemonStop } from "../commands/daemon.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (sub === "start") await cmdDaemonStart(a);
13
+ else if (sub === "stop") await cmdDaemonStop(a);
14
+ else if (sub === "restart") await cmdDaemonRestart(a);
15
+ else if (sub === "reload") await cmdDaemonReload(a);
16
+ else if (sub === "status") await cmdDaemonStatus(a);
17
+ else if (sub === "logs") cmdDaemonLogs(a);
18
+ else die(`unknown daemon subcommand: ${sub || "(none)"}`);
19
+ }
@@ -0,0 +1,20 @@
1
+ // apx desktop — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdDesktopInstall, cmdDesktopRestart, cmdDesktopStart, cmdDesktopStatus, cmdDesktopStop, cmdDesktopUninstall } from "../commands/desktop.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const [sub, ...oRest] = rest;
11
+ const oArgs = parseArgs(oRest);
12
+ if (!sub || sub === "start") { await cmdDesktopStart(oArgs); return; }
13
+ if (sub === "stop") { await cmdDesktopStop(oArgs); return; }
14
+ if (sub === "restart") { await cmdDesktopRestart(oArgs); return; }
15
+ if (sub === "status") { await cmdDesktopStatus(oArgs);return; }
16
+ if (sub === "install") { await cmdDesktopInstall(oArgs); return; }
17
+ if (sub === "uninstall") { await cmdDesktopUninstall(oArgs);return; }
18
+ die(`unknown desktop sub-command: ${sub}\nUsage: apx desktop <start|stop|restart|status|install|uninstall>`);
19
+ return;
20
+ }
@@ -0,0 +1,13 @@
1
+ // apx env — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdEnvDetect } from "../commands/runtime.js";
8
+
9
+ export default async function route(rest, { die }) {
10
+ const sub = rest[0];
11
+ if (sub === "detect" || sub === "list") await cmdEnvDetect();
12
+ else die(`unknown env subcommand: ${sub || "(none)"}`);
13
+ }
@@ -0,0 +1,11 @@
1
+ // apx exec — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdExec } from "../commands/exec.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdExec(parseArgs(rest));
11
+ }
@@ -0,0 +1,11 @@
1
+ // apx identity — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdIdentity } from "../commands/identity.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdIdentity(parseArgs(rest));
11
+ }
@@ -0,0 +1,71 @@
1
+ // Command registry: name (and alias) -> lazy loader for its route module.
2
+ //
3
+ // Lazy on purpose. cli/index.js used to eagerly import 165 symbols from 38
4
+ // command modules just to reach a 457-line switch, so `apx status` paid to
5
+ // load the Electron desktop wiring, the MCP runner and the session scanner.
6
+ // Now one command loads one module.
7
+ //
8
+ // Aliases live next to their command (see the `aliases` export in each route
9
+ // module); this map is generated from them.
10
+ export const ROUTES = Object.freeze({
11
+ "init": () => import("./init.js"),
12
+ "project": () => import("./project.js"),
13
+ "agent": () => import("./agent.js"),
14
+ "memory": () => import("./memory.js"),
15
+ "session": () => import("./session.js"),
16
+ "sessions": () => import("./sessions.js"),
17
+ "mcp": () => import("./mcp.js"),
18
+ "obsidian": () => import("./obsidian.js"),
19
+ "daemon": () => import("./daemon.js"),
20
+ "pair": () => import("./pair.js"),
21
+ "telegram": () => import("./telegram.js"),
22
+ "messages": () => import("./messages.js"),
23
+ "log": () => import("./log.js"),
24
+ "logs": () => import("./log.js"),
25
+ "exec": () => import("./exec.js"),
26
+ "acp": () => import("./acp.js"),
27
+ "search": () => import("./search.js"),
28
+ "chat": () => import("./chat.js"),
29
+ "code": () => import("./code.js"),
30
+ "conversations": () => import("./conversations.js"),
31
+ "conv": () => import("./conversations.js"),
32
+ "run": () => import("./run.js"),
33
+ "env": () => import("./env.js"),
34
+ "send": () => import("./send.js"),
35
+ "connections": () => import("./connections.js"),
36
+ "config": () => import("./config.js"),
37
+ "permission": () => import("./permission.js"),
38
+ "model": () => import("./model.js"),
39
+ "plugins": () => import("./plugins.js"),
40
+ "plugin": () => import("./plugins.js"),
41
+ "routine": () => import("./routine.js"),
42
+ "routines": () => import("./routine.js"),
43
+ "artifact": () => import("./artifact.js"),
44
+ "artifacts": () => import("./artifact.js"),
45
+ "task": () => import("./task.js"),
46
+ "tasks": () => import("./task.js"),
47
+ "panel": () => import("./panel.js"),
48
+ "profile": () => import("./profile.js"),
49
+ "profiles": () => import("./profile.js"),
50
+ "command": () => import("./command.js"),
51
+ "commands": () => import("./command.js"),
52
+ "org": () => import("./org.js"),
53
+ "organization": () => import("./org.js"),
54
+ "skills": () => import("./skills.js"),
55
+ "identity": () => import("./identity.js"),
56
+ "status": () => import("./status.js"),
57
+ "setup": () => import("./setup.js"),
58
+ "install": () => import("./setup.js"),
59
+ "update": () => import("./update.js"),
60
+ "upgrade": () => import("./update.js"),
61
+ "restart": () => import("./restart.js"),
62
+ "overlay": () => import("./overlay.js"),
63
+ "desktop": () => import("./desktop.js"),
64
+ "voice": () => import("./voice.js"),
65
+ });
66
+
67
+ export function resolveRoute(cmd) {
68
+ return ROUTES[cmd] || null;
69
+ }
70
+
71
+ export const COMMAND_NAMES = Object.freeze(Object.keys(ROUTES));
@@ -0,0 +1,11 @@
1
+ // apx init — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdInit } from "../commands/init.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ cmdInit(parseArgs(rest));
11
+ }
@@ -0,0 +1,20 @@
1
+ // apx log — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdLog } from "../commands/log.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["logs"];
14
+
15
+ export default async function route(rest, { parseArgs }) {
16
+ // `apx log` is the unified daemon log (everything: telegram, whisper,
17
+ // super-agent, tools, desktop). For just the legacy stdout sink,
18
+ // use `apx daemon logs`. `apx log -f` follows; `--errors` filters.
19
+ await cmdLog(parseArgs(rest));
20
+ }
@@ -0,0 +1,22 @@
1
+ // apx mcp — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdMcpAdd, cmdMcpCheck, cmdMcpDisable, cmdMcpEnable, cmdMcpList, cmdMcpLogs, cmdMcpRemove, cmdMcpRun, cmdMcpTools } from "../commands/mcp.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (sub === "list" || sub === "ls") await cmdMcpList(a);
13
+ else if (sub === "add") await cmdMcpAdd(a);
14
+ else if (sub === "remove" || sub === "rm") await cmdMcpRemove(a);
15
+ else if (sub === "enable") await cmdMcpEnable(a);
16
+ else if (sub === "disable") await cmdMcpDisable(a);
17
+ else if (sub === "run") await cmdMcpRun(a);
18
+ else if (sub === "tools") await cmdMcpTools(a);
19
+ else if (sub === "logs") await cmdMcpLogs(a);
20
+ else if (sub === "check") await cmdMcpCheck(a);
21
+ else die(`unknown mcp subcommand: ${sub || "(none)"}`);
22
+ }
@@ -0,0 +1,11 @@
1
+ // apx memory — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdMemory } from "../commands/memory.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ cmdMemory(parseArgs(rest));
11
+ }
@@ -0,0 +1,16 @@
1
+ // apx messages — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdMessagesChat, cmdMessagesSearch, cmdMessagesTail } from "../commands/messages.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (sub === "tail") await cmdMessagesTail(a);
13
+ else if (sub === "chat") await cmdMessagesChat(a);
14
+ else if (sub === "search") await cmdMessagesSearch(a);
15
+ else die(`unknown messages subcommand: ${sub || "(none)"}`);
16
+ }
@@ -0,0 +1,11 @@
1
+ // apx model — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdModel } from "../commands/model.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdModel(parseArgs(rest));
11
+ }
@@ -0,0 +1,17 @@
1
+ // apx obsidian — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdObsidianRemove, cmdObsidianSet, cmdObsidianStatus, cmdObsidianSync } from "../commands/obsidian.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (!sub || sub === "status" || sub === "show") await cmdObsidianStatus(a);
13
+ else if (sub === "set" || sub === "connect" || sub === "add") await cmdObsidianSet(a);
14
+ else if (sub === "sync") await cmdObsidianSync(a);
15
+ else if (sub === "remove" || sub === "rm" || sub === "disconnect") await cmdObsidianRemove(a);
16
+ else die(`unknown obsidian subcommand: ${sub}\nUsage: apx obsidian <set|status|sync|remove> [--global|--project <p>]`);
17
+ }
@@ -0,0 +1,34 @@
1
+ // apx org — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdOrgAreaAdd, cmdOrgAreaRm, cmdOrgRoleAdd, cmdOrgRoleRm, cmdOrgShow } from "../commands/org.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["organization"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ // `apx org area add ...` / `apx org role rm ...` — the resource verb is
19
+ // the first positional, the action the second.
20
+ if (!sub || sub === "show" || sub === "list") await cmdOrgShow(a);
21
+ else if (sub === "area") {
22
+ const action = rest[1];
23
+ const aa = parseArgs(rest.slice(1)); // keep `area` as _[0] for name parsing
24
+ if (action === "add" || action === "new") await cmdOrgAreaAdd(aa);
25
+ else if (action === "rm" || action === "remove" || action === "delete") await cmdOrgAreaRm(aa);
26
+ else die("usage: apx org area <add|rm> ...");
27
+ } else if (sub === "role") {
28
+ const action = rest[1];
29
+ const ra = parseArgs(rest.slice(1));
30
+ if (action === "add" || action === "new") await cmdOrgRoleAdd(ra);
31
+ else if (action === "rm" || action === "remove" || action === "delete") await cmdOrgRoleRm(ra);
32
+ else die("usage: apx org role <add|rm> ...");
33
+ } else die(`unknown org subcommand: ${sub}\nUsage: apx org <show|area|role> ...`);
34
+ }
@@ -0,0 +1,10 @@
1
+ // apx overlay — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ export default async function route(_rest, _ctx) {
8
+ console.error(" apx overlay has been renamed to apx desktop — forwarding.");
9
+ /* falls through */
10
+ }
@@ -0,0 +1,17 @@
1
+ // apx pair — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdPair, cmdPairList, cmdPairRevoke, cmdPairWeb } from "../commands/pair.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (!sub || sub === "new" || sub === "device" || sub === "deck") await cmdPair(a);
13
+ else if (sub === "web") await cmdPairWeb(a);
14
+ else if (sub === "list" || sub === "ls") await cmdPairList();
15
+ else if (sub === "revoke" || sub === "rm") await cmdPairRevoke(a);
16
+ else die(`unknown pair subcommand: ${sub} — try: (no arg)/deck, web, list, revoke <id>`);
17
+ }
@@ -0,0 +1,16 @@
1
+ // apx panel — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdPanelShare, cmdPanelStatus, cmdPanelUnshare } from "../commands/panel.js";
8
+
9
+ export default async function route(rest, { parseArgs, die }) {
10
+ const sub = rest[0];
11
+ const a = parseArgs(rest.slice(1));
12
+ if (!sub || sub === "status") await cmdPanelStatus(a);
13
+ else if (sub === "share") await cmdPanelShare(a);
14
+ else if (sub === "unshare") await cmdPanelUnshare(a);
15
+ else die(`unknown panel subcommand: ${sub}\nUsage: apx panel <status|share|unshare>`);
16
+ }
@@ -0,0 +1,11 @@
1
+ // apx permission — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdPermission } from "../commands/config.js";
8
+
9
+ export default async function route(rest, { parseArgs }) {
10
+ await cmdPermission(parseArgs(rest));
11
+ }
@@ -0,0 +1,21 @@
1
+ // apx plugins — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdPluginStatus, cmdPluginsList } from "../commands/plugins.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["plugin"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ if (sub === "list" || sub === "ls" || sub === undefined) await cmdPluginsList();
19
+ else if (sub === "status") await cmdPluginStatus(a);
20
+ else die(`unknown plugins subcommand: ${sub}`);
21
+ }
@@ -0,0 +1,27 @@
1
+ // apx profile — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdProfileConfig, cmdProfileDoctor, cmdProfileInstall, cmdProfileList, cmdProfileOff, cmdProfileShow, cmdProfileUninstall, cmdProfileUse } from "../commands/profile.js";
8
+
9
+ // Aliases accepted for this command. Declared here, next to the command
10
+ // itself — a global alias table would be wrong, since the same word means
11
+ // different things under different commands ("rm" is remove under `agent`,
12
+ // unset under `project config`, revoke under `pair`).
13
+ export const aliases = ["profiles"];
14
+
15
+ export default async function route(rest, { parseArgs, die }) {
16
+ const sub = rest[0];
17
+ const a = parseArgs(rest.slice(1));
18
+ if (!sub || sub === "list" || sub === "ls") await cmdProfileList(a);
19
+ else if (sub === "show" || sub === "get") await cmdProfileShow(a);
20
+ else if (sub === "install" || sub === "add") await cmdProfileInstall(a);
21
+ else if (sub === "use" || sub === "activate") await cmdProfileUse(a);
22
+ else if (sub === "off" || sub === "deactivate") await cmdProfileOff(a);
23
+ else if (sub === "config") await cmdProfileConfig(a);
24
+ else if (sub === "doctor") await cmdProfileDoctor(a);
25
+ else if (sub === "uninstall" || sub === "remove" || sub === "rm") await cmdProfileUninstall(a);
26
+ else die(`unknown profile subcommand: ${sub}\nUsage: apx profile <list|show|install|use|off|config|doctor|uninstall>`);
27
+ }
@@ -0,0 +1,41 @@
1
+ // apx project — argument routing.
2
+ //
3
+ // Extracted from the 457-line dispatch() switch in cli/index.js. Each command
4
+ // owns its own routing and imports only the command functions it calls, so the
5
+ // CLI no longer loads all 38 command modules to run one of them.
6
+
7
+ import { cmdProjectConfigEdit, cmdProjectConfigSet, cmdProjectConfigShow, cmdProjectConfigUnset } from "../commands/project-config.js";
8
+ import { cmdProjectAdd, cmdProjectList, cmdProjectRebuild, cmdProjectRemove } from "../commands/project.js";
9
+
10
+ export default async function route(rest, { parseArgs, die, dispatch }) {
11
+ const sub = rest[0];
12
+ const a = parseArgs(rest.slice(1));
13
+ const PROJECT_SUBCOMMANDS = new Set([
14
+ "add", "list", "ls", "remove", "rm", "rebuild", "config",
15
+ ]);
16
+ if (sub === "add") await cmdProjectAdd(a);
17
+ else if (sub === "list" || sub === "ls") await cmdProjectList();
18
+ else if (sub === "remove" || sub === "rm") await cmdProjectRemove(a);
19
+ else if (sub === "rebuild") await cmdProjectRebuild(a);
20
+ else if (sub === "config") {
21
+ // apx project config <show|set|unset|edit> <project> ...
22
+ const csub = rest[1];
23
+ const ca = parseArgs(rest.slice(2));
24
+ if (csub === "show" || csub === "get") await cmdProjectConfigShow(ca);
25
+ else if (csub === "set") await cmdProjectConfigSet(ca);
26
+ else if (csub === "unset" || csub === "rm") await cmdProjectConfigUnset(ca);
27
+ else if (csub === "edit") await cmdProjectConfigEdit(ca);
28
+ else die(`unknown project config subcommand: ${csub || "(none)"} — try: show, set, unset, edit`);
29
+ }
30
+ else if (sub && !PROJECT_SUBCOMMANDS.has(sub)) {
31
+ // Sugar: `apx project <name|id> <subcommand...>` runs the inner
32
+ // subcommand with --project=<name|id> appended.
33
+ // apx project testing mcp list → apx mcp list --project testing
34
+ // apx project 2 routine list → apx routine list --project 2
35
+ const innerCmd = rest[1];
36
+ if (!innerCmd) die(`apx project ${sub}: missing subcommand`);
37
+ const innerRest = [...rest.slice(2), "--project", sub];
38
+ await dispatch(innerCmd, innerRest);
39
+ }
40
+ else die(`unknown project subcommand: ${sub || "(none)"}`);
41
+ }