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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-dyc45f5w.js +11 -0
  3. package/{CodeAgentRpcHost-9g27hmer.js → CodeAgentRpcHost-6dzfkvsc.js} +1 -1
  4. package/CodeAgentRpcListener-tcwrdvst.js +182 -0
  5. package/{CodeTui-z5vkm9ea.js → CodeTui-q55b2zrn.js} +25 -8
  6. package/TunnelShare-hdq9h1hr.js +14 -0
  7. package/agent.command-20zaqe60.js +49 -0
  8. package/akanCode.js +13 -8
  9. package/{application.command-wthg8nn9.js → application.command-nd0fshsk.js} +45 -12
  10. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-s13x3zqb.js} +14 -10
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-sz11hpre.js → cloud.command-8kbddsz9.js} +28 -19
  13. package/cloud.script-hgvvajm3.js +27 -0
  14. package/code.command-625bg8s8.js +345 -0
  15. package/commandManifest.json +1 -1
  16. package/{context.command-15j9b7c0.js → context.command-p6haqjay.js} +20 -18
  17. package/context.runner-rsnqnk9j.js +27 -0
  18. package/{dependencyScanner-3afj2vt1.js → dependencyScanner-78sq8m4q.js} +2 -2
  19. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  20. package/{fileSys-wzzrntkw.js → fileSys-zpvt5gtf.js} +1 -1
  21. package/{guideline.command-snh85ctf.js → guideline.command-195g0h9a.js} +4 -4
  22. package/guidelines/agentRule/agentRule.instruction.md +22 -8
  23. package/guidelines/conventions/core.md +106 -0
  24. package/guidelines/conventions/rules/app.md +83 -0
  25. package/guidelines/conventions/rules/auth.md +46 -0
  26. package/guidelines/conventions/rules/config.md +60 -0
  27. package/guidelines/conventions/rules/constant.md +24 -0
  28. package/guidelines/conventions/rules/gates.md +32 -0
  29. package/guidelines/conventions/rules/layer.md +25 -0
  30. package/guidelines/conventions/rules/migration.md +27 -0
  31. package/guidelines/conventions/rules/module.md +90 -0
  32. package/guidelines/conventions/rules/page.md +56 -0
  33. package/guidelines/conventions/rules/sensitive.md +16 -0
  34. package/guidelines/conventions/rules/server.md +91 -0
  35. package/guidelines/conventions/rules/ssr.md +47 -0
  36. package/guidelines/conventions/rules/style.md +43 -0
  37. package/guidelines/conventions/rules/test.md +34 -0
  38. package/guidelines/conventions/rules/ts.md +95 -0
  39. package/guidelines/conventions/rules/tsx.md +76 -0
  40. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  41. package/guidelines/pageRule/pageRule.instruction.md +8 -7
  42. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  43. package/guidelines/runtimeRule/runtimeRule.instruction.md +35 -25
  44. package/guidelines/ssrRule/ssrRule.instruction.md +11 -10
  45. package/guidelines/transportRule/transportRule.instruction.md +5 -4
  46. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +4 -4
  47. package/incrementalBuilder.proc.js +7 -7
  48. package/{index-301pdbzz.js → index-00a7j05x.js} +7 -7
  49. package/{index-js6geqjn.js → index-0j1t1h2b.js} +3 -1
  50. package/{index-6txx6a9p.js → index-1h2jc0x3.js} +154 -88
  51. package/{index-55j120r8.js → index-1qsd8ft1.js} +65 -145
  52. package/{index-9th4gszy.js → index-2mwjshz5.js} +233 -1271
  53. package/index-2nxk8wgs.js +266 -0
  54. package/{index-j9vyj3dj.js → index-2phm56a1.js} +49 -8
  55. package/index-35j83zkd.js +61 -0
  56. package/index-4am4dvmf.js +29 -0
  57. package/index-75y7bcz4.js +28 -0
  58. package/index-7apsdr5g.js +487 -0
  59. package/{index-42j4a8zq.js → index-84h43kg6.js} +8 -6
  60. package/index-9bv479q5.js +1 -0
  61. package/{index-3wypz6xj.js → index-9zy8479y.js} +11 -5
  62. package/{index-a5dhqkdr.js → index-a1vb3x7t.js} +273 -259
  63. package/{index-52w0fvh8.js → index-bns3wcpc.js} +15 -0
  64. package/index-cjmjvg4r.js +3622 -0
  65. package/{index-pcwzkdqb.js → index-defp4gmb.js} +1 -1
  66. package/index-ewbmfarf.js +1606 -0
  67. package/index-fbewhg4g.js +590 -0
  68. package/index-fhw7yq2d.js +653 -0
  69. package/{index-wcej7g4z.js → index-g500c5j9.js} +271 -105
  70. package/{index-74tjjsnc.js → index-g841cap9.js} +33 -37
  71. package/{index-2azahjaw.js → index-gr9thy79.js} +5 -5
  72. package/{index-4pf8g7ff.js → index-h7hehkw6.js} +3 -0
  73. package/{index-xjf5j657.js → index-hm0tn7qv.js} +1001 -91
  74. package/index-j6eeh5d7.js +138 -0
  75. package/{index-31es1yev.js → index-j7hwy56s.js} +108 -7
  76. package/{index-skk9zc1x.js → index-jc2zbwra.js} +2 -2
  77. package/{index-905qdgqp.js → index-khk05tsf.js} +1 -1
  78. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  79. package/{index-tvehn2sp.js → index-qd7xn2bk.js} +1 -1
  80. package/{index-a58emady.js → index-qw6814m4.js} +55 -17
  81. package/index-raz588b3.js +445 -0
  82. package/{index-at7bz0xq.js → index-s4nvxpzm.js} +2 -0
  83. package/{index-bt438yxm.js → index-sp0qsr7a.js} +116 -13
  84. package/{index-xb8809yb.js → index-sveq36gh.js} +40 -43
  85. package/{index-hmt54t45.js → index-t1t9wq9a.js} +4 -4
  86. package/index-t78230d7.js +191 -0
  87. package/index-tenw3mah.js +225 -0
  88. package/{index-qfp55x1y.js → index-tgqameyb.js} +4 -4
  89. package/{index-espk51ah.js → index-tp56652m.js} +6 -6
  90. package/index-w15mg3km.js +389 -0
  91. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  92. package/{index-2xcc2ax5.js → index-y4kcmbt2.js} +2 -2
  93. package/index-yf9wc28h.js +52 -0
  94. package/{index-0fz95kxe.js → index-zbrwnmf1.js} +9 -7
  95. package/{index-40brg4px.js → index-zttm13c3.js} +5 -5
  96. package/index.js +24 -23
  97. package/{library.command-gycrwhf1.js → library.command-63hgt9te.js} +4 -4
  98. package/{localRegistry.command-jtd8gaes.js → localRegistry.command-g3f8k25t.js} +46 -22
  99. package/{module.command-v6hgs1bc.js → module.command-r4sa2khp.js} +7 -6
  100. package/{package.command-shzpcfph.js → package.command-96eheyvd.js} +5 -5
  101. package/package.json +2 -2
  102. package/{page.command-ptxn5kqk.js → page.command-gs6d841d.js} +4 -4
  103. package/{pipeline.command-zz31pgax.js → pipeline.command-wdfvdbfj.js} +3 -3
  104. package/{primitive.command-a1vse91z.js → primitive.command-dfsv4mpe.js} +8 -7
  105. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-kqj1t6hb.js} +1 -1
  106. package/{prompter-76k56b37.js → prompter-qrwx1p17.js} +2 -2
  107. package/quality.command-webzxee2.js +78 -0
  108. package/{repair.command-cvazbz99.js → repair.command-3r3j1xre.js} +7 -6
  109. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  110. package/{scalar.command-0acvyp26.js → scalar.command-e8y47j6d.js} +6 -5
  111. package/skills/akan-agent/SKILL.md +43 -0
  112. package/skills/akan-code/SKILL.md +38 -11
  113. package/skills/akan-debug/SKILL.md +41 -6
  114. package/skills/akan-deps/SKILL.md +1 -2
  115. package/skills/akan-err/SKILL.md +2 -1
  116. package/skills/akan-mcp/SKILL.md +40 -0
  117. package/skills/akan-page/SKILL.md +44 -0
  118. package/skills/akan-query/SKILL.md +39 -0
  119. package/skills/akan-runtime/SKILL.md +43 -0
  120. package/skills/akan-scaffold/SKILL.md +16 -6
  121. package/skills/akan-transport/SKILL.md +40 -0
  122. package/skills/akan-validate/SKILL.md +13 -11
  123. package/{subspace.command-822qx2bx.js → subspace.command-a1sf9n5a.js} +12 -10
  124. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  125. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  126. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  127. package/templates/app/akan.config.ts +2 -3
  128. package/templates/app/env/env.client.ts +2 -4
  129. package/templates/app/env/env.client.type.ts +2 -3
  130. package/templates/app/env/env.server.ts +2 -3
  131. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  132. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  133. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  134. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  135. package/templates/app/lib/option.ts +2 -3
  136. package/templates/app/main.ts +2 -4
  137. package/templates/app/page/_index.tsx +3 -3
  138. package/templates/app/page/_layout.tsx +13 -10
  139. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  140. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  141. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  142. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  143. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  144. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  145. package/templates/appSample/lib/task/task.constant.ts +1 -5
  146. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  147. package/templates/appSample/lib/task/task.document.ts +1 -1
  148. package/templates/appSample/lib/task/task.signal.ts +14 -9
  149. package/templates/appSample/page/task/_index.tsx +2 -1
  150. package/templates/appSample/page/task/new.tsx +2 -1
  151. package/templates/appSample/srvkit/guards.ts +11 -0
  152. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  153. package/templates/biomeForm.ts +144 -0
  154. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  155. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  156. package/templates/crudPages/new/page.tsx +4 -3
  157. package/templates/crudPages/page.tsx +3 -3
  158. package/templates/crudSinglePage/page.tsx +9 -5
  159. package/templates/libRoot/akan.config.ts +2 -3
  160. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  161. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  162. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  163. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  164. package/templates/libRoot/lib/option.ts +1 -2
  165. package/templates/module/__Model__.Template.tsx +11 -10
  166. package/templates/module/__Model__.Unit.tsx +18 -5
  167. package/templates/module/__Model__.Util.tsx +9 -7
  168. package/templates/module/__Model__.View.tsx +9 -6
  169. package/templates/module/__Model__.Zone.tsx +25 -17
  170. package/templates/module/__model__.constant.ts +8 -9
  171. package/templates/module/__model__.dictionary.ts +16 -17
  172. package/templates/module/__model__.document.ts +6 -8
  173. package/templates/module/__model__.service.ts +3 -3
  174. package/templates/module/__model__.signal.ts +11 -10
  175. package/templates/module/__model__.store.ts +3 -5
  176. package/templates/service/__model__.dictionary.ts +5 -6
  177. package/templates/service/__model__.service.ts +3 -3
  178. package/templates/service/__model__.signal.ts +5 -4
  179. package/templates/service/__model__.store.ts +3 -5
  180. package/templates/workspaceRoot/.gitignore.template +4 -0
  181. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  182. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  183. package/{tunnel.command-ycmja19q.js → tunnel.command-dcb0wg93.js} +25 -13
  184. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  185. package/typecheck.proc.js +6 -1
  186. package/verify.command-yyepccbh.js +93 -0
  187. package/{workflow.command-abb1d5xy.js → workflow.command-z5pg9ay0.js} +49 -14
  188. package/workspace.command-d7x5jttw.js +290 -0
  189. package/CodeAgent-8d5qs787.js +0 -9
  190. package/CodeAgentRpcListener-7p7z5dd7.js +0 -97
  191. package/TunnelShare-qkm8zp03.js +0 -14
  192. package/agent.command-ydftceda.js +0 -25
  193. package/cloud.script-nqevg5qw.js +0 -24
  194. package/code.command-9h3yrzhe.js +0 -167
  195. package/context.runner-8gg030b0.js +0 -25
  196. package/guidelines/conventions/conventions.instruction.md +0 -617
  197. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  198. package/index-2mwc0g0d.js +0 -49
  199. package/index-4vgbysa0.js +0 -279
  200. package/index-7md2g9vw.js +0 -6
  201. package/index-b70zct19.js +0 -856
  202. package/index-c6eggbee.js +0 -123
  203. package/index-zzvvc845.js +0 -74
  204. package/quality.command-ah8qcakd.js +0 -1478
  205. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  206. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  207. package/workspace.command-qm7cw29v.js +0 -521
@@ -0,0 +1,138 @@
1
+ // @bun
2
+ import {
3
+ getDirname2
4
+ } from "./index-bns3wcpc.js";
5
+
6
+ // pkgs/@akanjs/devkit/conventionSet.ts
7
+ import fsPromise from "fs/promises";
8
+ import path from "path";
9
+
10
+ class ConventionSet {
11
+ core;
12
+ rules;
13
+ constructor(core, rules) {
14
+ this.core = core;
15
+ this.rules = rules;
16
+ }
17
+ static async load(dir) {
18
+ const core = await fsPromise.readFile(path.join(dir, "core.md"), "utf-8");
19
+ const files = (await fsPromise.readdir(path.join(dir, "rules"))).filter((file) => file.endsWith(".md")).sort();
20
+ const rules = await Promise.all(files.map(async (file) => ConventionSet.parseRule(file.slice(0, -3), await fsPromise.readFile(path.join(dir, "rules", file), "utf-8"))));
21
+ return new ConventionSet(core.trim(), rules);
22
+ }
23
+ static parseRule(name, text) {
24
+ const match = /^---\n([\s\S]*?)\n---\n/.exec(text);
25
+ if (!match)
26
+ throw new Error(`Convention rule ${name} has no frontmatter`);
27
+ const front = match[1] ?? "";
28
+ const described = /^description:\s*(.+)$/m.exec(front);
29
+ const description = described?.[1]?.trim() ?? "";
30
+ const paths = [...front.matchAll(/^\s+-\s+"([^"]+)"$/gm)].map((entry) => entry[1] ?? "");
31
+ if (!description || paths.length === 0)
32
+ throw new Error(`Convention rule ${name} needs a description and paths`);
33
+ return { name, description, paths, body: text.slice(match[0].length).trim() };
34
+ }
35
+ static expand(glob) {
36
+ const open = glob.indexOf("{");
37
+ if (open === -1)
38
+ return [glob];
39
+ const close = glob.indexOf("}", open);
40
+ if (close === -1)
41
+ return [glob];
42
+ const head = glob.slice(0, open);
43
+ const tail = glob.slice(close + 1);
44
+ return glob.slice(open + 1, close).split(",").flatMap((choice) => ConventionSet.expand(`${head}${choice}${tail}`));
45
+ }
46
+ static demote(markdown) {
47
+ let fenced = false;
48
+ return markdown.split(`
49
+ `).map((line) => {
50
+ if (line.startsWith("```"))
51
+ fenced = !fenced;
52
+ return !fenced && /^#{1,5} /.test(line) ? `#${line}` : line;
53
+ }).join(`
54
+ `);
55
+ }
56
+ get instruction() {
57
+ return `${[this.core, ...this.rules.map((rule) => ConventionSet.demote(rule.body))].join(`
58
+
59
+ `)}
60
+ `;
61
+ }
62
+ }
63
+
64
+ // pkgs/@akanjs/devkit/prompter.ts
65
+ import fsPromise2 from "fs/promises";
66
+ import { input, select } from "@inquirer/prompts";
67
+ class Prompter2 {
68
+ static async#getGuidelineRoot() {
69
+ const dirname = getDirname2(import.meta.url);
70
+ const candidates = [`${dirname}/guidelines`, `${dirname}/../cli/guidelines`];
71
+ for (const candidate of candidates) {
72
+ try {
73
+ await fsPromise2.access(candidate);
74
+ return candidate;
75
+ } catch {}
76
+ }
77
+ return candidates[0];
78
+ }
79
+ static async selectGuideline() {
80
+ const guideNames = await Prompter2.listGuidelines();
81
+ return await select({
82
+ message: "Select a guideline",
83
+ choices: guideNames.map((name) => ({ name, value: name }))
84
+ });
85
+ }
86
+ static async listGuidelines() {
87
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
88
+ return (await fsPromise2.readdir(guidelineRoot)).filter((name) => !name.startsWith("_")).sort();
89
+ }
90
+ static async getInstruction(guideName) {
91
+ const guideNames = await Prompter2.listGuidelines();
92
+ if (!guideNames.includes(guideName))
93
+ throw new Error(`Unknown guideline "${guideName}". Available: ${guideNames.join(", ")}`);
94
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
95
+ const composed = `${guidelineRoot}/${guideName}/core.md`;
96
+ if (await Bun.file(composed).exists())
97
+ return (await ConventionSet.load(`${guidelineRoot}/${guideName}`)).instruction;
98
+ return await fsPromise2.readFile(`${guidelineRoot}/${guideName}/${guideName}.instruction.md`, "utf-8");
99
+ }
100
+ static async getConventionSet() {
101
+ return await ConventionSet.load(`${await Prompter2.#getGuidelineRoot()}/conventions`);
102
+ }
103
+ static async getUpdateRequest(guideName) {
104
+ return await input({
105
+ message: `What do you want to update in ${guideName}?`
106
+ });
107
+ }
108
+ async makeTsFileUpdatePrompt({ context, request }) {
109
+ return `You are a senior developer writing TypeScript-based programs using Akan.js, an in-house framework. Here's an overview of the Akan.js framework:
110
+ ${await this.getDocumentation("framework")}
111
+ Please understand the following background information, write code that meets the requirements, verify that it satisfies the validation conditions, and return the result.
112
+
113
+ # Code Style
114
+ - Use double quotes for all string literals in TypeScript/TSX code. Do not use single quotes.
115
+
116
+ # Background Information
117
+ \`\`\`markdown
118
+ ${context}
119
+ \`\`\`
120
+
121
+ # Requirements
122
+ \`\`\`markdown
123
+ ${request}
124
+ \`\`\`
125
+ `;
126
+ }
127
+ async getDocumentation(guideName) {
128
+ const guidelineRoot = await Prompter2.#getGuidelineRoot();
129
+ const filePath = `${guidelineRoot}/${guideName}/${guideName}.instruction.md`;
130
+ const document = await fsPromise2.readFile(filePath, "utf-8");
131
+ return `\`\`\`markdown
132
+ ${document}
133
+ \`\`\`
134
+ `;
135
+ }
136
+ }
137
+
138
+ export { ConventionSet, Prompter2 };
@@ -10,10 +10,10 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-wcej7g4z.js";
13
+ } from "./index-g500c5j9.js";
14
14
  import {
15
15
  FileSys2
16
- } from "./index-52w0fvh8.js";
16
+ } from "./index-bns3wcpc.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2,
@@ -23,12 +23,12 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-xjf5j657.js";
26
+ } from "./index-hm0tn7qv.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";
30
30
  import path from "path";
31
- import { capitalize, isRecord } from "akanjs/common";
31
+ import { capitalize, isRecord, parseRouteModuleKey } from "akanjs/common";
32
32
  var guidelineResourceUri = (name) => `akan://guidelines/${name}`;
33
33
  var staticResourceList = [
34
34
  { uri: "akan://docs/framework", name: "Akan framework guide", mimeType: "text/markdown" },
@@ -129,6 +129,7 @@ var generatedFiles = [
129
129
  "*/common/index.ts"
130
130
  ];
131
131
  var validationCommands = [
132
+ "akan verify [<app-or-lib-or-pkg>]",
132
133
  "akan sync <app-or-lib>",
133
134
  "akan lint <app-or-lib-or-pkg>",
134
135
  "akan typecheck <app-or-lib>",
@@ -142,7 +143,7 @@ var unknownGeneratedFilesFreshness = {
142
143
  status: "unknown",
143
144
  message: "Run sync before validation so generated Akan files match the current source conventions.",
144
145
  refreshCommand: "akan sync <app-or-lib>",
145
- verifyingCommands: ["akan lint <app-or-lib-or-pkg>", "akan build <app-name>"]
146
+ verifyingCommands: ["akan verify <app-or-lib>"]
146
147
  };
147
148
  var repairAction = (kind, command, reason, safeToRun) => ({
148
149
  kind,
@@ -231,7 +232,7 @@ var generatedFreshnessFromStates = async (workspace) => {
231
232
  status: targets.some((target) => target.status === "fresh") ? "fresh" : "stale",
232
233
  message: lastFresh ? `Generated files were refreshed for ${lastFresh.target} at ${lastFresh.lastSyncedAt}.` : "Generated sync state exists, but the last recorded repair did not pass.",
233
234
  refreshCommand: "akan sync <app-or-lib>",
234
- verifyingCommands: ["akan lint <app-or-lib-or-pkg>", "akan build <app-name>"],
235
+ verifyingCommands: ["akan verify <app-or-lib>"],
235
236
  targets
236
237
  };
237
238
  };
@@ -306,9 +307,33 @@ var getSysModules = async (workspace, sys, {
306
307
  }
307
308
  return modules.sort((a, b) => `${a.sysName}:${a.path}`.localeCompare(`${b.sysName}:${b.path}`));
308
309
  };
310
+ var getAppRoutes = async (app, workspaceRoot) => {
311
+ const sources = await app.getRouteSources();
312
+ const guardedLayouts = new Set;
313
+ const pages = [];
314
+ for (const source of sources) {
315
+ const parsed = parseRouteModuleKey(source.key);
316
+ if (parsed.kind === "layout" && source.info.chain?.guarded)
317
+ guardedLayouts.add(parsed.routeSegments.join("/"));
318
+ else if (parsed.kind === "page")
319
+ pages.push({ source, parsed });
320
+ }
321
+ return pages.map(({ source, parsed }) => {
322
+ const segments = parsed.routeSegments;
323
+ const reach = parsed.leaf === "_index" ? segments.length : segments.length - 1;
324
+ const underGuard = Array.from({ length: reach + 1 }, (_, idx) => segments.slice(0, idx).join("/")).some((prefix) => guardedLayouts.has(prefix));
325
+ return {
326
+ path: parsed.pattern.replace(/^\/:lang/, "") || "/",
327
+ file: path.relative(workspaceRoot, source.absPath).replaceAll(path.sep, "/"),
328
+ search: source.info.chain?.search ?? [],
329
+ guarded: !!source.info.chain?.guarded || underGuard,
330
+ devOnly: source.info.devOnly
331
+ };
332
+ }).sort((a, b) => a.path.localeCompare(b.path));
333
+ };
309
334
  var getSysContext = async (workspace, type, name, options) => {
310
335
  const sys = type === "app" ? AppExecutor.from(workspace, name) : LibExecutor.from(workspace, name);
311
- return {
336
+ const context = {
312
337
  type,
313
338
  name,
314
339
  path: `${type}s/${name}`,
@@ -318,6 +343,9 @@ var getSysContext = async (workspace, type, name, options) => {
318
343
  module: options.module
319
344
  })
320
345
  };
346
+ if (sys instanceof AppExecutor && options.app === name)
347
+ await getAppRoutes(sys, workspace.workspaceRoot).then((routes) => context.routes = routes, (error) => context.routeError = error instanceof Error ? error.message : String(error));
348
+ return context;
321
349
  };
322
350
 
323
351
  class AkanContextAnalyzer {
@@ -372,6 +400,41 @@ class AkanContextAnalyzer {
372
400
  hint
373
401
  };
374
402
  }
403
+ static async#agentGuideOversize(workspace, sysPaths) {
404
+ const sizeOf = async (file) => {
405
+ const content = await safeReadText(path.join(workspace.workspaceRoot, file));
406
+ return { file, bytes: content === null ? 0 : Buffer.byteLength(content) };
407
+ };
408
+ const root = await sizeOf("AGENTS.md");
409
+ if (root.bytes === 0)
410
+ return null;
411
+ const scoped = await Promise.all(sysPaths.map((sysPath) => sizeOf(`${sysPath}/AGENTS.md`)));
412
+ const largest = scoped.reduce((max, entry) => entry.bytes > max.bytes ? entry : max, { file: "", bytes: 0 });
413
+ const total = root.bytes + largest.bytes;
414
+ if (total <= 32 * 1024 * 0.8)
415
+ return null;
416
+ const subject = largest.bytes ? `AGENTS.md and ${largest.file} add up to` : "AGENTS.md is";
417
+ return `${subject} ${Math.ceil(total / 1024)} KiB of the 32 KiB Codex reads \u2014 run \`akan agent install\`, then shorten the text outside the akan:agent markers or move it into a skill.`;
418
+ }
419
+ static async#agentGuideLeftovers(workspace) {
420
+ const root = workspace.workspaceRoot;
421
+ const guide = await safeReadText(path.join(root, "AGENTS.md")) ?? "";
422
+ const leftovers = [];
423
+ for (const doc of ["docs/AI-DEVELOPMENT.md", "docs/GENERATED.md"]) {
424
+ const pointer = guide.includes(doc);
425
+ if (await safeReadText(path.join(root, doc)) !== null)
426
+ leftovers.push({
427
+ path: doc,
428
+ message: `${doc} is an older template's copy of the agent guide, and nothing reads it now \u2014 delete it${pointer ? " and the AGENTS.md sentence that points to it" : ""}.`
429
+ });
430
+ else if (pointer)
431
+ leftovers.push({
432
+ path: "AGENTS.md",
433
+ message: `AGENTS.md points to ${doc}, which is gone \u2014 delete that sentence.`
434
+ });
435
+ }
436
+ return leftovers;
437
+ }
375
438
  static async#configLeftovers(workspace, sysPaths) {
376
439
  const leftovers = [];
377
440
  for (const sysPath of sysPaths) {
@@ -435,6 +498,11 @@ class AkanContextAnalyzer {
435
498
  if (agentDrift)
436
499
  report({ severity: "warning", code: agentDrift.code, path: "AGENTS.md", message: agentDrift.message }, repairAction("generated", "akan agent install agents-md", agentDrift.hint, true));
437
500
  const sysPaths = [...context.apps, ...context.libs].map((sys) => sys.path);
501
+ const oversize = await AkanContextAnalyzer.#agentGuideOversize(workspace, sysPaths);
502
+ if (oversize)
503
+ diagnostics.push({ severity: "warning", code: "agent-guide-oversized", path: "AGENTS.md", message: oversize });
504
+ for (const leftover of await AkanContextAnalyzer.#agentGuideLeftovers(workspace))
505
+ diagnostics.push({ severity: "warning", code: "agent-guide-leftover", ...leftover });
438
506
  for (const leftover of await AkanContextAnalyzer.#configLeftovers(workspace, sysPaths))
439
507
  diagnostics.push({ severity: "warning", code: "config-leftover", ...leftover });
440
508
  for (const sys of [...context.apps, ...context.libs]) {
@@ -597,6 +665,12 @@ class AkanContextAnalyzer {
597
665
  lines.push("", "## Apps", ...context.apps.map((app) => `- ${app.name}: ${app.modules.length} module(s)`));
598
666
  lines.push("", "## Libraries", ...context.libs.map((lib) => `- ${lib.name}: ${lib.modules.length} module(s)`));
599
667
  lines.push("", "## Packages", ...context.pkgs.map((pkg) => `- ${pkg.name}${pkg.version ? ` (${pkg.version})` : ""}`));
668
+ for (const app of context.apps) {
669
+ if (app.routeError)
670
+ lines.push("", `## Routes: ${app.name}`, `- Not read: ${app.routeError}`);
671
+ else if (app.routes)
672
+ lines.push("", `## Routes: ${app.name}`, ...AkanContextAnalyzer.#routeLines(app.name, app.routes));
673
+ }
600
674
  const modules = AkanContextAnalyzer.findModules(context, moduleName);
601
675
  lines.push("", "## Modules");
602
676
  for (const module of modules) {
@@ -613,6 +687,33 @@ class AkanContextAnalyzer {
613
687
  `)}
614
688
  `;
615
689
  }
690
+ static routeListLimit = 60;
691
+ static #routeLines(appName, routes) {
692
+ const folderOf = (route) => route.file.split("/").slice(0, 4).join("/");
693
+ const groups = Map.groupBy(routes, folderOf);
694
+ const folded = new Set;
695
+ let listed = routes.length;
696
+ for (const [folder, members] of [...groups].sort((a, b) => b[1].length - a[1].length)) {
697
+ if (listed <= AkanContextAnalyzer.routeListLimit)
698
+ break;
699
+ folded.add(folder);
700
+ listed -= members.length;
701
+ }
702
+ const lines = [`Paths omit the \`/:lang\` prefix; \`akan preview ${appName} <path>\` opens one.`];
703
+ for (const route of routes) {
704
+ if (folded.has(folderOf(route)))
705
+ continue;
706
+ const search = route.search.length ? ` ?${route.search.join("&")}` : "";
707
+ const marks = `${route.guarded ? " (guarded)" : ""}${route.devOnly ? " (dev only)" : ""}`;
708
+ lines.push(`- ${route.path}${search}${marks} \u2014 ${route.file}`);
709
+ }
710
+ for (const folder of folded) {
711
+ const members = groups.get(folder) ?? [];
712
+ const examples = members.slice(0, 3).map((route) => route.path);
713
+ lines.push(`- ${folder}/: ${members.length} routes folded (${examples.join(", ")}, \u2026); \`--format json\` lists every route`);
714
+ }
715
+ return lines;
716
+ }
616
717
  }
617
718
 
618
719
  export { buildResourceList, codexMcpConfigPath, akanMcpInstallTargets, akanMcpInstallConfigPaths, createAkanMcpServer, createAkanCodexMcpServerBlock, upsertCodexMcpServerBlock, renderDoctorText, AkanContextAnalyzer };
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-9zy8479y.js";
6
6
  import {
7
7
  generatedFilesForSync,
8
8
  createPassedPrimitiveReport,
9
9
  scalarChangedFiles
10
- } from "./index-xjf5j657.js";
10
+ } from "./index-hm0tn7qv.js";
11
11
  import {
12
12
  pluralizeName
13
13
  } from "./index-nz8prx9g.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-9zy8479y.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {
@@ -836,4 +836,4 @@ class HmrWatcher {
836
836
  }
837
837
  }
838
838
 
839
- export { ApplicationBuildReporter, UNAVAILABLE_REDIS_HOST, redisTunnelPolicy, BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS, SOURCE_EXTS, shouldRestartBackendByDevPlan, shouldRestartBuilderByDevPlan, shouldAbandonBackendRecovery, normalizeBackendReportedGeneration, shouldRestartDevHostByDevPlan, devHostStateOf, isLegacyBackendFallbackFile, shouldMarkBuildPhaseRecovered, shouldKeepBuildFailure, createBackendBuildStatus, backendRestartReasonFromMessage, mergeBackendRestartReasons, shouldReplaceLastGoodMessage, shouldQueueBuildStatusReplay, hasBuildFailureForGeneration, decideBuilderRssRecycle, decideBuilderRssSettle, decideIdleSuspend, resolveIdleSuspendMs, hasAnyBuildFailure, shouldRefreshConfigOnIdleWake, shouldHoldForReturningBuilder, shouldWarnBuilderRssCeilingTight, isRssCeilingUnreachable, shouldRelayRecycledFrontendState, mergeInvalidateMessages, buildStatusReplaySequence, filesChangedSince, HmrWatcher, WatchRootResolver };
839
+ export { UNAVAILABLE_REDIS_HOST, redisTunnelPolicy, BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS, SOURCE_EXTS, shouldRestartBackendByDevPlan, shouldRestartBuilderByDevPlan, shouldAbandonBackendRecovery, normalizeBackendReportedGeneration, shouldRestartDevHostByDevPlan, devHostStateOf, isLegacyBackendFallbackFile, shouldMarkBuildPhaseRecovered, shouldKeepBuildFailure, createBackendBuildStatus, backendRestartReasonFromMessage, mergeBackendRestartReasons, shouldReplaceLastGoodMessage, shouldQueueBuildStatusReplay, hasBuildFailureForGeneration, decideBuilderRssRecycle, decideBuilderRssSettle, decideIdleSuspend, resolveIdleSuspendMs, hasAnyBuildFailure, shouldRefreshConfigOnIdleWake, shouldHoldForReturningBuilder, shouldWarnBuilderRssCeilingTight, isRssCeilingUnreachable, shouldRelayRecycledFrontendState, mergeInvalidateMessages, buildStatusReplaySequence, filesChangedSince, HmrWatcher, WatchRootResolver, ApplicationBuildReporter };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  FileSys2
4
- } from "./index-52w0fvh8.js";
4
+ } from "./index-bns3wcpc.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/dependencyScanner.ts
7
7
  import { builtinModules } from "module";
@@ -1,13 +1,13 @@
1
1
  // @bun
2
2
  import {
3
3
  AppExecutor
4
- } from "./index-wcej7g4z.js";
4
+ } from "./index-g500c5j9.js";
5
5
  import {
6
6
  jsonText,
7
7
  createWorkflowBaselineSummary,
8
8
  buildAkanModuleContextIndex,
9
9
  toolingRolloutGate
10
- } from "./index-xjf5j657.js";
10
+ } from "./index-hm0tn7qv.js";
11
11
  import {
12
12
  buildResourceList,
13
13
  codexMcpConfigPath,
@@ -17,31 +17,32 @@ import {
17
17
  upsertCodexMcpServerBlock,
18
18
  renderDoctorText,
19
19
  AkanContextAnalyzer
20
- } from "./index-31es1yev.js";
20
+ } from "./index-j7hwy56s.js";
21
21
  import {
22
22
  runner
23
- } from "./index-3wypz6xj.js";
23
+ } from "./index-9zy8479y.js";
24
24
  import {
25
25
  NativeApp
26
- } from "./index-bt438yxm.js";
26
+ } from "./index-sp0qsr7a.js";
27
27
  import {
28
28
  isPlaceholderAppId
29
- } from "./index-js6geqjn.js";
29
+ } from "./index-0j1t1h2b.js";
30
30
  import {
31
31
  getMobileTargets,
32
32
  appIdsOf
33
33
  } from "./index-m9jj544v.js";
34
34
  import {
35
35
  Prompter2
36
- } from "./index-zzvvc845.js";
36
+ } from "./index-j6eeh5d7.js";
37
37
  import {
38
38
  RepairRunner
39
- } from "./index-j9vyj3dj.js";
39
+ } from "./index-2phm56a1.js";
40
40
  import {
41
41
  WorkflowRunner
42
- } from "./index-b70zct19.js";
42
+ } from "./index-raz588b3.js";
43
43
 
44
44
  // pkgs/@akanjs/devkit/akanMcpContract.ts
45
+ import { lstatSync, realpathSync } from "fs";
45
46
  import path from "path";
46
47
  import { isRecord } from "akanjs/common";
47
48
  var emptySchema = { type: "object", properties: {} };
@@ -134,7 +135,44 @@ var optionalString = (args, key) => {
134
135
  };
135
136
  var isInspectAkanContextRequestType = (value) => typeof value === "string" && inspectAkanContextRequestTypes.includes(value);
136
137
  var parseJsonOutput = (output) => JSON.parse(output);
137
- var workspacePath = (workspace, filePath) => path.isAbsolute(filePath) ? filePath : path.join(workspace.workspaceRoot, filePath);
138
+ var workflowArtifactDir = ".akan/workflows";
139
+ var workflowRunIdPattern = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
140
+ var isInside = (base, target) => {
141
+ const relative = path.relative(base, target);
142
+ return !!relative && !relative.startsWith("..") && !path.isAbsolute(relative);
143
+ };
144
+ var hasEntry = (filePath) => {
145
+ try {
146
+ lstatSync(filePath);
147
+ return true;
148
+ } catch {
149
+ return false;
150
+ }
151
+ };
152
+ var realPathOfNearest = (filePath) => {
153
+ const rest = [];
154
+ let current = filePath;
155
+ while (!hasEntry(current) && path.dirname(current) !== current) {
156
+ rest.unshift(path.basename(current));
157
+ current = path.dirname(current);
158
+ }
159
+ return path.join(realpathSync(current), ...rest);
160
+ };
161
+ var staysInside = (workspaceRoot, root, resolved) => {
162
+ try {
163
+ const realRoot = realPathOfNearest(root);
164
+ return isInside(realPathOfNearest(workspaceRoot), realRoot) && isInside(realRoot, realPathOfNearest(resolved));
165
+ } catch {
166
+ return false;
167
+ }
168
+ };
169
+ var workflowArtifactPath = (workspace, filePath) => {
170
+ const root = path.resolve(workspace.workspaceRoot, workflowArtifactDir);
171
+ const resolved = workflowRunIdPattern.test(filePath) && !filePath.endsWith(".json") ? path.join(root, "runs", `${filePath}.json`) : path.resolve(workspace.workspaceRoot, filePath);
172
+ if (!isInside(root, resolved) || !staysInside(workspace.workspaceRoot, root, resolved))
173
+ throw new Error(`MCP workflow files live under ${workflowArtifactDir}/ of the workspace, not ${JSON.stringify(filePath)}.`);
174
+ return resolved;
175
+ };
138
176
  var defaultWorkflowPlanPath = (workflow, inputs) => {
139
177
  const slug = [
140
178
  slugPart(workflow),
@@ -432,7 +470,7 @@ var inspectAkanContext = async (workspace, args) => {
432
470
  if (props.request.type === "workflowDiagnostics") {
433
471
  const doctor = await AkanContextAnalyzer.doctor(workspace, {
434
472
  strict: true,
435
- runIdOrPlan: workspacePath(workspace, props.request.runIdOrPlan)
473
+ runIdOrPlan: workflowArtifactPath(workspace, props.request.runIdOrPlan)
436
474
  });
437
475
  const toWorkflowDiagnostic = ({ severity, code, message, scope }, context) => ({ severity, code, message, scope, context });
438
476
  const baselineSummary = createWorkflowBaselineSummary((doctor.baselineDiagnostics ?? []).map((diagnostic) => toWorkflowDiagnostic(diagnostic, diagnostic.context)), { detailsIncluded: false });
@@ -654,8 +692,7 @@ class ContextRunner2 extends runner("context") {
654
692
  throw new Error(`${configPath} already has an "akan" MCP server. Re-run with --force to overwrite it.`);
655
693
  }
656
694
  const nextConfig = { ...existing, mcpServers: { ...mcpServers, akan: nextAkanServer } };
657
- await workspace.writeFile(configPath, `${JSON.stringify(nextConfig, null, 2)}
658
- `);
695
+ await workspace.writeFile(configPath, nextConfig);
659
696
  return configPath;
660
697
  }
661
698
  async#installCodexMcp(workspace, { force, mode }) {
@@ -714,7 +751,7 @@ class ContextRunner2 extends runner("context") {
714
751
  if (name === "doctor_workspace")
715
752
  return compactDoctorWorkspaceResult(await AkanContextAnalyzer.doctor(workspace, {
716
753
  strict: !!args.strict,
717
- runIdOrPlan: typeof args.runIdOrPlan === "string" ? workspacePath(workspace, args.runIdOrPlan) : null,
754
+ runIdOrPlan: typeof args.runIdOrPlan === "string" ? workflowArtifactPath(workspace, args.runIdOrPlan) : null,
718
755
  changedFiles: Array.isArray(args.changedFiles) ? args.changedFiles.filter((file) => typeof file === "string") : []
719
756
  }), !!args.includeBaselineDetails);
720
757
  if (name === "explain_command")
@@ -731,7 +768,7 @@ class ContextRunner2 extends runner("context") {
731
768
  const planPath = typeof args.out === "string" && args.out ? args.out : defaultWorkflowPlanPath(workflow, inputs);
732
769
  const plan = parseJsonOutput(await new WorkflowRunner().plan(workflow, inputs, {
733
770
  format: "json",
734
- out: workspacePath(workspace, planPath)
771
+ out: workflowArtifactPath(workspace, planPath)
735
772
  }));
736
773
  return {
737
774
  ...plan,
@@ -742,7 +779,7 @@ class ContextRunner2 extends runner("context") {
742
779
  };
743
780
  }
744
781
  if (name === "apply_workflow") {
745
- const report = parseJsonOutput(await new WorkflowRunner().apply(workspacePath(workspace, stringArg(args, "planPath")), {
782
+ const report = parseJsonOutput(await new WorkflowRunner().apply(workflowArtifactPath(workspace, stringArg(args, "planPath")), {
746
783
  format: "json",
747
784
  dryRun: !!args.dryRun,
748
785
  workspace,
@@ -757,7 +794,7 @@ class ContextRunner2 extends runner("context") {
757
794
  };
758
795
  }
759
796
  if (name === "run_validation")
760
- return parseJsonOutput(await new WorkflowRunner().validate(workspacePath(workspace, stringArg(args, "runIdOrPlan")), {
797
+ return parseJsonOutput(await new WorkflowRunner().validate(workflowArtifactPath(workspace, stringArg(args, "runIdOrPlan")), {
761
798
  format: "json",
762
799
  workspace,
763
800
  includeBaselineDetails: !!args.includeBaselineDetails
@@ -949,6 +986,7 @@ ${payload}`);
949
986
  "create-ui": "`akan create-ui --app <app-or-lib> --module <module> --surface <view|unit|template> --format json` creates one UI surface and returns a primitive write report.",
950
987
  "add-field": "`akan add-field --app <app-or-lib> --module <module> --field <field> --type <String|Boolean|Date|Int|Float|scalar> --format json` updates source constant/dictionary files. Use Int or Float for numeric fields, not Number.",
951
988
  "add-enum-field": "`akan add-enum-field --app <app-or-lib> --module <module> --field <field> --values a,b --format json` adds an enum field to source constant/dictionary files without editing generated files.",
989
+ verify: "`akan verify [<app-or-lib-or-pkg>]` syncs, lints, typechecks and fast-builds what git reports as changed in one run, printing one line per problem; run it instead of lint, typecheck and build in turn.",
952
990
  sync: "`akan sync <app-or-lib>` refreshes generated Akan files from source conventions.",
953
991
  lint: "`akan lint <app-or-lib-or-pkg>` runs Biome linting after preparing generated files.",
954
992
  typecheck: "`akan typecheck <app-or-lib>` typechecks an app or a library after preparing generated files, its tests and specs included (`--tests false` to leave them out; a build does).",