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

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`.
@@ -478,6 +480,7 @@
478
480
  - 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
481
  - Updated dependencies [bd198af]
480
482
  - Updated dependencies [bc792ab]
483
+ - Updated dependencies [e9a2c7f]
481
484
  - Updated dependencies [eb88032]
482
485
  - Updated dependencies [31f7039]
483
486
  - Updated dependencies [61fbd7d]
@@ -505,8 +508,11 @@
505
508
  - Updated dependencies [dcb7e61]
506
509
  - Updated dependencies [6d5b544]
507
510
  - Updated dependencies [73f8830]
511
+ - Updated dependencies [5691327]
508
512
  - Updated dependencies [958f175]
509
513
  - Updated dependencies [9f30e93]
514
+ - Updated dependencies [ad09fac]
515
+ - Updated dependencies [ae045d8]
510
516
  - Updated dependencies [d9eaacc]
511
517
  - Updated dependencies [d9eaacc]
512
518
  - Updated dependencies [c334caf]
@@ -521,6 +527,8 @@
521
527
  - Updated dependencies [f3def22]
522
528
  - Updated dependencies [8424863]
523
529
  - Updated dependencies [bf28968]
530
+ - Updated dependencies [dfc3564]
531
+ - Updated dependencies [d12f556]
524
532
  - Updated dependencies [9b5bcee]
525
533
  - Updated dependencies [4561152]
526
534
  - Updated dependencies [73e833b]
@@ -537,6 +545,7 @@
537
545
  - Updated dependencies [9a9e1fa]
538
546
  - Updated dependencies [af133d7]
539
547
  - Updated dependencies [463fd1e]
548
+ - Updated dependencies [b0ccf6f]
540
549
  - Updated dependencies [9055634]
541
550
  - Updated dependencies [3537448]
542
551
  - Updated dependencies [a373d51]
@@ -36,6 +36,9 @@ an endpoint with a real guard is published, one with none is refused, and so is
36
36
 
37
37
  - `plug(AgentToolsRole)` gives a service `listAs(account, { allow })` / `callAs(account, call)`: the same catalogue
38
38
  and refusals in-process, batch servers included. Pass only an account the server resolved, never client input.
39
+ - `this.agentService.loop({ account | principal, allow, messages, approve, untrusted, onMessage, meta, budget })`
40
+ runs a model over those tools until it answers; `option.setAgentAccountResolver` resolves a stored `principal`
41
+ before every round. Each round is metered as its own turn with `turn.loop` and `turn.meta`.
39
42
 
40
43
  ## Verify
41
44
 
@@ -123,7 +123,7 @@ describe("PagesBundleBuilder", () => {
123
123
  "",
124
124
  "const dictionary = {};",
125
125
  "const pageProto = makePageProto<typeof dict>(dictionary);",
126
- "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });",
126
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal());",
127
127
  'export const runtime = registerClientRuntime({ ...pageProto, ...fetchProto }, { scope: "app" });',
128
128
  "",
129
129
  ].join("\n");
@@ -132,7 +132,7 @@ describe("PagesBundleBuilder", () => {
132
132
 
133
133
  expect(transformed).toContain('import { fetch as serverFetch } from "./sig";');
134
134
  expect(transformed).toContain(
135
- "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });",
135
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });",
136
136
  );
137
137
  expect(transformed).not.toContain("getSerializedSignal");
138
138
  expect(transformed).not.toContain('with { type: "macro" }');
@@ -2,11 +2,10 @@ import { describe, expect, test } from "bun:test";
2
2
  import { PagesBundleBuilder } from "./pagesBundleBuilder";
3
3
 
4
4
  const macroImport = `import { getSerializedSignal } from "./sig" with { type: "macro" };`;
5
- const macroFetchProto =
6
- "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal(), { Err: pageProto.Err });";
5
+ const macroFetchProto = "const fetchProto = FetchClient.build<typeof signal>(cnst, getSerializedSignal());";
7
6
  const serverImport = `import { fetch as serverFetch } from "./sig";`;
8
7
  const serverFetchProto =
9
- "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });";
8
+ "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });";
10
9
 
11
10
  const generatedUseClient = (lines: { importLine?: string; fetchProtoLine?: string } = {}) =>
12
11
  [
@@ -196,7 +196,7 @@ export class PagesBundleBuilder {
196
196
  edits.push({
197
197
  start: tokens[fetchProtoAt].start,
198
198
  end: fetchProtoEnd.end,
199
- text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { Err: pageProto.Err, base: serverFetch });",
199
+ text: "const fetchProto = FetchClient.build<typeof signal>(cnst, serverFetch.serializedSignal, { base: serverFetch });",
200
200
  });
201
201
  let transformed = source;
202
202
  for (const { start, end, text } of edits.sort((a, b) => b.start - a.start))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.2.0-rc.10",
3
+ "version": "3.2.0-rc.12",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -41,7 +41,7 @@
41
41
  "./*": "./*.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@akanjs/language": "3.2.0-rc.10",
44
+ "@akanjs/language": "3.2.0-rc.12",
45
45
  "@earendil-works/pi-agent-core": "1.3.0",
46
46
  "@earendil-works/pi-ai": "1.3.0",
47
47
  "@earendil-works/pi-codemode": "1.3.0",
@@ -50,7 +50,7 @@
50
50
  "@earendil-works/pi-tui": "1.3.0",
51
51
  "@inquirer/prompts": "^8.7.3",
52
52
  "@tailwindcss/node": "^4.3.3",
53
- "akanjs": "3.2.0-rc.10",
53
+ "akanjs": "3.2.0-rc.12",
54
54
  "chalk": "^6.0.1",
55
55
  "commander": "^15.0.0",
56
56
  "dayjs": "^1.11.23",
@@ -38,6 +38,12 @@ const LOCAL_NAMED_RE = /(?:^|\n)\s*export\s+\{\s*([^}]*?)\s*\}(?!\s*from)/g;
38
38
 
39
39
  const CANDIDATE_EXTS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
40
40
 
41
+ interface BarrelWalk {
42
+ visited: Set<string>;
43
+ read: Set<string>;
44
+ following: Set<string>;
45
+ }
46
+
41
47
  export class BarrelAnalyzer {
42
48
  readonly #logger = new Logger("BarrelAnalyzer");
43
49
  readonly #opts: BarrelAnalyzerOptions;
@@ -96,7 +102,7 @@ export class BarrelAnalyzer {
96
102
  const map: BarrelExportMap = new Map();
97
103
  const read = new Set<string>();
98
104
  this.#read.set(pkgName, read);
99
- await this.#walk(pkg.entryFile, pkg, map, read);
105
+ await this.#walk(pkg.entryFile, pkg, map, { visited: new Set(), read, following: new Set([pkg.entryFile]) });
100
106
  return map;
101
107
  } catch (err) {
102
108
  this.#logger.error(`analyze failed for ${pkgName}: ${(err as Error).message}`);
@@ -104,9 +110,10 @@ export class BarrelAnalyzer {
104
110
  }
105
111
  }
106
112
 
107
- async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap, visited: Set<string>): Promise<void> {
108
- if (visited.has(absFile)) return;
109
- visited.add(absFile);
113
+ async #walk(absFile: string, pkg: PackageEntry, map: BarrelExportMap, walk: BarrelWalk): Promise<void> {
114
+ if (walk.visited.has(absFile)) return;
115
+ walk.visited.add(absFile);
116
+ walk.read.add(absFile);
110
117
  const file = Bun.file(absFile);
111
118
  if (!(await file.exists())) return;
112
119
  const source = await file.text();
@@ -119,11 +126,12 @@ export class BarrelAnalyzer {
119
126
  authoritative.delete("default");
120
127
 
121
128
  const attributed = new Set<string>();
122
- const attribute = (listBody: string, subpath: string) => {
129
+ const attribute = (listBody: string, subpath: string, source?: BarrelExportMap | null) => {
123
130
  for (const item of parseNamedList(listBody)) {
124
131
  if (item.isType || item.imported === "default" || !authoritative.has(item.local)) continue;
125
132
  attributed.add(item.local);
126
- if (!map.has(item.local)) map.set(item.local, { subpath, originalName: item.imported });
133
+ if (map.has(item.local)) continue;
134
+ map.set(item.local, source?.get(item.imported) ?? { subpath, originalName: item.imported });
127
135
  }
128
136
  };
129
137
 
@@ -152,7 +160,7 @@ export class BarrelAnalyzer {
152
160
  const targetAbs = await this.#resolveRel(absFile, spec);
153
161
  if (!targetAbs) continue;
154
162
  const targetSubpath = this.#subpathFor(pkg, targetAbs);
155
- if (targetSubpath) attribute(namedList, targetSubpath);
163
+ if (targetSubpath) attribute(namedList, targetSubpath, await this.#exportsOf(targetAbs, pkg, walk));
156
164
  }
157
165
  }
158
166
 
@@ -172,10 +180,20 @@ export class BarrelAnalyzer {
172
180
 
173
181
  for (const spec of starSpecs) {
174
182
  const targetAbs = await this.#resolveRel(absFile, spec);
175
- if (targetAbs) await this.#walk(targetAbs, pkg, map, visited);
183
+ if (targetAbs) await this.#walk(targetAbs, pkg, map, walk);
176
184
  }
177
185
  }
178
186
 
187
+ //? A name re-exported by name from a barrel is mapped to the file that declares it, as a star walk would map it:
188
+ //? a rewrite to the barrel itself would load every module behind it.
189
+ async #exportsOf(absFile: string, pkg: PackageEntry, walk: BarrelWalk): Promise<BarrelExportMap | null> {
190
+ if (walk.following.has(absFile)) return null;
191
+ const map: BarrelExportMap = new Map();
192
+ const following = new Set([...walk.following, absFile]);
193
+ await this.#walk(absFile, pkg, map, { visited: new Set(), read: walk.read, following });
194
+ return map;
195
+ }
196
+
179
197
  #scanExports(source: string, absFile: string): Set<string> {
180
198
  try {
181
199
  const transpiler = [".tsx", ".jsx"].includes(path.extname(absFile)) ? this.#tsxTranspiler : this.#tsTranspiler;
@@ -209,6 +209,33 @@ describe("BarrelAnalyzer and rewriteBarrelImports", () => {
209
209
  expect(map?.get("OnlyA")).toEqual({ subpath: "@scope/pkg/a", originalName: "OnlyA" });
210
210
  });
211
211
 
212
+ test("a name re-exported by name from a sub-barrel maps to the file that declares it", async () => {
213
+ const root = await makeTempRoot();
214
+ const pkgDir = path.join(root, "pkg");
215
+ await write(
216
+ path.join(pkgDir, "index.ts"),
217
+ 'export { A, Bee as B2 } from "./sub";\nexport { C } from "./cycleA";\n',
218
+ );
219
+ await write(path.join(pkgDir, "sub", "index.ts"), 'export * from "./a";\nexport { B as Bee } from "./b";\n');
220
+ await write(path.join(pkgDir, "sub", "a.ts"), "export const A = 1;\n");
221
+ await write(path.join(pkgDir, "sub", "b.ts"), "export const B = 2;\n");
222
+ await write(path.join(pkgDir, "cycleA.ts"), 'export { C } from "./cycleB";\n');
223
+ await write(path.join(pkgDir, "cycleB.ts"), 'export { C } from "./cycleA";\n');
224
+ const analyzer = new BarrelAnalyzer({
225
+ resolvePackage: async () => ({ pkgName: "@scope/pkg", entryFile: path.join(pkgDir, "index.ts"), pkgDir }),
226
+ });
227
+
228
+ const map = await analyzer.analyze("@scope/pkg");
229
+ expect(map?.get("A")).toEqual({ subpath: "@scope/pkg/sub/a", originalName: "A" });
230
+ expect(map?.get("B2")).toEqual({ subpath: "@scope/pkg/sub/b", originalName: "B" });
231
+ expect(map?.get("C")).toEqual({ subpath: "@scope/pkg/cycleA", originalName: "C" });
232
+ expect(
233
+ (await analyzer.filesOf("@scope/pkg"))
234
+ .map((file) => path.relative(pkgDir, file))
235
+ .sort((a, b) => a.localeCompare(b)),
236
+ ).toEqual(["cycleA.ts", "cycleB.ts", "index.ts", "sub/a.ts", "sub/b.ts", "sub/index.ts"]);
237
+ });
238
+
212
239
  test("two analyses that interleave each keep their own place in their barrel", async () => {
213
240
  const root = await makeTempRoot();
214
241
  const barrels = { first: ["a1", "a2", "a3"], second: ["b1", "b2"] } as const;