@akanjs/devkit 3.3.0-rc.37 → 3.3.0-rc.39

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 (59) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/app/applicationBuildRunner.ts +7 -1
  3. package/app/dictionarySizes.ts +2 -5
  4. package/app/routeFilesReport.test.ts +59 -0
  5. package/app/routeFilesReport.ts +46 -0
  6. package/app/routeJsBudget.ts +18 -4
  7. package/artifact/storeBootstrap.ts +5 -1
  8. package/biome.base.json +1 -3
  9. package/codeAgent/skills/akan-page/SKILL.md +28 -7
  10. package/executors/clientRuntimeKeys.test.ts +72 -1
  11. package/executors/sysExecutor.ts +10 -8
  12. package/frontendBuild/allRoutesBuilder.ts +20 -8
  13. package/frontendBuild/buildRouteClient.test.ts +65 -0
  14. package/frontendBuild/clientBuildTypes.ts +11 -0
  15. package/frontendBuild/clientEntriesBundler.ts +21 -11
  16. package/frontendBuild/clientEntryDiscovery.test.ts +213 -0
  17. package/frontendBuild/clientEntryDiscovery.ts +49 -8
  18. package/frontendBuild/devBarrelImports.test.ts +54 -0
  19. package/frontendBuild/devBarrelImports.ts +1 -0
  20. package/frontendBuild/dictionaryAssetBuilder.test.ts +12 -4
  21. package/frontendBuild/dictionaryAssetBuilder.ts +20 -7
  22. package/frontendBuild/dictionaryConstants.ts +55 -1
  23. package/frontendBuild/dictionaryPacking.test.ts +58 -0
  24. package/frontendBuild/dictionaryPacking.ts +43 -0
  25. package/frontendBuild/dictionaryRoutes.test.ts +65 -0
  26. package/frontendBuild/dictionaryRoutes.ts +3 -1
  27. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  28. package/frontendBuild/precompressArtifacts.ts +18 -11
  29. package/frontendBuild/renderedEntries.ts +144 -0
  30. package/frontendBuild/routeClientBuilder.ts +65 -27
  31. package/frontendBuild/routeHandoffs.test.ts +10 -0
  32. package/frontendBuild/routeHandoffs.ts +3 -1
  33. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  34. package/frontendBuild/routeModulePreloads.ts +20 -11
  35. package/frontendBuild/routeRuntimeCheck.test.ts +23 -0
  36. package/frontendBuild/routeRuntimeCheck.ts +10 -3
  37. package/frontendBuild/routeRuntimePays.test.ts +7 -1
  38. package/lint/biomeBase.test.ts +23 -3
  39. package/package.json +3 -3
  40. package/quality/dictionaryKeys.test.ts +185 -2
  41. package/quality/dictionaryKeys.ts +82 -9
  42. package/quality/objectImportReport.ts +6 -3
  43. package/quality/translatorBindings.ts +187 -0
  44. package/transforms/barrelImportsPlugin.ts +56 -35
  45. package/transforms/exportReach.test.ts +162 -0
  46. package/transforms/exportReach.ts +308 -0
  47. package/transforms/moduleParts.test.ts +225 -0
  48. package/transforms/moduleParts.ts +418 -0
  49. package/transforms/objectMemberImports.test.ts +289 -7
  50. package/transforms/objectMemberImports.ts +92 -58
  51. package/transforms/objectMemberLookup.ts +150 -0
  52. package/transforms/objectModule.test.ts +72 -2
  53. package/transforms/objectModule.ts +31 -7
  54. package/transforms/partImports.test.ts +76 -0
  55. package/transforms/partImports.ts +110 -0
  56. package/transforms/partModules.test.ts +187 -0
  57. package/transforms/partModules.ts +90 -0
  58. package/transforms/partPurity.ts +124 -0
  59. package/workspace/scanInfo.ts +24 -0
package/CHANGELOG.md CHANGED
@@ -407,7 +407,18 @@
407
407
 
408
408
  - a291bbb: The path rules an agent loads with every service, signal, page and `.tsx` file are shorter: the `server`, `style` and `ssr` rules keep only what fails the build or silently changes behaviour and point at the skill that explains the rest (server 7.9 KB to 2.4 KB, style 5.8 KB to 2.5 KB, ssr 3.6 KB to 1.9 KB), and the `akan-page` skill no longer repeats what the `page` rule already says. Nothing was dropped: an endpoint's `errors` option and where an adapter's error keys live are now in the `akan-err` skill, the request-schema check in `transportRule`, and the `cn`, multi-slot and enum-to-class conventions in `cssRule`. `cssRule` and `recipeRule` now say the framework recipe list is in the `style` rule, and the API reference says what `akanjs/dictionary`, `document`, `service`, `store`, `client/native`, `native/desktop` and `test` hold. Run `akan agent install` in a workspace to pick up the new files.
409
409
  - f678e80: The skills no longer repeat the path rule an agent has already loaded for the same files: `akan-query` points at the `module` rule for its musts (500 rows, soft removal, hookless writes, secret projections, cascade direction), `akan-transport` at the `auth` rule for guards and drops what the `server` rule says about body types, the 30-second default deadline and remote errors, `akan-service`, `akan-err` and `akan-mcp` at the `server` rule, and `akan-ui`, `cssRule` and `componentRule` at the `style` rule for class order and the colour vocabulary. The `server` rule drops its in-page agent line, which the `akan-agent` skill already holds and which no service, signal or document file needs. Run `akan agent install` in a workspace to pick up the new files.
410
+ - ce430ed: A coding agent reads less before its first page: the generated AGENTS.md is about 9% smaller, leaving to the path rules what they already say while still naming every check that breaks the build, and it now says that `i18n: { localePrefix: "as-needed" }` in `akan.config.ts` serves URLs without `/<locale>/`. The `akan-page` skill now holds the guard basics, the first-render `searchParams` snapshot and Link prefetch, so `pageRule` keeps only the deeper contract (12 KB to 7 KB), and the `@akanjs/cli` README tells an agent to read the workspace's `AGENTS.md`, rules and skills rather than the package's `guidelines/` folder. Run `akan agent install` in a workspace to pick up the new files.
410
411
  - c44d068: A coding agent reads less to build its first app: the `akanjs` README keeps the path to a first app and links the rest on akanjs.com (17 KB to 7 KB), the `akan-page` and `akan-service` skills ship the API reference one section at a time with every entry named in the skill's index (`Link` now lists the anchor attributes it takes and `Link.Back`, `Link.Close` and `Link.Lang`), the `akan-page` skill holds what a first page looks up while `pageRule` keeps the deeper contract, and each rule is stated once across AGENTS.md, the path rules and the skills. Run `akan agent install` in a workspace to pick up the new files.
412
+ - 56d67dd: A production page loads the exports of a client file it uses, not everything else the file holds.
413
+
414
+ A workspace file with several exports — a `*.Util.tsx`, a `*.Zone.tsx`, a `ui/` or `webkit/` file — was one module to the bundler, so a page rendering `Memo.Util.Remove` also downloaded what `Memo.Util.Edit` imports. `akan build` now hands the browser bundle each such file as one module per export: a top-level declaration that only builds a value (a component, a function, a constant, a class) becomes its own module with the imports it alone reads, and an importer naming `{ Remove }` follows that module only. A `"use client"` file is likewise built as one entry per export, and a route preloads and counts as Route JS the entries of the exports its server files ask for.
415
+
416
+ How a file is written does not change: several exports in one file, imported by name or as `Memo.Util.Remove`. What the file does when it loads — a bare import, a call at the top level, anything that is not a plain declaration — stays together in one module that each of its exports loads first.
417
+
418
+ A file stays one module when it has a top-level `let` or `var`, `export *`, a namespace or a macro import, and so do generated barrels, `lib/__client` pieces, `index.ts` files and `*.constant|dictionary|document|service|signal|store.ts`. A namespace import (`import * as Util`) used as a value still loads every export.
419
+
420
+ On a real workspace's largest app (236 routes, brotli as served) the JS all routes load fell 9.3% in total, the lightest route went from 363.8 to 290.2 KB and the median from 795.3 to 764.7 KB. The build writes more, smaller files: 1,827 client files against 1,141, and 8.8% more bytes on disk. An app with little to take apart grows by a fraction of a KB per route. `akan start` (development) and the server bundle are unchanged. No upgrade step.
421
+
411
422
  - 55d1518: A production build of a workspace with several libs loads its client modules in order, and a page that needs every module weighs what it weighed before.
412
423
 
413
424
  - Each generated piece exports a name, and a module that needs the piece imports that name and hands it to `loadedAfter` from `akanjs/base`. A piece imported only for its effect could end up in a chunk the importer's chunk did not load first; a store or an endpoint was then read before it existed.
@@ -463,6 +474,7 @@
463
474
 
464
475
  **Upgrading.** No step is needed: the three wire fields in `akanjs/common` (`CodeAgentApprovalRequest.remember`, the `approve` command's `remember`, `approval_resolved.remembered`) and `CodeTranscriptPart`'s `remembered` are optional additions.
465
476
 
477
+ - d7e5c18: A built app serves its client files under 1 KB compressed too. `akan build` wrote a `.br` and `.gz` beside a file only from 1 KB up, and a page loads hundreds of smaller ones: re-export stubs, single icons, a model's runtime pieces. Each now gets its compressed copies whenever they come out smaller than the file. A page of the sample apps downloads 6 to 8 KB less JavaScript, and a page of a large app that loads about 500 files, 230 of them under 1 KB, about 44 KB less. The Route JS report and budget count what is served, so their numbers fall by the same amount.
466
478
  - 9c538dc: `akan workflow plan` and `apply` for `create-ui` now write a Zone or a Util, for a database module and for a service module.
467
479
 
468
480
  `--surface zone` and `--surface util` were advertised but apply refused them. They now write `<Model>.Zone.tsx` and `<Model>.Util.tsx` from the module templates. In a service module (`lib/_camera`, named `camera` or `_camera`) they write a small `Main` Zone or `Action` Util; `view`, `unit` and `template` stay refused there, since a service stores no model. `create-ui` also refuses, at plan and at apply, to overwrite a component file that already exists, which `view`, `unit` and `template` used to do silently.
@@ -470,6 +482,9 @@
470
482
  A service module's `<Service>.Zone.tsx` and `<Service>.Util.tsx` now count as client files by role for `akan.ssr.unnecessary-use-client`, as a database module's do, so the new scaffold is not warned about before it reads the store.
471
483
 
472
484
  - 1d8c8c2: An app with `basePaths` keeps every base path's CSS class scan in the candidate cache, so a start or build no longer rescans the sources of all but one of them. An entry is dropped only once its source file is deleted.
485
+ - 2f7c2b4: The build reads three more ways of writing a dictionary key, so a route holding one loads the groups it shows instead of the whole page dictionary. A key held in a `const` that may also be `null`, `undefined` or `false` (`const noteKey = denied ? "weather.locationDenied" : null`) is read as the keys written in it. A key read from a table the file made with `.map()` from another table (`stages.map((stage) => ({ ...stage, label: l(stage.key) }))`, then `l(item.key)`) is read as the keys the first table writes. A key picked from a `static` table of a constant class (`l(cnst.RunnerBot.labelKeyOf[botRole])`) is read as the keys that table writes, when the static has no type annotation and is an `as const` object or array of nothing but written strings; any other static, and a `.map()` callback that returns something the file does not write, keep the route on the whole dictionary as before.
486
+ - 2f7c2b4: A variable or parameter that only shares the translator's name no longer sends a route to the whole page dictionary. `values.map((l) => l.trim())`, `rows.sort((l, r) => l.order - r.order)`, `const l = line.length` and a `for (const l of lines)` loop are read as the plain values they are, so a file holding one keeps its routes on the dictionary groups they show. A name that may be the translator still counts as it: one destructured from an object, imported or not declared in the file, and any parameter or variable that is called, read through `l._`, `l.rich` or `l.trans`, or given another value.
487
+ - c866b21: No route downloads more dictionary than the whole file any more. A route that shows nearly every text could be handed up to four files that together came out larger than the whole dictionary, because several files compress worse than one. Such a route now loads the whole file, and it no longer decides how the other routes' files are cut, so light pages stop paying for it: in a large app with 20 such routes the lightest page's dictionary went from 115 KB back to 96 KB.
473
488
  - 53bf2de: A problem in an env file is reported without the file's text, so a build or lint log holds no secret.
474
489
 
475
490
  - **Type errors.** `akan build`, `akan typecheck` and `akan verify` report a TypeScript error in `env/env.server.*.ts` or `env/env.client.*.ts` by file, line, column and code alone. The source line and TypeScript's message are left out, because either can quote a value.
@@ -478,15 +493,61 @@
478
493
 
479
494
  **Upgrading.** A failed `akan lint` now exits with 3, the code of a failed check, where it exited with 1. A script that tests for a non-zero exit needs no change; one that tests for exactly 1 does. To see what is wrong on a line of an env file, open the file at the position the diagnostic names.
480
495
 
496
+ - fa19707: fix(lint): `noUnnecessaryConditions` is off in the base Biome config
497
+
498
+ Biome 2.5.14 reads `RegExp.prototype.exec` as never returning null, so a workspace got "Unnecessary optional chaining"
499
+ on `/…/.exec(url)?.[1]` and "This condition is always truthy" on `match ? … : …`. The fix it offers, `?.` to `.`,
500
+ throws on every string that does not match, and `akan verify` printed the warning to agents that then tried to fix
501
+ it. A workspace that wants the rule back sets `"noUnnecessaryConditions": "warn"` under `linter.rules.suspicious` in
502
+ its own `biome.json`.
503
+
504
+ - 537d28e: The first `akan sync` of a new checkout writes the client runtime files a second one used to, so the first production build of a clean tree loads its routes per module.
505
+
506
+ - **The files under `lib/__client` are written after every scope's `lib/cnst.ts`.** They were written beside it, and on a tree with no generated files a module whose signal names another lib's constants as `cnst.<lib>.X` got a fetch file that imports the scope's whole constant barrel. A build of that tree measured the per-module runtime as larger and kept the whole client runtime on every route. On a real workspace of nine libs, 21 fetch files were written that way by the first sync and none by the second; the first build of a clean tree said `0 routes load per module, 235 keep the whole runtime`, and now says `235 routes load per module`, as its second build did.
507
+ - **A lib reached only through another lib is a dependency from the first sync.** When an app or lib imports `@libs/b` and `b` imports `@libs/c`, its generated barrels name `c` at once. Before, the first sync left `c` out and a second sync added it, having found the import in the files the first one generated. `akan.app.json` lists such libs too, so their pages and assets are synced the first time.
508
+
509
+ A CI job that builds a clean checkout shipped the larger build. Running `akan sync <app>` before `akan build` was the way around it and is no longer needed.
510
+
511
+ Not changed: the order generated files list an app's libs in still depends on the order their scans finish in, so the first and the second sync of a new tree can list the same libs in a different order.
512
+
481
513
  - 90d740f: `native.ios.hideFormAccessoryBar: true` (or a target's `ios.hideFormAccessoryBar`) leaves out the bar WebKit shows above the keyboard while a page field is focused. The iOS shell already had the switch, but `akan.config.ts` refused the key and the native config never carried it, so every iOS app showed the bar.
482
514
 
483
515
  The key defaults to false, so existing apps are unchanged. The api report lists one new optional `AkanNativeIosConfig` property; no upgrade step is needed.
484
516
 
485
517
  - 4732186: `akan --version` loads no command module, and `akan tunnel`, `akan subspace` and the package commands such as `akan version` no longer load the TypeScript compiler unless a step compiles.
486
518
  - 1879e92: A whole-app lint runs about four times faster: `biome check apps/akan` in this repository went from 8.0 s to 2.0 s (median of five runs each on an Apple M4 Pro, 14 cores), where the same check with no lint plugins takes 0.95 s; `akan lint akan` went from 17.2 s to 5.0 s and `akan lint minimal` from 2.3 s to 1.7 s on the same machine. The ten costliest grit rules shipped in `@akanjs/devkit/lint` (the four colour rules, `no-conditional-st-hook`, `no-web-storage`, `no-web-only-api-outside-webkit`, `no-document-cookie`, `no-oversized-list-limit` and `no-unpublished-form-setter`) now check for a substring every match contains before their regex or code snippet runs, because Biome's GritQL engine pays for a regex or a snippet on every node it tries. Every rule reports the same diagnostics as before, and `biome.base.json` is unchanged, so a workspace picks this up by updating `@akanjs/devkit`.
519
+ - c7c27d9: A page that names a part through a workspace's own wrapper of an object loads that part's file, not everything the wrapper gathers: with a workspace's own `Field` wrapper, `<Field.Text />` no longer brings the wrapper's rich-text editor, map field and upload field onto the page.
520
+
521
+ - An object built over an imported one, `export const Field = Object.assign(Section, AkanField, { Rich, File })`, passes the copied object's parts on by file. `Field.Text` is imported from the file `akanjs/ui`'s `Field` takes `Text` from, and `Field.File` from the file the wrapper imports it from. The copied object may come through a barrel listed in `barrelImports` (`akanjs/ui`, a lib's `ui`), and may itself copy another object in.
522
+ - An object's file may now call React's `memo`, `forwardRef`, `lazy` and `createContext` while it loads (`const Rich = memo(…)`, `React.memo(…)`); any other call still keeps the whole object.
523
+ - What still keeps the whole object: a part declared in the wrapper's own file (`Field.Rich` above), a part the wrapper lists before the object it copies in (`Object.assign(Section, { File }, AkanField)`, where the copied object may replace `File`), a copied object whose own file does not qualify, and a namespace import copied in (`import * as parts`). `akan quality runtime` counts these as before, the first two as `unresolved-member` and a copied object's file by its own reason (`call`, `effect-statement`, …).
524
+ - A member reached from a server file past a `"use client"` wrapper or a `"use client"` copied object is narrowed only when the member's own file is `"use client"`, as with an object imported directly.
525
+
526
+ Measured on a real workspace's largest app (236 routes, JavaScript as served with brotli), whose own `Field` wrapper every route reaches: the lightest route went from 465.8 KB to 363.8 KB, the median of the 126 routes outside its signed-in area from 604.5 KB to 503.7 KB, and all routes together from 174,557 KB to 162,476 KB (−6.9%). The 110 signed-in routes, which use most of the wrapper's parts, moved little: median 894.1 KB to 882.5 KB.
527
+
528
+ No upgrade step.
529
+
487
530
  - 6ea7242: `akan build`, `akan verify` and `akan start` stop with an error naming the import chain when the server pages bundle would import `react-dom/server` as it loads, instead of building a bundle whose RSC worker throws "react-dom/server is not supported in React Server Components" at boot. A module in the page graph that dynamically imports the app's `server.ts` is the usual cause: it brings the whole server, SSR renderer included, into the pages bundle.
488
531
  - 0d5e75e: A stylesheet whose imports use no Tailwind (no `@import "tailwindcss"`, Tailwind at-rule or `theme()` function anywhere in its import graph) is no longer run through the Tailwind compiler: its imports are inlined and it ships without the `/*! tailwindcss … */` banner. A stylesheet that uses Tailwind compiles exactly as before.
489
532
  - 36408f1: The route JS budget report no longer counts, and the route build no longer emits, chunks for `"use client"` files that export only hooks, such as the `akanjs/store` field tools, which no page loads. Reported route sizes drop by about 21 KB brotli on every route of `apps/akan` and `apps/minimal`.
533
+ - 08bcac6: A production build now writes `route-files.json` into the app's `.akan/cache` directory. It lists every client file with its raw and served size, and the files each route loads, so a heavy route can be traced to its files without patching the CLI. The sizes are the ones the route JS budget counts.
534
+ - ed9e787: A route no longer loads a model's client reference because one of the app's stores names that model.
535
+
536
+ `akan build` reads each route's server modules for the models they hand to client components (`fetch.init<Model>`, `view<Model>`, `edit<Model>`, a slice) and preloads those models' reference files on the route. The generated root layout imports every store of the app so the server holds them, which made each store, and every file a store or a signal imports, a server module of every route. A store calling `fetch.view<Model>` in an action, or reading a slice, therefore put that model's reference on every page of the app, and one picking a `fetch` name at run time put every model's there.
537
+
538
+ - The read now follows only what a route's own layouts and page import. The root layout's store imports are left out of it.
539
+ - A `*.store.ts` file reached any other way hands nothing over: its actions run in the browser, where the code calling them already loads the model's store and descriptors.
540
+
541
+ A route still loads the reference of every model its page, layouts and the server components they render hand over. No upgrade step.
542
+
543
+ - fb4f076: A route no longer preloads the client files of exports it does not render.
544
+
545
+ `akan build` lists, per route, the `"use client"` files to preload and to count as Route JS. It walked every import of each server file the route reaches, so a server component file with several exports — a `*.View.tsx`, a `*.Unit.tsx`, a `ui/` file — put the client files of all its exports on every route rendering one of them, and a framework file such as `akanjs/ui`'s `Model` put every wrapper it can load on each route using one.
546
+
547
+ The list now starts at the route's page and layouts and follows, for each export asked of a server file, only the imports that export's declaration reads, through the file's other declarations. A file's bare imports and top-level statements still count for every route reaching the file, a namespace handed on as a value (`components={Model}`) and `export *` count whole, and a CommonJS file is read as before.
548
+
549
+ Only the preload and Route JS list narrows. Every client file is still built and in the manifest, so one this read misses loads when the page asks for it; the route runtime plan and the dictionary per route keep the wider list. `akan start` (development) is unchanged. No upgrade step.
550
+
490
551
  - eb1262f: Two readings that kept a whole app's routes on every model's runtime are gone, so those routes load per module again.
491
552
 
492
553
  - A server file that takes `fetch` from the server barrel (`../useServer`, `@apps/<app>/server`) and only calls endpoints no longer counts every model on every route because some other line says `slice`, such as `ips.slice(0, 1)` on an array. The build now reads what the file does with `fetch` itself: `fetch.init<Model>`, `view<Model>`, `edit<Model>`, their `get` forms and `fetch.slice` still count every model, and so does a `fetch` that is indexed, passed on or taken apart. In a real workspace one such service held all 38 routes of an app.
@@ -508,6 +569,7 @@
508
569
 
509
570
  `akan workflow plan create-scalar --app shop --module address` used to answer `requires input "scalar"` and drop `--module` without a word. It now answers `Workflow create-scalar requires input "scalar" (--scalar on the command line). It does not take "module", which was passed.` The `plan_workflow` tool of `akan mcp` returns the same message.
510
571
 
572
+ - Updated dependencies [800f3ef]
511
573
  - Updated dependencies [4a568b2]
512
574
  - Updated dependencies [e5d3cac]
513
575
  - Updated dependencies [c44d068]
@@ -515,6 +577,7 @@
515
577
  - Updated dependencies [6443972]
516
578
  - Updated dependencies [af57986]
517
579
  - Updated dependencies [f678e80]
580
+ - Updated dependencies [cda53a8]
518
581
  - Updated dependencies [af09c4f]
519
582
  - Updated dependencies [24315d1]
520
583
  - Updated dependencies [7c4143e]
@@ -562,6 +625,7 @@
562
625
  - Updated dependencies [aead1aa]
563
626
  - Updated dependencies [4225827]
564
627
  - Updated dependencies [4225827]
628
+ - Updated dependencies [040c561]
565
629
  - Updated dependencies [fb5e77e]
566
630
  - Updated dependencies [bfa67d8]
567
631
  - Updated dependencies [6f8f6aa]
@@ -580,6 +644,7 @@
580
644
  - Updated dependencies [f4b5aa6]
581
645
  - Updated dependencies [4225827]
582
646
  - Updated dependencies [8f9d432]
647
+ - Updated dependencies [fb46b5d]
583
648
  - akanjs@3.3.0
584
649
  - @akanjs/language@3.3.0
585
650
 
@@ -33,6 +33,7 @@ import type {
33
33
  ApplicationBuildProgressReporter,
34
34
  ApplicationBuildResult,
35
35
  } from "./applicationBuildReporter";
36
+ import { RouteFilesReport } from "./routeFilesReport";
36
37
  import { RouteJsBudget, type RouteJsBudgetMode, type RouteJsBudgetStatus, type RouteJsSize } from "./routeJsBudget";
37
38
 
38
39
  export interface TypecheckOptions {
@@ -614,11 +615,16 @@ void run().catch((error) => {
614
615
  //? verify build skips writing and measures in memory instead.
615
616
  async #measureRouteJs(environment: string): Promise<RouteJsMeasure | null> {
616
617
  if (this.#budget === "off" || !this.#modulesByRoute) return null;
617
- const sizes = await RouteJsBudget.measure(
618
+ const sizeByUrl = await RouteJsBudget.fileSizes(
618
619
  path.join(this.#app.dist.cwdPath, ".akan/artifact"),
619
620
  this.#modulesByRoute,
620
621
  { precompressed: !this.#verify },
621
622
  );
623
+ const sizes = RouteJsBudget.sizesOf(this.#modulesByRoute, sizeByUrl);
624
+ await RouteFilesReport.write(
625
+ this.#app.cwdPath,
626
+ RouteFilesReport.build(this.#app.name, this.#modulesByRoute, sizeByUrl),
627
+ );
622
628
  const budgetPath = path.join(this.#app.cwdPath, RouteJsBudget.fileName);
623
629
  const { summary: status, warnings } = await RouteJsBudget.check(sizes, {
624
630
  mode: this.#budget,
@@ -18,9 +18,6 @@ export interface DictionarySize {
18
18
  routeBrotliBytes?: DictionaryRouteBytes;
19
19
  }
20
20
 
21
- //? precompressArtifacts writes no `.br` for a smaller file, so it is served, and counted, raw.
22
- const minCompressedBytes = 1024;
23
-
24
21
  export class DictionarySizes {
25
22
  static of(artifactDir: string): DictionarySize[] {
26
23
  const artifactPath = path.join(artifactDir, "base-artifact.json");
@@ -87,8 +84,8 @@ export class DictionarySizes {
87
84
  const sidecar = `${file}.br`;
88
85
  if (fs.existsSync(sidecar)) return fs.statSync(sidecar).size;
89
86
  const raw = fs.readFileSync(file);
90
- if (raw.byteLength < minCompressedBytes) return raw.byteLength;
91
87
  const params = { [zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY };
92
- return zlib.brotliCompressSync(raw, { params }).byteLength;
88
+ //? precompressArtifacts writes no `.br` that would be larger than its file, so that file is served, and counted, raw.
89
+ return Math.min(raw.byteLength, zlib.brotliCompressSync(raw, { params }).byteLength);
93
90
  }
94
91
  }
@@ -0,0 +1,59 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { mkdir, mkdtemp } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import path from "node:path";
5
+ import { RouteFilesReport } from "./routeFilesReport";
6
+ import { RouteJsBudget } from "./routeJsBudget";
7
+
8
+ const write = async (file: string, text: string) => {
9
+ await mkdir(path.dirname(file), { recursive: true });
10
+ await Bun.write(file, text);
11
+ };
12
+
13
+ describe("RouteFilesReport", () => {
14
+ test("lists each file once, sorted, with routes as ascending indexes whose served bytes sum to the budget's", async () => {
15
+ const artifactDir = await mkdtemp(path.join(tmpdir(), "route-files-"));
16
+ await write(path.join(artifactDir, "client/rsc.js"), "r".repeat(3000));
17
+ await write(path.join(artifactDir, "client/rsc.js.br"), "b".repeat(900));
18
+ await write(path.join(artifactDir, "client/chunks/tiny.js"), "t".repeat(200));
19
+ await write(path.join(artifactDir, "client/memo.js"), "m".repeat(5000));
20
+ await write(path.join(artifactDir, "client/memo.js.br"), "b".repeat(1200));
21
+ const modulesByRoute = {
22
+ "/:lang/memo": ["/_akan/client/memo.js", "/_akan/client/rsc.js", "/_akan/client/chunks/tiny.js"],
23
+ "/:lang": ["/_akan/client/rsc.js", "/_akan/client/chunks/tiny.js"],
24
+ };
25
+
26
+ const sizeByUrl = await RouteJsBudget.fileSizes(artifactDir, modulesByRoute);
27
+ const report = RouteFilesReport.build("demo", modulesByRoute, sizeByUrl);
28
+
29
+ expect(report.files).toEqual([
30
+ { file: "/_akan/client/chunks/tiny.js", rawBytes: 200, servedBytes: 200 },
31
+ { file: "/_akan/client/memo.js", rawBytes: 5000, servedBytes: 1200 },
32
+ { file: "/_akan/client/rsc.js", rawBytes: 3000, servedBytes: 900 },
33
+ ]);
34
+ expect(Object.keys(report.routes)).toEqual(["/:lang", "/:lang/memo"]);
35
+ expect(report.routes).toEqual({ "/:lang": [0, 2], "/:lang/memo": [0, 1, 2] });
36
+ for (const { routeId, brotliBytes, rawBytes } of RouteJsBudget.sizesOf(modulesByRoute, sizeByUrl)) {
37
+ const indexes = report.routes[routeId] ?? [];
38
+ expect(indexes.reduce((sum, index) => sum + (report.files[index]?.servedBytes ?? 0), 0)).toBe(brotliBytes);
39
+ expect(indexes.reduce((sum, index) => sum + (report.files[index]?.rawBytes ?? 0), 0)).toBe(rawBytes);
40
+ }
41
+ });
42
+
43
+ test("writes the same bytes for the same input and does not throw when the directory cannot be written", async () => {
44
+ const appDir = await mkdtemp(path.join(tmpdir(), "route-files-app-"));
45
+ const report = RouteFilesReport.build(
46
+ "demo",
47
+ { "/a": ["/_akan/x.js"] },
48
+ new Map([["/_akan/x.js", { raw: 5, brotli: 4 }]]),
49
+ );
50
+ await RouteFilesReport.write(appDir, report);
51
+ const first = await Bun.file(path.join(appDir, RouteFilesReport.file)).text();
52
+ await RouteFilesReport.write(appDir, report);
53
+ expect(await Bun.file(path.join(appDir, RouteFilesReport.file)).text()).toBe(first);
54
+ expect(JSON.parse(first)).toEqual(report);
55
+
56
+ await write(path.join(appDir, "blocked"), "");
57
+ await RouteFilesReport.write(path.join(appDir, "blocked"), report);
58
+ });
59
+ });
@@ -0,0 +1,46 @@
1
+ import path from "node:path";
2
+ import type { RouteJsFileSizes } from "./routeJsBudget";
3
+
4
+ export interface RouteFilesReportData {
5
+ app: string;
6
+ files: { file: string; rawBytes: number; servedBytes: number }[];
7
+ routes: Record<string, number[]>;
8
+ }
9
+
10
+ const byCodeUnit = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);
11
+
12
+ export class RouteFilesReport {
13
+ //? Under `.akan/cache`: the development server clears the rest of `.akan` when it starts.
14
+ static readonly file = ".akan/cache/route-files.json";
15
+
16
+ static build(
17
+ app: string,
18
+ modulesByRoute: Record<string, string[]>,
19
+ sizeByUrl: RouteJsFileSizes,
20
+ ): RouteFilesReportData {
21
+ const urls = [...sizeByUrl.keys()].sort(byCodeUnit);
22
+ const indexOf = new Map(urls.map((url, index) => [url, index]));
23
+ const routes = Object.fromEntries(
24
+ Object.entries(modulesByRoute)
25
+ .sort(([a], [b]) => byCodeUnit(a, b))
26
+ .map(([routeId, routeUrls]) => [
27
+ routeId,
28
+ routeUrls.flatMap((url) => indexOf.get(url) ?? []).sort((a, b) => a - b),
29
+ ]),
30
+ );
31
+ return {
32
+ app,
33
+ files: urls.map((url) => ({
34
+ file: url,
35
+ rawBytes: sizeByUrl.get(url)?.raw ?? 0,
36
+ servedBytes: sizeByUrl.get(url)?.brotli ?? 0,
37
+ })),
38
+ routes,
39
+ };
40
+ }
41
+
42
+ static async write(appDir: string, report: RouteFilesReportData) {
43
+ const text = `${JSON.stringify({ app: report.app, files: report.files, routes: report.routes })}\n`;
44
+ await Bun.write(path.join(appDir, RouteFilesReport.file), text).catch(() => 0);
45
+ }
46
+ }
@@ -11,6 +11,8 @@ export interface RouteJsSize {
11
11
  brotliBytes: number;
12
12
  }
13
13
 
14
+ export type RouteJsFileSizes = Map<string, { raw: number; brotli: number }>;
15
+
14
16
  export interface RouteJsOverage {
15
17
  routeId: string;
16
18
  brotliBytes: number;
@@ -58,13 +60,13 @@ export class RouteJsBudget {
58
60
  static readonly #relativeSlack = 0.01;
59
61
  static readonly #absoluteSlack = 4096;
60
62
 
61
- //? A file under 1 KB has no `.br` sidecar (precompressArtifacts skips it), so it is served, and counted, raw.
62
- static async measure(
63
+ //? A file brotli does not shrink has no `.br` sidecar (precompressArtifacts writes none), so it is served, and counted, raw.
64
+ static async fileSizes(
63
65
  artifactDir: string,
64
66
  modulesByRoute: Record<string, string[]>,
65
67
  { precompressed = true }: { precompressed?: boolean } = {},
66
- ): Promise<RouteJsSize[]> {
67
- const sizeByUrl = new Map<string, { raw: number; brotli: number }>();
68
+ ): Promise<RouteJsFileSizes> {
69
+ const sizeByUrl: RouteJsFileSizes = new Map();
68
70
  const sizeOf = async (url: string) => {
69
71
  const file = path.join(artifactDir, url.replace(/^\/_akan\//, ""));
70
72
  const raw = Bun.file(file).size;
@@ -73,6 +75,10 @@ export class RouteJsBudget {
73
75
  return { raw, brotli: (await sidecar.exists()) ? sidecar.size : raw };
74
76
  };
75
77
  for (const url of new Set(Object.values(modulesByRoute).flat())) sizeByUrl.set(url, await sizeOf(url));
78
+ return sizeByUrl;
79
+ }
80
+
81
+ static sizesOf(modulesByRoute: Record<string, string[]>, sizeByUrl: RouteJsFileSizes): RouteJsSize[] {
76
82
  return Object.entries(modulesByRoute)
77
83
  .map(([routeId, urls]) => ({
78
84
  routeId,
@@ -83,6 +89,14 @@ export class RouteJsBudget {
83
89
  .sort((a, b) => b.brotliBytes - a.brotliBytes || RouteJsBudget.#byCodeUnit(a.routeId, b.routeId));
84
90
  }
85
91
 
92
+ static async measure(
93
+ artifactDir: string,
94
+ modulesByRoute: Record<string, string[]>,
95
+ options: { precompressed?: boolean } = {},
96
+ ): Promise<RouteJsSize[]> {
97
+ return RouteJsBudget.sizesOf(modulesByRoute, await RouteJsBudget.fileSizes(artifactDir, modulesByRoute, options));
98
+ }
99
+
86
100
  static modeOf({ checkBudget = false, updateBudget = false, raiseBudget = false }: RouteJsBudgetFlags) {
87
101
  if ([checkBudget, updateBudget, raiseBudget].filter(Boolean).length > 1)
88
102
  throw new Error("Pass at most one of --check-budget, --update-budget and --raise-budget.");
@@ -34,11 +34,15 @@ export class StoreBootstrap {
34
34
  return found.every(Boolean) ? "page" : "whole";
35
35
  }
36
36
 
37
+ static serverSpecifiers(appName: string): string[] {
38
+ return [`@apps/${appName}/lib/useClient`, `@apps/${appName}/lib/st`];
39
+ }
40
+
37
41
  static importLines(appName: string, scope: ClientRuntimeScope = "whole"): string[] {
38
42
  return StoreBootstrap.#lines(
39
43
  scope === "page"
40
44
  ? [StoreBootstrap.pageRuntime, StoreBootstrap.baseDescriptors].map((file) => `@apps/${appName}/lib/${file}`)
41
- : [`@apps/${appName}/lib/useClient`, `@apps/${appName}/lib/st`],
45
+ : StoreBootstrap.serverSpecifiers(appName),
42
46
  );
43
47
  }
44
48
 
package/biome.base.json CHANGED
@@ -24,9 +24,7 @@
24
24
  },
25
25
  "noArrayIndexKey": "off",
26
26
  "noShadowRestrictedNames": "off",
27
- "noUnnecessaryConditions": {
28
- "level": "warn"
29
- }
27
+ "noUnnecessaryConditions": "off"
30
28
  },
31
29
  "correctness": {
32
30
  "noUnusedFunctionParameters": "off",
@@ -31,13 +31,29 @@ export default page()
31
31
  arrive typed: `ID` / `String` → string, `Int` / `Float` → number, `Boolean`, `Date` → Dayjs, an `enumOf` class →
32
32
  its union, `[T]` → array. A path value the type refuses answers not-found, and a search value that fails is
33
33
  dropped. `lang` reaches every stage and is never declared.
34
- 3. Gate with `.guard(() => signedIn())` on the `_layout.tsx`, and repeat a stricter guard on a page that needs more.
35
- `.guard((_, { path }) => signedIn({ path }))` sends a refused visitor to `/signin?redirect=<path>`.
34
+ 3. Gate in the `_layout.tsx`'s `.guard()` (below).
36
35
  4. In `.render()`: `usePage()`, then fetch, then return.
37
36
  5. Re-skin an `akanjs/ui` component for a subtree with `_overrides.tsx`:
38
37
  `export default override({ Slot: AppComponent })`, no logic. Nested ones merge slot by slot, the closest winning;
39
38
  `componentRule` lists the slots.
40
39
 
40
+ ## Guards
41
+
42
+ - `.guard(fn)` runs before any of the route renders, once per chain (a second throws when the module loads). `fn`
43
+ may be `async` and gets the typed arguments and `lang` (a layout's without `children`), then `{ path }`. It refuses
44
+ with `router.redirect(href)`, `router.notFound()` or `getSelf({ unauthorize })`. Call `signedIn()` inside an arrow:
45
+ `.guard(signedIn)` would take the route's arguments as its option.
46
+ - `path` is where the visitor was going, in-app with its search (`undefined` while MCP lists the screen):
47
+ `.guard((_, { path }) => signedIn({ path }))` sends a refused visitor to `/signin?redirect=<path>`. It is a
48
+ redirect target, never an admission rule (CSR asks a guard again only when the route or an argument it declared
49
+ moves), handed only to `router.push` / `router.redirect`: a raw `//host` in it would take `window.location` off
50
+ the site.
51
+ - On the server every guard of the chain runs, root layout first, before any layout body and before the arguments
52
+ are checked, so a not-found is a 404 even after an awaited query. A guard's query the server refuses with 403 or
53
+ 404 (an owner check) answers not-found, so the page never confirms the record exists.
54
+ - Keeping a person on a page (an unsaved form) is `useNavigationGuard(() => !isDirty)` from `akanjs/webkit`, not
55
+ `.guard()`.
56
+
41
57
  ## API at a glance
42
58
 
43
59
  - Data-driven title: `.head(async ({ id }) => <title>{((await fetch.book(id)) as Book | null)?.title}</title>)`,
@@ -58,10 +74,15 @@ export default page()
58
74
  - A client filter kept in the URL without reloading the page: ``router.replace(`/books?q=${q}`, { shallow: true,
59
75
  scrollToTop: false })`` in a `"use client"` component, read back with `usePageLocation().searchParams`. Shallow
60
76
  holds only while the path stays the same; a server `.search()` sees the value at the next full navigation.
77
+ - On a web page's first render `st.use.searchParams()` is still the server's empty snapshot, synced right after
78
+ hydration, so an effect that needs the query on its first run takes the page's `.search()` value as a prop.
79
+ - A `Link` renders its page ahead of the click, guards included: on hover, on keyboard focus, or as it shows with
80
+ `prefetch="viewport"` (production only). A page whose render should happen once per visit (a view counted through
81
+ `duringRender`, an expensive report) sets `.config({ prefetch: false })`; on a `_layout.tsx` it covers every page
82
+ below, and a page there opts back in with `prefetch: true`.
61
83
 
62
84
  What a route file must never do — write while rendering, hooks, a second export — is the `page` rule, loaded with
63
- any `page/` file.
64
-
65
- Full detail: `get_guideline` with `pageRule` (guards in depth, heads, MCP apps, CSR root layouts, lib pages), or
66
- `ssrRule` for what may render on the server. Every stage's signature, the router's methods, Link's props and every
67
- import path are in the `akanApi-*` references below.
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.
@@ -316,6 +316,7 @@ const writeWorkspace = async ({
316
316
  appFiles = demoFiles,
317
317
  kept = false,
318
318
  moreLibs = {} as Record<string, Record<string, string>>,
319
+ scanned = true,
319
320
  } = {}) => {
320
321
  const created = await createTempApp(app, await realpath(os.tmpdir()));
321
322
  const temp = kept ? created : trackRoot(created);
@@ -336,7 +337,7 @@ const writeWorkspace = async ({
336
337
  for (const [file, content] of Object.entries(files)) await writeText(path.join(dir, file), content);
337
338
  }
338
339
  for (const [file, content] of Object.entries(appFiles)) await writeText(path.join(root, "apps", app, file), content);
339
- await temp.app.scan();
340
+ if (scanned) await temp.app.scan();
340
341
  return temp;
341
342
  };
342
343
 
@@ -1589,3 +1590,73 @@ describe("a build of a three-scope workspace", () => {
1589
1590
  });
1590
1591
  }, 240_000);
1591
1592
  });
1593
+
1594
+ const syncScript = (root: string, appName: string) => `
1595
+ const { AppExecutor } = await import(${devkitFile("executors/appExecutor.ts")});
1596
+ const { WorkspaceExecutor } = await import(${devkitFile("executors/workspaceExecutor.ts")});
1597
+ const [root, appName] = ${JSON.stringify([root, appName])};
1598
+ await AppExecutor.from(new WorkspaceExecutor({ workspaceRoot: root, repoName: "repo" }), appName).scan();
1599
+ console.log("{}");
1600
+ `;
1601
+ const scopeFilesOf = async (root: string) => {
1602
+ const files = [...new Bun.Glob("{apps,libs}/**/*").scanSync({ cwd: root, dot: true })].filter(
1603
+ (file) => !file.split("/").some((part) => part === "node_modules" || part === ".akan"),
1604
+ );
1605
+ return Object.fromEntries(
1606
+ await Promise.all(files.map(async (file) => [file, await Bun.file(path.join(root, file)).text()] as const)),
1607
+ );
1608
+ };
1609
+
1610
+ describe("the first sync of a new checkout", () => {
1611
+ test("writes what a second sync writes where a scope reaches a lib only through another lib, and gives each fetch piece its module's own constants", async () => {
1612
+ const [app, base, upper, top] = ["quay", "hull", "mast", "sail"];
1613
+ const orgFiles = kitModuleNamed("org", "Org");
1614
+ const temp = await writeWorkspace({
1615
+ app,
1616
+ lib: base,
1617
+ libFiles: stockFiles,
1618
+ moreLibs: {
1619
+ [upper]: {
1620
+ "lib/option.ts": option,
1621
+ ...orgFiles,
1622
+ "lib/org/org.constant.ts": `import { cnst as ${base} } from "@libs/${base}";\n${orgFiles["lib/org/org.constant.ts"] ?? ""}\nexport const orgKinds = [${base}.Item.name];\n`,
1623
+ "lib/org/org.signal.ts": (orgFiles["lib/org/org.signal.ts"] ?? "")
1624
+ .replace(
1625
+ 'import * as srv from "../srv";',
1626
+ 'import * as cnst from "../cnst";\nimport * as srv from "../srv";',
1627
+ )
1628
+ .replace(
1629
+ "orgCount: query(",
1630
+ `orgItem: query(cnst.${base}.LightItem, { guards: [Public], mcp: false }).exec(() => null),\n orgCount: query(`,
1631
+ ),
1632
+ },
1633
+ [top]: {
1634
+ "lib/option.ts": option,
1635
+ ...kitModuleNamed("crate", "Crate"),
1636
+ "ui/Orgs.tsx": `import { st } from "@libs/${upper}/client";\nexport const Orgs = () => st.use.orgCount();\n`,
1637
+ },
1638
+ },
1639
+ appFiles: {
1640
+ ...shopFilesOf(base),
1641
+ "ui/Crates.tsx": `import { st } from "@libs/${top}/client";\nexport const Crates = () => st.use.crateCount();\n`,
1642
+ },
1643
+ scanned: false,
1644
+ });
1645
+ //? The scan result lists an app's libs in the order the file system hands their importers.
1646
+ const manifest = `apps/${app}/akan.app.json`;
1647
+ const libDepsOf = (files: Record<string, string>) =>
1648
+ (JSON.parse(files[manifest] ?? "{}") as { libDeps: string[] }).libDeps.toSorted((a, b) => a.localeCompare(b));
1649
+ //? Each in a process of its own: the scan orders libs among every lib the process has scanned, other tests' too.
1650
+ await evaluate(temp.root, syncScript(temp.root, app), app);
1651
+ const first = await scopeFilesOf(temp.root);
1652
+ await evaluate(temp.root, syncScript(temp.root, app), app);
1653
+ const second = await scopeFilesOf(temp.root);
1654
+ expect(libDepsOf(first)).toEqual([base, upper, top]);
1655
+ expect({ ...first, [manifest]: libDepsOf(first) }).toEqual({ ...second, [manifest]: libDepsOf(second) });
1656
+ expect(first[`libs/${top}/lib/cnst.ts`]).toContain(`"@libs/${base}"`);
1657
+ const wholeConstants = Object.keys(first).filter(
1658
+ (file) => file.endsWith(".fetch.ts") && first[file]?.includes('from "../cnst"'),
1659
+ );
1660
+ expect(wholeConstants).toEqual([]);
1661
+ }, 240_000);
1662
+ });
@@ -90,6 +90,7 @@ export class SysExecutor extends Executor {
90
90
  );
91
91
  return written;
92
92
  }
93
+ //? `synced` is the app or lib whose sync this is: a lib's files are written by the sync of each app mounting it.
93
94
  async #syncClientPieces(scanInfo: AppInfo | LibInfo, synced: SysExecutor): Promise<FileContent[]> {
94
95
  const pieceDir = "lib/__client";
95
96
  const modulesOf = (info: AppInfo | LibInfo): string[] => [
@@ -151,13 +152,11 @@ export class SysExecutor extends Executor {
151
152
  await Promise.all(stale.map((file) => this.remove(`${pieceDir}/${file}`)));
152
153
  return written;
153
154
  }
154
- //? `synced` is the app or lib whose sync this is: a lib's files are written by the sync of each app mounting it.
155
- #getScanTemplateTasks(scanInfo: AppInfo | LibInfo, synced: SysExecutor): (Promise<FileContent[]> | null)[] {
155
+ #getScanTemplateTasks(scanInfo: AppInfo | LibInfo): (Promise<FileContent[]> | null)[] {
156
156
  return [
157
157
  this.#seedEnvFiles(),
158
158
  this._applyTemplate({ basePath: "env", template: "env", scanInfo }),
159
159
  this._applyTemplate({ basePath: "lib", template: "lib", scanInfo }),
160
- this.#syncClientPieces(scanInfo, synced),
161
160
  this._applyTemplate({ basePath: ".", template: "server.ts", scanInfo }),
162
161
  this._applyTemplate({ basePath: ".", template: "client.ts", scanInfo }),
163
162
  this.type === "lib" ? this._applyTemplate({ basePath: ".", template: "index.ts", scanInfo }) : null,
@@ -199,13 +198,16 @@ export class SysExecutor extends Executor {
199
198
  //* Locked: `writeLib` rewrites dependency-lib barrels that other dev servers regenerate and watch too.
200
199
  if (write)
201
200
  await CodegenLock.run(this.workspace.workspaceRoot, `scan:${this.name}`, async () => {
202
- await Promise.all(this.#getScanTemplateTasks(scanInfo, this));
201
+ await Promise.all(this.#getScanTemplateTasks(scanInfo));
203
202
  await this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
204
203
  await this.#updateDependencies(scanInfo);
205
- if (writeLib) {
206
- const libInfos = [...scanInfo.getLibInfos().values()];
207
- await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo, this)));
208
- }
204
+ const libInfos = writeLib ? [...scanInfo.getLibInfos().values()] : [];
205
+ await Promise.all(libInfos.flatMap((libInfo) => libInfo.exec.#getScanTemplateTasks(libInfo)));
206
+ //? A piece is shaped by each scope's generated `lib/cnst.ts`, which a new checkout has only once the above ran.
207
+ await Promise.all([
208
+ this.#syncClientPieces(scanInfo, this),
209
+ ...libInfos.map((libInfo) => libInfo.exec.#syncClientPieces(libInfo, this)),
210
+ ]);
209
211
  await this.syncAgentsIndex(scanInfo);
210
212
  });
211
213
  this.#scanInfo = scanInfo;