@akanjs/cli 3.2.0-rc.9 → 3.2.1-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 (145) hide show
  1. package/.build-stamp +2 -2
  2. package/CodeAgent-xdw73nbz.js +11 -0
  3. package/{CodeTui-qstk5vpj.js → CodeTui-0gewm71c.js} +822 -666
  4. package/README.ko.md +7 -0
  5. package/README.md +7 -0
  6. package/TunnelShare-cccfdgbm.js +16 -0
  7. package/agent.command-g1mj34wz.js +59 -0
  8. package/akanCode.js +12 -12
  9. package/appExecutor-rrx10jya.js +11 -0
  10. package/{application.command-m4rq4wc2.js → application.command-3w4v7t40.js} +84 -40
  11. package/{applicationBuildRunner-df7rx3ra.js → applicationBuildRunner-y5xbetyz.js} +51 -20
  12. package/buildBatch.proc.js +31 -16
  13. package/{cloud.command-a0gy0qq2.js → cloud.command-ph0rz6sw.js} +28 -29
  14. package/cloud.script-8bs9tp4j.js +30 -0
  15. package/{code.command-5rsdqw8s.js → code.command-9b967qpg.js} +13 -9
  16. package/context.command-ndzs5rbf.js +62 -0
  17. package/context.runner-bmstpng2.js +32 -0
  18. package/csrArtifactBuilder-gtvff6k7.js +10 -0
  19. package/{index-qd7xn2bk.js → dependencyScanner-93g8tk0r.js} +7 -6
  20. package/{devTui-h77zrjv5.js → devTui-rf374y2w.js} +1 -1
  21. package/{fileSys-zpvt5gtf.js → fileSys-e5mwt73x.js} +1 -1
  22. package/frameworkGraph-aneq2nwy.js +8 -0
  23. package/{guideline.command-mffxknbr.js → guideline.command-y8qz9kxy.js} +9 -5
  24. package/guidelines/agentRule/agentRule.instruction.md +25 -9
  25. package/guidelines/akanApi/akanApi.instruction.md +6 -4
  26. package/guidelines/conventions/core.md +23 -5
  27. package/guidelines/conventions/rules/app.md +4 -1
  28. package/guidelines/conventions/rules/page.md +5 -4
  29. package/guidelines/conventions/rules/ts.md +3 -3
  30. package/guidelines/errorCodes/errorCodes.instruction.md +165 -0
  31. package/guidelines/fieldRule/fieldRule.instruction.md +2 -1
  32. package/guidelines/mcpRule/mcpRule.instruction.md +225 -5
  33. package/guidelines/pageRule/pageRule.instruction.md +10 -1
  34. package/guidelines/queryRule/queryRule.instruction.md +3 -1
  35. package/guidelines/runtimeRule/runtimeRule.instruction.md +14 -8
  36. package/guidelines/transportRule/transportRule.instruction.md +31 -1
  37. package/incrementalBuilder.proc.js +609 -437
  38. package/{index-skmtj8rm.js → index-02v45hh9.js} +27 -10
  39. package/{index-j6gc8n14.js → index-0csk6jqm.js} +11 -9
  40. package/{index-2r9ff9qm.js → index-0wa5z6rm.js} +2 -2
  41. package/{index-nmvhjn8c.js → index-0z8sbdme.js} +93 -82
  42. package/{index-2vgv7fs7.js → index-1c2807kg.js} +727 -693
  43. package/{index-hj6w4ka1.js → index-1p81ecbz.js} +1 -1
  44. package/{index-2mf1aen9.js → index-1p9bxjmt.js} +2 -2
  45. package/{index-an76bdrv.js → index-2kh4xj3m.js} +1 -1
  46. package/{index-99qvtff2.js → index-2vn0m9z5.js} +5 -5
  47. package/{index-rp4yf32g.js → index-3569fr49.js} +36 -29
  48. package/{index-xvk2a75m.js → index-38x8ynrx.js} +25 -25
  49. package/{index-cmg5ngqa.js → index-3fmzz9sf.js} +20 -20
  50. package/{index-rfzp4pqs.js → index-45aprybg.js} +3 -3
  51. package/{index-k92x3vne.js → index-4a1n0nym.js} +1 -1
  52. package/{index-ra9fvn7s.js → index-4zgm54wf.js} +76 -40
  53. package/{index-exn38bzx.js → index-652f3bs8.js} +116 -54
  54. package/{index-grxs6fts.js → index-6gepp8yn.js} +57 -31
  55. package/{index-vm0dn0mt.js → index-6j351de4.js} +294 -157
  56. package/{index-w15mg3km.js → index-7ssr7wq4.js} +1 -1
  57. package/{index-gxav1bjz.js → index-82cmbpxc.js} +9 -9
  58. package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
  59. package/{index-gcx48get.js → index-9rymt8d6.js} +2 -2
  60. package/{index-swwjakt0.js → index-ankyx6dj.js} +14 -18
  61. package/{index-28x1aszt.js → index-b0t92k71.js} +154 -58
  62. package/index-b372rck5.js +799 -0
  63. package/{index-yf9wc28h.js → index-bejy9zyc.js} +1 -1
  64. package/{index-r0a604h4.js → index-c669pbyb.js} +5 -4
  65. package/{index-xyn02k0w.js → index-cm9rb480.js} +662 -433
  66. package/{index-j9790rhk.js → index-d0n78fzc.js} +1635 -1139
  67. package/{index-hqv34wzq.js → index-dr1carpr.js} +10 -10
  68. package/index-f2arv0mv.js +30 -0
  69. package/{index-5radqwn2.js → index-gtydr9qc.js} +12 -12
  70. package/{index-j6eeh5d7.js → index-j3fqs8rc.js} +5 -5
  71. package/{index-yckz5t8b.js → index-jdw9m5c4.js} +516 -434
  72. package/{index-ny2k80mv.js → index-jf4vk1s0.js} +9 -2
  73. package/{index-x40bdsca.js → index-jg5rwrf7.js} +77 -115
  74. package/{index-5zwr4n6k.js → index-ktxdfqg5.js} +65 -8
  75. package/index-mnhrqjjq.js +127 -0
  76. package/{index-3ghdb7p5.js → index-pc42gxa5.js} +2777 -3676
  77. package/{index-0hbtve0a.js → index-q8h4eg5y.js} +32 -28
  78. package/{index-j3v29pq7.js → index-qh81drde.js} +219 -175
  79. package/{index-b4qq3rq0.js → index-rwgqba9p.js} +1 -1
  80. package/{index-w8yasvpc.js → index-scfsqen7.js} +2136 -2175
  81. package/{index-9p260r4e.js → index-trffs83s.js} +538 -250
  82. package/{index-0gg15zwa.js → index-twjgmryg.js} +6 -6
  83. package/index-whvhsb5f.js +80 -0
  84. package/{index-h7hehkw6.js → index-xczjdng6.js} +3 -1
  85. package/{index-39jz41jb.js → index-xs9a3ddt.js} +3 -3
  86. package/{index-35j83zkd.js → index-xv3pvdw4.js} +2 -2
  87. package/{index-34792nh7.js → index-y2g0s9tn.js} +1 -1
  88. package/{index-43f4h4cm.js → index-ymgsvhc5.js} +7 -8
  89. package/{index-ygdbn9jn.js → index-zyb0ebm4.js} +1 -1
  90. package/{index-bns3wcpc.js → index-zyjztrvc.js} +2 -2
  91. package/index.js +30 -24
  92. package/libExecutor-nstr00s7.js +10 -0
  93. package/{library.command-bmd7zc5m.js → library.command-b02aw1hm.js} +12 -5
  94. package/{localRegistry.command-y6en1599.js → localRegistry.command-3hg1p4aj.js} +24 -24
  95. package/{module.command-7exfffqw.js → module.command-bd9gz6cv.js} +11 -7
  96. package/{package.command-adskw2rj.js → package.command-xmr0mxze.js} +11 -10
  97. package/package.json +8 -8
  98. package/{page.command-dw01272p.js → page.command-x94qf58g.js} +8 -4
  99. package/{pipeline.command-0b1r3y5r.js → pipeline.command-n2843k6t.js} +15 -9
  100. package/pkgExecutor-cka27e3c.js +10 -0
  101. package/{primitive.command-byw6vc04.js → primitive.command-cs7v376h.js} +12 -8
  102. package/{projectTypecheck-kkrpq60a.js → projectTypecheck-za2n3nbr.js} +1 -1
  103. package/{prompter-qrwx1p17.js → prompter-d33wmdpa.js} +2 -2
  104. package/{quality.command-6rqnhzct.js → quality.command-nqngh1jd.js} +25 -16
  105. package/{recipeScanner-4b69ybe0.js → recipeScanner-rrx69awy.js} +1 -1
  106. package/{repair.command-rw5zymak.js → repair.command-v2medwsm.js} +12 -8
  107. package/{routeSourceValidator-4h947v7c.js → routeSourceValidator-8n6j1vn7.js} +4 -2
  108. package/{scalar.command-2dyp9nh9.js → scalar.command-61cjmxn1.js} +10 -6
  109. package/skills/akan-debug/SKILL.md +8 -5
  110. package/skills/akan-err/SKILL.md +7 -0
  111. package/skills/akan-mcp/SKILL.md +19 -1
  112. package/skills/akan-scaffold/SKILL.md +1 -1
  113. package/skills/akan-validate/SKILL.md +3 -3
  114. package/{subspace.command-111ynwv1.js → subspace.command-dtv8nfh7.js} +30 -24
  115. package/templates/app/page/_layout.tsx +13 -0
  116. package/templates/app/page/styles.css.template +40 -0
  117. package/templates/appSample/page/_index.tsx +9 -9
  118. package/templates/appSample/page/_layout.tsx +1 -0
  119. package/templates/appSample/page/styles.css.template +40 -5
  120. package/templates/appSample/ui/Recipe/jellyButton.ts +1 -1
  121. package/templates/biomeForm.ts +1 -1
  122. package/templates/env/_env.server.type.ts +1 -1
  123. package/templates/facetIndex/index.ts +2 -37
  124. package/templates/lib/sig.ts +0 -4
  125. package/templates/lib/useClient.ts +1 -1
  126. package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
  127. package/templates/workspaceRoot/AGENTS.md.template +2 -1
  128. package/templates/workspaceRoot/README.ts +4 -2
  129. package/{tunnel.command-2gcpfbdj.js → tunnel.command-fmwm5fgb.js} +15 -13
  130. package/{typeChecker-s640r6c0.js → typeChecker-7jt6abrs.js} +1 -1
  131. package/typecheck.proc.js +3 -2
  132. package/{verify.command-djgs86ma.js → verify.command-4f260t53.js} +19 -17
  133. package/{workflow.command-n0k2mxr5.js → workflow.command-tm5q9xsm.js} +21 -14
  134. package/{workspace.command-fh1qwxfx.js → workspace.command-75gc280j.js} +56 -54
  135. package/CodeAgent-x2p3a3e0.js +0 -11
  136. package/TunnelShare-c4xsfzg5.js +0 -15
  137. package/agent.command-9et2e27p.js +0 -52
  138. package/cloud.script-xze4zh7n.js +0 -31
  139. package/context.command-rk1dwrg4.js +0 -57
  140. package/context.runner-83ky5m1b.js +0 -30
  141. package/dependencyScanner-78sq8m4q.js +0 -8
  142. /package/templates/{appSample → app}/public/fonts/Pretendard-Bold.woff2 +0 -0
  143. /package/templates/{appSample → app}/public/fonts/Pretendard-Medium.woff2 +0 -0
  144. /package/templates/{appSample → app}/public/fonts/Pretendard-Regular.woff2 +0 -0
  145. /package/templates/{appSample → app}/public/fonts/Pretendard-SemiBold.woff2 +0 -0
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  ShellOnlyEnv
4
- } from "./index-yf9wc28h.js";
4
+ } from "./index-bejy9zyc.js";
5
5
 
6
6
  // pkgs/@akanjs/cli/npmRegistry.ts
7
7
  import { Logger } from "akanjs/common";
@@ -37,5 +37,12 @@ async function getLatestPackageVersion(packageName, tag = "latest", registryUrl)
37
37
  throw new Error(`No npm dist-tag "${tag}" found for ${packageName}`);
38
38
  return version;
39
39
  }
40
+ async function getPublishedPeerDependencies(packageName, version, registryUrl) {
41
+ const registry = getNpmRegistryUrl(registryUrl);
42
+ const res = await fetch(`${packageUrl(registry, packageName)}/${encodeURIComponent(version)}`);
43
+ if (!res.ok)
44
+ throw new Error(`Failed to fetch ${packageName}@${version} metadata from ${registry} (${res.status})`);
45
+ return (await res.json()).peerDependencies ?? {};
46
+ }
40
47
 
41
- export { npmRegistryFromEnv, warnIgnoredNpmRegistry, getNpmRegistryUrl, getPublishedVersions, getLatestPackageVersion };
48
+ export { npmRegistryFromEnv, warnIgnoredNpmRegistry, getNpmRegistryUrl, getPublishedVersions, getLatestPackageVersion, getPublishedPeerDependencies };
@@ -3,7 +3,7 @@ import {
3
3
  ROOT_LAYOUT_SYSTEM,
4
4
  isImplicitRootLayoutKey,
5
5
  resolveSsrPageEntriesForApp
6
- } from "./index-3ghdb7p5.js";
6
+ } from "./index-b372rck5.js";
7
7
  import {
8
8
  computeRouteSeedIndex,
9
9
  saveRouteSeedIndex,
@@ -11,12 +11,13 @@ import {
11
11
  ClientEntriesBundler,
12
12
  VENDOR_SPECIFIERS,
13
13
  RouteClientBuilder
14
- } from "./index-w8yasvpc.js";
14
+ } from "./index-scfsqen7.js";
15
15
  import {
16
16
  SOURCE_EXTS,
17
- FontOptimizer,
18
- FontPruner
19
- } from "./index-vm0dn0mt.js";
17
+ buildCacheStamp,
18
+ isBuildCacheStamp,
19
+ FontOptimizer
20
+ } from "./index-6j351de4.js";
20
21
  import {
21
22
  BarrelAnalyzer,
22
23
  createTsconfigPackageResolver,
@@ -24,7 +25,10 @@ import {
24
25
  CsrEntryFiles,
25
26
  toClientReferencePath,
26
27
  PagesBundleBuilder
27
- } from "./index-nmvhjn8c.js";
28
+ } from "./index-0z8sbdme.js";
29
+ import {
30
+ FileSys2
31
+ } from "./index-zyjztrvc.js";
28
32
  import {
29
33
  CssBlockParser
30
34
  } from "./index-62md4dwy.js";
@@ -208,14 +212,16 @@ import { stat } from "fs/promises";
208
212
  var CANDIDATE_RE = /-?(?:[\w@]|\[(?:[^[\]\s]|\[[^[\]\s]+\])+\])[\w:/.-]*(?:(?:\[(?:[^[\]\s]|\[[^[\]\s]+\])+\]|\((?:[a-z-]+:)?--[^)\s]+\))[\w:/.-]*)*/g;
209
213
 
210
214
  class CssCandidateCache {
211
- static #version = 5;
215
+ static #version = 6;
212
216
  #path;
217
+ #stamp;
213
218
  #entries = new Map;
214
219
  #dirty = false;
215
220
  #reused = 0;
216
221
  #rescanned = 0;
217
- constructor(cachePath) {
222
+ constructor(cachePath, stamp = buildCacheStamp([import.meta.path])) {
218
223
  this.#path = cachePath;
224
+ this.#stamp = stamp;
219
225
  }
220
226
  get reused() {
221
227
  return this.#reused;
@@ -225,7 +231,7 @@ class CssCandidateCache {
225
231
  }
226
232
  async load() {
227
233
  const raw = await Bun.file(this.#path).json().catch(() => null);
228
- if (!raw || raw.version !== CssCandidateCache.#version || typeof raw.files !== "object")
234
+ if (raw?.version !== CssCandidateCache.#version || !isBuildCacheStamp(raw, this.#stamp) || !raw.files)
229
235
  return this;
230
236
  for (const [file, entry] of Object.entries(raw.files)) {
231
237
  if (typeof entry?.mtimeMs !== "number" || !Array.isArray(entry.candidates))
@@ -251,19 +257,21 @@ class CssCandidateCache {
251
257
  return candidates;
252
258
  }
253
259
  async save(present) {
254
- for (const file of [...this.#entries.keys()]) {
255
- if (present.has(file))
256
- continue;
260
+ const absent = [...this.#entries.keys()].filter((file) => !present.has(file));
261
+ const exists = await Promise.all(absent.map((file) => Bun.file(file).exists()));
262
+ absent.forEach((file, index) => {
263
+ if (exists[index])
264
+ return;
257
265
  this.#entries.delete(file);
258
266
  this.#dirty = true;
259
- }
267
+ });
260
268
  if (!this.#dirty)
261
269
  return;
262
270
  this.#dirty = false;
263
271
  const files = {};
264
272
  for (const [file, entry] of this.#entries)
265
273
  files[file] = entry;
266
- await Bun.write(this.#path, JSON.stringify({ version: CssCandidateCache.#version, files })).catch(() => {
274
+ await FileSys2.writeTextAtomic(this.#path, JSON.stringify({ version: CssCandidateCache.#version, ...this.#stamp, files })).catch(() => {
267
275
  return;
268
276
  });
269
277
  }
@@ -734,76 +742,13 @@ function declaredCustomProperties(css) {
734
742
  function getPageKeyBasePath(pageKey, basePaths) {
735
743
  return CsrEntryFiles.basePathOfPageKey(pageKey, basePaths);
736
744
  }
737
- // pkgs/@akanjs/devkit/frontendBuild/precompressArtifacts.ts
738
- import fs from "fs";
739
- import path4 from "path";
740
- import zlib from "zlib";
741
- var COMPRESSIBLE_EXTS = new Set([".css", ".html", ".js", ".json", ".svg"]);
742
- var MIN_COMPRESS_BYTES = 1024;
743
- var MAX_BROTLI_QUALITY = 11;
744
- var BROTLI_QUALITY_BY_EXT = { ".css": MAX_BROTLI_QUALITY };
745
- var DEFAULT_BROTLI_QUALITY = 9;
746
- var GZIP_LEVEL = 9;
747
- var { formatBytes } = FontPruner;
748
- async function precompressArtifacts(app) {
749
- const artifactDir = path4.join(app.dist.cwdPath, ".akan/artifact");
750
- const roots = [
751
- { root: path4.join(artifactDir, "client") },
752
- { root: path4.join(artifactDir, "styles") },
753
- { root: path4.join(artifactDir, "dict"), brotliQuality: MAX_BROTLI_QUALITY }
754
- ];
755
- const result = { files: 0, inputBytes: 0, outputBytes: 0, brotliBytes: 0 };
756
- await Promise.all(roots.map(({ root, brotliQuality }) => precompressRoot(root, result, brotliQuality)));
757
- if (result.files > 0) {
758
- app.verbose(`[precompress] wrote ${result.files} sidecars (${formatBytes(result.inputBytes)} -> gzip ${formatBytes(result.outputBytes)} / br ${formatBytes(result.brotliBytes)})`);
759
- }
760
- return result;
761
- }
762
- async function precompressRoot(root, result, brotliQuality) {
763
- if (!fs.existsSync(root) || !fs.statSync(root).isDirectory())
764
- return;
765
- const glob = new Bun.Glob("**/*");
766
- for await (const filePath of glob.scan({ cwd: root, absolute: true })) {
767
- if (!await shouldPrecompress(filePath))
768
- continue;
769
- const bytes = await Bun.file(filePath).bytes();
770
- const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
771
- const gz = Bun.gzipSync(buffer, { level: GZIP_LEVEL });
772
- const br = brotliCompress(buffer, brotliQuality ?? brotliQualityOf(path4.extname(filePath).toLowerCase()));
773
- await Promise.all([Bun.write(`${filePath}.gz`, gz), Bun.write(`${filePath}.br`, br)]);
774
- result.files += 1;
775
- result.inputBytes += bytes.byteLength;
776
- result.outputBytes += gz.byteLength;
777
- result.brotliBytes += br.byteLength;
778
- }
779
- }
780
- function brotliQualityOf(ext) {
781
- return BROTLI_QUALITY_BY_EXT[ext] ?? DEFAULT_BROTLI_QUALITY;
782
- }
783
- function brotliCompress(buffer, quality) {
784
- return zlib.brotliCompressSync(buffer, {
785
- params: {
786
- [zlib.constants.BROTLI_PARAM_QUALITY]: quality,
787
- [zlib.constants.BROTLI_PARAM_SIZE_HINT]: buffer.byteLength
788
- }
789
- });
790
- }
791
- async function shouldPrecompress(filePath) {
792
- if (filePath.endsWith(".gz") || filePath.endsWith(".br"))
793
- return false;
794
- if (!COMPRESSIBLE_EXTS.has(path4.extname(filePath).toLowerCase()))
795
- return false;
796
- const file = Bun.file(filePath);
797
- if (!await file.exists())
798
- return false;
799
- return file.size >= MIN_COMPRESS_BYTES;
800
- }
801
745
  // pkgs/@akanjs/devkit/frontendBuild/ssrBaseArtifactBuilder.ts
802
- import path7 from "path";
746
+ import { rename } from "fs/promises";
747
+ import path6 from "path";
803
748
  import { optimize } from "@tailwindcss/node";
804
749
 
805
750
  // pkgs/@akanjs/devkit/frontendBuild/dictionaryAssetBuilder.ts
806
- import path5 from "path";
751
+ import path4 from "path";
807
752
  import { Translator } from "akanjs/client";
808
753
 
809
754
  class DictionaryAssetBuilder {
@@ -823,7 +768,7 @@ class DictionaryAssetBuilder {
823
768
  return Object.fromEntries(assets);
824
769
  }
825
770
  async#loadAllDictionary() {
826
- const dictPath = path5.resolve(this.#app.cwdPath, "lib", "dict.ts");
771
+ const dictPath = path4.resolve(this.#app.cwdPath, "lib", "dict.ts");
827
772
  if (!await Bun.file(dictPath).exists())
828
773
  return null;
829
774
  const { getAllDictionary } = await import(dictPath);
@@ -833,7 +778,7 @@ class DictionaryAssetBuilder {
833
778
  const source = DictionaryAssetBuilder.source(lang, dictionary);
834
779
  const name = `${lang}-${Bun.hash(source).toString(36)}.js`;
835
780
  const relPath = `dict/${name}`;
836
- await Bun.write(path5.join(this.#absArtifactDir, relPath), source);
781
+ await Bun.write(path4.join(this.#absArtifactDir, relPath), source);
837
782
  return [lang, { url: `${DictionaryAssetBuilder.urlPrefix}/${name}`, relPath }];
838
783
  }
839
784
  static source(lang, dictionary) {
@@ -844,8 +789,8 @@ export default JSON.parse(${JSON.stringify(JSON.stringify(dictionary))});
844
789
  }
845
790
 
846
791
  // pkgs/@akanjs/devkit/frontendBuild/vendorNarrowing.ts
847
- import fs2 from "fs";
848
- import path6 from "path";
792
+ import fs from "fs";
793
+ import path5 from "path";
849
794
  var deprecatedReexports = { "akanjs/store": "store/deprecatedAgent.ts" };
850
795
 
851
796
  class VendorNarrowing {
@@ -854,12 +799,12 @@ class VendorNarrowing {
854
799
  static entriesIn(akanServerPath) {
855
800
  return VENDOR_SPECIFIERS.map((specifier) => ({
856
801
  specifier,
857
- absPath: path6.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`)
858
- })).filter(({ absPath }) => fs2.existsSync(absPath));
802
+ absPath: path5.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`)
803
+ })).filter(({ absPath }) => fs.existsSync(absPath));
859
804
  }
860
805
  constructor(akanjsRoot, vendorExports) {
861
806
  this.#akanjsRoot = akanjsRoot;
862
- const current = Object.values(deprecatedReexports).every((file) => fs2.existsSync(path6.join(akanjsRoot, file)));
807
+ const current = Object.values(deprecatedReexports).every((file) => fs.existsSync(path5.join(akanjsRoot, file)));
863
808
  this.#vendorExports = current ? vendorExports : {};
864
809
  }
865
810
  entryExports(vendorEntries) {
@@ -874,7 +819,7 @@ class VendorNarrowing {
874
819
  const used = this.#vendorExports[specifier];
875
820
  if (!used)
876
821
  continue;
877
- const source = await Bun.file(path6.join(this.#akanjsRoot, file)).text();
822
+ const source = await Bun.file(path5.join(this.#akanjsRoot, file)).text();
878
823
  const names = new Bun.Transpiler({ loader: "ts" }).scan(source).exports;
879
824
  if (!names.some((name) => used.includes(name)))
880
825
  blanked.push(`akanjs/${file}`);
@@ -917,20 +862,31 @@ class SsrBaseArtifactBuilder {
917
862
  this.#serverEnv = serverEnv;
918
863
  this.#vendorExports = vendorExports;
919
864
  this.#artifactDir = `${command === "build" ? app.dist.cwdPath : app.cwdPath}/.akan/artifact`;
920
- this.#absArtifactDir = path7.resolve(this.#artifactDir);
865
+ this.#absArtifactDir = path6.resolve(this.#artifactDir);
921
866
  }
922
867
  static servedWeb(command, web) {
923
868
  return command === "start" ? { ssr: true, csr: true } : web;
924
869
  }
925
870
  async build() {
926
871
  const akanConfig = await this.#app.getConfig();
927
- const { rscClientUrl, rscRuntimeClientManifest, rscRuntimeSsrManifest, vendorMap, runtimeChunks } = await this.#buildRuntimeClientEntries();
928
- const pageKeys = await this.#app.getPageKeys();
929
- this.#app.verbose(`[base-artifact] discovered ${pageKeys.length} route files under ${this.#app.cwdPath}/page`);
930
- const pageEntries = await resolveSsrPageEntriesForApp(this.#app, pageKeys);
931
- const { cssCompiler, optimizedFonts, cssAssets } = await this.#buildStyleAssets();
932
- const dictAssets = await new DictionaryAssetBuilder(this.#app, this.#absArtifactDir).build(akanConfig.i18n);
933
- const pagesBundle = await new PagesBundleBuilder(this.#app, this.#command, pageEntries, this.#serverEnv).build();
872
+ const phaseMs = { runtime: 0, routes: 0, styles: 0, dictionary: 0, pages: 0, total: 0 };
873
+ const timed = async (phase, run) => {
874
+ const started = performance.now();
875
+ try {
876
+ return await run();
877
+ } finally {
878
+ phaseMs[phase] = Math.round(performance.now() - started);
879
+ }
880
+ };
881
+ const { rscClientUrl, rscRuntimeClientManifest, rscRuntimeSsrManifest, vendorMap, runtimeChunks } = await timed("runtime", () => this.#buildRuntimeClientEntries());
882
+ const pageEntries = await timed("routes", async () => {
883
+ const pageKeys = await this.#app.getPageKeys();
884
+ this.#app.verbose(`[base-artifact] discovered ${pageKeys.length} route files under ${this.#app.cwdPath}/page`);
885
+ return await resolveSsrPageEntriesForApp(this.#app, pageKeys);
886
+ });
887
+ const { cssCompiler, optimizedFonts, cssAssets } = await timed("styles", () => this.#buildStyleAssets());
888
+ const dictAssets = await timed("dictionary", () => new DictionaryAssetBuilder(this.#app, this.#absArtifactDir).build(akanConfig.i18n));
889
+ const pagesBundle = await timed("pages", () => new PagesBundleBuilder(this.#app, this.#command, pageEntries, this.#serverEnv).build());
934
890
  this.#app.verbose(`[base-artifact] pages bundle -> ${pagesBundle.bundlePath} (buildId=${pagesBundle.buildId}, splitting=${pagesBundle.splitting}, entry=${pagesBundle.entryBytes} bytes, outputs=${pagesBundle.outputCount}, chunks=${pagesBundle.chunkCount}, total=${pagesBundle.outputBytes} bytes)`);
935
891
  const seedIndex = computeRouteSeedIndex(pageEntries);
936
892
  const seedIndexPath = await saveRouteSeedIndex(this.#absArtifactDir, seedIndex, {
@@ -944,7 +900,7 @@ class SsrBaseArtifactBuilder {
944
900
  vendorMap,
945
901
  cssAssets,
946
902
  dictAssets,
947
- pagesBundlePath: this.#command === "build" ? path7.relative(this.#absArtifactDir, pagesBundle.bundlePath) : pagesBundle.bundlePath,
903
+ pagesBundlePath: this.#command === "build" ? path6.relative(this.#absArtifactDir, pagesBundle.bundlePath) : pagesBundle.bundlePath,
948
904
  pagesBundleBuildId: pagesBundle.buildId,
949
905
  domains: [...akanConfig.domains],
950
906
  subRoutes: Object.fromEntries(Array.from(akanConfig.subRoutes.entries()).map(([basePath, domains]) => [basePath, [...domains]])),
@@ -962,18 +918,24 @@ class SsrBaseArtifactBuilder {
962
918
  androidSha256CertFingerprints: target.android?.sha256CertFingerprints
963
919
  }))
964
920
  };
965
- await Bun.write(path7.join(this.#absArtifactDir, "base-artifact.json"), `${JSON.stringify(artifact, null, 2)}
921
+ await SsrBaseArtifactBuilder.writeArtifact(this.#absArtifactDir, artifact);
922
+ phaseMs.total = Date.now() - this.#started;
923
+ this.#app.verbose(`[base-artifact] complete in ${phaseMs.total}ms`);
924
+ return { artifact, seedIndex, cssCompiler, optimizedFonts, runtimeChunks, phaseMs };
925
+ }
926
+ static async writeArtifact(absArtifactDir, artifact) {
927
+ const artifactPath = path6.join(absArtifactDir, "base-artifact.json");
928
+ await Bun.write(`${artifactPath}.tmp`, `${JSON.stringify(artifact, null, 2)}
966
929
  `);
967
- this.#app.verbose(`[base-artifact] complete in ${Date.now() - this.#started}ms`);
968
- return { artifact, seedIndex, cssCompiler, optimizedFonts, runtimeChunks };
930
+ await rename(`${artifactPath}.tmp`, artifactPath);
969
931
  }
970
932
  async#buildRuntimeClientEntries() {
971
933
  const akanServerPath = await this.#resolveAkanServerPath();
972
- const rscClientEntry = path7.resolve(akanServerPath, "rscClient.tsx");
973
- const rscSegmentOutletEntry = path7.resolve(akanServerPath, "rscSegmentOutlet.tsx");
934
+ const rscClientEntry = path6.resolve(akanServerPath, "rscClient.tsx");
935
+ const rscSegmentOutletEntry = path6.resolve(akanServerPath, "rscSegmentOutlet.tsx");
974
936
  const vendorEntries = VendorNarrowing.entriesIn(akanServerPath);
975
937
  const entries = [rscClientEntry, rscSegmentOutletEntry, ...vendorEntries.map((v) => v.absPath)];
976
- const narrowing = new VendorNarrowing(path7.dirname(akanServerPath), this.#vendorExports);
938
+ const narrowing = new VendorNarrowing(path6.dirname(akanServerPath), this.#vendorExports);
977
939
  const clientBundle = await new ClientEntriesBundler({
978
940
  app: this.#app,
979
941
  entries,
@@ -1024,15 +986,15 @@ class SsrBaseArtifactBuilder {
1024
986
  async#resolveAkanServerPath() {
1025
987
  const candidates = [];
1026
988
  try {
1027
- candidates.push(path7.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
989
+ candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
1028
990
  } catch {}
1029
- candidates.push(path7.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"), path7.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"));
991
+ candidates.push(path6.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"), path6.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"));
1030
992
  try {
1031
- candidates.push(path7.dirname(Bun.resolveSync("akanjs/server", path7.dirname(Bun.main))));
993
+ candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", path6.dirname(Bun.main))));
1032
994
  } catch {}
1033
- candidates.push(path7.join(path7.dirname(Bun.main), "node_modules/akanjs/server"), path7.join(path7.dirname(Bun.main), "../../akanjs/server"), path7.resolve(import.meta.dir, "../../server"), path7.resolve(import.meta.dir, "../server"));
995
+ candidates.push(path6.join(path6.dirname(Bun.main), "node_modules/akanjs/server"), path6.join(path6.dirname(Bun.main), "../../akanjs/server"), path6.resolve(import.meta.dir, "../../server"), path6.resolve(import.meta.dir, "../server"));
1034
996
  for (const candidate of candidates) {
1035
- if (await Bun.file(path7.join(candidate, "rscClient.tsx")).exists())
997
+ if (await Bun.file(path6.join(candidate, "rscClient.tsx")).exists())
1036
998
  return candidate;
1037
999
  }
1038
1000
  throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
@@ -1061,7 +1023,7 @@ ${preparedCssText}`).toString(36);
1061
1023
  `styles/${cssAssetName}-${cssHash}.css`,
1062
1024
  `/_akan/styles/${cssAssetName}-${cssHash}.css`
1063
1025
  ];
1064
- await Bun.write(path7.join(this.#absArtifactDir, cssRelPath), preparedCssText);
1026
+ await Bun.write(path6.join(this.#absArtifactDir, cssRelPath), preparedCssText);
1065
1027
  SsrBaseArtifactBuilder.#warnDroppedImports(this.#app, cssRelPath, preparedCssText, imported);
1066
1028
  this.#app.verbose(`[base-artifact] wrote ${preparedCssText.length} bytes of CSS for ${basePath} -> ${cssRelPath}`);
1067
1029
  return [basePath, { cssUrl, cssRelPath }];
@@ -1078,8 +1040,8 @@ ${preparedCssText}`).toString(36);
1078
1040
  }
1079
1041
  }
1080
1042
  // pkgs/@akanjs/devkit/frontendBuild/vendorImportScanner.ts
1081
- import fs3 from "fs";
1082
- import path8 from "path";
1043
+ import fs2 from "fs";
1044
+ import path7 from "path";
1083
1045
  import ts from "typescript";
1084
1046
 
1085
1047
  class VendorImportScanner {
@@ -1094,10 +1056,10 @@ class VendorImportScanner {
1094
1056
  static async exportsUsedIn(dir, specifiers, entryUrls) {
1095
1057
  const scanner = new VendorImportScanner(specifiers);
1096
1058
  const scanned = [];
1097
- if (fs3.existsSync(dir))
1059
+ if (fs2.existsSync(dir))
1098
1060
  for await (const relative of new Bun.Glob("**/*.js").scan({ cwd: dir })) {
1099
- scanner.scan(await Bun.file(path8.join(dir, relative)).text(), relative);
1100
- scanned.push(`/${relative.split(path8.sep).join("/")}`);
1061
+ scanner.scan(await Bun.file(path7.join(dir, relative)).text(), relative);
1062
+ scanned.push(`/${relative.split(path7.sep).join("/")}`);
1101
1063
  }
1102
1064
  const unread = [...new Set(entryUrls)].filter((url) => !scanned.some((relative) => url.endsWith(relative)));
1103
1065
  if (unread.length > 0) {
@@ -1172,4 +1134,4 @@ class VendorImportScanner {
1172
1134
  this.#names.get(specifier)?.add(name);
1173
1135
  }
1174
1136
  }
1175
- export { AllRoutesBuilder, CssCompiler, precompressArtifacts, SsrBaseArtifactBuilder, VendorImportScanner };
1137
+ export { AllRoutesBuilder, CssCompiler, SsrBaseArtifactBuilder, VendorImportScanner };
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import {
3
3
  JsonFormatter
4
- } from "./index-3ghdb7p5.js";
4
+ } from "./index-pc42gxa5.js";
5
5
 
6
- // pkgs/@akanjs/devkit/maintainabilityBaseline.ts
6
+ // pkgs/@akanjs/devkit/quality/maintainabilityBaseline.ts
7
7
  class MaintainabilityBaseline {
8
8
  sections;
9
9
  reasons;
@@ -19,8 +19,12 @@ class MaintainabilityBaseline {
19
19
  "akan.store.root-write-chain",
20
20
  "akan.component.write-chain",
21
21
  "akan.write.placement",
22
- "akan.service.call-in-loop"
22
+ "akan.service.call-in-loop",
23
+ "akan.error.bare-error"
23
24
  ];
25
+ static lateRules = new Set(["akan.error.bare-error"]);
26
+ static totalRules = new Set(["akan.error.bare-error"]);
27
+ static totalKey = "(total)";
24
28
  static reasonedRules = new Set([
25
29
  "akan.size.file",
26
30
  "akan.size.component",
@@ -40,6 +44,8 @@ class MaintainabilityBaseline {
40
44
  return violation.writeCount;
41
45
  if (violation.kind === "writePlacement")
42
46
  return violation.writes.length;
47
+ if (violation.kind === "bareError")
48
+ return violation.lines.length;
43
49
  return violation.calls.length;
44
50
  }
45
51
  static isDebtRule(name) {
@@ -97,6 +103,21 @@ class MaintainabilityBaseline {
97
103
  const recorded = this.recordedOf(violation);
98
104
  return recorded !== undefined && MaintainabilityBaseline.countOf(violation) <= recorded;
99
105
  }
106
+ unallowed(violations) {
107
+ const measured = MaintainabilityBaseline.of(violations);
108
+ return violations.filter((violation) => !(MaintainabilityBaseline.totalRules.has(violation.rule) && measured.totalOf(violation.rule) <= this.totalOf(violation.rule)) && !this.allows(violation));
109
+ }
110
+ staleTotals(violations) {
111
+ const measured = MaintainabilityBaseline.of(violations);
112
+ return [...MaintainabilityBaseline.totalRules].flatMap((rule) => {
113
+ const count = measured.totalOf(rule);
114
+ const recorded = this.totalOf(rule);
115
+ return count < recorded ? [{ rule, count, recorded }] : [];
116
+ });
117
+ }
118
+ totalOf(rule) {
119
+ return [...this.sections.get(rule)?.values() ?? []].reduce((sum, count) => sum + count, 0);
120
+ }
100
121
  recordedOf(violation) {
101
122
  return this.sections.get(violation.rule)?.get(violation.key);
102
123
  }
@@ -114,19 +135,55 @@ class MaintainabilityBaseline {
114
135
  }))
115
136
  ]));
116
137
  }
138
+ rulesOutside(other) {
139
+ return [...this.sections].filter(([rule, counts]) => counts.size && (other === null || MaintainabilityBaseline.lateRules.has(rule) && !other.sections.has(rule))).map(([rule]) => rule);
140
+ }
141
+ withSectionsOf(other, rules) {
142
+ if (!other)
143
+ return this;
144
+ const sections = new Map(this.sections);
145
+ for (const rule of rules)
146
+ sections.set(rule, other.sections.get(rule) ?? new Map);
147
+ return new MaintainabilityBaseline(sections, this.reasons);
148
+ }
149
+ movedBy(moves) {
150
+ if (!moves.size)
151
+ return this;
152
+ const movedKey = (key) => {
153
+ const file = key.split("#", 1)[0] ?? key;
154
+ const to = moves.get(file);
155
+ return to === undefined ? key : `${to}${key.slice(file.length)}`;
156
+ };
157
+ const sections = new Map([...this.sections].map(([rule, counts]) => {
158
+ const moved = new Map;
159
+ for (const [key, count] of counts) {
160
+ const to = movedKey(key);
161
+ moved.set(to, Math.max(moved.get(to) ?? 0, count));
162
+ }
163
+ return [rule, moved];
164
+ }));
165
+ return new MaintainabilityBaseline(sections, new Map([...this.reasons].map(([key, reason]) => [movedKey(key), reason])));
166
+ }
117
167
  tightenedBy(violations) {
118
168
  const current = MaintainabilityBaseline.of(violations);
119
- const sections = new Map([...this.sections].map(([rule, counts]) => [
120
- rule,
121
- MaintainabilityBaseline.#lowered(counts, current.sections.get(rule) ?? new Map)
122
- ]));
169
+ const sections = new Map([...this.sections].map(([rule, counts]) => {
170
+ const measured = current.sections.get(rule) ?? new Map;
171
+ if (!MaintainabilityBaseline.totalRules.has(rule))
172
+ return [rule, MaintainabilityBaseline.#lowered(counts, measured)];
173
+ return [rule, current.totalOf(rule) > this.totalOf(rule) ? counts : measured];
174
+ }));
123
175
  return new MaintainabilityBaseline(sections).#withReasonsOf(this.reasons);
124
176
  }
125
177
  #withReasonsOf(reasons) {
126
178
  return new MaintainabilityBaseline(this.sections, new Map([...reasons].filter(([key]) => this.#holdsReasoned(key))));
127
179
  }
128
180
  grownFrom(committed) {
129
- return [...this.sections].flatMap(([rule, counts]) => MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map).filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key))).map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })));
181
+ return [...this.sections].flatMap(([rule, counts]) => MaintainabilityBaseline.totalRules.has(rule) ? this.#totalGrownFrom(committed, rule) : MaintainabilityBaseline.#raised(counts, committed.sections.get(rule) ?? new Map).filter(([key]) => !(MaintainabilityBaseline.reasonedRules.has(rule) && this.reasonOf(key))).map(([key, count, recorded]) => ({ rule, key, count, committed: recorded })));
182
+ }
183
+ #totalGrownFrom(committed, rule) {
184
+ const count = this.totalOf(rule);
185
+ const recorded = committed.sections.has(rule) ? committed.totalOf(rule) : undefined;
186
+ return count > (recorded ?? 0) ? [{ rule, key: MaintainabilityBaseline.totalKey, count, committed: recorded }] : [];
130
187
  }
131
188
  stringify() {
132
189
  const sections = MaintainabilityBaseline.debtRules.flatMap((rule) => {
@@ -0,0 +1,127 @@
1
+ // @bun
2
+ import {
3
+ execEmoji,
4
+ Executor,
5
+ PkgInfo,
6
+ WorkspaceExecutor
7
+ } from "./index-pc42gxa5.js";
8
+
9
+ // pkgs/@akanjs/devkit/executors/pkgExecutor.ts
10
+ import path from "path";
11
+ class PkgExecutor2 extends Executor {
12
+ workspace;
13
+ name;
14
+ dist;
15
+ emoji = execEmoji.pkg;
16
+ constructor({ workspace = WorkspaceExecutor.fromRoot(), name }) {
17
+ super(name, `${workspace.workspaceRoot}/pkgs/${name}`);
18
+ this.workspace = workspace;
19
+ this.name = name;
20
+ this.dist = new Executor(`dist/${name}`, `${this.workspace.workspaceRoot}/dist/pkgs/${name}`);
21
+ }
22
+ static from(executor, name) {
23
+ return new PkgExecutor2({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
24
+ }
25
+ #scanInfo = null;
26
+ async scan({ refresh } = {}) {
27
+ if (this.#scanInfo && !refresh)
28
+ return this.#scanInfo;
29
+ const scanInfo = await PkgInfo.fromExecutor(this, { refresh });
30
+ this.#scanInfo = scanInfo;
31
+ return scanInfo;
32
+ }
33
+ async#getDependencyVersion(rootPackageJson, dep) {
34
+ const rootDeps = {
35
+ ...rootPackageJson.dependencies,
36
+ ...rootPackageJson.devDependencies
37
+ };
38
+ const rootVersion = rootDeps[dep];
39
+ if (rootVersion)
40
+ return rootVersion;
41
+ const overrideVersion = rootPackageJson.overrides?.[dep];
42
+ if (typeof overrideVersion === "string")
43
+ return overrideVersion;
44
+ try {
45
+ const packageJsonPath = `pkgs/${dep}/package.json`;
46
+ if (!await Bun.file(path.join(this.workspace.workspaceRoot, packageJsonPath)).exists())
47
+ return;
48
+ const packageJson = await this.workspace.readJson(packageJsonPath);
49
+ if (packageJson.name === dep)
50
+ return packageJson.version;
51
+ } catch {
52
+ return;
53
+ }
54
+ }
55
+ async#toDependencyMap(rootPackageJson, dependencies = [], devDependencies = []) {
56
+ const dependencyNames = [...new Set(dependencies)].sort();
57
+ const devDependencyNames = [...new Set(devDependencies)].filter((dep) => !dependencyNames.includes(dep)).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
58
+ const dependencyVersions = new Map;
59
+ const missingDeps = [];
60
+ for (const dep of [...dependencyNames, ...devDependencyNames]) {
61
+ const version = await this.#getDependencyVersion(rootPackageJson, dep);
62
+ if (version)
63
+ dependencyVersions.set(dep, version);
64
+ else
65
+ missingDeps.push(dep);
66
+ }
67
+ if (missingDeps.length > 0)
68
+ throw new Error(`Missing dependency versions in root package.json: ${missingDeps.join(", ")}`);
69
+ const toDependencyMap = (names) => Object.fromEntries(names.map((dep) => [dep, dependencyVersions.get(dep)]));
70
+ return { dependencies: toDependencyMap(dependencyNames), devDependencies: toDependencyMap(devDependencyNames) };
71
+ }
72
+ async updatePackageJsonDependencies(dependencies = [], devDependencies = []) {
73
+ const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);
74
+ const dependencyMaps = await this.#toDependencyMap(rootPackageJson, dependencies, devDependencies);
75
+ const newPkgJson = {
76
+ ...pkgJson,
77
+ ...dependencyMaps
78
+ };
79
+ await this.writeJson("package.json", newPkgJson);
80
+ return newPkgJson;
81
+ }
82
+ async generateDistPackageJson(dependencies = [], devDependencies = []) {
83
+ const [rootPackageJson, pkgJson] = await Promise.all([this.workspace.getPackageJson(), this.getPackageJson()]);
84
+ const dependencyMaps = await this.#toDependencyMap(rootPackageJson, dependencies, devDependencies);
85
+ const distPkgJson = {
86
+ ...pkgJson,
87
+ type: "module",
88
+ exports: {
89
+ ...pkgJson.exports,
90
+ ".": {
91
+ import: "./index.ts",
92
+ types: "./index.ts",
93
+ default: "./index.ts"
94
+ }
95
+ },
96
+ engines: { bun: ">=1.4.4" },
97
+ ...dependencyMaps
98
+ };
99
+ await Promise.all([this.dist.writeJson("package.json", distPkgJson), this.writeJson("package.json", distPkgJson)]);
100
+ return distPkgJson;
101
+ }
102
+ async build() {
103
+ await Bun.build({
104
+ root: this.cwdPath,
105
+ entrypoints: [`${this.cwdPath}/index.ts`],
106
+ splitting: false,
107
+ target: "bun"
108
+ });
109
+ await this.cp(`${this.cwdPath}/dist`, this.dist.cwdPath);
110
+ }
111
+ async generateTsconfigJson() {
112
+ const [rootTsconfig, pkgTsconfig] = await Promise.all([this.workspace.getTsConfig(), this.getTsConfig()]);
113
+ const tsconfig = {
114
+ ...rootTsconfig,
115
+ ...pkgTsconfig,
116
+ compilerOptions: {
117
+ ...rootTsconfig.compilerOptions,
118
+ ...pkgTsconfig.compilerOptions,
119
+ paths: {}
120
+ }
121
+ };
122
+ await this.dist.writeJson("tsconfig.json", tsconfig);
123
+ return tsconfig;
124
+ }
125
+ }
126
+
127
+ export { PkgExecutor2 };