@akanjs/cli 3.1.1-rc.9 → 3.1.2-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-z5vkm9ea.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/agent.command-20zaqe60.js +49 -0
  8. package/akanCode.js +13 -8
  9. package/{application.command-wthg8nn9.js → application.command-nd0fshsk.js} +45 -12
  10. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-s13x3zqb.js} +14 -10
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-sz11hpre.js → cloud.command-8kbddsz9.js} +28 -19
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/commandManifest.json +1 -1
  16. package/{context.command-15j9b7c0.js → context.command-p6haqjay.js} +20 -18
  17. package/context.runner-rsnqnk9j.js +27 -0
  18. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  19. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  20. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  21. package/{guideline.command-snh85ctf.js → guideline.command-195g0h9a.js} +4 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  23. package/guidelines/conventions/core.md +106 -0
  24. package/guidelines/conventions/rules/app.md +83 -0
  25. package/guidelines/conventions/rules/auth.md +46 -0
  26. package/guidelines/conventions/rules/config.md +60 -0
  27. package/guidelines/conventions/rules/constant.md +24 -0
  28. package/guidelines/conventions/rules/gates.md +32 -0
  29. package/guidelines/conventions/rules/layer.md +25 -0
  30. package/guidelines/conventions/rules/migration.md +27 -0
  31. package/guidelines/conventions/rules/module.md +90 -0
  32. package/guidelines/conventions/rules/page.md +56 -0
  33. package/guidelines/conventions/rules/sensitive.md +16 -0
  34. package/guidelines/conventions/rules/server.md +91 -0
  35. package/guidelines/conventions/rules/ssr.md +47 -0
  36. package/guidelines/conventions/rules/style.md +43 -0
  37. package/guidelines/conventions/rules/test.md +34 -0
  38. package/guidelines/conventions/rules/ts.md +95 -0
  39. package/guidelines/conventions/rules/tsx.md +76 -0
  40. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  41. package/guidelines/pageRule/pageRule.instruction.md +8 -7
  42. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  43. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  44. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  45. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  46. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +4 -4
  47. package/incrementalBuilder.proc.js +7 -7
  48. package/{index-301pdbzz.js → index-00a7j05x.js} +7 -7
  49. package/{index-js6geqjn.js → index-0j1t1h2b.js} +3 -1
  50. package/{index-6txx6a9p.js → index-1h2jc0x3.js} +154 -88
  51. package/{index-55j120r8.js → index-1qsd8ft1.js} +65 -145
  52. package/{index-9th4gszy.js → index-2mwjshz5.js} +233 -1271
  53. package/index-2nxk8wgs.js +266 -0
  54. package/{index-j9vyj3dj.js → index-2phm56a1.js} +49 -8
  55. package/index-35j83zkd.js +61 -0
  56. package/index-4am4dvmf.js +29 -0
  57. package/index-75y7bcz4.js +28 -0
  58. package/index-7apsdr5g.js +487 -0
  59. package/{index-42j4a8zq.js → index-84h43kg6.js} +8 -6
  60. package/index-9bv479q5.js +1 -0
  61. package/{index-3wypz6xj.js → index-9zy8479y.js} +11 -5
  62. package/{index-a5dhqkdr.js → index-a1vb3x7t.js} +273 -259
  63. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  64. package/index-cjmjvg4r.js +3622 -0
  65. package/{index-pcwzkdqb.js → index-defp4gmb.js} +1 -1
  66. package/index-ewbmfarf.js +1606 -0
  67. package/index-fbewhg4g.js +590 -0
  68. package/index-fhw7yq2d.js +653 -0
  69. package/{index-wcej7g4z.js → index-g500c5j9.js} +271 -105
  70. package/{index-74tjjsnc.js → index-g841cap9.js} +33 -37
  71. package/{index-2azahjaw.js → index-gr9thy79.js} +5 -5
  72. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  73. package/{index-xjf5j657.js → index-hm0tn7qv.js} +1001 -91
  74. package/index-j6eeh5d7.js +138 -0
  75. package/{index-31es1yev.js → index-j7hwy56s.js} +108 -7
  76. package/{index-skk9zc1x.js → index-jc2zbwra.js} +2 -2
  77. package/{index-905qdgqp.js → index-khk05tsf.js} +1 -1
  78. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  79. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  80. package/{index-a58emady.js → index-qw6814m4.js} +55 -17
  81. package/index-raz588b3.js +445 -0
  82. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  83. package/{index-bt438yxm.js → index-sp0qsr7a.js} +116 -13
  84. package/{index-xb8809yb.js → index-sveq36gh.js} +40 -43
  85. package/{index-hmt54t45.js → index-t1t9wq9a.js} +4 -4
  86. package/index-t78230d7.js +191 -0
  87. package/index-tenw3mah.js +225 -0
  88. package/{index-qfp55x1y.js → index-tgqameyb.js} +4 -4
  89. package/{index-espk51ah.js → index-tp56652m.js} +6 -6
  90. package/index-w15mg3km.js +389 -0
  91. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  92. package/{index-2xcc2ax5.js → index-y4kcmbt2.js} +2 -2
  93. package/index-yf9wc28h.js +52 -0
  94. package/{index-0fz95kxe.js → index-zbrwnmf1.js} +9 -7
  95. package/{index-40brg4px.js → index-zttm13c3.js} +5 -5
  96. package/index.js +24 -23
  97. package/{library.command-gycrwhf1.js → library.command-63hgt9te.js} +4 -4
  98. package/{localRegistry.command-jtd8gaes.js → localRegistry.command-g3f8k25t.js} +46 -22
  99. package/{module.command-v6hgs1bc.js → module.command-r4sa2khp.js} +7 -6
  100. package/{package.command-shzpcfph.js → package.command-96eheyvd.js} +5 -5
  101. package/package.json +2 -2
  102. package/{page.command-ptxn5kqk.js → page.command-gs6d841d.js} +4 -4
  103. package/{pipeline.command-zz31pgax.js → pipeline.command-wdfvdbfj.js} +3 -3
  104. package/{primitive.command-a1vse91z.js → primitive.command-dfsv4mpe.js} +8 -7
  105. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-kqj1t6hb.js} +1 -1
  106. package/{prompter-76k56b37.js → prompter-qrwx1p17.js} +2 -2
  107. package/quality.command-webzxee2.js +78 -0
  108. package/{repair.command-cvazbz99.js → repair.command-3r3j1xre.js} +7 -6
  109. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  110. package/{scalar.command-0acvyp26.js → scalar.command-e8y47j6d.js} +6 -5
  111. package/skills/akan-agent/SKILL.md +43 -0
  112. package/skills/akan-code/SKILL.md +38 -11
  113. package/skills/akan-debug/SKILL.md +41 -6
  114. package/skills/akan-deps/SKILL.md +1 -2
  115. package/skills/akan-err/SKILL.md +2 -1
  116. package/skills/akan-mcp/SKILL.md +40 -0
  117. package/skills/akan-page/SKILL.md +44 -0
  118. package/skills/akan-query/SKILL.md +39 -0
  119. package/skills/akan-runtime/SKILL.md +43 -0
  120. package/skills/akan-scaffold/SKILL.md +16 -6
  121. package/skills/akan-transport/SKILL.md +40 -0
  122. package/skills/akan-validate/SKILL.md +13 -11
  123. package/{subspace.command-822qx2bx.js → subspace.command-a1sf9n5a.js} +12 -10
  124. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  125. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  126. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  127. package/templates/app/akan.config.ts +2 -3
  128. package/templates/app/env/env.client.ts +2 -4
  129. package/templates/app/env/env.client.type.ts +2 -3
  130. package/templates/app/env/env.server.ts +2 -3
  131. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  132. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  133. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  134. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  135. package/templates/app/lib/option.ts +2 -3
  136. package/templates/app/main.ts +2 -4
  137. package/templates/app/page/_index.tsx +3 -3
  138. package/templates/app/page/_layout.tsx +13 -10
  139. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  140. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  141. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  142. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  143. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  144. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  145. package/templates/appSample/lib/task/task.constant.ts +1 -5
  146. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  147. package/templates/appSample/lib/task/task.document.ts +1 -1
  148. package/templates/appSample/lib/task/task.signal.ts +14 -9
  149. package/templates/appSample/page/task/_index.tsx +2 -1
  150. package/templates/appSample/page/task/new.tsx +2 -1
  151. package/templates/appSample/srvkit/guards.ts +11 -0
  152. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  153. package/templates/biomeForm.ts +144 -0
  154. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  155. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  156. package/templates/crudPages/new/page.tsx +4 -3
  157. package/templates/crudPages/page.tsx +3 -3
  158. package/templates/crudSinglePage/page.tsx +9 -5
  159. package/templates/libRoot/akan.config.ts +2 -3
  160. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  161. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  162. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  163. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  164. package/templates/libRoot/lib/option.ts +1 -2
  165. package/templates/module/__Model__.Template.tsx +11 -10
  166. package/templates/module/__Model__.Unit.tsx +18 -5
  167. package/templates/module/__Model__.Util.tsx +9 -7
  168. package/templates/module/__Model__.View.tsx +9 -6
  169. package/templates/module/__Model__.Zone.tsx +25 -17
  170. package/templates/module/__model__.constant.ts +8 -9
  171. package/templates/module/__model__.dictionary.ts +16 -17
  172. package/templates/module/__model__.document.ts +6 -8
  173. package/templates/module/__model__.service.ts +3 -3
  174. package/templates/module/__model__.signal.ts +11 -10
  175. package/templates/module/__model__.store.ts +3 -5
  176. package/templates/service/__model__.dictionary.ts +5 -6
  177. package/templates/service/__model__.service.ts +3 -3
  178. package/templates/service/__model__.signal.ts +5 -4
  179. package/templates/service/__model__.store.ts +3 -5
  180. package/templates/workspaceRoot/.gitignore.template +4 -0
  181. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  182. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  183. package/{tunnel.command-ycmja19q.js → tunnel.command-dcb0wg93.js} +25 -13
  184. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  185. package/typecheck.proc.js +6 -1
  186. package/verify.command-yyepccbh.js +93 -0
  187. package/{workflow.command-abb1d5xy.js → workflow.command-z5pg9ay0.js} +49 -14
  188. package/workspace.command-d7x5jttw.js +290 -0
  189. package/CodeAgent-8d5qs787.js +0 -9
  190. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  191. package/TunnelShare-qkm8zp03.js +0 -14
  192. package/agent.command-ydftceda.js +0 -25
  193. package/cloud.script-nqevg5qw.js +0 -24
  194. package/code.command-9h3yrzhe.js +0 -167
  195. package/context.runner-8gg030b0.js +0 -25
  196. package/guidelines/conventions/conventions.instruction.md +0 -617
  197. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  198. package/index-2mwc0g0d.js +0 -49
  199. package/index-4vgbysa0.js +0 -279
  200. package/index-7md2g9vw.js +0 -6
  201. package/index-b70zct19.js +0 -856
  202. package/index-c6eggbee.js +0 -123
  203. package/index-zzvvc845.js +0 -74
  204. package/quality.command-ah8qcakd.js +0 -1478
  205. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  206. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  207. package/workspace.command-qm7cw29v.js +0 -521
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getDirname2,
4
4
  FileSys2
5
- } from "./index-52w0fvh8.js";
5
+ } from "./index-bns3wcpc.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/executors.ts
8
8
  import {
@@ -22,7 +22,7 @@ import {
22
22
  stat as stat2,
23
23
  symlink
24
24
  } from "fs/promises";
25
- import path13 from "path";
25
+ import path14 from "path";
26
26
  import { pathToFileURL } from "url";
27
27
  import {
28
28
  capitalize,
@@ -49,7 +49,7 @@ ${block}`;
49
49
  var extractBlockVersion = (content) => content.match(/<!-- akan:agent:version ([^\s]+) -->/)?.[1] ?? null;
50
50
  var readDevkitVersion = async () => {
51
51
  const { readFile } = await import("fs/promises");
52
- const { getDirname } = await import("./fileSys-wzzrntkw.js");
52
+ const { getDirname } = await import("./fileSys-zpvt5gtf.js");
53
53
  try {
54
54
  const raw = await readFile(`${getDirname(import.meta.url)}/package.json`, "utf-8");
55
55
  return JSON.parse(raw).version ?? null;
@@ -123,16 +123,16 @@ var renderScopeAgentBlock = (scope, recipes) => {
123
123
  const scopePath = `${scope.type}s/${scope.name}`;
124
124
  const intro = `## Recipes In Scope
125
125
 
126
- UI recipes importable from \`${scopePath}\` code, **in addition to** the framework recipes indexed in the root
127
- \`AGENTS.md\` \`## Recipes\`. Same contract: import by exact name, then \`<name>(variants?, className?)\` \u2014 the second
126
+ UI recipes importable from \`${scopePath}\` code, **in addition to** the framework recipes indexed in
127
+ \`.claude/rules/akan/style.md\`. Same contract: import by exact name, then \`<name>(variants?, className?)\` \u2014 the second
128
128
  arg merges internally and takes an array too, so never wrap it in \`cn()\`. \`*\` marks the default, \`key?\` is a
129
129
  boolean flag. Do not guess recipe names or import paths; this index is regenerated by \`akan sync ${scope.name}\`
130
130
  and verified by \`akan lint ${scope.name}\`.`;
131
131
  if (recipes.length === 0) {
132
132
  return `${intro}
133
133
 
134
- No scope recipes yet. Before inlining a repeated surface (card, box, tile, \u2026), reuse a framework recipe from the
135
- root \`AGENTS.md\` or author one as \`${scopePath}/ui/Recipe/<name>.ts\` (one recipe per file, re-exported from that
134
+ No scope recipes yet. Before inlining a repeated surface (card, box, tile, \u2026), reuse a framework recipe from
135
+ \`.claude/rules/akan/style.md\` or author one as \`${scopePath}/ui/Recipe/<name>.ts\` (one recipe per file, re-exported from that
136
136
  folder's \`index.ts\`) \u2014 see the \`recipeRule\` guideline.`;
137
137
  }
138
138
  return `${intro}
@@ -656,6 +656,7 @@ class AkanAppConfig {
656
656
  this.i18n = resolveAkanI18nConfig(config?.i18n);
657
657
  process.env.AKAN_PUBLIC_DEFAULT_LOCALE = this.i18n.defaultLocale;
658
658
  process.env.AKAN_PUBLIC_LOCALES = this.i18n.locales.join(",");
659
+ process.env.AKAN_PUBLIC_LOCALE_PREFIX = this.i18n.localePrefix ?? "always";
659
660
  this.api = {
660
661
  prefix: normalizeRoutePrefix(config?.api?.prefix) ?? "/api",
661
662
  websocketPrefix: normalizeRoutePrefix(config?.api?.websocketPrefix) ?? "/ws"
@@ -857,6 +858,8 @@ class AkanAppConfig {
857
858
  "deepLinks",
858
859
  "updates",
859
860
  "devtools",
861
+ "csp",
862
+ "openUrls",
860
863
  "ios",
861
864
  "android",
862
865
  "desktop"
@@ -988,6 +991,7 @@ class AkanAppConfig {
988
991
  ...this.basePaths.size ? { AKAN_PUBLIC_BASE_PATHS: [...this.basePaths].join(",") } : {},
989
992
  AKAN_PUBLIC_DEFAULT_LOCALE: this.i18n.defaultLocale,
990
993
  AKAN_PUBLIC_LOCALES: this.i18n.locales.join(","),
994
+ ...this.i18n.localePrefix === "as-needed" ? { AKAN_PUBLIC_LOCALE_PREFIX: this.i18n.localePrefix } : {},
991
995
  AKAN_PUBLIC_API_PREFIX: this.api.prefix,
992
996
  AKAN_PUBLIC_WS_PREFIX: this.api.websocketPrefix,
993
997
  AKAN_PUBLIC_OPERATION_MODE: "cloud",
@@ -997,6 +1001,11 @@ class AkanAppConfig {
997
1001
  ...this.web.csr ? {} : { AKAN_CSR: "false" }
998
1002
  };
999
1003
  }
1004
+ static localImageGuard = [
1005
+ "ARG AKAN_ALLOW_LOCAL_IMAGE",
1006
+ `RUN if [ "$AKAN_ALLOW_LOCAL_IMAGE" != "1" ]; then echo "This build ran with AKAN_PUBLIC_ENV=local, which serves the dev routes to every caller. Build with the environment it deploys to, or pass --build-arg AKAN_ALLOW_LOCAL_IMAGE=1." >&2; exit 1; fi`
1007
+ ].join(`
1008
+ `);
1000
1009
  dockerfileFor(environment, { lockfile = true } = {}) {
1001
1010
  return this.#makeDockerfile(environment, lockfile);
1002
1011
  }
@@ -1007,8 +1016,10 @@ class AkanAppConfig {
1007
1016
  const preRunScripts = this.#getDockerRunScripts(preRuns);
1008
1017
  const postRunScripts = this.#getDockerRunScripts(postRuns);
1009
1018
  const imageScript = this.#getDockerImageScript(image, DEFAULT_DOCKER_IMAGE);
1019
+ const isLocal = (environment ?? this.baseDevEnv.env) === "local";
1010
1020
  const envLines = Object.entries(this.getProductionEnv(environment)).map(([key, value]) => `ENV ${key}=${value}`);
1011
- return `${imageScript}
1021
+ return `${imageScript}${isLocal ? `
1022
+ ${AkanAppConfig.localImageGuard}` : ""}
1012
1023
  RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
1013
1024
  RUN ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
1014
1025
  ARG TARGETARCH
@@ -1115,7 +1126,15 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
1115
1126
  static get akanVersion() {
1116
1127
  return getAkanPackageJson().version;
1117
1128
  }
1129
+ static #registryPins(pins) {
1130
+ if (!pins)
1131
+ return;
1132
+ const kept = Object.entries(pins).filter(([, spec]) => !/^(?:file:|link:|workspace:|portal:|[./~])/.test(spec));
1133
+ return kept.length ? Object.fromEntries(kept) : undefined;
1134
+ }
1118
1135
  getProductionPackageJson(data = {}) {
1136
+ const overrides = AkanAppConfig.#registryPins(this.rootPackageJson.overrides);
1137
+ const resolutions = AkanAppConfig.#registryPins(this.rootPackageJson.resolutions);
1119
1138
  return {
1120
1139
  name: this.app.name,
1121
1140
  description: this.app.name,
@@ -1126,6 +1145,8 @@ CMD [${command.map((c) => `"${c}"`).join(",")}]`;
1126
1145
  this.#resolveProductionDependencyVersion(lib)
1127
1146
  ])),
1128
1147
  ...this.trustedDependencies.length ? { trustedDependencies: this.trustedDependencies } : {},
1148
+ ...overrides ? { overrides } : {},
1149
+ ...resolutions ? { resolutions } : {},
1129
1150
  ...data
1130
1151
  };
1131
1152
  }
@@ -1353,7 +1374,7 @@ async function writeGeneratedOverridesLayoutFile(opts) {
1353
1374
  const filename = `${opts.key.replace(/^\.\//, "").replace(/[^a-zA-Z0-9]+/g, "_")}.tsx`;
1354
1375
  const absPath = path6.join(path6.resolve(opts.appCwdPath), IMPLICIT_OVERRIDES_DIR, filename);
1355
1376
  const source = `"use client";
1356
- import { UiOverrideProvider } from "akanjs/ui";
1377
+ import { UiOverrideProvider } from "akanjs/ui/UiOverride/UiOverride.tsx";
1357
1378
  import { createElement, type ReactNode } from "react";
1358
1379
  import value from ${JSON.stringify(importSpecifier(absPath, opts.userAbsPath))};
1359
1380
 
@@ -1493,7 +1514,7 @@ ${layoutBinding} return `;
1493
1514
  const source = opts.includeSystemProvider ? `import type { LayoutModule, LayoutProps, PageProps } from "akanjs/client";
1494
1515
  import { assertGuardOnChain, loadFonts, RouteGuards, resolveRouteModule, RouteHead } from "akanjs/client";
1495
1516
  import type { ReactNode } from "react";
1496
- import { System } from "akanjs/ui";
1517
+ import { System } from "akanjs/ui/System/index.tsx";
1497
1518
  import type { McpAppRootProps } from "akanjs/webkit";
1498
1519
  import { env } from "@apps/${opts.appName}/env/env.client";
1499
1520
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
@@ -1715,14 +1736,69 @@ class CodegenLock {
1715
1736
  }
1716
1737
  }
1717
1738
 
1718
- // pkgs/@akanjs/devkit/jsonFormatter.ts
1739
+ // pkgs/@akanjs/devkit/envSeed.ts
1719
1740
  import path8 from "path";
1741
+ class EnvSeed {
1742
+ static #server = `import type { ModulesOptions } from "../lib/option";
1743
+
1744
+ export const env: ModulesOptions = {};
1745
+ `;
1746
+ static #testingServer = `import type { ModulesOptions } from "../lib/option";
1747
+ import { libEnv } from "./env.server.type";
1748
+
1749
+ export const env: ModulesOptions = {
1750
+ ...libEnv,
1751
+ };
1752
+ `;
1753
+ static #client = `import type { AppClientEnv } from "./env.client.type";
1754
+
1755
+ export const env: AppClientEnv = {};
1756
+ `;
1757
+ static #untypedClient = `export const env = {};
1758
+ `;
1759
+ static #selectors = ["env.server.ts", "env.client.ts"];
1760
+ static #selectedPattern = /^\.\/(env\.(?:server|client)\.(?!(?:type|example)$)[\w-]+)$/;
1761
+ static #testing = "env.server.testing.ts";
1762
+ #envDir;
1763
+ constructor(envDir) {
1764
+ this.#envDir = envDir;
1765
+ }
1766
+ async missing() {
1767
+ const wanted = [...new Set([EnvSeed.#testing, ...await this.#selected()])].sort();
1768
+ const exists = await Promise.all(wanted.map((fileName) => FileSys2.fileExists(path8.join(this.#envDir, fileName))));
1769
+ const missing = wanted.filter((_, idx) => !exists[idx]);
1770
+ return await Promise.all(missing.map(async (fileName) => ({ fileName, content: await this.#contentOf(fileName) })));
1771
+ }
1772
+ async#selected() {
1773
+ const transpiler = new Bun.Transpiler({ loader: "ts" });
1774
+ const selected = await Promise.all(EnvSeed.#selectors.map(async (selector) => {
1775
+ const file = path8.join(this.#envDir, selector);
1776
+ if (!await FileSys2.fileExists(file))
1777
+ return [];
1778
+ return transpiler.scan(await FileSys2.readText(file)).imports.flatMap(({ path: specifier }) => specifier.match(EnvSeed.#selectedPattern)?.[1] ?? []).map((name) => `${name}.ts`);
1779
+ }));
1780
+ return selected.flat();
1781
+ }
1782
+ async#contentOf(fileName) {
1783
+ const side = fileName.startsWith("env.client.") ? "client" : "server";
1784
+ const example = path8.join(this.#envDir, `env.${side}.example.ts`);
1785
+ if (await FileSys2.fileExists(example))
1786
+ return await FileSys2.readText(example);
1787
+ if (side === "server")
1788
+ return fileName === EnvSeed.#testing ? EnvSeed.#testingServer : EnvSeed.#server;
1789
+ const typed = await FileSys2.fileExists(path8.join(this.#envDir, "env.client.type.ts"));
1790
+ return typed ? EnvSeed.#client : EnvSeed.#untypedClient;
1791
+ }
1792
+ }
1793
+
1794
+ // pkgs/@akanjs/devkit/jsonFormatter.ts
1795
+ import path9 from "path";
1720
1796
 
1721
1797
  class JsonFormatter {
1722
1798
  static lineWidth = 120;
1723
1799
  static stringify(value, filePath) {
1724
1800
  const json = JSON.stringify(value, null, 2);
1725
- if (path8.basename(filePath) === "package.json")
1801
+ if (path9.basename(filePath) === "package.json")
1726
1802
  return `${json}
1727
1803
  `;
1728
1804
  return `${JsonFormatter.#print(JSON.parse(json), 0, { column: 0, trailing: 0 })}
@@ -1793,7 +1869,7 @@ ${" ".repeat(depth)}]`;
1793
1869
  // pkgs/@akanjs/devkit/linter.ts
1794
1870
  import { spawn } from "child_process";
1795
1871
  import { existsSync as existsSync2, readFileSync } from "fs";
1796
- import path9 from "path";
1872
+ import path10 from "path";
1797
1873
  import chalk from "chalk";
1798
1874
  var parseBiomeReport = (output) => {
1799
1875
  for (let start = output.indexOf("{");start !== -1; start = output.indexOf("{", start + 1)) {
@@ -1854,7 +1930,7 @@ var emptyResult = (filePath) => ({
1854
1930
 
1855
1931
  class Linter {
1856
1932
  static biomeCommand(root) {
1857
- const wrapper = path9.join(root, "node_modules", "@biomejs", "biome", "bin", "biome");
1933
+ const wrapper = path10.join(root, "node_modules", "@biomejs", "biome", "bin", "biome");
1858
1934
  return existsSync2(wrapper) ? [process.execPath, wrapper] : ["biome"];
1859
1935
  }
1860
1936
  lintRoot;
@@ -1862,12 +1938,12 @@ class Linter {
1862
1938
  #biomeCommand;
1863
1939
  constructor(cwdPath) {
1864
1940
  this.lintRoot = this.#findBiomeRootPath(cwdPath);
1865
- this.configPath = Linter.#configPathIn(this.lintRoot) ?? path9.join(this.lintRoot, "biome.json");
1941
+ this.configPath = Linter.#configPathIn(this.lintRoot) ?? path10.join(this.lintRoot, "biome.json");
1866
1942
  this.#biomeCommand = Linter.biomeCommand(this.lintRoot);
1867
1943
  }
1868
1944
  static #configPathIn(dir) {
1869
1945
  for (const fileName of BIOME_CONFIG_FILES) {
1870
- const configPath = path9.join(dir, fileName);
1946
+ const configPath = path10.join(dir, fileName);
1871
1947
  if (existsSync2(configPath))
1872
1948
  return configPath;
1873
1949
  }
@@ -1876,19 +1952,19 @@ class Linter {
1876
1952
  #findBiomeRootPath(dir) {
1877
1953
  if (Linter.#configPathIn(dir))
1878
1954
  return dir;
1879
- const parentDir = path9.dirname(dir);
1955
+ const parentDir = path10.dirname(dir);
1880
1956
  if (parentDir === dir)
1881
1957
  throw new Error(`biome.json not found from ${dir}`);
1882
1958
  return this.#findBiomeRootPath(parentDir);
1883
1959
  }
1884
1960
  #toBiomePath(filePath) {
1885
- const relativePath = path9.relative(this.lintRoot, filePath);
1886
- if (!relativePath.startsWith("..") && !path9.isAbsolute(relativePath))
1961
+ const relativePath = path10.relative(this.lintRoot, filePath);
1962
+ if (!relativePath.startsWith("..") && !path10.isAbsolute(relativePath))
1887
1963
  return relativePath;
1888
1964
  return filePath;
1889
1965
  }
1890
1966
  #resolveFilePath(filePath) {
1891
- return path9.isAbsolute(filePath) ? filePath : path9.join(this.lintRoot, filePath);
1967
+ return path10.isAbsolute(filePath) ? filePath : path10.join(this.lintRoot, filePath);
1892
1968
  }
1893
1969
  async#runBiome(args, input) {
1894
1970
  return await new Promise((resolve, reject) => {
@@ -1914,7 +1990,7 @@ class Linter {
1914
1990
  const diagnosticPath = diagnostic.location?.path;
1915
1991
  if (!diagnosticPath)
1916
1992
  return fallbackFilePath;
1917
- return path9.isAbsolute(diagnosticPath) ? diagnosticPath : path9.join(this.lintRoot, diagnosticPath);
1993
+ return path10.isAbsolute(diagnosticPath) ? diagnosticPath : path10.join(this.lintRoot, diagnosticPath);
1918
1994
  }
1919
1995
  #createLintMessage(diagnostic) {
1920
1996
  const start = diagnostic.location?.start;
@@ -2090,20 +2166,41 @@ ${errorText}, ${warningText} found`];
2090
2166
  if (resolved.length === 0)
2091
2167
  return { fixed: [] };
2092
2168
  const before = new Map(resolved.map((filePath) => [filePath, readFileSync(filePath, "utf8")]));
2093
- await this.#runBiome([
2094
- "check",
2095
- "--write",
2096
- "--reporter=json",
2097
- "--max-diagnostics=none",
2098
- "--no-errors-on-unmatched",
2099
- "--config-path",
2100
- this.configPath,
2101
- ...resolved.map((filePath) => this.#toBiomePath(filePath))
2102
- ]);
2169
+ const biomePaths = resolved.map((filePath) => this.#toBiomePath(filePath));
2170
+ for (const batch of Linter.batchArgs(biomePaths, Linter.#pathArgsBudget))
2171
+ await this.#runBiome([
2172
+ "check",
2173
+ "--write",
2174
+ "--reporter=json",
2175
+ "--max-diagnostics=none",
2176
+ "--no-errors-on-unmatched",
2177
+ "--config-path",
2178
+ this.configPath,
2179
+ ...batch
2180
+ ]);
2103
2181
  return {
2104
2182
  fixed: resolved.filter((filePath) => readFileSync(filePath, "utf8") !== before.get(filePath))
2105
2183
  };
2106
2184
  }
2185
+ static #pathArgsBudget = 24000;
2186
+ static batchArgs(args, budget) {
2187
+ const batches = [];
2188
+ let batch = [];
2189
+ let length = 0;
2190
+ for (const arg of args) {
2191
+ const cost = arg.length + 3;
2192
+ if (batch.length > 0 && length + cost > budget) {
2193
+ batches.push(batch);
2194
+ batch = [];
2195
+ length = 0;
2196
+ }
2197
+ batch.push(arg);
2198
+ length += cost;
2199
+ }
2200
+ if (batch.length > 0)
2201
+ batches.push(batch);
2202
+ return batches;
2203
+ }
2107
2204
  async getConfigForFile(filePath) {
2108
2205
  const resolvedFilePath = this.#resolveFilePath(filePath);
2109
2206
  if (!existsSync2(resolvedFilePath))
@@ -2250,7 +2347,7 @@ class ManifestDependencies {
2250
2347
 
2251
2348
  // pkgs/@akanjs/devkit/repoIdentity.ts
2252
2349
  import { execFileSync } from "child_process";
2253
- import path10 from "path";
2350
+ import path11 from "path";
2254
2351
  var resolved = new Map;
2255
2352
  var readRemoteName = (workspaceRoot) => {
2256
2353
  try {
@@ -2268,20 +2365,21 @@ var resolveRepoName = (workspaceRoot) => {
2268
2365
  const cached = resolved.get(workspaceRoot);
2269
2366
  if (cached)
2270
2367
  return cached;
2271
- const repoName = readRemoteName(workspaceRoot) ?? path10.basename(workspaceRoot);
2368
+ const repoName = readRemoteName(workspaceRoot) ?? path11.basename(workspaceRoot);
2272
2369
  resolved.set(workspaceRoot, repoName);
2273
2370
  return repoName;
2274
2371
  };
2275
2372
 
2276
2373
  // pkgs/@akanjs/devkit/scanInfo.ts
2277
2374
  import { createHash } from "crypto";
2278
- import path11 from "path";
2375
+ import path12 from "path";
2279
2376
 
2280
2377
  // pkgs/@akanjs/devkit/workspaceLayout.ts
2281
2378
  var appRootAllowedFiles = new Set([
2282
2379
  "AGENTS.md",
2283
2380
  "CLAUDE.md",
2284
2381
  "akan.app.json",
2382
+ "akan.baseline.json",
2285
2383
  "akan.config.ts",
2286
2384
  "client.ts",
2287
2385
  "main.ts",
@@ -2310,6 +2408,7 @@ var libRootAllowedFiles = new Set([
2310
2408
  "AGENTS.md",
2311
2409
  "CLAUDE.md",
2312
2410
  "README.md",
2411
+ "akan.baseline.json",
2313
2412
  "akan.config.ts",
2314
2413
  "akan.lib.json",
2315
2414
  "client.ts",
@@ -2396,10 +2495,10 @@ var moduleUiFileTypes = {
2396
2495
  service: new Set(["Util", "Zone"]),
2397
2496
  scalar: new Set(["Template", "Unit"])
2398
2497
  };
2399
- var createDependencyScanner = async (exec) => (await import("./dependencyScanner-3afj2vt1.js")).TypeScriptDependencyScanner.from(exec);
2400
- var getScanPath = (exec, relativePath) => path11.posix.join(`${exec.type}s`, exec.name, relativePath.split(path11.sep).join("/"));
2498
+ var createDependencyScanner = async (exec) => (await import("./dependencyScanner-78sq8m4q.js")).TypeScriptDependencyScanner.from(exec);
2499
+ var getScanPath = (exec, relativePath) => path12.posix.join(`${exec.type}s`, exec.name, relativePath.split(path12.sep).join("/"));
2401
2500
  var getModuleNameFromPath = (kind, modulePath) => {
2402
- const dirname = path11.basename(modulePath);
2501
+ const dirname = path12.basename(modulePath);
2403
2502
  return kind === "service" ? dirname.replace(/^_+/, "") : dirname;
2404
2503
  };
2405
2504
  async function assertScanConvention(exec, libRoot) {
@@ -2420,24 +2519,24 @@ async function assertScanConvention(exec, libRoot) {
2420
2519
  for (const filename of await exec.readdir(facet)) {
2421
2520
  const shadow = facetIndexShadowOf(`${facet}/${filename}`);
2422
2521
  if (shadow)
2423
- addViolation(path11.join(facet, filename), shadow);
2522
+ addViolation(path12.join(facet, filename), shadow);
2424
2523
  }
2425
2524
  if (exec.type === "lib")
2426
2525
  for (const { relativePath, reason } of await exec.getPageConventionViolations())
2427
2526
  addViolation(relativePath, reason);
2428
2527
  for (const filename of libRoot.files)
2429
2528
  if (!isAllowedLibFacetRootFile(filename))
2430
- addViolation(path11.join("lib", filename), libFacetRootHintOf(filename) ?? "unsupported lib facet root file");
2529
+ addViolation(path12.join("lib", filename), libFacetRootHintOf(filename) ?? "unsupported lib facet root file");
2431
2530
  for (const dirname of libRoot.dirs)
2432
2531
  if (dirname.startsWith("__") && !internalLibDirs.has(dirname))
2433
- addViolation(path11.join("lib", dirname), "unsupported internal lib folder");
2532
+ addViolation(path12.join("lib", dirname), "unsupported internal lib folder");
2434
2533
  const databaseDirs = libRoot.dirs.filter((dirname) => !dirname.startsWith("_"));
2435
2534
  const serviceDirs = libRoot.dirs.filter((dirname) => dirname.startsWith("_") && !dirname.startsWith("__"));
2436
2535
  const scalarDirs = await exec.readdir("lib/__scalar");
2437
2536
  await Promise.all([
2438
- ...databaseDirs.map((dirname) => validateModuleFiles(exec, violations, "database", path11.join("lib", dirname))),
2439
- ...serviceDirs.map((dirname) => validateModuleFiles(exec, violations, "service", path11.join("lib", dirname))),
2440
- ...scalarDirs.map((dirname) => validateModuleFiles(exec, violations, "scalar", path11.join("lib/__scalar", dirname)))
2537
+ ...databaseDirs.map((dirname) => validateModuleFiles(exec, violations, "database", path12.join("lib", dirname))),
2538
+ ...serviceDirs.map((dirname) => validateModuleFiles(exec, violations, "service", path12.join("lib", dirname))),
2539
+ ...scalarDirs.map((dirname) => validateModuleFiles(exec, violations, "scalar", path12.join("lib/__scalar", dirname)))
2441
2540
  ]);
2442
2541
  if (violations.length > 0) {
2443
2542
  throw new Error(`[scan-convention]
@@ -2449,11 +2548,11 @@ async function validateModuleFiles(exec, violations, kind, modulePath) {
2449
2548
  const { files, dirs } = await exec.getFilesAndDirs(modulePath);
2450
2549
  const moduleName = getModuleNameFromPath(kind, modulePath);
2451
2550
  dirs.forEach((dirname) => {
2452
- violations.push(`${getScanPath(exec, path11.join(modulePath, dirname))}: unsupported module folder`);
2551
+ violations.push(`${getScanPath(exec, path12.join(modulePath, dirname))}: unsupported module folder`);
2453
2552
  });
2454
2553
  const uiModuleName = moduleName[0].toUpperCase() + moduleName.slice(1);
2455
2554
  for (const filename of files) {
2456
- const scanPath = getScanPath(exec, path11.join(modulePath, filename));
2555
+ const scanPath = getScanPath(exec, path12.join(modulePath, filename));
2457
2556
  if (filename === "index.ts" || filename === "index.tsx")
2458
2557
  continue;
2459
2558
  if (filename === `${moduleName}.abstract.md`)
@@ -2528,16 +2627,16 @@ class ScanInfo {
2528
2627
  }
2529
2628
  };
2530
2629
  await Promise.all([
2531
- ...databaseDirs.map((name) => collect(path11.join("lib", name), name, "databases")),
2532
- ...serviceDirs.map((dirname) => collect(path11.join("lib", dirname), dirname.slice(1), "services")),
2533
- ...scalarDirs.map((name) => collect(path11.join("lib/__scalar", name), name, "scalars"))
2630
+ ...databaseDirs.map((name) => collect(path12.join("lib", name), name, "databases")),
2631
+ ...serviceDirs.map((dirname) => collect(path12.join("lib", dirname), dirname.slice(1), "services")),
2632
+ ...scalarDirs.map((name) => collect(path12.join("lib/__scalar", name), name, "scalars"))
2534
2633
  ]);
2535
2634
  const routes = exec.type === "lib" ? [] : await exec.getPageKeys();
2536
2635
  const common = {
2537
2636
  name: exec.name,
2538
2637
  type: exec.type,
2539
2638
  repoName: exec.workspace.repoName,
2540
- serveDomain: WorkspaceExecutor.getBaseDevEnv(path11.join(exec.workspace.workspaceRoot, ".env")).serveDomain,
2639
+ serveDomain: WorkspaceExecutor.getBaseDevEnv(path12.join(exec.workspace.workspaceRoot, ".env")).serveDomain,
2541
2640
  files,
2542
2641
  libDeps,
2543
2642
  pkgDeps,
@@ -2850,8 +2949,20 @@ class Spinner {
2850
2949
 
2851
2950
  // pkgs/@akanjs/devkit/typecheck/projectTypecheck.ts
2852
2951
  import { mkdir as mkdir2, rm as rm3 } from "fs/promises";
2853
- import path12 from "path";
2952
+ import path13 from "path";
2953
+
2954
+ // pkgs/@akanjs/devkit/typecheck/typecheckFailure.ts
2955
+ class TypecheckFailure extends Error {
2956
+ records;
2957
+ constructor(records) {
2958
+ super(records.slice(0, 20).map((record) => `${record.file ?? "-"}:${record.line}:${record.col} ${record.code} ${record.message}`).join(`
2959
+ `) || "Typecheck failed");
2960
+ this.records = records;
2961
+ this.name = "TypecheckFailure";
2962
+ }
2963
+ }
2854
2964
 
2965
+ // pkgs/@akanjs/devkit/typecheck/projectTypecheck.ts
2855
2966
  class ProjectTypecheck2 {
2856
2967
  projectDir;
2857
2968
  workspaceRoot;
@@ -2864,9 +2975,9 @@ class ProjectTypecheck2 {
2864
2975
  this.env = env;
2865
2976
  }
2866
2977
  get typecheckDir() {
2867
- return path12.join(this.projectDir, ".akan", "typecheck");
2978
+ return path13.join(this.projectDir, ".akan", "typecheck");
2868
2979
  }
2869
- async run(entries, { clean = false, incremental = true, tests = false } = {}) {
2980
+ async run(entries, { clean = false, incremental = true, tests = false, report = "pretty" } = {}) {
2870
2981
  const name = tests ? "tsconfig.tests" : "tsconfig";
2871
2982
  await mkdir2(this.typecheckDir, { recursive: true });
2872
2983
  const tsconfig = {
@@ -2876,18 +2987,23 @@ class ProjectTypecheck2 {
2876
2987
  ...tests ? { exclude: ProjectTypecheck2.#excludes.map((glob) => `../../${glob}`) } : {},
2877
2988
  references: []
2878
2989
  };
2879
- const tsconfigPath = path12.join(this.typecheckDir, `${name}.json`);
2990
+ const tsconfigPath = path13.join(this.typecheckDir, `${name}.json`);
2880
2991
  await Bun.write(tsconfigPath, `${JSON.stringify(tsconfig, null, 2)}
2881
2992
  `);
2882
2993
  if (clean)
2883
- await rm3(path12.join(this.typecheckDir, `${name}.tsbuildinfo`), { force: true });
2884
- await this.#check(tsconfigPath);
2994
+ await rm3(path13.join(this.typecheckDir, `${name}.tsbuildinfo`), { force: true });
2995
+ await this.check(tsconfigPath, report);
2885
2996
  return tsconfigPath;
2886
2997
  }
2887
- async#check(tsconfigPath) {
2998
+ async check(tsconfigPath, report = "pretty") {
2888
2999
  const proc = Bun.spawn([process.execPath, await ProjectTypecheck2.workerEntry(this.workspaceRoot)], {
2889
3000
  cwd: this.workspaceRoot,
2890
- env: { ...this.env, AKAN_COMMAND_TYPE: "typecheck", AKAN_TYPECHECK_TSCONFIG: tsconfigPath },
3001
+ env: {
3002
+ ...this.env,
3003
+ AKAN_COMMAND_TYPE: "typecheck",
3004
+ AKAN_TYPECHECK_TSCONFIG: tsconfigPath,
3005
+ ...report === "records" ? { AKAN_TYPECHECK_FORMAT: "json", AKAN_TYPECHECK_ROOT: this.workspaceRoot } : {}
3006
+ },
2891
3007
  stdout: "pipe",
2892
3008
  stderr: "pipe"
2893
3009
  });
@@ -2896,16 +3012,28 @@ class ProjectTypecheck2 {
2896
3012
  new Response(proc.stderr).text(),
2897
3013
  proc.exited
2898
3014
  ]);
2899
- if (exitCode !== 0)
2900
- throw new Error((stderr || stdout).trim() || `Typecheck failed with exit code ${exitCode}`);
3015
+ if (exitCode === 0)
3016
+ return;
3017
+ const records = report === "records" ? ProjectTypecheck2.#parseRecords(stdout) : null;
3018
+ if (records?.length)
3019
+ throw new TypecheckFailure(records);
3020
+ throw new Error((stderr || stdout).trim() || `Typecheck failed with exit code ${exitCode}`);
3021
+ }
3022
+ static #parseRecords(stdout) {
3023
+ try {
3024
+ const parsed = JSON.parse(stdout);
3025
+ return Array.isArray(parsed) ? parsed : null;
3026
+ } catch {
3027
+ return null;
3028
+ }
2901
3029
  }
2902
3030
  static async workerEntry(workspaceRoot) {
2903
3031
  const candidates = [
2904
- path12.join(workspaceRoot, "pkgs/@akanjs/devkit/typecheck/typecheck.proc.ts"),
2905
- path12.join(workspaceRoot, "node_modules/@akanjs/devkit/typecheck/typecheck.proc.ts"),
2906
- path12.join(import.meta.dir, "typecheck.proc.js"),
2907
- path12.join(import.meta.dir, "typecheck.proc.ts"),
2908
- path12.join(import.meta.dir, "..", "typecheck.proc.js")
3032
+ path13.join(workspaceRoot, "pkgs/@akanjs/devkit/typecheck/typecheck.proc.ts"),
3033
+ path13.join(workspaceRoot, "node_modules/@akanjs/devkit/typecheck/typecheck.proc.ts"),
3034
+ path13.join(import.meta.dir, "typecheck.proc.js"),
3035
+ path13.join(import.meta.dir, "typecheck.proc.ts"),
3036
+ path13.join(import.meta.dir, "..", "typecheck.proc.js")
2909
3037
  ];
2910
3038
  for (const candidate of candidates)
2911
3039
  if (await Bun.file(candidate).exists())
@@ -3073,10 +3201,10 @@ class Executor {
3073
3201
  return this.#settle(proc, target, { redStderr: true }).then(({ code, signal }) => ({ code, signal }));
3074
3202
  }
3075
3203
  getPath(filePath) {
3076
- if (path13.isAbsolute(filePath))
3204
+ if (path14.isAbsolute(filePath))
3077
3205
  return filePath;
3078
3206
  if (filePath.startsWith("."))
3079
- return path13.join(this.cwdPath, filePath);
3207
+ return path14.join(this.cwdPath, filePath);
3080
3208
  const baseParts = this.cwdPath.split(/[\\/]/).filter(Boolean);
3081
3209
  const targetParts = filePath.split(/[\\/]/).filter(Boolean);
3082
3210
  let overlapLength = 0;
@@ -3090,7 +3218,7 @@ class Executor {
3090
3218
  if (isOverlap)
3091
3219
  overlapLength = i;
3092
3220
  }
3093
- return path13.join(this.cwdPath, ...targetParts.slice(overlapLength));
3221
+ return path14.join(this.cwdPath, ...targetParts.slice(overlapLength));
3094
3222
  }
3095
3223
  async mkdir(dirPath) {
3096
3224
  const writePath = this.getPath(dirPath);
@@ -3131,7 +3259,7 @@ class Executor {
3131
3259
  return this;
3132
3260
  }
3133
3261
  async removeDir(dirPath) {
3134
- const readPath = path13.join(this.getPath(dirPath), ".");
3262
+ const readPath = path14.join(this.getPath(dirPath), ".");
3135
3263
  if (await FileSys2.entryExists(readPath))
3136
3264
  await rm4(readPath, { recursive: true, force: true });
3137
3265
  this.logger.verbose(`Remove directory ${readPath}`);
@@ -3139,7 +3267,7 @@ class Executor {
3139
3267
  }
3140
3268
  async writeFile(filePath, content, { overwrite = true, silent = false } = {}) {
3141
3269
  const writePath = this.getPath(filePath);
3142
- const dir = path13.dirname(writePath);
3270
+ const dir = path14.dirname(writePath);
3143
3271
  if (!await FileSys2.dirExists(dir))
3144
3272
  await mkdir3(dir, { recursive: true });
3145
3273
  let contentStr = typeof content === "string" ? content : JsonFormatter.stringify(content, writePath);
@@ -3166,7 +3294,7 @@ class Executor {
3166
3294
  await this.writeFile(filePath, content);
3167
3295
  }
3168
3296
  async getLocalFile(targetPath) {
3169
- const filePath = path13.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
3297
+ const filePath = path14.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
3170
3298
  const content = await this.readFile(filePath);
3171
3299
  return { filePath, content };
3172
3300
  }
@@ -3245,7 +3373,8 @@ class Executor {
3245
3373
  templatePath,
3246
3374
  targetPath,
3247
3375
  scanInfo,
3248
- overwrite = true
3376
+ overwrite = true,
3377
+ dryRun = false
3249
3378
  }, dict = {}, options = {}) {
3250
3379
  const convertPath = (target) => Object.entries(dict).reduce((converted, [key, value]) => converted.replace(new RegExp(`__${key}__`, "g"), value), target);
3251
3380
  if (targetPath.endsWith(".ts") || targetPath.endsWith(".tsx")) {
@@ -3253,23 +3382,29 @@ class Executor {
3253
3382
  const result = await getContent.default(scanInfo ?? null, dict, options);
3254
3383
  if (result === null)
3255
3384
  return null;
3256
- const filename = typeof result === "object" ? result.filename : path13.basename(targetPath).replace(".js", ".ts");
3385
+ const filename = typeof result === "object" ? result.filename : path14.basename(targetPath).replace(".js", ".ts");
3257
3386
  const content = typeof result === "object" ? result.content : result;
3258
- const convertedTargetPath = convertPath(`${path13.dirname(targetPath)}/${filename}`);
3387
+ const convertedTargetPath = convertPath(`${path14.dirname(targetPath)}/${filename}`);
3388
+ if (dryRun)
3389
+ return { filePath: this.getPath(convertedTargetPath), content, written: false };
3259
3390
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
3260
3391
  return this.writeFile(convertedTargetPath, content, { overwrite });
3261
3392
  } else if (targetPath.endsWith(".template")) {
3262
3393
  const content = await FileSys2.readText(templatePath);
3263
3394
  const convertedTargetPath = convertPath(targetPath.slice(0, -9));
3264
3395
  const convertedContent = Object.entries(dict).reduce((data, [key, value]) => data.replace(new RegExp(`<%= ${key} %>`, "g"), value), content);
3396
+ if (dryRun)
3397
+ return { filePath: this.getPath(convertedTargetPath), content: convertedContent, written: false };
3265
3398
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
3266
3399
  return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
3267
- } else if (staticTemplateFileExtensions.has(path13.extname(targetPath).toLowerCase())) {
3400
+ } else if (staticTemplateFileExtensions.has(path14.extname(targetPath).toLowerCase())) {
3268
3401
  const convertedTargetPath = convertPath(targetPath);
3269
3402
  const writePath = this.getPath(convertedTargetPath);
3403
+ if (dryRun)
3404
+ return { filePath: writePath, content: "", written: false };
3270
3405
  if (!overwrite && await FileSys2.fileExists(writePath))
3271
3406
  return { filePath: writePath, content: "", written: false };
3272
- const dirname = path13.dirname(writePath);
3407
+ const dirname = path14.dirname(writePath);
3273
3408
  if (!await FileSys2.dirExists(dirname))
3274
3409
  await mkdir3(dirname, { recursive: true });
3275
3410
  await copyFile(templatePath, writePath);
@@ -3284,37 +3419,41 @@ class Executor {
3284
3419
  scanInfo,
3285
3420
  dict = {},
3286
3421
  options = {},
3287
- overwrite = true
3422
+ overwrite = true,
3423
+ dryRun = false
3288
3424
  }) {
3289
3425
  const templateRoot = await this.#resolveTemplateRoot();
3290
3426
  const templatePath = `${templateRoot}${template ? `/${template}` : ""}`;
3291
3427
  if ((await stat2(templatePath)).isFile()) {
3292
3428
  const fileContent = await this.#applyTemplateFile({
3293
3429
  templatePath,
3294
- targetPath: path13.join(basePath, path13.basename(templatePath)),
3430
+ targetPath: path14.join(basePath, path14.basename(templatePath)),
3295
3431
  scanInfo,
3296
- overwrite
3432
+ overwrite,
3433
+ dryRun
3297
3434
  }, dict, options);
3298
3435
  return fileContent ? [fileContent] : [];
3299
3436
  } else {
3300
3437
  const subdirs = await readDirEntries(templatePath);
3301
3438
  const fileContents = (await Promise.all(subdirs.map(async (subdir) => {
3302
- const subpath = path13.join(templatePath, subdir);
3439
+ const subpath = path14.join(templatePath, subdir);
3303
3440
  if ((await stat2(subpath)).isFile()) {
3304
3441
  const fileContent = await this.#applyTemplateFile({
3305
3442
  templatePath: subpath,
3306
- targetPath: path13.join(basePath, subdir),
3443
+ targetPath: path14.join(basePath, subdir),
3307
3444
  scanInfo,
3308
- overwrite
3445
+ overwrite,
3446
+ dryRun
3309
3447
  }, dict, options);
3310
3448
  return fileContent ? [fileContent] : [];
3311
3449
  } else
3312
3450
  return await this._applyTemplate({
3313
- basePath: path13.join(basePath, subdir),
3314
- template: path13.join(template, subdir),
3451
+ basePath: path14.join(basePath, subdir),
3452
+ template: path14.join(template, subdir),
3315
3453
  scanInfo,
3316
3454
  dict,
3317
3455
  overwrite,
3456
+ dryRun,
3318
3457
  options
3319
3458
  });
3320
3459
  }))).flat();
@@ -3323,8 +3462,8 @@ class Executor {
3323
3462
  }
3324
3463
  async#resolveTemplateRoot() {
3325
3464
  const candidates = [
3326
- path13.resolve(getDirname2(import.meta.url), "templates"),
3327
- path13.resolve(getDirname2(import.meta.url), "../cli/templates")
3465
+ path14.resolve(getDirname2(import.meta.url), "templates"),
3466
+ path14.resolve(getDirname2(import.meta.url), "../cli/templates")
3328
3467
  ];
3329
3468
  for (const candidate of candidates) {
3330
3469
  if (await FileSys2.dirExists(candidate))
@@ -3350,7 +3489,7 @@ class Executor {
3350
3489
  }
3351
3490
  }
3352
3491
  async getTypeChecker() {
3353
- const { TypeChecker } = await import("./typeChecker-px49mezc.js");
3492
+ const { TypeChecker } = await import("./typeChecker-j2jdnqsr.js");
3354
3493
  this.typeChecker ??= new TypeChecker(this);
3355
3494
  return this.typeChecker;
3356
3495
  }
@@ -3430,7 +3569,7 @@ class WorkspaceExecutor extends Executor {
3430
3569
  const appName = sourceEnv.AKAN_PUBLIC_APP_NAME;
3431
3570
  const workspaceRoot = sourceEnv.AKAN_WORKSPACE_ROOT;
3432
3571
  const workspaceId = sourceEnv.AKAN_WORKSPACE_ID;
3433
- const repoName = sourceEnv.AKAN_PUBLIC_REPO_NAME || resolveRepoName(envPath ? path13.dirname(envPath) : workspaceRoot ?? process.cwd());
3572
+ const repoName = sourceEnv.AKAN_PUBLIC_REPO_NAME || resolveRepoName(envPath ? path14.dirname(envPath) : workspaceRoot ?? process.cwd());
3434
3573
  const serveDomain = sourceEnv.AKAN_PUBLIC_SERVE_DOMAIN || WorkspaceExecutor.localServeDomain;
3435
3574
  const defaulted = ["AKAN_PUBLIC_REPO_NAME", "AKAN_PUBLIC_SERVE_DOMAIN"].filter((key) => !sourceEnv[key]);
3436
3575
  const portOffset = parseInt(sourceEnv.PORT_OFFSET ?? "0");
@@ -3448,6 +3587,10 @@ class WorkspaceExecutor extends Executor {
3448
3587
  defaulted
3449
3588
  };
3450
3589
  }
3590
+ static defaultCloneToLocalEnv(workspaceRoot) {
3591
+ if (!existsSync3(path14.join(workspaceRoot, ".env")))
3592
+ process.env.AKAN_PUBLIC_ENV ??= "local";
3593
+ }
3451
3594
  static assertDeployableEnv(baseDevEnv, environment, purpose) {
3452
3595
  const defaulted = environment === "local" ? [] : baseDevEnv.defaulted ?? [];
3453
3596
  if (!defaulted.length)
@@ -3520,7 +3663,7 @@ class WorkspaceExecutor extends Executor {
3520
3663
  await Promise.all(dirs.map(async (dir) => {
3521
3664
  if (dir.includes("_") || AVOID_DIRS.includes(dir))
3522
3665
  return;
3523
- const dirPath = path13.join(dirname, dir);
3666
+ const dirPath = path14.join(dirname, dir);
3524
3667
  if ((await stat2(dirPath)).isDirectory()) {
3525
3668
  results.push(`${prefix}${dir}`);
3526
3669
  if (maxDepth > 0)
@@ -3531,12 +3674,17 @@ class WorkspaceExecutor extends Executor {
3531
3674
  };
3532
3675
  return await getDirs(basePath);
3533
3676
  }
3534
- async commit(message, { init = false, add = true } = {}) {
3677
+ async commit(message, {
3678
+ init = false,
3679
+ add = true,
3680
+ identity
3681
+ } = {}) {
3535
3682
  if (init)
3536
3683
  await this.spawn("git", ["init", "--quiet"]);
3537
3684
  if (add)
3538
3685
  await this.spawn("git", ["add", "."]);
3539
- await this.spawn("git", ["commit", "--quiet", "-m", message]);
3686
+ const author = identity ? ["-c", `user.name=${identity.name}`, "-c", `user.email=${identity.email}`] : [];
3687
+ await this.spawn("git", [...author, "commit", "--quiet", "-m", message]);
3540
3688
  }
3541
3689
  async hasChanges() {
3542
3690
  return !!(await this.spawn("git", ["status", "--porcelain"])).trim();
@@ -3557,9 +3705,9 @@ class WorkspaceExecutor extends Executor {
3557
3705
  await Promise.all(dirs.map(async (dir) => {
3558
3706
  if (AVOID_DIRS.includes(dir))
3559
3707
  return;
3560
- const dirPath = path13.join(dirname, dir);
3708
+ const dirPath = path14.join(dirname, dir);
3561
3709
  if (await FileSys2.dirExists(dirPath)) {
3562
- const hasTargetFile = await FileSys2.fileExists(path13.join(dirPath, targetFilename));
3710
+ const hasTargetFile = await FileSys2.fileExists(path14.join(dirPath, targetFilename));
3563
3711
  if (hasTargetFile)
3564
3712
  results.push(`${prefix}${dir}`);
3565
3713
  if (maxDepth > 0)
@@ -3618,7 +3766,7 @@ class SysExecutor extends Executor {
3618
3766
  return [];
3619
3767
  const violations = [];
3620
3768
  for (const entry of await this.getAllFiles("**/*", { cwd: this.getPath("page") })) {
3621
- const relativePath = entry.split(path13.sep).join("/");
3769
+ const relativePath = entry.split(path14.sep).join("/");
3622
3770
  const reason = getPageSourceFileViolation(relativePath);
3623
3771
  if (reason)
3624
3772
  violations.push({ relativePath: `page/${relativePath}`, reason });
@@ -3636,8 +3784,18 @@ class SysExecutor extends Executor {
3636
3784
  throw new Error("Scan info is not available");
3637
3785
  return this.#scanInfo;
3638
3786
  }
3787
+ async#seedEnvFiles() {
3788
+ const envDir = path14.join(this.cwdPath, "env");
3789
+ const missing = await new EnvSeed(envDir).missing();
3790
+ if (!missing.length)
3791
+ return [];
3792
+ const written = await Promise.all(missing.map(({ fileName, content }) => this.writeFile(path14.join(envDir, fileName), content, { overwrite: false, silent: true })));
3793
+ this.logger.info(`${missing.map(({ fileName }) => `env/${fileName}`).join(", ")} were missing (gitignored, so a clone has none) and now hold local defaults: put this machine's values in them, or fetch the team's with \`akan download-env\`.`);
3794
+ return written;
3795
+ }
3639
3796
  #getScanTemplateTasks(scanInfo) {
3640
3797
  return [
3798
+ this.#seedEnvFiles(),
3641
3799
  this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
3642
3800
  this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
3643
3801
  this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
@@ -3713,7 +3871,7 @@ class SysExecutor extends Executor {
3713
3871
  await this.setPackageJson({ ...packageJson, dependencies, devDependencies });
3714
3872
  }
3715
3873
  async getLocalFile(targetPath) {
3716
- const filePath = path13.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
3874
+ const filePath = path14.isAbsolute(targetPath) ? targetPath : `${this.type}s/${this.name}/${targetPath}`;
3717
3875
  const content = await this.workspace.readFile(filePath);
3718
3876
  return { filePath, content };
3719
3877
  }
@@ -3789,7 +3947,7 @@ class SysExecutor extends Executor {
3789
3947
  class AppExecutor extends SysExecutor {
3790
3948
  static #routeSourceValidator = null;
3791
3949
  static async#getRouteSourceValidator() {
3792
- AppExecutor.#routeSourceValidator ??= (await import("./routeSourceValidator-6jd0q6r6.js")).RouteSourceValidator;
3950
+ AppExecutor.#routeSourceValidator ??= (await import("./routeSourceValidator-4h947v7c.js")).RouteSourceValidator;
3793
3951
  return AppExecutor.#routeSourceValidator;
3794
3952
  }
3795
3953
  dist;
@@ -3801,19 +3959,19 @@ class AppExecutor extends SysExecutor {
3801
3959
  static from(executor, name) {
3802
3960
  return new AppExecutor({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
3803
3961
  }
3804
- static #keptOnStart = [path13.join(".akan", "cache", "bin")];
3805
- static #legacyNative = path13.join(".akan", "native");
3962
+ static #keptOnStart = [path14.join(".akan", "cache", "bin")];
3963
+ static #legacyNative = path14.join(".akan", "native");
3806
3964
  async#removeDevOutput(dir = ".akan") {
3807
3965
  const entries = await readDirEntries(this.getPath(dir)).catch(() => []);
3808
3966
  await Promise.all(entries.map(async (name) => {
3809
- const entry = path13.join(dir, name);
3967
+ const entry = path14.join(dir, name);
3810
3968
  if (entry === AppExecutor.#legacyNative) {
3811
3969
  this.logger.warn(`apps/${this.name}/.akan/native holds native builds from before they moved to dist/native/${this.name}: upload any release waiting in its updates folders, then delete it.`);
3812
3970
  return;
3813
3971
  }
3814
3972
  if (AppExecutor.#keptOnStart.includes(entry))
3815
3973
  return;
3816
- if (AppExecutor.#keptOnStart.some((kept) => kept.startsWith(`${entry}${path13.sep}`)))
3974
+ if (AppExecutor.#keptOnStart.some((kept) => kept.startsWith(`${entry}${path14.sep}`)))
3817
3975
  return await this.#removeDevOutput(entry);
3818
3976
  await this.removeDir(entry);
3819
3977
  }));
@@ -3919,6 +4077,7 @@ class AppExecutor extends SysExecutor {
3919
4077
  return this.#akanConfig;
3920
4078
  }
3921
4079
  #pageKeys = null;
4080
+ #routeSources = [];
3922
4081
  #excludeDevOnlyPages = false;
3923
4082
  async getPageKeys({ refresh } = {}) {
3924
4083
  if (this.#pageKeys && !refresh)
@@ -3930,6 +4089,7 @@ class AppExecutor extends SysExecutor {
3930
4089
  const devOnlyKeys = new Set;
3931
4090
  const devOnlyDirs = [];
3932
4091
  const pageRoots = await this.getPageRoots();
4092
+ const routeSources = [];
3933
4093
  const libKeyPrefixes = pageRoots.map((root) => root.keyPrefix).filter(Boolean);
3934
4094
  for (const root of pageRoots) {
3935
4095
  if (!await FileSys2.dirExists(root.dir))
@@ -3939,13 +4099,13 @@ class AppExecutor extends SysExecutor {
3939
4099
  absolute: false,
3940
4100
  onlyFiles: true
3941
4101
  })) {
3942
- const segments = rel.split(path13.sep);
4102
+ const segments = rel.split(path14.sep);
3943
4103
  if (segments.some((s) => s === "node_modules"))
3944
4104
  continue;
3945
4105
  const posix = `${root.keyPrefix}${segments.join("/")}`;
3946
4106
  if (!root.keyPrefix && libKeyPrefixes.some((prefix) => posix.startsWith(prefix)))
3947
4107
  continue;
3948
- const absPath = path13.join(root.dir, ...segments);
4108
+ const absPath = path14.join(root.dir, ...segments);
3949
4109
  validatePageSourceFile(posix, { filePath: absPath });
3950
4110
  if (!isRouteSourceFile(posix))
3951
4111
  continue;
@@ -3979,6 +4139,7 @@ class AppExecutor extends SysExecutor {
3979
4139
  rootLayout: isRootLayout,
3980
4140
  pattern: parsed.pattern
3981
4141
  });
4142
+ routeSources.push({ key, absPath, info });
3982
4143
  if (info.devOnly) {
3983
4144
  devOnlyKeys.add(key);
3984
4145
  if (parsed.kind === "layout")
@@ -3989,9 +4150,14 @@ class AppExecutor extends SysExecutor {
3989
4150
  }
3990
4151
  }
3991
4152
  pageKeys.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
4153
+ this.#routeSources = routeSources.sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
3992
4154
  this.#pageKeys = this.#excludeDevOnlyPages ? this.#dropDevOnlyPages(pageKeys, devOnlyKeys, devOnlyDirs) : pageKeys;
3993
4155
  return this.#pageKeys;
3994
4156
  }
4157
+ async getRouteSources({ refresh } = {}) {
4158
+ await this.getPageKeys({ refresh });
4159
+ return this.#routeSources;
4160
+ }
3995
4161
  #dropDevOnlyPages(pageKeys, devOnlyKeys, devOnlyDirs) {
3996
4162
  if (!devOnlyKeys.size)
3997
4163
  return pageKeys;
@@ -4086,7 +4252,7 @@ class AppExecutor extends SysExecutor {
4086
4252
  static async#linkLibAsset(targetPath, linkPath) {
4087
4253
  const isWindows = process.platform === "win32";
4088
4254
  try {
4089
- const target = isWindows ? targetPath : path13.relative(path13.dirname(linkPath), targetPath);
4255
+ const target = isWindows ? targetPath : path14.relative(path14.dirname(linkPath), targetPath);
4090
4256
  await symlink(target, linkPath, isWindows ? "junction" : "dir");
4091
4257
  } catch (error) {
4092
4258
  if (!isWindows)
@@ -4129,7 +4295,7 @@ class AppExecutor extends SysExecutor {
4129
4295
  await this.writeFile(rel, content, opts);
4130
4296
  },
4131
4297
  readEnvClient: async () => {
4132
- const envClientPath = path13.join(this.cwdPath, "env", "env.client.ts");
4298
+ const envClientPath = path14.join(this.cwdPath, "env", "env.client.ts");
4133
4299
  if (!await FileSys2.fileExists(envClientPath))
4134
4300
  return null;
4135
4301
  try {
@@ -4223,7 +4389,7 @@ class PkgExecutor extends Executor {
4223
4389
  return overrideVersion;
4224
4390
  try {
4225
4391
  const packageJsonPath = `pkgs/${dep}/package.json`;
4226
- if (!await Bun.file(path13.join(this.workspace.workspaceRoot, packageJsonPath)).exists())
4392
+ if (!await Bun.file(path14.join(this.workspace.workspaceRoot, packageJsonPath)).exists())
4227
4393
  return;
4228
4394
  const packageJson = await this.workspace.readJson(packageJsonPath);
4229
4395
  if (packageJson.name === dep)
@@ -4316,4 +4482,4 @@ class ModuleExecutor extends Executor {
4316
4482
  }
4317
4483
  }
4318
4484
 
4319
- export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, resolveSsrPageEntriesForApp, CodegenLock, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, ProjectTypecheck2, CommandExecutionError, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
4485
+ export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, TypecheckFailure, ProjectTypecheck2, CommandExecutionError, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };