@illumiarq/lumis 1.2.7 → 1.2.9

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 (296) hide show
  1. package/README.md +38 -0
  2. package/dist/adapter-loader.d.ts +67 -0
  3. package/dist/adapter-loader.d.ts.map +1 -0
  4. package/dist/adapter-loader.js +273 -0
  5. package/dist/adapter-loader.js.map +1 -0
  6. package/dist/cli.d.ts +16 -1
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +173 -402
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/commands.command.d.ts +38 -0
  11. package/dist/commands/commands.command.d.ts.map +1 -0
  12. package/dist/commands/commands.command.js +176 -0
  13. package/dist/commands/commands.command.js.map +1 -0
  14. package/dist/commands/doctor.command.d.ts +9 -0
  15. package/dist/commands/doctor.command.d.ts.map +1 -0
  16. package/dist/commands/doctor.command.js +640 -0
  17. package/dist/commands/doctor.command.js.map +1 -0
  18. package/dist/commands/init.command.d.ts +9 -0
  19. package/dist/commands/init.command.d.ts.map +1 -0
  20. package/dist/commands/init.command.js +121 -0
  21. package/dist/commands/init.command.js.map +1 -0
  22. package/dist/commands/intent.command.d.ts +26 -0
  23. package/dist/commands/intent.command.d.ts.map +1 -0
  24. package/dist/commands/intent.command.js +211 -0
  25. package/dist/commands/intent.command.js.map +1 -0
  26. package/dist/commands/ir-rebuild.command.d.ts +9 -0
  27. package/dist/commands/ir-rebuild.command.d.ts.map +1 -0
  28. package/dist/commands/ir-rebuild.command.js +36 -0
  29. package/dist/commands/ir-rebuild.command.js.map +1 -0
  30. package/dist/commands/ir-show.command.d.ts +9 -0
  31. package/dist/commands/ir-show.command.d.ts.map +1 -0
  32. package/dist/commands/ir-show.command.js +32 -0
  33. package/dist/commands/ir-show.command.js.map +1 -0
  34. package/dist/commands/make.command.d.ts +9 -0
  35. package/dist/commands/make.command.d.ts.map +1 -0
  36. package/dist/commands/make.command.js +93 -0
  37. package/dist/commands/make.command.js.map +1 -0
  38. package/dist/commands/pack.command.d.ts +16 -0
  39. package/dist/commands/pack.command.d.ts.map +1 -0
  40. package/dist/commands/pack.command.js +44 -0
  41. package/dist/commands/pack.command.js.map +1 -0
  42. package/dist/commands/runtime.command.d.ts +6 -0
  43. package/dist/commands/runtime.command.d.ts.map +1 -0
  44. package/dist/commands/runtime.command.js +379 -0
  45. package/dist/commands/runtime.command.js.map +1 -0
  46. package/dist/commands/runtime.d.ts +45 -0
  47. package/dist/commands/runtime.d.ts.map +1 -0
  48. package/dist/commands/runtime.js +66 -0
  49. package/dist/commands/runtime.js.map +1 -0
  50. package/dist/commands/tinker-agent-plan.d.ts +26 -0
  51. package/dist/commands/tinker-agent-plan.d.ts.map +1 -0
  52. package/dist/commands/tinker-agent-plan.js +115 -0
  53. package/dist/commands/tinker-agent-plan.js.map +1 -0
  54. package/dist/commands/tinker-chat-commands.d.ts +19 -0
  55. package/dist/commands/tinker-chat-commands.d.ts.map +1 -0
  56. package/dist/commands/tinker-chat-commands.js +263 -0
  57. package/dist/commands/tinker-chat-commands.js.map +1 -0
  58. package/dist/commands/tinker-chat-runtime.d.ts +30 -0
  59. package/dist/commands/tinker-chat-runtime.d.ts.map +1 -0
  60. package/dist/commands/tinker-chat-runtime.js +227 -0
  61. package/dist/commands/tinker-chat-runtime.js.map +1 -0
  62. package/dist/commands/tinker-classic-mode.d.ts +15 -0
  63. package/dist/commands/tinker-classic-mode.d.ts.map +1 -0
  64. package/dist/commands/tinker-classic-mode.js +160 -0
  65. package/dist/commands/tinker-classic-mode.js.map +1 -0
  66. package/dist/commands/tinker-eval.command.d.ts +3 -0
  67. package/dist/commands/tinker-eval.command.d.ts.map +1 -0
  68. package/dist/commands/tinker-eval.command.js +151 -0
  69. package/dist/commands/tinker-eval.command.js.map +1 -0
  70. package/dist/commands/tinker-repl-display.d.ts +15 -0
  71. package/dist/commands/tinker-repl-display.d.ts.map +1 -0
  72. package/dist/commands/tinker-repl-display.js +147 -0
  73. package/dist/commands/tinker-repl-display.js.map +1 -0
  74. package/dist/commands/tinker-session-runtime.d.ts +27 -0
  75. package/dist/commands/tinker-session-runtime.d.ts.map +1 -0
  76. package/dist/commands/tinker-session-runtime.js +196 -0
  77. package/dist/commands/tinker-session-runtime.js.map +1 -0
  78. package/dist/commands/tinker.command.d.ts +9 -0
  79. package/dist/commands/tinker.command.d.ts.map +1 -0
  80. package/dist/commands/tinker.command.js +142 -0
  81. package/dist/commands/tinker.command.js.map +1 -0
  82. package/dist/commands/use.command.d.ts +10 -0
  83. package/dist/commands/use.command.d.ts.map +1 -0
  84. package/dist/commands/use.command.js +69 -0
  85. package/dist/commands/use.command.js.map +1 -0
  86. package/dist/config-loader.d.ts +68 -0
  87. package/dist/config-loader.d.ts.map +1 -0
  88. package/dist/config-loader.js +81 -0
  89. package/dist/config-loader.js.map +1 -0
  90. package/dist/index.d.ts +19 -15
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +12 -12
  93. package/dist/index.js.map +1 -1
  94. package/dist/launcher.d.ts +16 -0
  95. package/dist/launcher.d.ts.map +1 -0
  96. package/dist/launcher.js +301 -0
  97. package/dist/launcher.js.map +1 -0
  98. package/dist/lib/file-scanner.d.ts +8 -0
  99. package/dist/lib/file-scanner.d.ts.map +1 -0
  100. package/dist/lib/file-scanner.js +70 -0
  101. package/dist/lib/file-scanner.js.map +1 -0
  102. package/dist/lib/tinker-memory.d.ts +19 -0
  103. package/dist/lib/tinker-memory.d.ts.map +1 -0
  104. package/dist/lib/tinker-memory.js +107 -0
  105. package/dist/lib/tinker-memory.js.map +1 -0
  106. package/dist/lib/tinker-observer.d.ts +47 -0
  107. package/dist/lib/tinker-observer.d.ts.map +1 -0
  108. package/dist/lib/tinker-observer.js +77 -0
  109. package/dist/lib/tinker-observer.js.map +1 -0
  110. package/dist/lib/tinker-policy.d.ts +21 -0
  111. package/dist/lib/tinker-policy.d.ts.map +1 -0
  112. package/dist/lib/tinker-policy.js +102 -0
  113. package/dist/lib/tinker-policy.js.map +1 -0
  114. package/dist/lib/tinker-replay.d.ts +51 -0
  115. package/dist/lib/tinker-replay.d.ts.map +1 -0
  116. package/dist/lib/tinker-replay.js +123 -0
  117. package/dist/lib/tinker-replay.js.map +1 -0
  118. package/dist/{console.d.ts → output/ansi.d.ts} +4 -8
  119. package/dist/output/ansi.d.ts.map +1 -0
  120. package/dist/{console.js → output/ansi.js} +4 -12
  121. package/dist/output/ansi.js.map +1 -0
  122. package/dist/output/plan-display.d.ts +4 -0
  123. package/dist/output/plan-display.d.ts.map +1 -0
  124. package/dist/output/plan-display.js +49 -0
  125. package/dist/output/plan-display.js.map +1 -0
  126. package/dist/output/result-display.d.ts +5 -0
  127. package/dist/output/result-display.d.ts.map +1 -0
  128. package/dist/output/result-display.js +17 -0
  129. package/dist/output/result-display.js.map +1 -0
  130. package/dist/plugins/tinker-plugin.d.ts +86 -0
  131. package/dist/plugins/tinker-plugin.d.ts.map +1 -0
  132. package/dist/plugins/tinker-plugin.js +42 -0
  133. package/dist/plugins/tinker-plugin.js.map +1 -0
  134. package/dist/router-preferences.d.ts +5 -0
  135. package/dist/router-preferences.d.ts.map +1 -0
  136. package/dist/router-preferences.js +22 -0
  137. package/dist/router-preferences.js.map +1 -0
  138. package/dist/runtime/executor.d.ts +33 -0
  139. package/dist/runtime/executor.d.ts.map +1 -0
  140. package/dist/runtime/executor.js +180 -0
  141. package/dist/runtime/executor.js.map +1 -0
  142. package/dist/runtime/orchestration.d.ts +43 -0
  143. package/dist/runtime/orchestration.d.ts.map +1 -0
  144. package/dist/runtime/orchestration.js +209 -0
  145. package/dist/runtime/orchestration.js.map +1 -0
  146. package/dist/runtime/policy.d.ts +23 -0
  147. package/dist/runtime/policy.d.ts.map +1 -0
  148. package/dist/runtime/policy.js +43 -0
  149. package/dist/runtime/policy.js.map +1 -0
  150. package/dist/runtime/profiles.d.ts +15 -0
  151. package/dist/runtime/profiles.d.ts.map +1 -0
  152. package/dist/runtime/profiles.js +131 -0
  153. package/dist/runtime/profiles.js.map +1 -0
  154. package/dist/runtime/transcripts.d.ts +59 -0
  155. package/dist/runtime/transcripts.d.ts.map +1 -0
  156. package/dist/runtime/transcripts.js +172 -0
  157. package/dist/runtime/transcripts.js.map +1 -0
  158. package/dist/tools/git-diff.d.ts +3 -0
  159. package/dist/tools/git-diff.d.ts.map +1 -0
  160. package/dist/tools/git-diff.js +16 -0
  161. package/dist/tools/git-diff.js.map +1 -0
  162. package/dist/tools/index.d.ts +24 -0
  163. package/dist/tools/index.d.ts.map +1 -0
  164. package/dist/tools/index.js +88 -0
  165. package/dist/tools/index.js.map +1 -0
  166. package/dist/tools/lint.d.ts +3 -0
  167. package/dist/tools/lint.d.ts.map +1 -0
  168. package/dist/tools/lint.js +35 -0
  169. package/dist/tools/lint.js.map +1 -0
  170. package/dist/tools/read-file.d.ts +3 -0
  171. package/dist/tools/read-file.d.ts.map +1 -0
  172. package/dist/tools/read-file.js +47 -0
  173. package/dist/tools/read-file.js.map +1 -0
  174. package/dist/tools/run-command.d.ts +3 -0
  175. package/dist/tools/run-command.d.ts.map +1 -0
  176. package/dist/tools/run-command.js +71 -0
  177. package/dist/tools/run-command.js.map +1 -0
  178. package/dist/tools/run-tests.d.ts +3 -0
  179. package/dist/tools/run-tests.d.ts.map +1 -0
  180. package/dist/tools/run-tests.js +49 -0
  181. package/dist/tools/run-tests.js.map +1 -0
  182. package/dist/tools/tool-dispatch.d.ts +32 -0
  183. package/dist/tools/tool-dispatch.d.ts.map +1 -0
  184. package/dist/tools/tool-dispatch.js +120 -0
  185. package/dist/tools/tool-dispatch.js.map +1 -0
  186. package/dist/tools/typecheck.d.ts +3 -0
  187. package/dist/tools/typecheck.d.ts.map +1 -0
  188. package/dist/tools/typecheck.js +48 -0
  189. package/dist/tools/typecheck.js.map +1 -0
  190. package/dist/tools/types.d.ts +62 -0
  191. package/dist/tools/types.d.ts.map +1 -0
  192. package/dist/tools/types.js +7 -0
  193. package/dist/tools/types.js.map +1 -0
  194. package/dist/tools/write-file.d.ts +15 -0
  195. package/dist/tools/write-file.d.ts.map +1 -0
  196. package/dist/tools/write-file.js +52 -0
  197. package/dist/tools/write-file.js.map +1 -0
  198. package/dist/tracing/types.d.ts +10 -0
  199. package/dist/tracing/types.d.ts.map +1 -0
  200. package/dist/tracing/types.js +2 -0
  201. package/dist/tracing/types.js.map +1 -0
  202. package/package.json +37 -19
  203. package/dist/bridges/project-bridge.d.ts +0 -2
  204. package/dist/bridges/project-bridge.d.ts.map +0 -1
  205. package/dist/bridges/project-bridge.js +0 -171
  206. package/dist/bridges/project-bridge.js.map +0 -1
  207. package/dist/commands/app/cache-workflows.d.ts +0 -7
  208. package/dist/commands/app/cache-workflows.d.ts.map +0 -1
  209. package/dist/commands/app/cache-workflows.js +0 -139
  210. package/dist/commands/app/cache-workflows.js.map +0 -1
  211. package/dist/commands/app/command-runtime.d.ts +0 -11
  212. package/dist/commands/app/command-runtime.d.ts.map +0 -1
  213. package/dist/commands/app/command-runtime.js +0 -41
  214. package/dist/commands/app/command-runtime.js.map +0 -1
  215. package/dist/commands/app/config-cache.d.ts +0 -3
  216. package/dist/commands/app/config-cache.d.ts.map +0 -1
  217. package/dist/commands/app/config-cache.js +0 -75
  218. package/dist/commands/app/config-cache.js.map +0 -1
  219. package/dist/commands/app/config-publish.d.ts +0 -2
  220. package/dist/commands/app/config-publish.d.ts.map +0 -1
  221. package/dist/commands/app/config-publish.js +0 -68
  222. package/dist/commands/app/config-publish.js.map +0 -1
  223. package/dist/commands/app/config-stubs.d.ts +0 -3
  224. package/dist/commands/app/config-stubs.d.ts.map +0 -1
  225. package/dist/commands/app/config-stubs.js +0 -154
  226. package/dist/commands/app/config-stubs.js.map +0 -1
  227. package/dist/commands/app/database.d.ts +0 -3
  228. package/dist/commands/app/database.d.ts.map +0 -1
  229. package/dist/commands/app/database.js +0 -221
  230. package/dist/commands/app/database.js.map +0 -1
  231. package/dist/commands/app/docs.d.ts +0 -7
  232. package/dist/commands/app/docs.d.ts.map +0 -1
  233. package/dist/commands/app/docs.js +0 -61
  234. package/dist/commands/app/docs.js.map +0 -1
  235. package/dist/commands/app/routes.d.ts +0 -5
  236. package/dist/commands/app/routes.d.ts.map +0 -1
  237. package/dist/commands/app/routes.js +0 -95
  238. package/dist/commands/app/routes.js.map +0 -1
  239. package/dist/commands/app/security.d.ts +0 -3
  240. package/dist/commands/app/security.d.ts.map +0 -1
  241. package/dist/commands/app/security.js +0 -15
  242. package/dist/commands/app/security.js.map +0 -1
  243. package/dist/commands/app/worker-schedule.d.ts +0 -5
  244. package/dist/commands/app/worker-schedule.d.ts.map +0 -1
  245. package/dist/commands/app/worker-schedule.js +0 -94
  246. package/dist/commands/app/worker-schedule.js.map +0 -1
  247. package/dist/commands/app-commands.d.ts +0 -19
  248. package/dist/commands/app-commands.d.ts.map +0 -1
  249. package/dist/commands/app-commands.js +0 -77
  250. package/dist/commands/app-commands.js.map +0 -1
  251. package/dist/commands/build-vercel-fn.d.ts +0 -9
  252. package/dist/commands/build-vercel-fn.d.ts.map +0 -1
  253. package/dist/commands/build-vercel-fn.js +0 -32
  254. package/dist/commands/build-vercel-fn.js.map +0 -1
  255. package/dist/commands/build.d.ts +0 -14
  256. package/dist/commands/build.d.ts.map +0 -1
  257. package/dist/commands/build.js +0 -24
  258. package/dist/commands/build.js.map +0 -1
  259. package/dist/commands/info.d.ts +0 -2
  260. package/dist/commands/info.d.ts.map +0 -1
  261. package/dist/commands/info.js +0 -25
  262. package/dist/commands/info.js.map +0 -1
  263. package/dist/commands/keys.d.ts +0 -3
  264. package/dist/commands/keys.d.ts.map +0 -1
  265. package/dist/commands/keys.js +0 -60
  266. package/dist/commands/keys.js.map +0 -1
  267. package/dist/commands/maintenance.d.ts +0 -9
  268. package/dist/commands/maintenance.d.ts.map +0 -1
  269. package/dist/commands/maintenance.js +0 -38
  270. package/dist/commands/maintenance.js.map +0 -1
  271. package/dist/commands/module-list.d.ts +0 -2
  272. package/dist/commands/module-list.d.ts.map +0 -1
  273. package/dist/commands/module-list.js +0 -27
  274. package/dist/commands/module-list.js.map +0 -1
  275. package/dist/commands/preview.d.ts +0 -14
  276. package/dist/commands/preview.d.ts.map +0 -1
  277. package/dist/commands/preview.js +0 -49
  278. package/dist/commands/preview.js.map +0 -1
  279. package/dist/commands/serve.d.ts +0 -16
  280. package/dist/commands/serve.d.ts.map +0 -1
  281. package/dist/commands/serve.js +0 -61
  282. package/dist/commands/serve.js.map +0 -1
  283. package/dist/console.d.ts.map +0 -1
  284. package/dist/console.js.map +0 -1
  285. package/dist/paths.d.ts +0 -21
  286. package/dist/paths.d.ts.map +0 -1
  287. package/dist/paths.js +0 -47
  288. package/dist/paths.js.map +0 -1
  289. package/dist/server-wrapper.d.ts +0 -12
  290. package/dist/server-wrapper.d.ts.map +0 -1
  291. package/dist/server-wrapper.js +0 -63
  292. package/dist/server-wrapper.js.map +0 -1
  293. package/dist/vercel-wrapper.d.ts +0 -6
  294. package/dist/vercel-wrapper.d.ts.map +0 -1
  295. package/dist/vercel-wrapper.js +0 -50
  296. package/dist/vercel-wrapper.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,421 +1,192 @@
1
- #!/usr/bin/env node
2
1
  /**
3
- * @illumiarq/lumis extended CLI entry point.
2
+ * Host CLI entrypoint and command dispatcher.
4
3
  *
5
- * Intercepts LumiARQ-specific commands (serve / build / preview) and
6
- * delegates everything else to the base @lumiarq/lumis runCli().
4
+ * Commands are declared in a registry and resolved by longest prefix match,
5
+ * enabling subcommands with free-form trailing arguments (e.g. `intent <text>`).
7
6
  */
8
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
9
- import { join } from 'node:path';
10
- import { ui, writeError, writeLine } from './console.js';
11
- import { readStorageRoot } from './paths.js';
12
- import { serveApp } from './commands/serve.js';
13
- import { buildApp } from './commands/build.js';
14
- import { buildVercelFunction } from './commands/build-vercel-fn.js';
15
- import { previewApp } from './commands/preview.js';
16
- import { showInfo } from './commands/info.js';
17
- import { listModules } from './commands/module-list.js';
18
- import { generateKeys, rotateKeys } from './commands/keys.js';
19
- import { enableMaintenanceMode, disableMaintenanceMode } from './commands/maintenance.js';
20
- import { cacheConfig, cacheRoutes, cacheSearchIndex, cacheViews, checkRoutes, clearConfigCache, clearOptimizationCaches, clearRouteCache, clearSearchIndex, clearViews, installAuth, listRoutes, optimizeForProduction, publishConfig, publishStubs, runDatabaseCommand, scheduleList, scheduleRun, showResolvedConfig, workerList, workerStart, } from './commands/app-commands.js';
21
- const argv = process.argv.slice(2);
22
- const cmd = argv[0];
23
- async function main() {
24
- if (argv.includes('--help') || cmd === 'help') {
25
- return renderCombinedHelp();
26
- }
27
- // ── LumiARQ-specific commands ──────────────────────────────────────────────
28
- if (cmd === 'serve') {
29
- const port = parsePort(argv);
30
- const host = parseHost(argv);
31
- return serveApp({ ...(port !== undefined ? { port } : {}), ...(host ? { host } : {}) });
32
- }
33
- if (cmd === 'preview') {
34
- const port = parsePort(argv);
35
- const target = parsePreviewTarget(argv);
36
- return previewApp({ ...(port !== undefined ? { port } : {}), ...(target ? { target } : {}) });
37
- }
38
- if (cmd === 'build') {
39
- const target = parseTarget(argv);
40
- return buildApp(target !== undefined ? { target } : {});
41
- }
42
- if (cmd === 'build:vercel') {
43
- return buildApp({ target: 'vercel' });
44
- }
45
- if (cmd === 'build:vercel-fn') {
46
- return buildVercelFunction();
47
- }
48
- if (cmd === 'info') {
49
- return showInfo();
50
- }
51
- if (cmd === 'health') {
52
- runHealthPreChecks();
53
- const { runCli } = await import('@lumiarq/lumis');
54
- return runCli(['doctor', ...argv.slice(1)]);
55
- }
56
- if (cmd === 'module:list') {
57
- return listModules();
58
- }
59
- if (cmd === 'key:generate') {
60
- return generateKeys();
61
- }
62
- if (cmd === 'key:rotate') {
63
- return rotateKeys();
64
- }
65
- if (cmd === 'config:show') {
66
- const configName = argv[1];
67
- if (!configName) {
68
- writeError(ui.fail('Usage: lumis config:show <name> [--json]'));
69
- return 1;
70
- }
71
- return showResolvedConfig(configName);
72
- }
73
- if (cmd === 'config:cache') {
74
- return cacheConfig();
75
- }
76
- if (cmd === 'config:clear') {
77
- return clearConfigCache();
78
- }
79
- if (cmd?.startsWith('db:')) {
80
- return await runDatabaseCommand(cmd, argv.slice(1));
81
- }
82
- if (cmd === 'route:list') {
83
- return listRoutes();
84
- }
85
- if (cmd === 'route:check') {
86
- return checkRoutes();
87
- }
88
- if (cmd === 'route:cache') {
89
- return cacheRoutes();
90
- }
91
- if (cmd === 'route:clear') {
92
- return clearRouteCache();
93
- }
94
- if (cmd === 'view:cache') {
95
- return cacheViews();
96
- }
97
- if (cmd === 'view:clear') {
98
- return clearViews();
99
- }
100
- if (cmd === 'search:index') {
101
- return cacheSearchIndex();
102
- }
103
- if (cmd === 'search:clear') {
104
- return clearSearchIndex();
105
- }
106
- if (cmd === 'optimize') {
107
- return optimizeForProduction();
108
- }
109
- if (cmd === 'optimize:clear') {
110
- return clearOptimizationCaches();
111
- }
112
- if (cmd === 'down') {
113
- const message = parseStringFlag(argv, '--message');
114
- const secret = parseStringFlag(argv, '--secret');
115
- const allowedIps = parseRepeatedFlag(argv, '--allow');
116
- return enableMaintenanceMode({
117
- ...(message ? { message } : {}),
118
- ...(secret ? { secret } : {}),
119
- ...(allowedIps.length > 0 ? { allowedIps } : {}),
120
- });
121
- }
122
- if (cmd === 'up') {
123
- return disableMaintenanceMode();
124
- }
125
- if (cmd === 'stub:publish') {
126
- return publishStubs({ all: argv.includes('--all'), iam: argv.includes('--iam') });
127
- }
128
- if (cmd === 'auth:install') {
129
- const uiFramework = parseStringFlag(argv, '--ui');
130
- return installAuth({
131
- iam: argv.includes('--iam'),
132
- ...(uiFramework ? { ui: uiFramework } : {}),
133
- });
134
- }
135
- if (cmd === 'publish') {
136
- const subCmd = argv[1];
137
- if (subCmd === 'config') {
138
- const configName = argv[2] ?? 'list';
139
- return publishConfig(configName, argv.includes('--force'));
140
- }
141
- if (subCmd === 'stub' || subCmd === 'stubs') {
142
- return publishStubs({ all: argv.includes('--all'), iam: argv.includes('--iam') });
143
- }
144
- writeError(ui.fail(`Unknown publish subcommand: "${subCmd}". Try: publish config <name>`));
145
- return 1;
146
- }
147
- if (cmd === 'worker:start') {
148
- return workerStart(argv.includes('--dev'));
149
- }
150
- if (cmd === 'worker:list') {
151
- return workerList();
152
- }
153
- if (cmd === 'schedule:list') {
154
- return scheduleList();
155
- }
156
- if (cmd === 'schedule:run') {
157
- return scheduleRun(argv[1] ?? '');
158
- }
159
- const projectCommandExit = await runProjectCommandDirect(argv);
160
- if (projectCommandExit !== null) {
161
- return projectCommandExit;
7
+ import { executeIntentCommand } from './commands/intent.command.js';
8
+ import { executeIrRebuildCommand } from './commands/ir-rebuild.command.js';
9
+ import { executeIrShowCommand } from './commands/ir-show.command.js';
10
+ import { executeMakeCommand } from './commands/make.command.js';
11
+ import { executeCommandsListCommand, executeCommandsRunCommand } from './commands/commands.command.js';
12
+ import { executeDoctorCommand } from './commands/doctor.command.js';
13
+ import { executeInitCommand } from './commands/init.command.js';
14
+ import { executeUseCommand } from './commands/use.command.js';
15
+ import { ansi } from './output/ansi.js';
16
+ import { executePackDetectCommand, executePackListCommand } from './commands/pack.command.js';
17
+ import { executeRuntimeRunCommand, executeRuntimeTranscriptsListCommand, executeRuntimeTranscriptsPruneCommand, executeRuntimeTranscriptsShowCommand, } from './commands/runtime.command.js';
18
+ import { createCommandContext } from './commands/runtime.js';
19
+ import { executeTinkerCommand } from './commands/tinker.command.js';
20
+ import { executeTinkerEvalCommand } from './commands/tinker-eval.command.js';
21
+ import { runInteractiveLauncher } from './launcher.js';
22
+ import { pathToFileURL } from 'node:url';
23
+ const COMMANDS = [
24
+ { path: ['use'], description: 'Set preferred AI runtime', handler: executeUseCommand },
25
+ { path: ['pack', 'list'], description: 'List built-in packs', handler: executePackListCommand },
26
+ { path: ['pack', 'detect'], description: 'Detect best pack for project', handler: executePackDetectCommand },
27
+ { path: ['commands', 'list'], description: 'List pack and project commands', handler: executeCommandsListCommand },
28
+ { path: ['commands', 'run'], description: 'Run a pack or project command', handler: executeCommandsRunCommand },
29
+ { path: ['doctor'], description: 'Run Lumis diagnostics for this project', handler: executeDoctorCommand },
30
+ { path: ['init'], description: 'Initialize Lumis in this project', handler: executeInitCommand },
31
+ { path: ['make'], description: 'Create artifacts from intent', handler: executeMakeCommand },
32
+ { path: ['intent'], description: 'Parse and inspect intent', handler: executeIntentCommand },
33
+ { path: ['ir', 'show'], description: 'Show current IR', handler: executeIrShowCommand },
34
+ { path: ['ir', 'rebuild'], description: 'Rebuild project IR', handler: executeIrRebuildCommand },
35
+ { path: ['runtime', 'run'], description: 'Run runtime profile tasks', handler: executeRuntimeRunCommand },
36
+ { path: ['runtime', 'transcripts', 'list'], description: 'List runtime transcripts', handler: executeRuntimeTranscriptsListCommand },
37
+ { path: ['runtime', 'transcripts', 'show'], description: 'Show runtime transcript details', handler: executeRuntimeTranscriptsShowCommand },
38
+ { path: ['runtime', 'transcripts', 'prune'], description: 'Prune runtime transcripts', handler: executeRuntimeTranscriptsPruneCommand },
39
+ { path: ['tinker', 'eval'], description: 'Run Tinker evaluation harness', handler: executeTinkerEvalCommand },
40
+ { path: ['tinker'], description: 'Run interactive tinker mode', handler: executeTinkerCommand },
41
+ ];
42
+ function createTraceListener() {
43
+ if (process.env.LUMIS_TRACE !== '1') {
44
+ return undefined;
162
45
  }
163
- // ── Delegate to base @lumiarq/lumis (lazy import avoids auto-run side effect)
164
- const { runCli } = await import('@lumiarq/lumis');
165
- return runCli(argv);
46
+ return async (event) => {
47
+ const payload = {
48
+ type: event.type,
49
+ name: event.name,
50
+ status: event.status,
51
+ ...(event.message ? { message: event.message } : {}),
52
+ ...(event.context ? { context: event.context } : {}),
53
+ };
54
+ process.stderr.write(`[lumis-trace] ${JSON.stringify(payload)}\n`);
55
+ };
166
56
  }
167
- async function renderCombinedHelp() {
168
- renderWrapperHelp();
169
- writeLine(ui.section('Base Lumis Commands'));
170
- const { runCli } = await import('@lumiarq/lumis');
171
- return runCli(['--help']);
57
+ async function emitTrace(onTrace, event) {
58
+ if (!onTrace)
59
+ return;
60
+ await onTrace(event);
172
61
  }
173
- function renderWrapperHelp() {
174
- writeLine();
175
- writeLine(ui.section('LumiARQ CLI'));
176
- writeLine(` ${ui.dim('Wrapper commands are shown first; core Lumis commands remain available underneath.')}`);
177
- writeLine();
178
- writeLine(` ${ui.bold('Runtime')}`);
179
- writeLine(' lumis serve [--port|-p <port>] [--host|-H <host>]');
180
- writeLine(' lumis build [--target|--to|--t|-t <node|static|cloudflare|vercel>]');
181
- writeLine(' lumis build:vercel');
182
- writeLine(' lumis preview [--target|--to|--t|-t <node|static|cloudflare>]');
183
- writeLine();
184
- writeLine(` ${ui.bold('App')}`);
185
- writeLine(' lumis info');
186
- writeLine(' lumis health');
187
- writeLine(' lumis module:list');
188
- writeLine(' lumis config:show <name>');
189
- writeLine(' lumis config:cache | config:clear');
190
- writeLine(' lumis route:list | route:check | route:cache | route:clear');
191
- writeLine(' lumis view:cache | view:clear');
192
- writeLine(' lumis search:index | search:clear');
193
- writeLine(' lumis optimize | optimize:clear');
194
- writeLine(' lumis key:generate | key:rotate');
195
- writeLine(' lumis down [--message <text>] [--secret <token>] [--allow <ip>]');
196
- writeLine(' lumis up');
197
- writeLine(' lumis auth:install [--iam] [--ui react]');
198
- writeLine(' lumis stub:publish [--all|--iam]');
199
- writeLine();
200
- writeLine(` ${ui.bold('Database')}`);
201
- writeLine(' lumis db:generate | db:migrate');
202
- writeLine(' lumis db:ping — verify DB connection and diagnose failures');
203
- writeLine(' lumis db:seed');
204
- writeLine(' lumis db:fresh — migrate + seed (destructive)');
205
- writeLine(' lumis db:reset — drop all tables + migrate');
206
- writeLine(' lumis db:studio — open drizzle-kit studio');
207
- writeLine();
208
- writeLine(` ${ui.bold('Config')}`);
209
- writeLine(' lumis publish config <name> — mail | queue | cache | storage | session | security | logging | auth');
210
- writeLine(' lumis publish config all — publish every config file');
211
- writeLine(' lumis publish config list — show available configs');
212
- writeLine();
213
- writeLine(` ${ui.bold('Workers & Scheduling')}`);
214
- writeLine(' lumis worker:start [--dev] — start background worker process');
215
- writeLine(' lumis worker:list — list registered workers + scheduled jobs');
216
- writeLine(' lumis schedule:list — list all cron jobs');
217
- writeLine(' lumis schedule:run <name> — run a specific cron job immediately');
218
- writeLine();
219
- writeLine(` ${ui.bold('Core Lumis')}`);
220
- writeLine(' lumis doctor | init | make | intent | ir:* | runtime:* | tinker');
221
- writeLine();
222
- writeLine(` ${ui.bold('Project Commands')}`);
223
- writeLine(' lumis <your:command> — run projectCommands entries directly');
224
- writeLine(' lumis commands run project <name>');
225
- writeLine();
62
+ function formatUsage() {
63
+ const lines = [
64
+ ansi.label('Core CLI'),
65
+ ` ${ansi.dim('Prompt -> Plan -> Confirm -> Execute -> Verified Result')}`,
66
+ '',
67
+ `${ansi.bold('Usage')}:`,
68
+ ` ${ansi.cyan('lumis --help')}`,
69
+ ];
70
+ for (const command of COMMANDS) {
71
+ lines.push(` ${ansi.cyan(`lumis ${command.path.join(' ')}`)} ${ansi.dim(`# ${command.description}`)}`);
72
+ }
73
+ return `${lines.join('\n')}\n`;
226
74
  }
227
- const BASE_COMMAND_ROOTS = new Set([
228
- 'use',
229
- 'pack',
230
- 'commands',
231
- 'doctor',
232
- 'init',
233
- 'make',
234
- 'intent',
235
- 'ir',
236
- 'runtime',
237
- 'tinker',
238
- ]);
239
- async function runProjectCommandDirect(args) {
240
- const candidate = args[0];
241
- if (!candidate) {
242
- return null;
243
- }
244
- if (BASE_COMMAND_ROOTS.has(candidate)) {
245
- return null;
246
- }
247
- const { runCli } = await import('@lumiarq/lumis');
248
- let stdout = '';
249
- let stderr = '';
250
- const listExit = await runCli(['commands', 'list', '--json'], {
251
- write: (chunk) => {
252
- stdout += chunk;
253
- },
254
- writeError: (chunk) => {
255
- stderr += chunk;
256
- },
257
- });
258
- if (listExit !== 0 || stderr.trim().length > 0) {
259
- return null;
260
- }
261
- let commands = [];
262
- try {
263
- commands = JSON.parse(stdout);
264
- }
265
- catch {
266
- return null;
267
- }
268
- const exists = commands.some((entry) => entry.source === 'project' && entry.name === candidate);
269
- if (!exists) {
75
+ /**
76
+ * Resolve command using longest prefix semantics.
77
+ *
78
+ * Example:
79
+ * - argv: ['intent', 'create', 'record']
80
+ * - match: ['intent'] with args ['create', 'record']
81
+ *
82
+ * @param argv - Raw command tokens after the executable name.
83
+ * @returns Matched command and trailing arguments, or null when no command matches.
84
+ */
85
+ function matchCommand(argv) {
86
+ const matches = COMMANDS.filter((command) => {
87
+ if (command.path.length > argv.length) {
88
+ return false;
89
+ }
90
+ return command.path.every((segment, index) => segment === argv[index]);
91
+ }).sort((left, right) => right.path.length - left.path.length);
92
+ const command = matches[0];
93
+ if (!command) {
270
94
  return null;
271
95
  }
272
- return runCli(['commands', 'run', 'project', candidate, ...args.slice(1)]);
96
+ return {
97
+ command,
98
+ args: argv.slice(command.path.length),
99
+ };
273
100
  }
274
- function runHealthPreChecks() {
275
- const cwd = process.cwd();
276
- const checks = [];
277
- // Required bootstrap files
278
- checks.push({
279
- label: 'bootstrap/entry.ts present',
280
- pass: existsSync(join(cwd, 'bootstrap', 'entry.ts')),
281
- fix: 'bootstrap/entry.ts is missing this is the HTTP server entrypoint.',
282
- });
283
- checks.push({
284
- label: 'bootstrap/providers.ts present',
285
- pass: existsSync(join(cwd, 'bootstrap', 'providers.ts')),
286
- fix: "bootstrap/providers.ts is missing service container won't boot.",
287
- });
288
- checks.push({
289
- label: 'config/app.ts present',
290
- pass: existsSync(join(cwd, 'config', 'app.ts')),
291
- fix: 'config/app.ts is missing run: lumis publish config app',
292
- });
293
- checks.push({
294
- label: '@types/node installed',
295
- pass: existsSync(join(cwd, 'node_modules', '@types', 'node')) ||
296
- existsSync(join(cwd, '..', 'node_modules', '@types', 'node')),
297
- fix: 'Install @types/node: pnpm add -D @types/node',
298
- });
299
- // Warn if queue driver isn't stub but worker.ts is missing
300
- const queueConfigPath = join(cwd, 'config', 'queue.ts');
301
- if (existsSync(queueConfigPath)) {
302
- const queueSrc = readFileSync(queueConfigPath, 'utf8');
303
- const usesBullmq = queueSrc.includes("'bullmq'") || queueSrc.includes('"bullmq"');
304
- if (usesBullmq) {
305
- checks.push({
306
- label: 'bootstrap/worker.ts present (queue driver: bullmq)',
307
- pass: existsSync(join(cwd, 'bootstrap', 'worker.ts')),
308
- fix: "Queue driver is 'bullmq' but bootstrap/worker.ts is missing. Create it to process queued jobs.",
101
+ /**
102
+ * Execute the host CLI command flow.
103
+ *
104
+ * @param argv - CLI arguments excluding the node/script prefix.
105
+ * @param options - Optional execution overrides for project root and output writers.
106
+ * @returns Exit code (0 success, non-zero failure).
107
+ */
108
+ export async function runCli(argv, options = {}) {
109
+ const write = options.write ?? ((message) => process.stdout.write(message));
110
+ const writeError = options.writeError ?? ((message) => process.stderr.write(message));
111
+ const onTrace = createTraceListener();
112
+ const stdin = options.stdin ?? process.stdin;
113
+ const stdout = options.stdout ?? process.stdout;
114
+ const interactiveMode = options.interactiveMode ?? 'auto';
115
+ const shouldRunInteractiveMenu = argv.length === 0 &&
116
+ !argv.includes('--help') &&
117
+ (interactiveMode === 'on' ||
118
+ (interactiveMode === 'auto' && process.env.CI !== 'true' && process.env.LUMIS_NO_TUI !== '1' && stdin.isTTY && stdout.isTTY));
119
+ if (shouldRunInteractiveMenu) {
120
+ await emitTrace(onTrace, {
121
+ type: 'command-dispatch',
122
+ status: 'start',
123
+ name: 'interactive-launcher',
124
+ context: { mode: interactiveMode },
125
+ });
126
+ const launcherResult = await runInteractiveLauncher({
127
+ projectRoot: options.projectRoot ?? process.cwd(),
128
+ write,
129
+ stdin,
130
+ stdout,
131
+ });
132
+ if (launcherResult.kind === 'exit') {
133
+ await emitTrace(onTrace, {
134
+ type: 'command-dispatch',
135
+ status: launcherResult.code === 0 ? 'success' : 'failure',
136
+ name: 'interactive-launcher',
137
+ context: { exitCode: launcherResult.code },
309
138
  });
139
+ return launcherResult.code;
310
140
  }
311
- }
312
- // Stale route loader warning
313
- const routesLoader = join(cwd, readStorageRoot(cwd), 'framework', 'cache', 'routes.loader.ts');
314
- if (existsSync(routesLoader)) {
315
- const loaderMtime = statSync(routesLoader).mtimeMs;
316
- const routesRoot = join(cwd, 'src', 'modules');
317
- let stale = false;
318
- if (existsSync(routesRoot)) {
319
- const stack = [routesRoot];
320
- while (stack.length > 0) {
321
- const dir = stack.pop();
322
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
323
- if (entry.isDirectory()) {
324
- stack.push(join(dir, entry.name));
325
- continue;
326
- }
327
- if (/\/http\/routes\/.+\.(ts|js)$/.test(join(dir, entry.name))) {
328
- if (statSync(join(dir, entry.name)).mtimeMs > loaderMtime) {
329
- stale = true;
330
- break;
331
- }
332
- }
333
- }
334
- if (stale)
335
- break;
336
- }
337
- }
338
- checks.push({
339
- label: 'route cache is fresh',
340
- pass: !stale,
341
- fix: 'Route files have changed since last cache. Run: lumis route:cache',
141
+ argv = launcherResult.argv;
142
+ }
143
+ if (argv.includes('--help') || argv.length === 0) {
144
+ await emitTrace(onTrace, {
145
+ type: 'command-dispatch',
146
+ status: 'info',
147
+ name: 'help',
148
+ context: { argvLength: argv.length },
342
149
  });
150
+ write(formatUsage());
151
+ return 0;
152
+ }
153
+ const matched = matchCommand(argv);
154
+ if (!matched) {
155
+ await emitTrace(onTrace, {
156
+ type: 'command-dispatch',
157
+ status: 'failure',
158
+ name: 'unknown-command',
159
+ message: argv.join(' '),
160
+ });
161
+ writeError(`${ansi.fail(`Unknown command: ${argv.join(' ')}`)}\n`);
162
+ write(formatUsage());
163
+ return 1;
343
164
  }
344
- const warnings = checks.filter((c) => !c.pass);
345
- if (warnings.length > 0) {
346
- writeLine();
347
- writeLine(ui.section('Health Pre-checks'));
348
- for (const w of warnings) {
349
- writeLine(` ${ui.warn(w.label)}`);
350
- if (w.fix)
351
- writeLine(` ${ui.dim(w.fix)}`);
352
- }
353
- writeLine();
354
- }
355
- }
356
- function parsePort(args) {
357
- const idx = args.findIndex((a) => a === '--port' || a === '-p');
358
- const inline = args.find((a) => a.startsWith('--port='));
359
- const raw = inline ? inline.split('=')[1] : idx !== -1 ? args[idx + 1] : undefined;
360
- if (raw)
361
- return parseInt(raw, 10);
362
- return undefined;
363
- }
364
- function parseHost(args) {
365
- const idx = args.findIndex((a) => a === '--host' || a === '-H');
366
- const inline = args.find((a) => a.startsWith('--host='));
367
- if (inline)
368
- return inline.split('=')[1];
369
- if (idx !== -1)
370
- return args[idx + 1];
371
- return undefined;
372
- }
373
- function parseTarget(args) {
374
- const idx = args.findIndex((a) => a === '--target' || a === '--to' || a === '--t' || a === '-t');
375
- const inline = args.find((a) => a.startsWith('--target=') || a.startsWith('--to=') || a.startsWith('--t='));
376
- if (inline) {
377
- const val = inline.slice(inline.indexOf('=') + 1);
378
- if (val === 'node' || val === 'static' || val === 'cloudflare' || val === 'vercel')
379
- return val;
380
- }
381
- if (idx !== -1) {
382
- const val = args[idx + 1];
383
- if (val === 'node' || val === 'static' || val === 'cloudflare' || val === 'vercel')
384
- return val;
385
- }
386
- return undefined;
387
- }
388
- function parsePreviewTarget(args) {
389
- const target = parseTarget(args);
390
- if (target === 'vercel') {
391
- writeError(ui.fail('`preview` does not support target "vercel". Use: lumis build --target vercel'));
392
- return undefined;
393
- }
394
- return target;
165
+ await emitTrace(onTrace, {
166
+ type: 'command-dispatch',
167
+ status: 'start',
168
+ name: matched.command.path.join(' '),
169
+ context: { args: matched.args },
170
+ });
171
+ const context = await createCommandContext({
172
+ argv,
173
+ commandPath: matched.command.path,
174
+ commandArgs: matched.args,
175
+ projectRoot: options.projectRoot ?? process.cwd(),
176
+ write,
177
+ writeError,
178
+ ...(onTrace ? { onTrace } : {}),
179
+ });
180
+ return matched.command.handler(context);
395
181
  }
396
- function parseStringFlag(args, flag) {
397
- const index = args.findIndex((value) => value === flag);
398
- const inline = args.find((value) => value.startsWith(`${flag}=`));
399
- if (inline) {
400
- return inline.slice(flag.length + 1);
401
- }
402
- if (index !== -1) {
403
- return args[index + 1];
182
+ function isMainModule() {
183
+ const argv1 = process.argv[1];
184
+ if (!argv1) {
185
+ return false;
404
186
  }
405
- return undefined;
187
+ return import.meta.url === pathToFileURL(argv1).href;
406
188
  }
407
- function parseRepeatedFlag(args, flag) {
408
- const values = [];
409
- for (let index = 0; index < args.length; index += 1) {
410
- const token = args[index];
411
- if (token === flag && args[index + 1]) {
412
- values.push(args[index + 1]);
413
- }
414
- if (token?.startsWith(`${flag}=`)) {
415
- values.push(token.slice(flag.length + 1));
416
- }
417
- }
418
- return values;
189
+ if (isMainModule()) {
190
+ void runCli(process.argv.slice(2));
419
191
  }
420
- main().then((code) => process.exit(code));
421
192
  //# sourceMappingURL=cli.js.map