@akanjs/cli 3.1.1-rc.9 → 3.1.1

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 (184) hide show
  1. package/.build-stamp +1 -1
  2. package/CodeAgent-35wnb7w5.js +9 -0
  3. package/{CodeTui-z5vkm9ea.js → CodeTui-h6yz2kvq.js} +1 -1
  4. package/TunnelShare-xyjpa7gx.js +14 -0
  5. package/agent.command-3r4jsck8.js +46 -0
  6. package/akanCode.js +10 -6
  7. package/{application.command-wthg8nn9.js → application.command-g7xv6ad0.js} +44 -11
  8. package/{applicationBuildRunner-t2r84sz6.js → applicationBuildRunner-qvjnhr9j.js} +9 -6
  9. package/buildBatch.proc.js +6 -6
  10. package/{cloud.command-sz11hpre.js → cloud.command-6ebygmhw.js} +17 -15
  11. package/cloud.script-0s1jybd5.js +26 -0
  12. package/{code.command-9h3yrzhe.js → code.command-mpkm2emr.js} +6 -6
  13. package/commandManifest.json +1 -1
  14. package/{context.command-15j9b7c0.js → context.command-svdh6b2w.js} +18 -17
  15. package/context.runner-ch0z3a8g.js +26 -0
  16. package/{devTui-q7k7bakd.js → devTui-evr3b35y.js} +1 -1
  17. package/{guideline.command-snh85ctf.js → guideline.command-qwp3tnjx.js} +3 -3
  18. package/guidelines/conventions/core.md +106 -0
  19. package/guidelines/conventions/rules/app.md +83 -0
  20. package/guidelines/conventions/rules/auth.md +45 -0
  21. package/guidelines/conventions/rules/config.md +56 -0
  22. package/guidelines/conventions/rules/constant.md +24 -0
  23. package/guidelines/conventions/rules/gates.md +31 -0
  24. package/guidelines/conventions/rules/layer.md +25 -0
  25. package/guidelines/conventions/rules/migration.md +27 -0
  26. package/guidelines/conventions/rules/module.md +90 -0
  27. package/guidelines/conventions/rules/page.md +56 -0
  28. package/guidelines/conventions/rules/sensitive.md +16 -0
  29. package/guidelines/conventions/rules/server.md +86 -0
  30. package/guidelines/conventions/rules/ssr.md +47 -0
  31. package/guidelines/conventions/rules/style.md +43 -0
  32. package/guidelines/conventions/rules/test.md +34 -0
  33. package/guidelines/conventions/rules/ts.md +95 -0
  34. package/guidelines/conventions/rules/tsx.md +75 -0
  35. package/guidelines/mcpRule/mcpRule.instruction.md +1 -1
  36. package/guidelines/pageRule/pageRule.instruction.md +4 -3
  37. package/guidelines/queryRule/queryRule.instruction.md +4 -0
  38. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +3 -3
  39. package/incrementalBuilder.proc.js +6 -6
  40. package/{index-pcwzkdqb.js → index-1p0qbq3m.js} +1 -1
  41. package/{index-xb8809yb.js → index-1shvxzt0.js} +3 -3
  42. package/{index-a58emady.js → index-266dewjs.js} +11 -11
  43. package/{index-bt438yxm.js → index-3yz30c07.js} +5 -4
  44. package/{index-xjf5j657.js → index-4mj92tsh.js} +952 -47
  45. package/index-4pdts00b.js +1604 -0
  46. package/{index-42j4a8zq.js → index-8559hsz4.js} +4 -3
  47. package/{index-wcej7g4z.js → index-8scw1pjk.js} +93 -23
  48. package/{index-a5dhqkdr.js → index-96wzdhfh.js} +74 -233
  49. package/index-9bv479q5.js +1 -0
  50. package/index-9rvcs76p.js +653 -0
  51. package/index-am36s3jh.js +3582 -0
  52. package/index-b8c289dx.js +444 -0
  53. package/{index-espk51ah.js → index-dd44g6vz.js} +3 -3
  54. package/{index-3wypz6xj.js → index-eja64h28.js} +7 -3
  55. package/index-fbewhg4g.js +590 -0
  56. package/index-jje9qzyq.js +27 -0
  57. package/{index-j9vyj3dj.js → index-k5jbcxyh.js} +3 -3
  58. package/{index-2mwc0g0d.js → index-ksfgqq1x.js} +1 -1
  59. package/index-m5n3ka0p.js +18 -0
  60. package/{index-5nd1wtkv.js → index-p6x5b7hr.js} +1 -1
  61. package/{index-6txx6a9p.js → index-payhwt51.js} +21 -29
  62. package/{index-2azahjaw.js → index-qkkdhjm6.js} +2 -2
  63. package/{index-74tjjsnc.js → index-qxzrp5xt.js} +33 -37
  64. package/{index-qfp55x1y.js → index-r0k3ham2.js} +4 -4
  65. package/{index-hmt54t45.js → index-r2w2eh93.js} +4 -4
  66. package/index-r2wedvqn.js +138 -0
  67. package/{index-skk9zc1x.js → index-rnphv731.js} +2 -2
  68. package/{index-9th4gszy.js → index-s6da8ta9.js} +82 -1227
  69. package/index-tenw3mah.js +225 -0
  70. package/{index-31es1yev.js → index-tgt2fnd6.js} +107 -6
  71. package/{index-55j120r8.js → index-vxmy1p4f.js} +16 -36
  72. package/{index-301pdbzz.js → index-w4k2ragk.js} +7 -7
  73. package/{index-js6geqjn.js → index-w7q6h97v.js} +1 -1
  74. package/{index-dy0jx9ay.js → index-wwe9rsrx.js} +14 -0
  75. package/{index-2xcc2ax5.js → index-xq543a5y.js} +2 -2
  76. package/{index-0fz95kxe.js → index-xqgwjz7a.js} +1 -1
  77. package/{index-40brg4px.js → index-xxfy1jp2.js} +4 -4
  78. package/{index-905qdgqp.js → index-z4b84y6k.js} +1 -1
  79. package/index-zcf6k8a5.js +410 -0
  80. package/index.js +23 -22
  81. package/{library.command-gycrwhf1.js → library.command-2853y6mk.js} +3 -3
  82. package/{localRegistry.command-jtd8gaes.js → localRegistry.command-76ds31p4.js} +19 -15
  83. package/{module.command-v6hgs1bc.js → module.command-yfnb0abs.js} +5 -5
  84. package/{package.command-shzpcfph.js → package.command-d9s86hp9.js} +3 -3
  85. package/package.json +2 -2
  86. package/{page.command-ptxn5kqk.js → page.command-6a8a8rd1.js} +3 -3
  87. package/{pipeline.command-zz31pgax.js → pipeline.command-rt3rwd2z.js} +2 -2
  88. package/{primitive.command-a1vse91z.js → primitive.command-emcebgrq.js} +6 -6
  89. package/{projectTypecheck-2ztky9cf.js → projectTypecheck-51m7eh1f.js} +1 -1
  90. package/{prompter-76k56b37.js → prompter-hgcta8pb.js} +1 -1
  91. package/quality.command-xtrk0n3x.js +76 -0
  92. package/{repair.command-cvazbz99.js → repair.command-51szxnxx.js} +5 -5
  93. package/{routeSourceValidator-6jd0q6r6.js → routeSourceValidator-4h947v7c.js} +13 -3
  94. package/{scalar.command-0acvyp26.js → scalar.command-8qv27t82.js} +4 -4
  95. package/skills/akan-agent/SKILL.md +36 -0
  96. package/skills/akan-code/SKILL.md +1 -0
  97. package/skills/akan-debug/SKILL.md +40 -6
  98. package/skills/akan-deps/SKILL.md +1 -2
  99. package/skills/akan-mcp/SKILL.md +40 -0
  100. package/skills/akan-page/SKILL.md +44 -0
  101. package/skills/akan-query/SKILL.md +38 -0
  102. package/skills/akan-runtime/SKILL.md +40 -0
  103. package/skills/akan-scaffold/SKILL.md +16 -6
  104. package/skills/akan-transport/SKILL.md +40 -0
  105. package/skills/akan-validate/SKILL.md +13 -11
  106. package/{subspace.command-822qx2bx.js → subspace.command-pn56pnh8.js} +8 -8
  107. package/templates/__scalar/__model__/__model__.constant.ts +3 -5
  108. package/templates/__scalar/__model__/__model__.dictionary.ts +6 -5
  109. package/templates/__scalar/__model__/__model__.document.ts +3 -3
  110. package/templates/app/akan.config.ts +2 -3
  111. package/templates/app/env/env.client.ts +2 -4
  112. package/templates/app/env/env.client.type.ts +2 -3
  113. package/templates/app/env/env.server.ts +2 -3
  114. package/templates/app/lib/___appName__/__appName__.dictionary.ts +1 -2
  115. package/templates/app/lib/___appName__/__appName__.service.ts +3 -3
  116. package/templates/app/lib/___appName__/__appName__.signal.ts +5 -5
  117. package/templates/app/lib/___appName__/__appName__.store.ts +4 -6
  118. package/templates/app/lib/option.ts +2 -3
  119. package/templates/app/main.ts +2 -4
  120. package/templates/app/page/_index.tsx +3 -3
  121. package/templates/app/page/_layout.tsx +13 -10
  122. package/templates/appSample/lib/__scalar/workHistory/workHistory.constant.ts +1 -5
  123. package/templates/appSample/lib/__scalar/workHistory/workHistory.dictionary.ts +1 -1
  124. package/templates/appSample/lib/_noti/noti.signal.ts +1 -1
  125. package/templates/appSample/lib/task/Task.Template.tsx +2 -1
  126. package/templates/appSample/lib/task/Task.Unit.tsx +3 -2
  127. package/templates/appSample/lib/task/Task.Util.tsx +16 -4
  128. package/templates/appSample/lib/task/task.constant.ts +1 -5
  129. package/templates/appSample/lib/task/task.dictionary.ts +2 -8
  130. package/templates/appSample/lib/task/task.document.ts +1 -1
  131. package/templates/appSample/page/task/_index.tsx +2 -1
  132. package/templates/appSample/page/task/new.tsx +2 -1
  133. package/templates/appSample/ui/QuantityControl.tsx +5 -9
  134. package/templates/biomeForm.ts +144 -0
  135. package/templates/crudPages/[__model__Id]/edit/page.tsx +3 -3
  136. package/templates/crudPages/[__model__Id]/page.tsx +5 -5
  137. package/templates/crudPages/new/page.tsx +4 -3
  138. package/templates/crudPages/page.tsx +3 -3
  139. package/templates/crudSinglePage/page.tsx +9 -5
  140. package/templates/libRoot/akan.config.ts +2 -3
  141. package/templates/libRoot/lib/___libName__/__libName__.dictionary.ts +1 -2
  142. package/templates/libRoot/lib/___libName__/__libName__.service.ts +5 -4
  143. package/templates/libRoot/lib/___libName__/__libName__.signal.ts +6 -5
  144. package/templates/libRoot/lib/___libName__/__libName__.store.ts +5 -6
  145. package/templates/libRoot/lib/option.ts +1 -2
  146. package/templates/module/__Model__.Template.tsx +11 -10
  147. package/templates/module/__Model__.Unit.tsx +18 -5
  148. package/templates/module/__Model__.Util.tsx +9 -7
  149. package/templates/module/__Model__.View.tsx +9 -6
  150. package/templates/module/__Model__.Zone.tsx +25 -17
  151. package/templates/module/__model__.constant.ts +8 -9
  152. package/templates/module/__model__.dictionary.ts +16 -17
  153. package/templates/module/__model__.document.ts +6 -8
  154. package/templates/module/__model__.service.ts +3 -3
  155. package/templates/module/__model__.signal.ts +11 -10
  156. package/templates/module/__model__.store.ts +3 -5
  157. package/templates/service/__model__.dictionary.ts +6 -5
  158. package/templates/service/__model__.service.ts +3 -3
  159. package/templates/service/__model__.signal.ts +5 -4
  160. package/templates/service/__model__.store.ts +3 -5
  161. package/templates/workspaceRoot/.gitignore.template +3 -0
  162. package/templates/workspaceRoot/.vscode/settings.json.template +21 -21
  163. package/templates/workspaceRoot/AGENTS.md.template +4 -10
  164. package/{tunnel.command-ycmja19q.js → tunnel.command-q2h0j2en.js} +7 -7
  165. package/{typeChecker-px49mezc.js → typeChecker-j2jdnqsr.js} +1 -1
  166. package/typecheck.proc.js +6 -1
  167. package/verify.command-z1dsbmrt.js +91 -0
  168. package/{workflow.command-abb1d5xy.js → workflow.command-r3y67jeq.js} +47 -13
  169. package/workspace.command-t2f0xsrw.js +263 -0
  170. package/CodeAgent-8d5qs787.js +0 -9
  171. package/TunnelShare-qkm8zp03.js +0 -14
  172. package/agent.command-ydftceda.js +0 -25
  173. package/cloud.script-nqevg5qw.js +0 -24
  174. package/context.runner-8gg030b0.js +0 -25
  175. package/guidelines/conventions/conventions.instruction.md +0 -617
  176. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +0 -291
  177. package/index-4vgbysa0.js +0 -279
  178. package/index-7md2g9vw.js +0 -6
  179. package/index-b70zct19.js +0 -856
  180. package/index-zzvvc845.js +0 -74
  181. package/quality.command-ah8qcakd.js +0 -1478
  182. package/templates/workspaceRoot/docs/AI-DEVELOPMENT.md.template +0 -69
  183. package/templates/workspaceRoot/docs/GENERATED.md.template +0 -55
  184. package/workspace.command-qm7cw29v.js +0 -521
@@ -0,0 +1,444 @@
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-8scw1pjk.js";
14
+ import {
15
+ WorkspaceRunner,
16
+ AkanQualityScanner
17
+ } from "./index-am36s3jh.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 #loadTypescript() {
30
+ VerifyComments.#typescriptLoad ??= import("typescript").then((mod) => mod.default ?? mod);
31
+ return VerifyComments.#typescriptLoad;
32
+ }
33
+ static async added(root, files) {
34
+ const code = files.filter((file) => VerifyComments.#codeFile.test(file) && existsSync(path.join(root, file)));
35
+ if (!code.length)
36
+ return [];
37
+ const changed = await VerifyComments.#addedLines(root, code);
38
+ if (!changed)
39
+ return [];
40
+ const typescript = await VerifyComments.#loadTypescript();
41
+ const diagnostics = [];
42
+ for (const file of code) {
43
+ const lines = changed.get(file);
44
+ if (lines?.size === 0)
45
+ continue;
46
+ const text = await Bun.file(path.join(root, file)).text();
47
+ for (const comment of VerifyComments.commentsOf(typescript, file, text)) {
48
+ if (VerifyComments.#directive.test(comment.text))
49
+ continue;
50
+ if (lines && !VerifyComments.#touches(comment, lines))
51
+ continue;
52
+ diagnostics.push({
53
+ step: "lint",
54
+ file,
55
+ line: comment.line,
56
+ col: comment.col,
57
+ code: VerifyComments.code,
58
+ severity: "warning",
59
+ message: VerifyComments.#excerpt(comment.text)
60
+ });
61
+ }
62
+ }
63
+ const [first] = diagnostics;
64
+ if (first)
65
+ first.fix = VerifyComments.fix;
66
+ return diagnostics;
67
+ }
68
+ static commentsOf(typescript, file, text) {
69
+ const kind = file.endsWith("x") ? typescript.ScriptKind.TSX : typescript.ScriptKind.TS;
70
+ const source = typescript.createSourceFile(file, text, typescript.ScriptTarget.Latest, true, kind);
71
+ const ranges = new Map;
72
+ const visit = (node) => {
73
+ if (node.kind === typescript.SyntaxKind.JsxText)
74
+ return;
75
+ if (node.kind >= typescript.SyntaxKind.FirstJSDocNode && node.kind <= typescript.SyntaxKind.LastJSDocNode)
76
+ return;
77
+ const children = node.getChildren(source);
78
+ for (const child of children)
79
+ visit(child);
80
+ if (children.length)
81
+ return;
82
+ const start = node.getFullStart();
83
+ for (const range of [
84
+ ...typescript.getTrailingCommentRanges(text, start) ?? [],
85
+ ...typescript.getLeadingCommentRanges(text, start) ?? []
86
+ ])
87
+ ranges.set(range.pos, range);
88
+ };
89
+ visit(source);
90
+ return [...ranges.values()].sort((a, b) => a.pos - b.pos).map((range) => {
91
+ const start = source.getLineAndCharacterOfPosition(range.pos);
92
+ const end = source.getLineAndCharacterOfPosition(range.end);
93
+ return {
94
+ text: text.slice(range.pos, range.end),
95
+ line: start.line + 1,
96
+ col: start.character + 1,
97
+ lastLine: end.line + 1
98
+ };
99
+ });
100
+ }
101
+ static #touches(comment, lines) {
102
+ for (let line = comment.line;line <= comment.lastLine; line++)
103
+ if (lines.has(line))
104
+ return true;
105
+ return false;
106
+ }
107
+ static #excerpt(comment) {
108
+ const first = comment.split(`
109
+ `).find((line) => line.replace(/^[\s/*]+/, "").trim()) ?? comment;
110
+ const flat = first.replace(/\s+/g, " ").trim();
111
+ return flat.length <= 60 ? flat : `${flat.slice(0, 59)}\u2026`;
112
+ }
113
+ static async#addedLines(root, files) {
114
+ const tracked = await VerifyComments.#git(root, ["ls-files", "-z", "--", ...files]);
115
+ const diff = await VerifyComments.#git(root, [
116
+ "-c",
117
+ "core.quotePath=false",
118
+ "diff",
119
+ "-U0",
120
+ "--no-color",
121
+ "--no-ext-diff",
122
+ "--relative",
123
+ "HEAD",
124
+ "--",
125
+ ...files
126
+ ]);
127
+ if (tracked === null || diff === null)
128
+ return null;
129
+ const trackedFiles = new Set(tracked.split("\x00").filter(Boolean));
130
+ const added = VerifyComments.parseDiff(diff);
131
+ return new Map(files.map((file) => [file, trackedFiles.has(file) ? added.get(file) ?? new Set : undefined]));
132
+ }
133
+ static parseDiff(diff) {
134
+ const added = new Map;
135
+ let current = null;
136
+ for (const line of diff.split(`
137
+ `)) {
138
+ if (line.startsWith("+++ ")) {
139
+ const file = line.slice(4).replace(/^b\//, "");
140
+ current = file === "/dev/null" ? null : new Set;
141
+ if (current)
142
+ added.set(file, current);
143
+ continue;
144
+ }
145
+ const [, from, length] = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) ?? [];
146
+ if (from === undefined || !current)
147
+ continue;
148
+ const start = Number(from);
149
+ const count = length === undefined ? 1 : Number(length);
150
+ for (let offset = 0;offset < count; offset++)
151
+ current.add(start + offset);
152
+ }
153
+ return added;
154
+ }
155
+ static async#git(root, args) {
156
+ const proc = Bun.spawn(["git", ...args], { cwd: root, stdout: "pipe", stderr: "ignore" });
157
+ const [stdout, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
158
+ return code === 0 ? stdout : null;
159
+ }
160
+ }
161
+
162
+ // pkgs/@akanjs/cli/verify/verifyPipeline.ts
163
+ import { existsSync as existsSync2 } from "fs";
164
+ import path2 from "path";
165
+
166
+ // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
167
+ class VerifyDiagnostics {
168
+ static fromTypecheck(records) {
169
+ return records.map((record) => ({
170
+ step: "typecheck",
171
+ file: record.file,
172
+ line: record.line,
173
+ col: record.col,
174
+ code: record.code,
175
+ severity: record.severity,
176
+ message: record.message.split(`
177
+ `)[0] ?? record.message
178
+ }));
179
+ }
180
+ static fromBiome(report) {
181
+ return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => ({
182
+ step: "lint",
183
+ file: diagnostic.location?.path?.replaceAll("\\", "/") ?? null,
184
+ line: diagnostic.location?.start?.line ?? 0,
185
+ col: diagnostic.location?.start?.column ?? 0,
186
+ code: diagnostic.category ?? "biome",
187
+ severity: diagnostic.severity === "error" ? "error" : "warning",
188
+ message: diagnostic.message
189
+ }));
190
+ }
191
+ static fromMaintainability(entries) {
192
+ return entries.map((entry) => ({
193
+ step: "lint",
194
+ file: entry.file,
195
+ line: entry.line,
196
+ col: 0,
197
+ code: entry.rule,
198
+ severity: "error",
199
+ message: entry.problem,
200
+ fix: entry.path ? `${entry.fix} Path: ${entry.path}` : entry.fix
201
+ }));
202
+ }
203
+ static fromQuality(warnings, changedFiles) {
204
+ return warnings.filter((warning) => warning.file && changedFiles.has(warning.file)).map((warning) => ({
205
+ step: "ssr",
206
+ file: warning.file ?? null,
207
+ line: warning.line ?? 0,
208
+ col: 0,
209
+ code: warning.rule,
210
+ severity: "warning",
211
+ message: warning.message,
212
+ ...warning.fix ? { fix: warning.fix } : {}
213
+ }));
214
+ }
215
+ static #prefix = /^\[([\w.-]+)\]\s*/;
216
+ static #location = /((?:apps|libs|pkgs)\/[^\s:()`'"]+\.[a-z]+)(?::(\d+)(?::(\d+))?)?/;
217
+ static fromMessage(step, message, code = `akan.${step}`) {
218
+ const prefix = VerifyDiagnostics.#prefix.exec(message);
219
+ const location = VerifyDiagnostics.#location.exec(message);
220
+ return {
221
+ step,
222
+ file: location ? location[1] ?? null : null,
223
+ line: Number(location?.[2] ?? 0),
224
+ col: Number(location?.[3] ?? 0),
225
+ code: prefix?.[1] ?? code,
226
+ severity: "error",
227
+ message: message.slice(prefix?.[0].length ?? 0).trim()
228
+ };
229
+ }
230
+ }
231
+
232
+ // pkgs/@akanjs/cli/verify/verifyPipeline.ts
233
+ class VerifyPipeline {
234
+ #workspace;
235
+ #workspaceRunner;
236
+ #applicationRunner;
237
+ #steps = new Map;
238
+ #diagnostics = [];
239
+ constructor(workspace, workspaceRunner, applicationRunner) {
240
+ this.#workspace = workspace;
241
+ this.#workspaceRunner = workspaceRunner;
242
+ this.#applicationRunner = applicationRunner;
243
+ }
244
+ get #root() {
245
+ return this.#workspace.workspaceRoot;
246
+ }
247
+ async run(scope, { lintOnly = false, build = true } = {}) {
248
+ const startedAt = performance.now();
249
+ const systems = scope.targets.filter((target) => target.type !== "pkg");
250
+ if (!lintOnly)
251
+ await this.#each("sync", systems, (target) => this.#sync(target));
252
+ const synced = !this.#failed("sync");
253
+ await Promise.all([
254
+ this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly })),
255
+ lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target))
256
+ ]);
257
+ const apps = scope.targets.filter((target) => target.type === "app");
258
+ const clean = !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error");
259
+ if (!lintOnly && build && apps.length) {
260
+ if (clean)
261
+ await this.#each("build", apps, (target) => this.#build(target));
262
+ else
263
+ this.#skip("build");
264
+ }
265
+ if (!lintOnly && scope.touchesTsx)
266
+ await this.#each("ssr", [null], () => this.#ssr(scope));
267
+ return {
268
+ ok: !this.#diagnostics.some((diagnostic) => diagnostic.severity === "error"),
269
+ targets: scope.targets.map((target) => target.name),
270
+ ms: Math.round(performance.now() - startedAt),
271
+ steps: [...this.#steps.values()],
272
+ diagnostics: this.#diagnostics
273
+ };
274
+ }
275
+ async#each(name, items, step) {
276
+ if (!items.length)
277
+ return;
278
+ const startedAt = performance.now();
279
+ let fixed = 0;
280
+ let failed = false;
281
+ for (const item of items) {
282
+ const outcome = await step(item).catch((error) => ({
283
+ diagnostics: [VerifyDiagnostics.fromMessage(name, ApplicationBuildReporter.formatError(error, this.#root))]
284
+ }));
285
+ fixed += outcome.fixed ?? 0;
286
+ failed ||= outcome.diagnostics.some((diagnostic) => diagnostic.severity === "error");
287
+ this.#diagnostics.push(...outcome.diagnostics);
288
+ }
289
+ const ms = Math.round(performance.now() - startedAt);
290
+ this.#steps.set(name, { name, status: failed ? "fail" : "pass", ms, fixed });
291
+ }
292
+ #skip(name) {
293
+ this.#steps.set(name, { name, status: "skip", ms: 0, fixed: 0 });
294
+ }
295
+ #failed(name) {
296
+ return this.#steps.get(name)?.status === "fail";
297
+ }
298
+ async#sync(target) {
299
+ if (target.type === "app")
300
+ await AppExecutor.from(this.#workspace, target.name).scanSync();
301
+ else
302
+ await LibExecutor.from(this.#workspace, target.name).scan();
303
+ return { diagnostics: [] };
304
+ }
305
+ async#lint(target, { comments }) {
306
+ const files = target.files.length ? target.files.filter((file) => existsSync2(path2.join(this.#root, file))) : [target.dir];
307
+ const biome = files.length ? await this.#biome(files) : { diagnostics: [], fixed: 0 };
308
+ const exec = this.#execOf(target);
309
+ const gates = await this.#workspaceRunner.lintGateFailures(exec, true);
310
+ const added = comments && target.files.length ? await VerifyComments.added(this.#root, target.files) : [];
311
+ return {
312
+ diagnostics: [
313
+ ...biome.diagnostics,
314
+ ...added,
315
+ ...gates.messages.map((message) => VerifyDiagnostics.fromMessage("lint", message, "akan.lint")),
316
+ ...VerifyDiagnostics.fromMaintainability(gates.maintainability)
317
+ ],
318
+ fixed: biome.fixed
319
+ };
320
+ }
321
+ async#biome(files) {
322
+ const configPath = await WorkspaceRunner.resolveBiomeConfigPath(this.#workspace);
323
+ const [biome, ...biomeArgs] = Linter.biomeCommand(this.#root);
324
+ const proc = Bun.spawn([
325
+ biome,
326
+ ...biomeArgs,
327
+ "check",
328
+ "--write",
329
+ "--reporter=json",
330
+ "--max-diagnostics=none",
331
+ "--no-errors-on-unmatched",
332
+ ...configPath ? ["--config-path", configPath] : [],
333
+ ...files
334
+ ], { cwd: this.#root, stdout: "pipe", stderr: "pipe" });
335
+ const [stdout, stderr] = await Promise.all([
336
+ new Response(proc.stdout).text(),
337
+ new Response(proc.stderr).text(),
338
+ proc.exited
339
+ ]);
340
+ try {
341
+ const report = parseBiomeReport(stdout);
342
+ return { diagnostics: VerifyDiagnostics.fromBiome(report), fixed: report.summary?.changed ?? 0 };
343
+ } catch {
344
+ return { diagnostics: [VerifyDiagnostics.fromMessage("lint", (stderr || stdout).trim(), "biome")] };
345
+ }
346
+ }
347
+ async#typecheck(target) {
348
+ try {
349
+ if (target.type === "app")
350
+ await this.#applicationRunner.typecheck(AppExecutor.from(this.#workspace, target.name), {
351
+ tests: true,
352
+ report: "records"
353
+ });
354
+ else if (target.type === "lib")
355
+ await this.#applicationRunner.typecheckLibrary(LibExecutor.from(this.#workspace, target.name), {
356
+ tests: true,
357
+ report: "records"
358
+ });
359
+ else {
360
+ const tsconfigPath = path2.join(this.#root, target.dir, "tsconfig.json");
361
+ if (!existsSync2(tsconfigPath))
362
+ return { diagnostics: [] };
363
+ await new ProjectTypecheck2(path2.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
364
+ }
365
+ return { diagnostics: [] };
366
+ } catch (error) {
367
+ if (error instanceof TypecheckFailure)
368
+ return { diagnostics: VerifyDiagnostics.fromTypecheck(error.records) };
369
+ throw error;
370
+ }
371
+ }
372
+ async#build(target) {
373
+ await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
374
+ return { diagnostics: [] };
375
+ }
376
+ async#ssr(scope) {
377
+ const scanned = await new AkanQualityScanner().scan(this.#root);
378
+ const warnings = scanned.warnings.filter((warning) => warning.scope === "ssr");
379
+ return { diagnostics: VerifyDiagnostics.fromQuality(warnings, scope.changedFiles) };
380
+ }
381
+ #execOf(target) {
382
+ if (target.type === "app")
383
+ return AppExecutor.from(this.#workspace, target.name);
384
+ if (target.type === "lib")
385
+ return LibExecutor.from(this.#workspace, target.name);
386
+ return PkgExecutor.from(this.#workspace, target.name);
387
+ }
388
+ }
389
+
390
+ // pkgs/@akanjs/cli/verify/verifyReport.ts
391
+ class VerifyReport {
392
+ static lineMax = 280;
393
+ static defaultMax = 20;
394
+ static text(result, { max = VerifyReport.defaultMax } = {}) {
395
+ if (!result.targets.length)
396
+ return "verify ok \xB7 nothing changed under apps/, libs/ or pkgs/";
397
+ const lines = [VerifyReport.#header(result), ...VerifyReport.#diagnosticLines(result.diagnostics, max)];
398
+ return lines.join(`
399
+ `);
400
+ }
401
+ static json(result) {
402
+ return JSON.stringify(result);
403
+ }
404
+ static #header(result) {
405
+ const ran = result.steps.filter((step) => step.name !== "sync" || step.status === "fail");
406
+ const fixed = result.steps.reduce((sum, step) => sum + step.fixed, 0);
407
+ const seconds = `${(result.ms / 1000).toFixed(1)}s`;
408
+ const fixedNote = fixed ? `fixed ${fixed} file${fixed === 1 ? "" : "s"}` : null;
409
+ 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 ");
410
+ return [`verify ${result.ok ? "ok" : "fail"}`, result.targets.join(", "), steps, fixedNote, seconds].filter(Boolean).join(" \xB7 ");
411
+ }
412
+ static #stepLabel(step, diagnostics) {
413
+ if (step.status === "skip")
414
+ return `${step.name} skipped`;
415
+ if (step.status === "pass")
416
+ return `${step.name} ok`;
417
+ const errors = diagnostics.filter((entry) => entry.step === step.name && entry.severity === "error").length;
418
+ return `${step.name} ${errors} error${errors === 1 ? "" : "s"}`;
419
+ }
420
+ static #diagnosticLines(diagnostics, max) {
421
+ const groups = new Map;
422
+ const ordered = [...diagnostics].sort((a, b) => Number(a.severity === "warning") - Number(b.severity === "warning"));
423
+ for (const diagnostic of ordered) {
424
+ const key = `${diagnostic.code}\x00${diagnostic.message}`;
425
+ groups.set(key, [...groups.get(key) ?? [], diagnostic]);
426
+ }
427
+ const lines = [...groups.values()].map((group) => VerifyReport.#lineOf(group));
428
+ if (max <= 0 || lines.length <= max)
429
+ return lines;
430
+ return [...lines.slice(0, max), `+${lines.length - max} more \xB7 akan verify --max 0`];
431
+ }
432
+ static #lineOf([first, ...rest]) {
433
+ if (!first)
434
+ return "";
435
+ const where = first.file ? `${first.file}${first.line ? `:${first.line}${first.col ? `:${first.col}` : ""}` : ""}` : "-";
436
+ 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}` : ""})` : "";
437
+ const fix = first.fix ? ` fix: ${first.fix}` : "";
438
+ const warning = first.severity === "warning" ? " warning" : "";
439
+ const line = `${where}${others}${warning} ${first.code} ${first.message}${fix}`.replace(/\s+/g, " ").trim();
440
+ return line.length <= VerifyReport.lineMax ? line : `${line.slice(0, VerifyReport.lineMax - 1)}\u2026`;
441
+ }
442
+ }
443
+
444
+ export { VerifyComments, VerifyPipeline, VerifyReport };
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  SOURCE_EXTS,
7
7
  WatchRootResolver
8
- } from "./index-5nd1wtkv.js";
8
+ } from "./index-p6x5b7hr.js";
9
9
  import {
10
10
  bundleDefine,
11
11
  CsrEntryFiles,
@@ -19,11 +19,11 @@ import {
19
19
  CsrDevPaths,
20
20
  PagesEntrySourceGenerator,
21
21
  PagesBundleBuilder
22
- } from "./index-0fz95kxe.js";
22
+ } from "./index-xqgwjz7a.js";
23
23
  import {
24
24
  AsyncDefaultExportDetector,
25
25
  resolveSsrPageEntriesForApp
26
- } from "./index-wcej7g4z.js";
26
+ } from "./index-8scw1pjk.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/frontendBuild/autoImportSync.ts
29
29
  import { readdir, readFile, stat } from "fs/promises";
@@ -10,7 +10,7 @@ import {
10
10
  LibExecutor,
11
11
  PkgExecutor,
12
12
  ModuleExecutor
13
- } from "./index-wcej7g4z.js";
13
+ } from "./index-8scw1pjk.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
 
@@ -853,4 +857,4 @@ function command(refName, depsOrBuilder, builder) {
853
857
  }
854
858
  return CommandBase;
855
859
  }
856
- export { getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };
860
+ export { camelToKebabCase, getTargetMetas, getTargetCommandNames, App, Apps, Lib, Sys, SysOrOnlyApp, Exec, Pkg, Module, Workspace, CommandContainer, runner, script, ExitCodeError, markCliErrorPrinted, assertPromptable, runCommands, command };