@akanjs/cli 3.0.0-alpha.7 → 3.0.0-alpha.71

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 (129) 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-20e0cwbs.js} +2 -2
  5. package/{agent.command-pggr92jj.js → agent.command-xdvw642m.js} +9 -7
  6. package/{application.command-692yap1d.js → application.command-g3f7xj25.js} +31 -6
  7. package/{applicationBuildRunner-ha3y8ew8.js → applicationBuildRunner-af0wtspv.js} +19 -14
  8. package/{applicationReleasePackager-gg8ccbeh.js → applicationReleasePackager-93nzdfsy.js} +1 -1
  9. package/buildBatch.proc.js +7 -5
  10. package/{capacitorApp-p0z5yab2.js → capacitorApp-b0ppke3m.js} +29 -27
  11. package/{cloud.command-wqfsyzv2.js → cloud.command-0hmsv44q.js} +12 -10
  12. package/commandManifest.json +1 -1
  13. package/{context.command-9bxtdn0w.js → context.command-x92afrnf.js} +17 -15
  14. package/{dependencyScanner-f6grrep3.js → dependencyScanner-rbs2407b.js} +1 -1
  15. package/getDirname-ka11hm7e.js +8 -0
  16. package/{guideline.command-nfqahxex.js → guideline.command-hpq08q66.js} +8 -6
  17. package/guidelines/agentRule/agentRule.generate.json +31 -0
  18. package/guidelines/agentRule/agentRule.instruction.md +525 -0
  19. package/guidelines/conventions/conventions.generate.json +25 -0
  20. package/guidelines/conventions/conventions.instruction.md +839 -0
  21. package/guidelines/cssRule/cssRule.instruction.md +7 -0
  22. package/guidelines/framework/framework.generate.json +3 -2
  23. package/guidelines/framework/framework.instruction.md +1 -9
  24. package/guidelines/mcpRule/mcpRule.generate.json +25 -0
  25. package/guidelines/mcpRule/mcpRule.instruction.md +217 -0
  26. package/guidelines/queryRule/queryRule.generate.json +31 -0
  27. package/guidelines/queryRule/queryRule.instruction.md +143 -0
  28. package/guidelines/runtimeRule/runtimeRule.generate.json +25 -0
  29. package/guidelines/runtimeRule/runtimeRule.instruction.md +176 -0
  30. package/guidelines/transportRule/transportRule.generate.json +31 -0
  31. package/guidelines/transportRule/transportRule.instruction.md +60 -0
  32. package/guidelines/workspaceOnboarding/workspaceOnboarding.generate.json +24 -0
  33. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +263 -0
  34. package/guidelines/workspaceRecipes/workspaceRecipes.generate.json +33 -0
  35. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +402 -0
  36. package/incrementalBuilder.proc.js +8 -6
  37. package/index-1577bej2.js +7 -0
  38. package/{index-vg0sj9nc.js → index-5f4gnt4c.js} +258 -97
  39. package/{index-bjpxzr6s.js → index-5vy2jzar.js} +1 -1
  40. package/{index-mssqn2sq.js → index-6d5r8q6k.js} +54 -15
  41. package/{index-p3f4q532.js → index-737aj4fm.js} +14 -13
  42. package/{index-2c3e2xh8.js → index-8besc14m.js} +1 -1
  43. package/{index-qb61h0k7.js → index-abyjt72y.js} +333 -540
  44. package/{index-xhgtkekh.js → index-cbfp5wyp.js} +1 -1
  45. package/{index-5dw57f0d.js → index-cp00yns2.js} +80 -14
  46. package/{index-ztpw544k.js → index-ety6takb.js} +3 -3
  47. package/index-f39512t6.js +255 -0
  48. package/{index-6rhabeev.js → index-gvq17wqn.js} +5 -3
  49. package/{index-js368gk9.js → index-hs70d8ed.js} +6 -6
  50. package/{index-7myvn0f0.js → index-j37qq1f2.js} +1 -1
  51. package/{index-azv0xjb5.js → index-jybbmwed.js} +8 -4
  52. package/{index-4hek879p.js → index-m5gfc86a.js} +1 -1
  53. package/{index-w6wbb612.js → index-nq3avsf6.js} +13 -13
  54. package/{index-vtj3zps1.js → index-p27h7535.js} +8 -8
  55. package/{index-5pmx7bkg.js → index-pehn44hr.js} +3 -3
  56. package/{index-j9cxndc0.js → index-qnv0aqmm.js} +9 -6
  57. package/{index-gmy45vz2.js → index-r691v756.js} +4 -4
  58. package/{index-0cj2zxbm.js → index-sh01r3pm.js} +1 -1
  59. package/{index-a1e0j63x.js → index-sqsfv8wg.js} +15 -7
  60. package/{index-gex7c8kd.js → index-wbbswwqt.js} +51 -24
  61. package/{index-bz2sfzzt.js → index-wybbcgxn.js} +4 -4
  62. package/index.js +21 -19
  63. package/{library.command-md9715jz.js → library.command-8vgrdtwy.js} +6 -4
  64. package/{localRegistry.command-exkbamyj.js → localRegistry.command-0gtqj0r0.js} +11 -9
  65. package/{module.command-w5aaddxk.js → module.command-rama4zya.js} +10 -8
  66. package/{package.command-yfkrcy0z.js → package.command-6jxapdsg.js} +6 -4
  67. package/package.json +4 -5
  68. package/{page.command-echbavp4.js → page.command-hxy7x525.js} +6 -4
  69. package/{primitive.command-9fbhspw2.js → primitive.command-4bf6xcc3.js} +11 -9
  70. package/{quality.command-3pnt9yep.js → quality.command-h5edwegz.js} +192 -97
  71. package/{recipeScanner-tghkzrrt.js → recipeScanner-zrzev25x.js} +3 -3
  72. package/{repair.command-carj4vax.js → repair.command-rgqf6px6.js} +8 -6
  73. package/{routeSourceValidator-e4jmbfcx.js → routeSourceValidator-7fycdqyv.js} +1 -1
  74. package/{scalar.command-51ryzypc.js → scalar.command-6krkz6tw.js} +9 -7
  75. package/templates/app/env/env.client.debug.ts.template +1 -5
  76. package/templates/app/env/env.client.develop.ts.template +1 -5
  77. package/templates/app/env/env.client.local.ts.template +1 -5
  78. package/templates/app/env/env.client.main.ts.template +1 -5
  79. package/templates/app/env/env.client.testing.ts.template +1 -5
  80. package/templates/app/env/env.client.type.ts +2 -6
  81. package/templates/app/env/env.server.debug.ts.template +1 -5
  82. package/templates/app/env/env.server.develop.ts.template +1 -5
  83. package/templates/app/env/env.server.local.ts.template +1 -5
  84. package/templates/app/env/env.server.main.ts.template +1 -5
  85. package/templates/app/main.ts +3 -1
  86. package/templates/app/page/styles.css.template +3 -3
  87. package/templates/appSample/srvkit/AuthGuard.ts +9 -5
  88. package/templates/appSample/srvkit/SessionInternalArg.ts +4 -3
  89. package/templates/crudPages/[__model__Id]/edit/page.tsx +1 -1
  90. package/templates/crudPages/new/page.tsx +1 -1
  91. package/templates/crudSinglePage/page.tsx +1 -1
  92. package/templates/env/_env.server.type.ts +7 -5
  93. package/templates/lib/db.ts +1 -1
  94. package/templates/lib/dict.ts +1 -1
  95. package/templates/lib/sig.ts +1 -1
  96. package/templates/lib/srv.ts +6 -2
  97. package/templates/module/__Model__.Util.tsx +1 -1
  98. package/templates/module/__Model__.Zone.tsx +3 -5
  99. package/templates/workspaceRoot/AGENTS.md.template +4 -972
  100. package/templates/workspaceRoot/CLAUDE.md.template +19 -0
  101. package/templates/workspaceRoot/biome.json.template +4 -244
  102. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +10 -14
  103. package/templates/workspaceRoot/docs/GENERATED.md.template +12 -10
  104. package/templates/workspaceRoot/package.json.template +1 -1
  105. package/{typeChecker-kravn7ns.js → typeChecker-g6bh0xfv.js} +1 -1
  106. package/typecheck.proc.js +1 -1
  107. package/{workflow.command-91wmvm8k.js → workflow.command-dwhwrqhd.js} +16 -14
  108. package/{workspace.command-wa10mfd9.js → workspace.command-f5h11gjn.js} +71 -52
  109. package/templates/workspaceRoot/.cursor/rules/akan-page-routing.mdc.template +0 -43
  110. package/templates/workspaceRoot/.cursor/rules/akan-sync-conventions.mdc.template +0 -34
  111. package/templates/workspaceRoot/.cursor/rules/application-test-commands.mdc.template +0 -16
  112. package/templates/workspaceRoot/.cursor/rules/change-scope.mdc.template +0 -12
  113. package/templates/workspaceRoot/.cursor/rules/client-server-boundaries.mdc.template +0 -18
  114. package/templates/workspaceRoot/.cursor/rules/coding-comments.mdc.template +0 -25
  115. package/templates/workspaceRoot/.cursor/rules/coding-style.mdc.template +0 -44
  116. package/templates/workspaceRoot/.cursor/rules/domain-module-conventions.mdc.template +0 -17
  117. package/templates/workspaceRoot/.cursor/rules/format-lint.mdc.template +0 -12
  118. package/templates/workspaceRoot/.cursor/rules/lint-enforced-rules.mdc.template +0 -19
  119. package/templates/workspaceRoot/.cursor/rules/module-file-playbook.mdc.template +0 -62
  120. package/templates/workspaceRoot/.cursor/rules/naming-conventions.mdc.template +0 -15
  121. package/templates/workspaceRoot/.cursor/rules/react-component-style.mdc.template +0 -21
  122. package/templates/workspaceRoot/.cursor/rules/repo-overview.mdc.template +0 -17
  123. package/templates/workspaceRoot/.cursor/rules/scalar-modeling.mdc.template +0 -99
  124. package/templates/workspaceRoot/.cursor/rules/secrets-and-env.mdc.template +0 -13
  125. package/templates/workspaceRoot/.cursor/rules/service-signal-conventions.mdc.template +0 -83
  126. package/templates/workspaceRoot/.cursor/rules/srvkit-adapters-and-guards.mdc.template +0 -50
  127. package/templates/workspaceRoot/.cursor/rules/ssr-first.mdc.template +0 -59
  128. package/templates/workspaceRoot/.cursor/rules/typescript-imports.mdc.template +0 -16
  129. /package/{index-r24hmh0q.js → index-yb2wsc7f.js} +0 -0
@@ -5,7 +5,7 @@ import {
5
5
  } from "./index-76rn3g2c.js";
6
6
  import {
7
7
  CommandExecutionError
8
- } from "./index-vg0sj9nc.js";
8
+ } from "./index-5f4gnt4c.js";
9
9
 
10
10
  // pkgs/@akanjs/devkit/capacitorApp.ts
11
11
  import { cp, mkdir, readFile, rm, writeFile } from "fs/promises";
@@ -1,27 +1,27 @@
1
1
  // @bun
2
+ import {
3
+ LibraryScript
4
+ } from "./index-sqsfv8wg.js";
2
5
  import {
3
6
  resolveMobileTargets
4
7
  } from "./index-76rn3g2c.js";
5
- import {
6
- LibraryScript
7
- } from "./index-a1e0j63x.js";
8
8
  import {
9
9
  runner,
10
10
  script
11
- } from "./index-6rhabeev.js";
11
+ } from "./index-gvq17wqn.js";
12
12
  import {
13
13
  HmrWatcher,
14
14
  WatchRootResolver
15
- } from "./index-bjpxzr6s.js";
15
+ } from "./index-5vy2jzar.js";
16
16
  import {
17
17
  AppExecutor,
18
18
  LibExecutor,
19
19
  PkgExecutor,
20
20
  WorkspaceExecutor
21
- } from "./index-vg0sj9nc.js";
21
+ } from "./index-5f4gnt4c.js";
22
22
  import {
23
23
  __require
24
- } from "./index-r24hmh0q.js";
24
+ } from "./index-yb2wsc7f.js";
25
25
 
26
26
  // pkgs/@akanjs/devkit/applicationBuildReporter.ts
27
27
  import { Logger } from "akanjs/common";
@@ -72,6 +72,9 @@ Caused by: ${ApplicationBuildReporter.formatError(error.cause)}` : "";
72
72
  import { confirm } from "@inquirer/prompts";
73
73
  import { Logger as Logger5 } from "akanjs/common";
74
74
 
75
+ // pkgs/@akanjs/cli/application/application.runner.ts
76
+ import path4 from "path";
77
+
75
78
  // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
76
79
  import { stat } from "fs/promises";
77
80
  import path2 from "path";
@@ -350,7 +353,7 @@ class IncrementalBuilderHost {
350
353
  return false;
351
354
  this.#recycleRequested = true;
352
355
  this.#status = "recycling";
353
- this.logger.info(`recycling builder pid=${proc.pid} (${reason})`);
356
+ this.logger.debug(`recycling builder pid=${proc.pid} (${reason})`);
354
357
  this.#recycleTimer = setTimeout(() => {
355
358
  this.#recycleTimer = null;
356
359
  if (this.#proc !== proc)
@@ -1898,10 +1901,10 @@ function openBrowser(url) {
1898
1901
  }
1899
1902
 
1900
1903
  // 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;
1904
+ var loadBuildRunner = async () => (await import("./applicationBuildRunner-af0wtspv.js")).ApplicationBuildRunner;
1905
+ var loadReleasePackager = async () => (await import("./applicationReleasePackager-93nzdfsy.js")).ApplicationReleasePackager;
1906
+ var loadCapacitorApp = async () => (await import("./capacitorApp-b0ppke3m.js")).CapacitorApp;
1907
+ var loadAbstractCompactor = async () => (await import("./abstractCompactor-20e0cwbs.js")).AbstractCompactor;
1905
1908
  var loadPrompts = async () => await import("@inquirer/prompts");
1906
1909
 
1907
1910
  class ApplicationRunner extends runner("application") {
@@ -1945,10 +1948,69 @@ class ApplicationRunner extends runner("application") {
1945
1948
  stdio: "inherit"
1946
1949
  });
1947
1950
  }
1951
+ #runtimeDirOf(app, override) {
1952
+ return path4.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path4.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
1953
+ }
1954
+ async runLogs(app, options) {
1955
+ const { LogControlUnavailableError, LogTailClient } = await import("akanjs/server/logging/logTailClient");
1956
+ const { LogQueryMatcher } = await import("akanjs/server/logging/logQuery");
1957
+ const runtimeDir = this.#runtimeDirOf(app, options.runtimeDir);
1958
+ const socketPath = LogTailClient.socketPath(runtimeDir);
1959
+ const { level, grep, endpoint, trace, child, role, origin, since } = options;
1960
+ const query = Object.fromEntries(Object.entries({ level, grep, endpoint, trace, child, role, origin, since }).filter(([, value]) => value !== undefined && value !== null && value !== ""));
1961
+ const print = (record) => process.stdout.write(options.json ? `${JSON.stringify(record)}
1962
+ ` : Logger4.render(record));
1963
+ const note = (text) => process.stderr.write(`[akan logs] ${text}
1964
+ `);
1965
+ let finish = null;
1966
+ const closed = new Promise((resolve) => {
1967
+ finish = resolve;
1968
+ });
1969
+ let client;
1970
+ try {
1971
+ client = await LogTailClient.connect(socketPath, {
1972
+ onRecord: (entry) => print(entry.record),
1973
+ onEvent: (response) => {
1974
+ if (response.type === "dropped")
1975
+ note(`${response.count} records dropped (reader too slow)`);
1976
+ },
1977
+ onClose: () => finish?.()
1978
+ });
1979
+ } catch (error) {
1980
+ if (error instanceof LogControlUnavailableError)
1981
+ throw new Error(`${app.name} is not running (no ${path4.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
1982
+ throw error;
1983
+ }
1984
+ const sinceMs = since ? LogQueryMatcher.parseSince(since) : undefined;
1985
+ const noteCoverage = (coverage) => {
1986
+ if (sinceMs !== undefined && coverage.from !== null && sinceMs < coverage.from)
1987
+ note(`${LogTailClient.describeCoverage(coverage)}; older records are not retained`);
1988
+ };
1989
+ if (endpoint)
1990
+ note("requests served by the primitive query fast path carry no endpoint and are not shown");
1991
+ if (options.follow === false) {
1992
+ const { entries, coverage } = await client.history({
1993
+ ...query,
1994
+ ...options.replay ? { limit: options.replay } : {}
1995
+ });
1996
+ for (const entry of entries)
1997
+ print(entry.record);
1998
+ noteCoverage(coverage);
1999
+ client.close();
2000
+ return;
2001
+ }
2002
+ const subscribed = await client.subscribe(query, { replay: options.replay });
2003
+ noteCoverage(subscribed.coverage);
2004
+ const stop = () => client.close();
2005
+ process.once("SIGINT", stop);
2006
+ process.once("SIGTERM", stop);
2007
+ await closed;
2008
+ }
1948
2009
  async runConsole(app) {
1949
2010
  const serverPath = `${app.cwdPath}/server.ts`;
1950
2011
  if (!await app.exists("server.ts"))
1951
2012
  throw new Error(`Server file not found: apps/${app.name}/server.ts`);
2013
+ const runtimeDir = this.#runtimeDirOf(app);
1952
2014
  const code = `
1953
2015
  const serverModule = await import(${JSON.stringify(serverPath)});
1954
2016
  const { assertAkanConsoleAllowed, startAkanConsole } = await import("akanjs/server");
@@ -1958,6 +2020,7 @@ assertAkanConsoleAllowed(server.env);
1958
2020
  await server.start({ listen: false, web: false });
1959
2021
  try {
1960
2022
  await startAkanConsole(server, {
2023
+ runtimeDir: ${JSON.stringify(runtimeDir)},
1961
2024
  globals: {
1962
2025
  srv: serverModule.srv,
1963
2026
  sig: serverModule.sig,
@@ -2355,6 +2418,9 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2355
2418
  await app.scanSync();
2356
2419
  await this.applicationRunner.runConsole(app);
2357
2420
  }
2421
+ async logs(app, options) {
2422
+ await this.applicationRunner.runLogs(app, options);
2423
+ }
2358
2424
  async build(app, { write = true, fast = false, quiet = false } = {}) {
2359
2425
  await app.scanSync({ write });
2360
2426
  if (!quiet)
@@ -2528,7 +2594,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2528
2594
  let stopping = false;
2529
2595
  process.on("SIGINT", () => {
2530
2596
  if (stopping) {
2531
- Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "warn");
2597
+ Logger5.rawLog("Abandoning the local database teardown; containers are left running.", undefined, "error");
2532
2598
  process.exit(130);
2533
2599
  }
2534
2600
  stopping = true;
@@ -2542,7 +2608,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
2542
2608
  }), timeout]);
2543
2609
  if (result !== "timeout")
2544
2610
  return;
2545
- Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "warn");
2611
+ Logger5.rawLog(`Local database did not stop within ${ApplicationScript.dbShutdownTimeoutMs}ms; run \`akan dbdown\` once Docker responds.`, undefined, "error");
2546
2612
  }
2547
2613
  async testSys(sys) {
2548
2614
  if (sys.type === "app")
@@ -1,17 +1,17 @@
1
1
  // @bun
2
2
  import {
3
3
  AkanContextAnalyzer
4
- } from "./index-mssqn2sq.js";
4
+ } from "./index-6d5r8q6k.js";
5
5
  import {
6
6
  createRepairReport,
7
7
  generatedFilePathsForTarget,
8
8
  renderRepairReport,
9
9
  writeGeneratedSyncState,
10
10
  writeWorkflowRunArtifact
11
- } from "./index-2c3e2xh8.js";
11
+ } from "./index-8besc14m.js";
12
12
  import {
13
13
  runner
14
- } from "./index-6rhabeev.js";
14
+ } from "./index-gvq17wqn.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/repair/repair.runner.ts
17
17
  var commandForShell = (command) => command.startsWith("akan ") ? `bun run ${command}` : command;
@@ -0,0 +1,255 @@
1
+ // @bun
2
+ // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
3
+ import { mkdir } from "fs/promises";
4
+ import path from "path";
5
+ var LAYOUT_KEY_RE = /^\.\/(.+\/)?_layout\.(tsx|ts|jsx|js)$/;
6
+ async function appHasStModule(appCwdPath) {
7
+ return Bun.file(path.join(appCwdPath, "lib", "st.ts")).exists();
8
+ }
9
+ var IMPLICIT_LAYOUT_DIR = path.join(".akan", "generated", "root-layouts");
10
+ var IMPLICIT_DICT_DIR = path.join(".akan", "generated", "dict");
11
+ var IMPLICIT_OVERRIDES_DIR = path.join(".akan", "generated", "overrides");
12
+ var OVERRIDES_KEY_RE = /^\.\/(.+\/)?_overrides\.(tsx|ts|jsx|js)$/;
13
+ async function writeGeneratedOverridesLayoutFile(opts) {
14
+ const filename = `${opts.key.replace(/^\.\//, "").replace(/[^a-zA-Z0-9]+/g, "_")}.tsx`;
15
+ const absPath = path.join(path.resolve(opts.appCwdPath), IMPLICIT_OVERRIDES_DIR, filename);
16
+ const userRel = path.relative(path.dirname(absPath), opts.userAbsPath).split(path.sep).join("/");
17
+ const userSpecifier = userRel.startsWith(".") ? userRel : `./${userRel}`;
18
+ const source = `"use client";
19
+ import { UiOverrideProvider } from "akanjs/ui";
20
+ import { createElement, type ReactNode } from "react";
21
+ import value from ${JSON.stringify(userSpecifier)};
22
+
23
+ export default function AkanUiOverridesLayout({ children }: { children?: ReactNode }) {
24
+ return createElement(UiOverrideProvider, { value }, children);
25
+ }
26
+ `;
27
+ await Bun.write(absPath, source);
28
+ return absPath;
29
+ }
30
+ function getRootBoundarySegments(key) {
31
+ const match = LAYOUT_KEY_RE.exec(key);
32
+ if (!match)
33
+ return null;
34
+ const prefix = match[1]?.replace(/\/$/, "");
35
+ if (!prefix)
36
+ return [];
37
+ return prefix.split("/").filter(Boolean);
38
+ }
39
+ function implicitRootLayoutKey(segments) {
40
+ return `./${[...segments, "__root_layout"].join("/")}.tsx`;
41
+ }
42
+ function implicitRootLayoutAbsPath(appCwdPath, segments) {
43
+ const filename = segments.length ? `${segments.join("__")}__root_layout.tsx` : "__root_layout.tsx";
44
+ return path.join(path.resolve(appCwdPath), IMPLICIT_LAYOUT_DIR, filename);
45
+ }
46
+ function implicitDictionaryMacroAbsPath(appCwdPath) {
47
+ return path.join(path.resolve(appCwdPath), IMPLICIT_DICT_DIR, "useDict.ts");
48
+ }
49
+ function isRootBoundarySegments(segments, basePaths) {
50
+ const firstVisibleIndex = segments.findIndex((segment) => !/^\(.+\)$/.test(segment));
51
+ if (firstVisibleIndex === -1)
52
+ return segments.length <= 1;
53
+ if (segments.slice(firstVisibleIndex + 1).some((segment) => /^\(.+\)$/.test(segment)))
54
+ return false;
55
+ const visible = segments.slice(firstVisibleIndex);
56
+ const allowedBasePaths = new Set([...basePaths].map((basePath) => basePath.trim()).filter(Boolean));
57
+ return visible.length === 1 && (firstVisibleIndex > 0 || allowedBasePaths.has(visible[0] ?? ""));
58
+ }
59
+ function findRootBoundaries(pageKeys, appCwdPath, basePaths) {
60
+ const boundaries = new Map;
61
+ for (const key of pageKeys) {
62
+ const segments = getRootBoundarySegments(key);
63
+ if (!segments)
64
+ continue;
65
+ if (!isRootBoundarySegments(segments, basePaths))
66
+ continue;
67
+ const id = segments.join("/");
68
+ boundaries.set(id, {
69
+ sourceKey: key,
70
+ sourceAbsPath: path.resolve(appCwdPath, "page", key.replace(/^\.\//, "")),
71
+ segments
72
+ });
73
+ }
74
+ const hasExplicitRootBoundary = [...boundaries.values()].some((boundary) => boundary.segments.length === 0);
75
+ if (!hasExplicitRootBoundary && boundaries.size === 0) {
76
+ boundaries.set("", { sourceKey: null, sourceAbsPath: null, segments: [] });
77
+ }
78
+ return [...boundaries.values()].sort((a, b) => a.segments.join("/").localeCompare(b.segments.join("/")));
79
+ }
80
+ function hasAncestorRootBoundary(boundary, boundaries) {
81
+ return boundaries.some((candidate) => candidate !== boundary && candidate.segments.length < boundary.segments.length && candidate.segments.every((segment, index) => boundary.segments[index] === segment));
82
+ }
83
+ function findExplicitRootLayoutAbsPath(pageKeys, appCwdPath) {
84
+ const rootLayoutKey = pageKeys.find((key) => {
85
+ const segments = getRootBoundarySegments(key);
86
+ return segments !== null && segments.length === 0;
87
+ });
88
+ return rootLayoutKey ? path.resolve(appCwdPath, "page", rootLayoutKey.replace(/^\.\//, "")) : null;
89
+ }
90
+ function routePrefixForSegments(segments) {
91
+ const visible = segments.filter((segment) => !/^\(.+\)$/.test(segment));
92
+ return visible[0] ?? null;
93
+ }
94
+ async function assertEnvClientConvention(appCwdPath, appName) {
95
+ const envPath = path.join(appCwdPath, "env", "env.client.ts");
96
+ if (!await Bun.file(envPath).exists()) {
97
+ throw new Error(`[route-convention] app "${appName}" must provide env/env.client.ts exporting "env" for generated System.Provider`);
98
+ }
99
+ }
100
+ async function writeGeneratedDictionaryMacroFile(appCwdPath, appName) {
101
+ const absPath = implicitDictionaryMacroAbsPath(appCwdPath);
102
+ await mkdir(path.dirname(absPath), { recursive: true });
103
+ await Bun.write(absPath, `import { getAllDictionary } from "@apps/${appName}/lib/dict" with { type: "macro" };
104
+
105
+ export const allDictionary = getAllDictionary();
106
+ `);
107
+ return absPath;
108
+ }
109
+ async function writeGeneratedRootLayoutFile(opts) {
110
+ await assertEnvClientConvention(opts.appCwdPath, opts.appName);
111
+ const dictMacroAbsPath = opts.includeSystemProvider ? await writeGeneratedDictionaryMacroFile(opts.appCwdPath, opts.appName) : null;
112
+ const absPath = implicitRootLayoutAbsPath(opts.appCwdPath, opts.boundary.segments);
113
+ await mkdir(path.dirname(absPath), { recursive: true });
114
+ const dictMacroRel = dictMacroAbsPath ? path.relative(path.dirname(absPath), dictMacroAbsPath).split(path.sep).join("/") : null;
115
+ const dictMacroSpecifier = dictMacroRel ? dictMacroRel.startsWith(".") ? dictMacroRel : `./${dictMacroRel}` : null;
116
+ const sourceRel = opts.boundary.sourceAbsPath ? path.relative(path.dirname(absPath), opts.boundary.sourceAbsPath).split(path.sep).join("/") : null;
117
+ const sourceSpecifier = sourceRel ? sourceRel.startsWith(".") ? sourceRel : `./${sourceRel}` : null;
118
+ const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
119
+ const inheritedSourceRel = inheritedSourceAbsPath ? path.relative(path.dirname(absPath), inheritedSourceAbsPath).split(path.sep).join("/") : null;
120
+ const inheritedSourceSpecifier = inheritedSourceRel ? inheritedSourceRel.startsWith(".") ? inheritedSourceRel : `./${inheritedSourceRel}` : null;
121
+ const clientImport = opts.includeStInit ? `import { st } from "@apps/${opts.appName}/client";
122
+ void st;
123
+ ` : `import "@apps/${opts.appName}/client";
124
+ `;
125
+ const inheritedImport = inheritedSourceSpecifier ? `import * as inheritedLayout from ${JSON.stringify(inheritedSourceSpecifier)};
126
+ ` : `const inheritedLayout = {};
127
+ `;
128
+ const prefix = routePrefixForSegments(opts.boundary.segments);
129
+ const userImport = sourceSpecifier ? `import UserLayout, * as userLayout from ${JSON.stringify(sourceSpecifier)};
130
+ ` : `const UserLayout = ({ children }) => children;
131
+ const userLayout = {};
132
+ `;
133
+ const source = opts.includeSystemProvider ? `import type { LayoutProps, PageProps } from "akanjs/client";
134
+ import { loadFonts } from "akanjs/client";
135
+ import { System } from "akanjs/ui";
136
+ import { env } from "@apps/${opts.appName}/env/env.client";
137
+ import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
138
+ ${clientImport}${inheritedImport}${userImport}
139
+ const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
140
+ const defaultFonts = userFonts.filter((font) => font.default);
141
+ if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
142
+ const defaultFont = defaultFonts[0];
143
+ const defaultFontClassName = defaultFont ? (defaultFont.className ?? \`font-\${defaultFont.name}\`) : undefined;
144
+
145
+ export async function generateHead(props: PageProps) {
146
+ if (userLayout.generateHead) return userLayout.generateHead(props);
147
+ if (userLayout.head !== undefined) return userLayout.head;
148
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
149
+ return inheritedLayout.head;
150
+ }
151
+
152
+ export async function generateMetadata(props: PageProps) {
153
+ if (userLayout.generateMetadata) return userLayout.generateMetadata(props);
154
+ if (userLayout.metadata !== undefined) return userLayout.metadata;
155
+ if (inheritedLayout.generateMetadata) return inheritedLayout.generateMetadata(props);
156
+ return inheritedLayout.metadata;
157
+ }
158
+
159
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
160
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
161
+ export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
162
+
163
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
164
+ return (
165
+ <System.Provider
166
+ of={GeneratedLayout as never}
167
+ appName=${JSON.stringify(opts.appName)}
168
+ ${prefix ? `prefix=${JSON.stringify(prefix)}
169
+ ` : ""}params={params}
170
+ manifest={userLayout.manifest ?? inheritedLayout.manifest}
171
+ env={env}
172
+ theme={userLayout.theme ?? inheritedLayout.theme}
173
+ fonts={loadFonts(userFonts)}
174
+ className={defaultFontClassName}
175
+ gaTrackingId={userLayout.gaTrackingId ?? inheritedLayout.gaTrackingId}
176
+ layoutStyle={userLayout.layoutStyle ?? inheritedLayout.layoutStyle}
177
+ reconnect={userLayout.reconnect ?? inheritedLayout.reconnect ?? false}
178
+ wsConnect={userLayout.wsConnect ?? inheritedLayout.wsConnect ?? true}
179
+ allDictionary={process.env.AKAN_PUBLIC_RENDER_ENV === "ssr" ? allDictionary : undefined}
180
+ >
181
+ <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>
182
+ </System.Provider>
183
+ );
184
+ }
185
+ ` : `import type { LayoutProps, PageProps } from "akanjs/client";
186
+ ${inheritedImport}${userImport}
187
+ export async function generateHead(props: PageProps) {
188
+ if (userLayout.generateHead) return userLayout.generateHead(props);
189
+ if (userLayout.head !== undefined) return userLayout.head;
190
+ if (inheritedLayout.generateHead) return inheritedLayout.generateHead(props);
191
+ return inheritedLayout.head;
192
+ }
193
+
194
+ export async function generateMetadata(props: PageProps) {
195
+ if (userLayout.generateMetadata) return userLayout.generateMetadata(props);
196
+ if (userLayout.metadata !== undefined) return userLayout.metadata;
197
+ if (inheritedLayout.generateMetadata) return inheritedLayout.generateMetadata(props);
198
+ return inheritedLayout.metadata;
199
+ }
200
+
201
+ export const NotFound = userLayout.NotFound ?? inheritedLayout.NotFound;
202
+ export const Error = userLayout.Error ?? inheritedLayout.Error;
203
+ export const pageConfig = userLayout.pageConfig ?? inheritedLayout.pageConfig;
204
+
205
+ export default function GeneratedLayout({ children, params, searchParams }: LayoutProps) {
206
+ return <UserLayout params={params} searchParams={searchParams}>{children}</UserLayout>;
207
+ }
208
+ `;
209
+ await Bun.write(absPath, source);
210
+ return absPath;
211
+ }
212
+ async function resolveSsrPageEntries(opts) {
213
+ const absPageDir = path.resolve(opts.appCwdPath, "page");
214
+ const hasSt = await appHasStModule(opts.appCwdPath);
215
+ const basePaths = opts.basePaths ?? [];
216
+ const rootSourceAbsPath = findExplicitRootLayoutAbsPath(opts.pageKeys, opts.appCwdPath);
217
+ const rootBoundaries = findRootBoundaries(opts.pageKeys, opts.appCwdPath, basePaths);
218
+ const rootLayoutKeys = new Set(opts.pageKeys.filter((key) => {
219
+ const segments = getRootBoundarySegments(key);
220
+ return segments !== null && isRootBoundarySegments(segments, basePaths);
221
+ }));
222
+ const base = await Promise.all(opts.pageKeys.filter((key) => !rootLayoutKeys.has(key)).map(async (key) => {
223
+ const userAbsPath = path.resolve(absPageDir, key);
224
+ if (OVERRIDES_KEY_RE.test(key)) {
225
+ const moduleAbsPath = await writeGeneratedOverridesLayoutFile({
226
+ appCwdPath: opts.appCwdPath,
227
+ key,
228
+ userAbsPath
229
+ });
230
+ return { key, moduleAbsPath, seedAbsPaths: [userAbsPath] };
231
+ }
232
+ return { key, moduleAbsPath: userAbsPath };
233
+ }));
234
+ const generated = await Promise.all(rootBoundaries.map(async (boundary) => ({
235
+ key: implicitRootLayoutKey(boundary.segments),
236
+ moduleAbsPath: await writeGeneratedRootLayoutFile({
237
+ appCwdPath: opts.appCwdPath,
238
+ appName: opts.appName,
239
+ boundary,
240
+ rootSourceAbsPath,
241
+ includeStInit: hasSt && boundary.segments.length === 0,
242
+ includeSystemProvider: !hasAncestorRootBoundary(boundary, rootBoundaries)
243
+ }),
244
+ seedAbsPaths: [...new Set([boundary.sourceAbsPath, rootSourceAbsPath].filter((absPath) => absPath !== null))]
245
+ })));
246
+ const entries = [...base, ...generated];
247
+ entries.sort((a, b) => a.key.localeCompare(b.key));
248
+ return entries;
249
+ }
250
+ async function resolveSsrPageEntriesForApp(app, pageKeys) {
251
+ const config = await app.getConfig();
252
+ return resolveSsrPageEntries({ appCwdPath: app.cwdPath, appName: app.name, pageKeys, basePaths: config.basePaths });
253
+ }
254
+
255
+ export { getRootBoundarySegments, isRootBoundarySegments, resolveSsrPageEntriesForApp };
@@ -5,15 +5,17 @@ import {
5
5
  LibExecutor,
6
6
  ModuleExecutor,
7
7
  PkgExecutor,
8
- WorkspaceExecutor,
8
+ WorkspaceExecutor
9
+ } from "./index-5f4gnt4c.js";
10
+ import {
9
11
  getDirname
10
- } from "./index-vg0sj9nc.js";
12
+ } from "./index-1577bej2.js";
11
13
  import {
12
14
  FileSys
13
15
  } from "./index-67546d0j.js";
14
16
  import {
15
17
  __require
16
- } from "./index-r24hmh0q.js";
18
+ } from "./index-yb2wsc7f.js";
17
19
 
18
20
  // pkgs/@akanjs/devkit/commandDecorators/targetMeta.ts
19
21
  var COMMAND_META = Symbol("akan.command.meta");
@@ -1,24 +1,24 @@
1
1
  // @bun
2
2
  import {
3
3
  CloudRunner
4
- } from "./index-p3f4q532.js";
4
+ } from "./index-737aj4fm.js";
5
5
  import {
6
6
  PackageScript
7
- } from "./index-azv0xjb5.js";
7
+ } from "./index-jybbmwed.js";
8
8
  import {
9
9
  AiSession,
10
10
  CloudApi,
11
11
  GlobalConfig
12
- } from "./index-0cj2zxbm.js";
12
+ } from "./index-sh01r3pm.js";
13
13
  import {
14
14
  ApplicationScript
15
- } from "./index-5dw57f0d.js";
15
+ } from "./index-cp00yns2.js";
16
16
  import {
17
17
  script
18
- } from "./index-6rhabeev.js";
18
+ } from "./index-gvq17wqn.js";
19
19
  import {
20
20
  PkgExecutor
21
- } from "./index-vg0sj9nc.js";
21
+ } from "./index-5f4gnt4c.js";
22
22
 
23
23
  // pkgs/@akanjs/cli/cloud/cloud.script.ts
24
24
  import { Logger } from "akanjs/common";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  getDirname
4
- } from "./index-vg0sj9nc.js";
4
+ } from "./index-1577bej2.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/prompter.ts
7
7
  import fsPromise from "fs/promises";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-6rhabeev.js";
5
+ } from "./index-gvq17wqn.js";
6
6
  import {
7
7
  PkgExecutor
8
- } from "./index-vg0sj9nc.js";
8
+ } from "./index-5f4gnt4c.js";
9
9
  import {
10
10
  TypeScriptDependencyScanner
11
11
  } from "./index-46tjzh6s.js";
@@ -163,13 +163,17 @@ class PackageRunner extends runner("package") {
163
163
  "tailwind-scrollbar"
164
164
  ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit");
165
165
  }
166
- const bundledRuntimeDeps = new Set(pkg.name === "@akanjs/cli" ? ["@akanjs/devkit"] : []);
166
+ const packageBundledRuntimeDependencies = {
167
+ "@akanjs/cli": ["@akanjs/devkit"],
168
+ akanjs: ["use-agentic"]
169
+ };
170
+ const bundledRuntimeDeps = new Set(packageBundledRuntimeDependencies[pkg.name] ?? []);
167
171
  const forcedRuntimeDeps = packageRuntimeDependencies[pkg.name] ?? [];
168
172
  const forcedRuntimeDevDeps = packageRuntimeDevDependencies[pkg.name] ?? [];
169
173
  const [rootPackageJson, pkgJson] = await Promise.all([pkg.workspace.getPackageJson(), pkg.getPackageJson()]);
170
174
  const optionalPeerDeps = new Set(Object.entries(pkgJson.peerDependenciesMeta ?? {}).filter(([, meta]) => meta.optional).map(([dep]) => dep));
171
175
  const packageRuntimeDeps = [...new Set([...npmDeps, ...forcedRuntimeDeps])].filter((dep) => !optionalPeerDeps.has(dep) && !bundledRuntimeDeps.has(dep));
172
- const packageRuntimeDevDeps = [...new Set([...npmDevDeps, ...forcedRuntimeDevDeps])].filter((dep) => !optionalPeerDeps.has(dep));
176
+ const packageRuntimeDevDeps = [...new Set([...npmDevDeps, ...forcedRuntimeDevDeps])].filter((dep) => !optionalPeerDeps.has(dep) && !bundledRuntimeDeps.has(dep));
173
177
  const rootDeps = { ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies };
174
178
  const missingForcedDeps = forcedRuntimeDeps.filter((dep) => !rootDeps[dep]);
175
179
  const missingForcedDevDeps = forcedRuntimeDevDeps.filter((dep) => !rootDeps[dep]);
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-6rhabeev.js";
5
+ } from "./index-gvq17wqn.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {
@@ -1,22 +1,22 @@
1
1
  // @bun
2
2
  import {
3
3
  RepairRunner
4
- } from "./index-ztpw544k.js";
4
+ } from "./index-ety6takb.js";
5
5
  import {
6
6
  WorkflowRunner
7
- } from "./index-5pmx7bkg.js";
7
+ } from "./index-pehn44hr.js";
8
+ import {
9
+ ScalarScript
10
+ } from "./index-r691v756.js";
8
11
  import {
9
12
  PrimitiveScript
10
- } from "./index-bz2sfzzt.js";
13
+ } from "./index-wybbcgxn.js";
11
14
  import {
12
15
  ModuleScript
13
- } from "./index-vtj3zps1.js";
14
- import {
15
- ScalarScript
16
- } from "./index-gmy45vz2.js";
16
+ } from "./index-p27h7535.js";
17
17
  import {
18
18
  isPlaceholderAppId
19
- } from "./index-xhgtkekh.js";
19
+ } from "./index-cbfp5wyp.js";
20
20
  import {
21
21
  AkanContextAnalyzer,
22
22
  akanMcpInstallConfigPaths,
@@ -27,17 +27,17 @@ import {
27
27
  renderDoctorText,
28
28
  resourceList,
29
29
  upsertCodexMcpServerBlock
30
- } from "./index-mssqn2sq.js";
30
+ } from "./index-6d5r8q6k.js";
31
31
  import {
32
32
  buildAkanModuleContextIndex,
33
33
  createWorkflowBaselineSummary,
34
34
  createWorkflowStepRegistry,
35
35
  jsonText,
36
36
  toolingRolloutGate
37
- } from "./index-2c3e2xh8.js";
37
+ } from "./index-8besc14m.js";
38
38
  import {
39
39
  Prompter
40
- } from "./index-7myvn0f0.js";
40
+ } from "./index-j37qq1f2.js";
41
41
  import {
42
42
  getMobileTargets
43
43
  } from "./index-76rn3g2c.js";
@@ -45,10 +45,10 @@ import {
45
45
  CommandContainer,
46
46
  runner,
47
47
  script
48
- } from "./index-6rhabeev.js";
48
+ } from "./index-gvq17wqn.js";
49
49
  import {
50
50
  AppExecutor
51
- } from "./index-vg0sj9nc.js";
51
+ } from "./index-5f4gnt4c.js";
52
52
 
53
53
  // pkgs/@akanjs/cli/context/context.script.ts
54
54
  import { Logger } from "akanjs/common";
@@ -1,13 +1,13 @@
1
1
  // @bun
2
- import {
3
- PageScript
4
- } from "./index-4hek879p.js";
5
2
  import {
6
3
  pluralizeName
7
4
  } from "./index-ss469dec.js";
5
+ import {
6
+ PageScript
7
+ } from "./index-m5gfc86a.js";
8
8
  import {
9
9
  AiSession
10
- } from "./index-0cj2zxbm.js";
10
+ } from "./index-sh01r3pm.js";
11
11
  import {
12
12
  bilingualDescriptionForField,
13
13
  bilingualLabelForField,
@@ -15,17 +15,17 @@ import {
15
15
  generatedFilesForSync,
16
16
  moduleSourcePaths,
17
17
  sourceFile
18
- } from "./index-2c3e2xh8.js";
18
+ } from "./index-8besc14m.js";
19
19
  import {
20
20
  Prompter
21
- } from "./index-7myvn0f0.js";
21
+ } from "./index-j37qq1f2.js";
22
22
  import {
23
23
  runner,
24
24
  script
25
- } from "./index-6rhabeev.js";
25
+ } from "./index-gvq17wqn.js";
26
26
  import {
27
27
  ModuleExecutor
28
- } from "./index-vg0sj9nc.js";
28
+ } from "./index-5f4gnt4c.js";
29
29
  import {
30
30
  FileSys
31
31
  } from "./index-67546d0j.js";