@akanjs/cli 3.1.2-rc.3 → 3.2.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-n2tkg59z.js → CodeAgent-h6g8dg3a.js} +2 -2
  3. package/{CodeTui-9wsdx7ap.js → CodeTui-n9gacepn.js} +1 -1
  4. package/README.ko.md +9 -0
  5. package/README.md +9 -0
  6. package/TunnelShare-k3ja4w9x.js +14 -0
  7. package/{agent.command-tffz6wdn.js → agent.command-2f657613.js} +19 -17
  8. package/akanCode.js +2 -2
  9. package/{application.command-7bkxbrsp.js → application.command-yb8v177e.js} +45 -22
  10. package/{applicationBuildRunner-s13x3zqb.js → applicationBuildRunner-sctcmkyx.js} +57 -17
  11. package/buildBatch.proc.js +7 -7
  12. package/{cloud.command-a792bc10.js → cloud.command-et06ja22.js} +35 -18
  13. package/cloud.script-s6rbrwer.js +30 -0
  14. package/{code.command-ma8dtzww.js → code.command-7m67c7zc.js} +6 -6
  15. package/commandManifest.json +1 -1
  16. package/{context.command-80a1qhps.js → context.command-569z0rqf.js} +20 -19
  17. package/context.runner-ms8v1rxy.js +29 -0
  18. package/{guideline.command-195g0h9a.js → guideline.command-gnv3e8p8.js} +2 -2
  19. package/guidelines/akanApi/akanApi.instruction.md +317 -0
  20. package/guidelines/conventions/rules/app.md +5 -5
  21. package/guidelines/conventions/rules/config.md +1 -1
  22. package/guidelines/conventions/rules/gates.md +10 -5
  23. package/guidelines/conventions/rules/page.md +4 -2
  24. package/guidelines/conventions/rules/server.md +2 -0
  25. package/guidelines/conventions/rules/style.md +3 -1
  26. package/guidelines/conventions/rules/ts.md +2 -1
  27. package/guidelines/cssRule/cssRule.instruction.md +3 -1
  28. package/guidelines/pageRule/pageRule.instruction.md +3 -0
  29. package/incrementalBuilder.proc.js +70 -14
  30. package/{index-tns543wd.js → index-0fb3cpbt.js} +3 -3
  31. package/{index-zbrwnmf1.js → index-1q1cjn8s.js} +21 -11
  32. package/{index-wrmq92vk.js → index-3wjbhj2n.js} +1 -1
  33. package/{index-361ex3rb.js → index-48d5qsj3.js} +4 -4
  34. package/{index-aayg4dqf.js → index-5w9my9qe.js} +8 -8
  35. package/{index-1h2jc0x3.js → index-6wpaq392.js} +61 -15
  36. package/{index-tp56652m.js → index-7xdpww43.js} +69 -12
  37. package/index-7y5yghjg.js +2969 -0
  38. package/{index-zttm13c3.js → index-8g7tdsk4.js} +249 -696
  39. package/{index-m02tdq8a.js → index-8pb9yvp8.js} +63 -21
  40. package/{index-gbp1q1b5.js → index-8ts9774g.js} +4 -4
  41. package/{index-9zy8479y.js → index-93ewzmp6.js} +43 -14
  42. package/{index-zdpte1pj.js → index-9tbgb4d8.js} +1 -1
  43. package/index-abgh0jve.js +126 -0
  44. package/{index-khk05tsf.js → index-aj3ehkcx.js} +1 -1
  45. package/{index-84h43kg6.js → index-d4n1wmrz.js} +37 -4
  46. package/{index-gr9thy79.js → index-drz9e84d.js} +22 -8
  47. package/{index-hapx5myy.js → index-e3vmjtph.js} +2 -2
  48. package/{index-k64mhwbw.js → index-eajbmk10.js} +2 -1
  49. package/{index-0j1t1h2b.js → index-ed6ea0qp.js} +1 -1
  50. package/{index-sjabnf7j.js → index-fjr4d6yd.js} +444 -368
  51. package/index-hqrkqxx2.js +176 -0
  52. package/{index-z7kbxdqg.js → index-jdamtr7e.js} +3 -3
  53. package/{index-scck6h6d.js → index-kpdv34rq.js} +4 -4
  54. package/{index-ppvqy5bc.js → index-ktb3wcqz.js} +73 -34
  55. package/{index-sveq36gh.js → index-mmym5xmb.js} +4 -2
  56. package/{index-y4kcmbt2.js → index-mqntfzv5.js} +2 -2
  57. package/{index-4am4dvmf.js → index-ny2k80mv.js} +15 -3
  58. package/index-p6hjwt2d.js +1668 -0
  59. package/{index-wwe9rsrx.js → index-r0a604h4.js} +12 -2
  60. package/{index-jb2sreps.js → index-rc5fvqj2.js} +18 -18
  61. package/{index-db2nqrad.js → index-ryrm5z2c.js} +71 -19
  62. package/{index-eft5c2mp.js → index-s2grpzef.js} +331 -27
  63. package/{index-g500c5j9.js → index-sr5da35e.js} +33 -10
  64. package/{index-defp4gmb.js → index-sy481q2x.js} +1 -1
  65. package/{index-j9d3mjx1.js → index-thckcabc.js} +2 -2
  66. package/{index-9z3egsmg.js → index-vkzfk7qt.js} +25 -23
  67. package/index-w639tvkd.js +166 -0
  68. package/index-ygdbn9jn.js +122 -0
  69. package/{index-sp0qsr7a.js → index-zpv14wpy.js} +3 -3
  70. package/{index-sx91nf4z.js → index-zxsygkda.js} +18 -9
  71. package/index.js +24 -23
  72. package/{library.command-63hgt9te.js → library.command-1gp5qe3r.js} +3 -3
  73. package/{localRegistry.command-343ksmn9.js → localRegistry.command-v3g21rex.js} +25 -16
  74. package/{module.command-2hce9m6k.js → module.command-4xz9he6h.js} +6 -6
  75. package/{package.command-96eheyvd.js → package.command-s7qpnn1g.js} +12 -3
  76. package/package.json +2 -2
  77. package/{page.command-gs6d841d.js → page.command-fan34c49.js} +3 -3
  78. package/{pipeline.command-wdfvdbfj.js → pipeline.command-ph4fnn9w.js} +2 -2
  79. package/{primitive.command-7tdj12wn.js → primitive.command-3fqh8emf.js} +7 -7
  80. package/{projectTypecheck-kqj1t6hb.js → projectTypecheck-vkb40hjc.js} +1 -1
  81. package/{quality.command-29bgarh1.js → quality.command-ecj6exsh.js} +15 -10
  82. package/{repair.command-yng4rf5d.js → repair.command-fe9jw719.js} +6 -6
  83. package/{scalar.command-1nk4329t.js → scalar.command-cnvfhk0n.js} +5 -5
  84. package/skills/akan-debug/SKILL.md +2 -1
  85. package/skills/akan-page/SKILL.md +30 -2
  86. package/skills/akan-service/SKILL.md +77 -1
  87. package/{subspace.command-5cehmcdd.js → subspace.command-yxtt3v3e.js} +8 -8
  88. package/templates/app/lib/___appName__/__appName__.abstract.md.template +6 -0
  89. package/templates/app/page/_index.tsx +4 -284
  90. package/templates/app/page/_layout.tsx +1 -26
  91. package/templates/app/page/styles.css.template +58 -318
  92. package/templates/appSample/page/_index.tsx +281 -0
  93. package/templates/appSample/page/_layout.tsx +55 -0
  94. package/templates/appSample/page/styles.css.template +327 -0
  95. package/templates/libRoot/lib/___libName__/__libName__.abstract.md.template +6 -0
  96. package/templates/workspaceRoot/package.json.template +1 -12
  97. package/{tunnel.command-yrd4atqy.js → tunnel.command-ggj38mqf.js} +7 -7
  98. package/{typeChecker-j2jdnqsr.js → typeChecker-s640r6c0.js} +1 -1
  99. package/typecheck.proc.js +1 -1
  100. package/{verify.command-kbq0fcg8.js → verify.command-w9ttxkdz.js} +16 -14
  101. package/{workflow.command-274qfa8z.js → workflow.command-ss8devj0.js} +12 -12
  102. package/{workspace.command-r6hgmawy.js → workspace.command-rw1p0xeq.js} +50 -38
  103. package/TunnelShare-6d7z36sr.js +0 -14
  104. package/cloud.script-t2n13gv6.js +0 -27
  105. package/context.runner-wxqb3qcy.js +0 -28
  106. package/index-j2dgmzbj.js +0 -1259
  107. package/index-p6x5b7hr.js +0 -839
  108. package/index-vzpnr12w.js +0 -65
  109. package/templates/workspaceRoot/patches/zod@3.25.76.patch.template +0 -22
  110. package/templates/workspaceRoot/patches/zod@4.4.3.patch.template +0 -11
  111. /package/templates/{app → appSample}/page/_overrides.tsx +0 -0
  112. /package/templates/{app → appSample}/public/fonts/Pretendard-Black.woff2 +0 -0
  113. /package/templates/{app → appSample}/public/fonts/Pretendard-Bold.woff2 +0 -0
  114. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraBold.woff2 +0 -0
  115. /package/templates/{app → appSample}/public/fonts/Pretendard-ExtraLight.woff2 +0 -0
  116. /package/templates/{app → appSample}/public/fonts/Pretendard-Light.woff2 +0 -0
  117. /package/templates/{app → appSample}/public/fonts/Pretendard-Medium.woff2 +0 -0
  118. /package/templates/{app → appSample}/public/fonts/Pretendard-Regular.woff2 +0 -0
  119. /package/templates/{app → appSample}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
  120. /package/templates/{app → appSample}/public/fonts/Pretendard-Thin.woff2 +0 -0
  121. /package/templates/{app → appSample}/public/jelly/cloud.webp +0 -0
  122. /package/templates/{app → appSample}/public/jelly/comet.webp +0 -0
  123. /package/templates/{app → appSample}/public/jelly/moon.webp +0 -0
  124. /package/templates/{app → appSample}/public/jelly/planet.webp +0 -0
  125. /package/templates/{app → appSample}/public/jelly/rocket.webp +0 -0
  126. /package/templates/{app → appSample}/public/jelly/star.webp +0 -0
  127. /package/templates/{app → appSample}/public/jelly/sugar.webp +0 -0
  128. /package/templates/{app → appSample}/public/logo.png +0 -0
  129. /package/templates/{app → appSample}/ui/Recipe/index.ts +0 -0
  130. /package/templates/{app → appSample}/ui/Recipe/jellyButton.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ApplicationBuildReporter
4
- } from "./index-p6x5b7hr.js";
4
+ } from "./index-p6hjwt2d.js";
5
5
  import {
6
6
  parseBiomeReport,
7
7
  Linter,
@@ -10,11 +10,11 @@ import {
10
10
  AppExecutor,
11
11
  LibExecutor,
12
12
  PkgExecutor
13
- } from "./index-g500c5j9.js";
13
+ } from "./index-sr5da35e.js";
14
14
  import {
15
15
  WorkspaceRunner,
16
16
  AkanQualityScanner
17
- } from "./index-sjabnf7j.js";
17
+ } from "./index-fjr4d6yd.js";
18
18
 
19
19
  // pkgs/@akanjs/cli/verify/verifyComments.ts
20
20
  import { existsSync } from "fs";
@@ -184,10 +184,13 @@ class VerifyComments {
184
184
  }
185
185
 
186
186
  // pkgs/@akanjs/cli/verify/verifyPipeline.ts
187
- import { existsSync as existsSync2 } from "fs";
188
- import path2 from "path";
187
+ import { existsSync as existsSync4 } from "fs";
188
+ import path5 from "path";
189
189
 
190
190
  // pkgs/@akanjs/cli/verify/verifyDiagnostics.ts
191
+ import { readFileSync } from "fs";
192
+ import path2 from "path";
193
+
191
194
  class VerifyDiagnostics {
192
195
  static fromTypecheck(records) {
193
196
  return records.map((record) => {
@@ -220,16 +223,60 @@ class VerifyDiagnostics {
220
223
  fix: `check the spelling, or add ${key}: [en, ko] to .translate({}) in ${dictionaryFile}; one-off text takes l.trans({ en, ko })`
221
224
  };
222
225
  }
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
- }));
226
+ static fromBiome(report, root) {
227
+ return (report.diagnostics ?? []).filter((diagnostic) => diagnostic.severity === "error" || diagnostic.severity === "warning").map((diagnostic) => {
228
+ const file = diagnostic.location?.path?.replaceAll("\\", "/") ?? null;
229
+ return {
230
+ step: "lint",
231
+ file,
232
+ line: diagnostic.location?.start?.line ?? 0,
233
+ col: diagnostic.location?.start?.column ?? 0,
234
+ code: diagnostic.category ?? "biome",
235
+ severity: diagnostic.severity === "error" ? "error" : "warning",
236
+ ...VerifyDiagnostics.#adapterErrorOf(file, diagnostic.message) ?? VerifyDiagnostics.#deepImportOf(root, file, diagnostic) ?? { message: diagnostic.message }
237
+ };
238
+ });
239
+ }
240
+ static #deepImport = /^Module files should not import from two or more parent directories/;
241
+ static #deepSpecifier = /["'](\.\.\/\.\.\/[^"']*)["']/g;
242
+ static #layerOf = /^(apps|libs)\/([\w-]+)\/(common|srvkit|webkit|ui)(?:\/|$)/;
243
+ static #deepImportOf(root, file, diagnostic) {
244
+ const start = diagnostic.location?.start;
245
+ if (!root || !file || !start || !VerifyDiagnostics.#deepImport.test(diagnostic.message))
246
+ return null;
247
+ let line;
248
+ try {
249
+ line = readFileSync(path2.join(root, file), "utf8").split(`
250
+ `)[start.line - 1] ?? "";
251
+ } catch {
252
+ return null;
253
+ }
254
+ const specifiers = [...line.matchAll(VerifyDiagnostics.#deepSpecifier)];
255
+ const specifier = (specifiers.find((match) => match.index === start.column - 1) ?? specifiers[0])?.[1];
256
+ if (!specifier)
257
+ return null;
258
+ const target = path2.posix.join(path2.posix.dirname(file), specifier);
259
+ const [, kind, name, layer] = target.match(VerifyDiagnostics.#layerOf) ?? [];
260
+ if (!kind || !name || !layer)
261
+ return null;
262
+ const barrel = `@${kind}/${name}/${layer}`;
263
+ return {
264
+ message: `Module files should not reach ${barrel} through two or more parent directories.`,
265
+ fix: `import from "${barrel}"`
266
+ };
267
+ }
268
+ static #rawError = /^Do not (throw|construct) a raw `Error`/;
269
+ static #srvkitFile = /^((?:apps|libs)\/([\w-]+))\/srvkit\//;
270
+ static #adapterErrorOf(file, message) {
271
+ const [, verb] = message.match(VerifyDiagnostics.#rawError) ?? [];
272
+ const [, root, name] = file?.match(VerifyDiagnostics.#srvkitFile) ?? [];
273
+ if (!file || !verb || !root || !name)
274
+ return null;
275
+ const dict = path2.posix.relative(path2.posix.dirname(file), `${root}/lib/dict`);
276
+ return {
277
+ message: `Do not ${verb} a raw \`Error\`: an srvkit adapter uses \`Err\` with a key of the ${name} dictionary`,
278
+ fix: `import { Err } from "${dict}"; add <key>: [en, ko] to .error({}) in ${root}/lib/_${name}/${name}.dictionary.ts; ${verb === "throw" ? "throw " : ""}new Err("${name}.error.<key>")`
279
+ };
233
280
  }
234
281
  static fromMaintainability(entries) {
235
282
  return entries.map((entry) => ({
@@ -255,6 +302,9 @@ class VerifyDiagnostics {
255
302
  ...warning.fix ? { fix: warning.fix } : {}
256
303
  }));
257
304
  }
305
+ static fromRouteJsBudget({ file, message, fix }) {
306
+ return { step: "build", file, line: 0, col: 0, code: "akan.budget", severity: "warning", message, fix };
307
+ }
258
308
  static #prefix = /^\[([\w.-]+)\]\s*/;
259
309
  static #location = /((?:apps|libs|pkgs)\/[^\s:()`'"]+\.[a-z]+)(?::(\d+)(?::(\d+))?)?/;
260
310
  static fromMessage(step, message, code = `akan.${step}`) {
@@ -272,6 +322,240 @@ class VerifyDiagnostics {
272
322
  }
273
323
  }
274
324
 
325
+ // pkgs/@akanjs/cli/verify/verifyPrivateMethods.ts
326
+ import { existsSync as existsSync2 } from "fs";
327
+ import path3 from "path";
328
+
329
+ class VerifyPrivateMethods {
330
+ static #moduleFile = /^(?:apps|libs)\/.+\.(?:constant|document|service|store)\.ts$/;
331
+ static #ignoredDirs = new Set(["node_modules", "dist", ".akan", "dump", "local"]);
332
+ static #typescriptLoad;
333
+ static #loadTypescript() {
334
+ VerifyPrivateMethods.#typescriptLoad ??= import("typescript").then((mod) => mod.default ?? mod);
335
+ return VerifyPrivateMethods.#typescriptLoad;
336
+ }
337
+ static async fix(root, dir, files) {
338
+ const candidates = (files.length ? files : await VerifyPrivateMethods.#moduleFilesIn(root, dir)).filter((file) => VerifyPrivateMethods.#moduleFile.test(file) && !VerifyPrivateMethods.#isIgnored(file) && existsSync2(path3.join(root, file)));
339
+ const rewritten = new Map;
340
+ for (const file of candidates) {
341
+ const absolute = path3.join(root, file);
342
+ const text = await Bun.file(absolute).text();
343
+ if (!text.includes("#"))
344
+ continue;
345
+ const typescript = await VerifyPrivateMethods.#loadTypescript();
346
+ if (!VerifyPrivateMethods.rewrite(typescript, file, text).renamed.length)
347
+ continue;
348
+ const beside = await VerifyPrivateMethods.#namesBeside(typescript, root, file);
349
+ const result = VerifyPrivateMethods.rewrite(typescript, file, text, beside);
350
+ if (!result.renamed.length)
351
+ continue;
352
+ await Bun.write(absolute, result.text);
353
+ rewritten.set(file, result.text);
354
+ }
355
+ return rewritten;
356
+ }
357
+ static async#moduleFilesIn(root, dir) {
358
+ if (!existsSync2(path3.join(root, dir)))
359
+ return [];
360
+ const files = [];
361
+ for await (const file of new Bun.Glob("**/*.{constant,document,service,store}.ts").scan({
362
+ cwd: path3.join(root, dir)
363
+ }))
364
+ files.push(path3.posix.join(dir, file.replaceAll("\\", "/")));
365
+ return files;
366
+ }
367
+ static #isIgnored(file) {
368
+ return file.split("/").some((segment) => VerifyPrivateMethods.#ignoredDirs.has(segment));
369
+ }
370
+ static async#namesBeside(typescript, root, file) {
371
+ const base = path3.posix.basename(file);
372
+ const pattern = base.endsWith(".store.ts") ? "{apps,libs}/**/*.store.ts" : `{apps,libs}/**/${base}`;
373
+ const names = new Set;
374
+ for await (const found of new Bun.Glob(pattern).scan({ cwd: root })) {
375
+ const other = found.replaceAll("\\", "/");
376
+ if (other === file || VerifyPrivateMethods.#isIgnored(other))
377
+ continue;
378
+ const text = await Bun.file(path3.join(root, other)).text();
379
+ const source = typescript.createSourceFile(other, text, typescript.ScriptTarget.Latest, false);
380
+ const visit = (node) => {
381
+ if (typescript.isClassLike(node)) {
382
+ for (const { name } of node.members)
383
+ if (name && (typescript.isIdentifier(name) || typescript.isPrivateIdentifier(name)))
384
+ names.add(name.text.replace(/^#/, ""));
385
+ }
386
+ typescript.forEachChild(node, visit);
387
+ };
388
+ visit(source);
389
+ }
390
+ return names;
391
+ }
392
+ static rewrite(typescript, fileName, text, beside = new Set) {
393
+ const source = typescript.createSourceFile(fileName, text, typescript.ScriptTarget.Latest, true, typescript.ScriptKind.TS);
394
+ const edits = [];
395
+ const renamed = [];
396
+ const visit = (node) => {
397
+ if (typescript.isClassLike(node))
398
+ renamed.push(...VerifyPrivateMethods.#renameIn(typescript, source, node, edits, beside));
399
+ typescript.forEachChild(node, visit);
400
+ };
401
+ visit(source);
402
+ if (!edits.length)
403
+ return { text, renamed };
404
+ const ordered = [...edits].sort((left, right) => right.start - left.start || right.end - left.end);
405
+ let rewritten = text;
406
+ for (const edit of ordered)
407
+ rewritten = rewritten.slice(0, edit.start) + edit.text + rewritten.slice(edit.end);
408
+ return { text: rewritten, renamed };
409
+ }
410
+ static #renameIn(typescript, source, cls, edits, beside) {
411
+ const methods = new Map;
412
+ const taken = new Set(beside);
413
+ for (const member of cls.members) {
414
+ if (typescript.isConstructorDeclaration(member)) {
415
+ for (const parameter of member.parameters)
416
+ if (typescript.getModifiers(parameter)?.length && typescript.isIdentifier(parameter.name))
417
+ taken.add(parameter.name.text);
418
+ }
419
+ const name = member.name;
420
+ if (!name)
421
+ continue;
422
+ if (typescript.isPrivateIdentifier(name)) {
423
+ if (typescript.isMethodDeclaration(member))
424
+ methods.set(name.text, [...methods.get(name.text) ?? [], member]);
425
+ } else if (typescript.isIdentifier(name) || typescript.isStringLiteral(name))
426
+ taken.add(name.text);
427
+ }
428
+ if (!methods.size)
429
+ return [];
430
+ const references = new Map;
431
+ const brandChecked = new Set;
432
+ const collect = (node, shadowed) => {
433
+ let inScope = shadowed;
434
+ if (node !== cls && typescript.isClassLike(node)) {
435
+ const own = node.members.flatMap((member) => member.name && typescript.isPrivateIdentifier(member.name) ? [member.name.text] : []);
436
+ if (own.length)
437
+ inScope = new Set([...shadowed, ...own]);
438
+ }
439
+ if (typescript.isPrivateIdentifier(node) && !inScope.has(node.text)) {
440
+ const parent = node.parent;
441
+ if (typescript.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === typescript.SyntaxKind.InKeyword)
442
+ brandChecked.add(node.text);
443
+ else if (typescript.isPropertyAccessExpression(parent) && parent.name === node)
444
+ references.set(node.text, [...references.get(node.text) ?? [], node]);
445
+ }
446
+ typescript.forEachChild(node, (child) => collect(child, inScope));
447
+ };
448
+ for (const member of cls.members)
449
+ collect(member, new Set);
450
+ const renamed = [];
451
+ for (const [privateName, declarations] of methods) {
452
+ const bare = privateName.slice(1);
453
+ if (taken.has(bare) || brandChecked.has(privateName))
454
+ continue;
455
+ for (const declaration of declarations) {
456
+ const firstModifier = typescript.getModifiers(declaration)?.[0];
457
+ const insertAt = (firstModifier ?? declaration.asteriskToken ?? declaration.name).getStart(source);
458
+ edits.push({ start: insertAt, end: insertAt, text: "private " });
459
+ edits.push({ start: declaration.name.getStart(source), end: declaration.name.getEnd(), text: bare });
460
+ }
461
+ for (const reference of references.get(privateName) ?? [])
462
+ edits.push({ start: reference.getStart(source), end: reference.getEnd(), text: bare });
463
+ renamed.push(privateName);
464
+ }
465
+ return renamed;
466
+ }
467
+ }
468
+
469
+ // pkgs/@akanjs/cli/verify/verifyStyleClasses.ts
470
+ import { existsSync as existsSync3 } from "fs";
471
+ import path4 from "path";
472
+
473
+ class VerifyStyleClasses {
474
+ static #message = "daisyUI legacy class";
475
+ static #grit = "node_modules/@akanjs/devkit/lint/no-daisyui-legacy-class.grit";
476
+ static #comment = /\/\*[\s\S]*?\*\//g;
477
+ static #classSelector = /\.((?:\\.|[\w-])+)/g;
478
+ static #utility = /@utility\s+([\w-]+)/g;
479
+ static #tokenSeparator = /[\s"'`{}()[\],]+/;
480
+ static legacyPatternOf(gritSource) {
481
+ const at = gritSource.indexOf(`message = "${VerifyStyleClasses.#message}`);
482
+ const open = at === -1 ? -1 : gritSource.lastIndexOf('r"', at);
483
+ if (open === -1)
484
+ return null;
485
+ let close = open + 2;
486
+ while (close < at && !(gritSource[close] === '"' && gritSource[close - 1] !== "\\"))
487
+ close += 1;
488
+ if (close >= at)
489
+ return null;
490
+ try {
491
+ return new RegExp(gritSource.slice(open + 2, close));
492
+ } catch {
493
+ return null;
494
+ }
495
+ }
496
+ static classesDefinedIn(css) {
497
+ const text = css.replace(VerifyStyleClasses.#comment, "");
498
+ const names = new Set;
499
+ for (const [, name] of text.matchAll(VerifyStyleClasses.#classSelector))
500
+ if (name)
501
+ names.add(name.replaceAll("\\", ""));
502
+ for (const [, name] of text.matchAll(VerifyStyleClasses.#utility))
503
+ if (name)
504
+ names.add(name);
505
+ return names;
506
+ }
507
+ static async dropDefined(root, diagnostics, cssDirs) {
508
+ const flagged = diagnostics.filter((diagnostic) => diagnostic.severity === "warning" && diagnostic.message.startsWith(VerifyStyleClasses.#message));
509
+ if (!flagged.length || !existsSync3(path4.join(root, VerifyStyleClasses.#grit)))
510
+ return diagnostics;
511
+ const pattern = VerifyStyleClasses.legacyPatternOf(await Bun.file(path4.join(root, VerifyStyleClasses.#grit)).text());
512
+ if (!pattern)
513
+ return diagnostics;
514
+ const defined = await VerifyStyleClasses.#definedClasses(root, cssDirs);
515
+ if (!defined.size)
516
+ return diagnostics;
517
+ const sources = new Map;
518
+ const dropped = new Set;
519
+ for (const diagnostic of flagged) {
520
+ const file = diagnostic.location?.path;
521
+ const { start, end } = diagnostic.location ?? {};
522
+ if (!file || !start?.line || !end?.line)
523
+ continue;
524
+ const absolute = path4.resolve(root, file);
525
+ if (!sources.has(absolute))
526
+ sources.set(absolute, existsSync3(absolute) ? (await Bun.file(absolute).text()).split(`
527
+ `) : []);
528
+ const span = VerifyStyleClasses.#linesOf(sources.get(absolute) ?? [], start.line, end.line);
529
+ const legacy = span.split(VerifyStyleClasses.#tokenSeparator).filter((token) => token && pattern.test(token));
530
+ if (legacy.length && legacy.every((token) => defined.has(VerifyStyleClasses.#classNameOf(token))))
531
+ dropped.add(diagnostic);
532
+ }
533
+ return dropped.size ? diagnostics.filter((diagnostic) => !dropped.has(diagnostic)) : diagnostics;
534
+ }
535
+ static #classNameOf(token) {
536
+ return token.replace(/^.*:/, "").replace(/^!|!$/g, "").replace(/\/.*$/, "");
537
+ }
538
+ static #linesOf(lines, start, end) {
539
+ return lines.slice(start - 1, end).join(`
540
+ `);
541
+ }
542
+ static async#definedClasses(root, dirs) {
543
+ const names = new Set;
544
+ for (const dir of new Set(dirs)) {
545
+ const cwd = path4.join(root, dir);
546
+ if (!existsSync3(cwd))
547
+ continue;
548
+ for await (const file of new Bun.Glob("**/*.css").scan({ cwd })) {
549
+ if (file.split(/[\\/]/).includes("node_modules"))
550
+ continue;
551
+ for (const name of VerifyStyleClasses.classesDefinedIn(await Bun.file(path4.join(cwd, file)).text()))
552
+ names.add(name);
553
+ }
554
+ }
555
+ return names;
556
+ }
557
+ }
558
+
275
559
  // pkgs/@akanjs/cli/verify/verifyPipeline.ts
276
560
  class VerifyPipeline {
277
561
  #workspace;
@@ -293,8 +577,11 @@ class VerifyPipeline {
293
577
  if (!lintOnly)
294
578
  await this.#each("sync", systems, (target) => this.#sync(target));
295
579
  const synced = !this.#failed("sync");
580
+ const renames = new Map;
581
+ for (const target of systems)
582
+ renames.set(target, await VerifyPrivateMethods.fix(this.#root, target.dir, target.files).catch(() => new Map));
296
583
  await Promise.all([
297
- this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly })),
584
+ this.#each("lint", scope.targets, (target) => this.#lint(target, { comments: !lintOnly, rewritten: renames.get(target) ?? new Map })),
298
585
  lintOnly || !synced ? null : this.#each("typecheck", scope.targets, (target) => this.#typecheck(target))
299
586
  ]);
300
587
  const apps = scope.targets.filter((target) => target.type === "app");
@@ -345,9 +632,10 @@ class VerifyPipeline {
345
632
  await LibExecutor.from(this.#workspace, target.name).scan();
346
633
  return { diagnostics: [] };
347
634
  }
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 };
635
+ async#lint(target, { comments, rewritten }) {
636
+ const files = target.files.length ? target.files.filter((file) => existsSync4(path5.join(this.#root, file))) : [target.dir];
637
+ const biome = files.length ? await this.#biome(files, VerifyPipeline.#cssDirsOf(target)) : { diagnostics: [], fixed: 0 };
638
+ const formattedAfter = await this.#changedSince(rewritten);
351
639
  const exec = this.#execOf(target);
352
640
  const gates = await this.#workspaceRunner.lintGateFailures(exec, true);
353
641
  const added = comments && target.files.length ? await VerifyComments.added(this.#root, target.files) : [];
@@ -358,10 +646,22 @@ class VerifyPipeline {
358
646
  ...gates.messages.map((message) => VerifyDiagnostics.fromMessage("lint", message, "akan.lint")),
359
647
  ...VerifyDiagnostics.fromMaintainability(gates.maintainability)
360
648
  ],
361
- fixed: biome.fixed
649
+ fixed: (biome.fixed ?? 0) + rewritten.size - formattedAfter
362
650
  };
363
651
  }
364
- async#biome(files) {
652
+ static #cssDirsOf(target) {
653
+ if (target.type === "pkg")
654
+ return [];
655
+ return target.type === "app" ? [target.dir, "libs"] : ["libs"];
656
+ }
657
+ async#changedSince(rewritten) {
658
+ let changed = 0;
659
+ for (const [file, text] of rewritten)
660
+ if (await Bun.file(path5.join(this.#root, file)).text() !== text)
661
+ changed += 1;
662
+ return changed;
663
+ }
664
+ async#biome(files, cssDirs) {
365
665
  const configPath = await WorkspaceRunner.resolveBiomeConfigPath(this.#workspace);
366
666
  const [biome, ...biomeArgs] = Linter.biomeCommand(this.#root);
367
667
  const proc = Bun.spawn([
@@ -382,7 +682,11 @@ class VerifyPipeline {
382
682
  ]);
383
683
  try {
384
684
  const report = parseBiomeReport(stdout);
385
- return { diagnostics: VerifyDiagnostics.fromBiome(report), fixed: report.summary?.changed ?? 0 };
685
+ const diagnostics = await VerifyStyleClasses.dropDefined(this.#root, report.diagnostics ?? [], cssDirs);
686
+ return {
687
+ diagnostics: VerifyDiagnostics.fromBiome({ ...report, diagnostics }, this.#root),
688
+ fixed: report.summary?.changed ?? 0
689
+ };
386
690
  } catch {
387
691
  return { diagnostics: [VerifyDiagnostics.fromMessage("lint", (stderr || stdout).trim(), "biome")] };
388
692
  }
@@ -400,10 +704,10 @@ class VerifyPipeline {
400
704
  report: "records"
401
705
  });
402
706
  else {
403
- const tsconfigPath = path2.join(this.#root, target.dir, "tsconfig.json");
404
- if (!existsSync2(tsconfigPath))
707
+ const tsconfigPath = path5.join(this.#root, target.dir, "tsconfig.json");
708
+ if (!existsSync4(tsconfigPath))
405
709
  return { diagnostics: [] };
406
- await new ProjectTypecheck2(path2.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
710
+ await new ProjectTypecheck2(path5.join(this.#root, target.dir), this.#root, process.env).check(tsconfigPath, "records");
407
711
  }
408
712
  return { diagnostics: [] };
409
713
  } catch (error) {
@@ -413,8 +717,8 @@ class VerifyPipeline {
413
717
  }
414
718
  }
415
719
  async#build(target) {
416
- await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
417
- return { diagnostics: [] };
720
+ const { routeJsWarnings = [] } = await this.#applicationRunner.build(AppExecutor.from(this.#workspace, target.name), { fast: true });
721
+ return { diagnostics: routeJsWarnings.map((warning) => VerifyDiagnostics.fromRouteJsBudget(warning)) };
418
722
  }
419
723
  async#ssr(scope) {
420
724
  const scanned = await new AkanQualityScanner().scan(this.#root);
@@ -1003,7 +1003,7 @@ class AkanAppConfig {
1003
1003
  }
1004
1004
  static localImageGuard = [
1005
1005
  "ARG AKAN_ALLOW_LOCAL_IMAGE",
1006
- `RUN if [ "$AKAN_ALLOW_LOCAL_IMAGE" != "1" ]; then echo "This build ran with AKAN_PUBLIC_ENV=local, which serves the dev routes to every caller. Build with the environment it deploys to, or pass --build-arg AKAN_ALLOW_LOCAL_IMAGE=1." >&2; exit 1; fi`
1006
+ `RUN if [ "$AKAN_ALLOW_LOCAL_IMAGE" != "1" ]; then echo "This build ran with AKAN_PUBLIC_ENV=local, so the server runs without endpoint rate limits and on local defaults for Redis and the database mode. Build for the environment it deploys to with akan build --env, or pass --build-arg AKAN_ALLOW_LOCAL_IMAGE=1." >&2; exit 1; fi`
1007
1007
  ].join(`
1008
1008
  `);
1009
1009
  dockerfileFor(environment, { lockfile = true } = {}) {
@@ -1359,6 +1359,30 @@ class AsyncDefaultExportDetector {
1359
1359
  }
1360
1360
  }
1361
1361
 
1362
+ // pkgs/@akanjs/devkit/artifact/storeBootstrap.ts
1363
+ class StoreBootstrap {
1364
+ static importLines(appName) {
1365
+ return StoreBootstrap.#lines([`@apps/${appName}/lib/useClient`, `@apps/${appName}/lib/st`]);
1366
+ }
1367
+ static source(appName) {
1368
+ return `${StoreBootstrap.importLines(appName).join(`
1369
+ `)}
1370
+ `;
1371
+ }
1372
+ static ofClientBarrel(specifier, exports) {
1373
+ if (!/^@(?:apps|libs)\/[^/]+\/client$/.test(specifier))
1374
+ return null;
1375
+ const runtime = exports.get("usePage");
1376
+ const store = exports.get("st");
1377
+ if (!runtime || runtime.namespace || !store || store.namespace)
1378
+ return StoreBootstrap.#lines([specifier]);
1379
+ return StoreBootstrap.#lines([...new Set([runtime.subpath, store.subpath])]);
1380
+ }
1381
+ static #lines(specifiers) {
1382
+ return specifiers.map((specifier) => `import ${JSON.stringify(specifier)};`);
1383
+ }
1384
+ }
1385
+
1362
1386
  // pkgs/@akanjs/devkit/artifact/implicitRootLayout.ts
1363
1387
  var LAYOUT_KEY_RE = /^\.\/(.+\/)?_layout\.(tsx|ts|jsx|js)$/;
1364
1388
  var IMPLICIT_LAYOUT_DIR = path6.join(".akan", "generated", "root-layouts");
@@ -1467,10 +1491,7 @@ async function writeGeneratedRootLayoutFile(opts) {
1467
1491
  const sourceSpecifier = opts.boundary.sourceAbsPath ? importSpecifier(absPath, opts.boundary.sourceAbsPath) : null;
1468
1492
  const inheritedSourceAbsPath = opts.rootSourceAbsPath && opts.rootSourceAbsPath !== opts.boundary.sourceAbsPath ? opts.rootSourceAbsPath : null;
1469
1493
  const inheritedSourceSpecifier = inheritedSourceAbsPath ? importSpecifier(absPath, inheritedSourceAbsPath) : null;
1470
- const clientImport = opts.includeStInit ? `import { st } from "@apps/${opts.appName}/client";
1471
- void st;
1472
- ` : `import "@apps/${opts.appName}/client";
1473
- `;
1494
+ const storeImport = opts.includeStoreBootstrap ? StoreBootstrap.source(opts.appName) : "";
1474
1495
  const inheritedLabel = inheritedSourceAbsPath ? posixRelative(opts.appCwdPath, inheritedSourceAbsPath) : "";
1475
1496
  const inheritedImport = inheritedSourceSpecifier ? `import * as inheritedModule from ${JSON.stringify(inheritedSourceSpecifier)};
1476
1497
  const inheritedLayout = assertGuardOnChain(${JSON.stringify(inheritedLabel)}, resolveRouteModule(inheritedModule as never, ${JSON.stringify(inheritedLabel)})).module as LayoutModule;
@@ -1518,7 +1539,7 @@ import { System } from "akanjs/ui/System/index.tsx";
1518
1539
  import type { McpAppRootProps } from "akanjs/webkit";
1519
1540
  import { env } from "@apps/${opts.appName}/env/env.client";
1520
1541
  import { allDictionary } from ${JSON.stringify(dictMacroSpecifier)};
1521
- ${clientImport}${inheritedImport}${userImport}
1542
+ ${storeImport}${inheritedImport}${userImport}
1522
1543
  const userFonts = userLayout.fonts ?? inheritedLayout.fonts ?? [];
1523
1544
  const defaultFonts = userFonts.filter((font) => font.default);
1524
1545
  if (defaultFonts.length > 1) throw new Error("[route-convention] only one default font is allowed per root layout");
@@ -1604,7 +1625,7 @@ async function resolveSsrPageEntries(opts) {
1604
1625
  appName: opts.appName,
1605
1626
  boundary,
1606
1627
  rootSourceAbsPath,
1607
- includeStInit: hasSt && boundary.segments.length === 0,
1628
+ includeStoreBootstrap: hasSt,
1608
1629
  includeSystemProvider: !hasAncestorRootBoundary(boundary, rootBoundaries)
1609
1630
  }),
1610
1631
  seedAbsPaths: [...new Set([boundary.sourceAbsPath, rootSourceAbsPath].filter((absPath) => absPath !== null))]
@@ -2380,6 +2401,7 @@ var appRootAllowedFiles = new Set([
2380
2401
  "CLAUDE.md",
2381
2402
  "akan.app.json",
2382
2403
  "akan.baseline.json",
2404
+ "akan.budget.json",
2383
2405
  "akan.config.ts",
2384
2406
  "client.ts",
2385
2407
  "main.ts",
@@ -3489,7 +3511,7 @@ class Executor {
3489
3511
  }
3490
3512
  }
3491
3513
  async getTypeChecker() {
3492
- const { TypeChecker } = await import("./typeChecker-j2jdnqsr.js");
3514
+ const { TypeChecker } = await import("./typeChecker-s640r6c0.js");
3493
3515
  this.typeChecker ??= new TypeChecker(this);
3494
3516
  return this.typeChecker;
3495
3517
  }
@@ -3563,7 +3585,8 @@ class WorkspaceExecutor extends Executor {
3563
3585
  static localServeDomain = "localhost";
3564
3586
  static getBaseDevEnv(envPath) {
3565
3587
  const sourceEnv = {
3566
- ...envPath ? { ...process.env, ...parseEnvFile(envPath) } : process.env,
3588
+ ...envPath ? parseEnvFile(envPath) : {},
3589
+ ...Object.fromEntries(Object.entries(process.env).filter(([, value]) => value)),
3567
3590
  ...WorkspaceExecutor.publicEnvPin
3568
3591
  };
3569
3592
  const appName = sourceEnv.AKAN_PUBLIC_APP_NAME;
@@ -4482,4 +4505,4 @@ class ModuleExecutor extends Executor {
4482
4505
  }
4483
4506
  }
4484
4507
 
4485
- export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, TypecheckFailure, ProjectTypecheck2, CommandExecutionError, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
4508
+ export { AGENT_BLOCK_START, AGENT_BLOCK_END, stampBlockVersion, extractBlockVersion, readDevkitVersion, upsertAgentBlock, extractAgentBlock, renderRecipeEntries, collectScopeRecipeSources, renderScopeAgentBlock, CLAUDE_COMMENT_RULE, binPlatforms, ServerEnvProfile, AkanAppConfig, AkanWorkspaceConfig, AsyncDefaultExportDetector, StoreBootstrap, resolveSsrPageEntriesForApp, CodegenLock, JsonFormatter, parseBiomeReport, Linter, LibSource, formatLibStatuses, rootAllowedFiles, rootAllowedDirs, isAllowedLibFacetRootFile, libFacetRootHintOf, barrelFacetDirs, facetIndexShadowOf, rootEntryHintOf, isScannedRootEntry, AppInfo, Spinner, TypecheckFailure, ProjectTypecheck2, CommandExecutionError, parseEnvFile, Executor, WorkspaceExecutor, SysExecutor, AppExecutor, LibExecutor, PkgExecutor, ModuleExecutor };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  AppInfo
4
- } from "./index-g500c5j9.js";
4
+ } from "./index-sr5da35e.js";
5
5
 
6
6
  // pkgs/@akanjs/devkit/slicePlanner.ts
7
7
  class SlicePlanner {
@@ -10,7 +10,7 @@ import {
10
10
  isScannedRootEntry,
11
11
  AppExecutor,
12
12
  LibExecutor
13
- } from "./index-g500c5j9.js";
13
+ } from "./index-sr5da35e.js";
14
14
  import {
15
15
  FileSys2
16
16
  } from "./index-bns3wcpc.js";
@@ -23,7 +23,7 @@ import {
23
23
  workflowPathsForPlan,
24
24
  workflowRunArtifactPath,
25
25
  workflowSyncDir
26
- } from "./index-m02tdq8a.js";
26
+ } from "./index-8pb9yvp8.js";
27
27
 
28
28
  // pkgs/@akanjs/devkit/akanContext.ts
29
29
  import { readdir } from "fs/promises";