@forinda/kickjs-cli 8.1.5 → 8.1.7

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 (47) hide show
  1. package/dist/{agent-docs-DzaWoZc7.mjs → agent-docs-CNKIzlQ5.mjs} +3 -3
  2. package/dist/{agent-docs-DzaWoZc7.mjs.map → agent-docs-CNKIzlQ5.mjs.map} +1 -1
  3. package/dist/{agent-docs-BK33p0Pw.mjs → agent-docs-DUtJ6p1e.mjs} +2 -2
  4. package/dist/{build-clh7HpZV.mjs → build-C1ya_zWp.mjs} +3 -3
  5. package/dist/{build-DBT23vXN.mjs → build-CYRMk2Z8.mjs} +4 -4
  6. package/dist/{build-DBT23vXN.mjs.map → build-CYRMk2Z8.mjs.map} +1 -1
  7. package/dist/{builtins-HdwKAx0s.mjs → builtins-Byjz8UuR.mjs} +2 -2
  8. package/dist/{builtins-B6Dc2coA.mjs → builtins-CTvWnQQZ.mjs} +121 -24
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-CzL24fBQ.mjs → config-BZIWs0bx.mjs} +3 -3
  11. package/dist/{config-D06pHD-Y.mjs → config-BaIkyt4R.mjs} +4 -4
  12. package/dist/{config-D06pHD-Y.mjs.map → config-BaIkyt4R.mjs.map} +1 -1
  13. package/dist/{doctor-Bi_jVzha.mjs → doctor-CtPbmFxW.mjs} +8 -7
  14. package/dist/{doctor-Bi_jVzha.mjs.map → doctor-CtPbmFxW.mjs.map} +1 -1
  15. package/dist/{fullstack-DAEEITND.mjs → fullstack-KQgV78V3.mjs} +3 -3
  16. package/dist/{fullstack-CdAbknb3.mjs → fullstack-kj0NzeKU.mjs} +4 -4
  17. package/dist/{fullstack-CdAbknb3.mjs.map → fullstack-kj0NzeKU.mjs.map} +1 -1
  18. package/dist/index.d.mts +22 -22
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +2 -2
  21. package/dist/plugin-B240AAOf.mjs +11 -0
  22. package/dist/{plugin-BSNGbECd.mjs → plugin-KiE0QPvK.mjs} +2 -2
  23. package/dist/{project-DfBzpCeE.mjs → project-C5jzgKo-.mjs} +28 -26
  24. package/dist/{project-indmSdfC.mjs → project-Dq4SdxF6.mjs} +26 -24
  25. package/dist/project-Dq4SdxF6.mjs.map +1 -0
  26. package/dist/{project-docs-DRLN1EDX.mjs → project-docs-CP73I9uv.mjs} +1 -1
  27. package/dist/{project-docs-BCwWphge.mjs → project-docs-DRVouPvK.mjs} +2 -2
  28. package/dist/{project-docs-BCwWphge.mjs.map → project-docs-DRVouPvK.mjs.map} +1 -1
  29. package/dist/{project-root-CQCNCAvv.mjs → project-root-BRMuHEs3.mjs} +3 -3
  30. package/dist/{project-root-CQCNCAvv.mjs.map → project-root-BRMuHEs3.mjs.map} +1 -1
  31. package/dist/{project-root-BsyQhlS5.mjs → project-root-D4iNxhPu.mjs} +2 -2
  32. package/dist/{prompts-Ba0PO3Rn.mjs → prompts-DDlFHtva.mjs} +2 -2
  33. package/dist/{prompts-Ba0PO3Rn.mjs.map → prompts-DDlFHtva.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-DmTqmRjS.mjs → rolldown-runtime-BAJI6YvG.mjs} +1 -1
  35. package/dist/{run-plugins-BKWupYoJ.mjs → run-plugins-BYPm9bbY.mjs} +186 -90
  36. package/dist/run-plugins-BYPm9bbY.mjs.map +1 -0
  37. package/dist/typegen-BZJk-Lmq.mjs +131 -0
  38. package/dist/typegen-BdNffFKy.mjs +132 -0
  39. package/dist/{typegen-CnsfSSpH.mjs.map → typegen-BdNffFKy.mjs.map} +1 -1
  40. package/dist/{types-B6yNws8R.mjs → types-D8Vtq4vL.mjs} +1 -1
  41. package/package.json +6 -6
  42. package/dist/plugin-CD9WjquV.mjs +0 -12
  43. package/dist/plugin-CD9WjquV.mjs.map +0 -1
  44. package/dist/project-indmSdfC.mjs.map +0 -1
  45. package/dist/run-plugins-BKWupYoJ.mjs.map +0 -1
  46. package/dist/typegen-B6vIx4Qd.mjs +0 -131
  47. package/dist/typegen-CnsfSSpH.mjs +0 -132
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.1.5
2
+ * @forinda/kickjs-cli v8.1.7
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-DmTqmRjS.mjs";import{a as t,c as n,i as r,o as i,r as a,s as o,t as s,u as c}from"./project-DfBzpCeE.mjs";import{a as l,c as u,i as d,l as f,o as p,r as m,s as h}from"./config-CzL24fBQ.mjs";import{n as g,r as _}from"./plugin-BSNGbECd.mjs";import{c as v,l as y,s as b}from"./project-docs-DRLN1EDX.mjs";import{a as x,c as S,d as ee,f as C,i as te,l as ne,n as re,o as ie,p as ae,r as w,s as T,u as oe}from"./agent-docs-BK33p0Pw.mjs";import{t as E}from"./project-root-BsyQhlS5.mjs";import{_ as se,a as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,l as he,m as ge,o as _e,p as ve,r as ye,s as be,t as xe,u as Se}from"./typegen-B6vIx4Qd.mjs";import{t as Ce}from"./build-clh7HpZV.mjs";import{createRequire as we}from"node:module";import{cpSync as Te,existsSync as D,mkdirSync as Ee,readFileSync as O,readdirSync as k,rmSync as De,statSync as Oe,writeFileSync as ke}from"node:fs";import A,{basename as Ae,dirname as j,join as M,relative as N,resolve as P,sep as je}from"node:path";import{fileURLToPath as Me,pathToFileURL as F}from"node:url";import{fork as Ne,spawn as Pe,spawnSync as Fe}from"node:child_process";import{copyFile as Ie,mkdir as Le,readFile as I,readdir as Re,rm as ze,stat as Be,writeFile as L}from"node:fs/promises";import"@forinda/kickjs-cli-kit";import Ve from"pluralize";import{arch as He,platform as Ue,release as We}from"node:os";import{createHash as Ge}from"node:crypto";const Ke=[{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 qe(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 | fullstack`).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. swagger,ws,queue,devtools)`).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)=>{te(`KickJS — Create a new project`);let r=!!(t.yes||t.nonInteractive);e||=r?`my-api`:await oe({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let i;if(e===`.`?(i=P(`.`),e=Ae(i)):i=P(t.directory||e),D(i)){let n=k(i);if(n.length>0){if(t.force)x.warn(`Clearing existing files in ${i}`);else if(r){x.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),T(`Aborted.`);return}else{x.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)x.message(` - ${e}`);if(n.length>5&&x.message(` ... and ${n.length-5} more`),!await w({message:C.red(`Remove all existing files and proceed?`),initialValue:!1})){T(`Aborted.`);return}}for(let e of n)De(P(i,e),{recursive:!0,force:!0})}}let a=t.template;a||=r?`minimal`:await S({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`}]});let o=t.runtime;o||=r?`express`:await S({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 c=t.pm;c||=r?await n(void 0):await S({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let l=t.repo;l||=r?`inmemory`:await oe({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),f(l);let u=t.schema;u||=r?`zod`:await S({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(u)||(x.warn(`Unknown --schema "${u}", falling back to zod.`),u=`zod`);let d;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();d=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else d=r?[]:await ie({message:`Select packages to include`,options:[...Ke],required:!1});let p;p=t.git===void 0?r?!0:await w({message:`Initialize git repository?`,initialValue:!0}):t.git;let m;if(m=t.install===void 0?r?!0:await w({message:`Install dependencies?`,initialValue:!0}):t.install,a===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-DAEEITND.mjs`);await t({name:e,directory:i,packageManager:c,initGit:p,installDeps:m,schemaLib:u,runtime:o}),T(`Done! Next steps: ${C.cyan(`cd ${e} && ${c}${c===`pnpm`?` dev`:` run dev:server`}`)}`);return}await s({name:e,directory:i,packageManager:c,initGit:p,installDeps:m,template:a,defaultRepo:l,packages:d,schemaLib:u,runtime:o}),T(`Done! Next steps: ${C.cyan(`cd ${e} && ${c} dev`)}`)})}function R(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^(.)/,e=>e.toUpperCase())}function z(e){let t=R(e);return t.charAt(0).toLowerCase()+t.slice(1)}function B(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[\s_]+/g,`-`).toLowerCase()}function V(e){return Ve.plural(e)}function Je(e){return Ve.plural(e)}function Ye(e){return B(e).replace(/-/g,`_`)}function Xe(e){let t=e.cwd??process.cwd(),n=e.projectRoot??E(t),r=e.pluralize??!0,i=R(e.name),a=z(e.name),o=B(e.name),s=Ye(e.name),c={name:e.name,pascal:i,camel:a,kebab:o,snake:s,modulesDir:e.modulesDir??`src/modules`,cwd:t,projectRoot:n,args:e.args??[],flags:e.flags??{}};if(r){let e=V(o);c.pluralKebab=e,c.pluralPascal=R(e),c.pluralCamel=z(e)}return c}function Ze(e,t){return P(e.cwd,t)}async function Qe(e){return import(F(e).href)}const $e=new Map;async function et(e){let t=$e.get(e);if(t)return t;let n=tt(e);return $e.set(e,n),n}async function tt(e){let t=P(e,`package.json`);if(!D(t))return{generators:[],loaded:[],failed:[]};let n=nt(JSON.parse(await I(t,`utf-8`))),r=we(P(e,`package.json`)),i=[],a=[],o=[];for(let e of n){let t;try{t=r.resolve(`${e}/package.json`)}catch{continue}let n;try{n=JSON.parse(await I(t,`utf-8`))}catch(t){o.push({source:e,reason:`failed to parse package.json: ${t}`});continue}if(!n.kickjs?.generators)continue;let s=n.kickjs.generators,c=P(j(t),s);if(!D(c)){o.push({source:e,reason:`kickjs.generators points to missing file: ${s}`});continue}let l;try{l=await Qe(c)}catch(t){o.push({source:e,reason:`failed to import manifest: ${t}`});continue}let u=l.default;if(!Array.isArray(u)){o.push({source:e,reason:`manifest's default export is not an array of GeneratorSpec`});continue}for(let t of u){if(!rt(t)){o.push({source:e,reason:`manifest entry is not a valid GeneratorSpec (missing name/files)`});continue}i.push({source:e,spec:t})}a.push(e)}return{generators:i,loaded:a,failed:o}}function nt(e){let t=new Set;for(let n of[e.dependencies,e.devDependencies,e.peerDependencies])if(n)for(let e of Object.keys(n))t.add(e);return Array.from(t)}function rt(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.files==`function`}async function it(e,t=[]){let n=e.cwd??process.cwd(),r=t.find(t=>t.spec.name===e.generatorName);if(r)return st(r.spec,r.source,e,n);let i=ot(await et(n),e.generatorName);return i?st(i.spec,i.source,e,n):null}async function at(e,t=[]){let n=await et(e),r=new Set(t.map(e=>e.spec.name)),i=n.generators.filter(e=>!r.has(e.spec.name));return{generators:[...t,...i],loaded:n.loaded,failed:n.failed}}function ot(e,t){return e.generators.find(e=>e.spec.name===t)}async function st(e,t,n,r){let i=Xe({name:n.itemName,args:n.args,flags:n.flags,modulesDir:n.modulesDir,pluralize:n.pluralize,cwd:r,projectRoot:n.projectRoot}),a=await e.files(i),o=[];for(let e of a){let t=Ze(i,e.path);await y(t,e.content),o.push(t)}return{files:o,source:t}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const ct={inmemory:`in-memory`,drizzle:`Drizzle`,prisma:`Prisma`};function lt(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ut(e){return ct[e]??lt(e)}function dt(e){return`create${e}Repository`}function ft(e){return e??`define`}function pt(e){let{pascal:t,kebab:n,plural:r=``,repo:i,style:a}=e,o=dt(t),s=ft(a),c=`/**
11
+ import{t as e}from"./rolldown-runtime-BAJI6YvG.mjs";import{a as t,c as n,i as r,o as i,r as a,s as o,t as s,u as c}from"./project-C5jzgKo-.mjs";import{a as l,c as u,i as d,l as f,o as p,r as m,s as h}from"./config-BZIWs0bx.mjs";import{n as g,r as _}from"./plugin-KiE0QPvK.mjs";import{c as v,l as y,s as b}from"./project-docs-CP73I9uv.mjs";import{a as x,c as S,d as ee,f as C,i as te,l as ne,n as re,o as ie,p as ae,r as w,s as T,u as oe}from"./agent-docs-DUtJ6p1e.mjs";import{t as E}from"./project-root-D4iNxhPu.mjs";import{_ as se,a as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,l as he,m as ge,o as _e,p as ve,r as ye,s as be,t as xe,u as Se}from"./typegen-BZJk-Lmq.mjs";import{t as Ce}from"./build-C1ya_zWp.mjs";import{createRequire as we}from"node:module";import{cpSync as Te,existsSync as D,mkdirSync as Ee,readFileSync as O,readdirSync as k,rmSync as De,statSync as Oe,writeFileSync as ke}from"node:fs";import A,{basename as Ae,dirname as j,join as M,relative as N,resolve as P,sep as je}from"node:path";import{fileURLToPath as Me,pathToFileURL as F}from"node:url";import{fork as Ne,spawn as Pe,spawnSync as Fe}from"node:child_process";import{copyFile as Ie,mkdir as Le,readFile as I,readdir as Re,rm as ze,stat as Be,writeFile as L}from"node:fs/promises";import"@forinda/kickjs-cli-kit";import Ve from"pluralize";import{arch as He,platform as Ue,release as We}from"node:os";import{createHash as Ge}from"node:crypto";const Ke=[{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 qe(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 | fullstack`).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. swagger,ws,queue,devtools)`).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)=>{te(`KickJS — Create a new project`);let r=!!(t.yes||t.nonInteractive);e||=r?`my-api`:await oe({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let i;if(e===`.`?(i=P(`.`),e=Ae(i)):i=P(t.directory||e),D(i)){let n=k(i);if(n.length>0){if(t.force)x.warn(`Clearing existing files in ${i}`);else if(r){x.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),T(`Aborted.`);return}else{x.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)x.message(` - ${e}`);if(n.length>5&&x.message(` ... and ${n.length-5} more`),!await w({message:C.red(`Remove all existing files and proceed?`),initialValue:!1})){T(`Aborted.`);return}}for(let e of n)De(P(i,e),{recursive:!0,force:!0})}}let a=t.template;a||=r?`minimal`:await S({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`}]});let o=t.runtime;o||=r?`express`:await S({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 c=t.pm;c||=r?await n(void 0):await S({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let l=t.repo;l||=r?`inmemory`:await oe({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),f(l);let u=t.schema;u||=r?`zod`:await S({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(u)||(x.warn(`Unknown --schema "${u}", falling back to zod.`),u=`zod`);let d;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();d=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else d=r?[]:await ie({message:`Select packages to include`,options:[...Ke],required:!1});let p;p=t.git===void 0?r?!0:await w({message:`Initialize git repository?`,initialValue:!0}):t.git;let m;if(m=t.install===void 0?r?!0:await w({message:`Install dependencies?`,initialValue:!0}):t.install,a===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-KQgV78V3.mjs`);await t({name:e,directory:i,packageManager:c,initGit:p,installDeps:m,schemaLib:u,runtime:o}),T(`Done! Next steps: ${C.cyan(`cd ${e} && ${c}${c===`pnpm`?` dev`:` run dev:server`}`)}`);return}await s({name:e,directory:i,packageManager:c,initGit:p,installDeps:m,template:a,defaultRepo:l,packages:d,schemaLib:u,runtime:o}),T(`Done! Next steps: ${C.cyan(`cd ${e} && ${c} dev`)}`)})}function R(e){return e.replace(/[-_\s]+(.)?/g,(e,t)=>t?t.toUpperCase():``).replace(/^(.)/,e=>e.toUpperCase())}function z(e){let t=R(e);return t.charAt(0).toLowerCase()+t.slice(1)}function B(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[\s_]+/g,`-`).toLowerCase()}function V(e){return Ve.plural(e)}function Je(e){return Ve.plural(e)}function Ye(e){return B(e).replace(/-/g,`_`)}function Xe(e){let t=e.cwd??process.cwd(),n=e.projectRoot??E(t),r=e.pluralize??!0,i=R(e.name),a=z(e.name),o=B(e.name),s=Ye(e.name),c={name:e.name,pascal:i,camel:a,kebab:o,snake:s,modulesDir:e.modulesDir??`src/modules`,cwd:t,projectRoot:n,args:e.args??[],flags:e.flags??{}};if(r){let e=V(o);c.pluralKebab=e,c.pluralPascal=R(e),c.pluralCamel=z(e)}return c}function Ze(e,t){return P(e.cwd,t)}async function Qe(e){return import(F(e).href)}const $e=new Map;async function et(e){let t=$e.get(e);if(t)return t;let n=tt(e);return $e.set(e,n),n}async function tt(e){let t=P(e,`package.json`);if(!D(t))return{generators:[],loaded:[],failed:[]};let n=nt(JSON.parse(await I(t,`utf-8`))),r=we(P(e,`package.json`)),i=[],a=[],o=[];for(let e of n){let t;try{t=r.resolve(`${e}/package.json`)}catch{continue}let n;try{n=JSON.parse(await I(t,`utf-8`))}catch(t){o.push({source:e,reason:`failed to parse package.json: ${t}`});continue}if(!n.kickjs?.generators)continue;let s=n.kickjs.generators,c=P(j(t),s);if(!D(c)){o.push({source:e,reason:`kickjs.generators points to missing file: ${s}`});continue}let l;try{l=await Qe(c)}catch(t){o.push({source:e,reason:`failed to import manifest: ${t}`});continue}let u=l.default;if(!Array.isArray(u)){o.push({source:e,reason:`manifest's default export is not an array of GeneratorSpec`});continue}for(let t of u){if(!rt(t)){o.push({source:e,reason:`manifest entry is not a valid GeneratorSpec (missing name/files)`});continue}i.push({source:e,spec:t})}a.push(e)}return{generators:i,loaded:a,failed:o}}function nt(e){let t=new Set;for(let n of[e.dependencies,e.devDependencies,e.peerDependencies])if(n)for(let e of Object.keys(n))t.add(e);return Array.from(t)}function rt(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.name==`string`&&typeof t.files==`function`}async function it(e,t=[]){let n=e.cwd??process.cwd(),r=t.find(t=>t.spec.name===e.generatorName);if(r)return st(r.spec,r.source,e,n);let i=ot(await et(n),e.generatorName);return i?st(i.spec,i.source,e,n):null}async function at(e,t=[]){let n=await et(e),r=new Set(t.map(e=>e.spec.name)),i=n.generators.filter(e=>!r.has(e.spec.name));return{generators:[...t,...i],loaded:n.loaded,failed:n.failed}}function ot(e,t){return e.generators.find(e=>e.spec.name===t)}async function st(e,t,n,r){let i=Xe({name:n.itemName,args:n.args,flags:n.flags,modulesDir:n.modulesDir,pluralize:n.pluralize,cwd:r,projectRoot:n.projectRoot}),a=await e.files(i),o=[];for(let e of a){let t=Ze(i,e.path);await y(t,e.content),o.push(t)}return{files:o,source:t}}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const ct={inmemory:`in-memory`,drizzle:`Drizzle`,prisma:`Prisma`};function lt(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function ut(e){return ct[e]??lt(e)}function dt(e){return`create${e}Repository`}function ft(e){return e??`define`}function pt(e){let{pascal:t,kebab:n,plural:r=``,repo:i,style:a}=e,o=dt(t),s=ft(a),c=`/**
12
12
  * ${t} Module
13
13
  *
14
14
  * REST module with a flat folder structure.
@@ -540,7 +540,7 @@ export class ${t}Controller {
540
540
  return reply.noContent()
541
541
  }
542
542
  }
543
- `)}async function Dt(e){let{pascal:t,kebab:n,plural:r,pluralPascal:i,repo:a,noTests:o,tokenScope:s,style:c,testHarness:l,write:u}=e,d=e.swagger??!1,f=e.schemaLib??`zod`;await u(`${n}.module.ts`,pt({pascal:t,kebab:n,plural:r,repo:a,style:c})),await u(`${n}.constants.ts`,Tt({pascal:t,kebab:n})),await u(`${n}.controller.ts`,ht({pascal:t,kebab:n,plural:r,pluralPascal:i,swagger:d})),await u(`${n}.service.ts`,wt({pascal:t,kebab:n})),await u(`dtos/create-${n}.dto.ts`,vt({pascal:t,kebab:n,schemaLib:f})),await u(`dtos/update-${n}.dto.ts`,yt({pascal:t,kebab:n,schemaLib:f})),await u(`dtos/${n}-response.dto.ts`,bt({pascal:t,kebab:n})),await u(`${n}.repository.ts`,xt({pascal:t,kebab:n,repoType:a,dtoPrefix:`./dtos`,tokenScope:s})),o||(await u(`__tests__/${n}.controller.test.ts`,St({pascal:t,kebab:n,plural:r,style:c,testHarness:l})),await u(`__tests__/${n}.repository.test.ts`,Ct({pascal:t,kebab:n,plural:r,repoPrefix:`../${n}.repository`})))}function Ot(e){return e?typeof e==`string`?e:e.name:`inmemory`}async function kt(e){let{name:t,modulesDir:n,noEntity:r,noTests:i,repo:a=`inmemory`,force:o,dryRun:s}=e,c=e.pluralize!==!1,l=e.pattern??`rest`;e.minimal&&(l=`minimal`);let u=B(t),d=R(t),f=c?V(u):u,p=c?Je(d):d,m=M(n,f),h=[],g=o??!1,_={kebab:u,pascal:d,plural:f,pluralPascal:p,moduleDir:m,repo:a,noEntity:r??!1,noTests:i??!1,tokenScope:e.tokenScope??`app`,swagger:e.swagger??!1,schemaLib:e.schemaLib??`zod`,testHarness:e.testHarness??!1,style:e.style??`define`,write:async(e,t)=>{let n=M(m,e);if(s){h.push(n);return}if(!g&&await b(n)&&!await w({message:`File exists: ${C.dim(e)}. Overwrite?`,initialValue:!1})){x.warn(`Skipped: ${e}`);return}await y(n,t),h.push(n)},files:h};switch(l){case`minimal`:await Et(_);break;default:await Dt(_);break}return s||await At(n,d,f,u,_.style),h}async function At(e,t,n,r,i=`define`){let a=M(e,`index.ts`),o=await b(a),s=`./${n}/${r}.module`,c=i===`class`?`${t}Module`:`${t}Module()`;if(!o){await y(a,i===`class`?`import type { AppModuleEntry } from '@forinda/kickjs'
543
+ `)}async function Dt(e){let{pascal:t,kebab:n,plural:r,pluralPascal:i,repo:a,noTests:o,tokenScope:s,style:c,testHarness:l,write:u}=e,d=e.swagger??!1,f=e.schemaLib??`zod`;await u(`${n}.module.ts`,pt({pascal:t,kebab:n,plural:r,repo:a,style:c})),await u(`${n}.constants.ts`,Tt({pascal:t,kebab:n})),await u(`${n}.controller.ts`,ht({pascal:t,kebab:n,plural:r,pluralPascal:i,swagger:d})),await u(`${n}.service.ts`,wt({pascal:t,kebab:n})),await u(`dtos/create-${n}.dto.ts`,vt({pascal:t,kebab:n,schemaLib:f})),await u(`dtos/update-${n}.dto.ts`,yt({pascal:t,kebab:n,schemaLib:f})),await u(`dtos/${n}-response.dto.ts`,bt({pascal:t,kebab:n})),await u(`${n}.repository.ts`,xt({pascal:t,kebab:n,repoType:a,dtoPrefix:`./dtos`,tokenScope:s})),o||(await u(`__tests__/${n}.controller.test.ts`,St({pascal:t,kebab:n,plural:r,style:c,testHarness:l})),await u(`__tests__/${n}.repository.test.ts`,Ct({pascal:t,kebab:n,plural:r,repoPrefix:`../${n}.repository`})))}function Ot(e){return e?typeof e==`string`?e:e.name:`inmemory`}async function kt(e){let{name:t,modulesDir:n,noEntity:r,noTests:i,repo:a=`inmemory`,force:o,dryRun:s}=e,c=e.pluralize!==!1,l=e.pattern??`rest`;e.minimal&&(l=`minimal`);let u=B(t),d=R(t),f=c?V(u):u,p=c?Je(d):d,m=M(n,f),h=[],g=o??!1,_={kebab:u,pascal:d,plural:f,pluralPascal:p,moduleDir:m,repo:a,noEntity:r??!1,noTests:i??!1,tokenScope:e.tokenScope??`app`,swagger:e.swagger??!1,schemaLib:e.schemaLib??`zod`,testHarness:e.testHarness??!1,style:e.style??`define`,write:async(e,t)=>{let n=M(m,e);if(s){h.push(n);return}if(!g&&await b(n)&&!await w({message:`File exists: ${C.dim(e)}. Overwrite?`,initialValue:!1})){x.warn(`Skipped: ${e}`);return}await y(n,t),h.push(n)},files:h};switch(l){case`minimal`:await Et(_);break;default:await Dt(_)}return s||await At(n,d,f,u,_.style),h}async function At(e,t,n,r,i=`define`){let a=M(e,`index.ts`),o=await b(a),s=`./${n}/${r}.module`,c=i===`class`?`${t}Module`:`${t}Module()`;if(!o){let e=i===`class`?`import type { AppModuleEntry } from '@forinda/kickjs'
544
544
  import { ${t}Module } from '${s}'
545
545
 
546
546
  export const modules: AppModuleEntry[] = [${c}]
@@ -548,7 +548,7 @@ export const modules: AppModuleEntry[] = [${c}]
548
548
  import { ${t}Module } from '${s}'
549
549
 
550
550
  export const modules = defineModules().mount(${c})
551
- `);return}let l=await I(a,`utf-8`),u=`import { ${t}Module } from '${s}'`,d=H(s);if(!RegExp(`^import\\s*\\{[^}]*\\b${H(t)}Module\\b[^}]*\\}\\s*from\\s*['"]${d}['"]`,`m`).test(l)){let e=l.lastIndexOf(`import `);if(e!==-1){let t=l.indexOf(`
551
+ `;await y(a,e);return}let l=await I(a,`utf-8`),u=`import { ${t}Module } from '${s}'`,d=H(s);if(!RegExp(`^import\\s*\\{[^}]*\\b${H(t)}Module\\b[^}]*\\}\\s*from\\s*['"]${d}['"]`,`m`).test(l)){let e=l.lastIndexOf(`import `);if(e!==-1){let t=l.indexOf(`
552
552
  `,e);l=l.slice(0,t+1)+u+`
553
553
  `+l.slice(t+1)}else l=u+`
554
554
  `+l}let f=Mt(l);if(f){let e=l.slice(f.rhsStart,f.rhsEnd+1);RegExp(`\\b${H(t)}Module\\b`).test(e)||(l=jt(l,c))}else l=jt(l,c);await L(a,l,`utf-8`)}function jt(e,t){let n=Mt(e);if(!n)return e;if(n.shape===`array`){let r=e.slice(n.rhsStart+1,n.rhsEnd),i=r.trim(),a;if(!i)a=`[${t}]`;else{let e=i.endsWith(`,`)?``:`,`;a=`[${r.trimEnd()}${e} ${t}]`}return e.slice(0,n.rhsStart)+a+e.slice(n.rhsEnd+1)}return`${e.slice(0,n.chainEnd)}\n .mount(${t})${e.slice(n.chainEnd)}`}function Mt(e){let t=/export\s+const\s+modules\b[^=]*=/.exec(e);if(!t)return null;let n=t.index+t[0].length;for(;n<e.length&&/\s/.test(e[n]??``);)n++;if(e[n]===`[`){let t=Ft(e,n);return t===-1?null:{shape:`array`,rhsStart:n,rhsEnd:t}}if(e.slice(n,n+13)===`defineModules`){let t=Nt(e,n);return t===-1?null:{shape:`chain`,rhsStart:n,rhsEnd:t-1,chainEnd:t}}return null}function Nt(e,t=0){let n=/defineModules\s*\(/g;n.lastIndex=t;let r=n.exec(e);if(!r)return-1;let i=r.index+r[0].length-1;if(e[i]!==`(`||(i=It(e,i),i===-1))return-1;for(i++;;){let t=i;for(;t<e.length&&/\s/.test(e[t]??``);)t++;if(e[t]!==`.`||e.slice(t,t+6)!==`.mount`)break;for(t+=6;t<e.length&&/\s/.test(e[t]??``);)t++;if(e[t]!==`(`)break;let n=It(e,t);if(n===-1)break;i=n+1}return i}function Pt(e,t){let n=e.slice(t,t+2);if(n===`//`){for(t+=2;t<e.length&&e[t]!==`
@@ -1216,7 +1216,7 @@ ${p}
1216
1216
  `||e[l]===`\r`);)l++;let u=e.slice(l),d=/build\s*:\s*\([^)]*\)\s*=>\s*\(\s*\{/g.exec(s);if(!d)return{migrated:null,reason:`build: () => ({...}) not found in defineModule`};let f=d.index+d[0].length-1,p=Jt(s,f);if(p===-1)return{migrated:null,reason:`unbalanced build() braces`};let m=s.slice(f+1,p),h=W(m,/register\s*\(([^)]*)\)\s*\{/),g=W(m,/contributors\s*\(\s*\)\s*\{/),_=W(m,/routes\s*\(\s*\)\s*\{/);if(!_)return{migrated:null,reason:`routes() method missing inside build()`};let v=Xt(c,{container:h!==null,appModule:!0,moduleRoutes:!0,contributorRegistrations:g!==null}),y=``;return h!==null&&(y+=` register(container: Container): void {${G(h,6,4)} }\n\n`),g!==null&&(y+=` contributors(): ContributorRegistrations {${G(g,6,4)} }\n\n`),y+=` routes(): ModuleRoutes {${G(_,6,4)} }`,{migrated:`${v}${`export class ${r} implements AppModule {
1217
1217
  ${y}
1218
1218
  }
1219
- `}${u}`}}function $t(e,t){return t===`class`?Qt(e):Zt(e)}function en(e,t){let n=e,r=!1;if(t===`define`){/\bAppModuleClass\b/.test(n)&&(n=n.replaceAll(/\bAppModuleClass\b/g,`AppModuleEntry`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)(?![(.])/g,`$1()`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}else{/\bAppModuleEntry\b/.test(n)&&(n=n.replaceAll(/\bAppModuleEntry\b/g,`AppModuleClass`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)\s*\(\s*\)/g,`$1`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}return r?{migrated:n}:{migrated:null,reason:`no changes needed`}}async function tn(e){let t=[];return await n(P(e),0),t;async function n(e,r){let i;try{i=await Re(e)}catch{return}for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=M(e,a),o;try{o=await Be(i)}catch{continue}o.isDirectory()?await n(i,r+1):(a.endsWith(`.module.ts`)||a===`index.ts`&&r===1)&&t.push(i)}}}async function nn(e,t){let n=0;return await r(e,t),n;async function r(e,t){let i;try{i=await Re(e)}catch{return}await Le(t,{recursive:!0});for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=M(e,a),o=M(t,a),s;try{s=await Be(i)}catch{continue}s.isDirectory()?await r(i,o):(await Ie(i,o),n++)}}}function rn(e){return M(e,`.kickjs`,`codemod-backups`,`${new Date().toISOString().replaceAll(/[:.]/g,`-`)}-modules`)}async function an(e,t){let{dryRun:n=!1,cwd:r=process.cwd(),target:i}=t,a=t.backup??!n,o=await tn(e),s=await I(M(e,`index.ts`),`utf-8`).then(()=>!0,()=>!1),c=null;a&&(o.length>0||s)&&(c=rn(r),await nn(e,c));let l=[];for(let e of o){let t=$t(await I(e,`utf-8`),i);if(t.migrated==null){l.push({path:e,status:`skipped`,reason:t.reason});continue}n||await L(e,t.migrated,`utf-8`),l.push({path:e,status:`migrated`})}let u=M(e,`index.ts`),d=null;try{d=await I(u,`utf-8`)}catch{return{target:i,files:l,indexStatus:`not-found`,indexPath:u,backupDir:c}}let f=en(d,i);return f.migrated==null?{target:i,files:l,indexStatus:`skipped`,indexPath:u,indexReason:f.reason,backupDir:c}:(n||await L(u,f.migrated,`utf-8`),{target:i,files:l,indexStatus:`migrated`,indexPath:u,backupDir:c})}async function on(e,t){let n=await tn(e),r=[],i=t===`define`?/export\s+class\s+\w+Module\s+implements\s+AppModule\s*\{/:/export\s+const\s+\w+Module\s*=\s*defineModule\s*\(/;for(let e of n){let t=await I(e,`utf-8`);i.test(t)&&r.push(e)}return r}const sn={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 cn(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=sn[a];if(!o){let e=[...Object.keys(sn),`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 ln(e){let{name:t,fields:n,modulesDir:r,repo:i=`inmemory`,tokenScope:a=`app`,style:o=`define`}=e,s=e.pluralize!==!1,c=B(t),l=R(t),u=s?V(c):c,d=s?Je(l):l,f=M(r,u),p=[],m=async(e,t)=>{let n=M(f,e);await y(n,t),p.push(n)};return await m(`${c}.module.ts`,pt({pascal:l,kebab:c,plural:u,repo:i,style:o})),await m(`${c}.constants.ts`,Tt({pascal:l,kebab:c})),await m(`${c}.controller.ts`,ht({pascal:l,kebab:c,plural:u,pluralPascal:d,swagger:e.swagger??!1})),await m(`${c}.service.ts`,wt({pascal:l,kebab:c})),await m(`dtos/create-${c}.dto.ts`,un(l,n)),await m(`dtos/update-${c}.dto.ts`,dn(l,n)),await m(`dtos/${c}-response.dto.ts`,fn(l,n)),await m(`${c}.repository.ts`,xt({pascal:l,kebab:c,repoType:i,dtoPrefix:`./dtos`,tokenScope:a})),await At(r,l,u,c,o),p}function un(e,t){return`import { z } from 'zod'
1219
+ `}${u}`}}function $t(e,t){return t===`class`?Qt(e):Zt(e)}function en(e,t){let n=e,r=!1;if(t===`define`){/\bAppModuleClass\b/.test(n)&&(n=n.replaceAll(/\bAppModuleClass\b/g,`AppModuleEntry`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)(?![(.])/g,`$1()`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}else{/\bAppModuleEntry\b/.test(n)&&(n=n.replaceAll(/\bAppModuleEntry\b/g,`AppModuleClass`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)\s*\(\s*\)/g,`$1`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}return r?{migrated:n}:{migrated:null,reason:`no changes needed`}}async function tn(e){let t=[];return await n(P(e),0),t;async function n(e,r){let i;try{i=await Re(e)}catch{return}for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=M(e,a),o;try{o=await Be(i)}catch{continue}o.isDirectory()?await n(i,r+1):(a.endsWith(`.module.ts`)||a===`index.ts`&&r===1)&&t.push(i)}}}async function nn(e,t){let n=0;return await r(e,t),n;async function r(e,t){let i;try{i=await Re(e)}catch{return}await Le(t,{recursive:!0});for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=M(e,a),o=M(t,a),s;try{s=await Be(i)}catch{continue}s.isDirectory()?await r(i,o):(await Ie(i,o),n++)}}}function rn(e){let t=new Date().toISOString().replaceAll(/[:.]/g,`-`);return M(e,`.kickjs`,`codemod-backups`,`${t}-modules`)}async function an(e,t){let{dryRun:n=!1,cwd:r=process.cwd(),target:i}=t,a=t.backup??!n,o=await tn(e),s=await I(M(e,`index.ts`),`utf-8`).then(()=>!0,()=>!1),c=null;a&&(o.length>0||s)&&(c=rn(r),await nn(e,c));let l=[];for(let e of o){let t=$t(await I(e,`utf-8`),i);if(t.migrated==null){l.push({path:e,status:`skipped`,reason:t.reason});continue}n||await L(e,t.migrated,`utf-8`),l.push({path:e,status:`migrated`})}let u=M(e,`index.ts`),d=null;try{d=await I(u,`utf-8`)}catch{return{target:i,files:l,indexStatus:`not-found`,indexPath:u,backupDir:c}}let f=en(d,i);return f.migrated==null?{target:i,files:l,indexStatus:`skipped`,indexPath:u,indexReason:f.reason,backupDir:c}:(n||await L(u,f.migrated,`utf-8`),{target:i,files:l,indexStatus:`migrated`,indexPath:u,backupDir:c})}async function on(e,t){let n=await tn(e),r=[],i=t===`define`?/export\s+class\s+\w+Module\s+implements\s+AppModule\s*\{/:/export\s+const\s+\w+Module\s*=\s*defineModule\s*\(/;for(let e of n){let t=await I(e,`utf-8`);i.test(t)&&r.push(e)}return r}const sn={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 cn(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=sn[a];if(!o){let e=[...Object.keys(sn),`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 ln(e){let{name:t,fields:n,modulesDir:r,repo:i=`inmemory`,tokenScope:a=`app`,style:o=`define`}=e,s=e.pluralize!==!1,c=B(t),l=R(t),u=s?V(c):c,d=s?Je(l):l,f=M(r,u),p=[],m=async(e,t)=>{let n=M(f,e);await y(n,t),p.push(n)};return await m(`${c}.module.ts`,pt({pascal:l,kebab:c,plural:u,repo:i,style:o})),await m(`${c}.constants.ts`,Tt({pascal:l,kebab:c})),await m(`${c}.controller.ts`,ht({pascal:l,kebab:c,plural:u,pluralPascal:d,swagger:e.swagger??!1})),await m(`${c}.service.ts`,wt({pascal:l,kebab:c})),await m(`dtos/create-${c}.dto.ts`,un(l,n)),await m(`dtos/update-${c}.dto.ts`,dn(l,n)),await m(`dtos/${c}-response.dto.ts`,fn(l,n)),await m(`${c}.repository.ts`,xt({pascal:l,kebab:c,repoType:i,dtoPrefix:`./dtos`,tokenScope:a})),await At(r,l,u,c,o),p}function un(e,t){return`import { z } from 'zod'
1220
1220
 
1221
1221
  export const create${e}Schema = z.object({
1222
1222
  ${t.map(e=>{let t=e.zodType;return` ${e.name}: ${t}${e.optional?`.optional()`:``},`}).join(`
@@ -1280,7 +1280,7 @@ describe('${o}', () => {
1280
1280
  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=K(n);v(r);let i=await l(process.cwd()),a=p(i),o=a.dir??`src/modules`;q(await Wt({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
1281
1281
  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=K(n);v(r);let i=await l(process.cwd()),a=p(i),o=a.dir??`src/modules`;q(await Gt({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0}),r),await _n(r)}),n.command(`dto <name>`).description(`Generate a DTO schema for the project’s validation library
1282
1282
  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=K(n);v(r);let i=await l(process.cwd()),a=p(i),o=a.dir??`src/modules`;q(await Kt({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pattern:i?.pattern,pluralize:a.pluralize??!0,schemaLib:h(E())}),r)}),n.command(`test <name>`).description(`Generate a Vitest test scaffold
1283
- 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=K(n);v(r);let i=p(await l(process.cwd())),a=i.dir??`src/modules`;q(await pn({name:e,outDir:t.out,moduleName:t.module,modulesDir:a,pluralize:i.pluralize??!0}),r)}),n.command(`scaffold <name> [fields...]`).description(`Generate a full CRUD module from field definitions
1283
+ 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=K(n);v(r);let i=await l(process.cwd()),a=p(i),o=a.dir??`src/modules`;q(await pn({name:e,outDir:t.out,moduleName:t.module,modulesDir:o,pluralize:a.pluralize??!0}),r)}),n.command(`scaffold <name> [fields...]`).description(`Generate a full CRUD module from field definitions
1284
1284
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
1285
1285
  Types: string, text, number, int, float, boolean, date, email, url, uuid, json, enum:a,b,c
1286
1286
  Optional: append :optional (shell-safe): description:text:optional
@@ -1290,19 +1290,19 @@ describe('${o}', () => {
1290
1290
  Example: kick g scaffold Post title:string body:text:optional published:boolean:optional
1291
1291
  Optional: append :optional (shell-safe, no quoting needed)
1292
1292
  `),process.exit(1));let a=await l(process.cwd()),o=p(a),s=n.modulesDir??o.dir??`src/modules`,c=cn(t),f=u(a,process.cwd()),m=d(E()),h=await ln({name:e,fields:c,modulesDir:P(s),noEntity:n.entity===!1,noTests:n.tests===!1,pluralize:n.pluralize===!1?!1:o.pluralize??!0,tokenScope:f,swagger:m,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)`:``}`);q(h,i),await _n(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=K(t);v(n),q(await qt({outDir:P(`.`),modulesDir:e.modulesDir,defaultRepo:e.repo,force:e.force}),n)}),n.command(`agents`).alias(`agent-docs`).alias(`ai-docs`).description(`Regenerate .agents/* + root CLAUDE.md (sync after framework upgrades)`).option(`--only <which>`,`Limit scope: agents | claude | skills | gemini | copilot | 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 | fullstack`).option(`-f, --force`,`Overwrite existing files without prompting`).action(async(e,t)=>{let n=K(t);v(n);let r=e.only??`all`;if(!gn.includes(r)){console.error(` Invalid --only value: ${r}. Expected: ${gn.join(` | `)}`),process.exitCode=1;return}q(await re({outDir:P(`.`),only:r,name:e.name,pm:e.pm,template:e.template,force:e.force}),n)});for(let e of t?.generators??[])wn(n,e,t?.projectRoot)}function wn(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=K(o);v(s);let c=await it({generatorName:i.name,itemName:e??``,args:r??[],flags:a,cwd:process.cwd(),projectRoot:n},[t]);c&&q(c.files,s)})}const Tn=`/* AUTO-GENERATED by kick typegen — do not edit. Plugin: `;async function En(e){let t=A.resolve(e.cwd,`.kickjs/types`);e.check||await Le(t,{recursive:!0});let n=new Map,r=e.scan??fe,i=A.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(F(e).href)},async writeFile(t,n){let r=A.resolve(e.cwd,t);await Le(A.dirname(r),{recursive:!0}),await L(r,n,`utf8`)},getScanResult:e=>{let t=Dn(e),o=n.get(t);if(!o){let s={cacheDir:i,...e};o=a?se(s,a):r(s),n.set(t,o)}return o},log:console,watch:e.watch,check:e.check},s=[],c=[];for(let n of e.plugins){let r=n.outExtension??`.d.ts`,i=A.join(t,`${n.id.replace(/\//g,`__`)}${r}`),a;try{a=await n.generate(o)}catch(t){let r=t instanceof Error?t.message:String(t);if(e.check)throw Error(`kick typegen --check: ${n.id} failed to generate (${r})`,{cause:t});o.log.error(` ${n.id}: typegen failed (${r}) — 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 l=`${Tn}${n.id} */\n\n`+a+`
1293
- `,u=``;if(D(i)&&(u=await I(i,`utf8`)),u===l){s.push({id:n.id,status:`unchanged`,outFile:i});continue}if(e.check){c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i});continue}await L(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i})}if(c.length>0)throw new hn(c);return s}function Dn(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 On(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))}}var kn=e({applyDisableFilter:()=>On,runAllPluginTypegens:()=>An});async function An(e){let{enabled:t,skipped:n,unknown:r}=On(g([...Fa,...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 En({cwd:e.cwd,config:e.config??{},plugins:t,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&mn())for(let e of n)console.log(` ${e.id}: ${e.status}`);return n}catch(t){if(t instanceof hn||e.check)throw t;if(!e.silent){let e=t instanceof Error?t.message:String(t);console.warn(` kick typegen plugins: skipped (${e})`)}return[]}}function jn(e){let t=new Map;return{report(n,r){let i=r instanceof Error?r.message:String(r);t.get(n)!==i&&(t.set(n,i),e(` kick typegen: ${n} pass failed (${i}) — types in .kickjs/types may be stale`))},clear(e){t.delete(e)}}}function Mn(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-B6vIx4Qd.mjs`).then(e=>e.n)).runTypegen(e),runAllPluginTypegens:async e=>(await Promise.resolve().then(()=>kn)).runAllPluginTypegens(e),writeTypegenArtifacts:async(e,t,n)=>(await import(`./typegen-B6vIx4Qd.mjs`).then(e=>e.n)).writeTypegenArtifacts(e,t,n),buildAssets:async(e,t)=>(await import(`./build-clh7HpZV.mjs`).then(e=>e.n)).buildAssets(e,t)},a=n?.typegen?.schemaValidator??`zod`,o=n?.typegen?.envFile,s=A.resolve(t,n?.typegen?.outDir??`.kickjs/types`),c=n?.assetMap?Object.values(n.assetMap).map(e=>e?.src).filter(e=>typeof e==`string`&&e.length>0).map(e=>A.resolve(t,e)):[],l=!!n?.assetMap&&Object.keys(n.assetMap).length>0,u=e=>e.replaceAll(`\\`,`/`),d=c.map(u),f=e=>{let t=u(e);return d.some(e=>t===e||t.startsWith(`${e}/`))},p=jn(e.emitWarning),m=null,h=!1,g=new Set,_=new Set,v=!1,y=!1;function b(r,c){i.runTypegen({cwd:t,silent:!0,allowDuplicates:!0,schemaValidator:a,envFile:o,srcDir:n?.typegen?.srcDir,outDir:n?.typegen?.outDir,assetMap:n?.assetMap,changedFiles:r,runPlugins:!1}).then(()=>p.clear(`scan`)).catch(e=>p.report(`scan`,e)),i.runAllPluginTypegens({cwd:t,config:n,silent:!0,changedFiles:r,watch:!0}).then(e=>i.writeTypegenArtifacts(s,e,!0)).then(()=>p.clear(`plugins`)).catch(e=>p.report(`plugins`,e)).finally(()=>e.onPassComplete?.()),c&&n&&i.buildAssets(n,{cwd:t,silent:!0}).catch(()=>{})}function x(){let e=v?void 0:{changed:[...g],removed:[..._]},t=y;g.clear(),_.clear(),v=!1,y=!1,b(e,t)}return{assetSrcRoots:c,handleWatchEvent(e,t){if(!h&&!u(t).includes(`/.kickjs/`)){if(e===`unlinkDir`)v=!0,l&&(y=!0);else{if(t.endsWith(`.d.ts`))return;let n=/\.(ts|tsx|mts|cts)$/.test(t),r=f(t);if(!n&&!r)return;r&&l&&(y=!0),n&&(e===`unlink`?(_.add(t),g.delete(t)):(g.add(t),_.delete(t)))}m&&clearTimeout(m),m=setTimeout(x,r)}},runOnce(){h||b(void 0,l)},dispose(){h=!0,m&&clearTimeout(m),m=null}}}function Nn(e){let t=M(e,`node_modules`,`.bin`),n=process.platform===`win32`;for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=n?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=M(t,i);if(D(r))return{cmd:r,args:[`--noEmit`],shell:n,kind:e}}}return null}function Pn(e){let t=e.spawnFn??Pe,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 Fn(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
1293
+ `,u=``;if(D(i)&&(u=await I(i,`utf8`)),u===l){s.push({id:n.id,status:`unchanged`,outFile:i});continue}if(e.check){c.push({id:n.id,outFile:i}),s.push({id:n.id,status:`drifted`,outFile:i});continue}await L(i,l,`utf8`),s.push({id:n.id,status:`written`,outFile:i})}if(c.length>0)throw new hn(c);return s}function Dn(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 On(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))}}var kn=e({applyDisableFilter:()=>On,runAllPluginTypegens:()=>An});async function An(e){let t=[...Fa,...e.config?.plugins??[]],{enabled:n,skipped:r,unknown:i}=On(g(t,e.config?.commands??[]).typegens,e.config?.typegen?.disable??[]);if(!e.silent&&r.length>0)for(let e of r)console.log(` ${e.id}: disabled (typegen.disable)`);if(!e.silent&&i.length>0&&console.warn(` kick typegen: disable list references unknown id(s): ${i.map(e=>`'${e}'`).join(`, `)}. Run \`kick typegen --list\` to see registered ids.`),n.length===0)return[];try{let t=await En({cwd:e.cwd,config:e.config??{},plugins:n,watch:e.watch,check:e.check,changedFiles:e.changedFiles});if(!e.silent&&mn())for(let e of t)console.log(` ${e.id}: ${e.status}`);return t}catch(t){if(t instanceof hn||e.check)throw t;if(!e.silent){let e=t instanceof Error?t.message:String(t);console.warn(` kick typegen plugins: skipped (${e})`)}return[]}}function jn(e){let t=new Map;return{report(n,r){let i=r instanceof Error?r.message:String(r);t.get(n)!==i&&(t.set(n,i),e(` kick typegen: ${n} pass failed (${i}) — types in .kickjs/types may be stale`))},clear(e){t.delete(e)}}}function Mn(e){let{cwd:t,config:n}=e,r=e.debounceMs??100,i=e.pipeline??{runTypegen:async e=>(await import(`./typegen-BZJk-Lmq.mjs`).then(e=>e.n)).runTypegen(e),runAllPluginTypegens:async e=>(await Promise.resolve().then(()=>kn)).runAllPluginTypegens(e),writeTypegenArtifacts:async(e,t,n)=>(await import(`./typegen-BZJk-Lmq.mjs`).then(e=>e.n)).writeTypegenArtifacts(e,t,n),buildAssets:async(e,t)=>(await import(`./build-C1ya_zWp.mjs`).then(e=>e.n)).buildAssets(e,t)},a=n?.typegen?.schemaValidator??`zod`,o=n?.typegen?.envFile,s=A.resolve(t,n?.typegen?.outDir??`.kickjs/types`),c=n?.assetMap?Object.values(n.assetMap).map(e=>e?.src).filter(e=>typeof e==`string`&&e.length>0).map(e=>A.resolve(t,e)):[],l=!!n?.assetMap&&Object.keys(n.assetMap).length>0,u=e=>e.replaceAll(`\\`,`/`),d=c.map(u),f=e=>{let t=u(e);return d.some(e=>t===e||t.startsWith(`${e}/`))},p=jn(e.emitWarning),m=null,h=!1,g=new Set,_=new Set,v=!1,y=!1;function b(r,c){i.runTypegen({cwd:t,silent:!0,allowDuplicates:!0,schemaValidator:a,envFile:o,srcDir:n?.typegen?.srcDir,outDir:n?.typegen?.outDir,assetMap:n?.assetMap,changedFiles:r,runPlugins:!1}).then(()=>p.clear(`scan`)).catch(e=>p.report(`scan`,e)),i.runAllPluginTypegens({cwd:t,config:n,silent:!0,changedFiles:r,watch:!0}).then(e=>i.writeTypegenArtifacts(s,e,!0)).then(()=>p.clear(`plugins`)).catch(e=>p.report(`plugins`,e)).finally(()=>e.onPassComplete?.()),c&&n&&i.buildAssets(n,{cwd:t,silent:!0}).catch(()=>{})}function x(){let e=v?void 0:{changed:[...g],removed:[..._]},t=y;g.clear(),_.clear(),v=!1,y=!1,b(e,t)}return{assetSrcRoots:c,handleWatchEvent(e,t){if(!h&&!u(t).includes(`/.kickjs/`)){if(e===`unlinkDir`)v=!0,l&&(y=!0);else{if(t.endsWith(`.d.ts`))return;let n=/\.(ts|tsx|mts|cts)$/.test(t),r=f(t);if(!n&&!r)return;r&&l&&(y=!0),n&&(e===`unlink`?(_.add(t),g.delete(t)):(g.add(t),_.delete(t)))}m&&clearTimeout(m),m=setTimeout(x,r)}},runOnce(){h||b(void 0,l)},dispose(){h=!0,m&&clearTimeout(m),m=null}}}function Nn(e){let t=M(e,`node_modules`,`.bin`),n=process.platform===`win32`;for(let e of[`vue-tsc`,`tsgo`,`tsc`]){let r=n?[`${e}.CMD`,`${e}.cmd`,`${e}.exe`]:[e];for(let i of r){let r=M(t,i);if(D(r))return{cmd:r,args:[`--noEmit`],shell:n,kind:e}}}return null}function Pn(e){let t=e.spawnFn??Pe,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 Fn(e,t=12){let n=e.trim().split(/\r?\n/);return n.length<=t?n.join(`
1294
1294
  `):`${n.slice(0,t).join(`
1295
- `)}\n… ${n.length-t} more line(s)`}function In(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function Ln(e,t=`127.0.0.1`){let n=await import(`node:inspector`);n.open(e,t,!1);let r=n.url();if(!r)throw Error(`inspector.open() reported no URL`);return r}async function Rn(e,t,n={}){t&&(process.env.PORT=t);let r=In(n.polling),i=process.cwd(),a=await l(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await xe({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=P(i,a?.typegen?.outDir??`.kickjs/types`);try{await me(c,await An({cwd:i,config:a}),!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:u}=await import(`node:module`),{createServer:d}=await import(F(u(P(`package.json`)).resolve(`vite`)).href);globalThis.__kickjs_typegen_owner=`kick-dev`;let f=await d({configFile:P(`vite.config.ts`),server:{port:t?parseInt(t,10):void 0,...r?{watch:{usePolling:!0,interval:100}}:{}}}),p=n.typecheck??a?.dev?.typecheck??!1,m=null,h=!0;if(p){let e=Nn(i);e?m=Pn({cwd:i,bin:e,onResult:e=>{f.hot.send({type:`custom`,event:`kickjs:typecheck`,data:{ok:e.ok,output:e.output,durationMs:e.durationMs}}),e.ok?h||(h=!0,console.log(` kick typecheck: clean again (${e.kind}, ${e.durationMs}ms)`)):(h=!1,console.warn(`\n kick typecheck (${e.kind}, ${e.durationMs}ms):`),console.warn(Fn(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 g=Mn({cwd:i,config:a,emitWarning:e=>{console.warn(e),f.hot.send({type:`custom`,event:`kickjs:typegen-error`,data:{message:e,timestamp:Date.now()}})},onPassComplete:()=>m?.schedule()});f.watcher.on(`add`,e=>g.handleWatchEvent(`add`,e)),f.watcher.on(`unlink`,e=>g.handleWatchEvent(`unlink`,e)),f.watcher.on(`change`,e=>g.handleWatchEvent(`change`,e)),f.watcher.on(`unlinkDir`,e=>g.handleWatchEvent(`unlinkDir`,e)),g.assetSrcRoots.length>0&&f.watcher.add([...g.assetSrcRoots]),await f.listen(),f.printUrls(),console.log(`
1295
+ `)}\n… ${n.length-t} more line(s)`}function In(e){if(typeof e==`boolean`)return e;let t=process.env.KICKJS_WATCH_POLLING;return t===`1`||t===`true`}async function Ln(e,t=`127.0.0.1`){let n=await import(`node:inspector`);n.open(e,t,!1);let r=n.url();if(!r)throw Error(`inspector.open() reported no URL`);return r}async function Rn(e,t,n={}){t&&(process.env.PORT=t);let r=In(n.polling),i=process.cwd(),a=await l(i),o=a?.typegen?.schemaValidator??`zod`,s=a?.typegen?.envFile;try{await xe({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=P(i,a?.typegen?.outDir??`.kickjs/types`);try{let e=await An({cwd:i,config:a});await me(c,e,!1)}catch(e){console.warn(` kick typegen: plugin pass skipped (${e?.message??e})`)}let{createRequire:u}=await import(`node:module`),d=u(P(`package.json`)).resolve(`vite`),{createServer:f}=await import(F(d).href);globalThis.__kickjs_typegen_owner=`kick-dev`;let p=await f({configFile:P(`vite.config.ts`),server:{port:t?parseInt(t,10):void 0,...r?{watch:{usePolling:!0,interval:100}}:{}}}),m=n.typecheck??a?.dev?.typecheck??!1,h=null,g=!0;if(m){let e=Nn(i);e?h=Pn({cwd:i,bin:e,onResult:e=>{p.hot.send({type:`custom`,event:`kickjs:typecheck`,data:{ok:e.ok,output:e.output,durationMs:e.durationMs}}),e.ok?g||(g=!0,console.log(` kick typecheck: clean again (${e.kind}, ${e.durationMs}ms)`)):(g=!1,console.warn(`\n kick typecheck (${e.kind}, ${e.durationMs}ms):`),console.warn(Fn(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 _=Mn({cwd:i,config:a,emitWarning:e=>{console.warn(e),p.hot.send({type:`custom`,event:`kickjs:typegen-error`,data:{message:e,timestamp:Date.now()}})},onPassComplete:()=>h?.schedule()});p.watcher.on(`add`,e=>_.handleWatchEvent(`add`,e)),p.watcher.on(`unlink`,e=>_.handleWatchEvent(`unlink`,e)),p.watcher.on(`change`,e=>_.handleWatchEvent(`change`,e)),p.watcher.on(`unlinkDir`,e=>_.handleWatchEvent(`unlinkDir`,e)),_.assetSrcRoots.length>0&&p.watcher.add([..._.assetSrcRoots]),await p.listen(),p.printUrls(),console.log(`
1296
1296
  KickJS dev server running (Vite + @forinda/kickjs-vite)
1297
- `),m?.schedule();let _=!1,v=async()=>{if(!_){_=!0,g.dispose(),m?.dispose();try{await globalThis.__kickjs_app_shutdown?.()}catch(e){console.error(` app shutdown hook failed: ${e?.message??e}`)}await f.close(),process.exit(0)}};process.on(`SIGINT`,v),process.on(`SIGTERM`,v),process.on(`SIGBREAK`,v)}async function zn(e){let t=await l(e);try{await xe({cwd:e,allowDuplicates:!0,schemaValidator:t?.typegen?.schemaValidator??`zod`,envFile:t?.typegen?.envFile,srcDir:t?.typegen?.srcDir,outDir:t?.typegen?.outDir,assetMap:t?.assetMap,runPlugins:!1}),await me(P(e,t?.typegen?.outDir??`.kickjs/types`),await An({cwd:e,config:t}),!1)}catch(e){console.warn(` kick typegen: skipped before typecheck (${e?.message??e}).\n Generated types may be stale — errors inside .kickjs/types are likely from that.`)}}function Bn(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 Rn(e.entry,e.port,{polling:e.polling,typecheck:e.typecheck})}catch(e){e.code===`ERR_MODULE_NOT_FOUND`&&e.message?.includes(`vite`)?console.error(`
1297
+ `),h?.schedule();let v=!1,y=async()=>{if(!v){v=!0,_.dispose(),h?.dispose();try{await globalThis.__kickjs_app_shutdown?.()}catch(e){console.error(` app shutdown hook failed: ${e?.message??e}`)}await p.close(),process.exit(0)}};process.on(`SIGINT`,y),process.on(`SIGTERM`,y),process.on(`SIGBREAK`,y)}async function zn(e){let t=await l(e);try{await xe({cwd:e,allowDuplicates:!0,schemaValidator:t?.typegen?.schemaValidator??`zod`,envFile:t?.typegen?.envFile,srcDir:t?.typegen?.srcDir,outDir:t?.typegen?.outDir,assetMap:t?.assetMap,runPlugins:!1});let n=P(e,t?.typegen?.outDir??`.kickjs/types`),r=await An({cwd:e,config:t});await me(n,r,!1)}catch(e){console.warn(` kick typegen: skipped before typecheck (${e?.message??e}).\n Generated types may be stale — errors inside .kickjs/types are likely from that.`)}}function Bn(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 Rn(e.entry,e.port,{polling:e.polling,typecheck:e.typecheck})}catch(e){e.code===`ERR_MODULE_NOT_FOUND`&&e.message?.includes(`vite`)?console.error(`
1298
1298
  Error: vite is not installed.
1299
1299
  Run: pnpm add -D vite unplugin-swc
1300
1300
  `):console.error(`
1301
1301
  Dev server failed:`,e.message??e),process.exit(1)}}),e.command(`build`).description(`Build for production via Vite`).action(async()=>{console.log(`
1302
1302
  Building for production...
1303
- `);let{createRequire:e}=await import(`node:module`),{build:t}=await import(F(e(P(`package.json`)).resolve(`vite`)).href);await t({configFile:P(`vite.config.ts`)});let n=await l(process.cwd()),r=n?.copyDirs??[];if(r.length>0){console.log(`
1304
- Copying directories to dist...`);for(let e of r){let t=typeof e==`string`?e:e.src,n=typeof e==`string`?M(`dist`,e):e.dest??M(`dist`,t),r=P(t),i=P(n);if(!D(r)){console.log(` ⚠ Skipped ${t} (not found)`);continue}Ee(i,{recursive:!0}),Te(r,i,{recursive:!0}),console.log(` ✓ ${t} → ${n}`)}}if(n?.assetMap&&Object.keys(n.assetMap).length>0){console.log(`
1305
- Building asset map...`);try{await Ce(n,{cwd:process.cwd()})}catch(e){console.error(` ✗ asset build failed: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}console.log(`
1303
+ `);let{createRequire:e}=await import(`node:module`),t=e(P(`package.json`)).resolve(`vite`),{build:n}=await import(F(t).href);await n({configFile:P(`vite.config.ts`)});let r=await l(process.cwd()),i=r?.copyDirs??[];if(i.length>0){console.log(`
1304
+ Copying directories to dist...`);for(let e of i){let t=typeof e==`string`?e:e.src,n=typeof e==`string`?M(`dist`,e):e.dest??M(`dist`,t),r=P(t),i=P(n);if(!D(r)){console.log(` ⚠ Skipped ${t} (not found)`);continue}Ee(i,{recursive:!0}),Te(r,i,{recursive:!0}),console.log(` ✓ ${t} → ${n}`)}}if(r?.assetMap&&Object.keys(r.assetMap).length>0){console.log(`
1305
+ Building asset map...`);try{await Ce(r,{cwd:process.cwd()})}catch(e){console.error(` ✗ asset build failed: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}console.log(`
1306
1306
  Build complete.
1307
1307
  `)}),e.command(`build:assets`).description(`Rebuild the .kickjs-assets.json manifest under the configured outDir (no JS rebuild)`).action(async()=>{let e=await l(process.cwd());if(!e?.assetMap||Object.keys(e.assetMap).length===0){console.log(` No assetMap entries — nothing to build.`);return}console.log(`
1308
1308
  Building asset map...`);try{await Ce(e,{cwd:process.cwd()}),console.log(`
@@ -1313,7 +1313,7 @@ describe('${o}', () => {
1313
1313
  pnpm add -D @typescript/native-preview (tsgo, faster)
1314
1314
  `),process.exit(1);return}let r=Fe(n.cmd,n.args,{stdio:`inherit`,shell:n.shell,cwd:t});process.exit(r.status??1)}),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`).option(`--inspect-host <host>`,`Inspector bind address (use 0.0.0.0 to reach it from outside a container)`,`127.0.0.1`).action(async e=>{let t=Number(e.inspectPort??`9229`),n=e.inspectHost??`127.0.0.1`;[`127.0.0.1`,`localhost`,`::1`].includes(n)||console.warn(` WARNING: the debugger is bound to ${n}, not loopback. Anyone who can\n reach port ${t} can run code in this process. Use it on a trusted\n network only, and prefer publishing the port from your container instead.`);let r;try{r=await Ln(t,n)}catch(e){console.error(`\n Could not open the inspector on ${t}: ${e.message??e}\n Another process may already hold it — try --inspect-port <port>.`),process.exit(1);return}console.log(` Debugger: ${r}`);try{await Rn(e.entry,e.port)}catch(e){console.error(`
1315
1315
  Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function Vn(){try{let e=j(Me(import.meta.url));return JSON.parse(O(M(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const Hn=new Set(Object.values(a).filter(e=>e.deprecated).map(e=>e.pkg));function Un(e){let t=M(e,`package.json`);if(!D(t))return[];let n;try{n=JSON.parse(O(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=M(e,`node_modules`,...t.split(`/`),`package.json`);if(D(i))try{n=JSON.parse(O(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:Hn.has(t)}})}function Wn(e){let t=e;for(;;){if(D(M(t,`package.json`)))return t;let e=j(t);if(e===t)return null;t=e}}function Gn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${Vn()}`,``,` System:`,` OS: ${Ue()} ${We()} (${He()})`,` Node: ${process.version}`],t=Wn(process.cwd()),n=t?Un(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(`
1316
- `))})}const{bold:J,dim:Y,green:Kn,red:qn,yellow:Jn,blue:Yn}=C;function Xn(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 Zn(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function X(e,t){try{return await Zn(`${e}${t}`)}catch{return null}}async function Qn(e){let[t,n,r,i,a]=await Promise.all([X(e,`/health`),X(e,`/metrics`),X(e,`/routes`),X(e,`/container`),X(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function $n(e,t){let{health:n,metrics:r,routes:i,container:a,ws:o}=t,s=Y(`─`.repeat(60));if(console.log(),console.log(J(` KickJS Inspector`)+Y(` → ${e}`)),console.log(s),n){let e=n.status===`healthy`?Kn(`● healthy`):qn(`● `+n.status);console.log(` ${J(`Health:`)} ${e}`)}else console.log(` ${J(`Health:`)} ${qn(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?qn:r.errorRate>0?Jn:Kn;console.log(` ${J(`Uptime:`)} ${Xn(r.uptimeSeconds)}`),console.log(` ${J(`Requests:`)} ${r.requests}`),console.log(` ${J(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${Y(`(`)}${t(e+`%`)}${Y(`)`)}`)}if(a&&console.log(` ${J(`DI:`)} ${a.count} bindings`),o&&o.enabled&&console.log(` ${J(`WS:`)} ${o.connections??0} connections, ${o.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(J(` Routes`)),console.log(s),console.log(` ${Y(`METHOD`)} ${Y(`PATH`.padEnd(36))} ${Y(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${ee(e.method)} ${t} ${Yn(e.controller)}.${Y(e.handler)}`)}}console.log(s),console.log()}function er(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 Qn(r);t.json?console.log(JSON.stringify(e,null,2)):$n(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(qn(` ✖ Could not connect to ${n}`)),console.error(Y(` ${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 tr(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e.toLowerCase()))}function Z(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}const nr=[{match(e,t){let n=tr(e,[`config`,`get`])&&Z(e,[`undefined`,`null`]),r=e.includes(`@Value`)&&Z(e,[`undefined`,`is not defined`]);return!n&&!r?null:Z(e,[`vitest`,`createTestApp`,`__tests__`,`.test.`,`.spec.`])?{confidence:85,diagnosis:{id:`env-schema-not-registered-in-test`,title:`ConfigService.get() returns undefined inside a test`,explanation:`The env schema is registered by a module-load side effect in
1316
+ `))})}const{bold:J,dim:Y,green:Kn,red:qn,yellow:Jn,blue:Yn}=C;function Xn(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 Zn(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function Qn(e,t){try{return await Zn(`${e}${t}`)}catch{return null}}async function $n(e){let[t,n,r,i,a]=await Promise.all([Qn(e,`/health`),Qn(e,`/metrics`),Qn(e,`/routes`),Qn(e,`/container`),Qn(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function er(e,t){let{health:n,metrics:r,routes:i,container:a,ws:o}=t,s=Y(`─`.repeat(60));if(console.log(),console.log(J(` KickJS Inspector`)+Y(` → ${e}`)),console.log(s),n){let e=n.status===`healthy`?Kn(`● healthy`):qn(`● `+n.status);console.log(` ${J(`Health:`)} ${e}`)}else console.log(` ${J(`Health:`)} ${qn(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?qn:r.errorRate>0?Jn:Kn;console.log(` ${J(`Uptime:`)} ${Xn(r.uptimeSeconds)}`),console.log(` ${J(`Requests:`)} ${r.requests}`),console.log(` ${J(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${Y(`(`)}${t(e+`%`)}${Y(`)`)}`)}if(a&&console.log(` ${J(`DI:`)} ${a.count} bindings`),o&&o.enabled&&console.log(` ${J(`WS:`)} ${o.connections??0} connections, ${o.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(J(` Routes`)),console.log(s),console.log(` ${Y(`METHOD`)} ${Y(`PATH`.padEnd(36))} ${Y(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${ee(e.method)} ${t} ${Yn(e.controller)}.${Y(e.handler)}`)}}console.log(s),console.log()}function tr(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 $n(r);t.json?console.log(JSON.stringify(e,null,2)):er(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(qn(` ✖ Could not connect to ${n}`)),console.error(Y(` ${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 X(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e.toLowerCase()))}function Z(e,t){let n=e.toLowerCase();return t.some(e=>n.includes(e.toLowerCase()))}const nr=[{match(e,t){let n=X(e,[`config`,`get`])&&Z(e,[`undefined`,`null`]),r=e.includes(`@Value`)&&Z(e,[`undefined`,`is not defined`]);return!n&&!r?null:Z(e,[`vitest`,`createTestApp`,`__tests__`,`.test.`,`.spec.`])?{confidence:85,diagnosis:{id:`env-schema-not-registered-in-test`,title:`ConfigService.get() returns undefined inside a test`,explanation:`The env schema is registered by a module-load side effect in
1317
1317
  src/config/index.ts, and src/index.ts imports it before bootstrap().
1318
1318
  Tests never load src/index.ts — \`createTestApp\` builds the app
1319
1319
  directly — so that import does not run and ConfigService falls back to
@@ -1347,7 +1347,7 @@ describe('UserController', () => {
1347
1347
  beforeEach(() => Container.reset())
1348
1348
 
1349
1349
  it('does the thing', async () => { /* ... */ })
1350
- })`,docs:`https://kickjs.app/guide/testing.html`}}:null}},{match(e,t){return e.includes(`@Module`)||tr(e,[`Module`,`is not a function`])||tr(e,[`Module`,`no exported member`])?{confidence:80,diagnosis:{id:`module-decorator-not-found`,title:`KickJS does not have a @Module decorator (different pattern from NestJS)`,explanation:`NestJS uses @Module({ controllers, providers }). KickJS uses an interface
1350
+ })`,docs:`https://kickjs.app/guide/testing.html`}}:null}},{match(e,t){return e.includes(`@Module`)||X(e,[`Module`,`is not a function`])||X(e,[`Module`,`no exported member`])?{confidence:80,diagnosis:{id:`module-decorator-not-found`,title:`KickJS does not have a @Module decorator (different pattern from NestJS)`,explanation:`NestJS uses @Module({ controllers, providers }). KickJS uses an interface
1351
1351
  pattern instead: a class implements AppModule and exposes routes() that
1352
1352
  returns the controller wiring. This was a deliberate choice — modules
1353
1353
  become explicit values rather than metadata, which makes them easier to
@@ -1433,7 +1433,103 @@ beforeAll(() => {
1433
1433
  vi.stubEnv('JWT_SECRET', 'x'.repeat(32))
1434
1434
  resetEnvCache()
1435
1435
  loadEnv(envSchema)
1436
- })`,docs:`https://kickjs.app/guide/testing.html#environment-isolation`}}}}];function rr(e,t){let n=null;for(let r of nr){let i=null;try{i=r.match(e,t)}catch{continue}!i||i.confidence<40||(!n||i.confidence>n.confidence)&&(n=i)}return n}async function ir(e){let t=e.provider??`openai`,n=process.env.OPENAI_API_KEY;if(t===`openai`&&!n)return{kind:`unavailable`,reason:`OPENAI_API_KEY environment variable is not set`,suggestion:`Set OPENAI_API_KEY in your shell, e.g.
1436
+ })`,docs:`https://kickjs.app/guide/testing.html#environment-isolation`}}}},{match(e,t){let n=X(e,[`cannot inject`,`request-scoped`,`singleton`]),r=X(e,[`request-scoped`,`singleton`]);return!n&&!r?null:{confidence:n?100:70,diagnosis:{id:`di-request-scope-into-singleton`,title:`A SINGLETON cannot hold a REQUEST-scoped dependency`,explanation:`Controllers are SINGLETON by default: one instance for the process, built
1437
+ the first time the container resolves it. A REQUEST-scoped binding is the
1438
+ opposite — one instance per request, discarded when the response ends.
1439
+
1440
+ Injecting the second into the first would capture whichever request
1441
+ happened to build the singleton and hand that same instance to every
1442
+ later request, so the container refuses at resolve time instead.
1443
+
1444
+ This surfaces on the first request that reaches the controller, not at
1445
+ boot, because the container builds lazily. The route mounts fine and then
1446
+ answers 500.`,fix:`The error says "use TRANSIENT or REQUEST scope for the parent", and that
1447
+ is the fix when the parent is a @Service / @Repository / @Component —
1448
+ each takes \`{ scope }\`.
1449
+
1450
+ @Controller() does NOT. It takes no options and always registers as a
1451
+ SINGLETON, so for a controller the advice in the message is not
1452
+ available. Switch that one dependency to @Autowired instead: property
1453
+ injection re-resolves per access, so each request reads its own instance
1454
+ and the singleton never captures one.
1455
+
1456
+ If the dependency did not need request scope in the first place, the
1457
+ other direction also works — make it SINGLETON and pass the per-request
1458
+ values in as method arguments.`,docs:`https://kickjs.app/guide/dependency-injection.html#scopes`}}}},{match(e,t){let n=e.toLowerCase().includes(`circular dependency detected`),r=X(e,[`circular`,`dependency`]);return!n&&!r?null:{confidence:n?100:65,diagnosis:{id:`di-circular-dependency`,title:`Two services depend on each other, directly or through a chain`,explanation:`The container resolves constructor dependencies depth-first. When a token
1459
+ is requested while it is already being resolved further up the stack, the
1460
+ graph has a cycle and there is no order that satisfies both ends.
1461
+
1462
+ The error prints the whole chain, arrow-separated — read it as "A needed
1463
+ B, which needed C, which needed A again". The repeated name at both ends
1464
+ is where the cycle closes, and it is usually the pair in the middle that
1465
+ is worth splitting, not the class you were resolving.
1466
+
1467
+ Constructor injection is what forces the ordering. Property injection
1468
+ (@Autowired) resolves after construction, so it tolerates a cycle the
1469
+ constructor form cannot.`,fix:`Preferred: pull the shared behaviour into a third service both sides
1470
+ depend on. A cycle is usually a missing collaborator, and breaking it
1471
+ this way leaves both classes independently testable.
1472
+
1473
+ If the cycle is genuine and the design is settled, switch ONE side from
1474
+ constructor injection to @Autowired so it resolves lazily.`,codeBefore:`@Service()
1475
+ export class OrderService {
1476
+ constructor(private readonly billing: BillingService) {}
1477
+ }
1478
+
1479
+ @Service()
1480
+ export class BillingService {
1481
+ constructor(private readonly orders: OrderService) {} // ← closes the cycle
1482
+ }`,codeAfter:`@Service()
1483
+ export class OrderService {
1484
+ constructor(private readonly billing: BillingService) {}
1485
+ }
1486
+
1487
+ @Service()
1488
+ export class BillingService {
1489
+ @Autowired() private readonly orders!: OrderService // ← resolved after construction
1490
+ }`,docs:`https://kickjs.app/guide/dependency-injection.html#circular-dependency-detection`}}}},{match(e,t){let n=e.includes(`KICK001`),r=Z(e,[`no provider for`,`no provider found for`,`no binding is registered`]);return!n&&!r?null:{confidence:n?100:85,diagnosis:{id:`di-no-provider-for-token`,title:`A token was requested but nothing registers it`,explanation:`Decorators register bindings as a side effect of the class being LOADED —
1491
+ and a class is only loaded if something imports it. A module that is not
1492
+ in the bootstrap array is never imported, so none of its @Service /
1493
+ @Repository / @Controller classes ever register, and the first thing that
1494
+ asks for one gets this error.
1495
+
1496
+ That makes the failure almost always about the MODULE, not the class the
1497
+ error names — which is why the token in the message usually looks
1498
+ correctly decorated when you open it.
1499
+
1500
+ The other two causes: a class with no decorator at all, or a
1501
+ createToken() handle that nothing binds. Tokens are inert values — they
1502
+ carry a type, never an implementation.`,fix:`Check, in this order:
1503
+ 1. Is the enclosing module in \`bootstrap({ modules })\` (or in the array
1504
+ exported from src/modules/index.ts)?
1505
+ 2. Does the class carry @Service() / @Repository() / @Controller()?
1506
+ 3. For a createToken() token — does some module bind it in \`register()\`?`,codeAfter:`const TENANT_REPO = createToken<TenantRepo>('TENANT_REPO')
1507
+
1508
+ export const TenantModule = defineModule({
1509
+ name: 'TenantModule',
1510
+ build: () => ({
1511
+ register(container) {
1512
+ container.register(TENANT_REPO, { useClass: PrismaTenantRepo }) // ← the binding
1513
+ },
1514
+ routes: () => null,
1515
+ }),
1516
+ })`,docs:`https://kickjs.app/guide/dependency-injection.html#registering-services`}}}},{match(e,t){if(!Z(e,[`vite`,`kick dev`,`dev server`,`localhost:5173`,`:5173`])||!Z(e,[`404`,`not found`,`cannot get`,`cannot post`,`no route`]))return null;let n=X(e,[`app`,`export`]),r=Z(e,[`every route`,`all routes`,`every endpoint`,`all endpoints`,`none of the routes`]);return!n&&!r?null:{confidence:n&&r?85:n?80:70,diagnosis:{id:`vite-dev-app-not-exported`,title:"Every route 404s in dev because the entry file exports no `app`",explanation:`The Vite plugin does not start your server. It imports the entry module
1517
+ and reads \`app\` off it, then hands each request to that instance.
1518
+
1519
+ When the entry runs \`await bootstrap(...)\` without assigning the result to
1520
+ an exported \`app\`, the plugin finds nothing to delegate to and falls
1521
+ through to Vite's own 404 handler. Your app booted; nothing is routing to
1522
+ it.
1523
+
1524
+ The giveaway is that EVERY route 404s, including ones that clearly exist,
1525
+ and the failure is dev-only — \`kick start\` runs the entry directly and
1526
+ never needs the export.`,fix:"Export the bootstrap result as `app` from your entry file. The name is\nload-bearing — the plugin looks up exactly that export.",codeBefore:`import './env'
1527
+ import { bootstrap } from '@forinda/kickjs'
1528
+
1529
+ await bootstrap({ modules }) // ← nothing for the dev server to read`,codeAfter:`import './env'
1530
+ import { bootstrap } from '@forinda/kickjs'
1531
+
1532
+ export const app = await bootstrap({ modules })`,docs:`https://kickjs.app/guide/project-structure.html`}}}}];function rr(e,t){let n=null;for(let r of nr){let i=null;try{i=r.match(e,t)}catch{continue}!i||i.confidence<40||(!n||i.confidence>n.confidence)&&(n=i)}return n}async function ir(e){let t=e.provider??`openai`,n=process.env.OPENAI_API_KEY;if(t===`openai`&&!n)return{kind:`unavailable`,reason:`OPENAI_API_KEY environment variable is not set`,suggestion:`Set OPENAI_API_KEY in your shell, e.g.
1437
1533
  export OPENAI_API_KEY="sk-..."
1438
1534
 
1439
1535
  Then re-run \`kick explain --ai "<your error>"\`.`};let r;try{r=await import(`@forinda/kickjs-ai`)}catch{return{kind:`unavailable`,reason:`@forinda/kickjs-ai is not installed`,suggestion:`Install the AI package to enable the LLM fallback:
@@ -1532,12 +1628,12 @@ server.on('exit', () => {
1532
1628
  Cancelled.
1533
1629
  `);return}await ze(c,{recursive:!0,force:!0}),console.log(` Deleted: ${c}`);let l=M(n,`index.ts`);if(await b(l)){let e=await I(l,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${H(o)}Module\\s*\\}\\s*from\\s*['"][^'"]*${H(s)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=kr(e,o),e=e.replace(/\n{3,}/g,`
1534
1630
 
1535
- `),e!==t&&(await L(l,e,`utf-8`),console.log(` Unregistered: ${o}Module from ${l}`))}console.log(`\n Module '${s}' removed.\n`)}function jr(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=p(await l(process.cwd())),r=t.modulesDir??n.dir??`src/modules`,i=t.pluralize===!1?!1:n.pluralize??!0;for(let n of e)await Ar({name:n,modulesDir:P(r),force:t.force,pluralize:i})})}function Mr(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 Nr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Pr(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: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).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=E(process.cwd()),n=await l(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-BSNGbECd.mjs`).then(e=>e.t),{builtinCliPlugins:t}=await Promise.resolve().then(()=>Pa),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(`
1631
+ `),e!==t&&(await L(l,e,`utf-8`),console.log(` Unregistered: ${o}Module from ${l}`))}console.log(`\n Module '${s}' removed.\n`)}function jr(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=await l(process.cwd()),r=p(n),i=t.modulesDir??r.dir??`src/modules`,a=t.pluralize===!1?!1:r.pluralize??!0;for(let n of e)await Ar({name:n,modulesDir:P(i),force:t.force,pluralize:a})})}function Mr(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 Nr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function Pr(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: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).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=E(process.cwd()),n=await l(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-KiE0QPvK.mjs`).then(e=>e.t),{builtinCliPlugins:t}=await Promise.resolve().then(()=>Pa),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(`
1536
1632
  Registered typegen plugins:
1537
1633
  `);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``,n=`${e.id.replace(/\//g,`__`)}${e.outExtension??`.d.ts`}`;console.log(` ${e.id.padEnd(a+2)}→ .kickjs/types/${n}${t}`),console.log(` ${` `.repeat(a+2)} watches: ${e.inputs.join(`, `)||`(none)`}`)}console.log(`
1538
1634
  Disable one in kick.config.ts:
1539
1635
  `),console.log(` typegen: { disable: ['`+(r.typegens[0]?.id??`kick/x`)+`'] }
1540
- `);return}let r=Mr(e.schemaValidator)??n?.typegen?.schemaValidator??`zod`,i=Nr(e.envFile)??n?.typegen?.envFile,a={cwd:t,srcDir:e.src??n?.typegen?.srcDir,outDir:e.out??n?.typegen?.outDir,silent:e.silent,fix:e.fix,allowDuplicates:e.allowDuplicates,noCache:e.cache===!1,schemaValidator:r,envFile:i,assetMap:n?.assetMap,runPlugins:!1};try{if(e.watch){let t=await ye(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 xe(a);let r=await An({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 me(P(t,e.out??n?.typegen?.outDir??`.kickjs/types`),r,e.silent??!1)}}catch(e){e instanceof be?console.error(`
1636
+ `);return}let r=Mr(e.schemaValidator)??n?.typegen?.schemaValidator??`zod`,i=Nr(e.envFile)??n?.typegen?.envFile,a={cwd:t,srcDir:e.src??n?.typegen?.srcDir,outDir:e.out??n?.typegen?.outDir,silent:e.silent,fix:e.fix,allowDuplicates:e.allowDuplicates,noCache:e.cache===!1,schemaValidator:r,envFile:i,assetMap:n?.assetMap,runPlugins:!1};try{if(e.watch){let t=await ye(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 xe(a);let r=await An({cwd:t,config:n??null,silent:e.silent,check:e.check});if(e.check&&r.some(e=>e.status===`written`)&&process.exit(1),!e.check){let i=P(t,e.out??n?.typegen?.outDir??`.kickjs/types`);await me(i,r,e.silent??!1)}}}catch(e){e instanceof be?console.error(`
1541
1637
  `+e.message+`
1542
1638
  `):e instanceof hn?console.error(`
1543
1639
  `+e.message+`
@@ -1556,7 +1652,8 @@ Then import it at the top of src/index.ts:
1556
1652
  INSTEAD of ${t.join(` and `)} — no layering, no fallback. Without one of\nthose files, every var your test config does not pin resolves from your
1557
1653
  development env — including DATABASE_URL and any third-party credentials.
1558
1654
 
1559
- Create .env.test holding the whole environment the suite should run against
1655
+ Create .env.test (cp .env.test.example .env.test, if the project has one)
1656
+ holding the whole environment the suite should run against
1560
1657
  (a var you leave out is then missing, not inherited), or set KICKJS_ENV_FILE=off
1561
1658
  and supply env from the test runner.`}}const bi=[()=>ti(),ni,ri,ai,oi,li,ui,di,yi,mi];async function xi(e,t={}){let n={cwd:e,pkg:qr(M(e,`package.json`)),tsconfig:Xr(e),runtime:t.runtime??`express`},r=[...bi,...t.extraChecks??[]],i=[];for(let e of r){let t;try{t=await e(n)}catch(t){i.push({name:e.name||`doctor check`,status:`fail`,message:t instanceof Error?t.message:String(t)});continue}t!=null&&(Array.isArray(t)?i.push(...t):i.push(t))}return i}function Si(e){switch(e){case`pass`:return C.green(`✔`);case`warn`:return C.yellow(`⚠`);case`fail`:return C.red(`✖`)}}function Ci(e){let t=Si(e.status),n=e.message?` ${C.dim(`(${e.message})`)}`:``;return`${t} ${e.name}${n}`}function wi(e){return e.split(`
1562
1659
  `).map(e=>` ${C.dim(`→`)} ${e}`).join(`
@@ -1569,7 +1666,7 @@ and supply env from the test runner.`}}const bi=[()=>ti(),ni,ri,ai,oi,li,ui,di,y
1569
1666
  The regex-based rewrite handles the shapes our templates produce.
1570
1667
  Hand-rolled modules with non-standard structures may be skipped.
1571
1668
  Always commit before running with --apply.
1572
- `),process.exit(1));let r=p(await l(process.cwd())),i=P(e.modulesDir??r.dir??`src/modules`),a;e.target===`define`||e.target===`class`?a=e.target:e.target===void 0?a=r.style??`define`:(console.error(`\n ${C.red(`Error:`)} --target must be 'define' or 'class' (got '${e.target}').\n`),process.exit(1));let o=C.dim(`→ ${a}`),s=n?C.dim(`(dry-run)`):C.bold(`(applying)`);console.log(`\n ${C.bold(`kick codemod modules`)} ${o} ${s}`),console.log(` modulesDir: ${C.dim(i)}\n`);let c=e.backup!==!1&&!n,u=await an(i,{dryRun:n,target:a,backup:c});if(u.backupDir){let e=u.backupDir;console.log(` ${C.green(`✓`)} backup: ${C.dim(e)}\n ${C.dim(`(restore: rm -rf <modulesDir> && mv "<backup>" <modulesDir>)`)}\n`)}else!n&&e.backup===!1&&console.log(` ${C.dim(`(--no-backup — skipping snapshot)`)}\n`);let d=0,f=0;for(let e of u.files)if(e.status===`migrated`)d++,console.log(` ${C.green(`✓`)} ${e.path}`);else{f++;let t=C.dim(`(${e.reason??`skipped`})`);console.log(` ${C.dim(`-`)} ${e.path} ${t}`)}if(console.log(),u.indexStatus===`migrated`)console.log(` ${C.green(`✓`)} ${u.indexPath}`);else if(u.indexStatus===`skipped`){let e=C.dim(`(${u.indexReason??`skipped`})`);console.log(` ${C.dim(`-`)} ${u.indexPath} ${e}`)}else console.log(` ${C.dim(`-`)} ${u.indexPath} ${C.dim(`(not found)`)}`);let m=n?C.dim(` (dry-run — pass --apply to write)`):``;console.log(`\n ${C.bold(String(d))} migrated, ${C.bold(String(f))} skipped${m}\n`)})}const ki=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){if(!D(A.resolve(e.cwd,`kick.config.ts`)))return null;let t=await l(e.cwd);if(!t?.assetMap)return null;let n=ce(t.assetMap,e.cwd);return n.count===0?null:_e(n)}}),Ai="/* eslint-disable */\n// AUTO-GENERATED by `kick typegen`. DO NOT EDIT.\n// Re-run with `kick typegen` or rely on `kick dev` to refresh.\n";function ji(e,t,n,r={}){if(e.length===0)return`${Ai}
1669
+ `),process.exit(1));let r=await l(process.cwd()),i=p(r),a=P(e.modulesDir??i.dir??`src/modules`),o;e.target===`define`||e.target===`class`?o=e.target:e.target===void 0?o=i.style??`define`:(console.error(`\n ${C.red(`Error:`)} --target must be 'define' or 'class' (got '${e.target}').\n`),process.exit(1));let s=C.dim(`→ ${o}`),c=n?C.dim(`(dry-run)`):C.bold(`(applying)`);console.log(`\n ${C.bold(`kick codemod modules`)} ${s} ${c}`),console.log(` modulesDir: ${C.dim(a)}\n`);let u=e.backup!==!1&&!n,d=await an(a,{dryRun:n,target:o,backup:u});if(d.backupDir){let e=d.backupDir;console.log(` ${C.green(`✓`)} backup: ${C.dim(e)}\n ${C.dim(`(restore: rm -rf <modulesDir> && mv "<backup>" <modulesDir>)`)}\n`)}else!n&&e.backup===!1&&console.log(` ${C.dim(`(--no-backup — skipping snapshot)`)}\n`);let f=0,m=0;for(let e of d.files)if(e.status===`migrated`)f++,console.log(` ${C.green(`✓`)} ${e.path}`);else{m++;let t=C.dim(`(${e.reason??`skipped`})`);console.log(` ${C.dim(`-`)} ${e.path} ${t}`)}if(console.log(),d.indexStatus===`migrated`)console.log(` ${C.green(`✓`)} ${d.indexPath}`);else if(d.indexStatus===`skipped`){let e=C.dim(`(${d.indexReason??`skipped`})`);console.log(` ${C.dim(`-`)} ${d.indexPath} ${e}`)}else console.log(` ${C.dim(`-`)} ${d.indexPath} ${C.dim(`(not found)`)}`);let h=n?C.dim(` (dry-run — pass --apply to write)`):``;console.log(`\n ${C.bold(String(f))} migrated, ${C.bold(String(m))} skipped${h}\n`)})}const ki=()=>({id:`kick/assets`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`],async generate(e){let t=A.resolve(e.cwd,`kick.config.ts`);if(!D(t))return null;let n=await l(e.cwd);if(!n?.assetMap)return null;let r=ce(n.assetMap,e.cwd);return r.count===0?null:_e(r)}}),Ai="/* eslint-disable */\n// AUTO-GENERATED by `kick typegen`. DO NOT EDIT.\n// Re-run with `kick typegen` or rely on `kick dev` to refresh.\n";function ji(e,t,n,r={}){if(e.length===0)return`${Ai}
1573
1670
  // (no routes discovered yet — annotate a controller method with
1574
1671
  // @Get/@Post/@Put/@Delete/@Patch and re-run \`kick typegen\`)
1575
1672
  declare global {
@@ -1607,7 +1704,7 @@ ${x}
1607
1704
  ${g}
1608
1705
  `}function Mi(e){let t=e.contextKeys;return t==null?`string`:t.length===0?`never`:t.map(e=>JSON.stringify(e)).join(` | `)}function Ni(e){if(e.queryFilterable===null)return`unknown`;let t=e.querySortable??[];return`{ filter?: string | string[]; sort?: ${t.length>0?t.flatMap(e=>[`'${e}'`,`'-${e}'`]).join(` | `):`string`}; q?: string; page?: string; limit?: string }`}function Pi(e){let t=[];return e.queryFilterable&&e.queryFilterable.length>0&&t.push(`Filterable: ${e.queryFilterable.join(`, `)}`),e.querySortable&&e.querySortable.length>0&&t.push(`Sortable: ${e.querySortable.join(`, `)}`),e.querySearchable&&e.querySearchable.length>0&&t.push(`Searchable: ${e.querySearchable.join(`, `)}`),t}function Fi(e,t,n,r,i){if(!e||r===!1||e.source===null)return null;let a=Li(e.source,t,n);if(a===`unknown`)return null;let o=`${a}::${e.identifier}`,s=i.get(o)?.specifier;return s?s=i.get(o).specifier:(s=`_S${i.size}`,i.set(o,{identifier:e.identifier,specifier:s})),s}function Ii(e){if(e.size===0)return``;let t=[];for(let[n,r]of e){let[e]=n.split(`::`);t.push(`import type { ${r.identifier} as ${r.specifier} } from '${e}'`)}return t.join(`
1609
1706
  `)+`
1610
- `}function Li(e,t,n){if(e===null)return`unknown`;let r=j(n);if(e===``){let e=N(r,t).split(je).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=N(r,P(j(t),e)).split(je).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),i}function Ri(e){let t=e.endsWith(`Controller`)?e.slice(0,-10):e,n=t.length>0?t:e;return n.charAt(0).toLowerCase()+n.slice(1)}const zi=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:Bi(e),cwd:e.cwd,envFile:Vi(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=A.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return ji(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function Bi(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Vi(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const Hi=`@typescript/typescript6`;function Ui(e){return typeof e?.createProgram==`function`}function Wi(e){if(Ui(e.typescript))return{api:e.typescript,source:`typescript`};if(Ui(e.ts6))return{api:e.ts6,source:Hi};let t=`Install it in the project:\n pnpm add -D ${Hi}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
1707
+ `}function Li(e,t,n){if(e===null)return`unknown`;let r=j(n);if(e===``){let e=N(r,t).split(je).join(`/`);return e=e.replace(/\.(ts|tsx|mts|cts)$/i,``),e.startsWith(`.`)||(e=`./`+e),e}if(!e.startsWith(`.`)&&!e.startsWith(`/`))return e;let i=j(t),a=P(i,e),o=N(r,a).split(je).join(`/`);return o=o.replace(/\.(ts|tsx|mts|cts)$/i,``),o.startsWith(`.`)||(o=`./`+o),o}function Ri(e){let t=e.endsWith(`Controller`)?e.slice(0,-10):e,n=t.length>0?t:e;return n.charAt(0).toLowerCase()+n.slice(1)}const zi=()=>({id:`kick/routes`,outExtension:`.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){let t=await e.getScanResult({root:Bi(e),cwd:e.cwd,envFile:Vi(e)}),n=e.config?.typegen?.schemaValidator??`zod`,r=A.resolve(e.cwd,`.kickjs/types/kick__routes.ts`);return ji(t.routes,r,n,{onWarn:t=>e.log.warn(t)})}});function Bi(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Vi(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}const Hi=`@typescript/typescript6`;function Ui(e){return typeof e?.createProgram==`function`}function Wi(e){if(Ui(e.typescript))return{api:e.typescript,source:`typescript`};if(Ui(e.ts6))return{api:e.ts6,source:Hi};let t=`Install it in the project:\n pnpm add -D ${Hi}`;throw e.typescript?Error(`kick typegen: the client route map needs a TypeScript compiler API.
1611
1708
  TypeScript 7 does not ship a compiler API, so the compatibility package is required.\n ${t}`):Error(`kick typegen: the client route map needs a TypeScript compiler API, and neither 'typescript' nor '${Hi}' resolved from this project.\n ${t}`)}async function Gi(e){let t=we(M(e,`package.json`)),n=async e=>{try{return await import(F(t.resolve(e)).href)}catch{return null}},[r,i]=await Promise.all([n(`typescript`),n(Hi)]);return Wi({typescript:Ki(r),ts6:Ki(i)}).api}function Ki(e){let t=e;return t?.default&&typeof t.default==`object`?t.default:e}const qi=Symbol(`kick/client: expansion budget exhausted`);var Ji=class{ts;checker;program;opts;get printFlags(){return this.ts.TypeFormatFlags.NoTruncation}hoistedByType=new Map;inProgress=new Map;jsonInProgress=new Set;nextName=0;blocks=[];maxDepth;truncations=0;budget;constructor(e,t,n,r={}){this.ts=e,this.checker=t,this.program=n,this.opts=r,this.maxDepth=r.maxDepth??12,this.budget=r.truncationBudget??1e3}hoisted(){return this.blocks}expand(e){this.truncations=0;try{return this.render(e,0)}catch(e){if(e!==qi)throw e;return this.opts.onWarn?.(`expansion abandoned after ${this.budget} truncations — emitting 'unknown'. This usually means a recursive type. Declare a response schema on the route for an exact type.`),`unknown`}}render(e,t){let n=this.ts.TypeFlags;if(t>this.maxDepth){if(++this.truncations>this.budget)throw qi;return this.opts.onWarn?.(`type nesting exceeded ${this.maxDepth} levels — emitting 'unknown'. Declare a response schema on the route for an exact type.`),`unknown`}if(e.flags&(n.String|n.Number|n.Boolean|n.BigInt|n.ESSymbol)||e.flags&(n.Any|n.Unknown|n.Never|n.Void|n.Undefined|n.Null)||e.isLiteral()||e.flags&n.BooleanLiteral)return this.checker.typeToString(e,void 0,this.printFlags);if(e.isUnion()){let n=e.types.filter(e=>!this.isCallable(e));return(n.length>0?n:e.types).map(e=>this.render(e,t+1)).join(` | `)}if(e.isIntersection())return e.types.map(e=>this.render(e,t+1)).join(` & `);if(this.isTuple(e))return this.renderTuple(e,t);let r=this.arrayElement(e);if(r){let e=this.render(r.element,t+1),n=/[|&]/.test(e)?`(${e})[]`:`${e}[]`;return r.readonly?`readonly ${n}`:n}let i=this.toJsonType(e);if(i){if(this.jsonInProgress.has(e))return this.opts.onWarn?.(`'${this.checker.typeToString(e,void 0,this.printFlags)}' has a cyclic toJSON() — emitting 'unknown', since it has no serializable form.`),`unknown`;this.jsonInProgress.add(e);try{return this.render(i,t)}finally{this.jsonInProgress.delete(e)}}return this.isLibType(e)?this.renderLibType(e,t):e.flags&n.Object?this.renderObject(e,t):(this.opts.onWarn?.(`could not expand type '${this.checker.typeToString(e)}' — emitting 'unknown'`),`unknown`)}renderObject(e,t){let n=this.hoistedByType.get(e);if(n)return n;if(this.isNamed(e)){let t=this.allocName();this.hoistedByType.set(e,t);let n=this.blocks.length;return this.blocks.push(``),this.blocks[n]=`interface ${t} {\n${this.members(e,0,` `)}\n}`,t}let r=this.inProgress.get(e);if(r)return r.name??=this.allocName();let i={name:null};this.inProgress.set(e,i);let a;try{a=this.members(e,t,``,`; `)}finally{this.inProgress.delete(e)}if(i.name){this.hoistedByType.set(e,i.name);let t=this.blocks.length;return this.blocks.push(``),this.blocks[t]=`interface ${i.name} {\n${this.members(e,0,` `)}\n}`,i.name}return a.length>0?`{ ${a} }`:`{}`}allocName(){return`__T${this.nextName++}`}members(e,t,n,r=`
1612
1709
  `){let i=[];for(let r of this.checker.getIndexInfosOfType(e)){let e=this.checker.typeToString(r.keyType,void 0,this.printFlags);i.push(`${n}[key: ${e}]: ${this.render(r.type,t+1)}`)}for(let r of this.checker.getPropertiesOfType(e)){let e=this.typeOfProperty(r);if(this.isCallable(e)||r.getName().startsWith(`__@`))continue;let a=(r.flags&this.ts.SymbolFlags.Optional)!==0,o=this.renderPropertyType(e,a,r,t+1),s=this.isReadonlyProp(r)?`readonly `:``;i.push(`${n}${s}${this.propName(r.getName())}${a?`?`:``}: ${o}`)}return i.join(r===`
1613
1710
  `?`
@@ -1661,14 +1758,14 @@ declare global {
1661
1758
  }
1662
1759
 
1663
1760
  export type { Api }
1664
- `}const la=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,ua=`.kickjs/cache/client-map.sha1`,da=(()=>{try{return we(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function fa(e){try{if(!D(e))return null;let[t,n]=O(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function pa(e){return`${Tn}${la} */\n\n${e}\n`}function ma(e){try{return D(e)?O(e,`utf-8`):null}catch{return null}}async function ha(e){let t=A.resolve(e.cwd,Q);if(!D(t))return!1;try{await ze(t,{force:!0})}catch(t){return e.log.warn(` kick/client: could not remove the stale ${Q} — treat it as out of date (${t instanceof Error?t.message:String(t)})`),!0}return e.log.warn(` kick/client: removed the previously generated ${Q} rather than leave a stale one — re-run \`kick typegen\` once the cause above is fixed.`),!0}function ga(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function _a(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(D(A.resolve(e.cwd,Q))&&e.log.warn(` kick/client: ${Q} exists but typegen.client is not set, so it is NOT being refreshed.\n Add \`typegen: { client: true }\` to kick.config.ts to keep it current, or delete the file if nothing reads it.`),!1)}const va=()=>({id:la,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!_a(e))return null;if(e.watch)return e.log.info?.(" kick/client: skipped under watch (builds a full TypeScript program). Run `kick typegen` to refresh the client route map."),null;let t=await e.getScanResult({root:A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=new Set;for(let e of t.routes){let t=`${e.httpMethod} ${e.mountedPath??e.path}`;r.has(t)||(r.add(t),n.push(t))}let i=ga(e.config),a=await $i({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:da}),o=fa(A.resolve(e.cwd,ua)),s=ma(A.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===Zi(s))return mn()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=ca(await ea({projectDir:e.cwd,routesFile:A.resolve(e.cwd,`.kickjs/types/kick__routes.ts`),keys:n,maxDepth:i,onWarn:t=>e.log.warn(t)}),n);return a&&!e.check&&await e.writeFile(ua,`${a} ${Zi(pa(t))}`),t}catch(t){let n=D(A.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):mn()&&e.log.info?.(r),n&&await ha(e),null}}});function ya(e,t,n=`zod`){if(!e)return null;let r=N(j(t),e.filePath).split(je).join(`/`);return r=r.replace(/\.(ts|tsx|mts|cts)$/i,``),r.startsWith(`.`)||(r=`./`+r),`/* eslint-disable */
1761
+ `}const la=`kick/client`,Q=`.kickjs/types/kick__client.d.ts`,ua=`.kickjs/cache/client-map.sha1`,da=(()=>{try{return we(import.meta.url)(`../../../package.json`).version??`0.0.0`}catch{return`0.0.0`}})();function fa(e){try{if(!D(e))return null;let[t,n]=O(e,`utf-8`).trim().split(/\s+/);return t&&n?{inputs:t,output:n}:null}catch{return null}}function pa(e){return`${Tn}${la} */\n\n${e}\n`}function ma(e){try{return D(e)?O(e,`utf-8`):null}catch{return null}}async function ha(e){let t=A.resolve(e.cwd,Q);if(!D(t))return!1;try{await ze(t,{force:!0})}catch(t){return e.log.warn(` kick/client: could not remove the stale ${Q} — treat it as out of date (${t instanceof Error?t.message:String(t)})`),!0}return e.log.warn(` kick/client: removed the previously generated ${Q} rather than leave a stale one — re-run \`kick typegen\` once the cause above is fixed.`),!0}function ga(e){let t=e?.typegen?.client;return typeof t==`object`?t.maxDepth:void 0}function _a(e){let t=e.config?.typegen?.client;return typeof t==`boolean`?t:t&&typeof t==`object`?t.enabled!==!1:(D(A.resolve(e.cwd,Q))&&e.log.warn(` kick/client: ${Q} exists but typegen.client is not set, so it is NOT being refreshed.\n Add \`typegen: { client: true }\` to kick.config.ts to keep it current, or delete the file if nothing reads it.`),!1)}const va=()=>({id:la,outExtension:`.d.ts`,inputs:[`src/**/*.controller.ts`,`src/**/*.module.ts`],async generate(e){if(!_a(e))return null;if(e.watch)return e.log.info?.(" kick/client: skipped under watch (builds a full TypeScript program). Run `kick typegen` to refresh the client route map."),null;let t=await e.getScanResult({root:A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`),cwd:e.cwd}),n=[],r=new Set;for(let e of t.routes){let t=`${e.httpMethod} ${e.mountedPath??e.path}`;r.has(t)||(r.add(t),n.push(t))}let i=ga(e.config),a=await $i({projectDir:e.cwd,keys:n,maxDepth:i,cliVersion:da}),o=fa(A.resolve(e.cwd,ua)),s=ma(A.resolve(e.cwd,Q));if(a&&o&&s!==null&&o.inputs===a&&o.output===Zi(s))return mn()&&e.log.info?.(` kick/client: unchanged, keeping ${Q}`),null;try{let t=ca(await ea({projectDir:e.cwd,routesFile:A.resolve(e.cwd,`.kickjs/types/kick__routes.ts`),keys:n,maxDepth:i,onWarn:t=>e.log.warn(t)}),n);return a&&!e.check&&await e.writeFile(ua,`${a} ${Zi(pa(t))}`),t}catch(t){let n=D(A.resolve(e.cwd,Q)),r=` kick/client: skipped — ${t instanceof Error?t.message:String(t)}`;return n?e.log.warn(r):mn()&&e.log.info?.(r),n&&await ha(e),null}}});function ya(e,t,n=`zod`){if(!e)return null;let r=j(t),i=N(r,e.filePath).split(je).join(`/`);return i=i.replace(/\.(ts|tsx|mts|cts)$/i,``),i.startsWith(`.`)||(i=`./`+i),`/* eslint-disable */
1665
1762
  // AUTO-GENERATED by \`kick typegen\`. DO NOT EDIT.
1666
1763
  // Re-run with \`kick typegen\` or rely on \`kick dev\` to refresh.
1667
1764
 
1668
1765
  // Importing the schema as a type lets us infer its shape without
1669
1766
  // pulling in any runtime code. \`Awaited<>\` strips an accidental
1670
1767
  // Promise wrap on dynamic-imported defaults.
1671
- import type _envSchema from '${r}'
1768
+ import type _envSchema from '${i}'
1672
1769
 
1673
1770
  ${n===`kickjs-schema`?`type _Raw = import('@forinda/kickjs-schema').InferSchemaOutput<typeof _envSchema>
1674
1771
  type _Resolved = { [K in keyof _Raw]: _Raw[K] }
@@ -1699,5 +1796,5 @@ declare global {
1699
1796
  }
1700
1797
 
1701
1798
  export {}
1702
- `}const ba=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=Sa(e);if(t===!1)return null;let n=await e.getScanResult({root:xa(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=A.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return ya(n.env,i,r)}});function xa(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Sa(e){return e.config?.typegen?.envFile}function Ca(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function wa(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Ca(e),cwd:e.cwd,envFile:wa(e)}}const Ta=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=A.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return ve(t.classes,n,r)}}),Ea=()=>({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 pe(`ServiceToken`,he(t.classes,t.tokens,t.injects,n),"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Da=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){return pe(`ModuleToken`,le((await e.getScanResult($(e))).classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),Oa=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){return de((await e.getScanResult($(e))).pluginsAndAdapters)}}),ka=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){return Se((await e.getScanResult($(e))).augmentations)}}),Aa=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:ue(t.contextKeys)}}),ja=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){return ge((await e.getScanResult($(e))).routeFlags)}}),Ma={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Na=()=>({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}=Ma[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(`
1703
- `)}});var Pa=e({builtinCliPlugins:()=>Fa});const Fa=[_({name:`kick/init`,register:qe}),_({name:`kick/generate`,register:Cn}),_({name:`kick/run`,register:Bn}),_({name:`kick/info`,register:Gn}),_({name:`kick/inspect`,register:er}),_({name:`kick/add`,register:t}),_({name:`kick/list`,register:i}),_({name:`kick/explain`,register:ur}),_({name:`kick/mcp`,register:xr}),_({name:`kick/tinker`,register:Tr}),_({name:`kick/remove`,register:jr}),_({name:`kick/typegen`,register:Pr}),_({name:`kick/check`,register:Kr}),_({name:`kick/doctor`,register:Ei}),_({name:`kick/codemod`,register:Oi}),_({name:`kick/registry`,typegens:[Ta()]}),_({name:`kick/services`,typegens:[Ea()]}),_({name:`kick/modules`,typegens:[Da()]}),_({name:`kick/plugins`,typegens:[Oa()]}),_({name:`kick/augmentations`,typegens:[ka()]}),_({name:`kick/context`,typegens:[Aa()]}),_({name:`kick/route-flags`,typegens:[ja()]}),_({name:`kick/assets`,typegens:[ki()]}),_({name:`kick/routes`,typegens:[zi()]}),_({name:`kick/client`,typegens:[va()]}),_({name:`kick/env`,typegens:[ba()]}),_({name:`kick/runtime`,typegens:[Na()]})];export{kn as n,Fa as t};
1799
+ `}const ba=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=Sa(e);if(t===!1)return null;let n=await e.getScanResult({root:xa(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=A.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return ya(n.env,i,r)}});function xa(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Sa(e){return e.config?.typegen?.envFile}function Ca(e){return A.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function wa(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Ca(e),cwd:e.cwd,envFile:wa(e)}}const Ta=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=A.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return ve(t.classes,n,r)}}),Ea=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className)),r=he(t.classes,t.tokens,t.injects,n);return pe(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Da=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return pe(`ModuleToken`,le(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),Oa=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return de(t.pluginsAndAdapters)}}),ka=()=>({id:`kick/augmentations`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Se(t.augmentations)}}),Aa=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:ue(t.contextKeys)}}),ja=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ge(t.routeFlags)}}),Ma={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Na=()=>({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}=Ma[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(`
1800
+ `)}});var Pa=e({builtinCliPlugins:()=>Fa});const Fa=[_({name:`kick/init`,register:qe}),_({name:`kick/generate`,register:Cn}),_({name:`kick/run`,register:Bn}),_({name:`kick/info`,register:Gn}),_({name:`kick/inspect`,register:tr}),_({name:`kick/add`,register:t}),_({name:`kick/list`,register:i}),_({name:`kick/explain`,register:ur}),_({name:`kick/mcp`,register:xr}),_({name:`kick/tinker`,register:Tr}),_({name:`kick/remove`,register:jr}),_({name:`kick/typegen`,register:Pr}),_({name:`kick/check`,register:Kr}),_({name:`kick/doctor`,register:Ei}),_({name:`kick/codemod`,register:Oi}),_({name:`kick/registry`,typegens:[Ta()]}),_({name:`kick/services`,typegens:[Ea()]}),_({name:`kick/modules`,typegens:[Da()]}),_({name:`kick/plugins`,typegens:[Oa()]}),_({name:`kick/augmentations`,typegens:[ka()]}),_({name:`kick/context`,typegens:[Aa()]}),_({name:`kick/route-flags`,typegens:[ja()]}),_({name:`kick/assets`,typegens:[ki()]}),_({name:`kick/routes`,typegens:[zi()]}),_({name:`kick/client`,typegens:[va()]}),_({name:`kick/env`,typegens:[ba()]}),_({name:`kick/runtime`,typegens:[Na()]})];export{kn as n,Fa as t};
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.1.5
2
+ * @forinda/kickjs-cli v8.1.7
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,4 +8,4 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{d as e}from"./project-DfBzpCeE.mjs";import{a as t}from"./config-CzL24fBQ.mjs";import{n}from"./plugin-BSNGbECd.mjs";import{t as r}from"./builtins-B6Dc2coA.mjs";import{t as i}from"./project-root-BsyQhlS5.mjs";import{Command as a}from"commander";import{readFileSync as o}from"node:fs";import{delimiter as s,dirname as c,join as l}from"node:path";import{fileURLToPath as u}from"node:url";function d(e,t){if(!t?.commands?.length)return;let n=new Set(e.commands.map(e=>e.name()));for(let r of t.commands){if(n.has(r.name)){console.warn(` Warning: custom command '${r.name}' skipped — conflicts with a built-in command`);continue}f(e,r)}}function f(t,n){let r=t.command(n.name).description(n.description);if(n.aliases)for(let e of n.aliases)r.alias(e);r.allowUnknownOption(!0),r.argument(`[args...]`,`Additional arguments passed to the command`);function i(){return{PATH:`${l(process.cwd(),`node_modules`,`.bin`)}${s}${process.env.PATH??``}`}}r.action(t=>{let r=t.join(` `),a=Array.isArray(n.steps)?n.steps:[n.steps];for(let t of a){let a=r?`${t} ${r}`:t;console.log(` $ ${a}`);try{e(a,void 0,i())}catch{console.error(` Command failed: ${n.name}`),process.exitCode=1;return}}})}const p=c(u(import.meta.url)),m=JSON.parse(o(l(p,`..`,`package.json`),`utf-8`));async function h(){let e=new a;e.name(`kick`).description(`KickJS — A production-grade, decorator-driven Node.js framework`).version(m.version);let o=i(process.cwd()),s=o,c=await t(s)??{},l=n([...r,...c.plugins??[]],c.commands??[]);await l.register(e,{cwd:s,projectRoot:o,config:c,log:e=>console.log(e)}),d(e,{...c,commands:l.commands}),e.showHelpAfterError();let u=process.argv.map(e=>e===`-v`?`--version`:e);await e.parseAsync(u)}h().catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});export{};
11
+ import{d as e}from"./project-C5jzgKo-.mjs";import{a as t}from"./config-BZIWs0bx.mjs";import{n}from"./plugin-KiE0QPvK.mjs";import{t as r}from"./builtins-CTvWnQQZ.mjs";import{t as i}from"./project-root-D4iNxhPu.mjs";import{Command as a}from"commander";import{readFileSync as o}from"node:fs";import{delimiter as s,dirname as c,join as l}from"node:path";import{fileURLToPath as u}from"node:url";function d(e,t){if(!t?.commands?.length)return;let n=new Set(e.commands.map(e=>e.name()));for(let r of t.commands){if(n.has(r.name)){console.warn(` Warning: custom command '${r.name}' skipped — conflicts with a built-in command`);continue}f(e,r)}}function f(t,n){let r=t.command(n.name).description(n.description);if(n.aliases)for(let e of n.aliases)r.alias(e);r.allowUnknownOption(!0),r.argument(`[args...]`,`Additional arguments passed to the command`);function i(){return{PATH:`${l(process.cwd(),`node_modules`,`.bin`)}${s}${process.env.PATH??``}`}}r.action(t=>{let r=t.join(` `),a=Array.isArray(n.steps)?n.steps:[n.steps];for(let t of a){let a=r?`${t} ${r}`:t;console.log(` $ ${a}`);try{e(a,void 0,i())}catch{console.error(` Command failed: ${n.name}`),process.exitCode=1;return}}})}const p=c(u(import.meta.url)),m=JSON.parse(o(l(p,`..`,`package.json`),`utf-8`));async function h(){let e=new a;e.name(`kick`).description(`KickJS — A production-grade, decorator-driven Node.js framework`).version(m.version);let o=i(process.cwd()),s=o,c=await t(s)??{},l=[...r,...c.plugins??[]],u=n(l,c.commands??[]);await u.register(e,{cwd:s,projectRoot:o,config:c,log:e=>console.log(e)}),d(e,{...c,commands:u.commands}),e.showHelpAfterError();let f=process.argv.map(e=>e===`-v`?`--version`:e);await e.parseAsync(f)}h().catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});export{};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.1.5
2
+ * @forinda/kickjs-cli v8.1.7
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-DmTqmRjS.mjs";import{existsSync as t,mkdirSync as n,readFileSync as r,writeFileSync as i}from"node:fs";import{isAbsolute as a,join as o,relative as s,resolve as c}from"node:path";import{access as l,readFile as u}from"node:fs/promises";var d=e({BUILTIN_REPO_TYPES:()=>p,DEPRECATED_REPO_TYPES:()=>m,PACKAGE_MANAGERS:()=>f,defineConfig:()=>g,hasDependency:()=>_,hasSwagger:()=>v,loadKickConfig:()=>w,resolveModuleConfig:()=>S,resolveSchemaLib:()=>y,resolveTokenScope:()=>b,validateAssetMap:()=>E,warnIfDeprecatedRepo:()=>h,writeAssetConfigSnapshot:()=>T});const f=[`pnpm`,`npm`,`yarn`,`bun`],p=[`inmemory`],m=[`prisma`,`drizzle`];function h(e){return m.includes(e)?(console.warn(` Note: '${e}' is no longer a built-in repository preset — a repository shaped to it is that library's interface, not KickJS's.\n Scaffolding a generic custom-repository stub instead; wire it to ${e} yourself.`),!0):!1}function g(e){return e}function _(e,n,i=`runtime`){try{let a=o(e,`package.json`);if(!t(a))return!1;let s=JSON.parse(r(a,`utf-8`));return s.dependencies?.[n]?!0:i===`any`&&!!s.devDependencies?.[n]}catch{return!1}}function v(e){return _(e,`@forinda/kickjs-swagger`,`runtime`)}function y(e){return _(e,`valibot`,`runtime`)?`valibot`:_(e,`yup`,`runtime`)?`yup`:`zod`}function b(e,n){if(e?.tokenScope&&typeof e.tokenScope==`string`&&e.tokenScope.length>0){let t=x(e.tokenScope);if(t.length>0)return t}try{let e=o(n,`package.json`);if(t(e)){let t=JSON.parse(r(e,`utf-8`));if(typeof t.name==`string`&&t.name.length>0){let e=t.name.match(/^@([^/]+)\//),n=x(e?e[1]:t.name);if(n.length>0)return n}}}catch{}return`app`}function x(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function S(e){if(!e)return{};let t={dir:e.modules?.dir,repo:e.modules?.repo,schemaDir:e.modules?.schemaDir,pluralize:e.modules?.pluralize,style:e.modules?.style};return t.style!==void 0&&t.style!==`define`&&t.style!==`class`&&(console.warn(` Warning: modules.style '${t.style}' is not a valid value (expected 'define' or 'class'). Falling back to 'define'.`),t.style=`define`),t.repo&&typeof t.repo==`string`&&!p.includes(t.repo)&&(h(t.repo)||console.warn(` Warning: modules.repo '${t.repo}' is not a built-in type (${p.join(`, `)}). It will generate a stub repository. Use { name: '${t.repo}' } to silence this warning.`)),t}const C=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];async function w(e){let{findProjectRoot:t}=await import(`./project-root-BsyQhlS5.mjs`).then(e=>e.n),n=t(e);for(let e of C){let t=o(n,e);try{await l(t)}catch{continue}if(e.endsWith(`.json`)){let e=await u(t,`utf-8`);return JSON.parse(e)}if(e.endsWith(`.ts`)){let r;try{r=await import(`jiti`)}catch(t){let n=t instanceof Error?t.message:String(t);n.includes(`Cannot find package 'jiti'`)||n.includes(`ERR_MODULE_NOT_FOUND`)?console.warn(`Warning: Failed to load ${e} — 'jiti' is required for TypeScript configs. Run \`pnpm add -D jiti\` (or your package manager's equivalent), or rename the file to kick.config.js / kick.config.mjs / kick.config.json.`):console.warn(`Warning: Failed to initialize jiti for ${e}: ${n}`);continue}try{let e=await r.createJiti(n,{interopDefault:!0,fsCache:!1}).import(t,{default:!0}),i=E(e,n);for(let e of i)console.warn(` Warning: ${e}`);return T(n,e),e}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}try{let{pathToFileURL:e}=await import(`node:url`),r=await import(e(t).href),i=r.default??r,a=E(i,n);for(let e of a)console.warn(` Warning: ${e}`);return T(n,i),i}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}return null}function T(e,t){if(!(!t?.assetMap||Object.keys(t.assetMap).length===0))try{let r=o(e,`.kickjs`);n(r,{recursive:!0});let a={version:1,assetMap:t.assetMap,...t.build?.outDir?{build:{outDir:t.build.outDir}}:{}};i(o(r,`kick.config.json`),JSON.stringify(a,null,2)+`
12
- `,`utf-8`)}catch{}}function E(e,n){let r=[];if(!e?.assetMap)return r;let i=c(n);for(let[a,o]of Object.entries(e.assetMap)){if(!a||a.includes(`/`)){r.push(`assetMap key '${a}' is invalid — must be a non-empty string without '/'`);continue}if(typeof o?.src!=`string`||o.src.length===0){r.push(`assetMap.${a} is missing a non-empty 'src' field`);continue}t(c(n,o.src))||r.push(`assetMap.${a}.src ('${o.src}') does not exist — typegen + build will fail`),o.dest&&D(c(n,o.dest),i)&&r.push(`assetMap.${a}.dest ('${o.dest}') resolves outside the project root — refusing to copy`)}return r}function D(e,t){let n=s(t,e);return n===``?!1:n.startsWith(`..`)||a(n)}export{w as a,b as c,v as i,h as l,d as n,S as o,_ as r,y as s,f as t};
11
+ import{t as e}from"./rolldown-runtime-BAJI6YvG.mjs";import{existsSync as t,mkdirSync as n,readFileSync as r,writeFileSync as i}from"node:fs";import{isAbsolute as a,join as o,relative as s,resolve as c}from"node:path";import{access as l,readFile as u}from"node:fs/promises";var d=e({BUILTIN_REPO_TYPES:()=>p,DEPRECATED_REPO_TYPES:()=>m,PACKAGE_MANAGERS:()=>f,defineConfig:()=>g,hasDependency:()=>_,hasSwagger:()=>v,loadKickConfig:()=>w,resolveModuleConfig:()=>S,resolveSchemaLib:()=>y,resolveTokenScope:()=>b,validateAssetMap:()=>E,warnIfDeprecatedRepo:()=>h,writeAssetConfigSnapshot:()=>T});const f=[`pnpm`,`npm`,`yarn`,`bun`],p=[`inmemory`],m=[`prisma`,`drizzle`];function h(e){return m.includes(e)?(console.warn(` Note: '${e}' is no longer a built-in repository preset — a repository shaped to it is that library's interface, not KickJS's.\n Scaffolding a generic custom-repository stub instead; wire it to ${e} yourself.`),!0):!1}function g(e){return e}function _(e,n,i=`runtime`){try{let a=o(e,`package.json`);if(!t(a))return!1;let s=JSON.parse(r(a,`utf-8`));return s.dependencies?.[n]?!0:i===`any`&&!!s.devDependencies?.[n]}catch{return!1}}function v(e){return _(e,`@forinda/kickjs-swagger`,`runtime`)}function y(e){return _(e,`valibot`,`runtime`)?`valibot`:_(e,`yup`,`runtime`)?`yup`:`zod`}function b(e,n){if(e?.tokenScope&&typeof e.tokenScope==`string`&&e.tokenScope.length>0){let t=x(e.tokenScope);if(t.length>0)return t}try{let e=o(n,`package.json`);if(t(e)){let t=JSON.parse(r(e,`utf-8`));if(typeof t.name==`string`&&t.name.length>0){let e=t.name.match(/^@([^/]+)\//),n=x(e?e[1]:t.name);if(n.length>0)return n}}}catch{}return`app`}function x(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function S(e){if(!e)return{};let t={dir:e.modules?.dir,repo:e.modules?.repo,schemaDir:e.modules?.schemaDir,pluralize:e.modules?.pluralize,style:e.modules?.style};return t.style!==void 0&&t.style!==`define`&&t.style!==`class`&&(console.warn(` Warning: modules.style '${t.style}' is not a valid value (expected 'define' or 'class'). Falling back to 'define'.`),t.style=`define`),t.repo&&typeof t.repo==`string`&&!p.includes(t.repo)&&(h(t.repo)||console.warn(` Warning: modules.repo '${t.repo}' is not a built-in type (${p.join(`, `)}). It will generate a stub repository. Use { name: '${t.repo}' } to silence this warning.`)),t}const C=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];async function w(e){let{findProjectRoot:t}=await import(`./project-root-D4iNxhPu.mjs`).then(e=>e.n),n=t(e);for(let e of C){let t=o(n,e);try{await l(t)}catch{continue}if(e.endsWith(`.json`)){let e=await u(t,`utf-8`);return JSON.parse(e)}if(e.endsWith(`.ts`)){let r;try{r=await import(`jiti`)}catch(t){let n=t instanceof Error?t.message:String(t);n.includes(`Cannot find package 'jiti'`)||n.includes(`ERR_MODULE_NOT_FOUND`)?console.warn(`Warning: Failed to load ${e} — 'jiti' is required for TypeScript configs. Run \`pnpm add -D jiti\` (or your package manager's equivalent), or rename the file to kick.config.js / kick.config.mjs / kick.config.json.`):console.warn(`Warning: Failed to initialize jiti for ${e}: ${n}`);continue}try{let e=await r.createJiti(n,{interopDefault:!0,fsCache:!1}).import(t,{default:!0}),i=E(e,n);for(let e of i)console.warn(` Warning: ${e}`);return T(n,e),e}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}try{let{pathToFileURL:e}=await import(`node:url`),r=await import(e(t).href),i=r.default??r,a=E(i,n);for(let e of a)console.warn(` Warning: ${e}`);return T(n,i),i}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}return null}function T(e,t){if(t?.assetMap&&Object.keys(t.assetMap).length!==0)try{let r=o(e,`.kickjs`);n(r,{recursive:!0});let a={version:1,assetMap:t.assetMap,...t.build?.outDir?{build:{outDir:t.build.outDir}}:{}};i(o(r,`kick.config.json`),JSON.stringify(a,null,2)+`
12
+ `,`utf-8`)}catch{}}function E(e,n){let r=[];if(!e?.assetMap)return r;let i=c(n);for(let[a,o]of Object.entries(e.assetMap)){if(!a||a.includes(`/`)){r.push(`assetMap key '${a}' is invalid — must be a non-empty string without '/'`);continue}if(typeof o?.src!=`string`||o.src.length===0){r.push(`assetMap.${a} is missing a non-empty 'src' field`);continue}let e=c(n,o.src);t(e)||r.push(`assetMap.${a}.src ('${o.src}') does not exist — typegen + build will fail`),o.dest&&D(c(n,o.dest),i)&&r.push(`assetMap.${a}.dest ('${o.dest}') resolves outside the project root — refusing to copy`)}return r}function D(e,t){let n=s(t,e);return n===``?!1:n.startsWith(`..`)||a(n)}export{w as a,b as c,v as i,h as l,d as n,S as o,_ as r,y as s,f as t};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.1.5
2
+ * @forinda/kickjs-cli v8.1.7
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,6 +8,6 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-DmTqmRjS.mjs";import{isAbsolute as t,join as n,relative as r,resolve as i}from"node:path";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{access as l,readFile as u}from"node:fs/promises";var d=e({BUILTIN_REPO_TYPES:()=>p,DEPRECATED_REPO_TYPES:()=>m,PACKAGE_MANAGERS:()=>f,defineConfig:()=>g,hasDependency:()=>_,hasSwagger:()=>v,loadKickConfig:()=>w,resolveModuleConfig:()=>S,resolveSchemaLib:()=>y,resolveTokenScope:()=>b,validateAssetMap:()=>E,warnIfDeprecatedRepo:()=>h,writeAssetConfigSnapshot:()=>T});const f=[`pnpm`,`npm`,`yarn`,`bun`],p=[`inmemory`],m=[`prisma`,`drizzle`];function h(e){return m.includes(e)?(console.warn(` Note: '${e}' is no longer a built-in repository preset — a repository shaped to it is that library's interface, not KickJS's.\n Scaffolding a generic custom-repository stub instead; wire it to ${e} yourself.`),!0):!1}function g(e){return e}function _(e,t,r=`runtime`){try{let i=n(e,`package.json`);if(!a(i))return!1;let o=JSON.parse(s(i,`utf-8`));return o.dependencies?.[t]?!0:r===`any`&&!!o.devDependencies?.[t]}catch{return!1}}function v(e){return _(e,`@forinda/kickjs-swagger`,`runtime`)}function y(e){return _(e,`valibot`,`runtime`)?`valibot`:_(e,`yup`,`runtime`)?`yup`:`zod`}function b(e,t){if(e?.tokenScope&&typeof e.tokenScope==`string`&&e.tokenScope.length>0){let t=x(e.tokenScope);if(t.length>0)return t}try{let e=n(t,`package.json`);if(a(e)){let t=JSON.parse(s(e,`utf-8`));if(typeof t.name==`string`&&t.name.length>0){let e=t.name.match(/^@([^/]+)\//),n=x(e?e[1]:t.name);if(n.length>0)return n}}}catch{}return`app`}function x(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function S(e){if(!e)return{};let t={dir:e.modules?.dir,repo:e.modules?.repo,schemaDir:e.modules?.schemaDir,pluralize:e.modules?.pluralize,style:e.modules?.style};return t.style!==void 0&&t.style!==`define`&&t.style!==`class`&&(console.warn(` Warning: modules.style '${t.style}' is not a valid value (expected 'define' or 'class'). Falling back to 'define'.`),t.style=`define`),t.repo&&typeof t.repo==`string`&&!p.includes(t.repo)&&(h(t.repo)||console.warn(` Warning: modules.repo '${t.repo}' is not a built-in type (${p.join(`, `)}). It will generate a stub repository. Use { name: '${t.repo}' } to silence this warning.`)),t}const C=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];async function w(e){let{findProjectRoot:t}=await import(`./project-root-CQCNCAvv.mjs`).then(e=>e.n),r=t(e);for(let e of C){let t=n(r,e);try{await l(t)}catch{continue}if(e.endsWith(`.json`)){let e=await u(t,`utf-8`);return JSON.parse(e)}if(e.endsWith(`.ts`)){let n;try{n=await import(`jiti`)}catch(t){let n=t instanceof Error?t.message:String(t);n.includes(`Cannot find package 'jiti'`)||n.includes(`ERR_MODULE_NOT_FOUND`)?console.warn(`Warning: Failed to load ${e} — 'jiti' is required for TypeScript configs. Run \`pnpm add -D jiti\` (or your package manager's equivalent), or rename the file to kick.config.js / kick.config.mjs / kick.config.json.`):console.warn(`Warning: Failed to initialize jiti for ${e}: ${n}`);continue}try{let e=await n.createJiti(r,{interopDefault:!0,fsCache:!1}).import(t,{default:!0}),i=E(e,r);for(let e of i)console.warn(` Warning: ${e}`);return T(r,e),e}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}try{let{pathToFileURL:e}=await import(`node:url`),n=await import(e(t).href),i=n.default??n,a=E(i,r);for(let e of a)console.warn(` Warning: ${e}`);return T(r,i),i}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}return null}function T(e,t){if(!(!t?.assetMap||Object.keys(t.assetMap).length===0))try{let r=n(e,`.kickjs`);o(r,{recursive:!0});let i={version:1,assetMap:t.assetMap,...t.build?.outDir?{build:{outDir:t.build.outDir}}:{}};c(n(r,`kick.config.json`),JSON.stringify(i,null,2)+`
12
- `,`utf-8`)}catch{}}function E(e,t){let n=[];if(!e?.assetMap)return n;let r=i(t);for(let[o,s]of Object.entries(e.assetMap)){if(!o||o.includes(`/`)){n.push(`assetMap key '${o}' is invalid — must be a non-empty string without '/'`);continue}if(typeof s?.src!=`string`||s.src.length===0){n.push(`assetMap.${o} is missing a non-empty 'src' field`);continue}a(i(t,s.src))||n.push(`assetMap.${o}.src ('${s.src}') does not exist — typegen + build will fail`),s.dest&&D(i(t,s.dest),r)&&n.push(`assetMap.${o}.dest ('${s.dest}') resolves outside the project root — refusing to copy`)}return n}function D(e,n){let i=r(n,e);return i===``?!1:i.startsWith(`..`)||t(i)}export{v as a,y as c,_ as i,b as l,d as n,w as o,g as r,S as s,f as t,h as u};
13
- //# sourceMappingURL=config-D06pHD-Y.mjs.map
11
+ import{t as e}from"./rolldown-runtime-BAJI6YvG.mjs";import{isAbsolute as t,join as n,relative as r,resolve as i}from"node:path";import{existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{access as l,readFile as u}from"node:fs/promises";var d=e({BUILTIN_REPO_TYPES:()=>p,DEPRECATED_REPO_TYPES:()=>m,PACKAGE_MANAGERS:()=>f,defineConfig:()=>g,hasDependency:()=>_,hasSwagger:()=>v,loadKickConfig:()=>w,resolveModuleConfig:()=>S,resolveSchemaLib:()=>y,resolveTokenScope:()=>b,validateAssetMap:()=>E,warnIfDeprecatedRepo:()=>h,writeAssetConfigSnapshot:()=>T});const f=[`pnpm`,`npm`,`yarn`,`bun`],p=[`inmemory`],m=[`prisma`,`drizzle`];function h(e){return m.includes(e)?(console.warn(` Note: '${e}' is no longer a built-in repository preset — a repository shaped to it is that library's interface, not KickJS's.\n Scaffolding a generic custom-repository stub instead; wire it to ${e} yourself.`),!0):!1}function g(e){return e}function _(e,t,r=`runtime`){try{let i=n(e,`package.json`);if(!a(i))return!1;let o=JSON.parse(s(i,`utf-8`));return o.dependencies?.[t]?!0:r===`any`&&!!o.devDependencies?.[t]}catch{return!1}}function v(e){return _(e,`@forinda/kickjs-swagger`,`runtime`)}function y(e){return _(e,`valibot`,`runtime`)?`valibot`:_(e,`yup`,`runtime`)?`yup`:`zod`}function b(e,t){if(e?.tokenScope&&typeof e.tokenScope==`string`&&e.tokenScope.length>0){let t=x(e.tokenScope);if(t.length>0)return t}try{let e=n(t,`package.json`);if(a(e)){let t=JSON.parse(s(e,`utf-8`));if(typeof t.name==`string`&&t.name.length>0){let e=t.name.match(/^@([^/]+)\//),n=x(e?e[1]:t.name);if(n.length>0)return n}}}catch{}return`app`}function x(e){return e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/^-+|-+$/g,``).replace(/-{2,}/g,`-`)}function S(e){if(!e)return{};let t={dir:e.modules?.dir,repo:e.modules?.repo,schemaDir:e.modules?.schemaDir,pluralize:e.modules?.pluralize,style:e.modules?.style};return t.style!==void 0&&t.style!==`define`&&t.style!==`class`&&(console.warn(` Warning: modules.style '${t.style}' is not a valid value (expected 'define' or 'class'). Falling back to 'define'.`),t.style=`define`),t.repo&&typeof t.repo==`string`&&!p.includes(t.repo)&&(h(t.repo)||console.warn(` Warning: modules.repo '${t.repo}' is not a built-in type (${p.join(`, `)}). It will generate a stub repository. Use { name: '${t.repo}' } to silence this warning.`)),t}const C=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];async function w(e){let{findProjectRoot:t}=await import(`./project-root-BRMuHEs3.mjs`).then(e=>e.n),r=t(e);for(let e of C){let t=n(r,e);try{await l(t)}catch{continue}if(e.endsWith(`.json`)){let e=await u(t,`utf-8`);return JSON.parse(e)}if(e.endsWith(`.ts`)){let n;try{n=await import(`jiti`)}catch(t){let n=t instanceof Error?t.message:String(t);n.includes(`Cannot find package 'jiti'`)||n.includes(`ERR_MODULE_NOT_FOUND`)?console.warn(`Warning: Failed to load ${e} — 'jiti' is required for TypeScript configs. Run \`pnpm add -D jiti\` (or your package manager's equivalent), or rename the file to kick.config.js / kick.config.mjs / kick.config.json.`):console.warn(`Warning: Failed to initialize jiti for ${e}: ${n}`);continue}try{let e=await n.createJiti(r,{interopDefault:!0,fsCache:!1}).import(t,{default:!0}),i=E(e,r);for(let e of i)console.warn(` Warning: ${e}`);return T(r,e),e}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}try{let{pathToFileURL:e}=await import(`node:url`),n=await import(e(t).href),i=n.default??n,a=E(i,r);for(let e of a)console.warn(` Warning: ${e}`);return T(r,i),i}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Warning: Failed to load ${e}: ${n}`);continue}}return null}function T(e,t){if(t?.assetMap&&Object.keys(t.assetMap).length!==0)try{let r=n(e,`.kickjs`);o(r,{recursive:!0});let i={version:1,assetMap:t.assetMap,...t.build?.outDir?{build:{outDir:t.build.outDir}}:{}};c(n(r,`kick.config.json`),JSON.stringify(i,null,2)+`
12
+ `,`utf-8`)}catch{}}function E(e,t){let n=[];if(!e?.assetMap)return n;let r=i(t);for(let[o,s]of Object.entries(e.assetMap)){if(!o||o.includes(`/`)){n.push(`assetMap key '${o}' is invalid — must be a non-empty string without '/'`);continue}if(typeof s?.src!=`string`||s.src.length===0){n.push(`assetMap.${o} is missing a non-empty 'src' field`);continue}let e=i(t,s.src);a(e)||n.push(`assetMap.${o}.src ('${s.src}') does not exist — typegen + build will fail`),s.dest&&D(i(t,s.dest),r)&&n.push(`assetMap.${o}.dest ('${s.dest}') resolves outside the project root — refusing to copy`)}return n}function D(e,n){let i=r(n,e);return i===``?!1:i.startsWith(`..`)||t(i)}export{v as a,y as c,_ as i,b as l,d as n,w as o,g as r,S as s,f as t,h as u};
13
+ //# sourceMappingURL=config-BaIkyt4R.mjs.map