@akanjs/cli 3.2.0-rc.30 → 3.2.0-rc.32

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 (95) hide show
  1. package/.build-stamp +2 -2
  2. package/{CodeAgent-c17abdbf.js → CodeAgent-7m6cmdf8.js} +2 -2
  3. package/{CodeTui-jed1nj82.js → CodeTui-c6de37ea.js} +1 -1
  4. package/README.ko.md +7 -0
  5. package/README.md +7 -0
  6. package/TunnelShare-9ry4vh0y.js +18 -0
  7. package/{agent.command-9whnc6vb.js → agent.command-3qstwjef.js} +26 -21
  8. package/akanCode.js +2 -2
  9. package/{appExecutor-020cyesq.js → appExecutor-79azsb2w.js} +3 -3
  10. package/{application.command-4eqvyxkw.js → application.command-8y4kxzvc.js} +36 -24
  11. package/{applicationBuildRunner-frtcrqfd.js → applicationBuildRunner-trfxv3pd.js} +43 -15
  12. package/buildBatch.proc.js +10 -10
  13. package/{cloud.command-hbvmeezn.js → cloud.command-zczv575c.js} +28 -28
  14. package/cloud.script-t268m15f.js +35 -0
  15. package/{code.command-0ayrenk4.js → code.command-069wchwn.js} +10 -10
  16. package/context.command-v3e98f2h.js +64 -0
  17. package/context.runner-3jr6chgz.js +34 -0
  18. package/{guideline.command-w1grfwh7.js → guideline.command-zwypaqsh.js} +7 -7
  19. package/guidelines/akanApi/akanApi.instruction.md +1 -1
  20. package/guidelines/errorCodes/errorCodes.instruction.md +7 -0
  21. package/guidelines/mcpRule/mcpRule.instruction.md +155 -20
  22. package/guidelines/queryRule/queryRule.instruction.md +3 -1
  23. package/guidelines/runtimeRule/runtimeRule.instruction.md +7 -3
  24. package/guidelines/transportRule/transportRule.instruction.md +28 -0
  25. package/incrementalBuilder.proc.js +12 -9
  26. package/{index-5d57kx0s.js → index-275a4r3n.js} +3 -3
  27. package/{index-6zb17wcm.js → index-2jmvfa62.js} +3 -3
  28. package/{index-9rv2zt48.js → index-2yn3r67f.js} +78 -25
  29. package/{index-6pxmcaq8.js → index-3txdtztz.js} +1 -1
  30. package/{index-nm7nt9vm.js → index-4ss4gkv3.js} +2 -2
  31. package/{index-9wab2ngg.js → index-612fdtbk.js} +1 -1
  32. package/{index-7bs463x7.js → index-6dzjer7p.js} +6 -6
  33. package/{index-qssq2d41.js → index-71y6176j.js} +11 -6
  34. package/{index-4st0hq72.js → index-73x6z7ym.js} +24 -17
  35. package/{index-vjbne22r.js → index-7wf8snar.js} +1 -1
  36. package/{index-yvzm8mby.js → index-9wh04mqy.js} +1 -1
  37. package/{index-yxkjsyx8.js → index-a860mx0m.js} +2 -2
  38. package/{index-42jhx2ya.js → index-b2sdtgc7.js} +3 -3
  39. package/{index-1pjwsh2g.js → index-baccvws5.js} +1 -1
  40. package/{index-99kjwyma.js → index-c669pbyb.js} +4 -3
  41. package/{index-prgvqqxe.js → index-cd839jw2.js} +126 -113
  42. package/{index-6469101k.js → index-dadwp2aw.js} +33 -98
  43. package/{index-7v7tvgt7.js → index-dmcpetwe.js} +123 -43
  44. package/{index-ba2xd32s.js → index-e9w8wq0a.js} +27 -22
  45. package/{index-fp5xf6ef.js → index-ebn9kgea.js} +3 -3
  46. package/{index-s3m89wt2.js → index-exzkev4k.js} +7 -7
  47. package/{index-m5gg0wzv.js → index-gec8q5z9.js} +57 -30
  48. package/{index-m3t28rt3.js → index-gt8phqpt.js} +4 -4
  49. package/{index-g7jgd4xs.js → index-j592zfqc.js} +1 -1
  50. package/{index-cb91b6d8.js → index-jek2re5k.js} +3 -3
  51. package/{index-ffa52fwf.js → index-jf4vk1s0.js} +8 -1
  52. package/{index-v929w7j7.js → index-kykky4re.js} +59 -15
  53. package/{index-9wjrwjgz.js → index-nk374pqd.js} +8 -8
  54. package/{index-28nk8w3j.js → index-pk2ja04e.js} +8 -8
  55. package/{index-jgj31xvw.js → index-qcp6e2ht.js} +22 -5
  56. package/{index-at6haq2x.js → index-qyhr8wst.js} +61 -18
  57. package/{index-f16kr6vj.js → index-s885g0jj.js} +2 -2
  58. package/{index-bj8s07s7.js → index-t2zhw8c7.js} +4 -4
  59. package/{index-11d7nh8a.js → index-v7ajmsh3.js} +1 -1
  60. package/{index-dss3ds74.js → index-w1zexzpx.js} +1 -1
  61. package/{index-g45y5f3e.js → index-wzp3yg01.js} +1 -1
  62. package/{index-ze48c0vd.js → index-z92zm3wd.js} +2 -2
  63. package/{index-na8r4a27.js → index-zfnz878d.js} +1 -1
  64. package/{index-0gaj78wn.js → index-zmd9xxgd.js} +3 -3
  65. package/{index-p06kfhdf.js → index-zzebpyr0.js} +4 -4
  66. package/index.js +27 -27
  67. package/{libExecutor-tq994592.js → libExecutor-jc6f8hm6.js} +2 -2
  68. package/{library.command-x219mhcx.js → library.command-nxvesvhb.js} +11 -8
  69. package/{localRegistry.command-zvdcejhn.js → localRegistry.command-4a655xnq.js} +20 -20
  70. package/{module.command-k6cwcm7g.js → module.command-aaws9byg.js} +9 -9
  71. package/{package.command-vw7x09f8.js → package.command-j7hv26p0.js} +10 -10
  72. package/package.json +8 -8
  73. package/{page.command-gf06paq2.js → page.command-7yffs7n9.js} +7 -7
  74. package/{pipeline.command-y07dgj9b.js → pipeline.command-7yk0zcng.js} +8 -7
  75. package/{pkgExecutor-stde3yc3.js → pkgExecutor-arxmvx4t.js} +2 -2
  76. package/{primitive.command-edydvh07.js → primitive.command-7a1pt715.js} +10 -10
  77. package/{projectTypecheck-mk8wefvd.js → projectTypecheck-f4qhbecd.js} +1 -1
  78. package/{quality.command-mdb45vyr.js → quality.command-08bn42t4.js} +13 -10
  79. package/{repair.command-kvtaeecy.js → repair.command-r59jat74.js} +9 -9
  80. package/{scalar.command-sjt9p5e1.js → scalar.command-2ex84spb.js} +8 -8
  81. package/skills/akan-mcp/SKILL.md +9 -2
  82. package/skills/akan-validate/SKILL.md +3 -3
  83. package/{subspace.command-mkkqync4.js → subspace.command-2nxakmk3.js} +16 -13
  84. package/templates/workspaceRoot/.devcontainer/devcontainer.json.template +1 -1
  85. package/templates/workspaceRoot/README.ts +4 -2
  86. package/{tunnel.command-tr5b3030.js → tunnel.command-f7ep1qfa.js} +12 -12
  87. package/{typeChecker-bfrd1n9n.js → typeChecker-7jt6abrs.js} +1 -1
  88. package/typecheck.proc.js +3 -2
  89. package/{verify.command-0p9h8tpp.js → verify.command-xbztwp1r.js} +17 -17
  90. package/{workflow.command-9mfcwqzj.js → workflow.command-pmyx55y4.js} +18 -15
  91. package/{workspace.command-5hjtmcfs.js → workspace.command-89p90zvb.js} +36 -36
  92. package/TunnelShare-mbfcaqg0.js +0 -18
  93. package/cloud.script-9kmbr3d6.js +0 -35
  94. package/context.command-php852kf.js +0 -61
  95. package/context.runner-nngmn7c0.js +0 -34
@@ -3,7 +3,7 @@ import {
3
3
  ROOT_LAYOUT_SYSTEM,
4
4
  isImplicitRootLayoutKey,
5
5
  resolveSsrPageEntriesForApp
6
- } from "./index-ze48c0vd.js";
6
+ } from "./index-z92zm3wd.js";
7
7
  import {
8
8
  computeRouteSeedIndex,
9
9
  saveRouteSeedIndex,
@@ -11,12 +11,11 @@ import {
11
11
  ClientEntriesBundler,
12
12
  VENDOR_SPECIFIERS,
13
13
  RouteClientBuilder
14
- } from "./index-cb91b6d8.js";
14
+ } from "./index-jek2re5k.js";
15
15
  import {
16
16
  SOURCE_EXTS,
17
- FontOptimizer,
18
- FontPruner
19
- } from "./index-7v7tvgt7.js";
17
+ FontOptimizer
18
+ } from "./index-dmcpetwe.js";
20
19
  import {
21
20
  BarrelAnalyzer,
22
21
  createTsconfigPackageResolver,
@@ -24,7 +23,7 @@ import {
24
23
  CsrEntryFiles,
25
24
  toClientReferencePath,
26
25
  PagesBundleBuilder
27
- } from "./index-yvzm8mby.js";
26
+ } from "./index-9wh04mqy.js";
28
27
  import {
29
28
  CssBlockParser
30
29
  } from "./index-62md4dwy.js";
@@ -734,76 +733,12 @@ function declaredCustomProperties(css) {
734
733
  function getPageKeyBasePath(pageKey, basePaths) {
735
734
  return CsrEntryFiles.basePathOfPageKey(pageKey, basePaths);
736
735
  }
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
736
  // pkgs/@akanjs/devkit/frontendBuild/ssrBaseArtifactBuilder.ts
802
- import path7 from "path";
737
+ import path6 from "path";
803
738
  import { optimize } from "@tailwindcss/node";
804
739
 
805
740
  // pkgs/@akanjs/devkit/frontendBuild/dictionaryAssetBuilder.ts
806
- import path5 from "path";
741
+ import path4 from "path";
807
742
  import { Translator } from "akanjs/client";
808
743
 
809
744
  class DictionaryAssetBuilder {
@@ -823,7 +758,7 @@ class DictionaryAssetBuilder {
823
758
  return Object.fromEntries(assets);
824
759
  }
825
760
  async#loadAllDictionary() {
826
- const dictPath = path5.resolve(this.#app.cwdPath, "lib", "dict.ts");
761
+ const dictPath = path4.resolve(this.#app.cwdPath, "lib", "dict.ts");
827
762
  if (!await Bun.file(dictPath).exists())
828
763
  return null;
829
764
  const { getAllDictionary } = await import(dictPath);
@@ -833,7 +768,7 @@ class DictionaryAssetBuilder {
833
768
  const source = DictionaryAssetBuilder.source(lang, dictionary);
834
769
  const name = `${lang}-${Bun.hash(source).toString(36)}.js`;
835
770
  const relPath = `dict/${name}`;
836
- await Bun.write(path5.join(this.#absArtifactDir, relPath), source);
771
+ await Bun.write(path4.join(this.#absArtifactDir, relPath), source);
837
772
  return [lang, { url: `${DictionaryAssetBuilder.urlPrefix}/${name}`, relPath }];
838
773
  }
839
774
  static source(lang, dictionary) {
@@ -844,8 +779,8 @@ export default JSON.parse(${JSON.stringify(JSON.stringify(dictionary))});
844
779
  }
845
780
 
846
781
  // pkgs/@akanjs/devkit/frontendBuild/vendorNarrowing.ts
847
- import fs2 from "fs";
848
- import path6 from "path";
782
+ import fs from "fs";
783
+ import path5 from "path";
849
784
  var deprecatedReexports = { "akanjs/store": "store/deprecatedAgent.ts" };
850
785
 
851
786
  class VendorNarrowing {
@@ -854,12 +789,12 @@ class VendorNarrowing {
854
789
  static entriesIn(akanServerPath) {
855
790
  return VENDOR_SPECIFIERS.map((specifier) => ({
856
791
  specifier,
857
- absPath: path6.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`)
858
- })).filter(({ absPath }) => fs2.existsSync(absPath));
792
+ absPath: path5.resolve(akanServerPath, "vendor", `${specifier.replaceAll("/", "-").replaceAll(".", "-")}.ts`)
793
+ })).filter(({ absPath }) => fs.existsSync(absPath));
859
794
  }
860
795
  constructor(akanjsRoot, vendorExports) {
861
796
  this.#akanjsRoot = akanjsRoot;
862
- const current = Object.values(deprecatedReexports).every((file) => fs2.existsSync(path6.join(akanjsRoot, file)));
797
+ const current = Object.values(deprecatedReexports).every((file) => fs.existsSync(path5.join(akanjsRoot, file)));
863
798
  this.#vendorExports = current ? vendorExports : {};
864
799
  }
865
800
  entryExports(vendorEntries) {
@@ -874,7 +809,7 @@ class VendorNarrowing {
874
809
  const used = this.#vendorExports[specifier];
875
810
  if (!used)
876
811
  continue;
877
- const source = await Bun.file(path6.join(this.#akanjsRoot, file)).text();
812
+ const source = await Bun.file(path5.join(this.#akanjsRoot, file)).text();
878
813
  const names = new Bun.Transpiler({ loader: "ts" }).scan(source).exports;
879
814
  if (!names.some((name) => used.includes(name)))
880
815
  blanked.push(`akanjs/${file}`);
@@ -917,7 +852,7 @@ class SsrBaseArtifactBuilder {
917
852
  this.#serverEnv = serverEnv;
918
853
  this.#vendorExports = vendorExports;
919
854
  this.#artifactDir = `${command === "build" ? app.dist.cwdPath : app.cwdPath}/.akan/artifact`;
920
- this.#absArtifactDir = path7.resolve(this.#artifactDir);
855
+ this.#absArtifactDir = path6.resolve(this.#artifactDir);
921
856
  }
922
857
  static servedWeb(command, web) {
923
858
  return command === "start" ? { ssr: true, csr: true } : web;
@@ -944,7 +879,7 @@ class SsrBaseArtifactBuilder {
944
879
  vendorMap,
945
880
  cssAssets,
946
881
  dictAssets,
947
- pagesBundlePath: this.#command === "build" ? path7.relative(this.#absArtifactDir, pagesBundle.bundlePath) : pagesBundle.bundlePath,
882
+ pagesBundlePath: this.#command === "build" ? path6.relative(this.#absArtifactDir, pagesBundle.bundlePath) : pagesBundle.bundlePath,
948
883
  pagesBundleBuildId: pagesBundle.buildId,
949
884
  domains: [...akanConfig.domains],
950
885
  subRoutes: Object.fromEntries(Array.from(akanConfig.subRoutes.entries()).map(([basePath, domains]) => [basePath, [...domains]])),
@@ -962,18 +897,18 @@ class SsrBaseArtifactBuilder {
962
897
  androidSha256CertFingerprints: target.android?.sha256CertFingerprints
963
898
  }))
964
899
  };
965
- await Bun.write(path7.join(this.#absArtifactDir, "base-artifact.json"), `${JSON.stringify(artifact, null, 2)}
900
+ await Bun.write(path6.join(this.#absArtifactDir, "base-artifact.json"), `${JSON.stringify(artifact, null, 2)}
966
901
  `);
967
902
  this.#app.verbose(`[base-artifact] complete in ${Date.now() - this.#started}ms`);
968
903
  return { artifact, seedIndex, cssCompiler, optimizedFonts, runtimeChunks };
969
904
  }
970
905
  async#buildRuntimeClientEntries() {
971
906
  const akanServerPath = await this.#resolveAkanServerPath();
972
- const rscClientEntry = path7.resolve(akanServerPath, "rscClient.tsx");
973
- const rscSegmentOutletEntry = path7.resolve(akanServerPath, "rscSegmentOutlet.tsx");
907
+ const rscClientEntry = path6.resolve(akanServerPath, "rscClient.tsx");
908
+ const rscSegmentOutletEntry = path6.resolve(akanServerPath, "rscSegmentOutlet.tsx");
974
909
  const vendorEntries = VendorNarrowing.entriesIn(akanServerPath);
975
910
  const entries = [rscClientEntry, rscSegmentOutletEntry, ...vendorEntries.map((v) => v.absPath)];
976
- const narrowing = new VendorNarrowing(path7.dirname(akanServerPath), this.#vendorExports);
911
+ const narrowing = new VendorNarrowing(path6.dirname(akanServerPath), this.#vendorExports);
977
912
  const clientBundle = await new ClientEntriesBundler({
978
913
  app: this.#app,
979
914
  entries,
@@ -1024,15 +959,15 @@ class SsrBaseArtifactBuilder {
1024
959
  async#resolveAkanServerPath() {
1025
960
  const candidates = [];
1026
961
  try {
1027
- candidates.push(path7.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
962
+ candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", this.#app.workspace.workspaceRoot)));
1028
963
  } catch {}
1029
- candidates.push(path7.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"), path7.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"));
964
+ candidates.push(path6.join(this.#app.workspace.workspaceRoot, "pkgs/akanjs/server"), path6.join(this.#app.workspace.workspaceRoot, "node_modules/akanjs/server"));
1030
965
  try {
1031
- candidates.push(path7.dirname(Bun.resolveSync("akanjs/server", path7.dirname(Bun.main))));
966
+ candidates.push(path6.dirname(Bun.resolveSync("akanjs/server", path6.dirname(Bun.main))));
1032
967
  } 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"));
968
+ 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
969
  for (const candidate of candidates) {
1035
- if (await Bun.file(path7.join(candidate, "rscClient.tsx")).exists())
970
+ if (await Bun.file(path6.join(candidate, "rscClient.tsx")).exists())
1036
971
  return candidate;
1037
972
  }
1038
973
  throw new Error(`[base-artifact] failed to locate akanjs/server; looked in: ${candidates.join(", ")}`);
@@ -1061,7 +996,7 @@ ${preparedCssText}`).toString(36);
1061
996
  `styles/${cssAssetName}-${cssHash}.css`,
1062
997
  `/_akan/styles/${cssAssetName}-${cssHash}.css`
1063
998
  ];
1064
- await Bun.write(path7.join(this.#absArtifactDir, cssRelPath), preparedCssText);
999
+ await Bun.write(path6.join(this.#absArtifactDir, cssRelPath), preparedCssText);
1065
1000
  SsrBaseArtifactBuilder.#warnDroppedImports(this.#app, cssRelPath, preparedCssText, imported);
1066
1001
  this.#app.verbose(`[base-artifact] wrote ${preparedCssText.length} bytes of CSS for ${basePath} -> ${cssRelPath}`);
1067
1002
  return [basePath, { cssUrl, cssRelPath }];
@@ -1078,8 +1013,8 @@ ${preparedCssText}`).toString(36);
1078
1013
  }
1079
1014
  }
1080
1015
  // pkgs/@akanjs/devkit/frontendBuild/vendorImportScanner.ts
1081
- import fs3 from "fs";
1082
- import path8 from "path";
1016
+ import fs2 from "fs";
1017
+ import path7 from "path";
1083
1018
  import ts from "typescript";
1084
1019
 
1085
1020
  class VendorImportScanner {
@@ -1094,10 +1029,10 @@ class VendorImportScanner {
1094
1029
  static async exportsUsedIn(dir, specifiers, entryUrls) {
1095
1030
  const scanner = new VendorImportScanner(specifiers);
1096
1031
  const scanned = [];
1097
- if (fs3.existsSync(dir))
1032
+ if (fs2.existsSync(dir))
1098
1033
  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("/")}`);
1034
+ scanner.scan(await Bun.file(path7.join(dir, relative)).text(), relative);
1035
+ scanned.push(`/${relative.split(path7.sep).join("/")}`);
1101
1036
  }
1102
1037
  const unread = [...new Set(entryUrls)].filter((url) => !scanned.some((relative) => url.endsWith(relative)));
1103
1038
  if (unread.length > 0) {
@@ -1172,4 +1107,4 @@ class VendorImportScanner {
1172
1107
  this.#names.get(specifier)?.add(name);
1173
1108
  }
1174
1109
  }
1175
- export { AllRoutesBuilder, CssCompiler, precompressArtifacts, SsrBaseArtifactBuilder, VendorImportScanner };
1110
+ export { AllRoutesBuilder, CssCompiler, SsrBaseArtifactBuilder, VendorImportScanner };
@@ -1,16 +1,16 @@
1
1
  // @bun
2
2
  import {
3
3
  ErrorReport
4
- } from "./index-vjbne22r.js";
4
+ } from "./index-7wf8snar.js";
5
5
  import {
6
6
  JsonFormatter
7
- } from "./index-qssq2d41.js";
7
+ } from "./index-71y6176j.js";
8
8
 
9
9
  // pkgs/@akanjs/devkit/app/applicationBuildReporter.ts
10
10
  import { Logger } from "akanjs/common";
11
11
 
12
12
  // pkgs/@akanjs/devkit/app/routeJsBudget.ts
13
- import path3 from "path";
13
+ import path4 from "path";
14
14
  import { toError } from "akanjs/common";
15
15
 
16
16
  // pkgs/@akanjs/devkit/frontendBuild/fontPruner.ts
@@ -669,6 +669,84 @@ class FontPruner {
669
669
  }
670
670
  }
671
671
 
672
+ // pkgs/@akanjs/devkit/frontendBuild/precompressArtifacts.ts
673
+ import fs from "fs";
674
+ import path3 from "path";
675
+ import zlib from "zlib";
676
+ var COMPRESSIBLE_EXTS = new Set([".css", ".html", ".js", ".json", ".svg"]);
677
+ var MIN_COMPRESS_BYTES = 1024;
678
+ var MAX_BROTLI_QUALITY = 11;
679
+ var BROTLI_QUALITY_BY_EXT = { ".css": MAX_BROTLI_QUALITY };
680
+ var DEFAULT_BROTLI_QUALITY = 9;
681
+ var GZIP_LEVEL = 9;
682
+ var ROOT_BROTLI_QUALITY = {
683
+ client: undefined,
684
+ styles: undefined,
685
+ dict: MAX_BROTLI_QUALITY
686
+ };
687
+ var { formatBytes } = FontPruner;
688
+ async function precompressArtifacts(app) {
689
+ const artifactDir = path3.join(app.dist.cwdPath, ".akan/artifact");
690
+ const roots = Object.entries(ROOT_BROTLI_QUALITY).map(([dir, brotliQuality]) => ({
691
+ root: path3.join(artifactDir, dir),
692
+ brotliQuality
693
+ }));
694
+ const result = { files: 0, inputBytes: 0, outputBytes: 0, brotliBytes: 0 };
695
+ await Promise.all(roots.map(({ root, brotliQuality }) => precompressRoot(root, result, brotliQuality)));
696
+ if (result.files > 0) {
697
+ app.verbose(`[precompress] wrote ${result.files} sidecars (${formatBytes(result.inputBytes)} -> gzip ${formatBytes(result.outputBytes)} / br ${formatBytes(result.brotliBytes)})`);
698
+ }
699
+ return result;
700
+ }
701
+ async function precompressRoot(root, result, brotliQuality) {
702
+ if (!fs.existsSync(root) || !fs.statSync(root).isDirectory())
703
+ return;
704
+ const glob = new Bun.Glob("**/*");
705
+ for await (const filePath of glob.scan({ cwd: root, absolute: true })) {
706
+ if (!await shouldPrecompress(filePath))
707
+ continue;
708
+ const bytes = await Bun.file(filePath).bytes();
709
+ const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
710
+ const gz = Bun.gzipSync(buffer, { level: GZIP_LEVEL });
711
+ const br = brotliCompress(buffer, brotliQuality ?? brotliQualityOf(path3.extname(filePath).toLowerCase()));
712
+ await Promise.all([Bun.write(`${filePath}.gz`, gz), Bun.write(`${filePath}.br`, br)]);
713
+ result.files += 1;
714
+ result.inputBytes += bytes.byteLength;
715
+ result.outputBytes += gz.byteLength;
716
+ result.brotliBytes += br.byteLength;
717
+ }
718
+ }
719
+ async function servedBrotliBytesOf(artifactDir, filePath) {
720
+ const root = path3.relative(artifactDir, filePath).split(path3.sep)[0] ?? "";
721
+ if (!Object.hasOwn(ROOT_BROTLI_QUALITY, root) || !await shouldPrecompress(filePath))
722
+ return Bun.file(filePath).size;
723
+ const bytes = await Bun.file(filePath).bytes();
724
+ const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
725
+ const quality = ROOT_BROTLI_QUALITY[root] ?? brotliQualityOf(path3.extname(filePath).toLowerCase());
726
+ return brotliCompress(buffer, quality).byteLength;
727
+ }
728
+ function brotliQualityOf(ext) {
729
+ return BROTLI_QUALITY_BY_EXT[ext] ?? DEFAULT_BROTLI_QUALITY;
730
+ }
731
+ function brotliCompress(buffer, quality) {
732
+ return zlib.brotliCompressSync(buffer, {
733
+ params: {
734
+ [zlib.constants.BROTLI_PARAM_QUALITY]: quality,
735
+ [zlib.constants.BROTLI_PARAM_SIZE_HINT]: buffer.byteLength
736
+ }
737
+ });
738
+ }
739
+ async function shouldPrecompress(filePath) {
740
+ if (filePath.endsWith(".gz") || filePath.endsWith(".br"))
741
+ return false;
742
+ if (!COMPRESSIBLE_EXTS.has(path3.extname(filePath).toLowerCase()))
743
+ return false;
744
+ const file = Bun.file(filePath);
745
+ if (!await file.exists())
746
+ return false;
747
+ return file.size >= MIN_COMPRESS_BYTES;
748
+ }
749
+
672
750
  // pkgs/@akanjs/devkit/app/routeJsBudget.ts
673
751
  class RouteJsBudget {
674
752
  kbByRoute;
@@ -678,11 +756,13 @@ class RouteJsBudget {
678
756
  static tableRows = 10;
679
757
  static #relativeSlack = 0.01;
680
758
  static #absoluteSlack = 4096;
681
- static async measure(artifactDir, modulesByRoute) {
759
+ static async measure(artifactDir, modulesByRoute, { precompressed = true } = {}) {
682
760
  const sizeByUrl = new Map;
683
761
  const sizeOf = async (url) => {
684
- const file = path3.join(artifactDir, url.replace(/^\/_akan\//, ""));
762
+ const file = path4.join(artifactDir, url.replace(/^\/_akan\//, ""));
685
763
  const raw = Bun.file(file).size;
764
+ if (!precompressed)
765
+ return { raw, brotli: await servedBrotliBytesOf(artifactDir, file) };
686
766
  const sidecar = Bun.file(`${file}.br`);
687
767
  return { raw, brotli: await sidecar.exists() ? sidecar.size : raw };
688
768
  };
@@ -911,7 +991,7 @@ class ApplicationBuildReporter {
911
991
  }
912
992
 
913
993
  // pkgs/@akanjs/devkit/akanApp/devHostPolicy.ts
914
- import path4 from "path";
994
+ import path5 from "path";
915
995
  var UNAVAILABLE_REDIS_HOST = "redis-tunnel-unavailable.invalid";
916
996
  var redisTunnelPolicy = ({
917
997
  environment,
@@ -952,18 +1032,18 @@ var devHostStateOf = (state, gaveUp) => state === "stopped" && gaveUp ? "failed"
952
1032
  var RESTART_ROLE_ORDER = ["server", "shared", "barrel", "config"];
953
1033
  var generationValue = (generation) => generation ?? -1;
954
1034
  var isLegacyBackendFallbackFile = (file, workspaceRoot) => {
955
- const abs = path4.resolve(file);
956
- const ext = path4.extname(abs).toLowerCase();
1035
+ const abs = path5.resolve(file);
1036
+ const ext = path5.extname(abs).toLowerCase();
957
1037
  if (!SOURCE_EXTS.has(ext))
958
1038
  return false;
959
- const rel = path4.relative(path4.resolve(workspaceRoot), abs);
960
- if (!rel || rel.startsWith("..") || path4.isAbsolute(rel))
1039
+ const rel = path5.relative(path5.resolve(workspaceRoot), abs);
1040
+ if (!rel || rel.startsWith("..") || path5.isAbsolute(rel))
961
1041
  return false;
962
- const parts = rel.split(path4.sep).filter(Boolean);
1042
+ const parts = rel.split(path5.sep).filter(Boolean);
963
1043
  const [scope] = parts;
964
1044
  if (scope !== "apps" && scope !== "libs" && scope !== "pkgs")
965
1045
  return false;
966
- const base = path4.basename(abs);
1046
+ const base = path5.basename(abs);
967
1047
  return parts.includes("srvkit") || parts.includes("common") || SERVER_SUFFIXES.some((suffix) => base.endsWith(suffix)) || SHARED_SUFFIXES.some((suffix) => base.endsWith(suffix)) || RUNTIME_METADATA_BASENAMES.has(base) || base === "main.ts" || base === "server.ts";
968
1048
  };
969
1049
  var shouldMarkBuildPhaseRecovered = (previousByPhase, status) => {
@@ -1125,11 +1205,11 @@ var buildStatusReplaySequence = (pendingReplay, latestByPhase) => [...pendingRep
1125
1205
  var filesChangedSince = (before, after) => [...before].filter(([file, stamp]) => after.get(file) !== stamp).map(([file]) => file);
1126
1206
 
1127
1207
  // pkgs/@akanjs/devkit/frontendBuild/hmrWatcher.ts
1128
- import fs from "fs";
1129
- import path7 from "path";
1208
+ import fs2 from "fs";
1209
+ import path8 from "path";
1130
1210
 
1131
1211
  // pkgs/@akanjs/devkit/frontendBuild/hmrChangeClassifier.ts
1132
- import path5 from "path";
1212
+ import path6 from "path";
1133
1213
  var CSS_EXTS = new Set([".css"]);
1134
1214
  var CONFIG_BASENAMES = new Set(["akan.config.ts", "bunfig.toml", "tsconfig.json", "package.json"]);
1135
1215
 
@@ -1137,10 +1217,10 @@ class HmrChangeClassifier {
1137
1217
  classify(abs) {
1138
1218
  if (this.#isUninteresting(abs))
1139
1219
  return "ignore";
1140
- const base = path5.basename(abs);
1220
+ const base = path6.basename(abs);
1141
1221
  if (CONFIG_BASENAMES.has(base))
1142
1222
  return "config";
1143
- const ext = path5.extname(abs).toLowerCase();
1223
+ const ext = path6.extname(abs).toLowerCase();
1144
1224
  if (CSS_EXTS.has(ext))
1145
1225
  return "css";
1146
1226
  if (SOURCE_EXTS.has(ext))
@@ -1148,16 +1228,16 @@ class HmrChangeClassifier {
1148
1228
  return "ignore";
1149
1229
  }
1150
1230
  #isUninteresting(abs) {
1151
- const base = path5.basename(abs);
1231
+ const base = path6.basename(abs);
1152
1232
  if (!base)
1153
1233
  return true;
1154
1234
  if (base.startsWith("."))
1155
1235
  return true;
1156
1236
  if (base.endsWith("~") || base.endsWith(".swp") || base.endsWith(".swx") || base.endsWith(".tmp"))
1157
1237
  return true;
1158
- if (abs.includes(`${path5.sep}node_modules${path5.sep}`))
1238
+ if (abs.includes(`${path6.sep}node_modules${path6.sep}`))
1159
1239
  return true;
1160
- if (abs.includes(`${path5.sep}.akan${path5.sep}`))
1240
+ if (abs.includes(`${path6.sep}.akan${path6.sep}`))
1161
1241
  return true;
1162
1242
  return false;
1163
1243
  }
@@ -1165,7 +1245,7 @@ class HmrChangeClassifier {
1165
1245
 
1166
1246
  // pkgs/@akanjs/devkit/frontendBuild/sourceMtimeIndex.ts
1167
1247
  import { readdir, stat as stat3 } from "fs/promises";
1168
- import path6 from "path";
1248
+ import path7 from "path";
1169
1249
  var UNREADABLE = Number.NaN;
1170
1250
 
1171
1251
  class SourceMtimeIndex {
@@ -1228,7 +1308,7 @@ class SourceMtimeIndex {
1228
1308
  if (!this.#primed)
1229
1309
  return;
1230
1310
  await Promise.all(paths.map(async (file) => {
1231
- const abs = path6.resolve(file);
1311
+ const abs = path7.resolve(file);
1232
1312
  const stats = await stat3(abs).catch(() => null);
1233
1313
  if (!stats?.isFile()) {
1234
1314
  this.#files.delete(abs);
@@ -1314,7 +1394,7 @@ class SourceMtimeIndex {
1314
1394
  for (const entry of entries) {
1315
1395
  if (SourceMtimeIndex.#skipDirent(entry.name))
1316
1396
  continue;
1317
- const abs = path6.join(dir, entry.name);
1397
+ const abs = path7.join(dir, entry.name);
1318
1398
  if (entry.isDirectory()) {
1319
1399
  descend.push(abs);
1320
1400
  continue;
@@ -1341,7 +1421,7 @@ class SourceMtimeIndex {
1341
1421
  }
1342
1422
  if (known) {
1343
1423
  for (const abs of [...this.#files.keys()]) {
1344
- if (present.has(abs) || path6.dirname(abs) !== dir)
1424
+ if (present.has(abs) || path7.dirname(abs) !== dir)
1345
1425
  continue;
1346
1426
  this.#files.delete(abs);
1347
1427
  changed?.add(abs);
@@ -1359,7 +1439,7 @@ class SourceMtimeIndex {
1359
1439
  this.#unsettled.delete(dir);
1360
1440
  }
1361
1441
  #forget(dir) {
1362
- const prefix = `${dir}${path6.sep}`;
1442
+ const prefix = `${dir}${path7.sep}`;
1363
1443
  this.#dirs.delete(dir);
1364
1444
  this.#unreadable.delete(dir);
1365
1445
  this.#unsettled.delete(dir);
@@ -1397,8 +1477,8 @@ class SourceMtimeIndex {
1397
1477
  return !name || name.startsWith(".") || name === "node_modules";
1398
1478
  }
1399
1479
  static #pruneNestedRoots(roots) {
1400
- const resolved = [...new Set(roots.map((root) => path6.resolve(root)))].sort();
1401
- return resolved.filter((root) => !resolved.some((other) => other !== root && root.startsWith(`${other}${path6.sep}`)));
1480
+ const resolved = [...new Set(roots.map((root) => path7.resolve(root)))].sort();
1481
+ return resolved.filter((root) => !resolved.some((other) => other !== root && root.startsWith(`${other}${path7.sep}`)));
1402
1482
  }
1403
1483
  }
1404
1484
 
@@ -1424,7 +1504,7 @@ class HmrWatcher {
1424
1504
  #reportedCompensating = false;
1425
1505
  #reportedGaps = "";
1426
1506
  constructor(opts) {
1427
- this.#roots = [...new Set(opts.roots.map((r) => path7.resolve(r)))];
1507
+ this.#roots = [...new Set(opts.roots.map((r) => path8.resolve(r)))];
1428
1508
  this.#debounceMs = opts.debounceMs ?? HmrWatcher.#envDebounceMs() ?? 30;
1429
1509
  this.#verifyDelayMs = opts.verifyDelayMs ?? 250;
1430
1510
  this.#onBatch = opts.onBatch;
@@ -1437,10 +1517,10 @@ class HmrWatcher {
1437
1517
  async start() {
1438
1518
  for (const root of this.#roots) {
1439
1519
  try {
1440
- const w = fs.watch(root, { recursive: true, persistent: false }, (_event, filename) => {
1520
+ const w = fs2.watch(root, { recursive: true, persistent: false }, (_event, filename) => {
1441
1521
  if (!filename)
1442
1522
  return;
1443
- const abs = path7.resolve(root, filename.toString());
1523
+ const abs = path8.resolve(root, filename.toString());
1444
1524
  this.#queue(abs);
1445
1525
  });
1446
1526
  w.on("error", (err) => {
@@ -1623,9 +1703,9 @@ class HmrWatcher {
1623
1703
  }
1624
1704
 
1625
1705
  // pkgs/@akanjs/devkit/frontendBuild/watchRootResolver.ts
1626
- import fs2 from "fs";
1706
+ import fs3 from "fs";
1627
1707
  import { readFile } from "fs/promises";
1628
- import path8 from "path";
1708
+ import path9 from "path";
1629
1709
 
1630
1710
  class WatchRootResolver {
1631
1711
  #app;
@@ -1634,27 +1714,27 @@ class WatchRootResolver {
1634
1714
  }
1635
1715
  async resolve() {
1636
1716
  const tsconfig = await this.#app.getTsConfig();
1637
- const appDir = path8.resolve(this.#app.cwdPath);
1638
- const appsContainer = path8.dirname(appDir);
1639
- const libsContainer = path8.resolve(this.#app.workspace.workspaceRoot, "libs");
1640
- const libRoots = (await this.#resolveLibDeps(libsContainer))?.map((name) => path8.join(libsContainer, name)).filter((dir) => fs2.existsSync(dir));
1717
+ const appDir = path9.resolve(this.#app.cwdPath);
1718
+ const appsContainer = path9.dirname(appDir);
1719
+ const libsContainer = path9.resolve(this.#app.workspace.workspaceRoot, "libs");
1720
+ const libRoots = (await this.#resolveLibDeps(libsContainer))?.map((name) => path9.join(libsContainer, name)).filter((dir) => fs3.existsSync(dir));
1641
1721
  const set = new Set;
1642
- set.add(path8.resolve(`${this.#app.cwdPath}/page`));
1722
+ set.add(path9.resolve(`${this.#app.cwdPath}/page`));
1643
1723
  for (const targets of Object.values(tsconfig.compilerOptions.paths ?? {})) {
1644
1724
  for (const target of targets) {
1645
1725
  if (!target)
1646
1726
  continue;
1647
- if (path8.isAbsolute(target))
1727
+ if (path9.isAbsolute(target))
1648
1728
  continue;
1649
1729
  const cleaned = target.replace(/\/?\*+.*$/, "").replace(/\/[^/]+\.[^/]+$/, "");
1650
- const resolved = path8.resolve(this.#app.workspace.workspaceRoot, cleaned);
1730
+ const resolved = path9.resolve(this.#app.workspace.workspaceRoot, cleaned);
1651
1731
  if (resolved === libsContainer && libRoots) {
1652
1732
  for (const root of libRoots)
1653
1733
  set.add(root);
1654
1734
  continue;
1655
1735
  }
1656
1736
  const root = resolved === appsContainer ? appDir : resolved;
1657
- if (fs2.existsSync(root))
1737
+ if (fs3.existsSync(root))
1658
1738
  set.add(root);
1659
1739
  }
1660
1740
  }
@@ -1664,7 +1744,7 @@ class WatchRootResolver {
1664
1744
  const scanInfo = this.#app.getScanInfo({ allowEmpty: true });
1665
1745
  if (scanInfo?.type === "app")
1666
1746
  return scanInfo.libDeps;
1667
- const direct = await WatchRootResolver.#readManifestLibDeps(path8.join(this.#app.cwdPath, "akan.app.json"));
1747
+ const direct = await WatchRootResolver.#readManifestLibDeps(path9.join(this.#app.cwdPath, "akan.app.json"));
1668
1748
  if (!direct)
1669
1749
  return null;
1670
1750
  const closure = new Set;
@@ -1674,7 +1754,7 @@ class WatchRootResolver {
1674
1754
  if (!name || closure.has(name))
1675
1755
  continue;
1676
1756
  closure.add(name);
1677
- const nested = await WatchRootResolver.#readManifestLibDeps(path8.join(libsContainer, name, "akan.lib.json"));
1757
+ const nested = await WatchRootResolver.#readManifestLibDeps(path9.join(libsContainer, name, "akan.lib.json"));
1678
1758
  if (!nested)
1679
1759
  return null;
1680
1760
  queue.push(...nested);
@@ -1693,4 +1773,4 @@ class WatchRootResolver {
1693
1773
  }
1694
1774
  }
1695
1775
 
1696
- export { UNAVAILABLE_REDIS_HOST, redisTunnelPolicy, backendRecoveryPolicy, BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS, SOURCE_EXTS, shouldRestartBackendByDevPlan, shouldRestartBuilderByDevPlan, normalizeBackendReportedGeneration, shouldRestartDevHostByDevPlan, devHostStateOf, isLegacyBackendFallbackFile, shouldMarkBuildPhaseRecovered, shouldKeepBuildFailure, createBackendBuildStatus, backendRestartReasonFromMessage, mergeBackendRestartReasons, shouldReplaceLastGoodMessage, shouldQueueBuildStatusReplay, hasBuildFailureForGeneration, decideBuilderRssRecycle, decideBuilderRssSettle, decideIdleSuspend, resolveIdleSuspendMs, hasAnyBuildFailure, shouldRefreshConfigOnIdleWake, shouldHoldForReturningBuilder, shouldWarnBuilderRssCeilingTight, isRssCeilingUnreachable, shouldRelayRecycledFrontendState, mergeInvalidateMessages, buildStatusReplaySequence, filesChangedSince, HmrWatcher, WatchRootResolver, FontOptimizer, FontPruner, RouteJsBudget, ApplicationBuildReporter };
1776
+ export { UNAVAILABLE_REDIS_HOST, redisTunnelPolicy, backendRecoveryPolicy, BUILDER_MIN_RSS_RECYCLE_INTERVAL_MS, SOURCE_EXTS, shouldRestartBackendByDevPlan, shouldRestartBuilderByDevPlan, normalizeBackendReportedGeneration, shouldRestartDevHostByDevPlan, devHostStateOf, isLegacyBackendFallbackFile, shouldMarkBuildPhaseRecovered, shouldKeepBuildFailure, createBackendBuildStatus, backendRestartReasonFromMessage, mergeBackendRestartReasons, shouldReplaceLastGoodMessage, shouldQueueBuildStatusReplay, hasBuildFailureForGeneration, decideBuilderRssRecycle, decideBuilderRssSettle, decideIdleSuspend, resolveIdleSuspendMs, hasAnyBuildFailure, shouldRefreshConfigOnIdleWake, shouldHoldForReturningBuilder, shouldWarnBuilderRssCeilingTight, isRssCeilingUnreachable, shouldRelayRecycledFrontendState, mergeInvalidateMessages, buildStatusReplaySequence, filesChangedSince, HmrWatcher, WatchRootResolver, FontOptimizer, FontPruner, precompressArtifacts, RouteJsBudget, ApplicationBuildReporter };