@akanjs/cli 3.3.0-rc.1 → 3.3.0-rc.11

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 (115) hide show
  1. package/.build-stamp +2 -2
  2. package/CodeAgent-cqbf9gsv.js +11 -0
  3. package/{CodeAgentRpcHost-6dzfkvsc.js → CodeAgentRpcHost-pwps2d67.js} +1 -1
  4. package/{CodeTui-zee8atsr.js → CodeTui-ehdr4hgw.js} +46 -6
  5. package/TunnelShare-0p4dy89e.js +16 -0
  6. package/{agent.command-x65f2ags.js → agent.command-x55ncdjm.js} +20 -22
  7. package/akanCode.js +7 -7
  8. package/appExecutor-1ctzymwa.js +11 -0
  9. package/{application.command-azbd1pb2.js → application.command-xpntxnh8.js} +18 -20
  10. package/{applicationBuildRunner-trfxv3pd.js → applicationBuildRunner-19c76791.js} +16 -13
  11. package/buildBatch.proc.js +19 -19
  12. package/{cloud.command-gapp4634.js → cloud.command-p3ybjes7.js} +19 -24
  13. package/cloud.script-0dsyd10v.js +30 -0
  14. package/{code.command-5smx61yf.js → code.command-m6skj1kj.js} +34 -19
  15. package/{context.command-ym5jbkny.js → context.command-3c3nv0d6.js} +20 -22
  16. package/context.runner-yyp7a112.js +32 -0
  17. package/csrArtifactBuilder-mdh9ykn2.js +9 -0
  18. package/{index-2ny1e95c.js → dependencyScanner-93g8tk0r.js} +6 -5
  19. package/{fileSys-q22646yc.js → fileSys-e5mwt73x.js} +1 -1
  20. package/frameworkGraph-aneq2nwy.js +8 -0
  21. package/{guideline.command-zwypaqsh.js → guideline.command-725fq5p0.js} +8 -8
  22. package/guidelines/agentRule/agentRule.instruction.md +46 -7
  23. package/guidelines/akanApi/akanApi.instruction.md +7 -2
  24. package/guidelines/conventions/core.md +6 -11
  25. package/guidelines/conventions/rules/app.md +1 -2
  26. package/guidelines/conventions/rules/auth.md +18 -27
  27. package/guidelines/conventions/rules/config.md +15 -46
  28. package/guidelines/conventions/rules/page.md +19 -34
  29. package/guidelines/conventions/rules/server.md +1 -4
  30. package/guidelines/conventions/rules/ssr.md +3 -4
  31. package/guidelines/conventions/rules/ts.md +2 -1
  32. package/guidelines/cssRule/cssRule.instruction.md +3 -0
  33. package/guidelines/errorCodes/errorCodes.instruction.md +4 -0
  34. package/guidelines/mcpRule/mcpRule.instruction.md +11 -4
  35. package/guidelines/pageRule/pageRule.instruction.md +6 -53
  36. package/guidelines/runtimeRule/runtimeRule.instruction.md +68 -4
  37. package/incrementalBuilder.proc.js +24 -18
  38. package/{index-nc3br31y.js → index-22bwg8hy.js} +2 -2
  39. package/{index-9f3reh2y.js → index-2v38x3ad.js} +12 -1
  40. package/{index-67sd09ag.js → index-3a3vy2xy.js} +8 -8
  41. package/{index-p7beqww9.js → index-3fmzz9sf.js} +18 -18
  42. package/{index-9wh04mqy.js → index-3mj5trqc.js} +65 -11
  43. package/{index-7wf8snar.js → index-3r1crbct.js} +1 -1
  44. package/{index-41a03gkj.js → index-3zkhg65e.js} +19 -19
  45. package/{index-2jmvfa62.js → index-4r8dgm4x.js} +3 -3
  46. package/{index-jek2re5k.js → index-4yvtqcme.js} +8 -8
  47. package/{index-j0wr4e32.js → index-5ahe641t.js} +9 -9
  48. package/{index-0dm25wvf.js → index-7ssr7wq4.js} +1 -1
  49. package/{index-dmcpetwe.js → index-8bta5pnr.js} +98 -23
  50. package/{index-z92zm3wd.js → index-9a9t77hz.js} +29 -11
  51. package/{index-3txdtztz.js → index-9gjcbp2g.js} +1 -1
  52. package/{index-8jtqfye2.js → index-a4gcdffy.js} +488 -53
  53. package/{index-xwwex8rf.js → index-cbm9gzgx.js} +5 -5
  54. package/{index-j6jjmn2r.js → index-ckcc9ab3.js} +62 -21
  55. package/{index-w1zexzpx.js → index-crd99zqs.js} +1 -1
  56. package/{index-612fdtbk.js → index-f4jydw2x.js} +1 -1
  57. package/{index-4ss4gkv3.js → index-fagjtk6m.js} +2 -2
  58. package/{index-ebn9kgea.js → index-fjqapyex.js} +45 -16
  59. package/{index-h901f24n.js → index-h8w1n11r.js} +5 -5
  60. package/{index-275a4r3n.js → index-hxg6ctk2.js} +12 -16
  61. package/{index-78y75t0a.js → index-j2wq064m.js} +6 -7
  62. package/{index-knpm8sdm.js → index-j3fqs8rc.js} +1 -1
  63. package/{index-kfvjzk8r.js → index-kbnvyhy4.js} +3 -3
  64. package/{index-6dzjer7p.js → index-m303nhv6.js} +6 -6
  65. package/{index-dadwp2aw.js → index-nmdmkjt2.js} +271 -39
  66. package/{index-2yn3r67f.js → index-nnmw56fz.js} +6 -6
  67. package/{index-a860mx0m.js → index-pr9nypg7.js} +24 -24
  68. package/{index-s885g0jj.js → index-pyjkbg8e.js} +3 -3
  69. package/{index-zmd9xxgd.js → index-q63nbpv7.js} +3 -3
  70. package/{index-v7ajmsh3.js → index-qecrqpt6.js} +4 -21
  71. package/{index-gt8phqpt.js → index-rdcgz02t.js} +4 -4
  72. package/{index-j592zfqc.js → index-rt7q20sj.js} +1 -1
  73. package/{index-baccvws5.js → index-se7n78fh.js} +1 -1
  74. package/{index-s4nvxpzm.js → index-sxbsrndq.js} +1 -1
  75. package/{index-k6vwww45.js → index-t23dgyaf.js} +7 -7
  76. package/{index-71y6176j.js → index-v16gj2as.js} +86 -66
  77. package/{index-0s7w2085.js → index-vnk1qwgr.js} +4 -4
  78. package/{index-z96ks033.js → index-wkwe91sn.js} +169 -51
  79. package/{index-ybcb9wc8.js → index-wxqp1amd.js} +9 -9
  80. package/{index-p5zh7pmc.js → index-xv3pvdw4.js} +1 -1
  81. package/{index-zfnz878d.js → index-yey1envc.js} +1 -1
  82. package/{index-by2tvsq6.js → index-zyjztrvc.js} +1 -1
  83. package/index.js +30 -28
  84. package/{libExecutor-jc6f8hm6.js → libExecutor-n8hpm8s7.js} +3 -3
  85. package/{library.command-nxvesvhb.js → library.command-8abb26pg.js} +8 -8
  86. package/{localRegistry.command-xz62e4ng.js → localRegistry.command-sa211m1z.js} +18 -23
  87. package/{module.command-aaws9byg.js → module.command-z3cwjf0p.js} +10 -10
  88. package/{package.command-j7hv26p0.js → package.command-akynhtee.js} +9 -12
  89. package/package.json +3 -2
  90. package/{page.command-7yffs7n9.js → page.command-3fpdavk9.js} +8 -8
  91. package/{pipeline.command-7yk0zcng.js → pipeline.command-ca95n8rd.js} +7 -7
  92. package/{pkgExecutor-arxmvx4t.js → pkgExecutor-a73q41vx.js} +3 -3
  93. package/{primitive.command-7a1pt715.js → primitive.command-xwe9ggnf.js} +11 -11
  94. package/{projectTypecheck-f4qhbecd.js → projectTypecheck-7g542ymk.js} +1 -1
  95. package/{prompter-qyggfhqd.js → prompter-d33wmdpa.js} +2 -2
  96. package/{quality.command-c6mvrjh1.js → quality.command-7wz7y8z1.js} +9 -9
  97. package/{repair.command-093adzt9.js → repair.command-dej1qtfq.js} +10 -10
  98. package/{scalar.command-2ex84spb.js → scalar.command-z9qfxnvm.js} +9 -9
  99. package/skills/akan-agent/SKILL.md +8 -1
  100. package/skills/akan-code/SKILL.md +38 -3
  101. package/skills/akan-page/SKILL.md +18 -13
  102. package/skills/akan-runtime/SKILL.md +21 -16
  103. package/skills/akan-service/SKILL.md +2 -2
  104. package/{subspace.command-4n4n4jpv.js → subspace.command-9wekm4gn.js} +11 -13
  105. package/templates/localDev/docker-compose.yaml.template +2 -2
  106. package/{tunnel.command-f7ep1qfa.js → tunnel.command-cxc4h3j8.js} +10 -12
  107. package/{verify.command-zrkxnvct.js → verify.command-j0w9dr5c.js} +15 -17
  108. package/{workflow.command-ks16jegk.js → workflow.command-yt4sz04b.js} +15 -15
  109. package/{workspace.command-ahhfpaag.js → workspace.command-8mp4mcp2.js} +34 -38
  110. package/CodeAgent-fx6088tv.js +0 -11
  111. package/TunnelShare-9ry4vh0y.js +0 -18
  112. package/appExecutor-79azsb2w.js +0 -11
  113. package/cloud.script-3b401efv.js +0 -35
  114. package/context.runner-kctbfsde.js +0 -34
  115. package/dependencyScanner-ge10gb52.js +0 -8
@@ -1,10 +1,14 @@
1
1
  // @bun
2
2
  import {
3
- ErrorReport
4
- } from "./index-7wf8snar.js";
3
+ FileSys2
4
+ } from "./index-zyjztrvc.js";
5
+ import {
6
+ JsonFormatter,
7
+ AkanAppConfig
8
+ } from "./index-v16gj2as.js";
5
9
  import {
6
- JsonFormatter
7
- } from "./index-71y6176j.js";
10
+ ErrorReport
11
+ } from "./index-3r1crbct.js";
8
12
 
9
13
  // pkgs/@akanjs/devkit/app/applicationBuildReporter.ts
10
14
  import { Logger } from "akanjs/common";
@@ -14,14 +18,28 @@ import path4 from "path";
14
18
  import { toError } from "akanjs/common";
15
19
 
16
20
  // pkgs/@akanjs/devkit/frontendBuild/fontPruner.ts
17
- import { rm, rmdir, stat as stat2 } from "fs/promises";
21
+ import { rm as rm2, rmdir, stat as stat2 } from "fs/promises";
18
22
  import path2 from "path";
19
23
  import { isFontOptimizationEnabled } from "akanjs/client";
20
24
 
21
25
  // pkgs/@akanjs/devkit/frontendBuild/fontOptimizer.ts
22
- import { mkdir, stat } from "fs/promises";
26
+ import { mkdir, readdir, rm, stat } from "fs/promises";
23
27
  import path from "path";
24
28
  import ts from "typescript";
29
+
30
+ // pkgs/@akanjs/devkit/frontendBuild/buildCacheStamp.ts
31
+ import { statSync } from "fs";
32
+ var buildCacheStamp = (producers) => ({
33
+ akanjs: AkanAppConfig.akanVersion,
34
+ bun: `${Bun.version}+${Bun.revision}`,
35
+ code: producers.map((file) => {
36
+ const stats = statSync(file, { throwIfNoEntry: false });
37
+ return stats ? `${stats.mtimeMs}:${stats.size}` : "missing";
38
+ }).join(",")
39
+ });
40
+ var isBuildCacheStamp = (value, stamp) => value?.akanjs === stamp.akanjs && value.bun === stamp.bun && value.code === stamp.code;
41
+
42
+ // pkgs/@akanjs/devkit/frontendBuild/fontOptimizer.ts
25
43
  var FONT_URL_PREFIX = "/_akan/fonts";
26
44
  var DEFAULT_FONT_SUBSETS = ["latin"];
27
45
 
@@ -29,15 +47,18 @@ class FontOptimizer {
29
47
  #app;
30
48
  #command;
31
49
  #artifactRoot;
50
+ #cacheRoot;
51
+ #stamp = buildCacheStamp([import.meta.path]);
32
52
  #files = [];
33
53
  #cssParts = [];
34
54
  #woff2Ready = null;
35
55
  static #ksX1001Text = null;
36
- static #cacheVersion = 3;
56
+ static #cacheVersion = 4;
37
57
  constructor(app, command = "start") {
38
58
  this.#app = app;
39
59
  this.#command = command;
40
60
  this.#artifactRoot = path.join(command === "build" ? app.dist.cwdPath : app.cwdPath, ".akan/artifact");
61
+ this.#cacheRoot = command === "build" ? this.#artifactRoot : path.join(app.cwdPath, ".akan/cache");
41
62
  }
42
63
  async optimize() {
43
64
  const fonts = await this.discoverFonts();
@@ -58,11 +79,13 @@ class FontOptimizer {
58
79
  const result = { css: this.#cssParts.join(`
59
80
  `), fonts, files: this.#files };
60
81
  if (cacheKey)
61
- await this.#writeCache(cacheKey, result);
82
+ await this.#writeCache(cacheKey, result).catch(() => {
83
+ return;
84
+ });
62
85
  return result;
63
86
  }
64
87
  get #cachePath() {
65
- return path.join(this.#artifactRoot, "fontCache.json");
88
+ return path.join(this.#cacheRoot, "fontCache.json");
66
89
  }
67
90
  async#buildCacheKey(fonts) {
68
91
  const sources = [];
@@ -71,10 +94,10 @@ class FontOptimizer {
71
94
  continue;
72
95
  for (const face of this.#getFontFaces(font)) {
73
96
  const sourcePath = await this.#resolveFontSourcePath(face.src);
74
- const stamp = sourcePath ? await this.#fileStamp(sourcePath) : null;
75
- if (!stamp)
97
+ const digest = sourcePath ? await this.#fileDigest(sourcePath) : null;
98
+ if (!digest)
76
99
  return null;
77
- sources.push({ optimizedSrc: face.optimizedSrc, ...stamp });
100
+ sources.push({ optimizedSrc: face.optimizedSrc, sourcePath, ...digest });
78
101
  }
79
102
  for (const filePath of font.subsetFiles ?? []) {
80
103
  const abs = path.isAbsolute(filePath) ? filePath : path.join(this.#app.cwdPath, filePath);
@@ -86,11 +109,30 @@ class FontOptimizer {
86
109
  if (this.#getFontSubsets(font).includes("auto"))
87
110
  sources.push({ autoSubsetText: this.#cacheDigest(await this.#collectAutoSubsetText()) });
88
111
  }
89
- return this.#cacheDigest({ version: FontOptimizer.#cacheVersion, fonts, sources });
112
+ const lockfile = await this.#lockfileDigest();
113
+ return this.#cacheDigest({
114
+ version: FontOptimizer.#cacheVersion,
115
+ command: this.#command,
116
+ lockfile,
117
+ fonts,
118
+ sources
119
+ });
120
+ }
121
+ async#lockfileDigest() {
122
+ const root = this.#app.workspace.workspaceRoot;
123
+ const lockfiles = await Promise.all(["bun.lock", "bun.lockb"].map((name) => Bun.file(path.join(root, name)).bytes().catch(() => null)));
124
+ return lockfiles.map((bytes) => bytes ? this.#sha256(bytes) : null);
125
+ }
126
+ #sha256(bytes) {
127
+ return new Bun.CryptoHasher("sha256").update(bytes).digest("hex");
90
128
  }
91
129
  #cacheDigest(value) {
92
130
  return new Bun.CryptoHasher("sha256").update(this.#stableStringify(value)).digest("hex");
93
131
  }
132
+ async#fileDigest(filePath) {
133
+ const bytes = await Bun.file(filePath).bytes().catch(() => null);
134
+ return bytes ? { size: bytes.byteLength, sha256: this.#sha256(bytes) } : null;
135
+ }
94
136
  async#fileStamp(filePath) {
95
137
  try {
96
138
  const stats = await stat(filePath);
@@ -101,23 +143,56 @@ class FontOptimizer {
101
143
  }
102
144
  async#readCache(key) {
103
145
  const cache = await Bun.file(this.#cachePath).json().catch(() => null);
104
- if (cache?.version !== FontOptimizer.#cacheVersion || cache.key !== key)
146
+ if (cache?.version !== FontOptimizer.#cacheVersion || cache.key !== key || typeof cache.css !== "string")
147
+ return null;
148
+ if (!isBuildCacheStamp(cache, this.#stamp) || !Array.isArray(cache.files))
105
149
  return null;
106
- const files = cache.files.map((relativePath) => path.join(this.#artifactRoot, relativePath));
107
- for (const filePath of files) {
108
- if (!await Bun.file(filePath).exists())
150
+ const files = [];
151
+ for (const file of cache.files) {
152
+ const bytes = await this.#readIntact(this.#cacheRoot, file);
153
+ if (!bytes)
109
154
  return null;
155
+ if (this.#cacheRoot !== this.#artifactRoot && !await this.#readIntact(this.#artifactRoot, file))
156
+ await Bun.write(path.join(this.#artifactRoot, file.path), bytes);
157
+ files.push(path.join(this.#artifactRoot, file.path));
110
158
  }
111
159
  return { css: cache.css, files };
112
160
  }
161
+ async#readIntact(root, file) {
162
+ if (typeof file?.path !== "string" || typeof file.size !== "number")
163
+ return null;
164
+ const bytes = await Bun.file(path.join(root, file.path)).bytes().catch(() => null);
165
+ if (!bytes || bytes.byteLength !== file.size || this.#sha256(bytes) !== file.sha256)
166
+ return null;
167
+ return bytes;
168
+ }
113
169
  async#writeCache(key, result) {
170
+ const files = [];
171
+ for (const filePath of result.files) {
172
+ const bytes = await Bun.file(filePath).bytes();
173
+ const relativePath = path.relative(this.#artifactRoot, filePath);
174
+ const cachedPath = path.join(this.#cacheRoot, relativePath);
175
+ if (cachedPath !== filePath)
176
+ await FileSys2.writeTextAtomic(cachedPath, bytes);
177
+ files.push({ path: relativePath, size: bytes.byteLength, sha256: this.#sha256(bytes) });
178
+ }
114
179
  const cache = {
115
180
  version: FontOptimizer.#cacheVersion,
181
+ ...this.#stamp,
116
182
  key,
117
183
  css: result.css,
118
- files: result.files.map((filePath) => path.relative(this.#artifactRoot, filePath))
184
+ files
119
185
  };
120
- await Bun.write(this.#cachePath, JSON.stringify(cache));
186
+ await FileSys2.writeTextAtomic(this.#cachePath, JSON.stringify(cache));
187
+ await this.#pruneCachedFonts(files);
188
+ }
189
+ async#pruneCachedFonts(kept) {
190
+ if (this.#cacheRoot === this.#artifactRoot)
191
+ return;
192
+ const dir = path.join(this.#cacheRoot, FONT_URL_PREFIX.replace(/^\/_akan\//, ""));
193
+ const keep = new Set(kept.map((file) => path.join(this.#cacheRoot, file.path)));
194
+ const names = await readdir(dir).catch(() => []);
195
+ await Promise.all(names.filter((name) => !name.endsWith(".tmp")).map((name) => path.join(dir, name)).filter((filePath) => !keep.has(filePath)).map((filePath) => rm(filePath, { force: true })));
121
196
  }
122
197
  async discoverFonts() {
123
198
  const pageKeys = await this.#app.getPageKeys();
@@ -620,7 +695,7 @@ class FontPruner {
620
695
  }
621
696
  }
622
697
  async#remove(files) {
623
- await Promise.all(files.map((file) => rm(path2.join(this.#publicRoot, file), { force: true })));
698
+ await Promise.all(files.map((file) => rm2(path2.join(this.#publicRoot, file), { force: true })));
624
699
  const dirs = [...new Set(files.map((file) => path2.posix.dirname(file)))].filter((dir) => dir !== "." && dir !== "/").sort((a, b) => b.length - a.length);
625
700
  for (const dir of dirs)
626
701
  await rmdir(path2.join(this.#publicRoot, dir)).catch(() => {
@@ -1244,7 +1319,7 @@ class HmrChangeClassifier {
1244
1319
  }
1245
1320
 
1246
1321
  // pkgs/@akanjs/devkit/frontendBuild/sourceMtimeIndex.ts
1247
- import { readdir, stat as stat3 } from "fs/promises";
1322
+ import { readdir as readdir2, stat as stat3 } from "fs/promises";
1248
1323
  import path7 from "path";
1249
1324
  var UNREADABLE = Number.NaN;
1250
1325
 
@@ -1465,7 +1540,7 @@ class SourceMtimeIndex {
1465
1540
  }
1466
1541
  static async#readdirPath(dir) {
1467
1542
  try {
1468
- return { entries: await readdir(dir, { withFileTypes: true }), err: null };
1543
+ return { entries: await readdir2(dir, { withFileTypes: true }), err: null };
1469
1544
  } catch (err) {
1470
1545
  return { entries: null, err };
1471
1546
  }
@@ -1773,4 +1848,4 @@ class WatchRootResolver {
1773
1848
  }
1774
1849
  }
1775
1850
 
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 };
1851
+ 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, buildCacheStamp, isBuildCacheStamp, FontOptimizer, FontPruner, precompressArtifacts, RouteJsBudget, ApplicationBuildReporter };
@@ -7,16 +7,16 @@ import {
7
7
  AkanAppConfig,
8
8
  increaseBuildNum,
9
9
  decreaseBuildNum
10
- } from "./index-71y6176j.js";
10
+ } from "./index-v16gj2as.js";
11
11
  import {
12
12
  FileSys2
13
- } from "./index-by2tvsq6.js";
13
+ } from "./index-zyjztrvc.js";
14
14
  import {
15
15
  LibExecutor2
16
- } from "./index-zfnz878d.js";
16
+ } from "./index-yey1envc.js";
17
17
 
18
18
  // pkgs/@akanjs/devkit/executors/appExecutor.ts
19
- import { cp as cpEntry, lstat, mkdir, readdir as readDirEntries, realpath, symlink } from "fs/promises";
19
+ import { cp as cpEntry, lstat, mkdir, readdir as readDirEntries, realpath, rm as rm2, stat, symlink } from "fs/promises";
20
20
  import path3 from "path";
21
21
  import { pathToFileURL } from "url";
22
22
  import { isRouteSourceFile, parseRouteModuleKey, validatePageSourceFile, validateSubRoutePageKey } from "akanjs/common";
@@ -409,7 +409,12 @@ class AppExecutor2 extends SysExecutor {
409
409
  static from(executor, name) {
410
410
  return new AppExecutor2({ workspace: executor instanceof WorkspaceExecutor ? executor : executor.workspace, name });
411
411
  }
412
- static #keptOnStart = [path3.join(".akan", "cache", "bin")];
412
+ #verifyBuild = false;
413
+ useVerifyDist() {
414
+ this.dist = new Executor(`dist/verify/${this.name}`, `${this.workspace.workspaceRoot}/dist/verify/${this.name}`);
415
+ this.#verifyBuild = true;
416
+ }
417
+ static #keptOnStart = [path3.join(".akan", "cache")];
413
418
  static #legacyNative = path3.join(".akan", "native");
414
419
  async#removeDevOutput(dir = ".akan") {
415
420
  const entries = await readDirEntries(this.getPath(dir)).catch(() => []);
@@ -420,12 +425,23 @@ class AppExecutor2 extends SysExecutor {
420
425
  return;
421
426
  }
422
427
  if (AppExecutor2.#keptOnStart.includes(entry))
423
- return;
428
+ return await this.#removeStaleTemps(entry);
424
429
  if (AppExecutor2.#keptOnStart.some((kept) => kept.startsWith(`${entry}${path3.sep}`)))
425
430
  return await this.#removeDevOutput(entry);
426
431
  await this.removeDir(entry);
427
432
  }));
428
433
  }
434
+ static #staleTempMs = 60000;
435
+ async#removeStaleTemps(dir) {
436
+ const root = this.getPath(dir);
437
+ const names = await readDirEntries(root, { recursive: true }).catch(() => []);
438
+ await Promise.all(names.filter((name) => name.endsWith(".tmp")).map(async (name) => {
439
+ const file = path3.join(root, name);
440
+ const stats = await stat(file).catch(() => null);
441
+ if (stats?.isFile() && Date.now() - stats.mtimeMs > AppExecutor2.#staleTempMs)
442
+ await rm2(file, { force: true });
443
+ }));
444
+ }
429
445
  getEnv() {
430
446
  return WorkspaceExecutor.getBaseDevEnv().env;
431
447
  }
@@ -475,11 +491,13 @@ class AppExecutor2 extends SysExecutor {
475
491
  this.#excludeDevOnlyPages = true;
476
492
  this.#pageKeys = null;
477
493
  await this.dist.removeDir(this.dist.cwdPath);
478
- await Promise.all([this.dist.mkdir("private"), this.dist.mkdir("public")]);
479
- await Promise.all([
480
- this.cp("private", `${this.dist.cwdPath}/private`, { dereference: true }),
481
- ...akanConfig.web.ssr ? [this.cp("public", `${this.dist.cwdPath}/public`, { dereference: true })] : []
482
- ]);
494
+ if (!this.#verifyBuild) {
495
+ await Promise.all([this.dist.mkdir("private"), this.dist.mkdir("public")]);
496
+ await Promise.all([
497
+ this.cp("private", `${this.dist.cwdPath}/private`, { dereference: true }),
498
+ ...akanConfig.web.ssr ? [this.cp("public", `${this.dist.cwdPath}/public`, { dereference: true })] : []
499
+ ]);
500
+ }
483
501
  } else {
484
502
  await this.#removeDevOutput();
485
503
  if (!akanConfig.web.ssr || !akanConfig.web.csr)
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-2yn3r67f.js";
5
+ } from "./index-nnmw56fz.js";
6
6
 
7
7
  // pkgs/@akanjs/cli/page/page.runner.ts
8
8
  class PageRunner extends runner("page") {