@akanjs/devkit 3.3.0-rc.48 → 3.3.0-rc.49

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
@@ -425,6 +425,19 @@
425
425
 
426
426
  `akan lint-all` now runs Biome once over every app, lib and package, then each target's own gates, instead of one Biome run per target at once. Each run scans the whole workspace for the type-aware rules, about 1.6 GB apiece on Biome 2.5.15 (1.0 GB on 2.5.14), so this repository's 13 parallel runs no longer fit a 16 GB Linux runner: the kernel killed some of them, and the npm wrapper reported the killed run as exit 0 with no output. One run here peaks under 3 GB and finishes in about 17 s. `BiomeCheck.run` takes `targets: string[]` in place of `target`.
427
427
 
428
+ - 83d791b: fix(devkit): `akan build` prints one plain line per phase where its output is not a terminal
429
+
430
+ Run by an agent, a CI job or behind a pipe, `akan build` printed each phase twice (a start line, then an end line
431
+ with a coloured tick) and, between them, a coloured logger line carrying a process id and a timestamp:
432
+ `[client-runtime] 34 routes load per module, …`.
433
+
434
+ - Where stderr is not a terminal, a phase is one uncoloured line on stdout when it ends,
435
+ `✓ Compiling backend: 4 entrypoints, 37 outputs (148ms)`, and `✗ <phase> failed` on stderr when it fails. A
436
+ terminal keeps the spinner.
437
+ - The client-runtime count is part of the SSR phase's line everywhere:
438
+ `Building SSR route artifacts: 34 routes, 42 entries; 34 routes load per module, …`. `akan quality runtime` still
439
+ prints it with its reasons.
440
+
428
441
  - 22791e7: A production page loads fewer, larger client files: the client entries exactly the same routes load are built as one.
429
442
 
430
443
  `akan build` gave every `"use client"` file, and every export of one it takes apart, an entry of its own. The bundler puts a module in a chunk of its own for every different set of entries that reach it, so an app with several hundred entries ended with hundreds of small files per page, many under 1 KB, where a file is served uncompressed. Entries that the same set of routes loads are now one entry, so what only they reach is one chunk. Entries any other set of routes loads stay apart, and a route still downloads nothing it did not download before.
@@ -105,3 +105,20 @@ describe("ApplicationBuildReporter.printSummary", () => {
105
105
  );
106
106
  });
107
107
  });
108
+
109
+ describe("ApplicationBuildReporter.create", () => {
110
+ const rawLog = spyOn(Logger, "rawLog").mockImplementation(() => undefined);
111
+ afterEach(() => rawLog.mockClear());
112
+
113
+ test("prints one uncoloured line per finished phase and nothing when one starts, and a failed one to stderr", () => {
114
+ const reporter = ApplicationBuildReporter.create();
115
+ reporter.phaseStart?.({ id: "ssr", label: "Building SSR route artifacts" });
116
+ reporter.phaseDone?.({ id: "ssr", label: "Building SSR route artifacts", durationMs: 3_100, summary: "2 routes" });
117
+ reporter.phaseFail?.({ id: "csr", label: "Building CSR assets" }, new Error("boom"));
118
+
119
+ expect(rawLog.mock.calls).toEqual([
120
+ ["✓ Building SSR route artifacts: 2 routes (3.1s)"],
121
+ ["✗ Building CSR assets failed", undefined, "error"],
122
+ ]);
123
+ });
124
+ });
@@ -31,6 +31,7 @@ export class ApplicationBuildReporter {
31
31
  static create(): ApplicationBuildProgressReporter {
32
32
  return {
33
33
  phaseDone: (phase) => Logger.rawLog(ApplicationBuildReporter.formatPhaseLine(phase)),
34
+ phaseFail: (phase) => Logger.rawLog(`✗ ${phase.label} failed`, undefined, "error"),
34
35
  };
35
36
  }
36
37
 
@@ -11,6 +11,7 @@ import type { App } from "../commandDecorators";
11
11
  import { parseEnvFile, WorkspaceExecutor } from "../executors";
12
12
  import {
13
13
  AllRoutesBuilder,
14
+ type BuildAllRoutesResult,
14
15
  CsrArtifactBuilder,
15
16
  FontPruner,
16
17
  NARROWABLE_VENDOR_SPECIFIERS,
@@ -19,6 +20,7 @@ import {
19
20
  VendorImportScanner,
20
21
  } from "../frontendBuild";
21
22
  import { ServerBundleSecrets } from "../mobile/serverBundleSecrets";
23
+ import { RouteRuntimeReport } from "../quality/routeRuntimeReport";
22
24
  import { SecretEnvDeclaration, type SecretEnvDeclared } from "../transforms/secretEnvDeclaration";
23
25
  import { SecretEnvFile } from "../transforms/secretEnvFile";
24
26
  import { ServerEnvEvaluationError } from "../transforms/serverEnvEvaluationError";
@@ -28,10 +30,11 @@ import { ProjectTypecheck } from "../typecheck/projectTypecheck";
28
30
  import { Spinner } from "../util/spinner";
29
31
  import type { BaseDevEnv, PackageJson } from "../workspace/types";
30
32
  import { AppBin } from "./appBin";
31
- import type {
32
- ApplicationBuildPhaseResult,
33
- ApplicationBuildProgressReporter,
34
- ApplicationBuildResult,
33
+ import {
34
+ type ApplicationBuildPhaseResult,
35
+ type ApplicationBuildProgressReporter,
36
+ ApplicationBuildReporter,
37
+ type ApplicationBuildResult,
35
38
  } from "./applicationBuildReporter";
36
39
  import { RouteFilesReport } from "./routeFilesReport";
37
40
  import { RouteJsBudget, type RouteJsBudgetMode, type RouteJsBudgetStatus, type RouteJsSize } from "./routeJsBudget";
@@ -183,7 +186,9 @@ export class ApplicationBuildRunner {
183
186
 
184
187
  async build({ spinner = false }: BuildOptions = {}): Promise<BuildResult> {
185
188
  // serial build is needed because of Bun.build is unstable for parallel build
186
- this.#spinner = spinner;
189
+ //? ora writes to stderr, and to a file or a pipe it prints each phase twice, the end line in colour.
190
+ this.#spinner = spinner && process.stderr.isTTY;
191
+ if (spinner && !this.#spinner) this.#reporter ??= ApplicationBuildReporter.create();
187
192
  if (this.#verify) this.#app.useVerifyDist();
188
193
  const { web, assets, baseDevEnv } = await this.#app.getConfig();
189
194
  const environment = this.#environment ?? baseDevEnv.env;
@@ -207,7 +212,7 @@ export class ApplicationBuildRunner {
207
212
  async () => (web.ssr ? await this.#buildSsr() : null),
208
213
  (result) =>
209
214
  result
210
- ? `${result.allRoutes.manifest.routeIds.length} routes, ${result.allRoutes.manifest.knownEntries.length} entries`
215
+ ? ApplicationBuildRunner.#ssrSummary(result.allRoutes)
211
216
  : web.ssr
212
217
  ? "skipped"
213
218
  : "disabled by akan.config.ts web.ssr",
@@ -354,6 +359,11 @@ export class ApplicationBuildRunner {
354
359
  );
355
360
  }
356
361
 
362
+ static #ssrSummary({ manifest, runtimeReport }: BuildAllRoutesResult) {
363
+ const built = `${manifest.routeIds.length} routes, ${manifest.knownEntries.length} entries`;
364
+ return runtimeReport ? `${built}; ${RouteRuntimeReport.summary(runtimeReport)}` : built;
365
+ }
366
+
357
367
  async #runPhase<T>(
358
368
  id: BuildPhaseId,
359
369
  label: string,
@@ -25,15 +25,14 @@ export default page()
25
25
 
26
26
  ## Steps
27
27
 
28
- 1. Place the file: `<route>.tsx` or `<dir>/_index.tsx` serves the path, `_layout.tsx` nests a layout (`layout()`;
29
- the root one is `rootLayout()`), `[id]` is a dynamic segment, `(group)` groups without a segment.
30
- 2. Name every `[x]` segment with `.param("x", Type)` and read a query key only with `.search("k", Type)`. Values
31
- arrive typed: `ID` / `String` → string, `Int` / `Float` → number, `Boolean`, `Date` → Dayjs, an `enumOf` class →
32
- its union, `[T]` → array. A path value the type refuses answers not-found, and a search value that fails is
33
- dropped. `lang` reaches every stage and is never declared.
34
- 3. Gate in the `_layout.tsx`'s `.guard()` (below).
35
- 4. In `.render()`: `usePage()`, then fetch, then return.
36
- 5. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
28
+ File names, stages, the `.render()` order and what a route file must never do are the `page` rule, loaded with any
29
+ `page/` file.
30
+
31
+ 1. `.param()` / `.search()` values arrive typed: `ID` / `String` → string, `Int` / `Float` → number, `Boolean`,
32
+ `Date` → Dayjs, an `enumOf` class → its union, `[T]` → array. A path value the type refuses answers not-found,
33
+ and a search value that fails is dropped.
34
+ 2. Gate in the `_layout.tsx`'s `.guard()` (below).
35
+ 3. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
37
36
  `export default override({ Slot: AppComponent })`, no logic. Nested ones merge slot by slot, the closest winning;
38
37
  `componentRule` lists the slots.
39
38
 
@@ -81,8 +80,6 @@ export default page()
81
80
  `duringRender`, an expensive report) sets `.config({ prefetch: false })`; on a `_layout.tsx` it covers every page
82
81
  below, and a page there opts back in with `prefetch: true`.
83
82
 
84
- What a route file must never do — write while rendering, hooks, a second export — is the `page` rule, loaded with
85
- any `page/` file. `pageRule` holds what neither says: client-navigation and navigation guards, head merging, the
86
- script policy, CSR root layouts, lib pages, `devOnly`, the legacy shape. `ssrRule`: what may render on the server;
87
- `akan-mcp`: `.prompt()` and `.app()`. Stage signatures, router methods, Link props and import paths are in the
88
- `akanApi-*` references below.
83
+ `pageRule` holds what neither this skill nor the `page` rule says: client-navigation and navigation guards, head
84
+ merging, the script policy, CSR root layouts, lib pages, `devOnly`, the legacy shape. `ssrRule`: what may render on
85
+ the server; `akan-mcp`: `.prompt()` and `.app()`.
@@ -15,9 +15,8 @@ dictionary is a `serviceDictionary`.
15
15
  - Read the module's `*.abstract.md` **before** changing it — it states the invariants the code cannot show.
16
16
  Update it when an invariant, workflow, or public behaviour changes; not for formatting or imports.
17
17
  - Keep the public surface in the signal layer and the decisions in the service.
18
- - Service methods stay a few lines: load → chain → `return await ….save()`. Write `return await` explicitly
19
- in tail position. Side effects belong in `_preUpdate` / `_postCreate`, not inline. Fire-and-forget is
20
- explicitly `void`-ed.
18
+ - Service methods stay a few lines: load → chain → `return await ….save()`. Side effects belong in
19
+ `_preUpdate` / `_postCreate`, not inline. Fire-and-forget is explicitly `void`-ed.
21
20
  - Return `null` / `false` for "not allowed" or "not found" and let the signal decide whether that is an
22
21
  error.
23
22
  - `serve(name, { serverMode: "batch" }, …)` mounts the module, endpoints included, only in a `batch` or `all`
@@ -71,7 +70,7 @@ export class OpenlibraryService extends serve("openlibrary" as const, ({ plug })
71
70
  }
72
71
  }
73
72
 
74
- // lib/_openlibrary/openlibrary.signal.ts — Any answers plain JSON; nullable lets it answer null for "not found"
73
+ // lib/_openlibrary/openlibrary.signal.ts — Any answers plain JSON
75
74
  import { Any } from "akanjs/base";
76
75
  import { endpoint, internal, Public } from "akanjs/signal";
77
76
 
@@ -103,5 +102,8 @@ The page calls it as `await fetch.book(id)` (`fetch` from `@apps/<app>/client`)
103
102
  `common/`, or return a scalar (`akan create-scalar`) for a typed wire shape. A query that answers `null` without
104
103
  `nullable: true` fails the render, naming the endpoint.
105
104
 
106
- Full detail: `get_guideline` with `modelService`. The exact signatures of serve, adapt, endpoint and
107
- serviceDictionary, and every import path, are in the `akanApi-*` references below.
105
+ The adapter turns every failure into `null`, a not-found page. One the page must show as an error throws
106
+ `new Err("<app>.error.<key>")`, `Err` from `"../lib/dict"` and the key in `lib/_<app>/<app>.dictionary.ts`'s
107
+ `.error({})`; `new Error` fails the build (`no-throw-raw-error`).
108
+
109
+ The signatures of serve, adapt, endpoint and serviceDictionary, and every import path: the `akanApi-*` references.
@@ -9,7 +9,11 @@ import {
9
9
  import { computeRouteSeedIndex, type RouteSeedIndex } from "../artifact/routeSeedIndex";
10
10
  import { StoreBootstrap } from "../artifact/storeBootstrap";
11
11
  import type { App } from "../commandDecorators";
12
- import { type RouteRuntimeDictionaryFallback, RouteRuntimeReport } from "../quality/routeRuntimeReport";
12
+ import {
13
+ type RouteRuntimeBuildReport,
14
+ type RouteRuntimeDictionaryFallback,
15
+ RouteRuntimeReport,
16
+ } from "../quality/routeRuntimeReport";
13
17
  import { ModelReference } from "../transforms/modelReference";
14
18
  import { RouteRuntime } from "../transforms/routeRuntime";
15
19
  import type { AskedExports, ClientEntryDiscovery } from "./clientBuildTypes";
@@ -26,6 +30,7 @@ export interface BuildAllRoutesResult {
26
30
  seedIndex: RouteSeedIndex;
27
31
  /** A production build: the dictionary groups each route can show; a route left out loads every group. */
28
32
  dictionaryRoutes?: Map<string, string[]>;
33
+ runtimeReport?: RouteRuntimeBuildReport;
29
34
  }
30
35
 
31
36
  export class AllRoutesBuilder {
@@ -110,7 +115,13 @@ export class AllRoutesBuilder {
110
115
  `[build-all] wrote ${manifestPath} routes=${this.#routeIds.length} entries=${this.#merged.knownEntries.length}`,
111
116
  );
112
117
 
113
- return { manifest, manifestPath, seedIndex, ...(dictionaryRoutes ? { dictionaryRoutes } : {}) };
118
+ return {
119
+ manifest,
120
+ manifestPath,
121
+ seedIndex,
122
+ ...(dictionaryRoutes ? { dictionaryRoutes } : {}),
123
+ ...(delta.runtimeReport ? { runtimeReport: delta.runtimeReport } : {}),
124
+ };
114
125
  }
115
126
 
116
127
  async #readDictionaryRoutes(importsByModule: NonNullable<BuildRouteClientResult["clientGraph"]>) {
@@ -661,13 +661,14 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
661
661
  await load(route);
662
662
  return seenNow();
663
663
  };
664
- return { browser: await bundledText(clientOut), run, load, seenNow };
664
+ const summary = result.runtimeReport ? RouteRuntimeReport.summary(result.runtimeReport) : null;
665
+ return { browser: await bundledText(clientOut), run, load, seenNow, summary };
665
666
  };
666
667
  return { ...fixture, file, buildRoutes };
667
668
  };
668
669
  const timesIn = (text: string, marker: string) => text.split(marker).length - 1;
669
670
  const mixed =
670
- "[client-runtime] 1 route loads per module, 0 keep the whole runtime because per module would not be smaller, 1 keeps it for a reason `akan quality runtime` names";
671
+ "1 route loads per module, 0 keep the whole runtime because per module would not be smaller, 1 keeps it for a reason `akan quality runtime` names";
671
672
 
672
673
  test("a route with an entry keeping the whole runtime and a narrowed entry sharing a file holds each module's descriptors once, and runs them once", async () => {
673
674
  const { file, buildRoutes, warnings, said } = await describedFixture();
@@ -678,12 +679,13 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
678
679
  '"use client";\nimport { shared } from "./Shared";\nexport const Draft = () => [shared, "draft-ui-marker"];\n',
679
680
  );
680
681
 
681
- const { browser, run } = await buildRoutes({
682
+ const { browser, run, summary } = await buildRoutes({
682
683
  "/pick": [file("Pick"), file("Draft")],
683
684
  "/draft": [file("Draft")],
684
685
  });
685
686
 
686
- expect(said).toEqual([mixed]);
687
+ expect(summary).toBe(mixed);
688
+ expect(said).toEqual([]);
687
689
  expect(warnings).toEqual([]);
688
690
  for (const marker of ["draft-descriptor-ref", "tally-descriptor-ref"]) expect(timesIn(browser, marker)).toBe(1);
689
691
  expect(await run("/pick")).toEqual(["piece:draft", "whole:tally"]);
@@ -702,11 +704,12 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
702
704
  '"use client";\nimport { shared } from "./Shared";\nexport const Draft = () => [shared, "draft-ui-marker"];\nexport const ask = () => import("./Later");\n',
703
705
  );
704
706
 
705
- const { browser, load, seenNow } = await buildRoutes({ "/draft": [file("Draft")] });
707
+ const { browser, load, seenNow, summary } = await buildRoutes({ "/draft": [file("Draft")] });
706
708
 
707
- expect(said).toEqual([
708
- "[client-runtime] 1 route loads per module, 0 keep the whole runtime because per module would not be smaller",
709
- ]);
709
+ expect(summary).toBe(
710
+ "1 route loads per module, 0 keep the whole runtime because per module would not be smaller",
711
+ );
712
+ expect(said).toEqual([]);
710
713
  expect(warnings).toEqual([]);
711
714
  for (const marker of ["draft-descriptor-ref", "tally-descriptor-ref"]) expect(timesIn(browser, marker)).toBe(1);
712
715
  const { ask } = (await load("/draft")) as { ask: () => Promise<unknown> };
@@ -726,12 +729,13 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
726
729
  await write(file("Pick"), picking);
727
730
  await write(file("Plain"), '"use client";\nexport const Plain = () => "plain-ui-marker";\n');
728
731
 
729
- const { browser } = await buildRoutes({
732
+ const { browser, summary } = await buildRoutes({
730
733
  "/pick": [file("Pick"), reference],
731
734
  "/plain": [file("Plain"), reference],
732
735
  });
733
736
 
734
- expect(said).toEqual([mixed]);
737
+ expect(summary).toBe(mixed);
738
+ expect(said).toEqual([]);
735
739
  expect(warnings).toEqual([]);
736
740
  expect(browser).toContain("piece:draft.st");
737
741
  expect(timesIn(browser, "draft-descriptor-ref")).toBe(1);
@@ -741,11 +745,12 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
741
745
  const { appDir, file, buildRoutes, warnings, said } = await describedFixture({ whole: 0, draft: 600 });
742
746
  await write(file("Draft"), `"use client";\n${namingDraft}`);
743
747
 
744
- const { browser, run } = await buildRoutes({ "/draft": [file("Draft")] });
748
+ const { browser, run, summary } = await buildRoutes({ "/draft": [file("Draft")] });
745
749
 
746
- expect(said).toEqual([
747
- "[client-runtime] 0 routes load per module, 1 keeps the whole runtime because per module would not be smaller",
748
- ]);
750
+ expect(summary).toBe(
751
+ "0 routes load per module, 1 keeps the whole runtime because per module would not be smaller",
752
+ );
753
+ expect(said).toEqual([]);
749
754
  expect(warnings).toEqual([]);
750
755
  expect(browser).toContain("shared-marker");
751
756
  expect(browser).not.toContain("piece:draft.st");
@@ -767,11 +772,12 @@ export const getSerializedSignalOf = (name: string) => (name === "base" ? {} : {
767
772
  '"use client";\nimport { st } from "@apps/demo/client";\nimport { shared } from "./Shared";\nexport const Board = () => [shared, st.use.tallyCount(), "board-marker"];\n',
768
773
  );
769
774
 
770
- const { browser } = await buildRoutes({ "/draft": [file("Draft")], "/board": [file("Board")] });
775
+ const { browser, summary } = await buildRoutes({ "/draft": [file("Draft")], "/board": [file("Board")] });
771
776
 
772
- expect(said).toEqual([
773
- "[client-runtime] 2 routes load per module, 0 keep the whole runtime because per module would not be smaller",
774
- ]);
777
+ expect(summary).toBe(
778
+ "2 routes load per module, 0 keep the whole runtime because per module would not be smaller",
779
+ );
780
+ expect(said).toEqual([]);
775
781
  expect(warnings).toEqual([]);
776
782
  for (const marker of ["piece:draft.st", "piece:tally.st", "board-marker"]) expect(browser).toContain(marker);
777
783
  expect(browser).not.toContain("store-marker");
@@ -67,6 +67,8 @@ export interface BuildRouteClientResult {
67
67
  externalsByChunkUrl?: Record<string, string[]>;
68
68
  /** The imports of every module the browser loads, or in registry mode of the SSR bundle standing in for it. */
69
69
  clientGraph?: ReadonlyMap<string, readonly ClientModuleImport[]>;
70
+ /** Chunks mode, where the build narrowed any route: what `RouteRuntimeReport.file` now holds. */
71
+ runtimeReport?: RouteRuntimeBuildReport;
70
72
  }
71
73
 
72
74
  interface BootstrapEntries {
@@ -217,6 +219,7 @@ export class RouteClientBuilder {
217
219
  ...(registry ? { registryEntries: [...acceptedEntries].sort() } : {}),
218
220
  ...(browserBundle ? { externalsByChunkUrl: Object.fromEntries(browserBundle.externalsByChunkUrl) } : {}),
219
221
  clientGraph: referenceBundle.graph.importsByModule,
222
+ ...(trusted?.report ? { runtimeReport: trusted.report } : {}),
220
223
  };
221
224
  }
222
225
 
@@ -302,7 +305,6 @@ export class RouteClientBuilder {
302
305
 
303
306
  async #say(report: RouteRuntimeBuildReport) {
304
307
  await RouteRuntimeReport.write(this.#app.cwdPath, report);
305
- this.#app.log(`[client-runtime] ${RouteRuntimeReport.summary(report)}`);
306
308
  for (const route of report.notSmaller) this.#app.verbose(`[client-runtime] not smaller per module: ${route}`);
307
309
  for (const route of report.refused ?? [])
308
310
  this.#app.verbose(`[client-runtime] larger with the whole runtime here: ${route}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.48",
3
+ "version": "3.3.0-rc.49",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -50,7 +50,7 @@
50
50
  "./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
51
51
  },
52
52
  "dependencies": {
53
- "@akanjs/language": "3.3.0-rc.48",
53
+ "@akanjs/language": "3.3.0-rc.49",
54
54
  "@earendil-works/pi-agent-core": "1.5.2",
55
55
  "@earendil-works/pi-ai": "1.5.2",
56
56
  "@earendil-works/pi-codemode": "1.5.2",
@@ -59,7 +59,7 @@
59
59
  "@earendil-works/pi-tui": "1.5.2",
60
60
  "@inquirer/prompts": "^8.7.3",
61
61
  "@tailwindcss/node": "^4.3.3",
62
- "akanjs": "3.3.0-rc.48",
62
+ "akanjs": "3.3.0-rc.49",
63
63
  "chalk": "^6.0.1",
64
64
  "commander": "^15.0.0",
65
65
  "dayjs": "^1.11.23",