@akanjs/devkit 3.2.0-rc.12 → 3.2.0-rc.14

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.
package/CHANGELOG.md CHANGED
@@ -226,6 +226,7 @@
226
226
 
227
227
  **For an existing workspace** nothing is required. To give a fresh clone values other than the empty defaults, commit an `env/env.server.example.ts` (and `env.client.example.ts`) without secrets in it; in an older workspace, add `!**/env.client.example.ts` to `.gitignore` for the client one. If you link env files into a new worktree, link them before the first `akan` command there, or replace the defaults it wrote.
228
228
 
229
+ - fd2c575: A dev server that stops no longer re-arms its idle-suspend timer or keeps a file watcher running. A wake that settles after the stop, a builder message or relayed request that arrives after it, and an idle watcher that finishes starting after it each used to re-arm the timer, report the host awake, or leave the watcher open. A request that reaches a host stopped while suspended is now refused at once instead of being held for a wake that never comes.
229
230
  - e2b809a: The typecheck behind `akan typecheck`, `akan verify` and `akan build` now uses its incremental cache. It wrote a `.tsbuildinfo` on every run, then checked every file again anyway, so a run with nothing changed cost as much as the first: about 8 seconds on a 2,400-file project. Now a run re-checks only the files that changed and the files they affect, and reads the rest from the cache. The same project's second run takes about 1.2 seconds. The diagnostics are the same, in the same order, as a full check: options, global, syntax, type and declaration errors, an edited file's new errors and the errors it causes in files that import it. `--clean` still clears the cache first.
230
231
  - bf28968: An app can now serve its default locale at unprefixed paths. Set `i18n.localePrefix` to `"as-needed"` in `akan.config.ts`, and `/books/OL45804W` is the English page itself. Before, every page lived under `/<locale>/…`, and an unprefixed path answered with a 307 to the locale the browser asked for. An app with one language, or with URLs fixed from outside (OAuth callbacks, QR codes, links in mail, a migrated site), could only meet them with raw `<a href>`s, which reloaded the whole page and went through that 307 on every click.
231
232
 
@@ -402,6 +403,8 @@
402
403
  - **A new `akanApi` guideline** lists every import path and the exact signatures of the route stages, `router`, `Link`, `serve`, `adapt`, the endpoint builders, `SignalOption`, `serviceDictionary`, and the keys of `akan.config.ts` with the `web` and `i18n` shapes. It is generated from the akanjs types of the same release, and a test fails when the two drift apart. `akan agent install` ships it as a reference of both skills, and `get_guideline` / `akan guideline show akanApi` print it.
403
404
  - **`ServiceOptions.serverMode`** carries a doc comment, so an editor shows the same explanation on hover.
404
405
 
406
+ - 6bb1610: Internal: the dev host (`AkanAppHost`) runs the backend, the builder, idle suspend, RSS recycling and dev-plan restarts through one collaborator each instead of one 126-member class. Its public members, start and stop order, restart timing and messages are unchanged.
407
+ - 7aad7c1: `executors.ts` is split into one file per class under `executors/` and re-exports the same names, so every import of `@akanjs/devkit/executors` and the root barrel is unchanged. Each file under `executors/` also loads on its own: `akanConfig` and `scanInfo` import the `SysExecutor` subclasses when they use them, so no import order loads a subclass before its base.
405
408
  - 58f1c64: A route's client code no longer carries the UI of every module in the app and in each lib its store merges.
406
409
 
407
410
  - **Bootstrap.** Each route's `"use client"` entry, every generated root layout and the SSR dev registry start with `import "@apps/<app>/lib/useClient"` and `import "@apps/<app>/lib/st"`, which load the client runtime and the store. They used to import `@apps/<app>/client` bare, and that bundled the whole barrel.
@@ -479,10 +482,12 @@
479
482
  - d2b2291: A failed workflow no longer reports success to its caller. `akan workflow plan` exits 1 when the plan has an error, `akan workflow apply` when the apply or its `--dry-run` fails, and `akan workflow validate` when its status is `failed` (which includes `passed-with-baseline-blockers`); all three exited 0 before. A dry run of a plan with an error, such as `add-field --type Number`, reports `failed` and lists no changed or generated files, where it used to list the plan's edits under "Automatically Modified". Over MCP, `plan_workflow` names `apply_workflow` in `next` and `approval.canApplyWith` only for a plan without an error, and `apply_workflow` names `run_validation` only when the apply did not fail; a refused plan also drops its "apply this plan" and "validate the apply report" recommendations. The workflows that write into an existing module (`add-field`, `add-enum-field`, `add-mutation`, `add-slice`, `create-ui`, `rename-key`) now refuse a service module, or any folder without its `<module>.constant.ts`, at plan time and again at apply. The `workflow-module-not-database` error lists the target's database modules and points at `create-module`, and for a field at `create-scalar`. Before, `add-field` on a service module passed its plan and dry run and failed only at apply, and `create-ui` wrote a misnamed `_<service>.View.tsx` into it. The `workflow-module-missing` error now lists only database modules too, says a name that matches a service module (with or without its `_`) is one instead of asking "Did you mean \_<service>?", and points at another app or library only when it holds a database module of that name.
480
483
  - adcdf3b: `akan workflow plan` and the `plan_workflow` MCP tool refuse a module the target app or library lacks, for every workflow that writes into an existing module (`add-field`, `add-enum-field`, `add-mutation`, `add-slice`, `create-ui`, `rename-key`). The `workflow-module-missing` error names the module, lists the modules the target has, and points at the module whose name differs only in case or by a leading `_`, at a scalar of that name, or at the app or library that holds it; only when none exists does it point at `create-module`. Before, the plan passed and its dry run reported `passed`. `add-mutation` used to plan a missing module with a warning so that a `create-module` plan could precede it; it now refuses too, so plan it after applying `create-module`. Every workflow now refuses an unknown `app` at plan time, listing the workspace's apps and libraries. `apply` and `--dry-run` check the target again before anything else, so a plan written earlier for a module that is gone fails instead of passing. `plan_workflow` now inspects the MCP server's workspace rather than the process directory.
481
484
  - Updated dependencies [bd198af]
485
+ - Updated dependencies [ba81635]
482
486
  - Updated dependencies [bc792ab]
483
487
  - Updated dependencies [e9a2c7f]
484
488
  - Updated dependencies [eb88032]
485
489
  - Updated dependencies [31f7039]
490
+ - Updated dependencies [8c70603]
486
491
  - Updated dependencies [61fbd7d]
487
492
  - Updated dependencies [b3f85fa]
488
493
  - Updated dependencies [a707354]
@@ -517,6 +522,7 @@
517
522
  - Updated dependencies [d9eaacc]
518
523
  - Updated dependencies [c334caf]
519
524
  - Updated dependencies [170be15]
525
+ - Updated dependencies [f314eba]
520
526
  - Updated dependencies [e143263]
521
527
  - Updated dependencies [e4f7876]
522
528
  - Updated dependencies [cb0fd5b]
@@ -564,10 +570,12 @@
564
570
  - Updated dependencies [99fda20]
565
571
  - Updated dependencies [db5b284]
566
572
  - Updated dependencies [5e08722]
573
+ - Updated dependencies [2bf769f]
567
574
  - Updated dependencies [91ccf38]
568
575
  - Updated dependencies [c2af76a]
569
576
  - Updated dependencies [df32c46]
570
577
  - Updated dependencies [5f809e8]
578
+ - Updated dependencies [a5c476a]
571
579
  - Updated dependencies [76705dd]
572
580
  - Updated dependencies [206bb69]
573
581
  - Updated dependencies [170be15]
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import path from "node:path";
3
+ import type { BuilderMessage } from "akanjs/server";
3
4
  import { IncrementalBuilderHost } from "../incrementalBuilder";
4
5
  import { createTempApp, isolateEnv, tempRoots, writeText } from "../testHelpers";
5
6
  import { AkanAppHost } from "./akanApp.host";
@@ -195,6 +196,118 @@ describe("a builder request while no builder is running", () => {
195
196
  });
196
197
  });
197
198
 
199
+ describe("the builder's answers and a returning builder", () => {
200
+ isolateEnv({ AKAN_PUBLIC_REPO_NAME: "repo", AKAN_PUBLIC_SERVE_DOMAIN: "localhost", AKAN_PUBLIC_ENV: "local" });
201
+ const track = tempRoots();
202
+ const until = async (done: () => boolean | Promise<boolean>, timeoutMs = 10_000) => {
203
+ const deadline = performance.now() + timeoutMs;
204
+ while (!(await done()) && performance.now() < deadline) await Bun.sleep(25);
205
+ expect(await done()).toBe(true);
206
+ };
207
+ const fakeBuilder = (sent: BuilderMessage[]) =>
208
+ ({
209
+ status: "ready",
210
+ patcherOff: false,
211
+ start: ({ onReady }: { onReady?: () => void }) => onReady?.(),
212
+ send: (message: BuilderMessage) => {
213
+ sent.push(message);
214
+ return true;
215
+ },
216
+ stop: () => undefined,
217
+ }) as unknown as IncrementalBuilderHost;
218
+
219
+ test("a restarted backend never receives its predecessor's answer", async () => {
220
+ const { root, app } = track(await createTempApp("demo"));
221
+ const bootPath = path.join(root, "boot.txt");
222
+ const repliesPath = path.join(root, "replies.txt");
223
+ await writeText(
224
+ path.join(root, "apps/demo/main.ts"),
225
+ [
226
+ 'import fs from "node:fs";',
227
+ `const bootPath = ${JSON.stringify(bootPath)};`,
228
+ `const repliesPath = ${JSON.stringify(repliesPath)};`,
229
+ 'const boot = (fs.existsSync(bootPath) ? Number(fs.readFileSync(bootPath, "utf8")) : 0) + 1;',
230
+ "fs.writeFileSync(bootPath, String(boot));",
231
+ 'process.on("message", (message) => {',
232
+ ' if (message?.type === "build-graph-res") fs.appendFileSync(repliesPath, message.id + ":" + message.error + "\\n");',
233
+ "});",
234
+ 'process.send?.({ type: "backend-ready", pid: process.pid });',
235
+ 'process.send?.({ type: "build-graph", id: 1 });',
236
+ "if (boot === 1) setTimeout(() => process.exit(1), 100);",
237
+ "setInterval(() => undefined, 1_000);",
238
+ "",
239
+ ].join("\n"),
240
+ );
241
+ const sent: BuilderMessage[] = [];
242
+ let toHost: (message: BuilderMessage) => void = () => undefined;
243
+ const create = IncrementalBuilderHost.create;
244
+ IncrementalBuilderHost.create = (async (_app: unknown, _env: unknown, onMessage: typeof toHost) => {
245
+ toHost = onMessage;
246
+ return fakeBuilder(sent);
247
+ }) as unknown as typeof IncrementalBuilderHost.create;
248
+ const host = new AkanAppHost(app, { env: { ...process.env } as Record<string, string> });
249
+ try {
250
+ await host.start();
251
+ await until(() => sent.length >= 2);
252
+ const [stale, live] = sent as unknown as { id: number }[];
253
+ toHost({
254
+ type: "build-graph-res",
255
+ id: stale.id,
256
+ ok: false,
257
+ error: "stale",
258
+ kind: "unavailable",
259
+ } as BuilderMessage);
260
+ toHost({ type: "build-graph-res", id: live.id, ok: false, error: "live", kind: "unavailable" } as BuilderMessage);
261
+ await until(() => Bun.file(repliesPath).exists());
262
+ expect(await Bun.file(repliesPath).text()).toBe("1:live\n");
263
+ } finally {
264
+ await host.stop();
265
+ IncrementalBuilderHost.create = create;
266
+ }
267
+ }, 20_000);
268
+
269
+ test("a request that wakes an idle builder reaches it once the wake ends", async () => {
270
+ process.env.AKAN_DEV_IDLE_SUSPEND_MS = "200";
271
+ const { root, app } = track(await createTempApp("demo"));
272
+ const triggerPath = path.join(root, "trigger.txt");
273
+ await writeText(
274
+ path.join(root, "apps/demo/main.ts"),
275
+ [
276
+ 'import fs from "node:fs";',
277
+ `const triggerPath = ${JSON.stringify(triggerPath)};`,
278
+ 'process.send?.({ type: "backend-ready", pid: process.pid });',
279
+ "const poll = setInterval(() => {",
280
+ " if (!fs.existsSync(triggerPath)) return;",
281
+ " clearInterval(poll);",
282
+ ' process.send?.({ type: "build-graph", id: 5 });',
283
+ "}, 20);",
284
+ "setInterval(() => undefined, 1_000);",
285
+ "",
286
+ ].join("\n"),
287
+ );
288
+ const sent: BuilderMessage[] = [];
289
+ const create = IncrementalBuilderHost.create;
290
+ IncrementalBuilderHost.create = async () => fakeBuilder(sent);
291
+ const suspended = Promise.withResolvers<void>();
292
+ const host = new AkanAppHost(app, {
293
+ env: { ...process.env } as Record<string, string>,
294
+ onDevEvent: (event) => {
295
+ if ("state" in event && event.state === "suspended") suspended.resolve();
296
+ },
297
+ });
298
+ try {
299
+ await host.start();
300
+ await suspended.promise;
301
+ expect(sent.filter((message) => message.type === "build-graph")).toEqual([]);
302
+ await writeText(triggerPath, "go");
303
+ await until(() => sent.some((message) => message.type === "build-graph"));
304
+ } finally {
305
+ await host.stop();
306
+ IncrementalBuilderHost.create = create;
307
+ }
308
+ }, 20_000);
309
+ });
310
+
198
311
  describe("a stop while the builder is starting", () => {
199
312
  isolateEnv({ AKAN_PUBLIC_REPO_NAME: "repo", AKAN_PUBLIC_SERVE_DOMAIN: "localhost", AKAN_PUBLIC_ENV: "local" });
200
313
  const track = tempRoots();