@akanjs/cli 3.1.2-rc.4 → 3.2.0-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 (118) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-z34p8m91.js → CodeAgent-h6g8dg3a.js} +2 -2
  3. package/{CodeTui-nvd9fk3g.js → CodeTui-n9gacepn.js} +1 -1
  4. package/README.ko.md +9 -0
  5. package/README.md +9 -0
  6. package/TunnelShare-k3ja4w9x.js +14 -0
  7. package/{agent.command-962mp3kg.js → agent.command-2f657613.js} +19 -17
  8. package/akanCode.js +2 -2
  9. package/{application.command-1nr0bqq1.js → application.command-yb8v177e.js} +35 -21
  10. package/{applicationBuildRunner-xy7hnfzq.js → applicationBuildRunner-sctcmkyx.js} +55 -16
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-cj7b3m6y.js → cloud.command-et06ja22.js} +35 -18
  13. package/cloud.script-s6rbrwer.js +30 -0
  14. package/{code.command-asq7xrr6.js → code.command-7m67c7zc.js} +6 -6
  15. package/commandManifest.json +1 -1
  16. package/{context.command-fw4g2pw1.js → context.command-569z0rqf.js} +20 -19
  17. package/context.runner-ms8v1rxy.js +29 -0
  18. package/{guideline.command-43gfjsjv.js → guideline.command-gnv3e8p8.js} +2 -2
  19. package/guidelines/akanApi/akanApi.instruction.md +317 -0
  20. package/guidelines/conventions/rules/app.md +5 -5
  21. package/guidelines/conventions/rules/config.md +1 -1
  22. package/guidelines/conventions/rules/gates.md +10 -5
  23. package/incrementalBuilder.proc.js +69 -39
  24. package/{index-0tkj05cz.js → index-0fb3cpbt.js} +3 -3
  25. package/{index-6t7fkx73.js → index-1q1cjn8s.js} +21 -11
  26. package/{index-90q0w90q.js → index-3wjbhj2n.js} +1 -1
  27. package/{index-6zgt7zmx.js → index-48d5qsj3.js} +4 -4
  28. package/{index-z47rw9ez.js → index-5w9my9qe.js} +8 -8
  29. package/{index-qwe079ww.js → index-6wpaq392.js} +61 -15
  30. package/{index-kc871vpc.js → index-7xdpww43.js} +69 -12
  31. package/index-7y5yghjg.js +2969 -0
  32. package/{index-38patcx6.js → index-8g7tdsk4.js} +249 -696
  33. package/{index-kdswbvys.js → index-8pb9yvp8.js} +63 -21
  34. package/{index-hmj94es2.js → index-8ts9774g.js} +4 -4
  35. package/{index-r0q2ka2b.js → index-93ewzmp6.js} +43 -14
  36. package/{index-y0y0pnx8.js → index-9tbgb4d8.js} +1 -1
  37. package/index-abgh0jve.js +126 -0
  38. package/{index-t0hk1kxq.js → index-aj3ehkcx.js} +1 -1
  39. package/{index-demt944k.js → index-d4n1wmrz.js} +37 -4
  40. package/{index-sra1a5f8.js → index-drz9e84d.js} +22 -8
  41. package/{index-gfh90r3t.js → index-e3vmjtph.js} +2 -2
  42. package/{index-k64mhwbw.js → index-eajbmk10.js} +2 -1
  43. package/{index-g0yds382.js → index-ed6ea0qp.js} +1 -1
  44. package/{index-ap6ac70m.js → index-fjr4d6yd.js} +444 -368
  45. package/index-hqrkqxx2.js +176 -0
  46. package/{index-jzpeny42.js → index-jdamtr7e.js} +3 -3
  47. package/{index-ampz4vgv.js → index-kpdv34rq.js} +4 -4
  48. package/{index-kc6ffq0s.js → index-ktb3wcqz.js} +73 -34
  49. package/{index-dcm66hss.js → index-mmym5xmb.js} +4 -2
  50. package/{index-8d9r465x.js → index-mqntfzv5.js} +2 -2
  51. package/{index-4am4dvmf.js → index-ny2k80mv.js} +15 -3
  52. package/index-p6hjwt2d.js +1668 -0
  53. package/{index-53h0053j.js → index-rc5fvqj2.js} +12 -14
  54. package/{index-r8t5sq7z.js → index-ryrm5z2c.js} +66 -19
  55. package/{index-jzz6ye8x.js → index-s2grpzef.js} +40 -8
  56. package/{index-38by07nw.js → index-sr5da35e.js} +32 -9
  57. package/{index-qev8p5wp.js → index-sy481q2x.js} +1 -1
  58. package/{index-ck64kxrn.js → index-thckcabc.js} +2 -2
  59. package/{index-wymcdsas.js → index-vkzfk7qt.js} +25 -23
  60. package/{index-vkpqe29t.js → index-w639tvkd.js} +24 -125
  61. package/index-ygdbn9jn.js +122 -0
  62. package/{index-w60zxxye.js → index-zpv14wpy.js} +3 -3
  63. package/{index-2yan1ajk.js → index-zxsygkda.js} +18 -9
  64. package/index.js +24 -23
  65. package/{library.command-zh29tjdd.js → library.command-1gp5qe3r.js} +3 -3
  66. package/{localRegistry.command-k9pn9ahj.js → localRegistry.command-v3g21rex.js} +25 -16
  67. package/{module.command-dgpqs9fz.js → module.command-4xz9he6h.js} +6 -6
  68. package/{package.command-1je4hsca.js → package.command-s7qpnn1g.js} +12 -3
  69. package/package.json +2 -2
  70. package/{page.command-cgsasanh.js → page.command-fan34c49.js} +3 -3
  71. package/{pipeline.command-tb46sa8v.js → pipeline.command-ph4fnn9w.js} +2 -2
  72. package/{primitive.command-bzsy23x5.js → primitive.command-3fqh8emf.js} +7 -7
  73. package/{projectTypecheck-h8rgaczy.js → projectTypecheck-vkb40hjc.js} +1 -1
  74. package/{quality.command-120m9h6v.js → quality.command-ecj6exsh.js} +15 -10
  75. package/{repair.command-6m4wd0qv.js → repair.command-fe9jw719.js} +6 -6
  76. package/{scalar.command-3dn5hsc6.js → scalar.command-cnvfhk0n.js} +5 -5
  77. package/skills/akan-debug/SKILL.md +2 -1
  78. package/skills/akan-page/SKILL.md +16 -7
  79. package/skills/akan-service/SKILL.md +48 -19
  80. package/{subspace.command-s8nyfqbn.js → subspace.command-yxtt3v3e.js} +8 -8
  81. package/templates/app/lib/___appName__/__appName__.abstract.md.template +6 -0
  82. package/templates/app/page/_index.tsx +4 -284
  83. package/templates/app/page/_layout.tsx +1 -26
  84. package/templates/app/page/styles.css.template +58 -318
  85. package/templates/appSample/page/_index.tsx +281 -0
  86. package/templates/appSample/page/_layout.tsx +55 -0
  87. package/templates/appSample/page/styles.css.template +327 -0
  88. package/templates/libRoot/lib/___libName__/__libName__.abstract.md.template +6 -0
  89. package/templates/workspaceRoot/package.json.template +1 -12
  90. package/{tunnel.command-8mwrqkr3.js → tunnel.command-ggj38mqf.js} +7 -7
  91. package/{verify.command-2pspfy7k.js → verify.command-w9ttxkdz.js} +16 -14
  92. package/{workflow.command-7sy5vnsj.js → workflow.command-ss8devj0.js} +12 -12
  93. package/{workspace.command-x518tdv4.js → workspace.command-rw1p0xeq.js} +50 -38
  94. package/TunnelShare-jwbb50kz.js +0 -14
  95. package/cloud.script-8kr7qgfa.js +0 -27
  96. package/context.runner-p6m5cxk3.js +0 -28
  97. package/index-d894868w.js +0 -842
  98. package/index-re2kfscb.js +0 -1363
  99. /package/templates/{app → appSample}/page/_overrides.tsx +0 -0
  100. /package/templates/{app → appSample}/public/fonts/Pretendard-Black.woff2 +0 -0
  101. /package/templates/{app → appSample}/public/fonts/Pretendard-Bold.woff2 +0 -0
  102. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraBold.woff2 +0 -0
  103. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraLight.woff2 +0 -0
  104. /package/templates/{app → appSample}/public/fonts/Pretendard-Light.woff2 +0 -0
  105. /package/templates/{app → appSample}/public/fonts/Pretendard-Medium.woff2 +0 -0
  106. /package/templates/{app → appSample}/public/fonts/Pretendard-Regular.woff2 +0 -0
  107. /package/templates/{app → appSample}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
  108. /package/templates/{app → appSample}/public/fonts/Pretendard-Thin.woff2 +0 -0
  109. /package/templates/{app → appSample}/public/jelly/cloud.webp +0 -0
  110. /package/templates/{app → appSample}/public/jelly/comet.webp +0 -0
  111. /package/templates/{app → appSample}/public/jelly/moon.webp +0 -0
  112. /package/templates/{app → appSample}/public/jelly/planet.webp +0 -0
  113. /package/templates/{app → appSample}/public/jelly/rocket.webp +0 -0
  114. /package/templates/{app → appSample}/public/jelly/star.webp +0 -0
  115. /package/templates/{app → appSample}/public/jelly/sugar.webp +0 -0
  116. /package/templates/{app → appSample}/public/logo.png +0 -0
  117. /package/templates/{app → appSample}/ui/Recipe/index.ts +0 -0
  118. /package/templates/{app → appSample}/ui/Recipe/jellyButton.ts +0 -0
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-38by07nw.js";
4
+ } from "./index-sr5da35e.js";
5
5
  import {
6
6
  jsonText,
7
7
  createWorkflowBaselineSummary,
8
8
  buildAkanModuleContextIndex,
9
9
  toolingRolloutGate
10
- } from "./index-kdswbvys.js";
10
+ } from "./index-8pb9yvp8.js";
11
11
  import {
12
12
  buildResourceList,
13
13
  codexMcpConfigPath,
@@ -17,16 +17,16 @@ import {
17
17
  upsertCodexMcpServerBlock,
18
18
  renderDoctorText,
19
19
  AkanContextAnalyzer
20
- } from "./index-ck64kxrn.js";
20
+ } from "./index-thckcabc.js";
21
21
  import {
22
22
  runner
23
- } from "./index-r0q2ka2b.js";
23
+ } from "./index-93ewzmp6.js";
24
24
  import {
25
25
  NativeApp
26
- } from "./index-w60zxxye.js";
26
+ } from "./index-zpv14wpy.js";
27
27
  import {
28
28
  isPlaceholderAppId
29
- } from "./index-g0yds382.js";
29
+ } from "./index-ed6ea0qp.js";
30
30
  import {
31
31
  getMobileTargets,
32
32
  appIdsOf
@@ -36,13 +36,13 @@ import {
36
36
  } from "./index-j6eeh5d7.js";
37
37
  import {
38
38
  WorkspaceGraph
39
- } from "./index-vkpqe29t.js";
39
+ } from "./index-w639tvkd.js";
40
40
  import {
41
41
  RepairRunner
42
- } from "./index-0tkj05cz.js";
42
+ } from "./index-0fb3cpbt.js";
43
43
  import {
44
44
  WorkflowRunner
45
- } from "./index-wymcdsas.js";
45
+ } from "./index-vkzfk7qt.js";
46
46
 
47
47
  // pkgs/@akanjs/devkit/akanMcpContract.ts
48
48
  import { lstatSync, realpathSync } from "fs";
@@ -299,7 +299,7 @@ var readonlyMcpTools = [
299
299
  },
300
300
  {
301
301
  name: "get_graph",
302
- description: "Read-only Akan Graph from source, no dev server needed: models with their fields and relations, slices and endpoints with guards, the service methods and queries each calls, the store actions that fetch them, and the components and pages that use them. Every node and edge carries its source location. Pass app and/or module to scope a large workspace. Pass since (a git revision such as main, or HEAD for uncommitted work) for the Change Map instead: what changed since HEAD forked from it, working tree included, with each node, field and edge marked added, removed or changed, the unchanged neighbours they call or are called by, and the changed files no node covers, each marked the same way.",
302
+ description: "Read-only Akan Graph from source, no dev server needed: models with their fields and relations, slices and endpoints with the guards they name (each guard keyed by the app or lib that declares it, with its scope and the comment that says what it checks), the service methods and queries each calls, the store actions that fetch them, and the components and routes that use them. A module's jobs (internal: interval, cron, timeout, initialize, destroy, process) read their schedule and server or operation modes and call service methods like endpoints do; each adaptor a service plugs (an adapt() class, or an akanjs role) is a node, a method that calls it links to it, and an adaptor links to the adaptors it plugs itself. Each page/ file is a route (its URL pattern after the locale) or a layout, layouts wrap what they contain, and a route or layout that runs .guard() reads `guard` and links each function its guard calls; a layout's guard gates every route it wraps. A graph too large to answer unscoped drops first the routes and layouts that neither changed nor use a change; app or module brings them back. Every node and edge carries its source location. Pass app and/or module to scope a large workspace. Pass since (a git revision such as main, or HEAD for uncommitted work) for the Change Map instead: what changed since HEAD forked from it, working tree included, with each node, field and edge marked added, removed or changed, the unchanged neighbours they call or are called by, and the changed files no node covers, each marked the same way.",
303
303
  inputSchema: { type: "object", properties: { app: stringProperty, module: stringProperty, since: stringProperty } }
304
304
  },
305
305
  {
@@ -783,10 +783,8 @@ class ContextRunner2 extends runner("context") {
783
783
  const workflow = stringArg(args, "workflow");
784
784
  const inputs = workflowInputsArg(args);
785
785
  const planPath = typeof args.out === "string" && args.out ? args.out : defaultWorkflowPlanPath(workflow, inputs);
786
- const plan = parseJsonOutput(await new WorkflowRunner().plan(workflow, inputs, {
787
- format: "json",
788
- out: workflowArtifactPath(workspace, planPath)
789
- }));
786
+ const out = workflowArtifactPath(workspace, planPath);
787
+ const plan = parseJsonOutput(await new WorkflowRunner().plan(workflow, inputs, { format: "json", out, workspace }));
790
788
  return {
791
789
  ...plan,
792
790
  planPath,
@@ -1,28 +1,29 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationBuildReporter
4
- } from "./index-d894868w.js";
4
+ } from "./index-p6hjwt2d.js";
5
5
  import {
6
6
  script,
7
7
  ExitCodeError,
8
8
  markCliErrorPrinted,
9
9
  assertPromptable
10
- } from "./index-r0q2ka2b.js";
10
+ } from "./index-93ewzmp6.js";
11
11
  import {
12
+ SysExecutor,
12
13
  AppExecutor,
13
14
  LibExecutor,
14
15
  PkgExecutor
15
- } from "./index-38by07nw.js";
16
+ } from "./index-sr5da35e.js";
16
17
  import {
17
18
  DesktopServerStage
18
- } from "./index-g0yds382.js";
19
+ } from "./index-ed6ea0qp.js";
19
20
  import {
20
21
  LibraryScript
21
- } from "./index-8d9r465x.js";
22
+ } from "./index-mqntfzv5.js";
22
23
  import {
23
24
  ApplicationRunner,
24
25
  VerifyScope
25
- } from "./index-kc6ffq0s.js";
26
+ } from "./index-ktb3wcqz.js";
26
27
  import {
27
28
  PreviewChrome2,
28
29
  PreviewView2,
@@ -30,17 +31,18 @@ import {
30
31
  } from "./index-tenw3mah.js";
31
32
  import {
32
33
  formatSlicePlan
33
- } from "./index-qev8p5wp.js";
34
+ } from "./index-sy481q2x.js";
34
35
  import {
35
36
  openBrowser
36
37
  } from "./index-9dp031by.js";
37
38
 
38
39
  // pkgs/@akanjs/cli/application/application.script.ts
40
+ import path3 from "path";
39
41
  import { confirm } from "@inquirer/prompts";
40
42
  import { Logger as Logger3, toError } from "akanjs/common";
41
43
 
42
44
  // pkgs/@akanjs/cli/application/appPreview.ts
43
- import { closeSync, openSync, realpathSync } from "fs";
45
+ import { closeSync, openSync, realpathSync, statSync } from "fs";
44
46
  import { mkdir as mkdir2 } from "fs/promises";
45
47
  import path2 from "path";
46
48
  import { parseRouteModuleKey } from "akanjs/common";
@@ -628,11 +630,15 @@ class AppPreview {
628
630
  const unavailable = PreviewView2.unavailableReason(engine);
629
631
  if (unavailable)
630
632
  throw new Error(unavailable);
631
- const { i18n } = await app.getConfig();
633
+ const { i18n, api } = await app.getConfig();
632
634
  const changed = options.changed ? await AppPreview.#changedPages(app) : { paths: [], skipped: [] };
633
635
  if (options.changed && !changed.paths.length && !options.paths?.length)
634
636
  throw new Error(`No page to open: ${changed.skipped.join("; ")}. Pass a concrete path, e.g. \`akan preview ${app.name} /memo/1\`.`);
635
- const paths = AppPreview.pagePaths([...options.paths ?? [], ...changed.paths], i18n, { csr: !!options.csr });
637
+ const paths = AppPreview.pagePaths([...options.paths ?? [], ...changed.paths], i18n, {
638
+ csr: !!options.csr,
639
+ apiPrefix: api.prefix,
640
+ publicDir: path2.join(app.cwdPath, "public")
641
+ });
636
642
  const port = await app.getDevPort();
637
643
  const origin = `http://localhost:${port}`;
638
644
  const root = app.workspace.workspaceRoot;
@@ -684,10 +690,12 @@ class AppPreview {
684
690
  started?.proc.unref();
685
691
  }
686
692
  }
687
- static pagePaths(paths, i18n, { csr }) {
693
+ static pagePaths(paths, i18n, { csr, apiPrefix = "/api", publicDir = null }) {
688
694
  const keepsUnprefixed = i18n.localePrefix === "as-needed" && !csr;
689
695
  const pages = (paths.length ? paths : ["/"]).map((raw) => {
690
696
  const url = new URL(/^https?:\/\//.test(raw) ? raw : `http://localhost${raw.startsWith("/") ? "" : "/"}${raw}`);
697
+ if (!AppPreview.#isPagePath(url.pathname, i18n, { apiPrefix, publicDir }))
698
+ return `${url.pathname}${url.search}`;
691
699
  const [first] = url.pathname.split("/").filter(Boolean);
692
700
  if (!keepsUnprefixed && (!first || !i18n.locales.includes(first)))
693
701
  url.pathname = `/${i18n.defaultLocale}${url.pathname === "/" ? "/" : url.pathname}`;
@@ -699,6 +707,31 @@ class AppPreview {
699
707
  });
700
708
  return [...new Set(pages)];
701
709
  }
710
+ static #serverFiles = new Set(["/favicon.ico", "/robots.txt", "/sitemap.xml", "/manifest.webmanifest"]);
711
+ static #basePathFiles = new Set(["sitemap.xml", "manifest.webmanifest"]);
712
+ static #isPagePath(pathname, i18n, { apiPrefix, publicDir }) {
713
+ const segments = pathname.split("/").filter(Boolean);
714
+ const [first] = segments;
715
+ if (first && i18n.locales.includes(first))
716
+ return true;
717
+ const prefixes = ["/_akan", "/__csr", "/__rsc", "/.well-known", apiPrefix.replace(/\/+$/, "")].filter(Boolean);
718
+ if (prefixes.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)))
719
+ return false;
720
+ if (AppPreview.#serverFiles.has(pathname))
721
+ return false;
722
+ if (segments.length === 2 && AppPreview.#basePathFiles.has(segments[1] ?? ""))
723
+ return false;
724
+ return !(publicDir && AppPreview.#isPublicFile(publicDir, pathname));
725
+ }
726
+ static #isPublicFile(publicDir, pathname) {
727
+ try {
728
+ const root = path2.resolve(publicDir);
729
+ const filePath = path2.resolve(root, `.${decodeURIComponent(pathname)}`);
730
+ return filePath.startsWith(`${root}${path2.sep}`) && statSync(filePath).isFile();
731
+ } catch {
732
+ return false;
733
+ }
734
+ }
702
735
  static changedPageLimit = 8;
703
736
  static changedPages(sources, changedFiles) {
704
737
  const realOf = (file) => {
@@ -1224,9 +1257,9 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1224
1257
  throw error;
1225
1258
  }
1226
1259
  }
1227
- async createApplication(appName, workspace, { start = false, libs = [], sample = false } = {}) {
1260
+ async createApplication(appName, workspace, { start = false, libs = [] } = {}) {
1228
1261
  const spinner = workspace.spinning("Creating application...");
1229
- const app = await this.applicationRunner.createApplication(appName, workspace, libs, { sample });
1262
+ const app = await this.applicationRunner.createApplication(appName, workspace, libs);
1230
1263
  spinner.succeed(`Application created in apps/${app.name}`);
1231
1264
  await app.scanSync();
1232
1265
  if (start)
@@ -1305,13 +1338,21 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1305
1338
  write = true,
1306
1339
  fast = false,
1307
1340
  quiet = false,
1308
- profile
1341
+ profile,
1342
+ env,
1343
+ updateBudget = false
1309
1344
  } = {}) {
1310
1345
  await app.scanSync({ write });
1311
1346
  if (!quiet)
1312
1347
  Logger3.rawLog(`Creating an optimized production build for ${app.name}...`);
1313
1348
  try {
1314
- const result = await this.applicationRunner.build(app, { fast, spinner: !quiet, envProfile: profile });
1349
+ const result = await this.applicationRunner.build(app, {
1350
+ fast,
1351
+ spinner: !quiet,
1352
+ envProfile: profile,
1353
+ environment: env,
1354
+ budget: updateBudget ? "update" : "enforce"
1355
+ });
1315
1356
  Logger3.rawLog(`${app.name} built in dist/apps/${app.name}`);
1316
1357
  if (!quiet)
1317
1358
  ApplicationBuildReporter.printSummary(result);
@@ -1345,15 +1386,16 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1345
1386
  throw error;
1346
1387
  }
1347
1388
  }
1348
- async test(exec, { write = true, files = [] } = {}) {
1389
+ async test(exec, { write = true, files = [], coverage = false } = {}) {
1349
1390
  const testPaths = this.applicationRunner.resolveTestPaths(exec, files);
1391
+ const flags = coverage ? ApplicationScript.#coverageFlagsOf(exec) : [];
1350
1392
  if (exec instanceof LibExecutor) {
1351
1393
  if (write)
1352
1394
  await this.libraryScript.syncLibrary(exec);
1353
1395
  else
1354
1396
  await exec.scan({ write: false });
1355
1397
  exec.spinning(`Preparing ${exec.name}...`).succeed(`${exec.name} prepared`);
1356
- await this.applicationRunner.test(exec, testPaths);
1398
+ await this.applicationRunner.test(exec, testPaths, flags);
1357
1399
  return;
1358
1400
  }
1359
1401
  const spinner = exec.spinning(`Preparing ${exec.name}...`);
@@ -1367,7 +1409,12 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1367
1409
  spinner.fail(`${exec.name} prepare failed`);
1368
1410
  throw error;
1369
1411
  }
1370
- await this.applicationRunner.test(exec, testPaths);
1412
+ await this.applicationRunner.test(exec, testPaths, flags);
1413
+ }
1414
+ static #coverageFlagsOf(exec) {
1415
+ const root = exec instanceof SysExecutor || exec instanceof PkgExecutor ? exec.workspace.workspaceRoot : null;
1416
+ const dir = root ? path3.join(root, "local", "coverage", path3.relative(root, exec.cwdPath)) : "local/coverage";
1417
+ return ["--coverage", "--coverage-reporter=text", "--coverage-reporter=lcov", `--coverage-dir=${dir}`];
1371
1418
  }
1372
1419
  async start(apps, {
1373
1420
  open = false,
@@ -1600,7 +1647,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
1600
1647
  await Promise.all(shares.map(async (share) => await share.close()));
1601
1648
  }, "Abandoning the tunnel release; the shares expire on their own.");
1602
1649
  await Promise.all(apps.map(async (app) => {
1603
- const { TunnelShare } = await import("./TunnelShare-jwbb50kz.js");
1650
+ const { TunnelShare } = await import("./TunnelShare-k3ja4w9x.js");
1604
1651
  const share = await TunnelShare.open(app, { workspace: app.workspace });
1605
1652
  shares.push(share);
1606
1653
  urls.set(app.name, share.url);
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationBuildReporter
4
- } from "./index-d894868w.js";
4
+ } from "./index-p6hjwt2d.js";
5
5
  import {
6
6
  parseBiomeReport,
7
7
  Linter,
@@ -10,11 +10,11 @@ import {
10
10
  AppExecutor,
11
11
  LibExecutor,
12
12
  PkgExecutor
13
- } from "./index-38by07nw.js";
13
+ } from "./index-sr5da35e.js";
14
14
  import {
15
15
  WorkspaceRunner,
16
16
  AkanQualityScanner
17
- } from "./index-ap6ac70m.js";
17
+ } from "./index-fjr4d6yd.js";
18
18
 
19
19
  // pkgs/@akanjs/cli/verify/verifyComments.ts
20
20
  import { existsSync } from "fs";
@@ -188,6 +188,7 @@ import { existsSync as existsSync4 } from "fs";
188
188
  import path5 from "path";
189
189
 
190
190
  // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
191
+ import { readFileSync } from "fs";
191
192
  import path2 from "path";
192
193
 
193
194
  class VerifyDiagnostics {
@@ -222,7 +223,7 @@ class VerifyDiagnostics {
222
223
  fix: `check the spelling, or add ${key}: [en, ko] to .translate({}) in ${dictionaryFile}; one-off text takes l.trans({ en, ko })`
223
224
  };
224
225
  }
225
- static fromBiome(report) {
226
+ static fromBiome(report, root) {
226
227
  return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => {
227
228
  const file = diagnostic.location?.path?.replaceAll("\\", "/") ?? null;
228
229
  return {
@@ -232,10 +233,38 @@ class VerifyDiagnostics {
232
233
  col: diagnostic.location?.start?.column ?? 0,
233
234
  code: diagnostic.category ?? "biome",
234
235
  severity: diagnostic.severity === "error" ? "error" : "warning",
235
- ...VerifyDiagnostics.#adapterErrorOf(file, diagnostic.message) ?? { message: diagnostic.message }
236
+ ...VerifyDiagnostics.#adapterErrorOf(file, diagnostic.message) ?? VerifyDiagnostics.#deepImportOf(root, file, diagnostic) ?? { message: diagnostic.message }
236
237
  };
237
238
  });
238
239
  }
240
+ static #deepImport = /^Module files should not import from two or more parent directories/;
241
+ static #deepSpecifier = /["'](\.\.\/\.\.\/[^"']*)["']/g;
242
+ static #layerOf = /^(apps|libs)\/([\w-]+)\/(common|srvkit|webkit|ui)(?:\/|$)/;
243
+ static #deepImportOf(root, file, diagnostic) {
244
+ const start = diagnostic.location?.start;
245
+ if (!root || !file || !start || !VerifyDiagnostics.#deepImport.test(diagnostic.message))
246
+ return null;
247
+ let line;
248
+ try {
249
+ line = readFileSync(path2.join(root, file), "utf8").split(`
250
+ `)[start.line - 1] ?? "";
251
+ } catch {
252
+ return null;
253
+ }
254
+ const specifiers = [...line.matchAll(VerifyDiagnostics.#deepSpecifier)];
255
+ const specifier = (specifiers.find((match) => match.index === start.column - 1) ?? specifiers[0])?.[1];
256
+ if (!specifier)
257
+ return null;
258
+ const target = path2.posix.join(path2.posix.dirname(file), specifier);
259
+ const [, kind, name, layer] = target.match(VerifyDiagnostics.#layerOf) ?? [];
260
+ if (!kind || !name || !layer)
261
+ return null;
262
+ const barrel = `@${kind}/${name}/${layer}`;
263
+ return {
264
+ message: `Module files should not reach ${barrel} through two or more parent directories.`,
265
+ fix: `import from "${barrel}"`
266
+ };
267
+ }
239
268
  static #rawError = /^Do not (throw|construct) a raw `Error`/;
240
269
  static #srvkitFile = /^((?:apps|libs)\/([\w-]+))\/srvkit\//;
241
270
  static #adapterErrorOf(file, message) {
@@ -273,6 +302,9 @@ class VerifyDiagnostics {
273
302
  ...warning.fix ? { fix: warning.fix } : {}
274
303
  }));
275
304
  }
305
+ static fromRouteJsBudget({ file, message, fix }) {
306
+ return { step: "build", file, line: 0, col: 0, code: "akan.budget", severity: "warning", message, fix };
307
+ }
276
308
  static #prefix = /^\[([\w.-]+)\]\s*/;
277
309
  static #location = /((?:apps|libs|pkgs)\/[^\s:()`'"]+\.[a-z]+)(?::(\d+)(?::(\d+))?)?/;
278
310
  static fromMessage(step, message, code = `akan.${step}`) {
@@ -652,7 +684,7 @@ class VerifyPipeline {
652
684
  const report = parseBiomeReport(stdout);
653
685
  const diagnostics = await VerifyStyleClasses.dropDefined(this.#root, report.diagnostics ?? [], cssDirs);
654
686
  return {
655
- diagnostics: VerifyDiagnostics.fromBiome({ ...report, diagnostics }),
687
+ diagnostics: VerifyDiagnostics.fromBiome({ ...report, diagnostics }, this.#root),
656
688
  fixed: report.summary?.changed ?? 0
657
689
  };
658
690
  } catch {
@@ -685,8 +717,8 @@ class VerifyPipeline {
685
717
  }
686
718
  }
687
719
  async#build(target) {
688
- await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
689
- return { diagnostics: [] };
720
+ const { routeJsWarnings = [] } = await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
721
+ return { diagnostics: routeJsWarnings.map((warning) => VerifyDiagnostics.fromRouteJsBudget(warning)) };
690
722
  }
691
723
  async#ssr(scope) {
692
724
  const scanned = await new AkanQualityScanner().scan(this.#root);
@@ -1003,7 +1003,7 @@ class AkanAppConfig {
1003
1003
  }
1004
1004
  static localImageGuard = [
1005
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`
1006
+ `RUN if [ "$AKAN_ALLOW_LOCAL_IMAGE" != "1" ]; then echo "This build ran with AKAN_PUBLIC_ENV=local, so the server runs without endpoint rate limits and on local defaults for Redis and the database mode. Build for the environment it deploys to with akan build --env, or pass --build-arg AKAN_ALLOW_LOCAL_IMAGE=1." >&2; exit 1; fi`
1007
1007
  ].join(`
1008
1008
  `);
1009
1009
  dockerfileFor(environment, { lockfile = true } = {}) {
@@ -1359,6 +1359,30 @@ class AsyncDefaultExportDetector {
1359
1359
  }
1360
1360
  }
1361
1361
 
1362
+ // pkgs/@akanjs/devkit/artifact/storeBootstrap.ts
1363
+ class StoreBootstrap {
1364
+ static importLines(appName) {
1365
+ return StoreBootstrap.#lines([`@apps/${appName}/lib/useClient`, `@apps/${appName}/lib/st`]);
1366
+ }
1367
+ static source(appName) {
1368
+ return `${StoreBootstrap.importLines(appName).join(`
1369
+ `)}
1370
+ `;
1371
+ }
1372
+ static ofClientBarrel(specifier, exports) {
1373
+ if (!/^@(?:apps|libs)\/[^/]+\/client$/.test(specifier))
1374
+ return null;
1375
+ const runtime = exports.get("usePage");
1376
+ const store = exports.get("st");
1377
+ if (!runtime || runtime.namespace || !store || store.namespace)
1378
+ return StoreBootstrap.#lines([specifier]);
1379
+ return StoreBootstrap.#lines([...new Set([runtime.subpath, store.subpath])]);
1380
+ }
1381
+ static #lines(specifiers) {
1382
+ return specifiers.map((specifier) => `import ${JSON.stringify(specifier)};`);
1383
+ }
1384
+ }
1385
+
1362
1386
  // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
1363
1387
  var LAYOUT_KEY_RE = /^\.\/(.+\/)?_layout\.(tsx|ts|jsx|js)$/;
1364
1388
  var IMPLICIT_LAYOUT_DIR = path6.join(".akan", "generated", "root-layouts");
@@ -1467,10 +1491,7 @@ async function writeGeneratedRootLayoutFile(opts) {
1467
1491
  const sourceSpecifier = opts.boundary.sourceAbsPath ? importSpecifier(absPath, opts.boundary.sourceAbsPath) : null;
1468
1492
  const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
1469
1493
  const inheritedSourceSpecifier = inheritedSourceAbsPath ? importSpecifier(absPath, inheritedSourceAbsPath) : null;
1470
- const clientImport = opts.includeStInit ? `import { st } from "@apps/${opts.appName}/client";
1471
- void st;
1472
- ` : `import "@apps/${opts.appName}/client";
1473
- `;
1494
+ const storeImport = opts.includeStoreBootstrap ? StoreBootstrap.source(opts.appName) : "";
1474
1495
  const inheritedLabel = inheritedSourceAbsPath ? posixRelative(opts.appCwdPath, inheritedSourceAbsPath) : "";
1475
1496
  const inheritedImport = inheritedSourceSpecifier ? `import * as inheritedModule from ${JSON.stringify(inheritedSourceSpecifier)};
1476
1497
  const inheritedLayout = assertGuardOnChain(${JSON.stringify(inheritedLabel)}, resolveRouteModule(inheritedModule as never, ${JSON.stringify(inheritedLabel)})).module as LayoutModule;
@@ -1518,7 +1539,7 @@ import { System } from "akanjs/ui/System/index.tsx";
1518
1539
  import type { McpAppRootProps } from "akanjs/webkit";
1519
1540
  import { env } from "@apps/${opts.appName}/env/env.client";
1520
1541
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
1521
- ${clientImport}${inheritedImport}${userImport}
1542
+ ${storeImport}${inheritedImport}${userImport}
1522
1543
  const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
1523
1544
  const defaultFonts = userFonts.filter((font) => font.default);
1524
1545
  if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
@@ -1604,7 +1625,7 @@ async function resolveSsrPageEntries(opts) {
1604
1625
  appName: opts.appName,
1605
1626
  boundary,
1606
1627
  rootSourceAbsPath,
1607
- includeStInit: hasSt && boundary.segments.length === 0,
1628
+ includeStoreBootstrap: hasSt,
1608
1629
  includeSystemProvider: !hasAncestorRootBoundary(boundary, rootBoundaries)
1609
1630
  }),
1610
1631
  seedAbsPaths: [...new Set([boundary.sourceAbsPath, rootSourceAbsPath].filter((absPath) => absPath !== null))]
@@ -2380,6 +2401,7 @@ var appRootAllowedFiles = new Set([
2380
2401
  "CLAUDE.md",
2381
2402
  "akan.app.json",
2382
2403
  "akan.baseline.json",
2404
+ "akan.budget.json",
2383
2405
  "akan.config.ts",
2384
2406
  "client.ts",
2385
2407
  "main.ts",
@@ -3563,7 +3585,8 @@ class WorkspaceExecutor extends Executor {
3563
3585
  static localServeDomain = "localhost";
3564
3586
  static getBaseDevEnv(envPath) {
3565
3587
  const sourceEnv = {
3566
- ...envPath ? { ...process.env, ...parseEnvFile(envPath) } : process.env,
3588
+ ...envPath ? parseEnvFile(envPath) : {},
3589
+ ...Object.fromEntries(Object.entries(process.env).filter(([, value]) => value)),
3567
3590
  ...WorkspaceExecutor.publicEnvPin
3568
3591
  };
3569
3592
  const appName = sourceEnv.AKAN_PUBLIC_APP_NAME;
@@ -4482,4 +4505,4 @@ class ModuleExecutor extends Executor {
4482
4505
  }
4483
4506
  }
4484
4507
 
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 };
4508
+ export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, StoreBootstrap, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, TypecheckFailure, ProjectTypecheck2, CommandExecutionError, parseEnvFile, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-38by07nw.js";
4
+ } from "./index-sr5da35e.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-38by07nw.js";
13
+ } from "./index-sr5da35e.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-bns3wcpc.js";
@@ -23,7 +23,7 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-kdswbvys.js";
26
+ } from "./index-8pb9yvp8.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  WorkspaceExecutor
4
- } from "./index-38by07nw.js";
4
+ } from "./index-sr5da35e.js";
5
5
  import {
6
6
  jsonText,
7
7
  workflowPlanApproval,
@@ -19,6 +19,7 @@ import {
19
19
  getWorkflowSpec,
20
20
  compactWorkflowInputs,
21
21
  createWorkflowPlan,
22
+ workflowTargetDiagnostics,
22
23
  inspectWorkflowPlan,
23
24
  renderWorkflowList,
24
25
  renderWorkflowExplain,
@@ -26,30 +27,30 @@ import {
26
27
  renderWorkflowApply,
27
28
  renderWorkflowValidation,
28
29
  renderWorkflowRunArtifact
29
- } from "./index-kdswbvys.js";
30
+ } from "./index-8pb9yvp8.js";
30
31
  import {
31
32
  AkanContextAnalyzer
32
- } from "./index-ck64kxrn.js";
33
+ } from "./index-thckcabc.js";
33
34
  import {
34
35
  CommandContainer,
35
36
  runner
36
- } from "./index-r0q2ka2b.js";
37
+ } from "./index-93ewzmp6.js";
37
38
  import {
38
39
  ModuleScript
39
- } from "./index-hmj94es2.js";
40
+ } from "./index-8ts9774g.js";
40
41
  import {
41
42
  PrimitiveScript
42
- } from "./index-6zgt7zmx.js";
43
+ } from "./index-48d5qsj3.js";
43
44
  import {
44
45
  spawnAkan,
45
46
  isWorkspaceTarget
46
- } from "./index-0tkj05cz.js";
47
+ } from "./index-0fb3cpbt.js";
47
48
  import {
48
49
  ScalarScript
49
- } from "./index-gfh90r3t.js";
50
+ } from "./index-e3vmjtph.js";
50
51
  import {
51
52
  workflowSpecs
52
- } from "./index-k64mhwbw.js";
53
+ } from "./index-eajbmk10.js";
53
54
 
54
55
  // pkgs/@akanjs/cli/workflow/workflow.runner.ts
55
56
  import { mkdir, readFile, writeFile } from "fs/promises";
@@ -85,19 +86,17 @@ var failedPlan = (workflow, diagnostics) => ({
85
86
  requiresApproval: true,
86
87
  approval: workflowPlanApproval
87
88
  });
88
- var failedApplyReport = (workflow, code, message, plan) => {
89
- const diagnostics = [{ severity: "error", code, message }];
90
- return createWorkflowApplyReport({
91
- workflow,
92
- mode: "apply",
93
- changedFiles: [],
94
- generatedFiles: [],
95
- commands: [],
96
- diagnostics,
97
- nextActions: [],
98
- plan: plan ?? failedPlan(workflow, diagnostics)
99
- });
100
- };
89
+ var refusedApplyReport = (workflow, diagnostics, { plan, mode = "apply" } = {}) => createWorkflowApplyReport({
90
+ workflow,
91
+ mode,
92
+ changedFiles: [],
93
+ generatedFiles: [],
94
+ commands: [],
95
+ diagnostics,
96
+ nextActions: [],
97
+ plan: plan ?? failedPlan(workflow, diagnostics)
98
+ });
99
+ var failedApplyReport = (workflow, code, message, plan) => refusedApplyReport(workflow, [{ severity: "error", code, message }], { plan });
101
100
  var inferValidationKind = (command) => {
102
101
  if (command.kind)
103
102
  return command.kind;
@@ -280,7 +279,7 @@ class WorkflowRunner extends runner("workflow") {
280
279
  const spec = getWorkflowSpec(workflowSpecs, workflow);
281
280
  if (!spec)
282
281
  throw new Error(`Unknown workflow: ${workflow}. Run \`akan workflow list\` to see available workflows.`);
283
- const plan = await inspectWorkflowPlan(workspace ?? WorkspaceExecutor.fromRoot(), createWorkflowPlan(spec, compactWorkflowInputs(inputs)));
282
+ const plan = await inspectWorkflowPlan(workspace ?? WorkspaceExecutor.fromRoot(), spec, createWorkflowPlan(spec, compactWorkflowInputs(inputs)));
284
283
  if (out) {
285
284
  const outPath = resolvePath(out);
286
285
  await mkdir(path.dirname(outPath), { recursive: true });
@@ -320,6 +319,9 @@ class WorkflowRunner extends runner("workflow") {
320
319
  const message = inputErrors.map((diagnostic) => diagnostic.message).join(" ");
321
320
  return await renderApplyReport(failedApplyReport(plan.workflow, "workflow-plan-inputs-invalid", message, plan));
322
321
  }
322
+ const targetErrors = await workflowTargetDiagnostics(workspace ?? WorkspaceExecutor.fromRoot(), spec, plan.inputs);
323
+ if (targetErrors.length)
324
+ return await renderApplyReport(refusedApplyReport(plan.workflow, targetErrors, { plan, mode: dryRun ? "dry-run" : "apply" }));
323
325
  plan = { ...plan, steps: spec.steps, validation: spec.validation };
324
326
  if (dryRun)
325
327
  return await renderApplyReport(createDryRunWorkflowApplyReport(plan));