@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,487 @@
1
+ // @bun
2
+ import {
3
+ ApplicationBuildReporter
4
+ } from "./index-p6x5b7hr.js";
5
+ import {
6
+ parseBiomeReport,
7
+ Linter,
8
+ TypecheckFailure,
9
+ ProjectTypecheck2,
10
+ AppExecutor,
11
+ LibExecutor,
12
+ PkgExecutor
13
+ } from "./index-g500c5j9.js";
14
+ import {
15
+ WorkspaceRunner,
16
+ AkanQualityScanner
17
+ } from "./index-cjmjvg4r.js";
18
+
19
+ // pkgs/@akanjs/cli/verify/verifyComments.ts
20
+ import { existsSync } from "fs";
21
+ import path from "path";
22
+
23
+ class VerifyComments {
24
+ static code = "akan.comment.added";
25
+ static fix = "keep only a fact the code cannot say (vendor quirk, constraint, security, domain meaning, rejected alternative); delete the rest";
26
+ static #codeFile = /\.[cm]?[jt]sx?$/;
27
+ static #directive = /^(\/\/\/?|\/\*+)\s*(biome-ignore|@ts-|eslint-|prettier-ignore|#region|#endregion|<reference|[#@]__PURE__|@__NO_SIDE_EFFECTS__)/;
28
+ static #typescriptLoad;
29
+ static #templateCommentsLoad;
30
+ static #loadTypescript() {
31
+ VerifyComments.#typescriptLoad ??= import("typescript").then((mod) => mod.default ?? mod);
32
+ return VerifyComments.#typescriptLoad;
33
+ }
34
+ static async added(root, files) {
35
+ const code = files.filter((file) => VerifyComments.#codeFile.test(file) && existsSync(path.join(root, file)));
36
+ if (!code.length)
37
+ return [];
38
+ const changed = await VerifyComments.#addedLines(root, code);
39
+ if (!changed)
40
+ return [];
41
+ const typescript = await VerifyComments.#loadTypescript();
42
+ const templateComments = await VerifyComments.#loadTemplateComments();
43
+ const diagnostics = [];
44
+ for (const file of code) {
45
+ const lines = changed.get(file);
46
+ if (lines?.size === 0)
47
+ continue;
48
+ const text = await Bun.file(path.join(root, file)).text();
49
+ for (const comment of VerifyComments.commentsOf(typescript, file, text)) {
50
+ if (VerifyComments.#directive.test(comment.text))
51
+ continue;
52
+ if (VerifyComments.#scaffolded(comment, templateComments))
53
+ continue;
54
+ if (lines && !VerifyComments.#touches(comment, lines))
55
+ continue;
56
+ diagnostics.push({
57
+ step: "lint",
58
+ file,
59
+ line: comment.line,
60
+ col: comment.col,
61
+ code: VerifyComments.code,
62
+ severity: "warning",
63
+ message: VerifyComments.#excerpt(comment.text)
64
+ });
65
+ }
66
+ }
67
+ const [first] = diagnostics;
68
+ if (first)
69
+ first.fix = VerifyComments.fix;
70
+ return diagnostics;
71
+ }
72
+ static commentsOf(typescript, file, text) {
73
+ const kind = file.endsWith("x") ? typescript.ScriptKind.TSX : typescript.ScriptKind.TS;
74
+ const source = typescript.createSourceFile(file, text, typescript.ScriptTarget.Latest, true, kind);
75
+ const ranges = new Map;
76
+ const visit = (node) => {
77
+ if (node.kind === typescript.SyntaxKind.JsxText)
78
+ return;
79
+ if (node.kind >= typescript.SyntaxKind.FirstJSDocNode && node.kind <= typescript.SyntaxKind.LastJSDocNode)
80
+ return;
81
+ const children = node.getChildren(source);
82
+ for (const child of children)
83
+ visit(child);
84
+ if (children.length)
85
+ return;
86
+ const start = node.getFullStart();
87
+ for (const range of [
88
+ ...typescript.getTrailingCommentRanges(text, start) ?? [],
89
+ ...typescript.getLeadingCommentRanges(text, start) ?? []
90
+ ])
91
+ ranges.set(range.pos, range);
92
+ };
93
+ visit(source);
94
+ return [...ranges.values()].sort((a, b) => a.pos - b.pos).map((range) => {
95
+ const start = source.getLineAndCharacterOfPosition(range.pos);
96
+ const end = source.getLineAndCharacterOfPosition(range.end);
97
+ return {
98
+ text: text.slice(range.pos, range.end),
99
+ line: start.line + 1,
100
+ col: start.character + 1,
101
+ lastLine: end.line + 1
102
+ };
103
+ });
104
+ }
105
+ static #scaffolded(comment, templateComments) {
106
+ return comment.text.split(`
107
+ `).every((line) => !line.trim() || templateComments.has(line.trim()));
108
+ }
109
+ static #loadTemplateComments() {
110
+ VerifyComments.#templateCommentsLoad ??= (async () => {
111
+ const comments = new Set;
112
+ const root = ["templates", "../templates"].map((dir) => path.join(import.meta.dir, dir)).find(existsSync);
113
+ if (!root)
114
+ return comments;
115
+ for (const file of new Bun.Glob("**/*.{ts,tsx,template}").scanSync({ cwd: root, dot: true }))
116
+ for (const raw of (await Bun.file(path.join(root, file)).text()).split(/\n|\\n/)) {
117
+ const line = raw.replace(/\\([`$\\])/g, "$1").trim();
118
+ for (const { index } of line.matchAll(/\/\/|\/\*|^\*/g))
119
+ comments.add(line.slice(index).trim());
120
+ }
121
+ return comments;
122
+ })();
123
+ return VerifyComments.#templateCommentsLoad;
124
+ }
125
+ static #touches(comment, lines) {
126
+ for (let line = comment.line;line <= comment.lastLine; line++)
127
+ if (lines.has(line))
128
+ return true;
129
+ return false;
130
+ }
131
+ static #excerpt(comment) {
132
+ const first = comment.split(`
133
+ `).find((line) => line.replace(/^[\s/*]+/, "").trim()) ?? comment;
134
+ const flat = first.replace(/\s+/g, " ").trim();
135
+ return flat.length <= 60 ? flat : `${flat.slice(0, 59)}\u2026`;
136
+ }
137
+ static async#addedLines(root, files) {
138
+ const tracked = await VerifyComments.#git(root, ["ls-files", "-z", "--", ...files]);
139
+ const diff = await VerifyComments.#git(root, [
140
+ "-c",
141
+ "core.quotePath=false",
142
+ "diff",
143
+ "-U0",
144
+ "--no-color",
145
+ "--no-ext-diff",
146
+ "--relative",
147
+ "HEAD",
148
+ "--",
149
+ ...files
150
+ ]);
151
+ if (tracked === null || diff === null)
152
+ return null;
153
+ const trackedFiles = new Set(tracked.split("\x00").filter(Boolean));
154
+ const added = VerifyComments.parseDiff(diff);
155
+ return new Map(files.map((file) => [file, trackedFiles.has(file) ? added.get(file) ?? new Set : undefined]));
156
+ }
157
+ static parseDiff(diff) {
158
+ const added = new Map;
159
+ let current = null;
160
+ for (const line of diff.split(`
161
+ `)) {
162
+ if (line.startsWith("+++ ")) {
163
+ const file = line.slice(4).replace(/^b\//, "");
164
+ current = file === "/dev/null" ? null : new Set;
165
+ if (current)
166
+ added.set(file, current);
167
+ continue;
168
+ }
169
+ const [, from, length] = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) ?? [];
170
+ if (from === undefined || !current)
171
+ continue;
172
+ const start = Number(from);
173
+ const count = length === undefined ? 1 : Number(length);
174
+ for (let offset = 0;offset < count; offset++)
175
+ current.add(start + offset);
176
+ }
177
+ return added;
178
+ }
179
+ static async#git(root, args) {
180
+ const proc = Bun.spawn(["git", ...args], { cwd: root, stdout: "pipe", stderr: "ignore" });
181
+ const [stdout, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
182
+ return code === 0 ? stdout : null;
183
+ }
184
+ }
185
+
186
+ // pkgs/@akanjs/cli/verify/verifyPipeline.ts
187
+ import { existsSync as existsSync2 } from "fs";
188
+ import path2 from "path";
189
+
190
+ // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
191
+ class VerifyDiagnostics {
192
+ static fromTypecheck(records) {
193
+ return records.map((record) => {
194
+ const message = record.message.split(`
195
+ `)[0] ?? record.message;
196
+ return {
197
+ step: "typecheck",
198
+ file: record.file,
199
+ line: record.line,
200
+ col: record.col,
201
+ code: record.code,
202
+ severity: record.severity,
203
+ ...VerifyDiagnostics.#dictionaryKeyMiss(message) ?? { message }
204
+ };
205
+ });
206
+ }
207
+ static #dictionaryKeyArg = /^(?:Argument of type|Type) '"([\w$-]+)\.([\w$.-]+)"' is not assignable to (?:parameter of )?type '(?:"base\.|ServiceTranslatorKey<"base")/;
208
+ static #dictionaryKeyMiss(message) {
209
+ const [, refName, key] = message.match(VerifyDiagnostics.#dictionaryKeyArg) ?? [];
210
+ if (!refName || !key)
211
+ return null;
212
+ const dictionaryFile = `${refName}.dictionary.ts`;
213
+ if (key.startsWith("error."))
214
+ return {
215
+ message: `"${refName}.${key}" is not an error key of the ${refName} dictionary`,
216
+ fix: `add ${key.slice("error.".length)}: [en, ko] to .error({}) in ${dictionaryFile} (a service module's dictionary must be a serviceDictionary)`
217
+ };
218
+ return {
219
+ message: `"${refName}.${key}" is not a key of the ${refName} dictionary`,
220
+ fix: `check the spelling, or add ${key}: [en, ko] to .translate({}) in ${dictionaryFile}; one-off text takes l.trans({ en, ko })`
221
+ };
222
+ }
223
+ static fromBiome(report) {
224
+ return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => ({
225
+ step: "lint",
226
+ file: diagnostic.location?.path?.replaceAll("\\", "/") ?? null,
227
+ line: diagnostic.location?.start?.line ?? 0,
228
+ col: diagnostic.location?.start?.column ?? 0,
229
+ code: diagnostic.category ?? "biome",
230
+ severity: diagnostic.severity === "error" ? "error" : "warning",
231
+ message: diagnostic.message
232
+ }));
233
+ }
234
+ static fromMaintainability(entries) {
235
+ return entries.map((entry) => ({
236
+ step: "lint",
237
+ file: entry.file,
238
+ line: entry.line,
239
+ col: 0,
240
+ code: entry.rule,
241
+ severity: "error",
242
+ message: entry.problem,
243
+ fix: entry.path ? `${entry.fix} Path: ${entry.path}` : entry.fix
244
+ }));
245
+ }
246
+ static fromQuality(warnings, changedFiles) {
247
+ return warnings.filter((warning) => warning.file && changedFiles.has(warning.file)).map((warning) => ({
248
+ step: "ssr",
249
+ file: warning.file ?? null,
250
+ line: warning.line ?? 0,
251
+ col: 0,
252
+ code: warning.rule,
253
+ severity: "warning",
254
+ message: warning.message,
255
+ ...warning.fix ? { fix: warning.fix } : {}
256
+ }));
257
+ }
258
+ static #prefix = /^\[([\w.-]+)\]\s*/;
259
+ static #location = /((?:apps|libs|pkgs)\/[^\s:()`'"]+\.[a-z]+)(?::(\d+)(?::(\d+))?)?/;
260
+ static fromMessage(step, message, code = `akan.${step}`) {
261
+ const prefix = VerifyDiagnostics.#prefix.exec(message);
262
+ const location = VerifyDiagnostics.#location.exec(message);
263
+ return {
264
+ step,
265
+ file: location ? location[1] ?? null : null,
266
+ line: Number(location?.[2] ?? 0),
267
+ col: Number(location?.[3] ?? 0),
268
+ code: prefix?.[1] ?? code,
269
+ severity: "error",
270
+ message: message.slice(prefix?.[0].length ?? 0).trim()
271
+ };
272
+ }
273
+ }
274
+
275
+ // pkgs/@akanjs/cli/verify/verifyPipeline.ts
276
+ class VerifyPipeline {
277
+ #workspace;
278
+ #workspaceRunner;
279
+ #applicationRunner;
280
+ #steps = new Map;
281
+ #diagnostics = [];
282
+ constructor(workspace, workspaceRunner, applicationRunner) {
283
+ this.#workspace = workspace;
284
+ this.#workspaceRunner = workspaceRunner;
285
+ this.#applicationRunner = applicationRunner;
286
+ }
287
+ get #root() {
288
+ return this.#workspace.workspaceRoot;
289
+ }
290
+ async run(scope, { lintOnly = false, build = true } = {}) {
291
+ const startedAt = performance.now();
292
+ const systems = scope.targets.filter((target) => target.type !== "pkg");
293
+ if (!lintOnly)
294
+ await this.#each("sync", systems, (target) => this.#sync(target));
295
+ const synced = !this.#failed("sync");
296
+ await Promise.all([
297
+ this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly })),
298
+ lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target))
299
+ ]);
300
+ const apps = scope.targets.filter((target) => target.type === "app");
301
+ const clean = !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error");
302
+ if (!lintOnly && build && apps.length) {
303
+ if (clean)
304
+ await this.#each("build", apps, (target) => this.#build(target));
305
+ else
306
+ this.#skip("build");
307
+ }
308
+ if (!lintOnly && scope.touchesTsx)
309
+ await this.#each("ssr", [null], () => this.#ssr(scope));
310
+ return {
311
+ ok: !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error"),
312
+ targets: scope.targets.map((target) => target.name),
313
+ ms: Math.round(performance.now() - startedAt),
314
+ steps: [...this.#steps.values()],
315
+ diagnostics: this.#diagnostics
316
+ };
317
+ }
318
+ async#each(name, items, step) {
319
+ if (!items.length)
320
+ return;
321
+ const startedAt = performance.now();
322
+ let fixed = 0;
323
+ let failed = false;
324
+ for (const item of items) {
325
+ const outcome = await step(item).catch((error) => ({
326
+ diagnostics: [VerifyDiagnostics.fromMessage(name, ApplicationBuildReporter.formatError(error, this.#root))]
327
+ }));
328
+ fixed += outcome.fixed ?? 0;
329
+ failed ||= outcome.diagnostics.some((diagnostic) => diagnostic.severity === "error");
330
+ this.#diagnostics.push(...outcome.diagnostics);
331
+ }
332
+ const ms = Math.round(performance.now() - startedAt);
333
+ this.#steps.set(name, { name, status: failed ? "fail" : "pass", ms, fixed });
334
+ }
335
+ #skip(name) {
336
+ this.#steps.set(name, { name, status: "skip", ms: 0, fixed: 0 });
337
+ }
338
+ #failed(name) {
339
+ return this.#steps.get(name)?.status === "fail";
340
+ }
341
+ async#sync(target) {
342
+ if (target.type === "app")
343
+ await AppExecutor.from(this.#workspace, target.name).scanSync();
344
+ else
345
+ await LibExecutor.from(this.#workspace, target.name).scan();
346
+ return { diagnostics: [] };
347
+ }
348
+ async#lint(target, { comments }) {
349
+ const files = target.files.length ? target.files.filter((file) => existsSync2(path2.join(this.#root, file))) : [target.dir];
350
+ const biome = files.length ? await this.#biome(files) : { diagnostics: [], fixed: 0 };
351
+ const exec = this.#execOf(target);
352
+ const gates = await this.#workspaceRunner.lintGateFailures(exec, true);
353
+ const added = comments && target.files.length ? await VerifyComments.added(this.#root, target.files) : [];
354
+ return {
355
+ diagnostics: [
356
+ ...biome.diagnostics,
357
+ ...added,
358
+ ...gates.messages.map((message) => VerifyDiagnostics.fromMessage("lint", message, "akan.lint")),
359
+ ...VerifyDiagnostics.fromMaintainability(gates.maintainability)
360
+ ],
361
+ fixed: biome.fixed
362
+ };
363
+ }
364
+ async#biome(files) {
365
+ const configPath = await WorkspaceRunner.resolveBiomeConfigPath(this.#workspace);
366
+ const [biome, ...biomeArgs] = Linter.biomeCommand(this.#root);
367
+ const proc = Bun.spawn([
368
+ biome,
369
+ ...biomeArgs,
370
+ "check",
371
+ "--write",
372
+ "--reporter=json",
373
+ "--max-diagnostics=none",
374
+ "--no-errors-on-unmatched",
375
+ ...configPath ? ["--config-path", configPath] : [],
376
+ ...files
377
+ ], { cwd: this.#root, stdout: "pipe", stderr: "pipe" });
378
+ const [stdout, stderr] = await Promise.all([
379
+ new Response(proc.stdout).text(),
380
+ new Response(proc.stderr).text(),
381
+ proc.exited
382
+ ]);
383
+ try {
384
+ const report = parseBiomeReport(stdout);
385
+ return { diagnostics: VerifyDiagnostics.fromBiome(report), fixed: report.summary?.changed ?? 0 };
386
+ } catch {
387
+ return { diagnostics: [VerifyDiagnostics.fromMessage("lint", (stderr || stdout).trim(), "biome")] };
388
+ }
389
+ }
390
+ async#typecheck(target) {
391
+ try {
392
+ if (target.type === "app")
393
+ await this.#applicationRunner.typecheck(AppExecutor.from(this.#workspace, target.name), {
394
+ tests: true,
395
+ report: "records"
396
+ });
397
+ else if (target.type === "lib")
398
+ await this.#applicationRunner.typecheckLibrary(LibExecutor.from(this.#workspace, target.name), {
399
+ tests: true,
400
+ report: "records"
401
+ });
402
+ else {
403
+ const tsconfigPath = path2.join(this.#root, target.dir, "tsconfig.json");
404
+ if (!existsSync2(tsconfigPath))
405
+ return { diagnostics: [] };
406
+ await new ProjectTypecheck2(path2.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
407
+ }
408
+ return { diagnostics: [] };
409
+ } catch (error) {
410
+ if (error instanceof TypecheckFailure)
411
+ return { diagnostics: VerifyDiagnostics.fromTypecheck(error.records) };
412
+ throw error;
413
+ }
414
+ }
415
+ async#build(target) {
416
+ await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
417
+ return { diagnostics: [] };
418
+ }
419
+ async#ssr(scope) {
420
+ const scanned = await new AkanQualityScanner().scan(this.#root);
421
+ const warnings = scanned.warnings.filter((warning) => warning.scope === "ssr");
422
+ return { diagnostics: VerifyDiagnostics.fromQuality(warnings, scope.changedFiles) };
423
+ }
424
+ #execOf(target) {
425
+ if (target.type === "app")
426
+ return AppExecutor.from(this.#workspace, target.name);
427
+ if (target.type === "lib")
428
+ return LibExecutor.from(this.#workspace, target.name);
429
+ return PkgExecutor.from(this.#workspace, target.name);
430
+ }
431
+ }
432
+
433
+ // pkgs/@akanjs/cli/verify/verifyReport.ts
434
+ class VerifyReport {
435
+ static lineMax = 280;
436
+ static defaultMax = 20;
437
+ static text(result, { max = VerifyReport.defaultMax } = {}) {
438
+ if (!result.targets.length)
439
+ return "verify ok \xB7 nothing changed under apps/, libs/ or pkgs/";
440
+ const lines = [VerifyReport.#header(result), ...VerifyReport.#diagnosticLines(result.diagnostics, max)];
441
+ return lines.join(`
442
+ `);
443
+ }
444
+ static json(result) {
445
+ return JSON.stringify(result);
446
+ }
447
+ static #header(result) {
448
+ const ran = result.steps.filter((step) => step.name !== "sync" || step.status === "fail");
449
+ const fixed = result.steps.reduce((sum, step) => sum + step.fixed, 0);
450
+ const seconds = `${(result.ms / 1000).toFixed(1)}s`;
451
+ const fixedNote = fixed ? `fixed ${fixed} file${fixed === 1 ? "" : "s"}` : null;
452
+ const steps = result.ok ? ran.filter((step) => step.status === "pass").map((step) => step.name).join(" ") : ran.map((step) => VerifyReport.#stepLabel(step, result.diagnostics)).join(" \xB7 ");
453
+ return [`verify ${result.ok ? "ok" : "fail"}`, result.targets.join(", "), steps, fixedNote, seconds].filter(Boolean).join(" \xB7 ");
454
+ }
455
+ static #stepLabel(step, diagnostics) {
456
+ if (step.status === "skip")
457
+ return `${step.name} skipped`;
458
+ if (step.status === "pass")
459
+ return `${step.name} ok`;
460
+ const errors = diagnostics.filter((entry) => entry.step === step.name && entry.severity === "error").length;
461
+ return `${step.name} ${errors} error${errors === 1 ? "" : "s"}`;
462
+ }
463
+ static #diagnosticLines(diagnostics, max) {
464
+ const groups = new Map;
465
+ const ordered = [...diagnostics].sort((a, b) => Number(a.severity === "warning") - Number(b.severity === "warning"));
466
+ for (const diagnostic of ordered) {
467
+ const key = `${diagnostic.code}\x00${diagnostic.message}`;
468
+ groups.set(key, [...groups.get(key) ?? [], diagnostic]);
469
+ }
470
+ const lines = [...groups.values()].map((group) => VerifyReport.#lineOf(group));
471
+ if (max <= 0 || lines.length <= max)
472
+ return lines;
473
+ return [...lines.slice(0, max), `+${lines.length - max} more \xB7 akan verify --max 0`];
474
+ }
475
+ static #lineOf([first, ...rest]) {
476
+ if (!first)
477
+ return "";
478
+ const where = first.file ? `${first.file}${first.line ? `:${first.line}${first.col ? `:${first.col}` : ""}` : ""}` : "-";
479
+ const others = rest.length ? ` (\xD7${rest.length + 1}: ${rest.slice(0, 2).map((entry) => entry.file === first.file ? `:${entry.line}` : entry.file ?? "-").join(", ")}${rest.length > 2 ? `, +${rest.length - 2}` : ""})` : "";
480
+ const fix = first.fix ? ` fix: ${first.fix}` : "";
481
+ const warning = first.severity === "warning" ? " warning" : "";
482
+ const line = `${where}${others}${warning} ${first.code} ${first.message}${fix}`.replace(/\s+/g, " ").trim();
483
+ return line.length <= VerifyReport.lineMax ? line : `${line.slice(0, VerifyReport.lineMax - 1)}\u2026`;
484
+ }
485
+ }
486
+
487
+ export { VerifyComments, VerifyPipeline, VerifyReport };
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-3wypz6xj.js";
5
+ } from "./index-9zy8479y.js";
6
6
  import {
7
7
  FileSys2
8
- } from "./index-52w0fvh8.js";
8
+ } from "./index-bns3wcpc.js";
9
9
  import {
10
10
  PkgExecutor
11
- } from "./index-wcej7g4z.js";
11
+ } from "./index-g500c5j9.js";
12
12
  import {
13
13
  TypeScriptDependencyScanner2
14
- } from "./index-tvehn2sp.js";
14
+ } from "./index-qd7xn2bk.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/package/package.runner.ts
17
17
  import path2 from "path";
@@ -109,6 +109,7 @@ class PackageRunner extends runner("package") {
109
109
  "akanjs",
110
110
  "@akanjs/cli",
111
111
  "@akanjs/devkit",
112
+ "@akanjs/language",
112
113
  "create-akan-workspace"
113
114
  ];
114
115
  static #bundledRuntimeDependencies = {
@@ -179,7 +180,7 @@ class PackageRunner extends runner("package") {
179
180
  packageRuntimeDependencies[pkg.name] = [
180
181
  ...Object.keys(devkitPackageJson.dependencies ?? {}),
181
182
  "tailwind-scrollbar"
182
- ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit");
183
+ ].filter((dep) => dep !== "akanjs" && dep !== "@akanjs/devkit" && dep !== "@akanjs/language");
183
184
  }
184
185
  const bundledRuntimeDeps = new Set(PackageRunner.#bundledRuntimeDependencies[pkg.name] ?? []);
185
186
  const forcedRuntimeDeps = packageRuntimeDependencies[pkg.name] ?? [];
@@ -233,7 +234,8 @@ class PackageRunner extends runner("package") {
233
234
  const specifierPattern = new RegExp(`["'](${alternatives.join("|")})((?:/[^"'\\s]*)?)["']`, "g");
234
235
  const glob = new Bun.Glob(PackageRunner.#scannableDistFiles);
235
236
  const imports = new Map;
236
- for await (const relative of glob.scan({ cwd: distPath })) {
237
+ for await (const scanned of glob.scan({ cwd: distPath })) {
238
+ const relative = scanned.split(path2.sep).join("/");
237
239
  if (relative.includes("node_modules/") || relative.endsWith(".d.ts"))
238
240
  continue;
239
241
  if (/\.(test|spec)\.[a-z]+$/.test(relative))
@@ -0,0 +1 @@
1
+ // @bun
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getDirname2,
4
4
  FileSys2
5
- } from "./index-52w0fvh8.js";
5
+ } from "./index-bns3wcpc.js";
6
6
  import {
7
7
  Executor,
8
8
  WorkspaceExecutor,
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-wcej7g4z.js";
13
+ } from "./index-g500c5j9.js";
14
14
 
15
15
  // pkgs/@akanjs/devkit/commandDecorators/camelToKebabCase.ts
16
16
  var camelToKebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -348,7 +348,11 @@ class WorkspaceVersionCheck {
348
348
  return JSON.parse(readFileSync(packageJsonPath, "utf8")).version ?? null;
349
349
  }
350
350
  static #quote(arg) {
351
- return /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'\\''`)}'`;
351
+ if (/^[\w@%+=:,./-]+$/.test(arg))
352
+ return arg;
353
+ if (process.platform === "win32")
354
+ return `"${arg.replaceAll('"', "\\\"")}"`;
355
+ return `'${arg.replaceAll("'", `'\\''`)}'`;
352
356
  }
353
357
  }
354
358
 
@@ -734,8 +738,10 @@ ${versionWarning}`), undefined, "error");
734
738
  const opt = args[args.length - 2];
735
739
  reportFailure = async (failure) => await onFailure?.(failure, { usage: false, given: givenOptionsOf(allArgMetas, opt) });
736
740
  const commandArgs = [];
737
- if (targetMeta.targetOption.runsOnWorkspaceRoot)
741
+ if (targetMeta.targetOption.runsOnWorkspaceRoot) {
738
742
  await assertCurrentDirectoryIsWorkspaceRoot();
743
+ WorkspaceExecutor.defaultCloneToLocalEnv(process.cwd());
744
+ }
739
745
  const workspace = WorkspaceExecutor.fromRoot();
740
746
  const commandContext = { values: {} };
741
747
  for (const argMeta of allArgMetas) {
@@ -853,4 +859,4 @@ function command(refName, depsOrBuilder, builder) {
853
859
  }
854
860
  return CommandBase;
855
861
  }
856
- export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
862
+ export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };