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

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
@@ -4,22 +4,22 @@ import {
4
4
  SysExecutor,
5
5
  AppInfo,
6
6
  WorkspaceExecutor
7
- } from "./index-71y6176j.js";
7
+ } from "./index-v16gj2as.js";
8
8
  import {
9
9
  FileSys2
10
- } from "./index-by2tvsq6.js";
10
+ } from "./index-zyjztrvc.js";
11
11
  import {
12
12
  CliError
13
13
  } from "./index-j4yvgfhr.js";
14
14
  import {
15
15
  AppExecutor2
16
- } from "./index-z92zm3wd.js";
16
+ } from "./index-9a9t77hz.js";
17
17
  import {
18
18
  LibExecutor2
19
- } from "./index-zfnz878d.js";
19
+ } from "./index-yey1envc.js";
20
20
  import {
21
21
  PkgExecutor2
22
- } from "./index-w1zexzpx.js";
22
+ } from "./index-crd99zqs.js";
23
23
  import {
24
24
  UNAVAILABLE_REDIS_HOST,
25
25
  redisTunnelPolicy,
@@ -55,27 +55,27 @@ import {
55
55
  filesChangedSince,
56
56
  HmrWatcher,
57
57
  WatchRootResolver
58
- } from "./index-dmcpetwe.js";
58
+ } from "./index-8bta5pnr.js";
59
59
  import {
60
60
  runner,
61
61
  assertPromptable
62
- } from "./index-2yn3r67f.js";
62
+ } from "./index-nnmw56fz.js";
63
63
  import {
64
64
  UpdatePackFolder,
65
65
  UpdateUploader,
66
66
  NativePublicEnv,
67
67
  NativeApp
68
- } from "./index-ebn9kgea.js";
68
+ } from "./index-fjqapyex.js";
69
69
  import {
70
70
  DesktopServerStage
71
- } from "./index-612fdtbk.js";
71
+ } from "./index-f4jydw2x.js";
72
72
  import {
73
73
  resolveMobileTargets,
74
74
  resolveAppId
75
75
  } from "./index-m9jj544v.js";
76
76
  import {
77
77
  SlicePlanner
78
- } from "./index-j592zfqc.js";
78
+ } from "./index-rt7q20sj.js";
79
79
  import {
80
80
  openBrowser
81
81
  } from "./index-9dp031by.js";
@@ -88,9 +88,11 @@ import {
88
88
 
89
89
  // pkgs/@akanjs/cli/application/application.runner.ts
90
90
  import { existsSync, realpathSync as realpathSync2 } from "fs";
91
- import path7 from "path";
91
+ import path8 from "path";
92
92
 
93
93
  // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
94
+ import fs2 from "fs";
95
+ import path5 from "path";
94
96
  import { Logger as Logger2 } from "akanjs/common";
95
97
 
96
98
  // pkgs/@akanjs/devkit/tunnel/createTunnel.ts
@@ -259,15 +261,24 @@ var tunnelEnv = new ShellOnlyEnv([
259
261
  "SSH_TUNNEL_KNOWN_HOSTS",
260
262
  "SSH_TUNNEL_BIND_HOST"
261
263
  ]);
262
- var tunnelAuth = (app, repoName) => {
264
+ var readTunnelKey = (purpose, keyPath) => {
265
+ try {
266
+ return readFileSync(keyPath);
267
+ } catch (error) {
268
+ const reason = error.code ?? (error instanceof Error ? error.message : String(error));
269
+ throw new Error(`${purpose} could not read the key SSH_TUNNEL_PRIVATE_KEY_PATH names, ${keyPath} (${reason}).`, {
270
+ cause: error
271
+ });
272
+ }
273
+ };
274
+ var tunnelAuth = (purpose) => {
263
275
  const keyPath = tunnelEnv.get("SSH_TUNNEL_PRIVATE_KEY_PATH");
264
276
  const passphrase = tunnelEnv.get("SSH_TUNNEL_PASSPHRASE");
265
277
  if (keyPath)
266
- return { privateKey: readFileSync(keyPath), ...passphrase ? { passphrase } : {} };
278
+ return { privateKey: readTunnelKey(purpose, keyPath), ...passphrase ? { passphrase } : {} };
267
279
  if (process.env.SSH_TUNNEL_PASSWORD)
268
280
  return { password: process.env.SSH_TUNNEL_PASSWORD };
269
- app.logger.warn("The SSH tunnel uses the default shared credential. " + "Set SSH_TUNNEL_PRIVATE_KEY_PATH to a key (or SSH_TUNNEL_PASSWORD) once the cluster's tunnel endpoint accepts it.");
270
- return { password: repoName };
281
+ throw new Error(`${purpose} needs an SSH credential: export SSH_TUNNEL_PRIVATE_KEY_PATH (with SSH_TUNNEL_PASSPHRASE if the key has one) in the shell, or set SSH_TUNNEL_PASSWORD.`);
271
282
  };
272
283
  var tunnelHostVerifier = (app, hostId, onRefusal) => {
273
284
  const pinned = SshHostKeys.parsePinned(tunnelEnv.get("SSH_TUNNEL_HOST_FINGERPRINT"));
@@ -295,7 +306,8 @@ var createTunnel = async (service, { app, environment, port = service === "postg
295
306
  WorkspaceExecutor.assertDeployableEnv(baseDevEnv, environment, `The ${service} tunnel`);
296
307
  for (const line of tunnelEnv.ignored())
297
308
  app.logger.warn(line);
298
- const { serveDomain, repoName } = baseDevEnv;
309
+ const auth = tunnelAuth(`The ${service} tunnel for ${app.name}-${environment}`);
310
+ const { serveDomain } = baseDevEnv;
299
311
  const host = `${app.name}-${environment}.${serveDomain}`;
300
312
  const sshHost = host.endsWith(".localhost") ? "localhost" : host;
301
313
  const sshPort = process.env.SSH_TUNNEL_PORT ? parseInt(process.env.SSH_TUNNEL_PORT) : 32767;
@@ -317,7 +329,7 @@ var createTunnel = async (service, { app, environment, port = service === "postg
317
329
  host: sshHost,
318
330
  port: sshPort,
319
331
  username: process.env.SSH_TUNNEL_USERNAME ?? "root",
320
- ...tunnelAuth(app, repoName),
332
+ ...auth,
321
333
  hostVerifier: tunnelHostVerifier(app, `${sshHost}:${sshPort}`, (reason) => {
322
334
  refusal = reason;
323
335
  })
@@ -740,6 +752,10 @@ class IncrementalBuilderHost {
740
752
  return;
741
753
  if (!msg || typeof msg !== "object")
742
754
  return;
755
+ if (msg.type === "base-built") {
756
+ this.#startOptions.onBaseBuilt?.(msg.phaseMs);
757
+ return;
758
+ }
743
759
  if (msg.type === "build-route-res" || msg.type === "build-csr-res" || msg.type === "build-graph-res")
744
760
  this.#inFlight.delete(msg.id);
745
761
  if (builderMsgTypeSet.has(msg.type))
@@ -1185,7 +1201,7 @@ class DevBackend {
1185
1201
  const backend = Bun.spawn(["bun", `apps/${this.#app.name}/main.ts`], {
1186
1202
  cwd: this.#app.workspace.workspaceRoot,
1187
1203
  stdio: this.#stdio === "pipe" ? ["ignore", "pipe", "pipe"] : ["inherit", "inherit", "inherit"],
1188
- env: this.#env,
1204
+ env: this.#links.awaitsArtifact() ? { ...this.#env, AKAN_DEV_AWAIT_ARTIFACT: "1" } : this.#env,
1189
1205
  ipc: (msg) => {
1190
1206
  if (!msg || typeof msg !== "object")
1191
1207
  return;
@@ -1518,7 +1534,7 @@ class DevBuilder {
1518
1534
  this.#host = builder;
1519
1535
  try {
1520
1536
  await this.#waitForReady(attempt, { announceBootState });
1521
- this.#app.verbose(`[cli] base build ready in ${Date.now() - startTime}ms \u2014 starting backend`);
1537
+ this.#app.verbose(`[cli] base build ready in ${Date.now() - startTime}ms`);
1522
1538
  return this.#host;
1523
1539
  } catch (err) {
1524
1540
  lastError = err;
@@ -1623,6 +1639,9 @@ class DevBuilder {
1623
1639
  settle(resolve);
1624
1640
  this.#links.onReady();
1625
1641
  },
1642
+ onBaseBuilt: (phaseMs) => {
1643
+ this.#links.onBaseBuilt(phaseMs);
1644
+ },
1626
1645
  onRestartReady: () => {
1627
1646
  this.#links.onRestartReady();
1628
1647
  }
@@ -2104,6 +2123,69 @@ class DevRecycler {
2104
2123
  }
2105
2124
  }
2106
2125
 
2126
+ // pkgs/@akanjs/devkit/akanApp/devStartTimeline.ts
2127
+ var BASE_BUILD_PARTS = ["runtime", "routes", "styles", "dictionary", "pages"];
2128
+
2129
+ class DevStartTimeline {
2130
+ #logger;
2131
+ #now;
2132
+ #marks = {};
2133
+ #basePhaseMs = {};
2134
+ #reported = true;
2135
+ constructor(logger, now = () => performance.now()) {
2136
+ this.#logger = logger;
2137
+ this.#now = now;
2138
+ }
2139
+ begin() {
2140
+ this.#marks = { started: this.#now() };
2141
+ this.#basePhaseMs = {};
2142
+ this.#reported = false;
2143
+ }
2144
+ baseBuilt(phaseMs) {
2145
+ if (this.#reported || this.#marks.baseBuilt !== undefined)
2146
+ return;
2147
+ this.#basePhaseMs = phaseMs;
2148
+ this.#marks.baseBuilt = this.#now();
2149
+ }
2150
+ mark(mark) {
2151
+ if (this.#reported)
2152
+ return;
2153
+ if (mark === "backendSpawned")
2154
+ this.#marks.backendSpawned = this.#now();
2155
+ else
2156
+ this.#marks[mark] ??= this.#now();
2157
+ this.#report();
2158
+ }
2159
+ #report() {
2160
+ const { started, baseBuilt, builderReady, backendSpawned, backendReady } = this.#marks;
2161
+ if (started === undefined || builderReady === undefined || backendReady === undefined)
2162
+ return;
2163
+ this.#reported = true;
2164
+ const ms = (value) => Math.round(value).toString();
2165
+ const parts = [`prepare ${ms(started)}`, `builder ${ms(builderReady - started)}${this.#builderParts()}`];
2166
+ if (backendSpawned !== undefined) {
2167
+ const afterArtifact = baseBuilt !== undefined && backendSpawned < baseBuilt && baseBuilt <= backendReady ? ` (${ms(backendReady - baseBuilt)} after the artifact)` : "";
2168
+ parts.push(`backend ${ms(backendReady - backendSpawned)}${afterArtifact}`);
2169
+ }
2170
+ if (baseBuilt !== undefined)
2171
+ parts.push(`first artifact at ${ms(baseBuilt)}`);
2172
+ this.#logger.info(`ready in ${ms(Math.max(builderReady, backendReady))}ms (${parts.join(" \xB7 ")})`);
2173
+ }
2174
+ #builderParts() {
2175
+ const { started, baseBuilt, builderReady } = this.#marks;
2176
+ if (started === undefined || baseBuilt === undefined || builderReady === undefined)
2177
+ return "";
2178
+ const total = this.#basePhaseMs.total ?? 0;
2179
+ const base = BASE_BUILD_PARTS.flatMap((part) => {
2180
+ const partMs = this.#basePhaseMs[part];
2181
+ return partMs === undefined ? [] : [`${part} ${Math.round(partMs)}`];
2182
+ });
2183
+ const spawn = Math.max(0, Math.round(baseBuilt - started - total));
2184
+ const watch = Math.max(0, Math.round(builderReady - baseBuilt));
2185
+ return `: spawn ${spawn} + base build ${Math.round(total)} [${base.join(" \xB7 ")}] + watch ${watch}`;
2186
+ }
2187
+ }
2188
+
2107
2189
  // pkgs/@akanjs/devkit/akanApp/akanApp.host.ts
2108
2190
  class AkanAppHost {
2109
2191
  app;
@@ -2114,6 +2196,7 @@ class AkanAppHost {
2114
2196
  #lastDevState = null;
2115
2197
  #bootLatch = new DevBootLatch(() => this.#onDevEvent?.({ app: this.app.name, booted: true }));
2116
2198
  #stopping = false;
2199
+ #firstArtifact = "settled";
2117
2200
  #builderMessageQueue = Promise.resolve();
2118
2201
  #backendGraph;
2119
2202
  #statuses;
@@ -2124,6 +2207,7 @@ class AkanAppHost {
2124
2207
  #builder;
2125
2208
  #idle;
2126
2209
  #recycler;
2210
+ #timeline;
2127
2211
  constructor(app, {
2128
2212
  env,
2129
2213
  stdio = "inherit",
@@ -2139,13 +2223,20 @@ class AkanAppHost {
2139
2223
  const isStopping = () => this.#stopping;
2140
2224
  const statuses = new DevBuildStatusBoard(logger);
2141
2225
  this.#statuses = statuses;
2226
+ this.#timeline = new DevStartTimeline(logger);
2142
2227
  this.#backend = new DevBackend(app, { env, stdio, logger, statuses, graph }, {
2143
2228
  isStopping,
2144
- emit: (state, detail) => this.#emitDevEvent(state, detail),
2229
+ emit: (state, detail) => {
2230
+ if (state === "ready")
2231
+ this.#timeline.mark("backendReady");
2232
+ this.#emitDevEvent(state, detail);
2233
+ },
2145
2234
  beforeSpawn: () => {
2235
+ this.#timeline.mark("backendSpawned");
2146
2236
  this.#requests.startGeneration();
2147
2237
  this.#requests.discard("the backend restarted while the builder was away");
2148
2238
  },
2239
+ awaitsArtifact: () => this.#firstArtifact === "pending",
2149
2240
  toBuilder: (message) => this.#requests.send(message)
2150
2241
  });
2151
2242
  this.#gap = new BuilderGap({ graph, backend: this.#backend, logger });
@@ -2166,7 +2257,17 @@ class AkanAppHost {
2166
2257
  isStopping,
2167
2258
  onMessage: (message) => this.#enqueueBuilderMessage(message),
2168
2259
  onAway: () => this.#gap.open("builder replacement"),
2169
- onReady: () => this.#requests.flush(),
2260
+ onReady: () => {
2261
+ this.#timeline.mark("builderReady");
2262
+ this.#requests.flush();
2263
+ },
2264
+ onBaseBuilt: (phaseMs) => {
2265
+ this.#timeline.baseBuilt(phaseMs);
2266
+ if (this.#firstArtifact === "built")
2267
+ this.#backend.scheduleRestart({ files: [], roles: [] });
2268
+ else if (this.#firstArtifact === "pending")
2269
+ this.#firstArtifact = "built";
2270
+ },
2170
2271
  onRestartReady: () => {
2171
2272
  this.logger.verbose("[builder-recovery] builder ready after restart; replaying latest state");
2172
2273
  this.#backend.replay();
@@ -2220,13 +2321,30 @@ class AkanAppHost {
2220
2321
  await this.#backend.stop();
2221
2322
  if (this.#builder.current)
2222
2323
  this.#builder.stop();
2223
- const [redisHost] = await Promise.all([
2224
- this.#prepareDatabase("redis"),
2225
- this.#backendGraph.refresh(),
2226
- this.#builder.start()
2227
- ]);
2228
- Object.assign(this.env, { REDIS_HOST: redisHost });
2229
- this.#backend.start();
2324
+ this.#timeline.begin();
2325
+ const artifactFile = path5.join(this.app.cwdPath, ".akan/artifact/base-artifact.json");
2326
+ this.#firstArtifact = fs2.existsSync(artifactFile) ? "settled" : "pending";
2327
+ const prepared = Promise.all([this.#prepareDatabase("redis"), this.#backendGraph.refresh()]).then(([redisHost]) => {
2328
+ Object.assign(this.env, { REDIS_HOST: redisHost });
2329
+ if (this.#firstArtifact !== "settled")
2330
+ this.#backend.start();
2331
+ });
2332
+ try {
2333
+ await Promise.all([this.#builder.start(), prepared]);
2334
+ } catch (error) {
2335
+ this.#firstArtifact = "settled";
2336
+ if (!this.#stopping)
2337
+ await this.#backend.stop();
2338
+ throw error;
2339
+ }
2340
+ const artifactMissing = this.#firstArtifact === "pending" && !fs2.existsSync(artifactFile);
2341
+ this.#firstArtifact = "settled";
2342
+ if (artifactMissing && !this.#stopping) {
2343
+ await this.#backend.restarting;
2344
+ await this.#backend.stop();
2345
+ }
2346
+ if (!this.#backend.running)
2347
+ this.#backend.start();
2230
2348
  this.#idle.arm();
2231
2349
  return this;
2232
2350
  }
@@ -2319,16 +2437,16 @@ class AkanAppHost {
2319
2437
  }
2320
2438
  }
2321
2439
  // pkgs/@akanjs/devkit/app/applicationTestPreload.ts
2322
- import path5 from "path";
2440
+ import path6 from "path";
2323
2441
  var SIGNAL_TEST_PRELOAD_PATH = "test/signalTest.preload.ts";
2324
2442
  async function resolveSignalTestPreloadPath(target) {
2325
2443
  const candidates = [];
2326
- for (const basePath of [target.cwdPath, process.cwd(), path5.dirname(Bun.main), import.meta.dir]) {
2444
+ for (const basePath of [target.cwdPath, process.cwd(), path6.dirname(Bun.main), import.meta.dir]) {
2327
2445
  try {
2328
- candidates.push(path5.join(path5.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
2446
+ candidates.push(path6.join(path6.dirname(Bun.resolveSync("akanjs/package.json", basePath)), SIGNAL_TEST_PRELOAD_PATH));
2329
2447
  } catch {}
2330
2448
  }
2331
- candidates.push(path5.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.join(path5.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path5.resolve(import.meta.dir, "../../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
2449
+ candidates.push(path6.join(target.cwdPath, "../../node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path6.join(target.cwdPath, "../../pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path6.join(process.cwd(), "node_modules/akanjs", SIGNAL_TEST_PRELOAD_PATH), path6.join(process.cwd(), "pkgs/akanjs", SIGNAL_TEST_PRELOAD_PATH), path6.join(path6.dirname(Bun.main), "../../akanjs", SIGNAL_TEST_PRELOAD_PATH), path6.resolve(import.meta.dir, "../../../akanjs", SIGNAL_TEST_PRELOAD_PATH));
2332
2450
  const uniqueCandidates = [...new Set(candidates)];
2333
2451
  for (const candidate of uniqueCandidates)
2334
2452
  if (await Bun.file(candidate).exists())
@@ -2344,7 +2462,7 @@ import { Logger as Logger4, toError } from "akanjs/common";
2344
2462
 
2345
2463
  // pkgs/@akanjs/cli/application/testTarget.ts
2346
2464
  import { readdirSync, realpathSync, statSync } from "fs";
2347
- import path6 from "path";
2465
+ import path7 from "path";
2348
2466
  import { Logger as Logger3 } from "akanjs/common";
2349
2467
  var testFileName = /[._](test|spec)\.[cm]?[jt]sx?$/i;
2350
2468
  var hasTestFile = (dir, seen = new Set) => {
@@ -2353,7 +2471,7 @@ var hasTestFile = (dir, seen = new Set) => {
2353
2471
  return false;
2354
2472
  seen.add(real);
2355
2473
  return readdirSync(dir, { withFileTypes: true }).some((entry) => {
2356
- const entryPath = path6.join(dir, entry.name);
2474
+ const entryPath = path7.join(dir, entry.name);
2357
2475
  const isDir = entry.isDirectory() || entry.isSymbolicLink() && statSync(entryPath, { throwIfNoEntry: false })?.isDirectory();
2358
2476
  if (!isDir)
2359
2477
  return testFileName.test(entry.name);
@@ -2362,7 +2480,7 @@ var hasTestFile = (dir, seen = new Set) => {
2362
2480
  };
2363
2481
  var testTargetOf = (exec) => {
2364
2482
  const root = exec instanceof SysExecutor || exec instanceof PkgExecutor2 ? exec.workspace.workspaceRoot : process.cwd();
2365
- return { root, target: path6.relative(root, exec.cwdPath).split(path6.sep).join("/") };
2483
+ return { root, target: path7.relative(root, exec.cwdPath).split(path7.sep).join("/") };
2366
2484
  };
2367
2485
  var reportsNoTestFile = (exec) => {
2368
2486
  if (hasTestFile(exec.cwdPath))
@@ -2373,7 +2491,7 @@ var reportsNoTestFile = (exec) => {
2373
2491
  };
2374
2492
 
2375
2493
  // pkgs/@akanjs/cli/application/application.runner.ts
2376
- var loadBuildRunner = async () => (await import("./applicationBuildRunner-trfxv3pd.js")).ApplicationBuildRunner;
2494
+ var loadBuildRunner = async () => (await import("./applicationBuildRunner-19c76791.js")).ApplicationBuildRunner;
2377
2495
  var loadPrompts = async () => await import("@inquirer/prompts");
2378
2496
 
2379
2497
  class ApplicationRunner extends runner("application") {
@@ -2425,7 +2543,7 @@ class ApplicationRunner extends runner("application") {
2425
2543
  });
2426
2544
  }
2427
2545
  static runtimeDirOf(app, override) {
2428
- return path7.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path7.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
2546
+ return path8.resolve(override ?? process.env.AKAN_RUNTIME_DIR ?? path8.join(app.workspace.workspaceRoot, "local", "apps", app.name, "runtime"));
2429
2547
  }
2430
2548
  async runLogs(app, options) {
2431
2549
  const { LogControlUnavailableError, LogTailClient } = await import("akanjs/server/logging/logTailClient");
@@ -2451,7 +2569,7 @@ class ApplicationRunner extends runner("application") {
2451
2569
  });
2452
2570
  } catch (error) {
2453
2571
  if (error instanceof LogControlUnavailableError)
2454
- throw new Error(`${app.name} is not running (no ${path7.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
2572
+ throw new Error(`${app.name} is not running (no ${path8.basename(socketPath)} in ${runtimeDir}). Start it with \`akan start ${app.name}\`, or pass --runtime-dir for a built app.`);
2455
2573
  throw error;
2456
2574
  }
2457
2575
  const sinceMs = since ? LogQueryMatcher.parseSince(since) : undefined;
@@ -2513,7 +2631,7 @@ try {
2513
2631
  const serverPath = `${app.cwdPath}/server.ts`;
2514
2632
  if (!await app.exists("server.ts"))
2515
2633
  throw new Error(`Server file not found: apps/${app.name}/server.ts`);
2516
- const target = path7.resolve(app.workspace.workspaceRoot, dir);
2634
+ const target = path8.resolve(app.workspace.workspaceRoot, dir);
2517
2635
  const code = `
2518
2636
  const { server } = await import(${JSON.stringify(serverPath)});
2519
2637
  const { DatabaseAdaptorRole, DocumentTransfer } = await import("akanjs/service");
@@ -2574,7 +2692,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
2574
2692
  await new (await loadBuildRunner())(app).typecheck(options);
2575
2693
  }
2576
2694
  async typecheckLibrary(lib, options = {}) {
2577
- const { ProjectTypecheck } = await import("./projectTypecheck-f4qhbecd.js");
2695
+ const { ProjectTypecheck } = await import("./projectTypecheck-7g542ymk.js");
2578
2696
  const root = lib.workspace.workspaceRoot;
2579
2697
  await new ProjectTypecheck(lib.cwdPath, root, { ...process.env, AKAN_WORKSPACE_ROOT: root }).run([
2580
2698
  "../../server.ts",
@@ -2587,14 +2705,14 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
2587
2705
  }
2588
2706
  resolveTestPaths(exec, files) {
2589
2707
  const { root, target } = testTargetOf(exec);
2590
- const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
2708
+ const isInside = (relative) => relative !== ".." && !relative.startsWith(`..${path8.sep}`) && !path8.isAbsolute(relative);
2591
2709
  return files.map((file) => {
2592
- const candidates = path7.isAbsolute(file) ? [file] : [path7.resolve(exec.cwdPath, file), path7.resolve(root, file)];
2593
- const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) => path7.relative(exec.cwdPath, candidate));
2710
+ const candidates = path8.isAbsolute(file) ? [file] : [path8.resolve(exec.cwdPath, file), path8.resolve(root, file)];
2711
+ const existing = candidates.filter((candidate) => existsSync(candidate)).map((candidate) => path8.relative(exec.cwdPath, candidate));
2594
2712
  const found = existing.find(isInside);
2595
2713
  if (found === undefined)
2596
2714
  throw new Error(existing.length ? `${file} is outside ${target}: akan test ${exec.name} runs its own tests only` : `${file} names no file or folder in ${target}`);
2597
- return `./${found.split(path7.sep).join("/")}`;
2715
+ return `./${found.split(path8.sep).join("/")}`;
2598
2716
  });
2599
2717
  }
2600
2718
  async test(exec, testPaths = [], flags = []) {
@@ -2607,7 +2725,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
2607
2725
  AKAN_TEST_TARGET_TYPE: exec.type,
2608
2726
  AKAN_TEST_TARGET_NAME: exec.name,
2609
2727
  AKAN_TEST_LIBS: exec.getScanInfo({ allowEmpty: true })?.getLibs().join(",") ?? "",
2610
- AKAN_RUNTIME_DIR: path7.join(exec.workspace.workspaceRoot, "local", `${exec.type}s`, exec.name, "runtime")
2728
+ AKAN_RUNTIME_DIR: path8.join(exec.workspace.workspaceRoot, "local", `${exec.type}s`, exec.name, "runtime")
2611
2729
  } : {};
2612
2730
  const args = ["test", "--isolate", ...flags, ...preloadPath ? ["--preload", preloadPath] : [], ...testPaths];
2613
2731
  await exec.spawn("bun", args, {
@@ -2724,7 +2842,7 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
2724
2842
  try {
2725
2843
  return realpathSync2.native(root);
2726
2844
  } catch {
2727
- return path7.resolve(root);
2845
+ return path8.resolve(root);
2728
2846
  }
2729
2847
  };
2730
2848
  return canonical(reported) === canonical(own);
@@ -2748,13 +2866,13 @@ if (loaded) process.exitCode = await loaded.migrations.command(loaded.server, ar
2748
2866
  if (!mobileTarget || targets.length > 1)
2749
2867
  throw new Error("pack-update packs one native target at a time; pass --target <name>.");
2750
2868
  const nativeApp = new NativeApp(app, mobileTarget, env);
2751
- await UpdatePackFolder.clear(path7.resolve(out ?? path7.join(nativeApp.updatesDir, platform)));
2869
+ await UpdatePackFolder.clear(path8.resolve(out ?? path8.join(nativeApp.updatesDir, platform)));
2752
2870
  const pinned = publicEnv ? await NativePublicEnv.load(publicEnv) : against ? await NativePublicEnv.recordedIn(against) : null;
2753
2871
  await this.#buildMobileCsr(app, env, undefined, pinned);
2754
2872
  const { pack } = await nativeApp.packUpdate(platform, { out });
2755
2873
  app.logger.info(`packed ${mobileTarget.name} ${platform} for channel '${pack.channel}' to ${pack.out}: ${pack.files} files, ${(pack.size / 1024).toFixed(0)} KiB, native API ${pack.nativeApi}`);
2756
2874
  if (against) {
2757
- const bundle = path7.join(pack.out, UpdatePackFolder.bundleFile);
2875
+ const bundle = path8.join(pack.out, UpdatePackFolder.bundleFile);
2758
2876
  const compat = await NativeApp.compareBundles(app.cwdPath, against, bundle);
2759
2877
  const envProblem = await NativePublicEnv.problemAgainst(against, bundle);
2760
2878
  await UpdatePackFolder.writeCompat(pack, {
@@ -3001,7 +3119,7 @@ ${detail}`
3001
3119
  }
3002
3120
 
3003
3121
  // pkgs/@akanjs/cli/verify/verifyScope.ts
3004
- import path8 from "path";
3122
+ import path9 from "path";
3005
3123
  import ts from "typescript";
3006
3124
 
3007
3125
  class VerifyScope {
@@ -3045,11 +3163,11 @@ class VerifyScope {
3045
3163
  }
3046
3164
  static async#libImportsIn(workspaceRoot, dir) {
3047
3165
  const libs = new Set;
3048
- const cwd = path8.join(workspaceRoot, dir);
3166
+ const cwd = path9.join(workspaceRoot, dir);
3049
3167
  for await (const file of new Bun.Glob("**/*.{ts,tsx}").scan({ cwd })) {
3050
3168
  if (/(^|[\\/])(node_modules|dist)[\\/]/.test(file))
3051
3169
  continue;
3052
- const text = await Bun.file(path8.join(cwd, file)).text();
3170
+ const text = await Bun.file(path9.join(cwd, file)).text();
3053
3171
  if (!text.includes("@libs/"))
3054
3172
  continue;
3055
3173
  for (const { fileName } of ts.preProcessFile(text, true, true).importedFiles) {
@@ -1,31 +1,31 @@
1
1
  // @bun
2
- import {
3
- ApplicationBuildReporter
4
- } from "./index-dmcpetwe.js";
5
2
  import {
6
3
  parseBiomeReport,
7
4
  Linter,
8
5
  ProjectTypecheck2
9
- } from "./index-71y6176j.js";
6
+ } from "./index-v16gj2as.js";
10
7
  import {
11
8
  TypecheckFailure
12
9
  } from "./index-j4yvgfhr.js";
10
+ import {
11
+ ApplicationBuildReporter
12
+ } from "./index-8bta5pnr.js";
13
13
  import {
14
14
  AppExecutor2
15
- } from "./index-z92zm3wd.js";
15
+ } from "./index-9a9t77hz.js";
16
16
  import {
17
17
  LibExecutor2
18
- } from "./index-zfnz878d.js";
18
+ } from "./index-yey1envc.js";
19
19
  import {
20
20
  PkgExecutor2
21
- } from "./index-w1zexzpx.js";
21
+ } from "./index-crd99zqs.js";
22
22
  import {
23
23
  WorkspaceRunner,
24
24
  AkanQualityScanner
25
- } from "./index-78y75t0a.js";
25
+ } from "./index-j2wq064m.js";
26
26
  import {
27
27
  VerifyScope
28
- } from "./index-z96ks033.js";
28
+ } from "./index-wkwe91sn.js";
29
29
 
30
30
  // pkgs/@akanjs/cli/verify/verifyComments.ts
31
31
  import { existsSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  FileSys2
4
- } from "./index-by2tvsq6.js";
4
+ } from "./index-zyjztrvc.js";
5
5
  import {
6
6
  ShellOnlyEnv
7
7
  } from "./index-bejy9zyc.js";
@@ -5,7 +5,7 @@ import {
5
5
  SysExecutor,
6
6
  WorkspaceExecutor,
7
7
  AkanLibConfig
8
- } from "./index-71y6176j.js";
8
+ } from "./index-v16gj2as.js";
9
9
 
10
10
  // pkgs/@akanjs/devkit/executors/libExecutor.ts
11
11
  class LibExecutor2 extends SysExecutor {
@@ -39,7 +39,7 @@ class FileSys2 {
39
39
  return await Bun.file(path).write(content);
40
40
  }
41
41
  static async writeTextAtomic(filePath, content) {
42
- const temp = `${filePath}.${process.pid}.${Date.now().toString(36)}.tmp`;
42
+ const temp = `${filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
43
43
  try {
44
44
  await Bun.write(temp, content);
45
45
  await FileSys2.replace(temp, filePath);
package/index.js CHANGED
@@ -4,14 +4,14 @@ import {
4
4
  getTargetMetas,
5
5
  getTargetCommandNames,
6
6
  runCommands
7
- } from "./index-2yn3r67f.js";
7
+ } from "./index-nnmw56fz.js";
8
8
  import"./index-j4yvgfhr.js";
9
- import"./index-71y6176j.js";
10
- import"./index-by2tvsq6.js";
11
- import"./index-z92zm3wd.js";
12
- import"./index-zfnz878d.js";
13
- import"./index-w1zexzpx.js";
14
- import"./index-7wf8snar.js";
9
+ import"./index-v16gj2as.js";
10
+ import"./index-zyjztrvc.js";
11
+ import"./index-9a9t77hz.js";
12
+ import"./index-yey1envc.js";
13
+ import"./index-crd99zqs.js";
14
+ import"./index-3r1crbct.js";
15
15
 
16
16
  // pkgs/@akanjs/cli/bunVersionGuard.ts
17
17
  class BunVersionGuard {
@@ -27,27 +27,27 @@ import path from "path";
27
27
 
28
28
  // pkgs/@akanjs/cli/commandModules.ts
29
29
  var commandModules = {
30
- workspace: async () => (await import("./workspace.command-ahhfpaag.js")).WorkspaceCommand,
31
- agent: async () => (await import("./agent.command-x65f2ags.js")).AgentCommand,
32
- code: async () => (await import("./code.command-5smx61yf.js")).CodeCommand,
33
- application: async () => (await import("./application.command-azbd1pb2.js")).ApplicationCommand,
34
- library: async () => (await import("./library.command-nxvesvhb.js")).LibraryCommand,
35
- localRegistry: async () => (await import("./localRegistry.command-xz62e4ng.js")).LocalRegistryCommand,
36
- package: async () => (await import("./package.command-j7hv26p0.js")).PackageCommand,
37
- module: async () => (await import("./module.command-aaws9byg.js")).ModuleCommand,
38
- page: async () => (await import("./page.command-7yffs7n9.js")).PageCommand,
39
- context: async () => (await import("./context.command-ym5jbkny.js")).ContextCommand,
40
- cloud: async () => (await import("./cloud.command-gapp4634.js")).CloudCommand,
41
- subspace: async () => (await import("./subspace.command-4n4n4jpv.js")).SubspaceCommand,
42
- guideline: async () => (await import("./guideline.command-zwypaqsh.js")).GuidelineCommand,
43
- scalar: async () => (await import("./scalar.command-2ex84spb.js")).ScalarCommand,
44
- primitive: async () => (await import("./primitive.command-7a1pt715.js")).PrimitiveCommand,
45
- quality: async () => (await import("./quality.command-c6mvrjh1.js")).QualityCommand,
46
- verify: async () => (await import("./verify.command-zrkxnvct.js")).VerifyCommand,
47
- repair: async () => (await import("./repair.command-093adzt9.js")).RepairCommand,
48
- workflow: async () => (await import("./workflow.command-ks16jegk.js")).WorkflowCommand,
49
- pipeline: async () => (await import("./pipeline.command-7yk0zcng.js")).PipelineCommand,
50
- tunnel: async () => (await import("./tunnel.command-f7ep1qfa.js")).TunnelCommand
30
+ workspace: async () => (await import("./workspace.command-8mp4mcp2.js")).WorkspaceCommand,
31
+ agent: async () => (await import("./agent.command-x55ncdjm.js")).AgentCommand,
32
+ code: async () => (await import("./code.command-m6skj1kj.js")).CodeCommand,
33
+ application: async () => (await import("./application.command-xpntxnh8.js")).ApplicationCommand,
34
+ library: async () => (await import("./library.command-8abb26pg.js")).LibraryCommand,
35
+ localRegistry: async () => (await import("./localRegistry.command-sa211m1z.js")).LocalRegistryCommand,
36
+ package: async () => (await import("./package.command-akynhtee.js")).PackageCommand,
37
+ module: async () => (await import("./module.command-z3cwjf0p.js")).ModuleCommand,
38
+ page: async () => (await import("./page.command-3fpdavk9.js")).PageCommand,
39
+ context: async () => (await import("./context.command-3c3nv0d6.js")).ContextCommand,
40
+ cloud: async () => (await import("./cloud.command-p3ybjes7.js")).CloudCommand,
41
+ subspace: async () => (await import("./subspace.command-9wekm4gn.js")).SubspaceCommand,
42
+ guideline: async () => (await import("./guideline.command-725fq5p0.js")).GuidelineCommand,
43
+ scalar: async () => (await import("./scalar.command-z9qfxnvm.js")).ScalarCommand,
44
+ primitive: async () => (await import("./primitive.command-xwe9ggnf.js")).PrimitiveCommand,
45
+ quality: async () => (await import("./quality.command-7wz7y8z1.js")).QualityCommand,
46
+ verify: async () => (await import("./verify.command-j0w9dr5c.js")).VerifyCommand,
47
+ repair: async () => (await import("./repair.command-dej1qtfq.js")).RepairCommand,
48
+ workflow: async () => (await import("./workflow.command-yt4sz04b.js")).WorkflowCommand,
49
+ pipeline: async () => (await import("./pipeline.command-ca95n8rd.js")).PipelineCommand,
50
+ tunnel: async () => (await import("./tunnel.command-cxc4h3j8.js")).TunnelCommand
51
51
  };
52
52
  var commandModuleIds = Object.keys(commandModules);
53
53
 
@@ -75,6 +75,8 @@ class CommandManifest {
75
75
  }
76
76
  static resolve(manifest, argv) {
77
77
  const requested = argv[2];
78
+ if (requested === "--version" || requested === "-V")
79
+ return [];
78
80
  if (!manifest || !requested || requested.startsWith("-"))
79
81
  return null;
80
82
  const id = manifest.byCommand[requested];
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  LibExecutor2
4
- } from "./index-zfnz878d.js";
5
- import"./index-71y6176j.js";
4
+ } from "./index-yey1envc.js";
5
+ import"./index-v16gj2as.js";
6
6
  import"./index-j4yvgfhr.js";
7
- import"./index-by2tvsq6.js";
7
+ import"./index-zyjztrvc.js";
8
8
  export {
9
9
  LibExecutor2 as LibExecutor
10
10
  };