@akanjs/devkit 3.2.0-rc.11 → 3.2.0-rc.13

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
@@ -171,6 +171,7 @@
171
171
 
172
172
  A generated `errorCodes` guideline lists every code a framework error carries, with its status, whether it is forwarded, and whether the caller's JSON carries it; the `akan-err` skill ships it as a reference.
173
173
 
174
+ - d12f556: The barrel-import rewrite maps a name that a barrel re-exports by name from another barrel (`export { migration } from "./migration"`) to the file that declares it, as it already did through `export *`. It used to stop at the inner barrel, so a page that imported one name loaded every module behind it.
174
175
  - 0504209: `akan build <app> --env <env>` builds for an environment other than the workspace `.env`'s, the way the desktop and mobile builds already do. Before, the shell's `AKAN_PUBLIC_ENV` lost to the `.env`, so a new workspace could only build `local` without editing it. The local-build notice, the image guard and the README now say what a `local` build changes in a built server: no endpoint rate limits, and local defaults for Redis and the database mode. They no longer say the dev routes are served, which a built server never does.
175
176
  - bf872ce: A variable the shell sets now outranks the workspace `.env` when `akan` builds or runs an app, as dotenv and Bun's own `.env` loading do: `AKAN_PUBLIC_ENV=main akan build <app>` builds `main` where the `.env` says `local`. The order is `--env` (for `AKAN_PUBLIC_ENV`), then the process environment (the shell, and the `.env.local` and `.env.<NODE_ENV>` Bun loads into it), then the `.env`, then the defaults; an empty export counts as unset. The bundles, the bundled server env, `akan.env.json` and the Dockerfile still take one set of values. Where an exported value outranks the `.env`, `akan build` now warns with both values instead of the old warning that listed the values it ignored, and the server-env message, the `--env` help, the local-build notice, the README and the CLI reference state the new order.
176
177
 
@@ -214,6 +215,7 @@
214
215
  - **`@akanjs/devkit`**: `applyTemplate` takes `dryRun` to list the files a template would write without writing them, and `WorkspaceExecutor.commit` takes an `identity` to commit under.
215
216
 
216
217
  - 1870fcd: `akan verify` adds a `fix:` line to a module file's two-parent import that names the layer barrel to import from instead, such as `import from "@apps/<app>/common"`. The lint message itself now points at the layer barrel too.
218
+ - 5691327: `setErrorConstructor` on `FetchClient`, `HttpClient` and `WsClient`, `HttpClientOptions.ErrorCls` and `FetchClient.build`'s `Err` option are deprecated. Every dictionary's `Err` is `akanjs/common`'s `Err`, which a restored error already is, so they change nothing. They keep working. A generated `lib/sig.ts` no longer calls `fetch.setErrorConstructor(Err)`, and a generated `lib/useClient.ts` no longer passes `{ Err: pageProto.Err }`; `akan sync` rewrites both. No upgrade step is needed.
217
219
  - 76ab8d4: `akan doctor` exits with code 1 when its report says `"status": "failed"`, in text or JSON, with or without `--strict`, and for `--ios`, so the `agent:doctor` script (`akan doctor --strict --format json`) or a CI step fails on it. Before, it always exited 0. The full report still prints on stdout. A warning never changes the exit code: `--strict` still only decides which conventions count as errors, today a missing module abstract. Doctor's `dictionary-label-missing` now reads both a constant's fields and its dictionary's labels from their syntax, ignoring comments and strings. A field that appears only in a comment no longer asks for a label: a new `--sample` workspace no longer warns about `task`'s `priority`, `tags`, `assignee` and `completedAt` or `workHistory`'s `actor` and `previousStatus`, which its constants suggest only in comments. A label that exists only in a comment, or a `name:` inside a string, no longer counts, so a field whose label is commented out now warns.
218
220
  - 245d318: A font declared on a root layout now gets its metric-adjusted fallback faces: `@font-face` rules named `"<font> fallback"` that draw a local system font with `size-adjust`, `ascent-override` and `descent-override` matched to the web font. The variable `--font-<name>` already named that family, but the build never wrote it, because fontaine's `readMetrics` takes a URL and returned nothing for the file path it was given. While a web font loaded (`font-display: swap`), text drew in the browser's default font, usually a serif, and moved when the web font arrived. The metrics are read from the source font, not the subset, so a subset without Latin letters (`subsets: ["ks-x-1001"]`, or only `subsetText`) still sizes the fallback correctly. A font whose metrics cannot be read keeps its face and gets no fallback, as before. Set `adjustFontFallback: false` on a font to keep the old output. Cached font output from `akan start` is regenerated once.
219
221
  - 6f6cc2a: A fresh clone of a workspace now builds and starts after `bun install` alone. The env files that hold secrets stay gitignored, so a clone has none of them: before, `akan typecheck`, `akan build` and `akan verify` failed with `Cannot find module './env.server.local'`, and with no `.env` the CLI picked the `debug` environment, so `akan build` stopped asking for `AKAN_PUBLIC_REPO_NAME` and `AKAN_PUBLIC_SERVE_DOMAIN`.
@@ -224,6 +226,7 @@
224
226
 
225
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.
226
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.
227
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.
228
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.
229
232
 
@@ -400,6 +403,8 @@
400
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.
401
404
  - **`ServiceOptions.serverMode`** carries a doc comment, so an editor shows the same explanation on hover.
402
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.
403
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.
404
409
 
405
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.
@@ -477,10 +482,12 @@
477
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.
478
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.
479
484
  - Updated dependencies [bd198af]
485
+ - Updated dependencies [ba81635]
480
486
  - Updated dependencies [bc792ab]
481
487
  - Updated dependencies [e9a2c7f]
482
488
  - Updated dependencies [eb88032]
483
489
  - Updated dependencies [31f7039]
490
+ - Updated dependencies [8c70603]
484
491
  - Updated dependencies [61fbd7d]
485
492
  - Updated dependencies [b3f85fa]
486
493
  - Updated dependencies [a707354]
@@ -506,12 +513,16 @@
506
513
  - Updated dependencies [dcb7e61]
507
514
  - Updated dependencies [6d5b544]
508
515
  - Updated dependencies [73f8830]
516
+ - Updated dependencies [5691327]
509
517
  - Updated dependencies [958f175]
510
518
  - Updated dependencies [9f30e93]
519
+ - Updated dependencies [ad09fac]
520
+ - Updated dependencies [ae045d8]
511
521
  - Updated dependencies [d9eaacc]
512
522
  - Updated dependencies [d9eaacc]
513
523
  - Updated dependencies [c334caf]
514
524
  - Updated dependencies [170be15]
525
+ - Updated dependencies [f314eba]
515
526
  - Updated dependencies [e143263]
516
527
  - Updated dependencies [e4f7876]
517
528
  - Updated dependencies [cb0fd5b]
@@ -522,6 +533,8 @@
522
533
  - Updated dependencies [f3def22]
523
534
  - Updated dependencies [8424863]
524
535
  - Updated dependencies [bf28968]
536
+ - Updated dependencies [dfc3564]
537
+ - Updated dependencies [d12f556]
525
538
  - Updated dependencies [9b5bcee]
526
539
  - Updated dependencies [4561152]
527
540
  - Updated dependencies [73e833b]
@@ -538,6 +551,7 @@
538
551
  - Updated dependencies [9a9e1fa]
539
552
  - Updated dependencies [af133d7]
540
553
  - Updated dependencies [463fd1e]
554
+ - Updated dependencies [b0ccf6f]
541
555
  - Updated dependencies [9055634]
542
556
  - Updated dependencies [3537448]
543
557
  - Updated dependencies [a373d51]
@@ -556,10 +570,12 @@
556
570
  - Updated dependencies [99fda20]
557
571
  - Updated dependencies [db5b284]
558
572
  - Updated dependencies [5e08722]
573
+ - Updated dependencies [2bf769f]
559
574
  - Updated dependencies [91ccf38]
560
575
  - Updated dependencies [c2af76a]
561
576
  - Updated dependencies [df32c46]
562
577
  - Updated dependencies [5f809e8]
578
+ - Updated dependencies [a5c476a]
563
579
  - Updated dependencies [76705dd]
564
580
  - Updated dependencies [206bb69]
565
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();