@forinda/kickjs-cli 6.2.0-alpha.2 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/{agent-docs-BHxKWIf4.mjs → agent-docs-BnMTYOiD.mjs} +3 -3
  2. package/dist/{agent-docs-BHxKWIf4.mjs.map → agent-docs-BnMTYOiD.mjs.map} +1 -1
  3. package/dist/{build-DH7RVYT6.mjs → build-DxVQQIQS.mjs} +3 -3
  4. package/dist/{build-DH7RVYT6.mjs.map → build-DxVQQIQS.mjs.map} +1 -1
  5. package/dist/{builtins-B9jAir23.mjs → builtins-DIyfh8Vq.mjs} +2 -2
  6. package/dist/cli.mjs +137 -137
  7. package/dist/{config-DOnwtASE.mjs → config-DQFyBrSP.mjs} +3 -3
  8. package/dist/{config-DOnwtASE.mjs.map → config-DQFyBrSP.mjs.map} +1 -1
  9. package/dist/{doctor-CUR55xM0.mjs → doctor-D6Vqf-Ws.mjs} +44 -44
  10. package/dist/doctor-D6Vqf-Ws.mjs.map +1 -0
  11. package/dist/index.d.mts.map +1 -1
  12. package/dist/index.mjs +2 -2
  13. package/dist/{plugin-DiLjdUhB.mjs → plugin-Dl2YqKay.mjs} +3 -3
  14. package/dist/{plugin-DiLjdUhB.mjs.map → plugin-Dl2YqKay.mjs.map} +1 -1
  15. package/dist/{project-docs-M1yY0Jfu.mjs → project-docs-CIzEv44w.mjs} +2 -2
  16. package/dist/{project-docs-M1yY0Jfu.mjs.map → project-docs-CIzEv44w.mjs.map} +1 -1
  17. package/dist/{project-root-t0bXso9G.mjs → project-root-DYK_xUvF.mjs} +3 -3
  18. package/dist/{project-root-t0bXso9G.mjs.map → project-root-DYK_xUvF.mjs.map} +1 -1
  19. package/dist/{rolldown-runtime-DM9iduxt.mjs → rolldown-runtime-B13ILhgX.mjs} +1 -1
  20. package/dist/{run-plugins-DujFeVh4.mjs → run-plugins-u58MFV45.mjs} +13 -13
  21. package/dist/{run-plugins-DujFeVh4.mjs.map → run-plugins-u58MFV45.mjs.map} +1 -1
  22. package/dist/{typegen-6pW2cOTw.mjs → typegen-CuciH349.mjs} +5 -5
  23. package/dist/{typegen-6pW2cOTw.mjs.map → typegen-CuciH349.mjs.map} +1 -1
  24. package/dist/{types-D34YF7B6.mjs → types-zO8PDAjk.mjs} +1 -1
  25. package/package.json +5 -5
  26. package/dist/doctor-CUR55xM0.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v6.2.0-alpha.2
2
+ * @forinda/kickjs-cli v6.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-DM9iduxt.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
- //# sourceMappingURL=project-root-t0bXso9G.mjs.map
11
+ import{t as e}from"./rolldown-runtime-B13ILhgX.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
+ //# sourceMappingURL=project-root-DYK_xUvF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-root-t0bXso9G.mjs","names":[],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sLAGA,MAAM,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgB,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAM,EAAQ,EAAQ,CAAQ,EACxB,CAAE,KAAM,GAAW,EAAM,CAAK,EAEhC,EAAkC,KAClC,EAAS,EACb,OAAa,CACX,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAW,EAAQ,EAAQ,CAAI,CAAC,EAAG,OAAO,EAKhD,GAHI,IAAqB,MAAQ,EAAW,EAAQ,EAAQ,cAAc,CAAC,IACzE,EAAmB,GAEjB,IAAW,EAAQ,MACvB,IAAM,EAAS,EAAQ,CAAM,EAC7B,GAAI,IAAW,EAAQ,MACvB,EAAS,CACX,CAEA,OAAO,GAAoB,CAC7B"}
1
+ {"version":3,"file":"project-root-DYK_xUvF.mjs","names":[],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sLAGA,MAAM,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgB,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAM,EAAQ,EAAQ,CAAQ,EACxB,CAAE,KAAM,GAAW,EAAM,CAAK,EAEhC,EAAkC,KAClC,EAAS,EACb,OAAa,CACX,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAW,EAAQ,EAAQ,CAAI,CAAC,EAAG,OAAO,EAKhD,GAHI,IAAqB,MAAQ,EAAW,EAAQ,EAAQ,cAAc,CAAC,IACzE,EAAmB,GAEjB,IAAW,EAAQ,MACvB,IAAM,EAAS,EAAQ,CAAM,EAC7B,GAAI,IAAW,EAAQ,MACvB,EAAS,CACX,CAEA,OAAO,GAAoB,CAC7B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v6.2.0-alpha.2
2
+ * @forinda/kickjs-cli v6.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v6.2.0-alpha.2
2
+ * @forinda/kickjs-cli v6.2.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,p as l,s as u,u as d,v as f,y as p}from"./project-docs-M1yY0Jfu.mjs";import{A as m,C as h,D as g,E as _,F as v,I as y,L as b,M as ee,N as x,O as S,P as C,R as w,S as te,T as ne,_ as re,a as ie,b as ae,c as oe,f as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,o as he,p as ge,r as _e,s as ve,v as ye,w as be,x as xe,y as Se}from"./doctor-CUR55xM0.mjs";import{a as T,i as E,o as Ce,s as we}from"./config-DOnwtASE.mjs";import{t as Te}from"./project-root-t0bXso9G.mjs";import{n as D}from"./types-D34YF7B6.mjs";import{t as Ee}from"./build-DH7RVYT6.mjs";import{n as De}from"./agent-docs-BHxKWIf4.mjs";import{n as Oe}from"./plugin-DiLjdUhB.mjs";import{a as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue}from"./typegen-6pW2cOTw.mjs";import O,{basename as We,dirname as k,join as A,relative as j,resolve as M,sep as N}from"node:path";import{cpSync as Ge,existsSync as P,mkdirSync as Ke,readFileSync as F,readdirSync as qe,rmSync as Je,writeFileSync as Ye}from"node:fs";import{copyFile as Xe,mkdir as I,readFile as L,readdir as Ze,rm as Qe,stat as $e,writeFile as R}from"node:fs/promises";import{fork as et,spawn as tt,spawnSync as nt}from"node:child_process";import{fileURLToPath as rt,pathToFileURL as z}from"node:url";import{arch as it,platform as at,release as ot}from"node:os";const st=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function ct(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. auth,swagger,ws,queue)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{n(`KickJS — Create a new project`);let o=!!(t.yes||t.nonInteractive);e||=o?`my-api`:await c({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let l;if(e===`.`?(l=M(`.`),e=We(l)):l=M(t.directory||e),P(l)){let n=qe(l);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${l}`);else if(o){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),r(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await u({message:a.red(`Remove all existing files and proceed?`),initialValue:!1})){r(`Aborted.`);return}}for(let e of n)Je(M(l,e),{recursive:!0,force:!0})}}let f=t.template;f||=o?`minimal`:await i({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`}]});let p=t.runtime;p||=o?`express`:await i({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let m=t.pm;m||=o?await ve(void 0):await i({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=o?`inmemory`:await c({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),we(h);let g=t.schema;g||=o?`zod`:await i({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(s.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=o?[]:await d({message:`Select packages to include`,options:[...st],required:!1});let v;v=t.git===void 0?o?!0:await u({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;y=t.install===void 0?o?!0:await u({message:`Install dependencies?`,initialValue:!0}):t.install,await me({name:e,directory:l,packageManager:m,initGit:v,installDeps:y,template:f,defaultRepo:h,packages:_,schemaLib:g,runtime:p}),r(`Done! Next steps: ${a.cyan(`cd ${e} && ${m} dev`)}`)})}async function lt(e){let{name:n,outDir:r}=e,i=b(n),a=w(n),o=[],s=A(r,`${i}.plugin.ts`);return await t(s,`import {
11
+ import{_ as e,b as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,p as l,s as u,u as d,v as f,y as p}from"./project-docs-CIzEv44w.mjs";import{A as m,C as h,D as g,E as _,F as v,I as y,L as b,M as ee,N as x,O as S,P as C,R as w,S as te,T as ne,_ as re,a as ie,b as ae,c as oe,d as se,f as ce,g as le,h as ue,i as de,j as fe,k as pe,l as me,m as he,p as ge,r as _e,u as ve,v as ye,w as be,x as xe,y as Se}from"./doctor-D6Vqf-Ws.mjs";import{a as T,i as E,o as Ce,s as we}from"./config-DQFyBrSP.mjs";import{t as Te}from"./project-root-DYK_xUvF.mjs";import{n as D}from"./types-zO8PDAjk.mjs";import{t as Ee}from"./build-DxVQQIQS.mjs";import{n as De}from"./agent-docs-BnMTYOiD.mjs";import{n as Oe}from"./plugin-Dl2YqKay.mjs";import{a as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue}from"./typegen-CuciH349.mjs";import O,{basename as We,dirname as k,join as A,relative as j,resolve as M,sep as N}from"node:path";import{cpSync as Ge,existsSync as P,mkdirSync as Ke,readFileSync as F,readdirSync as qe,rmSync as Je,writeFileSync as Ye}from"node:fs";import{copyFile as Xe,mkdir as I,readFile as L,readdir as Ze,rm as Qe,stat as $e,writeFile as R}from"node:fs/promises";import{fork as et,spawn as tt,spawnSync as nt}from"node:child_process";import{fileURLToPath as rt,pathToFileURL as z}from"node:url";import{arch as it,platform as at,release as ot}from"node:os";const st=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function ct(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. auth,swagger,ws,queue)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{n(`KickJS — Create a new project`);let o=!!(t.yes||t.nonInteractive);e||=o?`my-api`:await c({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let l;if(e===`.`?(l=M(`.`),e=We(l)):l=M(t.directory||e),P(l)){let n=qe(l);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${l}`);else if(o){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),r(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await u({message:a.red(`Remove all existing files and proceed?`),initialValue:!1})){r(`Aborted.`);return}}for(let e of n)Je(M(l,e),{recursive:!0,force:!0})}}let f=t.template;f||=o?`minimal`:await i({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`}]});let p=t.runtime;p||=o?`express`:await i({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let m=t.pm;m||=o?await he(void 0):await i({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=o?`inmemory`:await c({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),we(h);let g=t.schema;g||=o?`zod`:await i({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(s.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=o?[]:await d({message:`Select packages to include`,options:[...st],required:!1});let v;v=t.git===void 0?o?!0:await u({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;y=t.install===void 0?o?!0:await u({message:`Install dependencies?`,initialValue:!0}):t.install,await ve({name:e,directory:l,packageManager:m,initGit:v,installDeps:y,template:f,defaultRepo:h,packages:_,schemaLib:g,runtime:p}),r(`Done! Next steps: ${a.cyan(`cd ${e} && ${m} dev`)}`)})}async function lt(e){let{name:n,outDir:r}=e,i=b(n),a=w(n),o=[],s=A(r,`${i}.plugin.ts`);return await t(s,`import {
12
12
  definePlugin,
13
13
  type AppAdapter,
14
14
  type AppModuleEntry,
@@ -274,7 +274,7 @@ export class ${i}Job {
274
274
  // Handle high-priority variant of this job
275
275
  }
276
276
  }
277
- `),c}const Et={string:{ts:`string`,zod:`z.string()`},text:{ts:`string`,zod:`z.string()`},number:{ts:`number`,zod:`z.number()`},int:{ts:`number`,zod:`z.number().int()`},float:{ts:`number`,zod:`z.number()`},boolean:{ts:`boolean`,zod:`z.boolean()`},date:{ts:`string`,zod:`z.string().datetime()`},email:{ts:`string`,zod:`z.string().email()`},url:{ts:`string`,zod:`z.string().url()`},uuid:{ts:`string`,zod:`z.string().uuid()`},json:{ts:`any`,zod:`z.any()`}};function Dt(e){return e.map(e=>{let t=e.indexOf(`:`);if(t===-1)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let n=e.slice(0,t),r=e.slice(t+1);if(!n||!r)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let i=!1;r.endsWith(`:optional`)&&(r=r.slice(0,-9),i=!0),n.endsWith(`?`)&&(n=n.slice(0,-1),i=!0),r.endsWith(`?`)&&(r=r.slice(0,-1),i=!0);let a=r;if(a.startsWith(`enum:`)){let e=a.slice(5).split(`,`);return{name:n,type:`enum`,tsType:e.map(e=>`'${e}'`).join(` | `),zodType:`z.enum([${e.map(e=>`'${e}'`).join(`, `)}])`,optional:i}}let o=Et[a];if(!o){let e=[...Object.keys(Et),`enum:a,b,c`].join(`, `);throw Error(`Unknown field type: "${a}". Valid types: ${e}`)}return{name:n,type:a,tsType:o.ts,zodType:o.zod,optional:i}})}async function Ot(e){let{name:n,fields:r,modulesDir:i,repo:a=`inmemory`,tokenScope:o=`app`,style:s=`define`}=e,c=e.pluralize!==!1,l=b(n),u=w(n),d=c?C(l):l,f=c?v(u):u,p=A(i,d),h=[],y=async(e,n)=>{let r=A(p,e);await t(r,n),h.push(r)};await y(`${l}.module.ts`,ee({pascal:u,kebab:l,plural:d,repo:a,style:s})),await y(`${l}.constants.ts`,_({pascal:u,kebab:l})),await y(`${l}.controller.ts`,de({pascal:u,kebab:l,plural:d,pluralPascal:f})),await y(`${l}.service.ts`,g({pascal:u,kebab:l})),await y(`dtos/create-${l}.dto.ts`,kt(u,r)),await y(`dtos/update-${l}.dto.ts`,At(u,r)),await y(`dtos/${l}-response.dto.ts`,jt(u,r)),await y(`${l}.repository.ts`,m({pascal:u,kebab:l,dtoPrefix:`./dtos`,tokenScope:o}));let x=a===`inmemory`,ne=x?`in-memory-${l}`:`${b(a)}-${l}`,re=x?fe({pascal:u,kebab:l,repoPrefix:`.`,dtoPrefix:`./dtos`}):S({pascal:u,kebab:l,repoType:a,repoPrefix:`.`,dtoPrefix:`./dtos`});return await y(`${ne}.repository.ts`,re),await te(i,u,d,l,s),h}function kt(e,t){return`import { z } from 'zod'
277
+ `),c}const Et={string:{ts:`string`,zod:`z.string()`},text:{ts:`string`,zod:`z.string()`},number:{ts:`number`,zod:`z.number()`},int:{ts:`number`,zod:`z.number().int()`},float:{ts:`number`,zod:`z.number()`},boolean:{ts:`boolean`,zod:`z.boolean()`},date:{ts:`string`,zod:`z.string().datetime()`},email:{ts:`string`,zod:`z.string().email()`},url:{ts:`string`,zod:`z.string().url()`},uuid:{ts:`string`,zod:`z.string().uuid()`},json:{ts:`any`,zod:`z.any()`}};function Dt(e){return e.map(e=>{let t=e.indexOf(`:`);if(t===-1)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let n=e.slice(0,t),r=e.slice(t+1);if(!n||!r)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let i=!1;r.endsWith(`:optional`)&&(r=r.slice(0,-9),i=!0),n.endsWith(`?`)&&(n=n.slice(0,-1),i=!0),r.endsWith(`?`)&&(r=r.slice(0,-1),i=!0);let a=r;if(a.startsWith(`enum:`)){let e=a.slice(5).split(`,`);return{name:n,type:`enum`,tsType:e.map(e=>`'${e}'`).join(` | `),zodType:`z.enum([${e.map(e=>`'${e}'`).join(`, `)}])`,optional:i}}let o=Et[a];if(!o){let e=[...Object.keys(Et),`enum:a,b,c`].join(`, `);throw Error(`Unknown field type: "${a}". Valid types: ${e}`)}return{name:n,type:a,tsType:o.ts,zodType:o.zod,optional:i}})}async function Ot(e){let{name:n,fields:r,modulesDir:i,repo:a=`inmemory`,tokenScope:o=`app`,style:s=`define`}=e,c=e.pluralize!==!1,l=b(n),u=w(n),d=c?C(l):l,f=c?v(u):u,p=A(i,d),h=[],y=async(e,n)=>{let r=A(p,e);await t(r,n),h.push(r)};await y(`${l}.module.ts`,ee({pascal:u,kebab:l,plural:d,repo:a,style:s})),await y(`${l}.constants.ts`,_({pascal:u,kebab:l})),await y(`${l}.controller.ts`,fe({pascal:u,kebab:l,plural:d,pluralPascal:f})),await y(`${l}.service.ts`,g({pascal:u,kebab:l})),await y(`dtos/create-${l}.dto.ts`,kt(u,r)),await y(`dtos/update-${l}.dto.ts`,At(u,r)),await y(`dtos/${l}-response.dto.ts`,jt(u,r)),await y(`${l}.repository.ts`,m({pascal:u,kebab:l,dtoPrefix:`./dtos`,tokenScope:o}));let x=a===`inmemory`,ne=x?`in-memory-${l}`:`${b(a)}-${l}`,re=x?pe({pascal:u,kebab:l,repoPrefix:`.`,dtoPrefix:`./dtos`}):S({pascal:u,kebab:l,repoType:a,repoPrefix:`.`,dtoPrefix:`./dtos`});return await y(`${ne}.repository.ts`,re),await te(i,u,d,l,s),h}function kt(e,t){return`import { z } from 'zod'
278
278
 
279
279
  export const create${e}Schema = z.object({
280
280
  ${t.map(e=>{let t=e.zodType;return` ${e.name}: ${t}${e.optional?`.optional()`:``},`}).join(`
@@ -323,19 +323,19 @@ describe('${s}', () => {
323
323
  `),c.push(u),c}const Nt=[`agents`,`claude`,`skills`,`gemini`,`copilot`,`both`,`all`];function U(e){return e.parent?.opts()?.dryRun??!1}function W(e,t=!1){let n=process.cwd();console.log(`\n ${t?`Would generate`:`Generated`} ${e.length} file${e.length===1?``:`s`}:`);for(let t of e)console.log(` ${t.replace(n+`/`,``)}`);t&&console.log(`
324
324
  (dry run — no files were written)`),console.log()}async function G(e){if(!e)try{let e=await E(process.cwd());await He({cwd:process.cwd(),allowDuplicates:!0,silent:!0,schemaValidator:e?.typegen?.schemaValidator??`zod`,envFile:e?.typegen?.envFile,srcDir:e?.typegen?.srcDir,outDir:e?.typegen?.outDir})}catch{}}const Pt=[{name:`module <name>`,description:`REST module (controller, service, DTOs, repo)`},{name:`scaffold <name> <fields...>`,description:`CRUD module from field definitions`},{name:`controller <name>`,description:`@Controller() class [-m module]`},{name:`service <name>`,description:`@Service() singleton [-m module]`},{name:`middleware <name>`,description:`Express middleware function [-m module]`},{name:`guard <name>`,description:`Route guard (auth, roles, etc.) [-m module]`},{name:`contributor <name>`,description:`Context contributor [--type http|bare] [--params a:string] [-m]`},{name:`dto <name>`,description:`Zod DTO schema [-m module]`},{name:`adapter <name>`,description:`AppAdapter with lifecycle hooks (app-level only)`},{name:`test <name>`,description:`Vitest test scaffold [-m module]`},{name:`job <name>`,description:`Queue @Job processor`},{name:`config`,description:`Generate kick.config.ts`},{name:`agents`,description:`Regenerate AGENTS.md + CLAUDE.md + kickjs-skills.md from upstream templates`}],Ft=new Set(Pt.map(e=>e.name.split(` `)[0]));async function It(){console.log(`
325
325
  Built-in generators:
326
- `);let e=Math.max(...Pt.map(e=>e.name.length));for(let t of Pt)console.log(` kick g ${t.name.padEnd(e+2)} ${t.description}`);let t=await E(process.cwd()),n=Oe(t?.plugins??[],t?.commands??[]),r=await oe(process.cwd(),n.generators);if(r.generators.length>0){console.log(`
326
+ `);let e=Math.max(...Pt.map(e=>e.name.length));for(let t of Pt)console.log(` kick g ${t.name.padEnd(e+2)} ${t.description}`);let t=await E(process.cwd()),n=Oe(t?.plugins??[],t?.commands??[]),r=await de(process.cwd(),n.generators);if(r.generators.length>0){console.log(`
327
327
  Plugin generators:
328
328
  `);let e=Math.max(...r.generators.map(e=>`${e.spec.name} <name>`.length));for(let{source:t,spec:n}of r.generators){let r=`${n.name} <name>`;console.log(` kick g ${r.padEnd(e+2)} ${n.description} [${t}]`)}}if(r.failed.length>0){console.log(`
329
329
  Failed to load:
330
- `);for(let{source:e,reason:t}of r.failed)console.log(` ${e} — ${t}`)}console.log()}async function Lt(e,t,n){let r=await E(process.cwd()),i=T(r),o=t.modulesDir??i.dir??`src/modules`,s=t.repo??ne(i.repo);t.repo&&we(t.repo);let c=t.pattern??r?.pattern??`rest`,l=t.pluralize===!1?!1:i.pluralize??!0,u=Ce(r,process.cwd()),d=i.style??`define`;if(!n&&d===`define`){let e=await wt(M(o),`define`);if(e.length>0){console.error(`\n ${a.red(`Error:`)} ${e.length} module file(s) still use the legacy \`class … implements AppModule\` shape.\n ${a.dim(`Project setting:`)} modules.style: 'define' (default)\n\n ${a.bold(`Files needing migration:`)}`);for(let t of e.slice(0,5))console.error(` - ${t}`);e.length>5&&console.error(` … and ${e.length-5} more`),console.error(`\n ${a.bold(`Pick one:`)}\n 1. Migrate everything to defineModule:\n ${a.dim(`$`)} kick codemod modules --experimental --apply\n 2. Keep the class form — pin it in kick.config.ts:\n ${a.dim(`// kick.config.ts`)}\n ${a.dim(`export default defineConfig({ modules: { style: 'class' } })`)}\n`),process.exit(1)}}let f=[];for(let r of e){let e=await be({name:r,modulesDir:M(o),noEntity:t.entity===!1,noTests:t.tests===!1,repo:s,minimal:t.minimal,force:t.force,pattern:c,dryRun:n,pluralize:l,prismaClientPath:i.prismaClientPath,tokenScope:u,style:i.style});f.push(...e)}W(f,n),await G(n)}function Rt(e,t){let n=e.command(`generate [names...]`).alias(`g`).description("Generate code scaffolds — bare form `kick g <name>` is shorthand for `kick g module <name>`").option(`--list`,`List all available generators`).option(`--dry-run`,`Preview files that would be generated without writing them`).option(`--no-entity`,`Skip entity and value object generation (module shortcut)`).option(`--no-tests`,`Skip test file generation (module shortcut)`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name (e.g. postgres)`).option(`--pattern <pattern>`,`Override project pattern: rest | minimal`).option(`--minimal`,`Shorthand for --pattern minimal`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular names (skip auto-pluralization)`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,r,i)=>{if(r.list){await It();return}if(!e||e.length===0){n.help();return}let a=U(i);p(a);let[o,s,...c]=e;if(o){let e=await E(process.cwd()),n=Oe(e?.plugins??[],e?.commands??[]),i=await pe({generatorName:o,itemName:s??``,args:c,flags:r,cwd:process.cwd(),projectRoot:t?.projectRoot},n.generators);if(i){W(i.files,a);return}if(o!==`module`&&Ft.has(o)){console.error(`\n '${o}' is a generator, not a module name.`),console.error(` Did you mean: kick g ${o} ${s??`<name>`}`),console.error(` If that errors, your @forinda/kickjs-cli is older than the '${o}' generator — upgrade it.\n`),process.exitCode=1;return}}await Lt(e,r,a)});n.command(`module <names...>`).description(`Generate one or more modules (e.g. kick g module user task project)`).option(`--no-entity`,`Skip entity and value object generation`).option(`--no-tests`,`Skip test file generation`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name (e.g. postgres)`).option(`--pattern <pattern>`,`Override project pattern: rest | minimal`).option(`--minimal`,`Shorthand for --pattern minimal`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular names (skip auto-pluralization)`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t,n)=>{let r=U(n);p(r),await Lt(e,{...n.optsWithGlobals(),...t},r)}),n.command(`adapter <name>`).description(`Generate an AppAdapter with lifecycle hooks and middleware support`).option(`-o, --out <dir>`,`Output directory`,`src/adapters`).action(async(e,t,n)=>{let r=U(n);p(r),W(await xe({name:e,outDir:M(t.out)}),r)}),n.command(`plugin <name>`).description(`Generate a KickPlugin with DI, modules, adapters, middleware, and lifecycle hooks`).option(`-o, --out <dir>`,`Output directory`,`src/plugins`).action(async(e,t,n)=>{let r=U(n);p(r),W(await lt({name:e,outDir:M(t.out)}),r)}),n.command(`middleware <name>`).description(`Generate an Express middleware function
330
+ `);for(let{source:e,reason:t}of r.failed)console.log(` ${e} — ${t}`)}console.log()}async function Lt(e,t,n){let r=await E(process.cwd()),i=T(r),o=t.modulesDir??i.dir??`src/modules`,s=t.repo??ne(i.repo);t.repo&&we(t.repo);let c=t.pattern??r?.pattern??`rest`,l=t.pluralize===!1?!1:i.pluralize??!0,u=Ce(r,process.cwd()),d=i.style??`define`;if(!n&&d===`define`){let e=await wt(M(o),`define`);if(e.length>0){console.error(`\n ${a.red(`Error:`)} ${e.length} module file(s) still use the legacy \`class … implements AppModule\` shape.\n ${a.dim(`Project setting:`)} modules.style: 'define' (default)\n\n ${a.bold(`Files needing migration:`)}`);for(let t of e.slice(0,5))console.error(` - ${t}`);e.length>5&&console.error(` … and ${e.length-5} more`),console.error(`\n ${a.bold(`Pick one:`)}\n 1. Migrate everything to defineModule:\n ${a.dim(`$`)} kick codemod modules --experimental --apply\n 2. Keep the class form — pin it in kick.config.ts:\n ${a.dim(`// kick.config.ts`)}\n ${a.dim(`export default defineConfig({ modules: { style: 'class' } })`)}\n`),process.exit(1)}}let f=[];for(let r of e){let e=await be({name:r,modulesDir:M(o),noEntity:t.entity===!1,noTests:t.tests===!1,repo:s,minimal:t.minimal,force:t.force,pattern:c,dryRun:n,pluralize:l,prismaClientPath:i.prismaClientPath,tokenScope:u,style:i.style});f.push(...e)}W(f,n),await G(n)}function Rt(e,t){let n=e.command(`generate [names...]`).alias(`g`).description("Generate code scaffolds — bare form `kick g <name>` is shorthand for `kick g module <name>`").option(`--list`,`List all available generators`).option(`--dry-run`,`Preview files that would be generated without writing them`).option(`--no-entity`,`Skip entity and value object generation (module shortcut)`).option(`--no-tests`,`Skip test file generation (module shortcut)`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name (e.g. postgres)`).option(`--pattern <pattern>`,`Override project pattern: rest | minimal`).option(`--minimal`,`Shorthand for --pattern minimal`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular names (skip auto-pluralization)`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,r,i)=>{if(r.list){await It();return}if(!e||e.length===0){n.help();return}let a=U(i);p(a);let[o,s,...c]=e;if(o){let e=await E(process.cwd()),n=Oe(e?.plugins??[],e?.commands??[]),i=await ie({generatorName:o,itemName:s??``,args:c,flags:r,cwd:process.cwd(),projectRoot:t?.projectRoot},n.generators);if(i){W(i.files,a);return}if(o!==`module`&&Ft.has(o)){console.error(`\n '${o}' is a generator, not a module name.`),console.error(` Did you mean: kick g ${o} ${s??`<name>`}`),console.error(` If that errors, your @forinda/kickjs-cli is older than the '${o}' generator — upgrade it.\n`),process.exitCode=1;return}}await Lt(e,r,a)});n.command(`module <names...>`).description(`Generate one or more modules (e.g. kick g module user task project)`).option(`--no-entity`,`Skip entity and value object generation`).option(`--no-tests`,`Skip test file generation`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name (e.g. postgres)`).option(`--pattern <pattern>`,`Override project pattern: rest | minimal`).option(`--minimal`,`Shorthand for --pattern minimal`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular names (skip auto-pluralization)`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t,n)=>{let r=U(n);p(r),await Lt(e,{...n.optsWithGlobals(),...t},r)}),n.command(`adapter <name>`).description(`Generate an AppAdapter with lifecycle hooks and middleware support`).option(`-o, --out <dir>`,`Output directory`,`src/adapters`).action(async(e,t,n)=>{let r=U(n);p(r),W(await xe({name:e,outDir:M(t.out)}),r)}),n.command(`plugin <name>`).description(`Generate a KickPlugin with DI, modules, adapters, middleware, and lifecycle hooks`).option(`-o, --out <dir>`,`Output directory`,`src/plugins`).action(async(e,t,n)=>{let r=U(n);p(r),W(await lt({name:e,outDir:M(t.out)}),r)}),n.command(`middleware <name>`).description(`Generate an Express middleware function
331
331
  Use -m to scope it to a module: kick g middleware auth -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await Se({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r)}),n.command(`guard <name>`).description(`Generate a route guard (auth, roles, etc.)
332
332
  Use -m to scope it to a module: kick g guard admin -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await ye({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r)}),n.command(`contributor <name>`).description(`Generate a Context Contributor (typed alternative to @Middleware for ctx.set)
333
333
  --type http (default, RequestContext) | bare (ExecutionContext)
334
334
  --params "source:string,region:number" → emits the withParams<T>() form
335
335
  Use -m to scope it to a module: kick g contributor tenant -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).option(`-t, --type <type>`,`Contributor flavour: http | bare`,`http`).option(`-k, --key <key>`,`Context key it writes (defaults to camelCase of name)`).option(`--params <fields>`,`Per-call params, e.g. "source:string,region:number"`).action(async(e,t,n)=>{let r=U(n);p(r);let i=(t.type??`http`).toLowerCase();i!==`http`&&i!==`bare`&&(console.warn(` kick g contributor: unknown --type '${t.type}', using 'http'.`),i=`http`);let a=await E(process.cwd()),o=T(a),s=o.dir??`src/modules`;W(await ft({name:e,type:i,key:t.key,params:t.params,outDir:t.out,moduleName:t.module,modulesDir:s,pattern:a?.pattern,pluralize:o.pluralize??!0}),r)}),n.command(`service <name>`).description(`Generate a @Service() class
336
336
  Use -m to scope it to a module: kick g service payment -m orders`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await re({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r)}),n.command(`controller <name>`).description(`Generate a @Controller() class with basic routes
337
- Use -m to scope it to a module: kick g controller auth -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await ce({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r),await G(r)}),n.command(`dto <name>`).description(`Generate a Zod DTO schema
338
- Use -m to scope it to a module: kick g dto create-user -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await le({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r)}),n.command(`test <name>`).description(`Generate a Vitest test scaffold
337
+ Use -m to scope it to a module: kick g controller auth -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await le({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r),await G(r)}),n.command(`dto <name>`).description(`Generate a Zod DTO schema
338
+ Use -m to scope it to a module: kick g dto create-user -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=await E(process.cwd()),a=T(i),o=a.dir??`src/modules`;W(await ue({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r)}),n.command(`test <name>`).description(`Generate a Vitest test scaffold
339
339
  Use -m to scope it to a module: kick g test user-service -m users`).option(`-o, --out <dir>`,`Output directory (overrides --module)`).option(`-m, --module <module>`,`Place inside a module's __tests__/ folder`).action(async(e,t,n)=>{let r=U(n);p(r);let i=T(await E(process.cwd())),a=i.dir??`src/modules`;W(await Mt({name:e,outDir:t.out,moduleName:t.module,modulesDir:a,pluralize:i.pluralize??!0}),r)}),n.command(`job <name>`).description(`Generate a @Job queue processor with @Process handlers`).option(`-o, --out <dir>`,`Output directory`,`src/jobs`).option(`-q, --queue <name>`,`Queue name (default: <name>-queue)`).action(async(e,t,n)=>{let r=U(n);p(r),W(await Tt({name:e,outDir:M(t.out),queue:t.queue}),r)}),n.command(`scaffold <name> [fields...]`).description(`Generate a full CRUD module from field definitions
340
340
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
341
341
  Types: string, text, number, int, float, boolean, date, email, url, uuid, json, enum:a,b,c
@@ -345,10 +345,10 @@ describe('${s}', () => {
345
345
  Usage: kick g scaffold <name> <field:type> [field:type...]
346
346
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
347
347
  Optional: append :optional (shell-safe, no quoting needed)
348
- `),process.exit(1));let a=await E(process.cwd()),o=T(a),s=n.modulesDir??o.dir??`src/modules`,c=Dt(t),l=Ce(a,process.cwd()),u=await Ot({name:e,fields:c,modulesDir:M(s),noEntity:n.entity===!1,noTests:n.tests===!1,pluralize:n.pluralize===!1?!1:o.pluralize??!0,tokenScope:l,style:o.style});console.log(`\n Scaffolded ${e} with ${c.length} field(s):`);for(let e of c)console.log(` ${e.name}: ${e.type}${e.optional?` (optional)`:``}`);W(u,i),await G(i)}),n.command(`config`).description(`Generate a kick.config.ts at the project root`).option(`--modules-dir <dir>`,`Modules directory path`,`src/modules`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name`,`inmemory`).option(`-f, --force`,`Overwrite existing kick.config.ts without prompting`).action(async(e,t)=>{let n=U(t);p(n),W(await pt({outDir:M(`.`),modulesDir:e.modulesDir,defaultRepo:e.repo,force:e.force}),n)}),n.command(`agents`).alias(`agent-docs`).alias(`ai-docs`).description(`Regenerate AGENTS.md + CLAUDE.md + kickjs-skills.md (sync after framework upgrades)`).option(`--only <which>`,`Limit scope: agents | claude | skills | both (agents+claude) | all (default: all)`,`all`).option(`--name <name>`,`Project name (defaults to package.json name)`).option(`--pm <pm>`,`Package manager (defaults to package.json packageManager)`).option(`--template <template>`,`Template: rest | minimal`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t)=>{let n=U(t);p(n);let r=e.only??`all`;if(!Nt.includes(r)){console.error(` Invalid --only value: ${r}. Expected: ${Nt.join(` | `)}`),process.exitCode=1;return}W(await De({outDir:M(`.`),only:r,name:e.name,pm:e.pm,template:e.template,force:e.force}),n)});for(let e of t?.generators??[])zt(n,e,t?.projectRoot)}function zt(e,t,n){let{source:r,spec:i}=t,a=i.args?.[0],o=a?.name??`itemName`,s=a?.required?`<${o}>`:`[${o}]`,c=`${i.name} ${s} [extraArgs...]`,l=e.command(c).description(`${i.description} [${r}]`);for(let e of i.flags??[]){let t=e.takesValue?`--${e.name} <value>`:`--${e.name}`,n=e.alias?`-${e.alias}, ${t}`:t;l.option(n,e.description??``)}l.action(async(e,r,a,o)=>{let s=U(o);p(s);let c=await pe({generatorName:i.name,itemName:e??``,args:r??[],flags:a,cwd:process.cwd(),projectRoot:n},[t]);c&&W(c.files,s)})}function Bt(e,t,n){let r=nt(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function Vt(e){let t=O.resolve(e.cwd,`.kickjs/types`);await I(t,{recursive:!0});let n=new Map,r=e.scan??Pe,i=O.resolve(e.cwd,`.kickjs`,`cache`),a=e.scan?void 0:e.changedFiles,o={cwd:e.cwd,config:e.config,async importTs(e){return await import(z(e).href)},async writeFile(t,n){let r=O.resolve(e.cwd,t);await I(O.dirname(r),{recursive:!0}),await R(r,n,`utf8`)},getScanResult:e=>{let t=Ht(e),o=n.get(t);if(!o){let s={cacheDir:i,...e};o=a?Ne(s,a):r(s),n.set(t,o)}return o},log:console},s=[];for(let n of e.plugins){let r=n.outExtension??`.d.ts`,i=O.join(t,`${n.id.replace(/\//g,`__`)}${r}`),a;try{a=await n.generate(o)}catch(e){let t=e instanceof Error?e.message:String(e);o.log.error(` ${n.id}: typegen failed (${t}) — keeping previous output`),s.push({id:n.id,status:`error`,outFile:i});continue}if(a===null){s.push({id:n.id,status:`skipped`});continue}let c=`/* AUTO-GENERATED by kick typegen — do not edit. Plugin: ${n.id} */\n\n`+a+`
348
+ `),process.exit(1));let a=await E(process.cwd()),o=T(a),s=n.modulesDir??o.dir??`src/modules`,c=Dt(t),l=Ce(a,process.cwd()),u=await Ot({name:e,fields:c,modulesDir:M(s),noEntity:n.entity===!1,noTests:n.tests===!1,pluralize:n.pluralize===!1?!1:o.pluralize??!0,tokenScope:l,style:o.style});console.log(`\n Scaffolded ${e} with ${c.length} field(s):`);for(let e of c)console.log(` ${e.name}: ${e.type}${e.optional?` (optional)`:``}`);W(u,i),await G(i)}),n.command(`config`).description(`Generate a kick.config.ts at the project root`).option(`--modules-dir <dir>`,`Modules directory path`,`src/modules`).option(`--repo <type>`,`Repository name: inmemory (default) or any DB name`,`inmemory`).option(`-f, --force`,`Overwrite existing kick.config.ts without prompting`).action(async(e,t)=>{let n=U(t);p(n),W(await pt({outDir:M(`.`),modulesDir:e.modulesDir,defaultRepo:e.repo,force:e.force}),n)}),n.command(`agents`).alias(`agent-docs`).alias(`ai-docs`).description(`Regenerate AGENTS.md + CLAUDE.md + kickjs-skills.md (sync after framework upgrades)`).option(`--only <which>`,`Limit scope: agents | claude | skills | both (agents+claude) | all (default: all)`,`all`).option(`--name <name>`,`Project name (defaults to package.json name)`).option(`--pm <pm>`,`Package manager (defaults to package.json packageManager)`).option(`--template <template>`,`Template: rest | minimal`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t)=>{let n=U(t);p(n);let r=e.only??`all`;if(!Nt.includes(r)){console.error(` Invalid --only value: ${r}. Expected: ${Nt.join(` | `)}`),process.exitCode=1;return}W(await De({outDir:M(`.`),only:r,name:e.name,pm:e.pm,template:e.template,force:e.force}),n)});for(let e of t?.generators??[])zt(n,e,t?.projectRoot)}function zt(e,t,n){let{source:r,spec:i}=t,a=i.args?.[0],o=a?.name??`itemName`,s=a?.required?`<${o}>`:`[${o}]`,c=`${i.name} ${s} [extraArgs...]`,l=e.command(c).description(`${i.description} [${r}]`);for(let e of i.flags??[]){let t=e.takesValue?`--${e.name} <value>`:`--${e.name}`,n=e.alias?`-${e.alias}, ${t}`:t;l.option(n,e.description??``)}l.action(async(e,r,a,o)=>{let s=U(o);p(s);let c=await ie({generatorName:i.name,itemName:e??``,args:r??[],flags:a,cwd:process.cwd(),projectRoot:n},[t]);c&&W(c.files,s)})}function Bt(e,t,n){let r=nt(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function Vt(e){let t=O.resolve(e.cwd,`.kickjs/types`);await I(t,{recursive:!0});let n=new Map,r=e.scan??Pe,i=O.resolve(e.cwd,`.kickjs`,`cache`),a=e.scan?void 0:e.changedFiles,o={cwd:e.cwd,config:e.config,async importTs(e){return await import(z(e).href)},async writeFile(t,n){let r=O.resolve(e.cwd,t);await I(O.dirname(r),{recursive:!0}),await R(r,n,`utf8`)},getScanResult:e=>{let t=Ht(e),o=n.get(t);if(!o){let s={cacheDir:i,...e};o=a?Ne(s,a):r(s),n.set(t,o)}return o},log:console},s=[];for(let n of e.plugins){let r=n.outExtension??`.d.ts`,i=O.join(t,`${n.id.replace(/\//g,`__`)}${r}`),a;try{a=await n.generate(o)}catch(e){let t=e instanceof Error?e.message:String(e);o.log.error(` ${n.id}: typegen failed (${t}) — keeping previous output`),s.push({id:n.id,status:`error`,outFile:i});continue}if(a===null){s.push({id:n.id,status:`skipped`});continue}let c=`/* AUTO-GENERATED by kick typegen — do not edit. Plugin: ${n.id} */\n\n`+a+`
349
349
  `,l=``;if(P(i)&&(l=await L(i,`utf8`)),l===c){s.push({id:n.id,status:`unchanged`,outFile:i});continue}if(e.check)throw Error(`kick typegen --check: drift detected for ${n.id} (${i})`);await R(i,c,`utf8`),s.push({id:n.id,status:`written`,outFile:i})}return s}function Ht(e){let t=(e.extensions??[]).slice().toSorted().join(`,`),n=(e.exclude??[]).slice().toSorted().join(`,`);return[`root=${e.root}`,`cwd=${e.cwd}`,`extensions=${t}`,`exclude=${n}`,`envFile=${e.envFile??``}`].join(`|`)}function Ut(e,t){let n=new Set(t),r=[],i=[],a=new Set;for(let t of e)n.has(t.id)?(i.push(t),a.add(t.id)):r.push(t);return{enabled:r,skipped:i,unknown:[...n].filter(e=>!a.has(e))}}function Wt(){let e=(process.env.LOG_LEVEL??process.env.KICKJS_LOG_LEVEL??``).toLowerCase();return e===`debug`||e===`trace`}async function Gt(e){let{enabled:t,skipped:n,unknown:r}=Ut(Oe([...Or,...e.config?.plugins??[]],e.config?.commands??[]).typegens,e.config?.typegen?.disable??[]);if(!e.silent&&n.length>0)for(let e of n)console.log(` ${e.id}: disabled (typegen.disable)`);if(!e.silent&&r.length>0&&console.warn(` kick typegen: disable list references unknown id(s): ${r.map(e=>`'${e}'`).join(`, `)}. Run \`kick typegen --list\` to see registered ids.`),t.length===0)return[];try{let n=await Vt({cwd:e.cwd,config:e.config??{},plugins:t,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&Wt())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(!e.silent){let e=t instanceof Error?t.message:String(t);console.warn(` kick typegen plugins: skipped (${e})`)}return[]}}function Kt(e){let t=A(e,`node_modules`,`.bin`),n=process.platform===`win32`;for(let e of[`tsgo`,`tsc`]){let r=n?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=A(t,i);if(P(r))return{cmd:r,args:[`--noEmit`],shell:n,kind:e}}}return null}function qt(e){let t=e.spawnFn??tt,n=null,r=0,i=!1;return{schedule(){if(i)return;let a=++r;n&&=(n.kill(),null);let o=Date.now(),s=t(e.bin.cmd,e.bin.args,{cwd:e.cwd,shell:e.bin.shell,stdio:[`ignore`,`pipe`,`pipe`]});n=s;let c=``;s.stdout?.on(`data`,e=>{c+=e.toString()}),s.stderr?.on(`data`,e=>{c+=e.toString()}),s.on(`error`,()=>{a===r&&(n=null)}),s.on(`close`,t=>{i||a!==r||(n=null,e.onResult({ok:t===0,output:c,durationMs:Date.now()-o,kind:e.bin.kind}))})},dispose(){i=!0,n&&=(n.kill(),null)}}}function Jt(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
350
350
  `):`${n.slice(0,t).join(`
351
- `)}\n… ${n.length-t} more line(s)`}function Yt(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function Xt(e,t,n={}){t&&(process.env.PORT=t);let r=Yt(n.polling),i=process.cwd(),a=await E(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await He({cwd:i,allowDuplicates:!0,schemaValidator:o,envFile:s,srcDir:a?.typegen?.srcDir,outDir:a?.typegen?.outDir,assetMap:a?.assetMap,runPlugins:!1})}catch(e){console.warn(` kick typegen: skipped (${e?.message??e})`)}let c=M(i,a?.typegen?.outDir??`.kickjs/types`);try{await Fe(c,await Gt({cwd:i,config:a}),!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:l}=await import(`node:module`),{createServer:u}=await import(z(l(M(`package.json`)).resolve(`vite`)).href);globalThis[se]=`kick-dev`;let d=await u({configFile:M(`vite.config.ts`),server:{port:t?parseInt(t,10):void 0,...r?{watch:{usePolling:!0,interval:100}}:{}}}),f=n.typecheck??a?.dev?.typecheck??!1,p=null,m=!0;if(f){let e=Kt(i);e?p=qt({cwd:i,bin:e,onResult:e=>{d.hot.send({type:`custom`,event:`kickjs:typecheck`,data:{ok:e.ok,output:e.output,durationMs:e.durationMs}}),e.ok?m||(m=!0,console.log(` kick typecheck: clean again (${e.kind}, ${e.durationMs}ms)`)):(m=!1,console.warn(`\n kick typecheck (${e.kind}, ${e.durationMs}ms):`),console.warn(Jt(e.output).replace(/^/gm,` `)))}}):console.warn(` kick dev: --typecheck requested but neither tsgo (@typescript/native-preview) nor typescript is installed in this project — skipping type checks.`)}let h=ge({cwd:i,config:a,emitWarning:e=>{console.warn(e),d.hot.send({type:`custom`,event:`kickjs:typegen-error`,data:{message:e,timestamp:Date.now()}})},onPassComplete:()=>p?.schedule()});d.watcher.on(`add`,e=>h.handleWatchEvent(`add`,e)),d.watcher.on(`unlink`,e=>h.handleWatchEvent(`unlink`,e)),d.watcher.on(`change`,e=>h.handleWatchEvent(`change`,e)),d.watcher.on(`unlinkDir`,e=>h.handleWatchEvent(`unlinkDir`,e)),h.assetSrcRoots.length>0&&d.watcher.add([...h.assetSrcRoots]),await d.listen(),d.printUrls(),console.log(`
351
+ `)}\n… ${n.length-t} more line(s)`}function Yt(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function Xt(e,t,n={}){t&&(process.env.PORT=t);let r=Yt(n.polling),i=process.cwd(),a=await E(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await He({cwd:i,allowDuplicates:!0,schemaValidator:o,envFile:s,srcDir:a?.typegen?.srcDir,outDir:a?.typegen?.outDir,assetMap:a?.assetMap,runPlugins:!1})}catch(e){console.warn(` kick typegen: skipped (${e?.message??e})`)}let c=M(i,a?.typegen?.outDir??`.kickjs/types`);try{await Fe(c,await Gt({cwd:i,config:a}),!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:l}=await import(`node:module`),{createServer:u}=await import(z(l(M(`package.json`)).resolve(`vite`)).href);globalThis[oe]=`kick-dev`;let d=await u({configFile:M(`vite.config.ts`),server:{port:t?parseInt(t,10):void 0,...r?{watch:{usePolling:!0,interval:100}}:{}}}),f=n.typecheck??a?.dev?.typecheck??!1,p=null,m=!0;if(f){let e=Kt(i);e?p=qt({cwd:i,bin:e,onResult:e=>{d.hot.send({type:`custom`,event:`kickjs:typecheck`,data:{ok:e.ok,output:e.output,durationMs:e.durationMs}}),e.ok?m||(m=!0,console.log(` kick typecheck: clean again (${e.kind}, ${e.durationMs}ms)`)):(m=!1,console.warn(`\n kick typecheck (${e.kind}, ${e.durationMs}ms):`),console.warn(Jt(e.output).replace(/^/gm,` `)))}}):console.warn(` kick dev: --typecheck requested but neither tsgo (@typescript/native-preview) nor typescript is installed in this project — skipping type checks.`)}let h=me({cwd:i,config:a,emitWarning:e=>{console.warn(e),d.hot.send({type:`custom`,event:`kickjs:typegen-error`,data:{message:e,timestamp:Date.now()}})},onPassComplete:()=>p?.schedule()});d.watcher.on(`add`,e=>h.handleWatchEvent(`add`,e)),d.watcher.on(`unlink`,e=>h.handleWatchEvent(`unlink`,e)),d.watcher.on(`change`,e=>h.handleWatchEvent(`change`,e)),d.watcher.on(`unlinkDir`,e=>h.handleWatchEvent(`unlinkDir`,e)),h.assetSrcRoots.length>0&&d.watcher.add([...h.assetSrcRoots]),await d.listen(),d.printUrls(),console.log(`
352
352
  KickJS dev server running (Vite + @forinda/kickjs-vite)
353
353
  `),p?.schedule();let g=!1,_=async()=>{if(!g){g=!0,h.dispose(),p?.dispose();try{await globalThis.__kickjs_app_shutdown?.()}catch(e){console.error(` app shutdown hook failed: ${e?.message??e}`)}await d.close(),process.exit(0)}};process.on(`SIGINT`,_),process.on(`SIGTERM`,_),process.on(`SIGBREAK`,_)}function Zt(e){e.command(`dev`).description(`Start development server with Vite HMR (zero-downtime reload)`).option(`-e, --entry <file>`,`Entry file`,`src/index.ts`).option(`-p, --port <port>`,`Port number`).option(`--polling`,`Force chokidar to poll for file changes (Docker / WSL / NFS / older kernels)`).option(`--typecheck`,`Run the project TypeScript checker (tsgo/tsc --noEmit) after each change and report diagnostics`).action(async e=>{try{await Xt(e.entry,e.port,{polling:e.polling,typecheck:e.typecheck})}catch(e){e.code===`ERR_MODULE_NOT_FOUND`&&e.message?.includes(`vite`)?console.error(`
354
354
  Error: vite is not installed.
@@ -364,7 +364,7 @@ describe('${s}', () => {
364
364
  Building asset map...`);try{await Ee(e,{cwd:process.cwd()}),console.log(`
365
365
  Asset build complete.
366
366
  `)}catch(e){console.error(` ✗ ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}),e.command(`start`).description(`Start production server`).option(`-e, --entry <file>`,`Entry file`,`dist/index.js`).option(`-p, --port <port>`,`Port number`).action(e=>{let t={NODE_ENV:`production`};e.port&&(t.PORT=String(e.port)),Bt(e.entry,t)}),e.command(`dev:debug`).description(`Start dev server with Node.js inspector attached`).option(`-e, --entry <file>`,`Entry file`,`src/index.ts`).option(`-p, --port <port>`,`Port number`).option(`--inspect-port <port>`,`Inspector port`,`9229`).action(async e=>{let t=e.inspectPort??`9229`;process.env.NODE_OPTIONS=`--inspect=0.0.0.0:${t}`,console.log(` Debugger: ws://0.0.0.0:${t}`);try{await Xt(e.entry,e.port)}catch(e){console.error(`
367
- Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function Qt(){try{let e=k(rt(import.meta.url));return JSON.parse(F(A(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const $t=new Set(Object.values(ue).filter(e=>e.deprecated).map(e=>e.pkg));function en(e){let t=A(e,`package.json`);if(!P(t))return[];let n;try{n=JSON.parse(F(t,`utf-8`))}catch{return[]}let r={...n.dependencies,...n.devDependencies};return Object.keys(r).filter(e=>e===`@forinda/kickjs`||e.startsWith(`@forinda/kickjs-`)).toSorted().map(t=>{let n=null,i=A(e,`node_modules`,...t.split(`/`),`package.json`);if(P(i))try{n=JSON.parse(F(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:$t.has(t)}})}function tn(e){let t=e;for(;;){if(P(A(t,`package.json`)))return t;let e=k(t);if(e===t)return null;t=e}}function nn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${Qt()}`,``,` System:`,` OS: ${at()} ${ot()} (${it()})`,` Node: ${process.version}`],t=tn(process.cwd()),n=t?en(t):[];if(!t)e.push(``,` Packages: (not inside a project — no package.json found)`);else if(n.length===0)e.push(``,` Packages: (no @forinda/kickjs* dependencies in ${t})`);else{e.push(``,` Packages:`);let t=Math.max(...n.map(e=>e.name.length));for(let r of n){let n=r.installed??`${r.declared??`?`} (declared — not installed)`,i=r.deprecated?" [DEPRECATED — see `kick add --list --all`]":``;e.push(` ${r.name.padEnd(t+2)} ${n}${i}`)}}e.push(``),console.log(e.join(`
367
+ Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function Qt(){try{let e=k(rt(import.meta.url));return JSON.parse(F(A(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const $t=new Set(Object.values(se).filter(e=>e.deprecated).map(e=>e.pkg));function en(e){let t=A(e,`package.json`);if(!P(t))return[];let n;try{n=JSON.parse(F(t,`utf-8`))}catch{return[]}let r={...n.dependencies,...n.devDependencies};return Object.keys(r).filter(e=>e===`@forinda/kickjs`||e.startsWith(`@forinda/kickjs-`)).toSorted().map(t=>{let n=null,i=A(e,`node_modules`,...t.split(`/`),`package.json`);if(P(i))try{n=JSON.parse(F(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:$t.has(t)}})}function tn(e){let t=e;for(;;){if(P(A(t,`package.json`)))return t;let e=k(t);if(e===t)return null;t=e}}function nn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${Qt()}`,``,` System:`,` OS: ${at()} ${ot()} (${it()})`,` Node: ${process.version}`],t=tn(process.cwd()),n=t?en(t):[];if(!t)e.push(``,` Packages: (not inside a project — no package.json found)`);else if(n.length===0)e.push(``,` Packages: (no @forinda/kickjs* dependencies in ${t})`);else{e.push(``,` Packages:`);let t=Math.max(...n.map(e=>e.name.length));for(let r of n){let n=r.installed??`${r.declared??`?`} (declared — not installed)`,i=r.deprecated?" [DEPRECATED — see `kick add --list --all`]":``;e.push(` ${r.name.padEnd(t+2)} ${n}${i}`)}}e.push(``),console.log(e.join(`
368
368
  `))})}const{bold:K,dim:q,green:rn,red:J,yellow:an,blue:on}=a;function sn(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=[];return t&&a.push(`${t}d`),n&&a.push(`${n}h`),r&&a.push(`${r}m`),a.push(`${i}s`),a.join(` `)}async function cn(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function Y(e,t){try{return await cn(`${e}${t}`)}catch{return null}}async function ln(e){let[t,n,r,i,a]=await Promise.all([Y(e,`/health`),Y(e,`/metrics`),Y(e,`/routes`),Y(e,`/container`),Y(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function un(e,t){let{health:n,metrics:r,routes:i,container:a,ws:s}=t,c=q(`─`.repeat(60));if(console.log(),console.log(K(` KickJS Inspector`)+q(` → ${e}`)),console.log(c),n){let e=n.status===`healthy`?rn(`● healthy`):J(`● `+n.status);console.log(` ${K(`Health:`)} ${e}`)}else console.log(` ${K(`Health:`)} ${J(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?J:r.errorRate>0?an:rn;console.log(` ${K(`Uptime:`)} ${sn(r.uptimeSeconds)}`),console.log(` ${K(`Requests:`)} ${r.requests}`),console.log(` ${K(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${q(`(`)}${t(e+`%`)}${q(`)`)}`)}if(a&&console.log(` ${K(`DI:`)} ${a.count} bindings`),s&&s.enabled&&console.log(` ${K(`WS:`)} ${s.connections??0} connections, ${s.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(K(` Routes`)),console.log(c),console.log(` ${q(`METHOD`)} ${q(`PATH`.padEnd(36))} ${q(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${o(e.method)} ${t} ${on(e.controller)}.${q(e.handler)}`)}}console.log(c),console.log()}function dn(e){e.command(`inspect [url]`).description(`Connect to a running KickJS app and display debug info`).option(`-p, --port <port>`,`Override port`).option(`-w, --watch`,`Poll every 5 seconds`).option(`-j, --json`,`Output raw JSON`).action(async(e,t)=>{let n=e??`http://localhost:3000`;if(t.port)try{let e=new URL(n);e.port=t.port,n=e.origin}catch{n=`http://localhost:${t.port}`}let r=`${n.replace(/\/$/,``)}/_debug`,i=async()=>{try{let e=await ln(r);t.json?console.log(JSON.stringify(e,null,2)):un(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(J(` ✖ Could not connect to ${n}`)),console.error(q(` ${e instanceof Error?e.message:String(e)}`))),t.watch||(process.exitCode=1)}};if(t.watch){let e=async()=>{process.stdout.write(`\x1B[2J\x1B[H`),await i()};await e(),setInterval(e,5e3)}else await i()})}function fn(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e.toLowerCase()))}function X(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}const pn=[{match(e,t){let n=fn(e,[`config`,`get`])&&X(e,[`undefined`,`null`]),r=e.includes(`@Value`)&&X(e,[`undefined`,`is not defined`]);return!n&&!r?null:{confidence:n&&r?90:75,diagnosis:{id:`env-schema-not-registered`,title:`ConfigService.get() returns undefined for user-defined keys`,explanation:`Your src/index.ts is missing \`import "./config"\`. That side-effect import
369
369
  registers the env schema with kickjs at module-load time. Without it,
370
370
  ConfigService falls back to the base schema (PORT/NODE_ENV/LOG_LEVEL only)
@@ -538,7 +538,7 @@ server.on('exit', () => {
538
538
  Cancelled.
539
539
  `);return}await Qe(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let d=A(n,`index.ts`);if(await f(d)){let e=await L(d,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${x(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${x(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=Rn(e,s),e=e.replace(/\n{3,}/g,`
540
540
 
541
- `),e!==t&&(await R(d,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${d}`))}console.log(`\n Module '${c}' removed.\n`)}function Bn(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=T(await E(process.cwd())),r=t.modulesDir??n.dir??`src/modules`,i=t.pluralize===!1?!1:n.pluralize??!0;for(let n of e)await zn({name:n,modulesDir:M(r),force:t.force,pluralize:i})})}function Vn(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function Hn(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Un(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: fail on plugin-typegen drift instead of writing`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=Te(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-DiLjdUhB.mjs`).then(e=>e.t),{builtinCliPlugins:t}=await import(`./builtins-B9jAir23.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
541
+ `),e!==t&&(await R(d,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${d}`))}console.log(`\n Module '${c}' removed.\n`)}function Bn(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=T(await E(process.cwd())),r=t.modulesDir??n.dir??`src/modules`,i=t.pluralize===!1?!1:n.pluralize??!0;for(let n of e)await zn({name:n,modulesDir:M(r),force:t.force,pluralize:i})})}function Vn(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function Hn(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Un(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: fail on plugin-typegen drift instead of writing`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=Te(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-Dl2YqKay.mjs`).then(e=>e.t),{builtinCliPlugins:t}=await import(`./builtins-DIyfh8Vq.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
542
542
  Registered typegen plugins:
543
543
  `);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``;console.log(` ${e.id.padEnd(a+2)}inputs: ${e.inputs.join(`, `)||`(none)`}${t}`)}console.log();return}let r=Vn(e.schemaValidator)??n?.typegen?.schemaValidator??`zod`,i=Hn(e.envFile)??n?.typegen?.envFile,a={cwd:t,srcDir:e.src??n?.typegen?.srcDir,outDir:e.out??n?.typegen?.outDir,silent:e.silent,allowDuplicates:e.allowDuplicates,noCache:e.cache===!1,schemaValidator:r,envFile:i,assetMap:n?.assetMap,runPlugins:!1};try{if(e.watch){let t=await Be(a);e.silent||console.log(` kick typegen: watching for changes (Ctrl-C to exit)`);let n=()=>{t(),process.exit(0)};process.on(`SIGINT`,n),process.on(`SIGTERM`,n),await new Promise(()=>{})}else{await He(a);let r=await Gt({cwd:t,config:n??null,silent:e.silent,check:e.check});e.check&&r.some(e=>e.status===`written`)&&process.exit(1),e.check||await Fe(M(t,e.out??n?.typegen?.outDir??`.kickjs/types`),r,e.silent??!1)}}catch(e){e instanceof Ve?console.error(`
544
544
  `+e.message+`
@@ -616,6 +616,6 @@ declare global {
616
616
  }
617
617
 
618
618
  export {}
619
- `}const gr=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=vr(e);if(t===!1)return null;let n=await e.getScanResult({root:_r(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=O.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return hr(n.env,i,r)}});function _r(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function vr(e){return e.config?.typegen?.envFile}function yr(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function br(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:yr(e),cwd:e.cwd,envFile:br(e)}}const xr=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=O.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return ze(t.classes,n,r)}}),Sr=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className));return Le(`ServiceToken`,Ie(t.classes,t.tokens,t.injects,n),"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Cr=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){return Le(`ModuleToken`,Ae((await e.getScanResult($(e))).classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),wr=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){return Me((await e.getScanResult($(e))).pluginsAndAdapters)}}),Tr=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){return Ue((await e.getScanResult($(e))).augmentations)}}),Er=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:je(t.contextKeys)}}),Dr={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Or=[D({name:`kick/init`,register:ct}),D({name:`kick/generate`,register:Rt}),D({name:`kick/run`,register:Zt}),D({name:`kick/info`,register:nn}),D({name:`kick/inspect`,register:dn}),D({name:`kick/add`,register:ie}),D({name:`kick/list`,register:he}),D({name:`kick/explain`,register:xn}),D({name:`kick/mcp`,register:An}),D({name:`kick/tinker`,register:Pn}),D({name:`kick/remove`,register:Bn}),D({name:`kick/typegen`,register:Un}),D({name:`kick/check`,register:tr}),D({name:`kick/doctor`,register:_e}),D({name:`kick/codemod`,register:rr}),D({name:`kick/registry`,typegens:[xr()]}),D({name:`kick/services`,typegens:[Sr()]}),D({name:`kick/modules`,typegens:[Cr()]}),D({name:`kick/plugins`,typegens:[wr()]}),D({name:`kick/augmentations`,typegens:[Tr()]}),D({name:`kick/context`,typegens:[Er()]}),D({name:`kick/assets`,typegens:[ir()]}),D({name:`kick/routes`,typegens:[fr()]}),D({name:`kick/env`,typegens:[gr()]}),D({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Dr[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
619
+ `}const gr=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=vr(e);if(t===!1)return null;let n=await e.getScanResult({root:_r(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=O.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return hr(n.env,i,r)}});function _r(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function vr(e){return e.config?.typegen?.envFile}function yr(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function br(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:yr(e),cwd:e.cwd,envFile:br(e)}}const xr=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=O.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return ze(t.classes,n,r)}}),Sr=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className));return Le(`ServiceToken`,Ie(t.classes,t.tokens,t.injects,n),"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Cr=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){return Le(`ModuleToken`,Ae((await e.getScanResult($(e))).classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),wr=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){return Me((await e.getScanResult($(e))).pluginsAndAdapters)}}),Tr=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){return Ue((await e.getScanResult($(e))).augmentations)}}),Er=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:je(t.contextKeys)}}),Dr={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Or=[D({name:`kick/init`,register:ct}),D({name:`kick/generate`,register:Rt}),D({name:`kick/run`,register:Zt}),D({name:`kick/info`,register:nn}),D({name:`kick/inspect`,register:dn}),D({name:`kick/add`,register:ce}),D({name:`kick/list`,register:ge}),D({name:`kick/explain`,register:xn}),D({name:`kick/mcp`,register:An}),D({name:`kick/tinker`,register:Pn}),D({name:`kick/remove`,register:Bn}),D({name:`kick/typegen`,register:Un}),D({name:`kick/check`,register:tr}),D({name:`kick/doctor`,register:_e}),D({name:`kick/codemod`,register:rr}),D({name:`kick/registry`,typegens:[xr()]}),D({name:`kick/services`,typegens:[Sr()]}),D({name:`kick/modules`,typegens:[Cr()]}),D({name:`kick/plugins`,typegens:[wr()]}),D({name:`kick/augmentations`,typegens:[Tr()]}),D({name:`kick/context`,typegens:[Er()]}),D({name:`kick/assets`,typegens:[ir()]}),D({name:`kick/routes`,typegens:[fr()]}),D({name:`kick/env`,typegens:[gr()]}),D({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Dr[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
620
620
  `)}}]})];export{Ut as applyDisableFilter,Gt as runAllPluginTypegens,Or as t};
621
- //# sourceMappingURL=run-plugins-DujFeVh4.mjs.map
621
+ //# sourceMappingURL=run-plugins-u58MFV45.mjs.map