@akanjs/cli 3.0.0-alpha.8 → 3.0.0-alpha.80

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 (152) hide show
  1. package/.build-stamp +1 -1
  2. package/README.ko.md +1 -1
  3. package/README.md +1 -1
  4. package/{abstractCompactor-e5yq60qz.js → abstractCompactor-pwc6d6yk.js} +3 -5
  5. package/{agent.command-pggr92jj.js → agent.command-180hh0ye.js} +11 -12
  6. package/{application.command-692yap1d.js → application.command-gmcgen9y.js} +59 -35
  7. package/{applicationBuildRunner-ha3y8ew8.js → applicationBuildRunner-tavpx3fv.js} +22 -20
  8. package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-ktjt0erc.js} +8 -9
  9. package/buildBatch.proc.js +12 -13
  10. package/capacitorApp-kwa67kzs.js +12 -0
  11. package/{cloud.command-wqfsyzv2.js → cloud.command-gpq7qxrc.js} +15 -17
  12. package/commandManifest.json +1 -1
  13. package/{context.command-9bxtdn0w.js → context.command-dk2m2sjx.js} +19 -22
  14. package/dependencyScanner-c64m6fxp.js +8 -0
  15. package/fleet.command-3bkyyd3a.js +836 -0
  16. package/getDirname-dr3jz1xg.js +7 -0
  17. package/{guideline.command-nfqahxex.js → guideline.command-w6ddv13r.js} +16 -17
  18. package/guidelines/agentRule/agentRule.generate.json +31 -0
  19. package/guidelines/agentRule/agentRule.instruction.md +525 -0
  20. package/guidelines/conventions/conventions.generate.json +25 -0
  21. package/guidelines/conventions/conventions.instruction.md +847 -0
  22. package/guidelines/cssRule/cssRule.instruction.md +7 -0
  23. package/guidelines/framework/framework.generate.json +3 -2
  24. package/guidelines/framework/framework.instruction.md +1 -9
  25. package/guidelines/mcpRule/mcpRule.generate.json +25 -0
  26. package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
  27. package/guidelines/queryRule/queryRule.generate.json +31 -0
  28. package/guidelines/queryRule/queryRule.instruction.md +143 -0
  29. package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
  30. package/guidelines/runtimeRule/runtimeRule.instruction.md +176 -0
  31. package/guidelines/ssrRule/ssrRule.instruction.md +49 -5
  32. package/guidelines/transportRule/transportRule.generate.json +31 -0
  33. package/guidelines/transportRule/transportRule.instruction.md +60 -0
  34. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
  35. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
  36. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
  37. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
  38. package/incrementalBuilder.proc.js +21 -22
  39. package/{index-4hek879p.js → index-1kzsn94d.js} +1 -1
  40. package/{index-p3f4q532.js → index-3c9n3nt8.js} +31 -30
  41. package/index-3d9y066c.js +76 -0
  42. package/{index-76rn3g2c.js → index-47pj3aee.js} +4 -4
  43. package/{index-gex7c8kd.js → index-5n0hf8r9.js} +65 -38
  44. package/{index-mssqn2sq.js → index-5y7qba1c.js} +79 -33
  45. package/index-6wwzs1bc.js +7 -0
  46. package/{index-wnp7hwq7.js → index-92zztqy1.js} +7 -7
  47. package/{index-fgc8r6dj.js → index-a5vmm6x4.js} +3 -1
  48. package/{index-azv0xjb5.js → index-a8h184wr.js} +15 -11
  49. package/{index-67546d0j.js → index-ayy5ecax.js} +1 -1
  50. package/{index-xhgtkekh.js → index-b2nt0w0k.js} +27 -27
  51. package/{index-xys926f2.js → index-by5gpp8x.js} +4 -4
  52. package/{index-bz2sfzzt.js → index-cd5x18qh.js} +32 -32
  53. package/{index-bjpxzr6s.js → index-ctphds8v.js} +1 -1
  54. package/{index-w6wbb612.js → index-dq6wq1tv.js} +94 -61
  55. package/{index-js368gk9.js → index-ee8z8adx.js} +13 -13
  56. package/{index-5dw57f0d.js → index-f7wewj2v.js} +155 -76
  57. package/{index-6rhabeev.js → index-ft1sfjz0.js} +36 -25
  58. package/{index-7myvn0f0.js → index-h7yw2z9n.js} +7 -7
  59. package/{index-5pmx7bkg.js → index-j9vnq8tr.js} +18 -18
  60. package/{index-vg0sj9nc.js → index-k1n0h7dk.js} +840 -201
  61. package/{index-vtj3zps1.js → index-k86zc21w.js} +57 -57
  62. package/{index-46tjzh6s.js → index-mfm35dhh.js} +29 -29
  63. package/{index-xjd3rqzj.js → index-n68jx79w.js} +6 -15
  64. package/{index-ztpw544k.js → index-qcracvc9.js} +8 -8
  65. package/{index-2c3e2xh8.js → index-saheq2bs.js} +4 -4
  66. package/{index-gmy45vz2.js → index-v0s24t8j.js} +14 -14
  67. package/{index-0cj2zxbm.js → index-wet2ytnr.js} +12 -11
  68. package/{index-j9cxndc0.js → index-x23688ar.js} +12 -7
  69. package/index-xnhf8tr9.js +109 -0
  70. package/{index-a1e0j63x.js → index-xxe90kqy.js} +58 -25
  71. package/{index-qb61h0k7.js → index-z3c9mmw4.js} +1098 -1360
  72. package/index.js +22 -24
  73. package/{library.command-md9715jz.js → library.command-wpedct6c.js} +11 -9
  74. package/{localRegistry.command-exkbamyj.js → localRegistry.command-pjdxa01g.js} +20 -22
  75. package/{module.command-w5aaddxk.js → module.command-8n4kct3e.js} +13 -15
  76. package/{package.command-yfkrcy0z.js → package.command-fcbd0b1d.js} +8 -9
  77. package/package.json +5 -7
  78. package/{page.command-echbavp4.js → page.command-x4379grq.js} +7 -8
  79. package/{primitive.command-9fbhspw2.js → primitive.command-8etmnqhq.js} +13 -15
  80. package/{quality.command-3pnt9yep.js → quality.command-hfx7z8yr.js} +226 -104
  81. package/recipeScanner-fpagtgc1.js +11 -0
  82. package/{repair.command-carj4vax.js → repair.command-j0fs5qkz.js} +12 -13
  83. package/{routeSourceValidator-e4jmbfcx.js → routeSourceValidator-ze6x894c.js} +0 -2
  84. package/{scalar.command-51ryzypc.js → scalar.command-2emk89eh.js} +11 -13
  85. package/templates/app/env/env.client.debug.ts.template +1 -5
  86. package/templates/app/env/env.client.develop.ts.template +1 -5
  87. package/templates/app/env/env.client.local.ts.template +1 -5
  88. package/templates/app/env/env.client.main.ts.template +1 -5
  89. package/templates/app/env/env.client.testing.ts.template +1 -5
  90. package/templates/app/env/env.client.type.ts +2 -6
  91. package/templates/app/env/env.server.debug.ts.template +1 -5
  92. package/templates/app/env/env.server.develop.ts.template +1 -5
  93. package/templates/app/env/env.server.local.ts.template +1 -5
  94. package/templates/app/env/env.server.main.ts.template +1 -5
  95. package/templates/app/main.ts +3 -1
  96. package/templates/appSample/lib/task/task.signal.ts +11 -6
  97. package/templates/appSample/srvkit/AuthGuard.ts +9 -5
  98. package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
  99. package/templates/crudPages/[__model__Id]/edit/page.tsx +6 -6
  100. package/templates/crudPages/[__model__Id]/page.tsx +10 -13
  101. package/templates/crudPages/new/page.tsx +6 -6
  102. package/templates/crudPages/page.tsx +9 -9
  103. package/templates/crudSinglePage/page.tsx +11 -7
  104. package/templates/env/_env.server.type.ts +7 -5
  105. package/templates/lib/db.ts +1 -1
  106. package/templates/lib/dict.ts +1 -1
  107. package/templates/lib/sig.ts +1 -1
  108. package/templates/lib/srv.ts +6 -2
  109. package/templates/module/__Model__.Util.tsx +1 -1
  110. package/templates/module/__Model__.Zone.tsx +3 -5
  111. package/templates/module/__model__.dictionary.ts +4 -1
  112. package/templates/module/__model__.signal.ts +2 -3
  113. package/templates/module/__model__.store.ts +1 -2
  114. package/templates/workspaceRoot/.gitignore.template +0 -1
  115. package/templates/workspaceRoot/AGENTS.md.template +4 -972
  116. package/templates/workspaceRoot/CLAUDE.md.template +19 -0
  117. package/templates/workspaceRoot/biome.json.template +4 -244
  118. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +10 -14
  119. package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
  120. package/templates/workspaceRoot/package.json.template +2 -4
  121. package/typeChecker-3xgrzc2v.js +7 -0
  122. package/typecheck.proc.js +4 -5
  123. package/{workflow.command-91wmvm8k.js → workflow.command-cvpmzwjg.js} +21 -23
  124. package/{workspace.command-wa10mfd9.js → workspace.command-mbb5s3wx.js} +108 -91
  125. package/capacitorApp-p0z5yab2.js +0 -60
  126. package/dependencyScanner-f6grrep3.js +0 -9
  127. package/index-mxvakhsm.js +0 -66
  128. package/index-r24hmh0q.js +0 -4
  129. package/recipeScanner-tghkzrrt.js +0 -12
  130. package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
  131. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -34
  132. package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
  133. package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
  134. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
  135. package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
  136. package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
  137. package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
  138. package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
  139. package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -19
  140. package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -62
  141. package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
  142. package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
  143. package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
  144. package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -99
  145. package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
  146. package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
  147. package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
  148. package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
  149. package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
  150. package/typeChecker-kravn7ns.js +0 -8
  151. /package/{index-0wae5ebk.js → index-meh558jy.js} +0 -0
  152. /package/{index-ss469dec.js → index-nz8prx9g.js} +0 -0
@@ -1,27 +1,28 @@
1
1
  // @bun
2
- import {
3
- resolveMobileTargets
4
- } from "./index-76rn3g2c.js";
5
- import {
6
- LibraryScript
7
- } from "./index-a1e0j63x.js";
8
2
  import {
9
3
  runner,
10
4
  script
11
- } from "./index-6rhabeev.js";
5
+ } from "./index-ft1sfjz0.js";
6
+ import {
7
+ WorkspaceExecutor,
8
+ AppExecutor,
9
+ LibExecutor,
10
+ PkgExecutor
11
+ } from "./index-k1n0h7dk.js";
12
+ import {
13
+ LibraryScript
14
+ } from "./index-xxe90kqy.js";
12
15
  import {
13
16
  HmrWatcher,
14
17
  WatchRootResolver
15
- } from "./index-bjpxzr6s.js";
18
+ } from "./index-ctphds8v.js";
16
19
  import {
17
- AppExecutor,
18
- LibExecutor,
19
- PkgExecutor,
20
- WorkspaceExecutor
21
- } from "./index-vg0sj9nc.js";
20
+ SlicePlanner,
21
+ formatSlicePlan
22
+ } from "./index-xnhf8tr9.js";
22
23
  import {
23
- __require
24
- } from "./index-r24hmh0q.js";
24
+ resolveMobileTargets
25
+ } from "./index-47pj3aee.js";
25
26
 
26
27
  // pkgs/@akanjs/devkit/applicationBuildReporter.ts
27
28
  import { Logger } from "akanjs/common";
@@ -72,9 +73,10 @@ Caused by: ${ApplicationBuildReporter.formatError(error.cause)}` : "";
72
73
  import { confirm } from "@inquirer/prompts";
73
74
  import { Logger as Logger5 } from "akanjs/common";
74
75
 
76
+ // pkgs/@akanjs/cli/application/application.runner.ts
77
+ import path5 from "path";
78
+
75
79
  // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
76
- import { stat } from "fs/promises";
77
- import path2 from "path";
78
80
  import { Logger as Logger3 } from "akanjs/common";
79
81
 
80
82
  // pkgs/@akanjs/devkit/sshTunnel.ts
@@ -350,7 +352,7 @@ class IncrementalBuilderHost {
350
352
  return false;
351
353
  this.#recycleRequested = true;
352
354
  this.#status = "recycling";
353
- this.logger.info(`recycling builder pid=${proc.pid} (${reason})`);
355
+ this.logger.debug(`recycling builder pid=${proc.pid} (${reason})`);
354
356
  this.#recycleTimer = setTimeout(() => {
355
357
  this.#recycleTimer = null;
356
358
  if (this.#proc !== proc)
@@ -470,38 +472,23 @@ class BuilderRequestRouter {
470
472
  }
471
473
  }
472
474
 
473
- // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
474
- var backendMsgTypeSet = new Set(["build-route", "build-csr"]);
475
- var BACKEND_RESTART_DEBOUNCE_MS = 120;
476
- var BACKEND_GRACEFUL_TIMEOUT_MS = 8000;
477
- var BACKEND_RECOVERY_BASE_DELAY_MS = 1000;
478
- var BACKEND_RECOVERY_MAX_DELAY_MS = 30000;
475
+ // pkgs/@akanjs/devkit/akanApp/BackendImportGraph.ts
476
+ import { stat } from "fs/promises";
477
+ import path3 from "path";
478
+
479
+ // pkgs/@akanjs/devkit/akanApp/devHostPolicy.ts
480
+ import path2 from "path";
479
481
  var BACKEND_RECOVERY_MAX_ATTEMPTS = 5;
480
- var BACKEND_STDERR_TAIL_LIMIT = 40;
481
- var BUILDER_READY_TIMEOUT_MS = 150000;
482
- var BUILDER_START_MAX_ATTEMPTS = 3;
483
482
  var HELD_BUILDER_REQUEST_LIMIT = 64;
484
- var BUILDER_RSS_RECYCLE_QUIET_MS = 750;
485
483
  var BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS = 30000;
486
484
  var BUILDER_TIGHT_RSS_REPORT_LIMIT = 2;
487
- var BUILDER_RSS_SETTLE_MS = 20000;
488
- var PS_RSS_TIMEOUT_MS = 2000;
489
485
  var BUILDER_RSS_HARD_MULTIPLE = 1.5;
490
486
  var DEV_IDLE_SUSPEND_MS = 300000;
491
487
  var DEV_IDLE_MIN_UPTIME_MS = 30000;
492
- var BUILDER_RECOVERY_BASE_DELAY_MS = 2000;
493
- var BUILDER_RECOVERY_MAX_DELAY_MS = 60000;
494
488
  var SOURCE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
495
- var NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav|html)$/i;
496
489
  var SERVER_SUFFIXES = [".service.ts", ".document.ts"];
497
490
  var SHARED_SUFFIXES = [".constant.ts", ".dictionary.ts", ".signal.ts"];
498
491
  var RUNTIME_METADATA_BASENAMES = new Set(["dict.ts", "sig.ts", "useClient.ts", "useServer.ts"]);
499
- var GRAPH_IMPORT_KINDS = new Set([
500
- "import-statement",
501
- "require-call",
502
- "require-resolve",
503
- "dynamic-import"
504
- ]);
505
492
  var shouldRestartBackendByDevPlan = (message) => {
506
493
  if (!message.devPlan)
507
494
  return null;
@@ -682,6 +669,15 @@ var mergeInvalidateMessages = (current, next) => {
682
669
  var buildStatusReplaySequence = (pendingReplay, latestByPhase) => [...pendingReplay, ...latestByPhase.values()];
683
670
  var filesChangedSince = (before, after) => [...before].filter(([file, stamp]) => after.get(file) !== stamp).map(([file]) => file);
684
671
 
672
+ // pkgs/@akanjs/devkit/akanApp/BackendImportGraph.ts
673
+ var NON_SOURCE_EXT_RE = /\.(css|scss|sass|less|json|svg|png|jpe?g|webp|gif|avif|ico|woff2?|ttf|otf|mp3|mp4|wav|html)$/i;
674
+ var GRAPH_IMPORT_KINDS = new Set([
675
+ "import-statement",
676
+ "require-call",
677
+ "require-resolve",
678
+ "dynamic-import"
679
+ ]);
680
+
685
681
  class BackendImportGraph {
686
682
  #app;
687
683
  #logger;
@@ -704,7 +700,7 @@ class BackendImportGraph {
704
700
  return this.#lastRefreshSucceeded;
705
701
  }
706
702
  has(file) {
707
- return this.#files.has(path2.resolve(file));
703
+ return this.#files.has(path3.resolve(file));
708
704
  }
709
705
  async fingerprint() {
710
706
  const stamps = await Promise.all([...this.#files].map(async (file) => {
@@ -732,9 +728,9 @@ class BackendImportGraph {
732
728
  const roots = await this.#entrypoints();
733
729
  const files = new Set;
734
730
  const queue = [...roots];
735
- const workspaceRoot = path2.resolve(this.#app.workspace.workspaceRoot);
731
+ const workspaceRoot = path3.resolve(this.#app.workspace.workspaceRoot);
736
732
  while (queue.length > 0) {
737
- const current = path2.resolve(queue.pop());
733
+ const current = path3.resolve(queue.pop());
738
734
  if (files.has(current))
739
735
  continue;
740
736
  if (!this.#isWorkspaceSource(current, workspaceRoot))
@@ -743,7 +739,7 @@ class BackendImportGraph {
743
739
  if (!imports)
744
740
  continue;
745
741
  files.add(current);
746
- const importerDir = path2.dirname(current);
742
+ const importerDir = path3.dirname(current);
747
743
  for (const imp of imports) {
748
744
  if (!GRAPH_IMPORT_KINDS.has(imp.kind) || !imp.path || NON_SOURCE_EXT_RE.test(imp.path))
749
745
  continue;
@@ -774,7 +770,7 @@ class BackendImportGraph {
774
770
  const roots = [`${this.#app.cwdPath}/main.ts`, `${this.#app.cwdPath}/server.ts`];
775
771
  const existing = [];
776
772
  for (const root of roots) {
777
- const abs = path2.resolve(root);
773
+ const abs = path3.resolve(root);
778
774
  if (await Bun.file(abs).exists())
779
775
  existing.push(abs);
780
776
  }
@@ -783,25 +779,25 @@ class BackendImportGraph {
783
779
  #resolve(specifier, importerDir) {
784
780
  try {
785
781
  const resolved = Bun.resolveSync(specifier, importerDir);
786
- if (!path2.isAbsolute(resolved))
782
+ if (!path3.isAbsolute(resolved))
787
783
  return null;
788
- if (!SOURCE_EXTS.has(path2.extname(resolved).toLowerCase()))
784
+ if (!SOURCE_EXTS.has(path3.extname(resolved).toLowerCase()))
789
785
  return null;
790
- return path2.resolve(resolved);
786
+ return path3.resolve(resolved);
791
787
  } catch {
792
788
  return null;
793
789
  }
794
790
  }
795
791
  #isWorkspaceSource(file, workspaceRoot) {
796
- const rel = path2.relative(workspaceRoot, file);
797
- if (rel.startsWith("..") || path2.isAbsolute(rel))
792
+ const rel = path3.relative(workspaceRoot, file);
793
+ if (rel.startsWith("..") || path3.isAbsolute(rel))
798
794
  return false;
799
- if (rel.includes(`${path2.sep}node_modules${path2.sep}`) || rel.includes(`${path2.sep}.akan${path2.sep}`))
795
+ if (rel.includes(`${path3.sep}node_modules${path3.sep}`) || rel.includes(`${path3.sep}.akan${path3.sep}`))
800
796
  return false;
801
- return SOURCE_EXTS.has(path2.extname(file).toLowerCase());
797
+ return SOURCE_EXTS.has(path3.extname(file).toLowerCase());
802
798
  }
803
799
  #scanImports(file, source) {
804
- const ext = path2.extname(file).toLowerCase();
800
+ const ext = path3.extname(file).toLowerCase();
805
801
  if (ext === ".tsx")
806
802
  return this.#tsxTranspiler.scanImports(source);
807
803
  if (ext === ".jsx")
@@ -812,6 +808,21 @@ class BackendImportGraph {
812
808
  }
813
809
  }
814
810
 
811
+ // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
812
+ var backendMsgTypeSet = new Set(["build-route", "build-csr"]);
813
+ var BACKEND_RESTART_DEBOUNCE_MS = 120;
814
+ var BACKEND_GRACEFUL_TIMEOUT_MS = 8000;
815
+ var BACKEND_RECOVERY_BASE_DELAY_MS = 1000;
816
+ var BACKEND_RECOVERY_MAX_DELAY_MS = 30000;
817
+ var BACKEND_STDERR_TAIL_LIMIT = 40;
818
+ var BUILDER_READY_TIMEOUT_MS = 150000;
819
+ var BUILDER_START_MAX_ATTEMPTS = 3;
820
+ var BUILDER_RSS_RECYCLE_QUIET_MS = 750;
821
+ var BUILDER_RSS_SETTLE_MS = 20000;
822
+ var PS_RSS_TIMEOUT_MS = 2000;
823
+ var BUILDER_RECOVERY_BASE_DELAY_MS = 2000;
824
+ var BUILDER_RECOVERY_MAX_DELAY_MS = 60000;
825
+
815
826
  class AkanAppHost {
816
827
  app;
817
828
  logger = new Logger3("AkanAppHost");
@@ -907,6 +918,7 @@ class AkanAppHost {
907
918
  }
908
919
  #startBackend(startStatus = null) {
909
920
  this.#builderRequests.startGeneration();
921
+ this.#discardPendingBuilderMessages("the backend restarted while the builder was away");
910
922
  this.#backendStartStatus = startStatus;
911
923
  this.#backendGaveUp = false;
912
924
  this.#setBackendLifecycleState("starting");
@@ -1498,6 +1510,12 @@ ${this.#backendStderrTail.join(`
1498
1510
  this.#pendingBuilderMessages.push(message);
1499
1511
  this.logger.verbose(`[builder] holding ${message.type} until the builder is ready (${this.#pendingBuilderMessages.length} waiting)`);
1500
1512
  }
1513
+ #discardPendingBuilderMessages(reason) {
1514
+ const held = this.#pendingBuilderMessages.splice(0);
1515
+ if (held.length === 0)
1516
+ return;
1517
+ this.logger.verbose(`[builder] dropped ${held.length} held builder request(s): ${reason}`);
1518
+ }
1501
1519
  #failPendingBuilderMessages(reason) {
1502
1520
  const held = this.#pendingBuilderMessages.splice(0);
1503
1521
  if (held.length === 0)
@@ -1858,20 +1876,20 @@ ${this.#backendStderrTail.join(`
1858
1876
  }
1859
1877
  }
1860
1878
  // pkgs/@akanjs/devkit/applicationTestPreload.ts
1861
- import path3 from "path";
1879
+ import path4 from "path";
1862
1880
  var SIGNAL_TEST_PRELOAD_PATH = "test/signalTest.preload.ts";
1863
1881
  async function resolveSignalTestPreloadPath(target) {
1864
1882
  const candidates = [];
1865
1883
  const addResolvedPackageCandidate = (basePath) => {
1866
1884
  try {
1867
- candidates.push(path3.join(path3.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
1885
+ candidates.push(path4.join(path4.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
1868
1886
  } catch {}
1869
1887
  };
1870
1888
  addResolvedPackageCandidate(target.cwdPath);
1871
1889
  addResolvedPackageCandidate(process.cwd());
1872
- addResolvedPackageCandidate(path3.dirname(Bun.main));
1890
+ addResolvedPackageCandidate(path4.dirname(Bun.main));
1873
1891
  addResolvedPackageCandidate(import.meta.dir);
1874
- candidates.push(path3.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path3.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path3.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path3.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path3.join(path3.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path3.resolve(import.meta.dir, "../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
1892
+ candidates.push(path4.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.join(path4.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path4.resolve(import.meta.dir, "../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
1875
1893
  const uniqueCandidates = [...new Set(candidates)];
1876
1894
  for (const candidate of uniqueCandidates) {
1877
1895
  if (await Bun.file(candidate).exists())
@@ -1898,10 +1916,10 @@ function openBrowser(url) {
1898
1916
  }
1899
1917
 
1900
1918
  // pkgs/@akanjs/cli/application/application.runner.ts
1901
- var loadBuildRunner = async () => (await import("./applicationBuildRunner-ha3y8ew8.js")).ApplicationBuildRunner;
1902
- var loadReleasePackager = async () => (await import("./applicationReleasePackager-gg8ccbeh.js")).ApplicationReleasePackager;
1903
- var loadCapacitorApp = async () => (await import("./capacitorApp-p0z5yab2.js")).CapacitorApp;
1904
- var loadAbstractCompactor = async () => (await import("./abstractCompactor-e5yq60qz.js")).AbstractCompactor;
1919
+ var loadBuildRunner = async () => (await import("./applicationBuildRunner-tavpx3fv.js")).ApplicationBuildRunner;
1920
+ var loadReleasePackager = async () => (await import("./applicationReleasePackager-ktjt0erc.js")).ApplicationReleasePackager;
1921
+ var loadCapacitorApp = async () => (await import("./capacitorApp-kwa67kzs.js")).CapacitorApp;
1922
+ var loadAbstractCompactor = async () => (await import("./abstractCompactor-pwc6d6yk.js")).AbstractCompactor;
1905
1923
  var loadPrompts = async () => await import("@inquirer/prompts");
1906
1924
 
1907
1925
  class ApplicationRunner extends runner("application") {
@@ -1914,8 +1932,11 @@ class ApplicationRunner extends runner("application") {
1914
1932
  });
1915
1933
  return AppExecutor.from(workspace, appName);
1916
1934
  }
1935
+ async planSlice(app) {
1936
+ return await new SlicePlanner(app).plan();
1937
+ }
1917
1938
  async removeApplication(app) {
1918
- await app.workspace.exec(`rm -rf apps/${app.name}`);
1939
+ await app.workspace.removeDir(`apps/${app.name}`);
1919
1940
  }
1920
1941
  async getConfig(app) {
1921
1942
  return await app.getConfig();
@@ -1945,10 +1966,69 @@ class ApplicationRunner extends runner("application") {
1945
1966
  stdio: "inherit"
1946
1967
  });
1947
1968
  }
1969
+ #runtimeDirOf(app, override) {
1970
+ return path5.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path5.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
1971
+ }
1972
+ async runLogs(app, options) {
1973
+ const { LogControlUnavailableError, LogTailClient } = await import("akanjs/server/logging/logTailClient");
1974
+ const { LogQueryMatcher } = await import("akanjs/server/logging/logQuery");
1975
+ const runtimeDir = this.#runtimeDirOf(app, options.runtimeDir);
1976
+ const socketPath = LogTailClient.socketPath(runtimeDir);
1977
+ const { level, grep, endpoint, trace, child, role, origin, since } = options;
1978
+ const query = Object.fromEntries(Object.entries({ level, grep, endpoint, trace, child, role, origin, since }).filter(([, value]) => value !== undefined && value !== null && value !== ""));
1979
+ const print = (record) => process.stdout.write(options.json ? `${JSON.stringify(record)}
1980
+ ` : Logger4.render(record));
1981
+ const note = (text) => process.stderr.write(`[akan logs] ${text}
1982
+ `);
1983
+ let finish = null;
1984
+ const closed = new Promise((resolve) => {
1985
+ finish = resolve;
1986
+ });
1987
+ let client;
1988
+ try {
1989
+ client = await LogTailClient.connect(socketPath, {
1990
+ onRecord: (entry) => print(entry.record),
1991
+ onEvent: (response) => {
1992
+ if (response.type === "dropped")
1993
+ note(`${response.count} records dropped (reader too slow)`);
1994
+ },
1995
+ onClose: () => finish?.()
1996
+ });
1997
+ } catch (error) {
1998
+ if (error instanceof LogControlUnavailableError)
1999
+ throw new Error(`${app.name} is not running (no ${path5.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
2000
+ throw error;
2001
+ }
2002
+ const sinceMs = since ? LogQueryMatcher.parseSince(since) : undefined;
2003
+ const noteCoverage = (coverage) => {
2004
+ if (sinceMs !== undefined && coverage.from !== null && sinceMs < coverage.from)
2005
+ note(`${LogTailClient.describeCoverage(coverage)}; older records are not retained`);
2006
+ };
2007
+ if (endpoint)
2008
+ note("requests served by the primitive query fast path carry no endpoint and are not shown");
2009
+ if (options.follow === false) {
2010
+ const { entries, coverage } = await client.history({
2011
+ ...query,
2012
+ ...options.replay ? { limit: options.replay } : {}
2013
+ });
2014
+ for (const entry of entries)
2015
+ print(entry.record);
2016
+ noteCoverage(coverage);
2017
+ client.close();
2018
+ return;
2019
+ }
2020
+ const subscribed = await client.subscribe(query, { replay: options.replay });
2021
+ noteCoverage(subscribed.coverage);
2022
+ const stop = () => client.close();
2023
+ process.once("SIGINT", stop);
2024
+ process.once("SIGTERM", stop);
2025
+ await closed;
2026
+ }
1948
2027
  async runConsole(app) {
1949
2028
  const serverPath = `${app.cwdPath}/server.ts`;
1950
2029
  if (!await app.exists("server.ts"))
1951
2030
  throw new Error(`Server file not found: apps/${app.name}/server.ts`);
2031
+ const runtimeDir = this.#runtimeDirOf(app);
1952
2032
  const code = `
1953
2033
  const serverModule = await import(${JSON.stringify(serverPath)});
1954
2034
  const { assertAkanConsoleAllowed, startAkanConsole } = await import("akanjs/server");
@@ -1958,6 +2038,7 @@ assertAkanConsoleAllowed(server.env);
1958
2038
  await server.start({ listen: false, web: false });
1959
2039
  try {
1960
2040
  await startAkanConsole(server, {
2041
+ runtimeDir: ${JSON.stringify(runtimeDir)},
1961
2042
  globals: {
1962
2043
  srv: serverModule.srv,
1963
2044
  sig: serverModule.sig,
@@ -2329,6 +2410,12 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2329
2410
  await this.applicationRunner.removeApplication(app);
2330
2411
  spinner.succeed(`Application ${app.name} (apps/${app.name}) removed`);
2331
2412
  }
2413
+ async planSlice(app, format = "text") {
2414
+ const spinner = app.spinning("Planning distributable slice...");
2415
+ const plan = await this.applicationRunner.planSlice(app);
2416
+ spinner.succeed(`Slice planned (${plan.libs.length} libs, ${plan.warnings.length} warnings)`);
2417
+ Logger5.rawLog(format === "json" ? JSON.stringify(plan, null, 2) : formatSlicePlan(plan));
2418
+ }
2332
2419
  async sync(sys) {
2333
2420
  if (sys.type === "app")
2334
2421
  await sys.scanSync();
@@ -2355,6 +2442,9 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2355
2442
  await app.scanSync();
2356
2443
  await this.applicationRunner.runConsole(app);
2357
2444
  }
2445
+ async logs(app, options) {
2446
+ await this.applicationRunner.runLogs(app, options);
2447
+ }
2358
2448
  async build(app, { write = true, fast = false, quiet = false } = {}) {
2359
2449
  await app.scanSync({ write });
2360
2450
  if (!quiet)
@@ -2388,8 +2478,8 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2388
2478
  async test(exec, { write = true } = {}) {
2389
2479
  if (exec instanceof LibExecutor) {
2390
2480
  await this.libraryScript.syncLibrary(exec);
2391
- const spinner2 = exec.spinning(`Preparing ${exec.name}...`);
2392
- spinner2.succeed(`${exec.name} prepared`);
2481
+ const spinner = exec.spinning(`Preparing ${exec.name}...`);
2482
+ spinner.succeed(`${exec.name} prepared`);
2393
2483
  await this.applicationRunner.test(exec);
2394
2484
  return;
2395
2485
  }
@@ -2528,7 +2618,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2528
2618
  let stopping = false;
2529
2619
  process.on("SIGINT", () => {
2530
2620
  if (stopping) {
2531
- Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "warn");
2621
+ Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "error");
2532
2622
  process.exit(130);
2533
2623
  }
2534
2624
  stopping = true;
@@ -2542,18 +2632,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2542
2632
  }), timeout]);
2543
2633
  if (result !== "timeout")
2544
2634
  return;
2545
- Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "warn");
2546
- }
2547
- async testSys(sys) {
2548
- if (sys.type === "app")
2549
- await this.testApplication(sys);
2550
- else
2551
- await this.libraryScript.testLibrary(sys);
2552
- }
2553
- async testApplication(app) {
2554
- const spinner = app.spinning("Testing application...");
2555
- await this.applicationRunner.test(app);
2556
- spinner.succeed(`Application ${app.name} (apps/${app.name}) test is successful`);
2635
+ Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "error");
2557
2636
  }
2558
2637
  }
2559
2638
 
@@ -1,19 +1,18 @@
1
1
  // @bun
2
2
  import {
3
- AppExecutor,
4
3
  Executor,
4
+ WorkspaceExecutor,
5
+ AppExecutor,
5
6
  LibExecutor,
6
- ModuleExecutor,
7
7
  PkgExecutor,
8
- WorkspaceExecutor,
9
- getDirname
10
- } from "./index-vg0sj9nc.js";
8
+ ModuleExecutor
9
+ } from "./index-k1n0h7dk.js";
11
10
  import {
12
11
  FileSys
13
- } from "./index-67546d0j.js";
12
+ } from "./index-ayy5ecax.js";
14
13
  import {
15
- __require
16
- } from "./index-r24hmh0q.js";
14
+ getDirname2
15
+ } from "./index-6wwzs1bc.js";
17
16
 
18
17
  // pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
19
18
  var COMMAND_META = Symbol("akan.command.meta");
@@ -381,6 +380,16 @@ var prompts = async () => await import("@inquirer/prompts");
381
380
  var select = (config, context) => prompts().then((m) => m.select(config, context));
382
381
  var confirm = (config, context) => prompts().then((m) => m.confirm(config, context));
383
382
  var input = (config, context) => prompts().then((m) => m.input(config, context));
383
+ var assertEnumChoice = (argMeta, value) => {
384
+ const enumChoices = argMeta.argsOption.enum;
385
+ if (!enumChoices || typeof enumChoices === "function")
386
+ return;
387
+ const choices = normalizeEnumChoices(enumChoices);
388
+ if (choices.some((choice) => String(choice.value) === String(value)))
389
+ return;
390
+ const label = argMeta.type === "Option" ? `option '--${camelToKebabCase3(argMeta.name)}'` : `argument '${argMeta.name}'`;
391
+ throw new Error(`${label} argument '${String(value)}' is invalid. Allowed choices are ${choices.map((choice) => choice.name).join(", ")}.`);
392
+ };
384
393
  var resolveEnumChoices = async (argMeta, context) => {
385
394
  const enumChoices = argMeta.argsOption.enum;
386
395
  if (!enumChoices)
@@ -394,9 +403,10 @@ var getOptionValue = async (argMeta, opt, context) => {
394
403
  name,
395
404
  argsOption: { enum: enumChoices, default: defaultValue, type, desc, nullable, example, ask }
396
405
  } = argMeta;
397
- if (opt[argMeta.name] !== undefined)
406
+ if (opt[argMeta.name] !== undefined) {
407
+ assertEnumChoice(argMeta, opt[argMeta.name]);
398
408
  return convertArgValue(opt[argMeta.name], type ?? "string");
399
- else if (defaultValue !== undefined)
409
+ } else if (defaultValue !== undefined)
400
410
  return defaultValue;
401
411
  if (enumChoices) {
402
412
  const choices = normalizeEnumChoices(await resolveEnumChoices(argMeta, context) ?? []);
@@ -422,9 +432,10 @@ var getArgumentValue = async (argMeta, value) => {
422
432
  name,
423
433
  argsOption: { default: defaultValue, type, desc, nullable, example, ask }
424
434
  } = argMeta;
425
- if (value !== undefined)
435
+ if (value !== undefined) {
436
+ assertEnumChoice(argMeta, value);
426
437
  return convertArgValue(value, type ?? "string");
427
- else if (defaultValue !== undefined)
438
+ } else if (defaultValue !== undefined)
428
439
  return defaultValue;
429
440
  else if (nullable)
430
441
  return null;
@@ -526,36 +537,36 @@ var getInternalArgumentValue = async (argMeta, value, workspace) => {
526
537
  return PkgExecutor.from(workspace, pkgName);
527
538
  } else if (sysType === "module") {
528
539
  if (value) {
529
- const [sysName, moduleName2] = value.split(":");
530
- if (!sysName || !moduleName2)
540
+ const [sysName, moduleName] = value.split(":");
541
+ if (!sysName || !moduleName)
531
542
  throw new Error(`Invalid module name: ${value}`);
532
543
  if (appNames.includes(sysName)) {
533
544
  const app = AppExecutor.from(workspace, sysName);
534
- const modules2 = await app.getModules();
535
- if (modules2.includes(moduleName2))
536
- return ModuleExecutor.from(app, moduleName2);
545
+ const modules = await app.getModules();
546
+ if (modules.includes(moduleName))
547
+ return ModuleExecutor.from(app, moduleName);
537
548
  else
538
- throw new Error(`Invalid module name: ${moduleName2}`);
549
+ throw new Error(`Invalid module name: ${moduleName}`);
539
550
  } else if (libNames.includes(sysName)) {
540
551
  const lib = LibExecutor.from(workspace, sysName);
541
- const modules2 = await lib.getModules();
542
- if (modules2.includes(moduleName2))
543
- return ModuleExecutor.from(lib, moduleName2);
552
+ const modules = await lib.getModules();
553
+ if (modules.includes(moduleName))
554
+ return ModuleExecutor.from(lib, moduleName);
544
555
  } else
545
556
  throw new Error(`Invalid system name: ${sysName}`);
546
557
  }
547
558
  const { type, name } = await select({
548
559
  message: `select the App or Lib name`,
549
560
  choices: [
550
- ...appNames.map((name2) => ({ name: name2, value: { type: "app", name: name2 } })),
551
- ...libNames.map((name2) => ({ name: name2, value: { type: "lib", name: name2 } }))
561
+ ...appNames.map((name) => ({ name, value: { type: "app", name } })),
562
+ ...libNames.map((name) => ({ name, value: { type: "lib", name } }))
552
563
  ]
553
564
  });
554
565
  const executor = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
555
566
  const modules = await executor.getModules();
556
567
  const moduleName = await select({
557
568
  message: `Select the module name`,
558
- choices: modules.map((name2) => ({ name: `${executor.name}:${name2}`, value: name2 }))
569
+ choices: modules.map((name) => ({ name: `${executor.name}:${name}`, value: name }))
559
570
  });
560
571
  return ModuleExecutor.from(executor, moduleName);
561
572
  } else
@@ -566,7 +577,7 @@ var runCommands = async (...commands) => {
566
577
  printCliError(error);
567
578
  process.exit(1);
568
579
  });
569
- const __dirname2 = getDirname(import.meta.url);
580
+ const __dirname2 = getDirname2(import.meta.url);
570
581
  const packageJsonCandidates = [`${path.dirname(Bun.main)}/package.json`, `${__dirname2}/../package.json`];
571
582
  let cliPackageJson = null;
572
583
  for (const packageJsonPath of packageJsonCandidates) {
@@ -1,14 +1,14 @@
1
1
  // @bun
2
2
  import {
3
- getDirname
4
- } from "./index-vg0sj9nc.js";
3
+ getDirname2
4
+ } from "./index-6wwzs1bc.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/prompter.ts
7
7
  import fsPromise from "fs/promises";
8
8
  import { input, select } from "@inquirer/prompts";
9
9
  class Prompter {
10
10
  static async#getGuidelineRoot() {
11
- const dirname = getDirname(import.meta.url);
11
+ const dirname = getDirname2(import.meta.url);
12
12
  const candidates = [`${dirname}/guidelines`, `${dirname}/../cli/guidelines`];
13
13
  for (const candidate of candidates) {
14
14
  try {
@@ -19,7 +19,6 @@ class Prompter {
19
19
  return candidates[0];
20
20
  }
21
21
  static async selectGuideline() {
22
- const guidelineRoot = await Prompter.#getGuidelineRoot();
23
22
  const guideNames = await Prompter.listGuidelines();
24
23
  return await select({
25
24
  message: "Select a guideline",
@@ -37,10 +36,11 @@ class Prompter {
37
36
  return JSON.parse(guideJson);
38
37
  }
39
38
  static async getInstruction(guideName) {
39
+ const guideNames = await Prompter.listGuidelines();
40
+ if (!guideNames.includes(guideName))
41
+ throw new Error(`Unknown guideline "${guideName}". Available: ${guideNames.join(", ")}`);
40
42
  const guidelineRoot = await Prompter.#getGuidelineRoot();
41
- const filePath = `${guidelineRoot}/${guideName}/${guideName}.instruction.md`;
42
- const content = await fsPromise.readFile(filePath, "utf-8");
43
- return content;
43
+ return await fsPromise.readFile(`${guidelineRoot}/${guideName}/${guideName}.instruction.md`, "utf-8");
44
44
  }
45
45
  static async getUpdateRequest(guideName) {
46
46
  return await input({
@@ -1,32 +1,32 @@
1
1
  // @bun
2
2
  import {
3
- AkanContextAnalyzer
4
- } from "./index-mssqn2sq.js";
5
- import {
6
- WorkflowExecutor,
7
- compactWorkflowInputs,
8
- createDryRunWorkflowApplyReport,
3
+ jsonText,
4
+ workflowPlanApproval,
9
5
  createWorkflowApplyReport,
6
+ workflowCommandsForPlan,
7
+ writeWorkflowRunArtifact,
8
+ readWorkflowRunArtifact,
10
9
  createWorkflowBaselineSummary,
11
- createWorkflowPlan,
12
10
  createWorkflowValidationRunReport,
13
- getWorkflowSpec,
14
- jsonText,
11
+ createDryRunWorkflowApplyReport,
12
+ WorkflowExecutor,
15
13
  listWorkflowSpecs,
16
- readWorkflowRunArtifact,
17
- renderWorkflowApply,
18
- renderWorkflowExplain,
14
+ getWorkflowSpec,
15
+ compactWorkflowInputs,
16
+ createWorkflowPlan,
19
17
  renderWorkflowList,
18
+ renderWorkflowExplain,
20
19
  renderWorkflowPlan,
21
- renderWorkflowRunArtifact,
20
+ renderWorkflowApply,
22
21
  renderWorkflowValidation,
23
- workflowCommandsForPlan,
24
- workflowPlanApproval,
25
- writeWorkflowRunArtifact
26
- } from "./index-2c3e2xh8.js";
22
+ renderWorkflowRunArtifact
23
+ } from "./index-saheq2bs.js";
24
+ import {
25
+ AkanContextAnalyzer
26
+ } from "./index-5y7qba1c.js";
27
27
  import {
28
28
  runner
29
- } from "./index-6rhabeev.js";
29
+ } from "./index-ft1sfjz0.js";
30
30
 
31
31
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
32
32
  import { mkdir, readFile, writeFile } from "fs/promises";