luca 2.0.0 → 3.0.2

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 (532) hide show
  1. package/.github/workflows/release.yaml +170 -0
  2. package/AGENTS.md +99 -0
  3. package/CLAUDE.md +123 -0
  4. package/CNAME +1 -0
  5. package/README.md +275 -9
  6. package/RUNME.md +56 -0
  7. package/assistants/codingAssistant/ABOUT.md +5 -0
  8. package/assistants/codingAssistant/CORE.md +33 -0
  9. package/assistants/codingAssistant/hooks.ts +21 -0
  10. package/assistants/codingAssistant/tools.ts +12 -0
  11. package/assistants/inkbot/ABOUT.md +16 -0
  12. package/assistants/inkbot/CORE.md +330 -0
  13. package/assistants/inkbot/hooks.ts +6 -0
  14. package/assistants/inkbot/tools.ts +53 -0
  15. package/assistants/researcher/ABOUT.md +5 -0
  16. package/assistants/researcher/CORE.md +46 -0
  17. package/assistants/researcher/hooks.ts +16 -0
  18. package/assistants/researcher/tools.ts +237 -0
  19. package/bun.lock +2667 -0
  20. package/bunfig.toml +3 -0
  21. package/commands/audit-docs.ts +740 -0
  22. package/commands/build-bootstrap.ts +117 -0
  23. package/commands/build-python-bridge.ts +42 -0
  24. package/commands/build-scaffolds.ts +175 -0
  25. package/commands/bundle-consumer-project.ts +521 -0
  26. package/commands/generate-api-docs.ts +114 -0
  27. package/commands/inkbot.ts +874 -0
  28. package/commands/release.ts +80 -0
  29. package/commands/try-all-challenges.ts +543 -0
  30. package/commands/try-challenge.ts +100 -0
  31. package/dist/agi/container.server.d.ts +63 -0
  32. package/dist/agi/container.server.d.ts.map +1 -0
  33. package/dist/agi/endpoints/ask.d.ts +20 -0
  34. package/dist/agi/endpoints/ask.d.ts.map +1 -0
  35. package/dist/agi/endpoints/conversations/[id].d.ts +27 -0
  36. package/dist/agi/endpoints/conversations/[id].d.ts.map +1 -0
  37. package/dist/agi/endpoints/conversations.d.ts +18 -0
  38. package/dist/agi/endpoints/conversations.d.ts.map +1 -0
  39. package/dist/agi/endpoints/experts.d.ts +8 -0
  40. package/dist/agi/endpoints/experts.d.ts.map +1 -0
  41. package/dist/agi/feature.d.ts +9 -0
  42. package/dist/agi/feature.d.ts.map +1 -0
  43. package/dist/agi/features/assistant.d.ts +509 -0
  44. package/dist/agi/features/assistant.d.ts.map +1 -0
  45. package/dist/agi/features/assistants-manager.d.ts +236 -0
  46. package/dist/agi/features/assistants-manager.d.ts.map +1 -0
  47. package/dist/agi/features/autonomous-assistant.d.ts +281 -0
  48. package/dist/agi/features/autonomous-assistant.d.ts.map +1 -0
  49. package/dist/agi/features/browser-use.d.ts +479 -0
  50. package/dist/agi/features/browser-use.d.ts.map +1 -0
  51. package/dist/agi/features/claude-code.d.ts +824 -0
  52. package/dist/agi/features/claude-code.d.ts.map +1 -0
  53. package/dist/agi/features/conversation-history.d.ts +245 -0
  54. package/dist/agi/features/conversation-history.d.ts.map +1 -0
  55. package/dist/agi/features/conversation.d.ts +464 -0
  56. package/dist/agi/features/conversation.d.ts.map +1 -0
  57. package/dist/agi/features/docs-reader.d.ts +72 -0
  58. package/dist/agi/features/docs-reader.d.ts.map +1 -0
  59. package/dist/agi/features/file-tools.d.ts +110 -0
  60. package/dist/agi/features/file-tools.d.ts.map +1 -0
  61. package/dist/agi/features/luca-coder.d.ts +323 -0
  62. package/dist/agi/features/luca-coder.d.ts.map +1 -0
  63. package/dist/agi/features/openai-codex.d.ts +381 -0
  64. package/dist/agi/features/openai-codex.d.ts.map +1 -0
  65. package/dist/agi/features/openapi.d.ts +200 -0
  66. package/dist/agi/features/openapi.d.ts.map +1 -0
  67. package/dist/agi/features/skills-library.d.ts +167 -0
  68. package/dist/agi/features/skills-library.d.ts.map +1 -0
  69. package/dist/agi/index.d.ts +5 -0
  70. package/dist/agi/index.d.ts.map +1 -0
  71. package/dist/agi/lib/interceptor-chain.d.ts +44 -0
  72. package/dist/agi/lib/interceptor-chain.d.ts.map +1 -0
  73. package/dist/agi/lib/token-counter.d.ts +13 -0
  74. package/dist/agi/lib/token-counter.d.ts.map +1 -0
  75. package/dist/bootstrap/generated.d.ts +5 -0
  76. package/dist/bootstrap/generated.d.ts.map +1 -0
  77. package/dist/browser.d.ts +12 -0
  78. package/dist/browser.d.ts.map +1 -0
  79. package/dist/bus.d.ts +29 -0
  80. package/dist/bus.d.ts.map +1 -0
  81. package/dist/cli/build-info.d.ts +4 -0
  82. package/dist/cli/build-info.d.ts.map +1 -0
  83. package/dist/cli/cli.d.ts +3 -12
  84. package/dist/cli/cli.d.ts.map +1 -0
  85. package/dist/client.d.ts +60 -0
  86. package/dist/client.d.ts.map +1 -0
  87. package/dist/clients/civitai/index.d.ts +472 -0
  88. package/dist/clients/civitai/index.d.ts.map +1 -0
  89. package/dist/clients/client-template.d.ts +30 -0
  90. package/dist/clients/client-template.d.ts.map +1 -0
  91. package/dist/clients/comfyui/index.d.ts +281 -0
  92. package/dist/clients/comfyui/index.d.ts.map +1 -0
  93. package/dist/clients/elevenlabs/index.d.ts +197 -0
  94. package/dist/clients/elevenlabs/index.d.ts.map +1 -0
  95. package/dist/clients/graph.d.ts +64 -0
  96. package/dist/clients/graph.d.ts.map +1 -0
  97. package/dist/clients/openai/index.d.ts +247 -0
  98. package/dist/clients/openai/index.d.ts.map +1 -0
  99. package/dist/clients/rest.d.ts +92 -0
  100. package/dist/clients/rest.d.ts.map +1 -0
  101. package/dist/clients/supabase/index.d.ts +176 -0
  102. package/dist/clients/supabase/index.d.ts.map +1 -0
  103. package/dist/clients/websocket.d.ts +127 -0
  104. package/dist/clients/websocket.d.ts.map +1 -0
  105. package/dist/command.d.ts +163 -0
  106. package/dist/command.d.ts.map +1 -0
  107. package/dist/commands/bootstrap.d.ts +20 -0
  108. package/dist/commands/bootstrap.d.ts.map +1 -0
  109. package/dist/commands/chat.d.ts +37 -0
  110. package/dist/commands/chat.d.ts.map +1 -0
  111. package/dist/commands/code.d.ts +28 -0
  112. package/dist/commands/code.d.ts.map +1 -0
  113. package/dist/commands/console.d.ts +22 -0
  114. package/dist/commands/console.d.ts.map +1 -0
  115. package/dist/commands/describe.d.ts +50 -0
  116. package/dist/commands/describe.d.ts.map +1 -0
  117. package/dist/commands/eval.d.ts +23 -0
  118. package/dist/commands/eval.d.ts.map +1 -0
  119. package/dist/commands/help.d.ts +25 -0
  120. package/dist/commands/help.d.ts.map +1 -0
  121. package/dist/commands/index.d.ts +18 -0
  122. package/dist/commands/index.d.ts.map +1 -0
  123. package/dist/commands/introspect.d.ts +24 -0
  124. package/dist/commands/introspect.d.ts.map +1 -0
  125. package/dist/commands/mcp.d.ts +35 -0
  126. package/dist/commands/mcp.d.ts.map +1 -0
  127. package/dist/commands/prompt.d.ts +38 -0
  128. package/dist/commands/prompt.d.ts.map +1 -0
  129. package/dist/commands/run.d.ts +24 -0
  130. package/dist/commands/run.d.ts.map +1 -0
  131. package/dist/commands/sandbox-mcp.d.ts +34 -0
  132. package/dist/commands/sandbox-mcp.d.ts.map +1 -0
  133. package/dist/commands/save-api-docs.d.ts +21 -0
  134. package/dist/commands/save-api-docs.d.ts.map +1 -0
  135. package/dist/commands/scaffold.d.ts +24 -0
  136. package/dist/commands/scaffold.d.ts.map +1 -0
  137. package/dist/commands/select.d.ts +22 -0
  138. package/dist/commands/select.d.ts.map +1 -0
  139. package/dist/commands/serve.d.ts +29 -0
  140. package/dist/commands/serve.d.ts.map +1 -0
  141. package/dist/container-describer.d.ts +144 -0
  142. package/dist/container-describer.d.ts.map +1 -0
  143. package/dist/container.d.ts +451 -0
  144. package/dist/container.d.ts.map +1 -0
  145. package/dist/endpoint.d.ts +113 -0
  146. package/dist/endpoint.d.ts.map +1 -0
  147. package/dist/feature.d.ts +47 -0
  148. package/dist/feature.d.ts.map +1 -0
  149. package/dist/graft.d.ts +29 -0
  150. package/dist/graft.d.ts.map +1 -0
  151. package/dist/hash-object.d.ts +8 -0
  152. package/dist/hash-object.d.ts.map +1 -0
  153. package/dist/helper.d.ts +209 -0
  154. package/dist/helper.d.ts.map +1 -0
  155. package/dist/introspection/generated.node.d.ts +44623 -0
  156. package/dist/introspection/generated.node.d.ts.map +1 -0
  157. package/dist/introspection/generated.web.d.ts +1412 -0
  158. package/dist/introspection/generated.web.d.ts.map +1 -0
  159. package/dist/introspection/index.d.ts +156 -0
  160. package/dist/introspection/index.d.ts.map +1 -0
  161. package/dist/introspection/scan.d.ts +147 -0
  162. package/dist/introspection/scan.d.ts.map +1 -0
  163. package/dist/node/container.d.ts +256 -0
  164. package/dist/node/container.d.ts.map +1 -0
  165. package/dist/node/feature.d.ts +9 -0
  166. package/dist/node/feature.d.ts.map +1 -0
  167. package/dist/node/features/container-link.d.ts +213 -0
  168. package/dist/node/features/container-link.d.ts.map +1 -0
  169. package/dist/node/features/content-db.d.ts +354 -0
  170. package/dist/node/features/content-db.d.ts.map +1 -0
  171. package/dist/node/features/disk-cache.d.ts +236 -0
  172. package/dist/node/features/disk-cache.d.ts.map +1 -0
  173. package/dist/node/features/dns.d.ts +511 -0
  174. package/dist/node/features/dns.d.ts.map +1 -0
  175. package/dist/node/features/docker.d.ts +485 -0
  176. package/dist/node/features/docker.d.ts.map +1 -0
  177. package/dist/node/features/downloader.d.ts +73 -0
  178. package/dist/node/features/downloader.d.ts.map +1 -0
  179. package/dist/node/features/figlet-fonts.d.ts +4 -0
  180. package/dist/node/features/figlet-fonts.d.ts.map +1 -0
  181. package/dist/node/features/file-manager.d.ts +177 -0
  182. package/dist/node/features/file-manager.d.ts.map +1 -0
  183. package/dist/node/features/fs.d.ts +635 -0
  184. package/dist/node/features/fs.d.ts.map +1 -0
  185. package/dist/node/features/git.d.ts +329 -0
  186. package/dist/node/features/git.d.ts.map +1 -0
  187. package/dist/node/features/google-auth.d.ts +200 -0
  188. package/dist/node/features/google-auth.d.ts.map +1 -0
  189. package/dist/node/features/google-calendar.d.ts +194 -0
  190. package/dist/node/features/google-calendar.d.ts.map +1 -0
  191. package/dist/node/features/google-docs.d.ts +138 -0
  192. package/dist/node/features/google-docs.d.ts.map +1 -0
  193. package/dist/node/features/google-drive.d.ts +202 -0
  194. package/dist/node/features/google-drive.d.ts.map +1 -0
  195. package/dist/node/features/google-mail.d.ts +221 -0
  196. package/dist/node/features/google-mail.d.ts.map +1 -0
  197. package/dist/node/features/google-sheets.d.ts +157 -0
  198. package/dist/node/features/google-sheets.d.ts.map +1 -0
  199. package/dist/node/features/grep.d.ts +207 -0
  200. package/dist/node/features/grep.d.ts.map +1 -0
  201. package/dist/node/features/helpers.d.ts +236 -0
  202. package/dist/node/features/helpers.d.ts.map +1 -0
  203. package/dist/node/features/ink.d.ts +332 -0
  204. package/dist/node/features/ink.d.ts.map +1 -0
  205. package/dist/node/features/ipc-socket.d.ts +298 -0
  206. package/dist/node/features/ipc-socket.d.ts.map +1 -0
  207. package/dist/node/features/json-tree.d.ts +140 -0
  208. package/dist/node/features/json-tree.d.ts.map +1 -0
  209. package/dist/node/features/networking.d.ts +373 -0
  210. package/dist/node/features/networking.d.ts.map +1 -0
  211. package/dist/node/features/nlp.d.ts +125 -0
  212. package/dist/node/features/nlp.d.ts.map +1 -0
  213. package/dist/node/features/opener.d.ts +93 -0
  214. package/dist/node/features/opener.d.ts.map +1 -0
  215. package/dist/node/features/os.d.ts +168 -0
  216. package/dist/node/features/os.d.ts.map +1 -0
  217. package/dist/node/features/package-finder.d.ts +419 -0
  218. package/dist/node/features/package-finder.d.ts.map +1 -0
  219. package/dist/node/features/postgres.d.ts +173 -0
  220. package/dist/node/features/postgres.d.ts.map +1 -0
  221. package/dist/node/features/proc.d.ts +285 -0
  222. package/dist/node/features/proc.d.ts.map +1 -0
  223. package/dist/node/features/process-manager.d.ts +427 -0
  224. package/dist/node/features/process-manager.d.ts.map +1 -0
  225. package/dist/node/features/python.d.ts +477 -0
  226. package/dist/node/features/python.d.ts.map +1 -0
  227. package/dist/node/features/redis.d.ts +247 -0
  228. package/dist/node/features/redis.d.ts.map +1 -0
  229. package/dist/node/features/repl.d.ts +84 -0
  230. package/dist/node/features/repl.d.ts.map +1 -0
  231. package/dist/node/features/runpod.d.ts +527 -0
  232. package/dist/node/features/runpod.d.ts.map +1 -0
  233. package/dist/node/features/secure-shell.d.ts +145 -0
  234. package/dist/node/features/secure-shell.d.ts.map +1 -0
  235. package/dist/node/features/semantic-search.d.ts +207 -0
  236. package/dist/node/features/semantic-search.d.ts.map +1 -0
  237. package/dist/node/features/sqlite.d.ts +180 -0
  238. package/dist/node/features/sqlite.d.ts.map +1 -0
  239. package/dist/node/features/telegram.d.ts +173 -0
  240. package/dist/node/features/telegram.d.ts.map +1 -0
  241. package/dist/node/features/transpiler.d.ts +51 -0
  242. package/dist/node/features/transpiler.d.ts.map +1 -0
  243. package/dist/node/features/tts.d.ts +108 -0
  244. package/dist/node/features/tts.d.ts.map +1 -0
  245. package/dist/node/features/ui.d.ts +562 -0
  246. package/dist/node/features/ui.d.ts.map +1 -0
  247. package/dist/node/features/vault.d.ts +90 -0
  248. package/dist/node/features/vault.d.ts.map +1 -0
  249. package/dist/node/features/vm.d.ts +285 -0
  250. package/dist/node/features/vm.d.ts.map +1 -0
  251. package/dist/node/features/yaml-tree.d.ts +118 -0
  252. package/dist/node/features/yaml-tree.d.ts.map +1 -0
  253. package/dist/node/features/yaml.d.ts +127 -0
  254. package/dist/node/features/yaml.d.ts.map +1 -0
  255. package/dist/node.d.ts +67 -0
  256. package/dist/node.d.ts.map +1 -0
  257. package/dist/python/generated.d.ts +2 -0
  258. package/dist/python/generated.d.ts.map +1 -0
  259. package/dist/react/index.d.ts +36 -0
  260. package/dist/react/index.d.ts.map +1 -0
  261. package/dist/registry.d.ts +97 -0
  262. package/dist/registry.d.ts.map +1 -0
  263. package/dist/scaffolds/generated.d.ts +13 -0
  264. package/dist/scaffolds/generated.d.ts.map +1 -0
  265. package/dist/scaffolds/template.d.ts +11 -0
  266. package/dist/scaffolds/template.d.ts.map +1 -0
  267. package/dist/schemas/base.d.ts +254 -0
  268. package/dist/schemas/base.d.ts.map +1 -0
  269. package/dist/selector.d.ts +130 -0
  270. package/dist/selector.d.ts.map +1 -0
  271. package/dist/server.d.ts +89 -0
  272. package/dist/server.d.ts.map +1 -0
  273. package/dist/servers/express.d.ts +104 -0
  274. package/dist/servers/express.d.ts.map +1 -0
  275. package/dist/servers/mcp.d.ts +201 -0
  276. package/dist/servers/mcp.d.ts.map +1 -0
  277. package/dist/servers/socket.d.ts +121 -0
  278. package/dist/servers/socket.d.ts.map +1 -0
  279. package/dist/state.d.ts +24 -0
  280. package/dist/state.d.ts.map +1 -0
  281. package/dist/web/clients/socket.d.ts +37 -0
  282. package/dist/web/clients/socket.d.ts.map +1 -0
  283. package/dist/web/container.d.ts +55 -0
  284. package/dist/web/container.d.ts.map +1 -0
  285. package/dist/web/extension.d.ts +4 -0
  286. package/dist/web/extension.d.ts.map +1 -0
  287. package/dist/web/feature.d.ts +8 -0
  288. package/dist/web/feature.d.ts.map +1 -0
  289. package/dist/web/features/asset-loader.d.ts +35 -0
  290. package/dist/web/features/asset-loader.d.ts.map +1 -0
  291. package/dist/web/features/container-link.d.ts +167 -0
  292. package/dist/web/features/container-link.d.ts.map +1 -0
  293. package/dist/web/features/esbuild.d.ts +51 -0
  294. package/dist/web/features/esbuild.d.ts.map +1 -0
  295. package/dist/web/features/helpers.d.ts +140 -0
  296. package/dist/web/features/helpers.d.ts.map +1 -0
  297. package/dist/web/features/network.d.ts +69 -0
  298. package/dist/web/features/network.d.ts.map +1 -0
  299. package/dist/web/features/speech.d.ts +71 -0
  300. package/dist/web/features/speech.d.ts.map +1 -0
  301. package/dist/web/features/vault.d.ts +62 -0
  302. package/dist/web/features/vault.d.ts.map +1 -0
  303. package/dist/web/features/vm.d.ts +48 -0
  304. package/dist/web/features/vm.d.ts.map +1 -0
  305. package/dist/web/features/voice-recognition.d.ts +96 -0
  306. package/dist/web/features/voice-recognition.d.ts.map +1 -0
  307. package/dist/web/shims/isomorphic-vm.d.ts +22 -0
  308. package/dist/web/shims/isomorphic-vm.d.ts.map +1 -0
  309. package/index.html +1457 -0
  310. package/index.ts +1 -0
  311. package/install.sh +84 -0
  312. package/luca.cli.ts +16 -0
  313. package/luca.console.ts +9 -0
  314. package/main.py +6 -0
  315. package/package.json +219 -58
  316. package/public/index.html +1457 -0
  317. package/public/slides-ai-native.html +902 -0
  318. package/public/slides-intro.html +974 -0
  319. package/pyproject.toml +7 -0
  320. package/scripts/build-web.ts +28 -0
  321. package/scripts/examples/ask-luca-expert.ts +42 -0
  322. package/scripts/examples/assistant-questions.ts +12 -0
  323. package/scripts/examples/excalidraw-expert.ts +75 -0
  324. package/scripts/examples/expert-chat.ts +0 -0
  325. package/scripts/examples/file-manager.ts +14 -0
  326. package/scripts/examples/ideas.ts +12 -0
  327. package/scripts/examples/interactive-chat.ts +20 -0
  328. package/scripts/examples/openai-tool-calls.ts +113 -0
  329. package/scripts/examples/opening-a-web-browser.ts +5 -0
  330. package/scripts/examples/telegram-bot.ts +79 -0
  331. package/scripts/examples/using-assistant-with-mcp.ts +555 -0
  332. package/scripts/examples/using-claude-code.ts +10 -0
  333. package/scripts/examples/using-contentdb.ts +35 -0
  334. package/scripts/examples/using-conversations.ts +35 -0
  335. package/scripts/examples/using-disk-cache.ts +10 -0
  336. package/scripts/examples/using-docker-shell.ts +75 -0
  337. package/scripts/examples/using-elevenlabs.ts +25 -0
  338. package/scripts/examples/using-google-calendar.ts +57 -0
  339. package/scripts/examples/using-google-docs.ts +74 -0
  340. package/scripts/examples/using-google-drive.ts +74 -0
  341. package/scripts/examples/using-google-sheets.ts +89 -0
  342. package/scripts/examples/using-nlp.ts +55 -0
  343. package/scripts/examples/using-ollama.ts +11 -0
  344. package/scripts/examples/using-postgres.ts +55 -0
  345. package/scripts/examples/using-runpod.ts +32 -0
  346. package/scripts/examples/using-tts.ts +40 -0
  347. package/scripts/scaffold.ts +391 -0
  348. package/scripts/scratch.ts +15 -0
  349. package/scripts/stamp-build.sh +12 -0
  350. package/scripts/test-assistant-hooks.ts +13 -0
  351. package/scripts/test-docs-reader.ts +10 -0
  352. package/scripts/test-linux-binary.sh +80 -0
  353. package/scripts/update-introspection-data.ts +58 -0
  354. package/src/agi/README.md +14 -0
  355. package/src/agi/container.server.ts +156 -0
  356. package/src/agi/feature.ts +13 -0
  357. package/src/agi/features/agent-memory.ts +694 -0
  358. package/src/agi/features/assistant.ts +1653 -0
  359. package/src/agi/features/assistants-manager.ts +534 -0
  360. package/src/agi/features/autonomous-assistant.ts +431 -0
  361. package/src/agi/features/browser-use.ts +672 -0
  362. package/src/agi/features/claude-code.ts +1584 -0
  363. package/src/agi/features/coding-tools.ts +175 -0
  364. package/src/agi/features/conversation-history.ts +672 -0
  365. package/src/agi/features/conversation.ts +1494 -0
  366. package/src/agi/features/docs-reader.ts +167 -0
  367. package/src/agi/features/file-tools.ts +340 -0
  368. package/src/agi/features/luca-coder.ts +641 -0
  369. package/src/agi/features/mcp-bridge.ts +532 -0
  370. package/src/agi/features/openai-codex.ts +651 -0
  371. package/src/agi/features/openapi.ts +445 -0
  372. package/src/agi/features/skills-library.ts +557 -0
  373. package/src/agi/index.ts +6 -0
  374. package/src/agi/lib/interceptor-chain.ts +89 -0
  375. package/src/agi/lib/token-counter.ts +202 -0
  376. package/src/bootstrap/generated.ts +9791 -0
  377. package/src/browser.ts +25 -0
  378. package/src/bus.ts +122 -0
  379. package/src/cli/build-info.ts +4 -0
  380. package/src/cli/cli.ts +355 -0
  381. package/src/client.ts +170 -0
  382. package/src/clients/civitai/index.ts +537 -0
  383. package/src/clients/client-template.ts +41 -0
  384. package/src/clients/comfyui/index.ts +604 -0
  385. package/src/clients/elevenlabs/index.ts +317 -0
  386. package/src/clients/graph.ts +87 -0
  387. package/src/clients/openai/index.ts +456 -0
  388. package/src/clients/rest.ts +207 -0
  389. package/src/clients/supabase/index.ts +357 -0
  390. package/src/clients/voicebox/index.ts +300 -0
  391. package/src/clients/websocket.ts +251 -0
  392. package/src/command.ts +506 -0
  393. package/src/commands/bootstrap.ts +244 -0
  394. package/src/commands/chat.ts +309 -0
  395. package/src/commands/code.ts +371 -0
  396. package/src/commands/console.ts +189 -0
  397. package/src/commands/describe.ts +243 -0
  398. package/src/commands/eval.ts +67 -0
  399. package/src/commands/help.ts +240 -0
  400. package/src/commands/index.ts +19 -0
  401. package/src/commands/introspect.ts +218 -0
  402. package/src/commands/mcp.ts +64 -0
  403. package/src/commands/prompt.ts +1014 -0
  404. package/src/commands/run.ts +278 -0
  405. package/src/commands/sandbox-mcp.ts +343 -0
  406. package/src/commands/save-api-docs.ts +51 -0
  407. package/src/commands/scaffold.ts +225 -0
  408. package/src/commands/select.ts +99 -0
  409. package/src/commands/serve.ts +208 -0
  410. package/src/container-describer.ts +1091 -0
  411. package/src/container.ts +1199 -0
  412. package/src/endpoint.ts +365 -0
  413. package/src/entity.ts +173 -0
  414. package/src/feature.ts +118 -0
  415. package/src/graft.ts +181 -0
  416. package/src/hash-object.ts +97 -0
  417. package/src/helper.ts +849 -0
  418. package/src/introspection/generated.agi.ts +41200 -0
  419. package/src/introspection/generated.node.ts +28773 -0
  420. package/src/introspection/generated.web.ts +2272 -0
  421. package/src/introspection/index.ts +296 -0
  422. package/src/introspection/scan.ts +1136 -0
  423. package/src/node/container.ts +409 -0
  424. package/src/node/feature.ts +13 -0
  425. package/src/node/features/container-link.ts +559 -0
  426. package/src/node/features/content-db.ts +849 -0
  427. package/src/node/features/disk-cache.ts +388 -0
  428. package/src/node/features/display-result.ts +57 -0
  429. package/src/node/features/dns.ts +669 -0
  430. package/src/node/features/docker.ts +921 -0
  431. package/src/node/features/downloader.ts +79 -0
  432. package/src/node/features/figlet-fonts.ts +600 -0
  433. package/src/node/features/file-manager.ts +535 -0
  434. package/src/node/features/fs.ts +1050 -0
  435. package/src/node/features/git.ts +592 -0
  436. package/src/node/features/google-auth.ts +504 -0
  437. package/src/node/features/google-calendar.ts +306 -0
  438. package/src/node/features/google-docs.ts +412 -0
  439. package/src/node/features/google-drive.ts +346 -0
  440. package/src/node/features/google-mail.ts +540 -0
  441. package/src/node/features/google-sheets.ts +286 -0
  442. package/src/node/features/grep.ts +427 -0
  443. package/src/node/features/helpers.ts +762 -0
  444. package/src/node/features/ink.ts +490 -0
  445. package/src/node/features/ipc-socket.ts +649 -0
  446. package/src/node/features/json-tree.ts +170 -0
  447. package/src/node/features/networking.ts +961 -0
  448. package/src/node/features/nlp.ts +212 -0
  449. package/src/node/features/opener.ts +180 -0
  450. package/src/node/features/os.ts +403 -0
  451. package/src/node/features/package-finder.ts +540 -0
  452. package/src/node/features/postgres.ts +289 -0
  453. package/src/node/features/proc.ts +503 -0
  454. package/src/node/features/process-manager.ts +844 -0
  455. package/src/node/features/python.ts +912 -0
  456. package/src/node/features/redis.ts +446 -0
  457. package/src/node/features/repl.ts +212 -0
  458. package/src/node/features/runpod.ts +811 -0
  459. package/src/node/features/secure-shell.ts +261 -0
  460. package/src/node/features/semantic-search.ts +935 -0
  461. package/src/node/features/sqlite.ts +289 -0
  462. package/src/node/features/telegram.ts +343 -0
  463. package/src/node/features/transpiler.ts +160 -0
  464. package/src/node/features/tts.ts +185 -0
  465. package/src/node/features/ui.ts +791 -0
  466. package/src/node/features/vault.ts +153 -0
  467. package/src/node/features/vm.ts +462 -0
  468. package/src/node/features/yaml-tree.ts +148 -0
  469. package/src/node/features/yaml.ts +133 -0
  470. package/src/node.ts +76 -0
  471. package/src/python/bridge.py +220 -0
  472. package/src/python/generated.ts +226 -0
  473. package/src/react/index.ts +175 -0
  474. package/src/registry.ts +210 -0
  475. package/src/scaffolds/generated.ts +1814 -0
  476. package/src/scaffolds/template.ts +46 -0
  477. package/src/schemas/base.ts +296 -0
  478. package/src/selector.ts +352 -0
  479. package/src/server.ts +229 -0
  480. package/src/servers/express.ts +283 -0
  481. package/src/servers/mcp.ts +802 -0
  482. package/src/servers/socket.ts +258 -0
  483. package/src/state.ts +101 -0
  484. package/src/web/clients/socket.ts +99 -0
  485. package/src/web/container.ts +75 -0
  486. package/src/web/extension.ts +30 -0
  487. package/src/web/feature.ts +12 -0
  488. package/src/web/features/asset-loader.ts +72 -0
  489. package/src/web/features/container-link.ts +382 -0
  490. package/src/web/features/esbuild.ts +93 -0
  491. package/src/web/features/helpers.ts +291 -0
  492. package/src/web/features/network.ts +85 -0
  493. package/src/web/features/speech.ts +104 -0
  494. package/src/web/features/vault.ts +207 -0
  495. package/src/web/features/vm.ts +85 -0
  496. package/src/web/features/voice-recognition.ts +161 -0
  497. package/src/web/shims/isomorphic-vm.ts +149 -0
  498. package/tsconfig.build.json +12 -0
  499. package/tsconfig.json +58 -0
  500. package/uv.lock +8 -0
  501. package/LICENSE +0 -21
  502. package/dist/cli/cli.js +0 -48
  503. package/dist/cli/common.d.ts +0 -2
  504. package/dist/cli/common.js +0 -6
  505. package/dist/cli/index.d.ts +0 -2
  506. package/dist/cli/index.js +0 -5
  507. package/dist/cli/run.d.ts +0 -1
  508. package/dist/cli/run.js +0 -38
  509. package/dist/core/index.d.ts +0 -4
  510. package/dist/core/index.js +0 -32
  511. package/dist/core/read.d.ts +0 -2
  512. package/dist/core/read.js +0 -29
  513. package/dist/core/request.d.ts +0 -1
  514. package/dist/core/request.js +0 -2
  515. package/dist/core/write.d.ts +0 -2
  516. package/dist/core/write.js +0 -21
  517. package/dist/index.d.ts +0 -1
  518. package/dist/index.js +0 -5
  519. package/dist/utils/common.d.ts +0 -9
  520. package/dist/utils/common.js +0 -57
  521. package/dist/utils/consts.d.ts +0 -3
  522. package/dist/utils/consts.js +0 -11
  523. package/dist/utils/dict.d.ts +0 -1
  524. package/dist/utils/dict.js +0 -7
  525. package/dist/utils/index.d.ts +0 -5
  526. package/dist/utils/index.js +0 -21
  527. package/dist/utils/log.d.ts +0 -1
  528. package/dist/utils/log.js +0 -5
  529. package/dist/utils/types.d.ts +0 -1
  530. package/dist/utils/types.js +0 -2
  531. package/dist/utils/utils.test.d.ts +0 -1
  532. package/dist/utils/utils.test.js +0 -7
@@ -0,0 +1,1814 @@
1
+ // Auto-generated scaffold and MCP readme content
2
+ // Source: docs/scaffolds/*.md, docs/examples/assistant/, and docs/mcp/readme.md
3
+ //
4
+ // Do not edit manually. Run: luca build-scaffolds
5
+
6
+ export interface ScaffoldSection {
7
+ heading: string
8
+ code: string
9
+ }
10
+
11
+ export interface ScaffoldData {
12
+ sections: ScaffoldSection[]
13
+ full: string
14
+ tutorial: string
15
+ }
16
+
17
+ export const scaffolds: Record<string, ScaffoldData> = {
18
+ feature: {
19
+ sections: [
20
+ { heading: "Imports", code: `import { z } from 'zod'
21
+ import { FeatureStateSchema, FeatureOptionsSchema, FeatureEventsSchema } from 'luca'
22
+ import { Feature } from 'luca'` },
23
+ { heading: "Schemas", code: `export const {{PascalName}}StateSchema = FeatureStateSchema.extend({
24
+ // Add your state fields here. These are observable — changes emit events.
25
+ // Example: itemCount: z.number().default(0).describe('Number of items stored'),
26
+ })
27
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
28
+
29
+ export const {{PascalName}}OptionsSchema = FeatureOptionsSchema.extend({
30
+ // Add constructor options here. Validated when the feature is created.
31
+ // Example: directory: z.string().optional().describe('Storage directory path'),
32
+ })
33
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
34
+
35
+ export const {{PascalName}}EventsSchema = FeatureEventsSchema.extend({
36
+ // Each key is an event name. Value is z.tuple() of listener arguments.
37
+ // Example: itemAdded: z.tuple([z.string().describe('Item key')]).describe('Emitted when an item is added'),
38
+ })` },
39
+ { heading: "Class", code: `/**
40
+ * {{description}}
41
+ * \`\`\`typescript
42
+ * const {{camelName}} = container.feature('{{camelName}}')
43
+ * \`\`\`
44
+ *
45
+ * @extends Feature
46
+ */
47
+ export class {{PascalName}} extends Feature<{{PascalName}}State, {{PascalName}}Options> {
48
+ static override shortcut = 'features.{{camelName}}' as const
49
+ static override stateSchema = {{PascalName}}StateSchema
50
+ static override optionsSchema = {{PascalName}}OptionsSchema
51
+ static override eventsSchema = {{PascalName}}EventsSchema
52
+
53
+ static { Feature.register(this, '{{camelName}}') }
54
+
55
+ /**
56
+ * Called after the feature is initialized. Use this for any setup logic
57
+ * instead of overriding the constructor.
58
+ */
59
+ async afterInitialize() {
60
+ // Set up initial state, start background tasks, etc.
61
+ }
62
+ }` },
63
+ { heading: "Module Augmentation", code: `declare module 'luca' {
64
+ interface AvailableFeatures {
65
+ {{camelName}}: typeof {{PascalName}}
66
+ }
67
+ }` },
68
+ { heading: "Registration", code: `// Inside the class:
69
+ static { Feature.register(this, '{{camelName}}') }
70
+
71
+ // At module level:
72
+ export default {{PascalName}}` },
73
+ { heading: "Complete Example", code: `import { z } from 'zod'
74
+ import { FeatureStateSchema, FeatureOptionsSchema } from 'luca'
75
+ import { Feature } from 'luca'
76
+
77
+ declare module 'luca' {
78
+ interface AvailableFeatures {
79
+ {{camelName}}: typeof {{PascalName}}
80
+ }
81
+ }
82
+
83
+ export const {{PascalName}}StateSchema = FeatureStateSchema.extend({})
84
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
85
+
86
+ export const {{PascalName}}OptionsSchema = FeatureOptionsSchema.extend({})
87
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
88
+
89
+ /**
90
+ * {{description}}
91
+ *
92
+ * @example
93
+ * \`\`\`typescript
94
+ * const {{camelName}} = container.feature('{{camelName}}')
95
+ * \`\`\`
96
+ *
97
+ * @extends Feature
98
+ */
99
+ export class {{PascalName}} extends Feature<{{PascalName}}State, {{PascalName}}Options> {
100
+ static override shortcut = 'features.{{camelName}}' as const
101
+ static override stateSchema = {{PascalName}}StateSchema
102
+ static override optionsSchema = {{PascalName}}OptionsSchema
103
+ static { Feature.register(this, '{{camelName}}') }
104
+
105
+ async afterInitialize() {
106
+ // Setup logic goes here — not in the constructor
107
+ }
108
+ }
109
+
110
+ export default {{PascalName}}` }
111
+ ],
112
+ full: `import { z } from 'zod'
113
+ import { FeatureStateSchema, FeatureOptionsSchema } from 'luca'
114
+ import { Feature } from 'luca'
115
+
116
+ declare module 'luca' {
117
+ interface AvailableFeatures {
118
+ {{camelName}}: typeof {{PascalName}}
119
+ }
120
+ }
121
+
122
+ export const {{PascalName}}StateSchema = FeatureStateSchema.extend({})
123
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
124
+
125
+ export const {{PascalName}}OptionsSchema = FeatureOptionsSchema.extend({})
126
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
127
+
128
+ /**
129
+ * {{description}}
130
+ *
131
+ * @example
132
+ * \`\`\`typescript
133
+ * const {{camelName}} = container.feature('{{camelName}}')
134
+ * \`\`\`
135
+ *
136
+ * @extends Feature
137
+ */
138
+ export class {{PascalName}} extends Feature<{{PascalName}}State, {{PascalName}}Options> {
139
+ static override shortcut = 'features.{{camelName}}' as const
140
+ static override stateSchema = {{PascalName}}StateSchema
141
+ static override optionsSchema = {{PascalName}}OptionsSchema
142
+ static { Feature.register(this, '{{camelName}}') }
143
+
144
+ async afterInitialize() {
145
+ // Setup logic goes here — not in the constructor
146
+ }
147
+ }
148
+
149
+ export default {{PascalName}}`,
150
+ tutorial: `# Building a Feature
151
+
152
+ A feature is a container-managed capability — something your application needs that lives on the machine (file I/O, caching, encryption, etc). Features are lazy-loaded, observable, and self-documenting.
153
+
154
+ When to build a feature:
155
+ - You need a reusable local capability (not a network call — that's a client)
156
+ - You want state management, events, and introspection for free
157
+ - You're wrapping a library so the rest of the codebase uses a uniform interface
158
+
159
+ ## Imports
160
+
161
+ \`\`\`ts
162
+ import { z } from 'zod'
163
+ import { FeatureStateSchema, FeatureOptionsSchema, FeatureEventsSchema } from 'luca'
164
+ import { Feature } from 'luca'
165
+ \`\`\`
166
+
167
+ These are the only imports your feature file needs from luca. If your feature wraps a third-party library, import it here too — feature implementations are the ONE place where direct library imports are allowed.
168
+
169
+ The use of dynamic imports is encouraged here, only import libraries you need when the feature is used, and only when necessary in the lifecycle of the feature if it can be done.
170
+
171
+ feature's have built in ways to check if their requirements are supported and can be enabled cautiously.
172
+
173
+ ## Schemas
174
+
175
+ Define the shape of your feature's state, options, and events using Zod. Every field must have a \`.describe()\` — this becomes the documentation.
176
+
177
+ \`\`\`ts
178
+ export const {{PascalName}}StateSchema = FeatureStateSchema.extend({
179
+ // Add your state fields here. These are observable — changes emit events.
180
+ // Example: itemCount: z.number().default(0).describe('Number of items stored'),
181
+ })
182
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
183
+
184
+ export const {{PascalName}}OptionsSchema = FeatureOptionsSchema.extend({
185
+ // Add constructor options here. Validated when the feature is created.
186
+ // Example: directory: z.string().optional().describe('Storage directory path'),
187
+ })
188
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
189
+
190
+ export const {{PascalName}}EventsSchema = FeatureEventsSchema.extend({
191
+ // Each key is an event name. Value is z.tuple() of listener arguments.
192
+ // Example: itemAdded: z.tuple([z.string().describe('Item key')]).describe('Emitted when an item is added'),
193
+ })
194
+ \`\`\`
195
+
196
+ ## Class
197
+
198
+ The class extends \`Feature\` with your state and options types. Static properties drive registration and introspection. Every public method needs a JSDoc block with \`@param\`, \`@returns\`, and \`@example\`.
199
+
200
+ Running \`luca introspect\` captures JSDoc blocks and Zod schemas and includes them in the description whenever somebody calls \`container.features.describe('{{camelName}}')\` or \`luca describe {{camelName}}\`.
201
+
202
+ \`\`\`ts
203
+ /**
204
+ * {{description}}
205
+ * \`\`\`typescript
206
+ * const {{camelName}} = container.feature('{{camelName}}')
207
+ * \`\`\`
208
+ *
209
+ * @extends Feature
210
+ */
211
+ export class {{PascalName}} extends Feature<{{PascalName}}State, {{PascalName}}Options> {
212
+ static override shortcut = 'features.{{camelName}}' as const
213
+ static override stateSchema = {{PascalName}}StateSchema
214
+ static override optionsSchema = {{PascalName}}OptionsSchema
215
+ static override eventsSchema = {{PascalName}}EventsSchema
216
+
217
+ static { Feature.register(this, '{{camelName}}') }
218
+
219
+ /**
220
+ * Called after the feature is initialized. Use this for any setup logic
221
+ * instead of overriding the constructor.
222
+ */
223
+ async afterInitialize() {
224
+ // Set up initial state, start background tasks, etc.
225
+ }
226
+ }
227
+ \`\`\`
228
+
229
+ **Important**: You almost never need to override the constructor. Use \`afterInitialize()\` for any setup logic — it runs after the feature is fully wired into the container and has access to \`this.container\`, \`this.options\`, \`this.state\`, etc.
230
+
231
+ ## Module Augmentation
232
+
233
+ This is what gives \`container.feature('yourName')\` TypeScript autocomplete. Without it, the feature works but TypeScript won't know about it.
234
+
235
+ \`\`\`ts
236
+ declare module 'luca' {
237
+ interface AvailableFeatures {
238
+ {{camelName}}: typeof {{PascalName}}
239
+ }
240
+ }
241
+ \`\`\`
242
+
243
+ ## Registration
244
+
245
+ Registration happens inside the class body using a static block. The default export is just the class itself.
246
+
247
+ \`\`\`ts
248
+ // Inside the class:
249
+ static { Feature.register(this, '{{camelName}}') }
250
+
251
+ // At module level:
252
+ export default {{PascalName}}
253
+ \`\`\`
254
+
255
+ ## Complete Example
256
+
257
+ Here's a minimal but complete feature. This is what a real feature file looks like:
258
+
259
+ \`\`\`ts
260
+ import { z } from 'zod'
261
+ import { FeatureStateSchema, FeatureOptionsSchema } from 'luca'
262
+ import { Feature } from 'luca'
263
+
264
+ declare module 'luca' {
265
+ interface AvailableFeatures {
266
+ {{camelName}}: typeof {{PascalName}}
267
+ }
268
+ }
269
+
270
+ export const {{PascalName}}StateSchema = FeatureStateSchema.extend({})
271
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
272
+
273
+ export const {{PascalName}}OptionsSchema = FeatureOptionsSchema.extend({})
274
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
275
+
276
+ /**
277
+ * {{description}}
278
+ *
279
+ * @example
280
+ * \`\`\`typescript
281
+ * const {{camelName}} = container.feature('{{camelName}}')
282
+ * \`\`\`
283
+ *
284
+ * @extends Feature
285
+ */
286
+ export class {{PascalName}} extends Feature<{{PascalName}}State, {{PascalName}}Options> {
287
+ static override shortcut = 'features.{{camelName}}' as const
288
+ static override stateSchema = {{PascalName}}StateSchema
289
+ static override optionsSchema = {{PascalName}}OptionsSchema
290
+ static { Feature.register(this, '{{camelName}}') }
291
+
292
+ async afterInitialize() {
293
+ // Setup logic goes here — not in the constructor
294
+ }
295
+ }
296
+
297
+ export default {{PascalName}}
298
+ \`\`\`
299
+
300
+ ## Conventions
301
+
302
+ - **Naming**: PascalCase for class, camelCase for registration ID. The file name should be kebab-case (e.g. \`disk-cache.ts\`).
303
+ - **JSDoc**: Every public method, getter, and the class itself needs a JSDoc block. Include \`@example\` with working code.
304
+ - **Describe everything**: Every Zod field needs \`.describe()\`. Every event tuple argument needs \`.describe()\`. This IS the documentation.
305
+ - **No Node builtins in consumer code**: If your feature wraps \`fs\` or \`crypto\`, that's fine inside the feature. But code that USES your feature should never import those directly.
306
+ - **State is observable**: Use \`this.state.set()\` and \`this.state.get()\`. Don't use plain instance properties for data that should be reactive.
307
+ - **Events for lifecycle**: Emit events for significant state changes so consumers can react.
308
+ `,
309
+ },
310
+ client: {
311
+ sections: [
312
+ { heading: "Imports", code: `import { z } from 'zod'
313
+ import { Client, RestClient } from 'luca/client'
314
+ import { ClientStateSchema, ClientOptionsSchema, ClientEventsSchema } from 'luca'` },
315
+ { heading: "Schemas", code: `export const {{PascalName}}StateSchema = ClientStateSchema.extend({
316
+ // Add your state fields here.
317
+ // Example: authenticated: z.boolean().default(false).describe('Whether API auth is configured'),
318
+ })
319
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
320
+
321
+ export const {{PascalName}}OptionsSchema = ClientOptionsSchema.extend({
322
+ // Add constructor options here.
323
+ // Example: apiKey: z.string().optional().describe('API key for authentication'),
324
+ })
325
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>` },
326
+ { heading: "Class", code: `/**
327
+ * {{description}}
328
+ *
329
+ * @example
330
+ * \`\`\`typescript
331
+ * const {{camelName}} = container.client('{{camelName}}')
332
+ * \`\`\`
333
+ *
334
+ * @extends RestClient
335
+ */
336
+ export class {{PascalName}} extends RestClient<{{PascalName}}State, {{PascalName}}Options> {
337
+ static override shortcut = 'clients.{{camelName}}' as const
338
+ static override stateSchema = {{PascalName}}StateSchema
339
+ static override optionsSchema = {{PascalName}}OptionsSchema
340
+ static { Client.register(this, '{{camelName}}') }
341
+
342
+ /**
343
+ * Called after the client is initialized. Use this for any setup logic
344
+ * instead of overriding the constructor.
345
+ */
346
+ async afterInitialize() {
347
+ // Set up default headers, configure auth, etc.
348
+ }
349
+
350
+ // Add API methods here. Each wraps an endpoint.
351
+ // Example:
352
+ // async listItems(): Promise<Item[]> {
353
+ // return this.get('/items')
354
+ // }
355
+ }` },
356
+ { heading: "Module Augmentation", code: `declare module 'luca/client' {
357
+ interface AvailableClients {
358
+ {{camelName}}: typeof {{PascalName}}
359
+ }
360
+ }` },
361
+ { heading: "Registration", code: `// Inside the class:
362
+ static { Client.register(this, '{{camelName}}') }
363
+
364
+ // At module level:
365
+ export default {{PascalName}}` },
366
+ { heading: "Complete Example", code: `import { z } from 'zod'
367
+ import { Client, RestClient } from 'luca/client'
368
+ import { ClientStateSchema, ClientOptionsSchema } from 'luca'
369
+
370
+ declare module 'luca/client' {
371
+ interface AvailableClients {
372
+ {{camelName}}: typeof {{PascalName}}
373
+ }
374
+ }
375
+
376
+ export const {{PascalName}}StateSchema = ClientStateSchema.extend({})
377
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
378
+
379
+ export const {{PascalName}}OptionsSchema = ClientOptionsSchema.extend({
380
+ baseURL: z.string().default('https://api.example.com').describe('API base URL'),
381
+ })
382
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
383
+
384
+ /**
385
+ * {{description}}
386
+ *
387
+ * @example
388
+ * \`\`\`typescript
389
+ * const {{camelName}} = container.client('{{camelName}}')
390
+ * \`\`\`
391
+ *
392
+ * @extends RestClient
393
+ */
394
+ export class {{PascalName}} extends RestClient<{{PascalName}}State, {{PascalName}}Options> {
395
+ static override shortcut = 'clients.{{camelName}}' as const
396
+ static override stateSchema = {{PascalName}}StateSchema
397
+ static override optionsSchema = {{PascalName}}OptionsSchema
398
+ static { Client.register(this, '{{camelName}}') }
399
+
400
+ async afterInitialize() {
401
+ // Setup logic goes here — not in the constructor
402
+ }
403
+ }
404
+
405
+ export default {{PascalName}}` }
406
+ ],
407
+ full: `import { z } from 'zod'
408
+ import { Client, RestClient } from 'luca/client'
409
+ import { ClientStateSchema, ClientOptionsSchema } from 'luca'
410
+
411
+ declare module 'luca/client' {
412
+ interface AvailableClients {
413
+ {{camelName}}: typeof {{PascalName}}
414
+ }
415
+ }
416
+
417
+ export const {{PascalName}}StateSchema = ClientStateSchema.extend({})
418
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
419
+
420
+ export const {{PascalName}}OptionsSchema = ClientOptionsSchema.extend({
421
+ baseURL: z.string().default('https://api.example.com').describe('API base URL'),
422
+ })
423
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
424
+
425
+ /**
426
+ * {{description}}
427
+ *
428
+ * @example
429
+ * \`\`\`typescript
430
+ * const {{camelName}} = container.client('{{camelName}}')
431
+ * \`\`\`
432
+ *
433
+ * @extends RestClient
434
+ */
435
+ export class {{PascalName}} extends RestClient<{{PascalName}}State, {{PascalName}}Options> {
436
+ static override shortcut = 'clients.{{camelName}}' as const
437
+ static override stateSchema = {{PascalName}}StateSchema
438
+ static override optionsSchema = {{PascalName}}OptionsSchema
439
+ static { Client.register(this, '{{camelName}}') }
440
+
441
+ async afterInitialize() {
442
+ // Setup logic goes here — not in the constructor
443
+ }
444
+ }
445
+
446
+ export default {{PascalName}}`,
447
+ tutorial: `# Building a Client
448
+
449
+ A client is a container-managed connection to an external service. Clients handle network communication — HTTP APIs, WebSocket connections, GraphQL endpoints. They extend \`RestClient\` (for HTTP), \`WebSocketClient\` (for WS), or the base \`Client\` class.
450
+
451
+ When to build a client:
452
+ - You need to talk to an external API or service
453
+ - You want connection management, error handling, and observability for free
454
+ - You're wrapping an API so the rest of the codebase uses \`container.client('name')\`
455
+
456
+ ## Imports
457
+
458
+ \`\`\`ts
459
+ import { z } from 'zod'
460
+ import { Client, RestClient } from 'luca/client'
461
+ import { ClientStateSchema, ClientOptionsSchema, ClientEventsSchema } from 'luca'
462
+ \`\`\`
463
+
464
+ Use \`RestClient\` for HTTP APIs (most common). It gives you \`get\`, \`post\`, \`put\`, \`patch\`, \`delete\` methods that handle JSON, headers, and error wrapping.
465
+
466
+ ## Schemas
467
+
468
+ \`\`\`ts
469
+ export const {{PascalName}}StateSchema = ClientStateSchema.extend({
470
+ // Add your state fields here.
471
+ // Example: authenticated: z.boolean().default(false).describe('Whether API auth is configured'),
472
+ })
473
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
474
+
475
+ export const {{PascalName}}OptionsSchema = ClientOptionsSchema.extend({
476
+ // Add constructor options here.
477
+ // Example: apiKey: z.string().optional().describe('API key for authentication'),
478
+ })
479
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
480
+ \`\`\`
481
+
482
+ ## Class
483
+
484
+ Running \`luca introspect\` captures JSDoc blocks and Zod schemas and includes them in the description whenever somebody calls \`container.clients.describe('{{camelName}}')\` or \`luca describe {{camelName}}\`.
485
+
486
+ \`\`\`ts
487
+ /**
488
+ * {{description}}
489
+ *
490
+ * @example
491
+ * \`\`\`typescript
492
+ * const {{camelName}} = container.client('{{camelName}}')
493
+ * \`\`\`
494
+ *
495
+ * @extends RestClient
496
+ */
497
+ export class {{PascalName}} extends RestClient<{{PascalName}}State, {{PascalName}}Options> {
498
+ static override shortcut = 'clients.{{camelName}}' as const
499
+ static override stateSchema = {{PascalName}}StateSchema
500
+ static override optionsSchema = {{PascalName}}OptionsSchema
501
+ static { Client.register(this, '{{camelName}}') }
502
+
503
+ /**
504
+ * Called after the client is initialized. Use this for any setup logic
505
+ * instead of overriding the constructor.
506
+ */
507
+ async afterInitialize() {
508
+ // Set up default headers, configure auth, etc.
509
+ }
510
+
511
+ // Add API methods here. Each wraps an endpoint.
512
+ // Example:
513
+ // async listItems(): Promise<Item[]> {
514
+ // return this.get('/items')
515
+ // }
516
+ }
517
+ \`\`\`
518
+
519
+ **Important**: You almost never need to override the constructor. Use \`afterInitialize()\` for setup logic — it runs after the client is fully wired into the container. Set \`baseURL\` via the options schema default instead of constructor manipulation.
520
+
521
+ ## Module Augmentation
522
+
523
+ \`\`\`ts
524
+ declare module 'luca/client' {
525
+ interface AvailableClients {
526
+ {{camelName}}: typeof {{PascalName}}
527
+ }
528
+ }
529
+ \`\`\`
530
+
531
+ ## Registration
532
+
533
+ Registration happens inside the class body using a static block. The default export is just the class itself.
534
+
535
+ \`\`\`ts
536
+ // Inside the class:
537
+ static { Client.register(this, '{{camelName}}') }
538
+
539
+ // At module level:
540
+ export default {{PascalName}}
541
+ \`\`\`
542
+
543
+ ## Complete Example
544
+
545
+ \`\`\`ts
546
+ import { z } from 'zod'
547
+ import { Client, RestClient } from 'luca/client'
548
+ import { ClientStateSchema, ClientOptionsSchema } from 'luca'
549
+
550
+ declare module 'luca/client' {
551
+ interface AvailableClients {
552
+ {{camelName}}: typeof {{PascalName}}
553
+ }
554
+ }
555
+
556
+ export const {{PascalName}}StateSchema = ClientStateSchema.extend({})
557
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
558
+
559
+ export const {{PascalName}}OptionsSchema = ClientOptionsSchema.extend({
560
+ baseURL: z.string().default('https://api.example.com').describe('API base URL'),
561
+ })
562
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
563
+
564
+ /**
565
+ * {{description}}
566
+ *
567
+ * @example
568
+ * \`\`\`typescript
569
+ * const {{camelName}} = container.client('{{camelName}}')
570
+ * \`\`\`
571
+ *
572
+ * @extends RestClient
573
+ */
574
+ export class {{PascalName}} extends RestClient<{{PascalName}}State, {{PascalName}}Options> {
575
+ static override shortcut = 'clients.{{camelName}}' as const
576
+ static override stateSchema = {{PascalName}}StateSchema
577
+ static override optionsSchema = {{PascalName}}OptionsSchema
578
+ static { Client.register(this, '{{camelName}}') }
579
+
580
+ async afterInitialize() {
581
+ // Setup logic goes here — not in the constructor
582
+ }
583
+ }
584
+
585
+ export default {{PascalName}}
586
+ \`\`\`
587
+
588
+ ## Conventions
589
+
590
+ - **Extend RestClient for HTTP**: It gives you typed HTTP methods. Only use base \`Client\` if you need a non-HTTP protocol.
591
+ - **Set baseURL via options schema**: Use a Zod \`.default()\` on the \`baseURL\` field rather than overriding the constructor.
592
+ - **Use \`afterInitialize()\`**: For any setup logic (auth, default headers, etc.) instead of overriding the constructor.
593
+ - **Wrap endpoints as methods**: Each API endpoint gets a method. Keep them thin — just map to HTTP calls.
594
+ - **JSDoc everything**: Every public method needs \`@param\`, \`@returns\`, \`@example\`. Run \`luca introspect\` after changes to update generated docs.
595
+ - **Auth in options**: Pass API keys, tokens via options schema. Check them in \`afterInitialize()\` or a setup method.
596
+ `,
597
+ },
598
+ server: {
599
+ sections: [
600
+ { heading: "Imports", code: `import { z } from 'zod'
601
+ import { Server } from 'luca'
602
+ import { ServerStateSchema, ServerOptionsSchema, ServerEventsSchema } from 'luca'
603
+ import type { NodeContainer } from 'luca'
604
+ import type { ServersInterface } from 'luca'` },
605
+ { heading: "Schemas", code: `export const {{PascalName}}StateSchema = ServerStateSchema.extend({
606
+ // Add your state fields here.
607
+ // Example: connectionCount: z.number().default(0).describe('Active connections'),
608
+ })
609
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
610
+
611
+ export const {{PascalName}}OptionsSchema = ServerOptionsSchema.extend({
612
+ // Add constructor options here. port and host come from ServerOptionsSchema.
613
+ // Example: cors: z.boolean().default(true).describe('Enable CORS'),
614
+ })
615
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
616
+
617
+ export const {{PascalName}}EventsSchema = ServerEventsSchema.extend({
618
+ // Add your events here.
619
+ // Example: connection: z.tuple([z.string().describe('Client ID')]).describe('New client connected'),
620
+ })` },
621
+ { heading: "Class", code: `/**
622
+ * {{description}}
623
+ *
624
+ * @example
625
+ * \`\`\`typescript
626
+ * const {{camelName}} = container.server('{{camelName}}', { port: 3000 })
627
+ * await {{camelName}}.start()
628
+ * \`\`\`
629
+ *
630
+ * @extends Server
631
+ */
632
+ export class {{PascalName}} extends Server<{{PascalName}}State, {{PascalName}}Options> {
633
+ static override shortcut = 'servers.{{camelName}}' as const
634
+ static override stateSchema = {{PascalName}}StateSchema
635
+ static override optionsSchema = {{PascalName}}OptionsSchema
636
+ static override eventsSchema = {{PascalName}}EventsSchema
637
+ static { Server.register(this, '{{camelName}}') }
638
+
639
+ static override attach(container: NodeContainer & ServersInterface) {
640
+ return container
641
+ }
642
+
643
+ override async configure() {
644
+ if (this.isConfigured) return this
645
+ // Set up the underlying server here
646
+ this.state.set('configured', true)
647
+ return this
648
+ }
649
+
650
+ override async start(options?: { port?: number }) {
651
+ if (this.isListening) return this
652
+ if (!this.isConfigured) await this.configure()
653
+
654
+ const port = options?.port || this.options.port || 3000
655
+ // Start listening here
656
+ this.state.set('port', port)
657
+ this.state.set('listening', true)
658
+ return this
659
+ }
660
+
661
+ override async stop() {
662
+ if (this.isStopped) return this
663
+ // Clean up connections here
664
+ this.state.set('listening', false)
665
+ this.state.set('stopped', true)
666
+ return this
667
+ }
668
+ }` },
669
+ { heading: "Module Augmentation", code: `declare module 'luca' {
670
+ interface AvailableServers {
671
+ {{camelName}}: typeof {{PascalName}}
672
+ }
673
+ }` },
674
+ { heading: "Registration", code: `// Inside the class:
675
+ static { Server.register(this, '{{camelName}}') }
676
+
677
+ // At module level:
678
+ export default {{PascalName}}` },
679
+ { heading: "Complete Example", code: `import { z } from 'zod'
680
+ import { Server } from 'luca'
681
+ import { ServerStateSchema, ServerOptionsSchema, ServerEventsSchema } from 'luca'
682
+ import type { NodeContainer } from 'luca'
683
+ import type { ServersInterface } from 'luca'
684
+
685
+ declare module 'luca' {
686
+ interface AvailableServers {
687
+ {{camelName}}: typeof {{PascalName}}
688
+ }
689
+ }
690
+
691
+ export const {{PascalName}}StateSchema = ServerStateSchema.extend({})
692
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
693
+
694
+ export const {{PascalName}}OptionsSchema = ServerOptionsSchema.extend({})
695
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
696
+
697
+ export const {{PascalName}}EventsSchema = ServerEventsSchema.extend({})
698
+
699
+ /**
700
+ * {{description}}
701
+ *
702
+ * @example
703
+ * \`\`\`typescript
704
+ * const {{camelName}} = container.server('{{camelName}}', { port: 3000 })
705
+ * await {{camelName}}.start()
706
+ * \`\`\`
707
+ *
708
+ * @extends Server
709
+ */
710
+ export class {{PascalName}} extends Server<{{PascalName}}State, {{PascalName}}Options> {
711
+ static override shortcut = 'servers.{{camelName}}' as const
712
+ static override stateSchema = {{PascalName}}StateSchema
713
+ static override optionsSchema = {{PascalName}}OptionsSchema
714
+ static override eventsSchema = {{PascalName}}EventsSchema
715
+ static { Server.register(this, '{{camelName}}') }
716
+
717
+ static override attach(container: NodeContainer & ServersInterface) {
718
+ return container
719
+ }
720
+
721
+ override async configure() {
722
+ if (this.isConfigured) return this
723
+ this.state.set('configured', true)
724
+ return this
725
+ }
726
+
727
+ override async start(options?: { port?: number }) {
728
+ if (this.isListening) return this
729
+ if (!this.isConfigured) await this.configure()
730
+ const port = options?.port || this.options.port || 3000
731
+ this.state.set('port', port)
732
+ this.state.set('listening', true)
733
+ return this
734
+ }
735
+
736
+ override async stop() {
737
+ if (this.isStopped) return this
738
+ this.state.set('listening', false)
739
+ this.state.set('stopped', true)
740
+ return this
741
+ }
742
+ }
743
+
744
+ export default {{PascalName}}` }
745
+ ],
746
+ full: `import { z } from 'zod'
747
+ import { Server } from 'luca'
748
+ import { ServerStateSchema, ServerOptionsSchema, ServerEventsSchema } from 'luca'
749
+ import type { NodeContainer } from 'luca'
750
+ import type { ServersInterface } from 'luca'
751
+
752
+ declare module 'luca' {
753
+ interface AvailableServers {
754
+ {{camelName}}: typeof {{PascalName}}
755
+ }
756
+ }
757
+
758
+ export const {{PascalName}}StateSchema = ServerStateSchema.extend({})
759
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
760
+
761
+ export const {{PascalName}}OptionsSchema = ServerOptionsSchema.extend({})
762
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
763
+
764
+ export const {{PascalName}}EventsSchema = ServerEventsSchema.extend({})
765
+
766
+ /**
767
+ * {{description}}
768
+ *
769
+ * @example
770
+ * \`\`\`typescript
771
+ * const {{camelName}} = container.server('{{camelName}}', { port: 3000 })
772
+ * await {{camelName}}.start()
773
+ * \`\`\`
774
+ *
775
+ * @extends Server
776
+ */
777
+ export class {{PascalName}} extends Server<{{PascalName}}State, {{PascalName}}Options> {
778
+ static override shortcut = 'servers.{{camelName}}' as const
779
+ static override stateSchema = {{PascalName}}StateSchema
780
+ static override optionsSchema = {{PascalName}}OptionsSchema
781
+ static override eventsSchema = {{PascalName}}EventsSchema
782
+ static { Server.register(this, '{{camelName}}') }
783
+
784
+ static override attach(container: NodeContainer & ServersInterface) {
785
+ return container
786
+ }
787
+
788
+ override async configure() {
789
+ if (this.isConfigured) return this
790
+ this.state.set('configured', true)
791
+ return this
792
+ }
793
+
794
+ override async start(options?: { port?: number }) {
795
+ if (this.isListening) return this
796
+ if (!this.isConfigured) await this.configure()
797
+ const port = options?.port || this.options.port || 3000
798
+ this.state.set('port', port)
799
+ this.state.set('listening', true)
800
+ return this
801
+ }
802
+
803
+ override async stop() {
804
+ if (this.isStopped) return this
805
+ this.state.set('listening', false)
806
+ this.state.set('stopped', true)
807
+ return this
808
+ }
809
+ }
810
+
811
+ export default {{PascalName}}`,
812
+ tutorial: `# Building a Server
813
+
814
+ A server is a container-managed listener — something that accepts connections and handles requests. Servers manage their own lifecycle (configure, start, stop) and expose observable state.
815
+
816
+ When to build a server:
817
+ - You need to accept incoming connections (HTTP, WebSocket, custom protocol)
818
+ - You want lifecycle management, port handling, and observability for free
819
+ - You're wrapping a server library so the codebase uses \`container.server('name')\`
820
+
821
+ ## Imports
822
+
823
+ \`\`\`ts
824
+ import { z } from 'zod'
825
+ import { Server } from 'luca'
826
+ import { ServerStateSchema, ServerOptionsSchema, ServerEventsSchema } from 'luca'
827
+ import type { NodeContainer } from 'luca'
828
+ import type { ServersInterface } from 'luca'
829
+ \`\`\`
830
+
831
+ ## Schemas
832
+
833
+ \`\`\`ts
834
+ export const {{PascalName}}StateSchema = ServerStateSchema.extend({
835
+ // Add your state fields here.
836
+ // Example: connectionCount: z.number().default(0).describe('Active connections'),
837
+ })
838
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
839
+
840
+ export const {{PascalName}}OptionsSchema = ServerOptionsSchema.extend({
841
+ // Add constructor options here. port and host come from ServerOptionsSchema.
842
+ // Example: cors: z.boolean().default(true).describe('Enable CORS'),
843
+ })
844
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
845
+
846
+ export const {{PascalName}}EventsSchema = ServerEventsSchema.extend({
847
+ // Add your events here.
848
+ // Example: connection: z.tuple([z.string().describe('Client ID')]).describe('New client connected'),
849
+ })
850
+ \`\`\`
851
+
852
+ ## Class
853
+
854
+ Running \`luca introspect\` captures JSDoc blocks and Zod schemas and includes them in the description whenever somebody calls \`container.servers.describe('{{camelName}}')\` or \`luca describe {{camelName}}\`.
855
+
856
+ \`\`\`ts
857
+ /**
858
+ * {{description}}
859
+ *
860
+ * @example
861
+ * \`\`\`typescript
862
+ * const {{camelName}} = container.server('{{camelName}}', { port: 3000 })
863
+ * await {{camelName}}.start()
864
+ * \`\`\`
865
+ *
866
+ * @extends Server
867
+ */
868
+ export class {{PascalName}} extends Server<{{PascalName}}State, {{PascalName}}Options> {
869
+ static override shortcut = 'servers.{{camelName}}' as const
870
+ static override stateSchema = {{PascalName}}StateSchema
871
+ static override optionsSchema = {{PascalName}}OptionsSchema
872
+ static override eventsSchema = {{PascalName}}EventsSchema
873
+ static { Server.register(this, '{{camelName}}') }
874
+
875
+ static override attach(container: NodeContainer & ServersInterface) {
876
+ return container
877
+ }
878
+
879
+ override async configure() {
880
+ if (this.isConfigured) return this
881
+ // Set up the underlying server here
882
+ this.state.set('configured', true)
883
+ return this
884
+ }
885
+
886
+ override async start(options?: { port?: number }) {
887
+ if (this.isListening) return this
888
+ if (!this.isConfigured) await this.configure()
889
+
890
+ const port = options?.port || this.options.port || 3000
891
+ // Start listening here
892
+ this.state.set('port', port)
893
+ this.state.set('listening', true)
894
+ return this
895
+ }
896
+
897
+ override async stop() {
898
+ if (this.isStopped) return this
899
+ // Clean up connections here
900
+ this.state.set('listening', false)
901
+ this.state.set('stopped', true)
902
+ return this
903
+ }
904
+ }
905
+ \`\`\`
906
+
907
+ ## Module Augmentation
908
+
909
+ \`\`\`ts
910
+ declare module 'luca' {
911
+ interface AvailableServers {
912
+ {{camelName}}: typeof {{PascalName}}
913
+ }
914
+ }
915
+ \`\`\`
916
+
917
+ ## Registration
918
+
919
+ Registration happens inside the class body using a static block. The default export is just the class itself.
920
+
921
+ \`\`\`ts
922
+ // Inside the class:
923
+ static { Server.register(this, '{{camelName}}') }
924
+
925
+ // At module level:
926
+ export default {{PascalName}}
927
+ \`\`\`
928
+
929
+ ## Complete Example
930
+
931
+ \`\`\`ts
932
+ import { z } from 'zod'
933
+ import { Server } from 'luca'
934
+ import { ServerStateSchema, ServerOptionsSchema, ServerEventsSchema } from 'luca'
935
+ import type { NodeContainer } from 'luca'
936
+ import type { ServersInterface } from 'luca'
937
+
938
+ declare module 'luca' {
939
+ interface AvailableServers {
940
+ {{camelName}}: typeof {{PascalName}}
941
+ }
942
+ }
943
+
944
+ export const {{PascalName}}StateSchema = ServerStateSchema.extend({})
945
+ export type {{PascalName}}State = z.infer<typeof {{PascalName}}StateSchema>
946
+
947
+ export const {{PascalName}}OptionsSchema = ServerOptionsSchema.extend({})
948
+ export type {{PascalName}}Options = z.infer<typeof {{PascalName}}OptionsSchema>
949
+
950
+ export const {{PascalName}}EventsSchema = ServerEventsSchema.extend({})
951
+
952
+ /**
953
+ * {{description}}
954
+ *
955
+ * @example
956
+ * \`\`\`typescript
957
+ * const {{camelName}} = container.server('{{camelName}}', { port: 3000 })
958
+ * await {{camelName}}.start()
959
+ * \`\`\`
960
+ *
961
+ * @extends Server
962
+ */
963
+ export class {{PascalName}} extends Server<{{PascalName}}State, {{PascalName}}Options> {
964
+ static override shortcut = 'servers.{{camelName}}' as const
965
+ static override stateSchema = {{PascalName}}StateSchema
966
+ static override optionsSchema = {{PascalName}}OptionsSchema
967
+ static override eventsSchema = {{PascalName}}EventsSchema
968
+ static { Server.register(this, '{{camelName}}') }
969
+
970
+ static override attach(container: NodeContainer & ServersInterface) {
971
+ return container
972
+ }
973
+
974
+ override async configure() {
975
+ if (this.isConfigured) return this
976
+ this.state.set('configured', true)
977
+ return this
978
+ }
979
+
980
+ override async start(options?: { port?: number }) {
981
+ if (this.isListening) return this
982
+ if (!this.isConfigured) await this.configure()
983
+ const port = options?.port || this.options.port || 3000
984
+ this.state.set('port', port)
985
+ this.state.set('listening', true)
986
+ return this
987
+ }
988
+
989
+ override async stop() {
990
+ if (this.isStopped) return this
991
+ this.state.set('listening', false)
992
+ this.state.set('stopped', true)
993
+ return this
994
+ }
995
+ }
996
+
997
+ export default {{PascalName}}
998
+ \`\`\`
999
+
1000
+ ## Conventions
1001
+
1002
+ - **Lifecycle**: Implement \`configure()\`, \`start()\`, and \`stop()\`. Check guards (\`isConfigured\`, \`isListening\`, \`isStopped\`) at the top of each.
1003
+ - **Use \`afterInitialize()\`**: For any setup logic instead of overriding the constructor. Lifecycle methods (\`configure\`, \`start\`, \`stop\`) handle the server's runtime phases.
1004
+ - **State tracking**: Set \`configured\`, \`listening\`, \`stopped\`, and \`port\` on the state. This powers the introspection system.
1005
+ - **attach() is static**: It runs when the container first loads the server class. Use it for container-level setup if needed.
1006
+ - **Port from options**: Accept port via options schema and respect it in \`start()\`. Allow override via start options.
1007
+ - **JSDoc everything**: Every public method needs \`@param\`, \`@returns\`, \`@example\`. Run \`luca introspect\` after changes to update generated docs.
1008
+ `,
1009
+ },
1010
+ command: {
1011
+ sections: [
1012
+ { heading: "Imports", code: `import { z } from 'zod'
1013
+ import type { ContainerContext } from 'luca'` },
1014
+ { heading: "Positional Arguments", code: `// luca {{kebabName}} ./src => options.target === './src'
1015
+ export const positionals = ['target']` },
1016
+ { heading: "Args Schema", code: `export const argsSchema = z.object({
1017
+ // Positional: first arg after command name (via positionals array above)
1018
+ // target: z.string().optional().describe('The target to operate on'),
1019
+
1020
+ // Flags: passed as --flag on the CLI
1021
+ // verbose: z.boolean().default(false).describe('Enable verbose output'),
1022
+ // output: z.string().optional().describe('Output file path'),
1023
+ })` },
1024
+ { heading: "Description", code: `export const description = '{{description}}'` },
1025
+ { heading: "Handler", code: `export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1026
+ const { container } = context
1027
+ const fs = container.feature('fs')
1028
+
1029
+ // options.target is set from the first positional arg (via positionals export)
1030
+ // options.verbose, options.output, etc. come from --flags
1031
+
1032
+ // Your implementation here
1033
+ }` },
1034
+ { heading: "Complete Example", code: `import { z } from 'zod'
1035
+ import type { ContainerContext } from 'luca'
1036
+
1037
+ export const description = '{{description}}'
1038
+
1039
+ // Map positional args to named options: luca {{kebabName}} myTarget => options.target === 'myTarget'
1040
+ export const positionals = ['target']
1041
+
1042
+ export const argsSchema = z.object({
1043
+ target: z.string().optional().describe('The target to operate on'),
1044
+ })
1045
+
1046
+ export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1047
+ const { container } = context
1048
+ const fs = container.feature('fs')
1049
+
1050
+ console.log('{{kebabName}} running...', options.target)
1051
+ }` },
1052
+ { heading: "Container Properties", code: `export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1053
+ const { container } = context
1054
+
1055
+ // Current working directory
1056
+ container.cwd // '/path/to/project'
1057
+
1058
+ // Path utilities (scoped to cwd)
1059
+ container.paths.resolve('src') // '/path/to/project/src'
1060
+ container.paths.join('a', 'b') // '/path/to/project/a/b'
1061
+ container.paths.relative('src') // 'src'
1062
+
1063
+ // Package manifest (parsed package.json)
1064
+ container.manifest.name // 'my-project'
1065
+ container.manifest.version // '1.0.0'
1066
+
1067
+ // Raw CLI arguments (from minimist) — prefer positionals export for positional args
1068
+ container.argv // { _: ['{{kebabName}}', ...], verbose: true, ... }
1069
+ }` }
1070
+ ],
1071
+ full: `import { z } from 'zod'
1072
+ import type { ContainerContext } from 'luca'
1073
+
1074
+ export const description = '{{description}}'
1075
+
1076
+ // Map positional args to named options: luca {{kebabName}} myTarget => options.target === 'myTarget'
1077
+ export const positionals = ['target']
1078
+
1079
+ export const argsSchema = z.object({
1080
+ target: z.string().optional().describe('The target to operate on'),
1081
+ })
1082
+
1083
+ export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1084
+ const { container } = context
1085
+ const fs = container.feature('fs')
1086
+
1087
+ console.log('{{kebabName}} running...', options.target)
1088
+ }`,
1089
+ tutorial: `# Building a Command
1090
+
1091
+ A command extends the \`luca\` CLI. Commands live in a project's \`commands/\` folder and are automatically discovered. They are Helper subclasses under the hood — the framework grafts your module exports into a Command class at runtime.
1092
+
1093
+ When to build a command:
1094
+ - You need a CLI task for a project (build scripts, generators, automation)
1095
+ - You want argument parsing, help text, and container access for free
1096
+ - The task should be runnable via \`luca yourCommand\`
1097
+
1098
+ ## Imports
1099
+
1100
+ \`\`\`ts
1101
+ import { z } from 'zod'
1102
+ import type { ContainerContext } from 'luca'
1103
+ \`\`\`
1104
+
1105
+ ## Positional Arguments
1106
+
1107
+ Export a \`positionals\` array to map CLI positional args into named options fields. The first positional (\`_[0]\`) is always the command name — \`positionals\` maps \`_[1]\`, \`_[2]\`, etc.
1108
+
1109
+ \`\`\`ts
1110
+ // luca {{kebabName}} ./src => options.target === './src'
1111
+ export const positionals = ['target']
1112
+ \`\`\`
1113
+
1114
+ ## Args Schema
1115
+
1116
+ Define your command's arguments and flags with Zod. Each field becomes a \`--flag\` on the CLI. Fields named in \`positionals\` also accept positional args.
1117
+
1118
+ \`\`\`ts
1119
+ export const argsSchema = z.object({
1120
+ // Positional: first arg after command name (via positionals array above)
1121
+ // target: z.string().optional().describe('The target to operate on'),
1122
+
1123
+ // Flags: passed as --flag on the CLI
1124
+ // verbose: z.boolean().default(false).describe('Enable verbose output'),
1125
+ // output: z.string().optional().describe('Output file path'),
1126
+ })
1127
+ \`\`\`
1128
+
1129
+ ## Description
1130
+
1131
+ Export a description string for \`luca --help\` display:
1132
+
1133
+ \`\`\`ts
1134
+ export const description = '{{description}}'
1135
+ \`\`\`
1136
+
1137
+ ## Handler
1138
+
1139
+ Export a default async function. It receives parsed options and the container context. Use the container for all I/O. Positional args declared in the \`positionals\` export are available as named fields on \`options\`.
1140
+
1141
+ \`\`\`ts
1142
+ export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1143
+ const { container } = context
1144
+ const fs = container.feature('fs')
1145
+
1146
+ // options.target is set from the first positional arg (via positionals export)
1147
+ // options.verbose, options.output, etc. come from --flags
1148
+
1149
+ // Your implementation here
1150
+ }
1151
+ \`\`\`
1152
+
1153
+ ## Complete Example
1154
+
1155
+ \`\`\`ts
1156
+ import { z } from 'zod'
1157
+ import type { ContainerContext } from 'luca'
1158
+
1159
+ export const description = '{{description}}'
1160
+
1161
+ // Map positional args to named options: luca {{kebabName}} myTarget => options.target === 'myTarget'
1162
+ export const positionals = ['target']
1163
+
1164
+ export const argsSchema = z.object({
1165
+ target: z.string().optional().describe('The target to operate on'),
1166
+ })
1167
+
1168
+ export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1169
+ const { container } = context
1170
+ const fs = container.feature('fs')
1171
+
1172
+ console.log('{{kebabName}} running...', options.target)
1173
+ }
1174
+ \`\`\`
1175
+
1176
+ ## Container Properties
1177
+
1178
+ The \`context.container\` object provides useful properties beyond features:
1179
+
1180
+ \`\`\`ts
1181
+ export default async function {{camelName}}(options: z.infer<typeof argsSchema>, context: ContainerContext) {
1182
+ const { container } = context
1183
+
1184
+ // Current working directory
1185
+ container.cwd // '/path/to/project'
1186
+
1187
+ // Path utilities (scoped to cwd)
1188
+ container.paths.resolve('src') // '/path/to/project/src'
1189
+ container.paths.join('a', 'b') // '/path/to/project/a/b'
1190
+ container.paths.relative('src') // 'src'
1191
+
1192
+ // Package manifest (parsed package.json)
1193
+ container.manifest.name // 'my-project'
1194
+ container.manifest.version // '1.0.0'
1195
+
1196
+ // Raw CLI arguments (from minimist) — prefer positionals export for positional args
1197
+ container.argv // { _: ['{{kebabName}}', ...], verbose: true, ... }
1198
+ }
1199
+ \`\`\`
1200
+
1201
+ ## Conventions
1202
+
1203
+ - **File location**: \`commands/{{kebabName}}.ts\` in the project root. The \`luca\` CLI discovers these automatically.
1204
+ - **Naming**: kebab-case for filename. \`luca {{kebabName}}\` maps to \`commands/{{kebabName}}.ts\`.
1205
+ - **Use the container**: Never import \`fs\`, \`path\`, \`child_process\` directly. Use \`container.feature('fs')\`, \`container.paths\`, \`container.feature('proc')\`.
1206
+ - **Positional args**: Export \`positionals = ['name1', 'name2']\` to map CLI positional args into named options fields. For raw access, use \`container.argv._\` where \`_[0]\` is the command name.
1207
+ - **Exit codes**: Return nothing for success. Throw for errors — the CLI catches and reports them.
1208
+ - **Help text**: Use \`.describe()\` on every schema field — it powers \`luca {{kebabName}} --help\`.
1209
+ `,
1210
+ },
1211
+ endpoint: {
1212
+ sections: [
1213
+ { heading: "Required Exports", code: `export const path = '/api/{{camelName}}'
1214
+ export const description = '{{description}}'
1215
+ export const tags = ['{{camelName}}']` },
1216
+ { heading: "Handler Functions", code: `export async function get(params: any, ctx: any) {
1217
+ const fs = ctx.container.feature('fs')
1218
+ // Your logic here
1219
+ return { message: 'ok' }
1220
+ }
1221
+
1222
+ export async function post(params: any, ctx: any) {
1223
+ // Create something
1224
+ return { created: true }
1225
+ }` },
1226
+ { heading: "Validation Schemas", code: `import { z } from 'zod'
1227
+
1228
+ export const getSchema = z.object({
1229
+ q: z.string().optional().describe('Search query'),
1230
+ limit: z.number().default(20).describe('Max results'),
1231
+ })
1232
+
1233
+ export const postSchema = z.object({
1234
+ title: z.string().min(1).describe('Item title'),
1235
+ body: z.string().min(1).describe('Item content'),
1236
+ })` },
1237
+ { heading: "Rate Limiting", code: `// Global rate limit for all methods
1238
+ export const rateLimit = { maxRequests: 100, windowSeconds: 60 }
1239
+
1240
+ // Per-method rate limit
1241
+ export const postRateLimit = { maxRequests: 10, windowSeconds: 1 }` },
1242
+ { heading: "Delete Handler", code: `// Use a local name, then re-export as \`delete\`
1243
+ const del = async (params: any, ctx: any) => {
1244
+ return { deleted: true }
1245
+ }
1246
+ export { del as delete }` },
1247
+ { heading: "Complete Example", code: `export const path = '/api/{{camelName}}'
1248
+ export const description = '{{description}}'
1249
+ export const tags = ['{{camelName}}']
1250
+
1251
+ export async function get(params: any, ctx: any) {
1252
+ return { items: [], total: 0 }
1253
+ }
1254
+
1255
+ export async function post(params: any, ctx: any) {
1256
+ return { item: { id: '1', ...params }, message: 'Created' }
1257
+ }
1258
+
1259
+ const del = async (params: any, ctx: any) => {
1260
+ const { id } = ctx.params
1261
+ return { message: \`Deleted \${id}\` }
1262
+ }
1263
+ export { del as delete }` },
1264
+ { heading: "Dynamic Route Example", code: `// endpoints/{{camelName}}/[id].ts
1265
+ export const path = '/api/{{camelName}}/:id'
1266
+ export const description = 'Get, update, or delete a specific item'
1267
+ export const tags = ['{{camelName}}']
1268
+
1269
+ export async function get(params: any, ctx: any) {
1270
+ const { id } = ctx.params
1271
+ return { item: { id } }
1272
+ }
1273
+
1274
+ export async function put(params: any, ctx: any) {
1275
+ const { id } = ctx.params
1276
+ return { item: { id, ...params }, message: 'Updated' }
1277
+ }
1278
+
1279
+ const del = async (params: any, ctx: any) => {
1280
+ const { id } = ctx.params
1281
+ return { message: \`Deleted \${id}\` }
1282
+ }
1283
+ export { del as delete }` }
1284
+ ],
1285
+ full: `export const path = '/api/{{camelName}}'
1286
+ export const description = '{{description}}'
1287
+ export const tags = ['{{camelName}}']
1288
+
1289
+ export async function get(params: any, ctx: any) {
1290
+ return { items: [], total: 0 }
1291
+ }
1292
+
1293
+ export async function post(params: any, ctx: any) {
1294
+ return { item: { id: '1', ...params }, message: 'Created' }
1295
+ }
1296
+
1297
+ const del = async (params: any, ctx: any) => {
1298
+ const { id } = ctx.params
1299
+ return { message: \`Deleted \${id}\` }
1300
+ }
1301
+ export { del as delete }`,
1302
+ tutorial: `# Building an Endpoint
1303
+
1304
+ An endpoint is a route handler that \`luca serve\` auto-discovers and mounts on an Express server. Endpoints live in \`endpoints/\` and follow a file-based routing convention — each file becomes an API route with automatic validation, OpenAPI spec generation, and rate limiting.
1305
+
1306
+ When to build an endpoint:
1307
+ - You need a REST API route (GET, POST, PUT, PATCH, DELETE)
1308
+ - You want Zod validation, OpenAPI docs, and rate limiting for free
1309
+ - You're building an API that \`luca serve\` manages
1310
+
1311
+ ## File Location
1312
+
1313
+ Endpoints go in \`endpoints/\` at your project root:
1314
+ - \`endpoints/health.ts\` → \`/health\`
1315
+ - \`endpoints/posts.ts\` → \`/api/posts\`
1316
+ - \`endpoints/posts/[id].ts\` → \`/api/posts/:id\` (requires \`path\` export)
1317
+
1318
+ Run \`luca serve\` and they're automatically discovered and mounted.
1319
+
1320
+ ## Imports
1321
+
1322
+ Endpoints are lightweight — just exports and handler functions. No imports are required.
1323
+
1324
+ If your project has \`luca\` as an npm dependency, you can import \`z\` from \`zod\` and \`EndpointContext\` from \`luca\` for type safety. Otherwise, use \`any\` types — the framework handles validation and context injection for you.
1325
+
1326
+ Access framework capabilities through the \`ctx\` parameter:
1327
+ - \`ctx.container.feature('fs')\` for file operations
1328
+ - \`ctx.container.feature('yaml')\` for YAML parsing
1329
+ - \`ctx.container.feature('sqlite')\` for database access
1330
+
1331
+ ## Required Exports
1332
+
1333
+ Every endpoint MUST export a \`path\` string:
1334
+
1335
+ \`\`\`ts
1336
+ export const path = '/api/{{camelName}}'
1337
+ export const description = '{{description}}'
1338
+ export const tags = ['{{camelName}}']
1339
+ \`\`\`
1340
+
1341
+ ## Handler Functions
1342
+
1343
+ Export named functions for each HTTP method you support. Each receives validated parameters and a context object:
1344
+
1345
+ \`\`\`ts
1346
+ export async function get(params: any, ctx: any) {
1347
+ const fs = ctx.container.feature('fs')
1348
+ // Your logic here
1349
+ return { message: 'ok' }
1350
+ }
1351
+
1352
+ export async function post(params: any, ctx: any) {
1353
+ // Create something
1354
+ return { created: true }
1355
+ }
1356
+ \`\`\`
1357
+
1358
+ The \`EndpointContext\` gives you:
1359
+ - \`ctx.container\` — the luca container (access any feature, client, etc.)
1360
+ - \`ctx.request\` — Express request object
1361
+ - \`ctx.response\` — Express response object
1362
+ - \`ctx.query\` — parsed query string
1363
+ - \`ctx.body\` — parsed request body
1364
+ - \`ctx.params\` — URL parameters (\`:id\`, etc.)
1365
+
1366
+ Return any object — it's automatically JSON-serialized as the response.
1367
+
1368
+ ## Validation Schemas
1369
+
1370
+ If \`zod\` is available (via \`luca\` dependency or \`node_modules\`), export Zod schemas to validate parameters for each method. Name them \`{method}Schema\`:
1371
+
1372
+ \`\`\`ts
1373
+ import { z } from 'zod'
1374
+
1375
+ export const getSchema = z.object({
1376
+ q: z.string().optional().describe('Search query'),
1377
+ limit: z.number().default(20).describe('Max results'),
1378
+ })
1379
+
1380
+ export const postSchema = z.object({
1381
+ title: z.string().min(1).describe('Item title'),
1382
+ body: z.string().min(1).describe('Item content'),
1383
+ })
1384
+ \`\`\`
1385
+
1386
+ Invalid requests automatically return 400 with Zod error details. Schemas also feed the auto-generated OpenAPI spec. If zod is not available, skip schema exports — the endpoint still works, you just lose automatic validation.
1387
+
1388
+ ## Rate Limiting
1389
+
1390
+ Export rate limit config to protect endpoints:
1391
+
1392
+ \`\`\`ts
1393
+ // Global rate limit for all methods
1394
+ export const rateLimit = { maxRequests: 100, windowSeconds: 60 }
1395
+
1396
+ // Per-method rate limit
1397
+ export const postRateLimit = { maxRequests: 10, windowSeconds: 1 }
1398
+ \`\`\`
1399
+
1400
+ ## Delete Handler
1401
+
1402
+ \`delete\` is a reserved word in JS, so you can't use it as a function name directly. Use a named export alias:
1403
+
1404
+ \`\`\`ts
1405
+ // Use a local name, then re-export as \`delete\`
1406
+ const del = async (params: any, ctx: any) => {
1407
+ return { deleted: true }
1408
+ }
1409
+ export { del as delete }
1410
+ \`\`\`
1411
+
1412
+ You can also export \`deleteSchema\` and \`deleteRateLimit\` for validation and rate limiting on DELETE.
1413
+
1414
+ ## Complete Example
1415
+
1416
+ A CRUD endpoint for a resource (no external imports needed):
1417
+
1418
+ \`\`\`ts
1419
+ export const path = '/api/{{camelName}}'
1420
+ export const description = '{{description}}'
1421
+ export const tags = ['{{camelName}}']
1422
+
1423
+ export async function get(params: any, ctx: any) {
1424
+ return { items: [], total: 0 }
1425
+ }
1426
+
1427
+ export async function post(params: any, ctx: any) {
1428
+ return { item: { id: '1', ...params }, message: 'Created' }
1429
+ }
1430
+
1431
+ const del = async (params: any, ctx: any) => {
1432
+ const { id } = ctx.params
1433
+ return { message: \`Deleted \${id}\` }
1434
+ }
1435
+ export { del as delete }
1436
+ \`\`\`
1437
+
1438
+ ## Dynamic Route Example
1439
+
1440
+ For routes with URL parameters, create a nested file:
1441
+
1442
+ \`\`\`ts
1443
+ // endpoints/{{camelName}}/[id].ts
1444
+ export const path = '/api/{{camelName}}/:id'
1445
+ export const description = 'Get, update, or delete a specific item'
1446
+ export const tags = ['{{camelName}}']
1447
+
1448
+ export async function get(params: any, ctx: any) {
1449
+ const { id } = ctx.params
1450
+ return { item: { id } }
1451
+ }
1452
+
1453
+ export async function put(params: any, ctx: any) {
1454
+ const { id } = ctx.params
1455
+ return { item: { id, ...params }, message: 'Updated' }
1456
+ }
1457
+
1458
+ const del = async (params: any, ctx: any) => {
1459
+ const { id } = ctx.params
1460
+ return { message: \`Deleted \${id}\` }
1461
+ }
1462
+ export { del as delete }
1463
+ \`\`\`
1464
+
1465
+ ## Conventions
1466
+
1467
+ - **File = route**: The file path maps to the URL path. \`endpoints/users.ts\` serves \`/api/users\`.
1468
+ - **Export \`path\`**: Every endpoint must export a \`path\` string. This is the mounted route.
1469
+ - **Use Zod schemas**: Name them \`getSchema\`, \`postSchema\`, etc. They validate AND document.
1470
+ - **Use the container**: Access features via \`ctx.container.feature('fs')\`, not Node.js imports.
1471
+ - **Return objects**: Handler return values are JSON-serialized. Use \`ctx.response\` only for streaming or custom status codes.
1472
+ - **OpenAPI for free**: Your \`path\`, \`description\`, \`tags\`, and schemas automatically generate an OpenAPI spec at \`/openapi.json\`.
1473
+ `,
1474
+ },
1475
+ selector: {
1476
+ sections: [
1477
+ { heading: "Imports", code: `import { z } from 'zod'
1478
+ import type { ContainerContext } from 'luca'` },
1479
+ { heading: "Args Schema", code: `export const argsSchema = z.object({
1480
+ // Add your input arguments here.
1481
+ // Example: field: z.string().optional().describe('Specific field to return'),
1482
+ })` },
1483
+ { heading: "Description", code: `export const description = '{{description}}'` },
1484
+ { heading: "Caching", code: `export function cacheKey(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1485
+ return context.container.git.currentCommitSha
1486
+ }` },
1487
+ { heading: "Caching", code: `export const cacheable = false` },
1488
+ { heading: "Handler", code: `export async function run(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1489
+ const { container } = context
1490
+ // Query and return your data
1491
+ return { /* your data */ }
1492
+ }` },
1493
+ { heading: "Complete Example", code: `import { z } from 'zod'
1494
+ import type { ContainerContext } from 'luca'
1495
+
1496
+ export const description = '{{description}}'
1497
+
1498
+ export const argsSchema = z.object({})
1499
+
1500
+ export async function run(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1501
+ const { container } = context
1502
+
1503
+ // Return your data here
1504
+ return {}
1505
+ }` }
1506
+ ],
1507
+ full: `import { z } from 'zod'
1508
+ import type { ContainerContext } from 'luca'
1509
+
1510
+ export const description = '{{description}}'
1511
+
1512
+ export const argsSchema = z.object({})
1513
+
1514
+ export async function run(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1515
+ const { container } = context
1516
+
1517
+ // Return your data here
1518
+ return {}
1519
+ }`,
1520
+ tutorial: `# Building a Selector
1521
+
1522
+ A selector returns data. Where commands perform actions, selectors query and return structured results with built-in caching. Selectors live in a project's \`selectors/\` folder and are automatically discovered.
1523
+
1524
+ When to build a selector:
1525
+ - You need to query project data (package info, file listings, config values)
1526
+ - The result benefits from caching (keyed by git SHA or custom key)
1527
+ - You want the data available via \`container.select('name')\` or \`luca select name\`
1528
+
1529
+ ## Imports
1530
+
1531
+ \`\`\`ts
1532
+ import { z } from 'zod'
1533
+ import type { ContainerContext } from 'luca'
1534
+ \`\`\`
1535
+
1536
+ ## Args Schema
1537
+
1538
+ Define the selector's input arguments with Zod.
1539
+
1540
+ \`\`\`ts
1541
+ export const argsSchema = z.object({
1542
+ // Add your input arguments here.
1543
+ // Example: field: z.string().optional().describe('Specific field to return'),
1544
+ })
1545
+ \`\`\`
1546
+
1547
+ ## Description
1548
+
1549
+ Export a description string for discoverability:
1550
+
1551
+ \`\`\`ts
1552
+ export const description = '{{description}}'
1553
+ \`\`\`
1554
+
1555
+ ## Caching
1556
+
1557
+ Selectors cache by default. The default cache key is \`hashObject({ selectorName, args, gitSha })\` — same args + same commit = cache hit.
1558
+
1559
+ To customize the cache key:
1560
+
1561
+ \`\`\`ts
1562
+ export function cacheKey(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1563
+ return context.container.git.currentCommitSha
1564
+ }
1565
+ \`\`\`
1566
+
1567
+ To disable caching:
1568
+
1569
+ \`\`\`ts
1570
+ export const cacheable = false
1571
+ \`\`\`
1572
+
1573
+ ## Handler
1574
+
1575
+ Export a \`run\` function that returns data. It receives parsed args and the container context.
1576
+
1577
+ \`\`\`ts
1578
+ export async function run(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1579
+ const { container } = context
1580
+ // Query and return your data
1581
+ return { /* your data */ }
1582
+ }
1583
+ \`\`\`
1584
+
1585
+ ## Complete Example
1586
+
1587
+ \`\`\`ts
1588
+ import { z } from 'zod'
1589
+ import type { ContainerContext } from 'luca'
1590
+
1591
+ export const description = '{{description}}'
1592
+
1593
+ export const argsSchema = z.object({})
1594
+
1595
+ export async function run(args: z.infer<typeof argsSchema>, context: ContainerContext) {
1596
+ const { container } = context
1597
+
1598
+ // Return your data here
1599
+ return {}
1600
+ }
1601
+ \`\`\`
1602
+
1603
+ ## Conventions
1604
+
1605
+ - **File location**: \`selectors/{{kebabName}}.ts\` in the project root. Discovered automatically.
1606
+ - **Naming**: kebab-case for filename. \`luca select {{kebabName}}\` maps to \`selectors/{{kebabName}}.ts\`.
1607
+ - **Use the container**: Never import \`fs\`, \`path\` directly. Use \`container.feature('fs')\`, \`container.paths\`.
1608
+ - **Return data**: The \`run\` function must return the data. It gets wrapped in \`{ data, cached, cacheKey }\` by the framework.
1609
+ - **Caching**: On by default. Override \`cacheKey()\` for custom invalidation, or set \`cacheable = false\` to skip.
1610
+ - **CLI**: \`luca select {{kebabName}}\` runs the selector and prints JSON. Use \`--json\` for data only, \`--no-cache\` to force fresh.
1611
+ `,
1612
+ }
1613
+ }
1614
+
1615
+ export const assistantFiles: Record<string, string> = {
1616
+ "CORE.md": `# Luca Assistant Example
1617
+
1618
+ You are currently an example / template "Assistant" provided by the Luca framework. ( You'll probably have no idea what that is, don't worry, it doesn't matter ).
1619
+
1620
+ You are what gets scaffolded when a user writes the \`luca scaffold assistant\` command.
1621
+
1622
+ In luca, an Assistant is backed by a folder which has a few components:
1623
+
1624
+ - CORE.md -- this is a markdown file that will get injected into the system prompt of a chat completion call
1625
+ - tools.ts -- this file is expected to export functions, and a schemas object whose keys are the names of the functions that get exported, and whose values are zod v4 schemas that describe the parameters
1626
+ - hooks.ts -- this file is expexted to export functions, whose names match the events emitted by the luca assistant helper
1627
+
1628
+ Currently, the user is chatting with you from the \`luca chat\` CLI.
1629
+
1630
+ You should tell them what each of these files is and how to edit them.
1631
+
1632
+ It is also important for them to know that the luca \`container\` is globally available for them in the context of the \`tools.ts\` and \`hooks.ts\` files.
1633
+
1634
+ `,
1635
+ "tools.ts": `import { z } from 'zod'
1636
+
1637
+ export const schemas = {
1638
+ README: z.object({}).describe('CALL THIS README FUNCTION AS EARLY AS POSSIBLE')
1639
+ }
1640
+
1641
+ export function README(options: z.infer<typeof schemas.README>) {
1642
+ return 'YO YO'
1643
+ }
1644
+
1645
+ `,
1646
+ "hooks.ts": `export function started() {
1647
+ console.log('Assistant started!')
1648
+ }
1649
+ `
1650
+ }
1651
+
1652
+ export const mcpReadme = `# Luca Development Guide
1653
+
1654
+ You are working in a **luca project**. The luca container provides all capabilities your code needs. Do not install npm packages or import Node.js builtins directly.
1655
+
1656
+ ## The Contract
1657
+
1658
+ Every capability goes through the container. If you need something that doesn't exist, build it as a feature, client, or server. If it wraps a third-party library, the helper IS the interface — consumer code never imports the library directly.
1659
+
1660
+ ## Import Rule
1661
+
1662
+ All consumer code imports from \`luca\` only:
1663
+
1664
+ \`\`\`ts
1665
+ import { Feature, features, z, FeatureStateSchema, FeatureOptionsSchema } from 'luca'
1666
+ import { Client, clients, RestClient, ClientStateSchema } from 'luca/client'
1667
+ import { Server, servers, ServerStateSchema } from 'luca'
1668
+ import { commands, CommandOptionsSchema } from 'luca'
1669
+ \`\`\`
1670
+
1671
+ Never import from \`fs\`, \`path\`, \`crypto\`, or other Node builtins. Never import third-party packages in consumer code. If a container feature wraps the functionality, use it.
1672
+
1673
+ ## Zod v4
1674
+
1675
+ This project uses **Zod v4** — import \`z\` from \`luca\`, never from \`'zod'\` directly. All option, state, and event schemas use Zod v4 syntax. Key patterns:
1676
+
1677
+ \`\`\`ts
1678
+ // Extending base schemas (options, state, events)
1679
+ export const MyStateSchema = FeatureStateSchema.extend({
1680
+ count: z.number().default(0).describe('Number of items'),
1681
+ label: z.string().optional().describe('Display label'),
1682
+ })
1683
+
1684
+ // Events use z.tuple() for listener arguments
1685
+ export const MyEventsSchema = FeatureEventsSchema.extend({
1686
+ itemAdded: z.tuple([z.string().describe('key'), z.number().describe('index')]),
1687
+ })
1688
+
1689
+ // Type inference
1690
+ export type MyState = z.infer<typeof MyStateSchema>
1691
+ \`\`\`
1692
+
1693
+ Zod v4 differences from v3 that matter:
1694
+ - \`z.string().check(...)\` replaces some v3 refinement patterns
1695
+ - \`.toJSONSchema()\` is built-in on any schema — no external library needed
1696
+ - Error customization uses \`z.string({ error: "message" })\` not \`.refine()\` for simple cases
1697
+ - \`z.interface()\` exists for recursive/lazy object types
1698
+ - Do NOT use \`z.nativeEnum()\` — use \`z.enum()\` instead
1699
+
1700
+ ## Dependencies
1701
+
1702
+ If the project has \`node_modules\` and a package manager, helper implementations can import third-party libraries internally. If not (e.g. running via the \`luca\` binary's VM), all code must import only from \`luca\`.
1703
+
1704
+ ## Discovering Capabilities
1705
+
1706
+ The container has registries for features, clients, servers, commands, and endpoints. **Do not guess** what is available — use your MCP tools to discover it:
1707
+
1708
+ 1. **\`find_capability\`** — Overview of all features, clients, and servers with descriptions. Start here.
1709
+ 2. **\`list_registry\`** — List all names in a specific registry (features, clients, servers, commands, endpoints).
1710
+ 3. **\`describe_helper\`** — Full API docs for a specific helper (methods, options, state, events). Call this before writing code that uses a helper.
1711
+ 4. **\`eval\`** — Once you know what you need, prototype calls in the live sandbox before writing them into files.
1712
+
1713
+ ## Mini Examples
1714
+
1715
+ ### Feature with composition
1716
+
1717
+ Features access other features via \`this.container.feature(...)\`:
1718
+
1719
+ \`\`\`ts
1720
+ import { z } from 'zod'
1721
+ import { FeatureStateSchema, FeatureOptionsSchema, FeatureEventsSchema } from 'luca'
1722
+ import { Feature, features } from 'luca'
1723
+ import type { ContainerContext } from 'luca'
1724
+
1725
+ export const ConfigStateSchema = FeatureStateSchema.extend({
1726
+ loaded: z.boolean().default(false).describe('Whether config has been loaded'),
1727
+ })
1728
+
1729
+ export const ConfigOptionsSchema = FeatureOptionsSchema.extend({
1730
+ filePath: z.string().default('config.json').describe('Path to config file'),
1731
+ })
1732
+
1733
+ export const ConfigEventsSchema = FeatureEventsSchema.extend({
1734
+ configLoaded: z.tuple([z.record(z.unknown()).describe('parsed config')]),
1735
+ })
1736
+
1737
+ export class Config extends Feature<z.infer<typeof ConfigStateSchema>, z.infer<typeof ConfigOptionsSchema>> {
1738
+ static override shortcut = 'features.config' as const
1739
+ static override stateSchema = ConfigStateSchema
1740
+ static override optionsSchema = ConfigOptionsSchema
1741
+ static override eventsSchema = ConfigEventsSchema
1742
+ static override description = 'Loads and manages project configuration'
1743
+
1744
+ /** Load and parse the config file */
1745
+ async load() {
1746
+ const fs = this.container.feature('fs')
1747
+ const raw = await fs.readFile(this.options.filePath)
1748
+ const data = JSON.parse(raw)
1749
+ this.state.set('loaded', true)
1750
+ this.emit('configLoaded', data)
1751
+ return data
1752
+ }
1753
+ }
1754
+
1755
+ declare module 'luca' {
1756
+ interface AvailableFeatures { config: typeof Config }
1757
+ }
1758
+ export default features.register('config', Config)
1759
+ \`\`\`
1760
+
1761
+ ### Client with composition
1762
+
1763
+ Clients access features and other clients via \`this.container\`:
1764
+
1765
+ \`\`\`ts
1766
+ import { z } from 'zod'
1767
+ import { Client, clients, ClientStateSchema, ClientOptionsSchema, ClientEventsSchema } from 'luca'
1768
+ import type { ContainerContext } from 'luca'
1769
+
1770
+ export const GithubOptionsSchema = ClientOptionsSchema.extend({
1771
+ token: z.string().describe('GitHub personal access token'),
1772
+ owner: z.string().describe('Repository owner'),
1773
+ repo: z.string().describe('Repository name'),
1774
+ })
1775
+
1776
+ export const GithubEventsSchema = ClientEventsSchema.extend({
1777
+ issuesFetched: z.tuple([z.number().describe('count')]),
1778
+ })
1779
+
1780
+ export class GithubClient extends Client<z.infer<typeof ClientStateSchema>, z.infer<typeof GithubOptionsSchema>> {
1781
+ static override shortcut = 'clients.github' as const
1782
+ static override optionsSchema = GithubOptionsSchema
1783
+ static override eventsSchema = GithubEventsSchema
1784
+ static override description = 'GitHub API client using container REST client'
1785
+
1786
+ /** Fetch open issues */
1787
+ async issues() {
1788
+ const rest = this.container.client('rest')
1789
+ const res = await rest.get(\`https://api.github.com/repos/\${this.options.owner}/\${this.options.repo}/issues\`, {
1790
+ headers: { Authorization: \`token \${this.options.token}\` },
1791
+ })
1792
+ this.emit('issuesFetched', res.data.length)
1793
+ return res.data
1794
+ }
1795
+ }
1796
+
1797
+ declare module 'luca' {
1798
+ interface AvailableClients { github: typeof GithubClient }
1799
+ }
1800
+ export default clients.register('github', GithubClient)
1801
+ \`\`\`
1802
+
1803
+ ## Workflow
1804
+
1805
+ 1. **\`find_capability\`** — Search what already exists before writing anything
1806
+ 2. **\`describe_helper\`** — Read the full API docs for the helper you need
1807
+ 3. **\`eval\`** — Prototype and test container API calls in the sandbox
1808
+ 4. **\`scaffold\`** — Generate correct boilerplate when building something new
1809
+ 5. **Write the file** — Using the patterns from the scaffold
1810
+
1811
+ ## Portability
1812
+
1813
+ Code that only imports from \`luca\` can be copied between any luca project. That's the goal. Features, clients, servers, and commands written this way are portable building blocks.
1814
+ `