@akanjs/cli 3.0.0-beta.2 → 3.0.0-beta.20

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 (187) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-awv258wb.js +9 -0
  3. package/CodeAgentRpcHost-p7h6n2hp.js +7 -0
  4. package/CodeAgentRpcListener-7p7z5dd7.js +97 -0
  5. package/CodeTui-1nqh35ez.js +1457 -0
  6. package/README.md +3 -0
  7. package/TunnelShare-scf4e4pd.js +9 -0
  8. package/{agent.command-d2gfxfck.js → agent.command-1s9ag7sb.js} +8 -9
  9. package/akanCode.js +102 -0
  10. package/{application.command-pj2m7584.js → application.command-49hwy6va.js} +51 -78
  11. package/{applicationBuildRunner-kxwbssgn.js → applicationBuildRunner-ybyp97pv.js} +63 -64
  12. package/{applicationReleasePackager-4yasxwv9.js → applicationReleasePackager-esnrphw8.js} +40 -60
  13. package/buildBatch.proc.js +19 -24
  14. package/{capacitorApp-36rbr858.js → capacitorApp-1synz4en.js} +3 -4
  15. package/cloud.command-d7rqtzt9.js +94 -0
  16. package/cloud.script-bkbpcr96.js +19 -0
  17. package/code.command-nn48xzej.js +154 -0
  18. package/commandManifest.json +1 -1
  19. package/consoleToStderr-h5bryj94.js +7 -0
  20. package/context.command-s3mcmvpa.js +48 -0
  21. package/context.runner-k99nb5pk.js +21 -0
  22. package/{dependencyScanner-shs82ynp.js → dependencyScanner-ye2e6pdz.js} +2 -2
  23. package/{devTui-40ggmd99.js → devTui-q7k7bakd.js} +122 -40
  24. package/fileSys-5ngz93ga.js +9 -0
  25. package/guideline.command-sct4qnt5.js +42 -0
  26. package/guidelines/agentRule/agentRule.instruction.md +206 -25
  27. package/guidelines/conventions/conventions.instruction.md +79 -24
  28. package/guidelines/fieldRule/fieldRule.instruction.md +1 -0
  29. package/guidelines/mcpRule/mcpRule.instruction.md +7 -5
  30. package/guidelines/queryRule/queryRule.instruction.md +17 -7
  31. package/guidelines/runtimeRule/runtimeRule.instruction.md +74 -0
  32. package/guidelines/ssrRule/ssrRule.instruction.md +4 -2
  33. package/guidelines/transportRule/transportRule.instruction.md +51 -0
  34. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +66 -3
  35. package/incrementalBuilder.proc.js +31 -48
  36. package/{index-h7yw2z9n.js → index-0bq14vr1.js} +8 -14
  37. package/index-13ffe9wp.js +69 -0
  38. package/index-22d57v4c.js +266 -0
  39. package/{index-fz5q3gd7.js → index-31yr441d.js} +10 -17
  40. package/index-3hx1z96c.js +87 -0
  41. package/index-3sq321ak.js +53 -0
  42. package/{index-kcxmv48c.js → index-3t7g9e4r.js} +45 -79
  43. package/{index-q0y2jq9j.js → index-5b6tavv3.js} +6 -3
  44. package/{index-47pj3aee.js → index-5e0n4hqx.js} +11 -12
  45. package/{index-259dsnz3.js → index-5pc1qrbv.js} +5 -8
  46. package/index-7md2g9vw.js +6 -0
  47. package/index-8mna0947.js +187 -0
  48. package/{index-zry5nz81.js → index-8sf7wmdr.js} +51 -30
  49. package/{index-2tv3fdx4.js → index-9d9bgcx4.js} +342 -765
  50. package/index-9dp031by.js +12 -0
  51. package/{index-ne2qy0nk.js → index-ahemdr5n.js} +12 -12
  52. package/{index-ws5e0j51.js → index-as7xmyz8.js} +40 -24
  53. package/index-axzjaqve.js +1118 -0
  54. package/{index-3d9y066c.js → index-bjwxs904.js} +9 -8
  55. package/index-c6eggbee.js +123 -0
  56. package/index-d2242ksy.js +99 -0
  57. package/{index-a64esmtb.js → index-ddxvdd1p.js} +169 -305
  58. package/{index-92zztqy1.js → index-dy0jx9ay.js} +2 -17
  59. package/{index-pnqbkf5p.js → index-dzf3r49a.js} +6 -2
  60. package/{index-w8kmx1b6.js → index-fgq75haa.js} +198 -290
  61. package/{index-by5gpp8x.js → index-hj6w4ka1.js} +2 -1
  62. package/{index-hwkygn9s.js → index-khpfpcsd.js} +302 -33
  63. package/{index-wt7qrtd4.js → index-mxav6j3c.js} +93 -232
  64. package/{index-gyd220p2.js → index-myhc3c1j.js} +554 -577
  65. package/{index-600zhnve.js → index-nv5976x3.js} +56 -197
  66. package/index-p6pbz9n5.js +25 -0
  67. package/{index-4edzf1gr.js → index-przybvy5.js} +77 -150
  68. package/index-smme4r47.js +49 -0
  69. package/{index-mak3cd28.js → index-w2zdcw3k.js} +137 -255
  70. package/index-wa5jbxj1.js +760 -0
  71. package/{index-v0qh106m.js → index-ww4z397j.js} +527 -723
  72. package/{index-j9yhg404.js → index-xqjwd384.js} +4 -7
  73. package/{index-7737gxcp.js → index-xqpzbab5.js} +107 -241
  74. package/index-xsjh6nzh.js +2729 -0
  75. package/{index-ktb5njgy.js → index-ygn77a5w.js} +47 -99
  76. package/index-ztp3e73t.js +700 -0
  77. package/index.js +23 -22
  78. package/{library.command-nbsky672.js → library.command-1gx04jgn.js} +4 -5
  79. package/{localRegistry.command-yeq57wjr.js → localRegistry.command-zndxj1q6.js} +22 -42
  80. package/{module.command-29vqzrh8.js → module.command-3waddk95.js} +8 -11
  81. package/{package.command-axv0abmn.js → package.command-zrc7br1y.js} +6 -7
  82. package/package.json +14 -5
  83. package/{page.command-vs9s3zrh.js → page.command-vpjgardh.js} +4 -5
  84. package/{primitive.command-cbxmqbtc.js → primitive.command-sz84tk4t.js} +9 -22
  85. package/prompter-ptaa3nk0.js +8 -0
  86. package/{quality.command-gmbs7nws.js → quality.command-g869hafs.js} +203 -376
  87. package/{recipeScanner-fpagtgc1.js → recipeScanner-4b69ybe0.js} +1 -1
  88. package/{repair.command-bqsjptsj.js → repair.command-chsnjvvv.js} +11 -35
  89. package/{routeSourceValidator-apyqw7wk.js → routeSourceValidator-7ycnfz0e.js} +0 -6
  90. package/{scalar.command-6k1vhe9s.js → scalar.command-2v21newx.js} +7 -10
  91. package/skills/akan-code/SKILL.md +130 -0
  92. package/skills/akan-debug/SKILL.md +42 -0
  93. package/skills/akan-deps/SKILL.md +50 -0
  94. package/skills/akan-err/SKILL.md +39 -0
  95. package/skills/akan-module/SKILL.md +45 -0
  96. package/skills/akan-scaffold/SKILL.md +76 -0
  97. package/skills/akan-scalar/SKILL.md +52 -0
  98. package/skills/akan-service/SKILL.md +34 -0
  99. package/skills/akan-store/SKILL.md +67 -0
  100. package/skills/akan-ui/SKILL.md +63 -0
  101. package/skills/akan-validate/SKILL.md +44 -0
  102. package/{subspace.command-fwjfcts7.js → subspace.command-ckcbwfp1.js} +138 -67
  103. package/templates/__scalar/__model__/__model__.abstract.md.template +8 -0
  104. package/templates/appSample/lib/__scalar/workHistory/workHistory.abstract.ts +8 -39
  105. package/templates/appSample/lib/_noti/noti.abstract.ts +6 -29
  106. package/templates/appSample/lib/task/task.abstract.ts +12 -32
  107. package/templates/appSample/lib/task/task.signal.spec.ts +15 -18
  108. package/templates/appSample/lib/task/task.signal.test.ts +15 -1
  109. package/templates/appSample/lib/task/task.signal.ts +1 -1
  110. package/templates/appSample/srvkit/{AuthGuard.ts → guards.ts} +7 -4
  111. package/templates/appSample/srvkit/{SessionInternalArg.ts → internalArgs.ts} +6 -4
  112. package/templates/client.ts +7 -30
  113. package/templates/crudPages/[__model__Id]/edit/page.tsx +2 -1
  114. package/templates/crudPages/[__model__Id]/page.tsx +2 -1
  115. package/templates/crudPages/new/page.tsx +2 -1
  116. package/templates/crudPages/page.tsx +2 -1
  117. package/templates/crudSinglePage/page.tsx +2 -1
  118. package/templates/lib/__lib/lib.dictionary.ts +0 -2
  119. package/templates/lib/__lib/lib.document.ts +0 -2
  120. package/templates/lib/sig.ts +8 -30
  121. package/templates/localDev/docker-compose.yaml.template +3 -14
  122. package/templates/module/__model__.signal.ts +12 -4
  123. package/templates/pkgRoot/tsconfig.json.template +2 -7
  124. package/templates/server.ts +0 -2
  125. package/templates/service/__model__.abstract.md.template +8 -0
  126. package/tunnel.command-kd2yr4fx.js +129 -0
  127. package/{typeChecker-3xgrzc2v.js → typeChecker-px49mezc.js} +1 -1
  128. package/typecheck.proc.js +1 -1
  129. package/workflow.command-44252cqv.js +79 -0
  130. package/{workspace.command-8s050m0h.js → workspace.command-fqcztt5p.js} +77 -109
  131. package/abstractCompactor-mjh5ppsq.js +0 -101
  132. package/cloud.command-jshwdq22.js +0 -93
  133. package/context.command-ez8a0zyz.js +0 -80
  134. package/devTuiView-c08ccbat.js +0 -9
  135. package/getDirname-dr3jz1xg.js +0 -7
  136. package/guideline.command-xmqwx8zm.js +0 -359
  137. package/guidelines/agentRule/agentRule.generate.json +0 -31
  138. package/guidelines/componentRule/componentRule.generate.json +0 -31
  139. package/guidelines/conventions/conventions.generate.json +0 -25
  140. package/guidelines/cssRule/cssRule.generate.json +0 -31
  141. package/guidelines/docPageRule/docPageRule.generate.json +0 -31
  142. package/guidelines/docPageRule/docPageRule.instruction.md +0 -25
  143. package/guidelines/docSyncRule/docSyncRule.generate.json +0 -31
  144. package/guidelines/docSyncRule/docSyncRule.instruction.md +0 -25
  145. package/guidelines/enumConstant/enumConstant.generate.json +0 -31
  146. package/guidelines/enumConstant/enumConstant.instruction.md +0 -28
  147. package/guidelines/fieldRule/fieldRule.generate.json +0 -31
  148. package/guidelines/framework/framework.generate.json +0 -32
  149. package/guidelines/mcpRule/mcpRule.generate.json +0 -35
  150. package/guidelines/modelConstant/modelConstant.generate.json +0 -32
  151. package/guidelines/modelDictionary/modelDictionary.generate.json +0 -32
  152. package/guidelines/modelDocument/modelDocument.generate.json +0 -31
  153. package/guidelines/modelService/modelService.generate.json +0 -31
  154. package/guidelines/modelSignal/modelSignal.generate.json +0 -31
  155. package/guidelines/modelStore/modelStore.generate.json +0 -31
  156. package/guidelines/modelTemplate/modelTemplate.generate.json +0 -31
  157. package/guidelines/modelUnit/modelUnit.generate.json +0 -31
  158. package/guidelines/modelUtil/modelUtil.generate.json +0 -31
  159. package/guidelines/modelView/modelView.generate.json +0 -31
  160. package/guidelines/modelZone/modelZone.generate.json +0 -31
  161. package/guidelines/moduleCodegen/moduleCodegen.generate.json +0 -31
  162. package/guidelines/moduleCodegen/moduleCodegen.instruction.md +0 -28
  163. package/guidelines/moduleOverview/moduleOverview.generate.json +0 -31
  164. package/guidelines/queryRule/queryRule.generate.json +0 -31
  165. package/guidelines/recipeRule/recipeRule.generate.json +0 -31
  166. package/guidelines/runtimeRule/runtimeRule.generate.json +0 -25
  167. package/guidelines/scalarConstant/scalarConstant.generate.json +0 -32
  168. package/guidelines/scalarDictionary/scalarDictionary.generate.json +0 -32
  169. package/guidelines/scalarModule/scalarModule.generate.json +0 -31
  170. package/guidelines/sharedUiUsage/sharedUiUsage.generate.json +0 -31
  171. package/guidelines/sharedUiUsage/sharedUiUsage.instruction.md +0 -25
  172. package/guidelines/ssrRule/ssrRule.generate.json +0 -31
  173. package/guidelines/transportRule/transportRule.generate.json +0 -31
  174. package/guidelines/utilUiUsage/utilUiUsage.generate.json +0 -31
  175. package/guidelines/utilUiUsage/utilUiUsage.instruction.md +0 -25
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +0 -24
  177. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +0 -33
  178. package/index-2hq52jq3.js +0 -465
  179. package/index-6wwzs1bc.js +0 -7
  180. package/index-8pm30m73.js +0 -841
  181. package/index-kn1h7p1x.js +0 -560
  182. package/index-meh558jy.js +0 -65
  183. package/index-rwg2aa4f.js +0 -229
  184. package/templates/__scalar/__model__/__model__.abstract.md +0 -28
  185. package/templates/module/__model__.abstract.md +0 -28
  186. package/templates/service/__model__.abstract.md +0 -28
  187. package/workflow.command-nwpcdc8p.js +0 -107
package/README.md CHANGED
@@ -74,6 +74,9 @@ artifact is built last and is not overwritten by the root `akan` bootstrap scrip
74
74
  - Use `@akanjs/cli` as the user-facing executable package.
75
75
  - `@akanjs/devkit` is bundled into the CLI for published CLI usage; it is not required as a separate
76
76
  runtime dependency for ordinary CLI users.
77
+ - The `akan code` agent follows that same split: its engine, tools and skills are a devkit facet
78
+ (`@akanjs/devkit/codeAgent`), and `@akanjs/cli/code` is the terminal host plus the SDK entry that
79
+ re-exports both.
77
80
 
78
81
  ## Requirements
79
82
 
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ TunnelShare2
4
+ } from "./index-smme4r47.js";
5
+ import"./index-22d57v4c.js";
6
+ import"./index-5b6tavv3.js";
7
+ export {
8
+ TunnelShare2 as TunnelShare
9
+ };
@@ -2,17 +2,16 @@
2
2
  import {
3
3
  Workspace,
4
4
  command
5
- } from "./index-mak3cd28.js";
6
- import"./index-q0y2jq9j.js";
7
- import"./index-2tv3fdx4.js";
8
- import"./index-6wwzs1bc.js";
9
- import"./index-by5gpp8x.js";
10
- import"./index-gyd220p2.js";
11
- import"./index-ktb5njgy.js";
12
- import"./index-h7yw2z9n.js";
5
+ } from "./index-w2zdcw3k.js";
6
+ import"./index-5b6tavv3.js";
7
+ import"./index-9d9bgcx4.js";
8
+ import"./index-hj6w4ka1.js";
9
+ import"./index-myhc3c1j.js";
10
+ import"./index-ygn77a5w.js";
11
+ import"./index-0bq14vr1.js";
13
12
  import {
14
13
  AgentScript
15
- } from "./index-ne2qy0nk.js";
14
+ } from "./index-ahemdr5n.js";
16
15
 
17
16
  // pkgs/@akanjs/cli/agent/agent.command.ts
18
17
  class AgentCommand extends command("agent", [AgentScript], ({ public: target }) => ({
package/akanCode.js ADDED
@@ -0,0 +1,102 @@
1
+ // @bun
2
+ import {
3
+ AkanEditScope2,
4
+ DevLogFeedback2,
5
+ PreviewChrome2,
6
+ PreviewView2,
7
+ PreviewFeedback2,
8
+ TurnFeedback2,
9
+ AkanCli2,
10
+ AkanVerifier2,
11
+ VerifyFeedback2,
12
+ AkanToolPack2,
13
+ MailToolPack2,
14
+ McpUnauthorized2,
15
+ McpClient2,
16
+ McpToolPack2,
17
+ SessionToolPack2,
18
+ WebToolPack2,
19
+ AkanCodePlugins2,
20
+ AkanEnvKeys2,
21
+ akanSystemPrompt2,
22
+ CodeSessionIndex2,
23
+ AkanCodeServices2,
24
+ CodeAgentAsks2,
25
+ CodeAgentEventMapper2,
26
+ CodeAgentGate2,
27
+ CodeAgentUi2,
28
+ CodeMailbox2,
29
+ CodeSessionFork2,
30
+ CodeAgent2
31
+ } from "./index-xsjh6nzh.js";
32
+ import {
33
+ akanCodeDefaultModel2,
34
+ akanCodeModel2,
35
+ akanCodeModelSupportsImages2,
36
+ akanCodeModelWarnings2,
37
+ CodeAgentStreamPrinter2
38
+ } from "./index-c6eggbee.js";
39
+ import {
40
+ SubagentPool2,
41
+ akanCodePaths2
42
+ } from "./index-ztp3e73t.js";
43
+ import"./index-7md2g9vw.js";
44
+ import {
45
+ CodeAgentRpcHost2
46
+ } from "./index-d2242ksy.js";
47
+ import {
48
+ CodeTuiLines2,
49
+ CodeTuiAgents2,
50
+ CodeTuiClipboard2,
51
+ CodeTuiCommands2,
52
+ CodeTuiEditor2,
53
+ CodeTuiFiles2,
54
+ CodeTuiMarkdown2,
55
+ CodeTuiParts2
56
+ } from "./index-wa5jbxj1.js";
57
+ export {
58
+ AkanCli2 as AkanCli,
59
+ AkanCodePlugins2 as AkanCodePlugins,
60
+ AkanCodeServices2 as AkanCodeServices,
61
+ AkanEditScope2 as AkanEditScope,
62
+ AkanEnvKeys2 as AkanEnvKeys,
63
+ AkanToolPack2 as AkanToolPack,
64
+ AkanVerifier2 as AkanVerifier,
65
+ CodeAgent2 as CodeAgent,
66
+ CodeAgentAsks2 as CodeAgentAsks,
67
+ CodeAgentEventMapper2 as CodeAgentEventMapper,
68
+ CodeAgentGate2 as CodeAgentGate,
69
+ CodeAgentRpcHost2 as CodeAgentRpcHost,
70
+ CodeAgentStreamPrinter2 as CodeAgentStreamPrinter,
71
+ CodeAgentUi2 as CodeAgentUi,
72
+ CodeMailbox2 as CodeMailbox,
73
+ CodeSessionFork2 as CodeSessionFork,
74
+ CodeSessionIndex2 as CodeSessionIndex,
75
+ CodeTuiAgents2 as CodeTuiAgents,
76
+ CodeTuiClipboard2 as CodeTuiClipboard,
77
+ CodeTuiCommands2 as CodeTuiCommands,
78
+ CodeTuiEditor2 as CodeTuiEditor,
79
+ CodeTuiFiles2 as CodeTuiFiles,
80
+ CodeTuiLines2 as CodeTuiLines,
81
+ CodeTuiMarkdown2 as CodeTuiMarkdown,
82
+ CodeTuiParts2 as CodeTuiParts,
83
+ DevLogFeedback2 as DevLogFeedback,
84
+ MailToolPack2 as MailToolPack,
85
+ McpClient2 as McpClient,
86
+ McpToolPack2 as McpToolPack,
87
+ McpUnauthorized2 as McpUnauthorized,
88
+ PreviewChrome2 as PreviewChrome,
89
+ PreviewFeedback2 as PreviewFeedback,
90
+ PreviewView2 as PreviewView,
91
+ SessionToolPack2 as SessionToolPack,
92
+ SubagentPool2 as SubagentPool,
93
+ TurnFeedback2 as TurnFeedback,
94
+ VerifyFeedback2 as VerifyFeedback,
95
+ WebToolPack2 as WebToolPack,
96
+ akanCodeDefaultModel2 as akanCodeDefaultModel,
97
+ akanCodeModel2 as akanCodeModel,
98
+ akanCodeModelSupportsImages2 as akanCodeModelSupportsImages,
99
+ akanCodeModelWarnings2 as akanCodeModelWarnings,
100
+ akanCodePaths2 as akanCodePaths,
101
+ akanSystemPrompt2 as akanSystemPrompt
102
+ };
@@ -6,30 +6,34 @@ import {
6
6
  Exec,
7
7
  Workspace,
8
8
  command
9
- } from "./index-mak3cd28.js";
10
- import"./index-q0y2jq9j.js";
11
- import"./index-2tv3fdx4.js";
12
- import"./index-6wwzs1bc.js";
9
+ } from "./index-w2zdcw3k.js";
10
+ import"./index-5b6tavv3.js";
11
+ import"./index-9d9bgcx4.js";
12
+ import"./index-khpfpcsd.js";
13
+ import"./index-5pc1qrbv.js";
13
14
  import {
14
15
  ApplicationScript
15
- } from "./index-v0qh106m.js";
16
- import"./index-259dsnz3.js";
17
- import"./index-hwkygn9s.js";
18
- import {
19
- AbstractDoc
20
- } from "./index-meh558jy.js";
21
- import"./index-j9yhg404.js";
16
+ } from "./index-ww4z397j.js";
17
+ import"./index-7md2g9vw.js";
18
+ import"./index-xqjwd384.js";
22
19
  import {
23
20
  getMobileTargetChoices
24
- } from "./index-47pj3aee.js";
21
+ } from "./index-5e0n4hqx.js";
25
22
 
26
23
  // pkgs/@akanjs/cli/application/application.command.ts
27
- import { select } from "@inquirer/prompts";
28
24
  var mobileTargetOption = {
29
25
  desc: "mobile target name or all",
30
26
  ask: "Select mobile target",
31
27
  enum: async ({ app }) => await getMobileTargetChoices(app)
32
28
  };
29
+ var devEnvs = ["local", "debug", "develop", "main"];
30
+ var buildEnvOption = { enum: devEnvs, desc: "backend environment", default: "debug" };
31
+ var startEnvOption = { enum: devEnvs, desc: "backend environment", default: "local" };
32
+ var releaseEnvOption = {
33
+ enum: ["debug", "develop", "main", "local"],
34
+ desc: "backend environment",
35
+ default: "main"
36
+ };
33
37
 
34
38
  class ApplicationCommand extends command("application", [ApplicationScript], ({ public: target }) => ({
35
39
  createApplication: target({ desc: "Create a new application in the workspace" }).arg("appName", String, { desc: "name of application" }).option("start", Boolean, { desc: "start application", default: false }).with(Workspace).exec(async function(appName, start, workspace) {
@@ -44,13 +48,6 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
44
48
  sync: target({ desc: "Sync dependencies and configuration for an app or library" }).with(Sys).exec(async function(sys) {
45
49
  await this.applicationScript.sync(sys);
46
50
  }),
47
- compact: target({ desc: "Compact the *.abstract.md files of an app or library with the AI editor" }).with(Sys).option("module", String, { desc: "single module to compact", nullable: true }).option("minLines", Number, {
48
- flag: "n",
49
- desc: "only compact abstracts longer than this",
50
- default: AbstractDoc.compactMinLines
51
- }).option("interactive", Boolean, { desc: "confirm or refine each rewrite", default: false }).exec(async function(sys, module, minLines, interactive) {
52
- await this.applicationScript.compact(sys, { module, minLines, interactive });
53
- }),
54
51
  script: target({ desc: "Run a custom script in the application" }).with(App).arg("filename", String, { desc: "name of script", nullable: true }).exec(async function(app, filename) {
55
52
  await this.applicationScript.script(app, filename);
56
53
  }),
@@ -60,7 +57,14 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
60
57
  logs: target({ desc: "Tail the running application's logs, filtered (attaches to akan-control.sock)" }).with(App).option("level", String, { desc: "minimum level: trace, verbose, debug, info, warn, error", nullable: true }).option("grep", String, { desc: "substring the message must contain", nullable: true }).option("endpoint", String, {
61
58
  desc: "endpoint glob(s), comma-separated: mutation:*, query:userList",
62
59
  nullable: true
63
- }).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, { flag: "R", desc: "process role(s): gateway, all, batch, rsc-worker", nullable: true }).option("origin", String, { desc: "call origin(s): http, websocket, mcp, internal, page", nullable: true }).option("since", String, { desc: "only records newer than this: 5m, 30s, or epoch ms", nullable: true }).option("replay", Number, { flag: "n", desc: "records to replay from the buffer before following", default: 0 }).option("json", Boolean, { desc: "print NDJSON records instead of rendered lines", default: false }).option("follow", Boolean, { desc: "keep streaming; pass --follow false for history only", default: true }).option("runtimeDir", String, {
60
+ }).option("trace", String, { desc: "one request's traceId", nullable: true }).option("child", String, { desc: "replica index(es), comma-separated", nullable: true }).option("role", String, {
61
+ flag: "R",
62
+ desc: "process role(s): gateway, federation, batch, all, rsc-worker",
63
+ nullable: true
64
+ }).option("origin", String, { desc: "call origin(s): http, websocket, mcp, internal, page", nullable: true }).option("since", String, {
65
+ desc: "only records newer than this: a duration ago in ms, s, m, h or d (30s, 5m, 2h), or an epoch-ms timestamp",
66
+ nullable: true
67
+ }).option("replay", Number, { flag: "n", desc: "records to replay from the buffer before following", default: 0 }).option("json", Boolean, { desc: "print NDJSON records instead of rendered lines", default: false }).option("follow", Boolean, { desc: "keep streaming; pass --follow false for history only", default: true }).option("runtimeDir", String, {
64
68
  flag: "d",
65
69
  desc: "runtime dir holding akan-control.sock (default: local/apps/<app>/runtime)",
66
70
  nullable: true
@@ -89,37 +93,25 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
89
93
  test: target({ desc: "Prepare and test an app, library, or package" }).with(Exec).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(exec, write) {
90
94
  await this.applicationScript.test(exec, { write });
91
95
  }),
92
- buildIos: target({ short: true, desc: "Build iOS app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
93
- enum: ["local", "debug", "develop", "main"],
94
- desc: "backend environment",
95
- default: "debug"
96
- }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
96
+ buildIos: target({ short: true, desc: "Build iOS app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
97
97
  await this.applicationScript.buildIos(app, { target, env, write, regenerate });
98
98
  }),
99
- buildAndroid: target({ short: true, desc: "Build Android app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
100
- enum: ["local", "debug", "develop", "main"],
101
- desc: "backend environment",
102
- default: "debug"
103
- }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
99
+ buildAndroid: target({ short: true, desc: "Build Android app with Capacitor" }).with(App).option("target", String, mobileTargetOption).option("env", String, buildEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, write, regenerate) {
104
100
  await this.applicationScript.buildAndroid(app, { target, env, write, regenerate });
105
101
  }),
106
102
  start: target({ short: true, desc: "Start development server(s) (frontend SSR + backend)" }).with(Apps).option("plain", Boolean, { desc: "print prefixed lines instead of the full-screen view", default: false }).option("kill", Boolean, { flag: "k", desc: "free the dev ports first, whoever is holding them", default: false }).option("concurrency", Number, {
107
103
  desc: "apps to boot at a time (default: what this machine's memory and cores allow)",
108
104
  nullable: true
109
- }).option("dbup", Boolean, { desc: "start the local database first", default: true }).option("open", Boolean, { desc: "open web browser?", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(apps, plain, kill, concurrency, dbup, open, write) {
110
- await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, write });
111
- }),
112
- startIos: target({ short: true, desc: "Start iOS app in simulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
113
- enum: ["local", "debug", "develop", "main"],
114
- desc: "backend environment",
115
- default: "local"
116
- }).option("open", Boolean, { desc: "open ios simulator", default: false }).option("release", Boolean, { desc: "release mode", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("noAllowProvisioningUpdates", Boolean, {
117
- desc: "disable automatic iOS provisioning updates for physical devices",
118
- default: false
105
+ }).option("dbup", Boolean, { desc: "start the local database first", default: true }).option("open", Boolean, { desc: "open web browser?", default: false }).option("share", Boolean, { desc: "also share each app on a public URL through an akan tunnel", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).exec(async function(apps, plain, kill, concurrency, dbup, open, share, write) {
106
+ await this.applicationScript.start(apps, { plain, kill, concurrency, dbup, open, share, write });
107
+ }),
108
+ startIos: target({ short: true, desc: "Start iOS app in simulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("open", Boolean, { desc: "open ios simulator", default: false }).option("release", Boolean, { desc: "release mode", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowProvisioningUpdates", Boolean, {
109
+ desc: "let Xcode create or update provisioning profiles for a physical device",
110
+ default: true
119
111
  }).option("device", String, {
120
112
  desc: "run target to select non-interactively: udid, device name, or runtime (e.g. 'iPhone 16' or 'iOS 18')",
121
113
  default: ""
122
- }).exec(async function(app, target, env, open, release, write, regenerate, noAllowProvisioningUpdates, device) {
114
+ }).exec(async function(app, target, env, open, release, write, regenerate, allowProvisioningUpdates, device) {
123
115
  await this.applicationScript.startIos(app, {
124
116
  target,
125
117
  env,
@@ -127,15 +119,11 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
127
119
  operation: release ? "release" : "local",
128
120
  write,
129
121
  regenerate,
130
- noAllowProvisioningUpdates,
122
+ noAllowProvisioningUpdates: !allowProvisioningUpdates,
131
123
  device: device || undefined
132
124
  });
133
125
  }),
134
- startAndroid: target({ short: true, desc: "Start Android app in emulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
135
- enum: ["local", "debug", "develop", "main"],
136
- desc: "backend environment",
137
- default: "local"
138
- }).option("release", Boolean, { desc: "release mode", default: false }).option("open", Boolean, { desc: "open android simulator", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, release, open, write, regenerate) {
126
+ startAndroid: target({ short: true, desc: "Start Android app in emulator or device" }).with(App).option("target", String, mobileTargetOption).option("env", String, startEnvOption).option("release", Boolean, { desc: "release mode", default: false }).option("open", Boolean, { desc: "open android simulator", default: false }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).exec(async function(app, target, env, release, open, write, regenerate) {
139
127
  await this.applicationScript.startAndroid(app, {
140
128
  target,
141
129
  env,
@@ -145,24 +133,10 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
145
133
  regenerate
146
134
  });
147
135
  }),
148
- releaseIos: target({ desc: "Build and package iOS app for release (App Store)" }).with(App).option("target", String, mobileTargetOption).option("env", String, {
149
- enum: ["debug", "develop", "main", "local"],
150
- desc: "backend environment",
151
- default: "main"
152
- }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, write, regenerate, allowLocalRelease) {
153
- await this.applicationScript.releaseIos(app, {
154
- target,
155
- env,
156
- write,
157
- regenerate,
158
- allowLocalRelease
159
- });
136
+ releaseIos: target({ desc: "Build and package iOS app for release (App Store)" }).with(App).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, target, env, write, regenerate, allowLocalRelease) {
137
+ await this.applicationScript.releaseIos(app, { target, env, write, regenerate, allowLocalRelease });
160
138
  }),
161
- releaseAndroid: target({ desc: "Build and package Android app for release (Play Store)" }).with(App).option("assembleType", String, { enum: ["apk", "aab"], default: "apk" }).option("target", String, mobileTargetOption).option("env", String, {
162
- enum: ["debug", "develop", "main", "local"],
163
- desc: "backend environment",
164
- default: "main"
165
- }).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, regenerate, allowLocalRelease) {
139
+ releaseAndroid: target({ desc: "Build and package Android app for release (Play Store)" }).with(App).option("assembleType", String, { enum: ["apk", "aab"], default: "apk" }).option("target", String, mobileTargetOption).option("env", String, releaseEnvOption).option("write", Boolean, { desc: "write code generation", default: true }).option("regenerate", Boolean, { flag: "g", desc: "delete and regenerate native project", default: false }).option("allowLocalRelease", Boolean, { flag: "l", desc: "allow release with --env local", default: false }).exec(async function(app, assembleType, target, env, write, regenerate, allowLocalRelease) {
166
140
  await this.applicationScript.releaseAndroid(app, assembleType, {
167
141
  target,
168
142
  env,
@@ -174,22 +148,21 @@ class ApplicationCommand extends command("application", [ApplicationScript], ({
174
148
  releaseSource: target({ desc: "Release app source code with OTA update support" }).with(App).option("rebuild", Boolean, { desc: "rebuild", default: false }).option("buildNum", Number, { desc: "build number", default: 0 }).option("environment", String, { desc: "environment", default: "debug" }).option("local", Boolean, { desc: "local", default: true }).exec(async function(app, rebuild, buildNum, environment, local) {
175
149
  await this.applicationScript.releaseSource(app, { rebuild, buildNum, environment, local });
176
150
  }),
177
- codepush: target({ desc: "Deploy over-the-air (OTA) update for mobile app" }).with(App).exec(async function(app) {
178
- const os = await select({
179
- message: "Select os",
180
- choices: [
181
- { value: "ios", name: "ios", description: "ios" },
182
- { value: "android", name: "android", description: "android" }
183
- ]
184
- });
185
- await this.applicationScript.codepush(app, os);
151
+ codepush: target({ desc: "Over-the-air (OTA) update for a mobile app \u2014 in development, deploys nothing yet" }).with(App).exec(async function(app) {
152
+ await this.applicationScript.codepush(app);
186
153
  }),
187
154
  dbup: target({ desc: "Start local database services for a database mode" }).with(Workspace).option("mode", String, {
188
- desc: "database mode",
189
- default: "multiple",
190
- enum: ["single", "multiple", "cluster"]
155
+ desc: "database mode; left out, every mode the workspace's apps declare",
156
+ enum: ["single", "multiple", "cluster"],
157
+ nullable: true
191
158
  }).exec(async function(workspace, mode) {
192
- await this.applicationScript.dbup(workspace, mode);
159
+ await this.applicationScript.dbupDeclared(workspace, mode);
160
+ }),
161
+ dbExport: target({ desc: "Write every model table of an app to one NDJSON file each" }).with(App).option("dir", String, { desc: "directory under the workspace to write", default: "local/transfer" }).exec(async function(app, dir) {
162
+ await this.applicationScript.transferDatabase(app, "export", dir);
163
+ }),
164
+ dbImport: target({ desc: "Read files db-export wrote into an app's database, in the mode the shell names" }).with(App).option("dir", String, { desc: "directory under the workspace to read", default: "local/transfer" }).exec(async function(app, dir) {
165
+ await this.applicationScript.transferDatabase(app, "import", dir);
193
166
  }),
194
167
  dbdown: target({ desc: "Stop local database services" }).with(Workspace).exec(async function(workspace) {
195
168
  await this.applicationScript.dbdown(workspace);
@@ -1,17 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  Spinner
4
- } from "./index-2tv3fdx4.js";
4
+ } from "./index-9d9bgcx4.js";
5
5
  import {
6
6
  AllRoutesBuilder,
7
7
  CsrArtifactBuilder,
8
8
  FontPruner,
9
9
  precompressArtifacts,
10
10
  SsrBaseArtifactBuilder
11
- } from "./index-a64esmtb.js";
12
- import"./index-w8kmx1b6.js";
13
- import"./index-q0y2jq9j.js";
14
- import"./index-hwkygn9s.js";
11
+ } from "./index-ddxvdd1p.js";
12
+ import"./index-fgq75haa.js";
13
+ import"./index-5b6tavv3.js";
15
14
  import"./index-n68jx79w.js";
16
15
 
17
16
  // pkgs/@akanjs/devkit/applicationBuildRunner.ts
@@ -51,6 +50,7 @@ class ApplicationBuildRunner {
51
50
  #app;
52
51
  #fast;
53
52
  #reporter;
53
+ #spinner;
54
54
  #startedAt = Date.now();
55
55
  #phases = [];
56
56
  constructor(app, { fast = false, reporter } = {}) {
@@ -59,21 +59,17 @@ class ApplicationBuildRunner {
59
59
  this.#reporter = reporter;
60
60
  }
61
61
  async build({ spinner = false } = {}) {
62
- const phaseOptions = { spinner };
62
+ this.#spinner = spinner;
63
63
  const { web, assets } = await this.#app.getConfig();
64
- await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"), undefined, {
65
- spinner
66
- });
64
+ await this.#runPhase("prepare", "Preparing output directory", () => this.#app.prepareCommand("build"));
67
65
  if (!this.#fast)
68
- await this.#runPhase("typecheck", "Typechecking", () => this.typecheck(), undefined, phaseOptions);
69
- await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs`, phaseOptions);
70
- await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr", phaseOptions);
71
- await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await this.#buildCsr() : null, (result) => result?.outputDir ?? (web.csr ? "skipped" : "disabled by akan.config.ts web.csr"), phaseOptions);
72
- await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts", phaseOptions);
73
- await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files", phaseOptions);
74
- await this.#runPhase("metadata", "Writing production metadata", () => this.#buildAppMeta(), undefined, {
75
- spinner
76
- });
66
+ await this.#runPhase("typecheck", "Typechecking", () => this.typecheck());
67
+ await this.#runPhase("backend", "Compiling backend", () => this.#buildBackend(), (result) => `${result.entrypoints} entrypoints, ${result.outputs} outputs`);
68
+ await this.#runPhase("ssr", "Building SSR route artifacts", async () => web.ssr ? await this.#buildSsr() : null, (result) => result ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries` : web.ssr ? "skipped" : "disabled by akan.config.ts web.ssr");
69
+ await this.#runPhase("csr", "Building CSR assets", async () => web.csr ? await new CsrArtifactBuilder(this.#app, "build").build() : null, (result) => result?.outputDir ?? (web.csr ? "skipped" : "disabled by akan.config.ts web.csr"));
70
+ await this.#runPhase("assets", "Trimming unread static assets", async () => assets.pruneFonts ? await new FontPruner(this.#app, assets).prune() : null, (result) => result ? `${result.removed.length} font file(s) dropped, ${ApplicationBuildRunner.formatBytes(result.freedBytes)} freed; ${result.kept.length} kept` : "disabled by akan.config.ts assets.pruneFonts");
71
+ await this.#runPhase("compress", "Compressing static assets", () => precompressArtifacts(this.#app), (result) => result.files > 0 ? `${result.files} files, ${ApplicationBuildRunner.formatBytes(result.inputBytes)} -> gzip ${ApplicationBuildRunner.formatBytes(result.outputBytes)} / br ${ApplicationBuildRunner.formatBytes(result.brotliBytes)}` : "no files");
72
+ await this.#runPhase("metadata", "Writing production metadata", () => this.#buildAppMeta());
77
73
  return {
78
74
  phases: this.#phases,
79
75
  durationMs: Date.now() - this.#startedAt,
@@ -84,21 +80,20 @@ class ApplicationBuildRunner {
84
80
  async typecheck(options = {}) {
85
81
  const { clean = false, incremental = true } = options;
86
82
  await this.#app.getPageKeys({ refresh: true });
87
- const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig({ incremental });
83
+ const { typecheckDir, tsconfigPath } = await this.#writeTypecheckTsconfig(incremental);
88
84
  if (clean)
89
85
  await rm(path.join(typecheckDir, "tsconfig.tsbuildinfo"), { force: true });
90
86
  await this.#checkProjectInChildProcess(tsconfigPath);
91
87
  }
92
- async#runPhase(id, label, task, summarize, options = {}) {
88
+ async#runPhase(id, label, task, summarize) {
93
89
  this.#reporter?.phaseStart?.({ id, label });
94
90
  const phaseStartedAt = Date.now();
95
- const spinner = options.spinner ? new Spinner(label, { prefix: `${BUILD_PHASE_EMOJIS[id]} ${id}` }).start() : undefined;
91
+ const spinner = this.#spinner ? new Spinner(label, { prefix: `${BUILD_PHASE_EMOJIS[id]} ${id}` }).start() : undefined;
96
92
  try {
97
93
  const result = await task();
98
94
  const phase = { id, label, durationMs: Date.now() - phaseStartedAt, summary: summarize?.(result) };
99
95
  this.#phases.push(phase);
100
- const summary = phase.summary ? `: ${phase.summary}` : "";
101
- spinner?.succeed(`${label}${summary}`);
96
+ spinner?.succeed(`${label}${phase.summary ? `: ${phase.summary}` : ""}`);
102
97
  this.#reporter?.phaseDone?.(phase);
103
98
  return result;
104
99
  } catch (error) {
@@ -111,59 +106,72 @@ class ApplicationBuildRunner {
111
106
  const akanConfig = await this.#app.getConfig();
112
107
  await Promise.all([
113
108
  this.#app.dist.writeJson("package.json", akanConfig.getProductionPackageJson()),
114
- this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, akanConfig.dockerfile)
109
+ this.#app.dist.writeFile(`${this.#app.dist.cwdPath}/Dockerfile`, akanConfig.dockerfile),
110
+ this.#app.dist.writeJson("akan.build.json", {
111
+ buildId: await this.#resolveBuildId(),
112
+ akanVersion: akanConfig.akanVersion,
113
+ builtAt: new Date().toISOString()
114
+ })
115
115
  ]);
116
116
  }
117
+ async#resolveBuildId() {
118
+ const fromEnv = process.env.AKAN_BUILD_ID?.trim();
119
+ if (fromEnv)
120
+ return fromEnv;
121
+ const root = this.#app.workspace.workspaceRoot;
122
+ const sha = Bun.spawnSync(["git", "rev-parse", "--short=12", "HEAD"], { cwd: root, stderr: "ignore" });
123
+ if (sha.exitCode !== 0)
124
+ return null;
125
+ const dirty = Bun.spawnSync(["git", "status", "--porcelain", "--untracked-files=no"], {
126
+ cwd: root,
127
+ stderr: "ignore"
128
+ });
129
+ const suffix = dirty.exitCode === 0 && dirty.stdout.toString().trim() ? "-dirty" : "";
130
+ return `${sha.stdout.toString().trim()}${suffix}`;
131
+ }
117
132
  async#buildBackend() {
118
- const akanConfig = await this.#app.getConfig();
119
- const backendExternals = [
120
- ...new Set([...akanConfig.externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS])
121
- ];
122
- const { web } = akanConfig;
133
+ const { externalLibs, web } = await this.#app.getConfig();
123
134
  const backendEntryPoints = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
124
135
  for (const entrypoint of backendEntryPoints) {
125
136
  if (!await Bun.file(entrypoint).exists())
126
137
  throw new Error(`Backend entrypoint not found: ${entrypoint}`);
127
138
  }
128
- const backendResult = await this.#buildOrThrow("backend", {
129
- entrypoints: backendEntryPoints,
139
+ const sharedConfig = {
130
140
  outdir: this.#app.dist.cwdPath,
131
141
  target: "bun",
132
142
  minify: AKAN_BACKEND_MINIFY,
133
143
  naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
134
- define: { "process.env.NODE_ENV": JSON.stringify("production") },
135
- plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : []
136
- });
144
+ define: { "process.env.NODE_ENV": JSON.stringify("production") }
145
+ };
146
+ const backendConfig = { ...sharedConfig, plugins: [this.#createExternalSpecifiersPlugin(externalLibs)] };
147
+ const [mainResult, serverResult] = [
148
+ await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[0]] }),
149
+ await this.#buildOrThrow("backend", { ...backendConfig, entrypoints: [backendEntryPoints[1]], splitting: true })
150
+ ];
137
151
  const rscWorkerResult = web.ssr ? await this.#buildOrThrow("rsc-worker", {
152
+ ...backendConfig,
138
153
  entrypoints: [this.#resolveRscWorkerBuildEntry()],
139
- outdir: this.#app.dist.cwdPath,
140
- target: "bun",
141
- minify: AKAN_BACKEND_MINIFY,
142
- naming: { entry: "[name].[ext]", chunk: "chunk-[hash].[ext]" },
143
- conditions: ["react-server"],
144
- define: { "process.env.NODE_ENV": JSON.stringify("production") },
145
- plugins: backendExternals.length > 0 ? [this.#createExternalSpecifiersPlugin(backendExternals)] : []
154
+ conditions: ["react-server"]
146
155
  }) : null;
147
156
  const consoleRuntimeResult = await this.#buildOrThrow("console-runtime", {
157
+ ...sharedConfig,
148
158
  entrypoints: [this.#resolveConsoleRuntimeBuildEntry()],
149
- outdir: this.#app.dist.cwdPath,
150
- target: "bun",
151
- minify: AKAN_BACKEND_MINIFY,
152
- naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" },
153
- define: { "process.env.NODE_ENV": JSON.stringify("production") }
159
+ naming: { entry: "console-runtime.[ext]", chunk: "chunk-[hash].[ext]" }
154
160
  });
155
161
  await this.#writeConsoleShim();
162
+ const results = [mainResult, serverResult, rscWorkerResult, consoleRuntimeResult];
156
163
  return {
157
164
  entrypoints: backendEntryPoints.length + (rscWorkerResult ? 2 : 1),
158
- outputs: backendResult.outputs.length + (rscWorkerResult?.outputs.length ?? 0) + consoleRuntimeResult.outputs.length + 1
165
+ outputs: results.reduce((sum, result) => sum + (result?.outputs.length ?? 0), 1)
159
166
  };
160
167
  }
161
168
  async#writeConsoleShim() {
162
- await Bun.write(path.join(this.#app.dist.cwdPath, "console.js"), `import { cnst, db, dict, option, server, sig, srv } from "./server.js";
163
- import { assertAkanConsoleAllowed, startAkanConsole } from "./console-runtime.js";
169
+ await Bun.write(path.join(this.#app.dist.cwdPath, "console.js"), `process.env.AKAN_COMMAND_TYPE = "console";
170
+ const { cnst, db, dict, option, server, sig, srv } = await import("./server.js");
171
+ const { assertAkanConsoleAllowed, startAkanConsole } = await import("./console-runtime.js");
164
172
 
165
173
  const run = async () => {
166
- assertAkanConsoleAllowed(server.env);
174
+ assertAkanConsoleAllowed();
167
175
  await server.start({ listen: false, web: false });
168
176
  try {
169
177
  await startAkanConsole(server, { globals: { cnst, db, dict, option, sig, srv } });
@@ -192,9 +200,6 @@ void run().catch((error) => {
192
200
  return path.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server/console.ts");
193
201
  }
194
202
  }
195
- async#buildCsr() {
196
- return await new CsrArtifactBuilder(this.#app, "build").build();
197
- }
198
203
  async#buildSsr() {
199
204
  const pageKeys = await this.#app.getPageKeys();
200
205
  if (pageKeys.length === 0) {
@@ -205,7 +210,7 @@ void run().catch((error) => {
205
210
  const allRoutes = await new AllRoutesBuilder(this.#app, base.artifact, "build").build();
206
211
  return { base, allRoutes };
207
212
  }
208
- async#writeTypecheckTsconfig({ incremental = true } = {}) {
213
+ async#writeTypecheckTsconfig(incremental) {
209
214
  const typecheckDir = path.join(this.#app.cwdPath, ".akan", "typecheck");
210
215
  await mkdir(typecheckDir, { recursive: true });
211
216
  const libPageIncludes = (await this.#app.getPageRoots()).filter((root) => root.keyPrefix).flatMap((root) => {
@@ -272,9 +277,9 @@ void run().catch((error) => {
272
277
  throw new AggregateError(result.logs, `[${label}] Bun.build failed`);
273
278
  return result;
274
279
  }
275
- #createExternalSpecifiersPlugin(specifiers) {
276
- const uniqueSpecifiers = [...new Set(specifiers)];
277
- const escaped = uniqueSpecifiers.map((specifier) => specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
280
+ #createExternalSpecifiersPlugin(externalLibs) {
281
+ const specifiers = new Set([...externalLibs, ...SSR_RENDER_EXTERNALS, ...AKAN_OPTIONAL_BACKEND_EXTERNALS]);
282
+ const escaped = [...specifiers].map((specifier) => specifier.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
278
283
  const filter = new RegExp(`^(${escaped.join("|")})(?:/.*)?$`);
279
284
  return {
280
285
  name: "akan-backend-externalize-specifiers",
@@ -283,13 +288,7 @@ void run().catch((error) => {
283
288
  }
284
289
  };
285
290
  }
286
- static formatBytes(bytes) {
287
- if (bytes < 1024)
288
- return `${bytes}B`;
289
- if (bytes < 1024 * 1024)
290
- return `${(bytes / 1024).toFixed(1)}KB`;
291
- return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
292
- }
291
+ static formatBytes = FontPruner.formatBytes;
293
292
  }
294
293
  export {
295
294
  ApplicationBuildRunner