@akanjs/devkit 3.3.0-rc.0 → 3.3.0-rc.10

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 (85) hide show
  1. package/CHANGELOG.md +229 -2
  2. package/README.ko.md +3 -2
  3. package/README.md +3 -3
  4. package/akanApp/akanApp.host.test.ts +22 -5
  5. package/akanApp/akanApp.host.ts +46 -9
  6. package/akanApp/akanApp.host.wiring.test.ts +206 -2
  7. package/akanApp/devBackend.ts +3 -1
  8. package/akanApp/devBuilder.ts +5 -1
  9. package/akanApp/devStartTimeline.test.ts +115 -0
  10. package/akanApp/devStartTimeline.ts +69 -0
  11. package/akanConfig/akanConfig.test.ts +57 -8
  12. package/akanConfig/akanConfig.ts +12 -65
  13. package/akanConfig/dockerImage.ts +17 -0
  14. package/akanConfig/nativeKeys.ts +52 -0
  15. package/app/applicationBuildRunner.test.ts +49 -1
  16. package/app/applicationBuildRunner.ts +3 -1
  17. package/codeAgent/agent/CodeAgent.ts +36 -16
  18. package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
  19. package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
  20. package/codeAgent/agent/CodeAgentGate.ts +23 -4
  21. package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
  22. package/codeAgent/agent/codeAgent.test.ts +62 -0
  23. package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
  24. package/codeAgent/agent/codeAgentContract.test.ts +117 -5
  25. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  26. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  27. package/codeAgent/skills/akan-page/SKILL.md +18 -13
  28. package/codeAgent/skills/akan-runtime/SKILL.md +21 -16
  29. package/codeAgent/skills/akan-service/SKILL.md +2 -2
  30. package/docs/apiReference.test.ts +5 -0
  31. package/docs/apiReference.ts +7 -3
  32. package/docs/declarationReader.ts +28 -1
  33. package/executors/appExecutor.ts +35 -11
  34. package/executors/executors.test.ts +30 -3
  35. package/frontendBuild/buildCacheStamp.test.ts +42 -0
  36. package/frontendBuild/buildCacheStamp.ts +23 -0
  37. package/frontendBuild/buildRouteClient.test.ts +2 -7
  38. package/frontendBuild/clientEntryDiscovery.ts +2 -2
  39. package/frontendBuild/cssCandidateCache.test.ts +70 -1
  40. package/frontendBuild/cssCandidateCache.ts +17 -10
  41. package/frontendBuild/cssCompiler.test.ts +112 -0
  42. package/frontendBuild/cssCompiler.ts +41 -21
  43. package/frontendBuild/devBarrelImports.test.ts +30 -0
  44. package/frontendBuild/devBarrelImports.ts +2 -2
  45. package/frontendBuild/fontOptimizer.test.ts +144 -3
  46. package/frontendBuild/fontOptimizer.ts +103 -18
  47. package/frontendBuild/pagesBundleBuilder.ts +3 -1
  48. package/frontendBuild/plainStylesheet.test.ts +155 -0
  49. package/frontendBuild/plainStylesheet.ts +197 -0
  50. package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
  51. package/frontendBuild/rscServerRendererGuard.ts +68 -0
  52. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
  53. package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
  54. package/guideline/agentAssets.test.ts +10 -0
  55. package/guideline/agentAssets.ts +52 -11
  56. package/incrementalBuilder/buildBatch.proc.ts +11 -10
  57. package/incrementalBuilder/buildBatchProtocol.ts +2 -1
  58. package/incrementalBuilder/builderBoot.ts +14 -7
  59. package/incrementalBuilder/builderChannel.ts +8 -2
  60. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  61. package/incrementalBuilder/builderLanes.ts +2 -2
  62. package/incrementalBuilder/builderWatch.ts +8 -8
  63. package/incrementalBuilder/csrRegistry.ts +4 -4
  64. package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
  65. package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
  66. package/incrementalBuilder/incrementalBuilder.proc.test.ts +41 -0
  67. package/incrementalBuilder/incrementalBuilder.proc.ts +9 -8
  68. package/incrementalBuilder/ssrRegistry.ts +6 -6
  69. package/index.ts +1 -1
  70. package/integration/renderAdmissionSoak.test.ts +99 -0
  71. package/integration/renderAdmissionSoak.ts +609 -0
  72. package/mobile/nativeConfig.test.ts +100 -0
  73. package/mobile/nativeConfig.ts +55 -16
  74. package/mobile/nativePublicEnv.ts +2 -1
  75. package/package.json +14 -169
  76. package/packageExports.test.ts +38 -24
  77. package/transforms/barrelAnalyzer.ts +2 -2
  78. package/transforms/transforms.test.ts +3 -3
  79. package/tunnel/createTunnel.test.ts +29 -8
  80. package/tunnel/createTunnel.ts +18 -11
  81. package/util/fileEditor.ts +1 -0
  82. package/util/fileSys.test.ts +13 -0
  83. package/util/fileSys.ts +2 -2
  84. package/util/selectModel.ts +1 -0
  85. package/workspace/getRelatedCnsts.ts +7 -0
@@ -2,8 +2,11 @@ import { describe, expect, test } from "bun:test";
2
2
  import { generateKeyPairSync } from "node:crypto";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
+ import { resolveAcl } from "../../native/packages/cli/src/lib/acl";
5
6
  import { buildCsp, cspHash, parseCsp } from "../../native/packages/cli/src/lib/csp";
6
7
  import { rewriteDevHtml } from "../../native/packages/cli/src/lib/hmr";
8
+ import { aclCheck } from "../../native/packages/core/src/acl";
9
+ import externalViewManifest from "../../native/plugins/external-view/native-plugin.json";
7
10
  import type { AkanNativeTarget } from "../akanConfig";
8
11
  import { tempDirs } from "../test/testHelpers";
9
12
  import { NativeApi } from "./nativeApi";
@@ -484,6 +487,27 @@ describe("NativeConfig.build", () => {
484
487
  expect((await NativeApi.load(repoApp)).validateConfig(config, { appDir: root })).toEqual([]);
485
488
  });
486
489
 
490
+ test("ios.hideFormAccessoryBar reaches the iOS shell, and the runtime accepts it; left out, the bar stays", async () => {
491
+ const root = await makeTempRoot();
492
+ const build = (ios?: { hideFormAccessoryBar?: boolean }) =>
493
+ NativeConfig.build({
494
+ appPath: root,
495
+ target: { ...minimalTarget, permissions: [], deepLinks: undefined, android: undefined, ios },
496
+ webDir: path.join(root, "web"),
497
+ contributions: [],
498
+ locales: ["en"],
499
+ platform: "ios",
500
+ }).config;
501
+ const config = build({ hideFormAccessoryBar: true });
502
+
503
+ expect(config.ios).toEqual({ hideFormAccessoryBar: true });
504
+ expect(build().ios).toBeUndefined();
505
+ expect(build({ hideFormAccessoryBar: false }).ios).toBeUndefined();
506
+ await mkdir(path.join(root, "web"), { recursive: true });
507
+ await writeFile(path.join(root, "web/index.html"), "<html><head></head><body></body></html>");
508
+ expect((await NativeApi.load(repoApp)).validateConfig(config, { appDir: root })).toEqual([]);
509
+ });
510
+
487
511
  test("an app with updates ships the updates plugin and its settings", () => {
488
512
  const updates = { url: "https://releases.example.com/board", publicKey: `${"a".repeat(43)}=`, channel: "pilot" };
489
513
  const { config } = NativeConfig.build({
@@ -697,6 +721,82 @@ describe("NativeConfig.build", () => {
697
721
  expect(opener(["*"])).toBe("opener:default");
698
722
  });
699
723
 
724
+ test("an external view opens only the origins native.desktop.externalView lists, and evaluates or types only when it says so", () => {
725
+ const externalView = (setting?: NonNullable<AkanNativeTarget["desktop"]>["externalView"]) => {
726
+ const { config, warnings } = NativeConfig.build({
727
+ appPath: "/repo/apps/minimal",
728
+ target: {
729
+ ...minimalTarget,
730
+ plugins: ["external-view"],
731
+ ...(setting ? { desktop: { externalView: setting } } : {}),
732
+ },
733
+ webDir: "/web",
734
+ contributions: [],
735
+ locales: ["en"],
736
+ platform: "windows",
737
+ publicEnv: cloudEnv,
738
+ });
739
+ const permissions = config.capabilities?.[0]?.permissions.filter((p) =>
740
+ JSON.stringify(p).includes("external-view"),
741
+ );
742
+ const plugin = { spec: "external-view", dir: "/plugins/external-view", manifest: externalViewManifest as never };
743
+ const acl = resolveAcl([{ identifier: "app", permissions: permissions ?? [] }], [plugin], "windows");
744
+ return {
745
+ permissions,
746
+ warnings: warnings.filter((warning) => warning.includes("external-view")),
747
+ open: aclCheck(acl, "external-view", "open").scope?.allow,
748
+ evaluate: aclCheck(acl, "external-view", "evaluate").allowed,
749
+ sendKey: aclCheck(acl, "external-view", "sendKey").allowed,
750
+ };
751
+ };
752
+
753
+ expect(externalView()).toEqual({
754
+ permissions: [{ identifier: "external-view:default", allow: [] }],
755
+ warnings: [
756
+ "Native target 'default': external-view opens no origin until native.desktop.externalView.allowOrigins lists one.",
757
+ ],
758
+ open: [],
759
+ evaluate: false,
760
+ sendKey: false,
761
+ });
762
+ expect(
763
+ externalView({
764
+ allowOrigins: ["https://Board.example:443", "http://10.0.0.5:8080"],
765
+ evaluate: true,
766
+ sendKey: true,
767
+ }),
768
+ ).toEqual({
769
+ permissions: [
770
+ {
771
+ identifier: "external-view:default",
772
+ allow: [{ origin: "https://board.example" }, { origin: "http://10.0.0.5:8080" }],
773
+ },
774
+ "external-view:allow-evaluate",
775
+ "external-view:allow-sendKey",
776
+ ],
777
+ warnings: [],
778
+ open: [{ origin: "https://board.example" }, { origin: "http://10.0.0.5:8080" }],
779
+ evaluate: true,
780
+ sendKey: true,
781
+ });
782
+ expect(externalView({ allowOrigins: ["https://b\u00fccher.example"], sendKey: true })).toMatchObject({
783
+ open: [{ origin: "https://xn--bcher-kva.example" }],
784
+ evaluate: false,
785
+ sendKey: true,
786
+ });
787
+ for (const origin of [
788
+ "https://board.example/screen",
789
+ "https://*.example",
790
+ "https://user@board.example",
791
+ "board.example",
792
+ "ftp://board.example",
793
+ "https://board.example?x=1",
794
+ ])
795
+ expect(() => externalView({ allowOrigins: [origin] })).toThrow(
796
+ `native.desktop.externalView.allowOrigins holds "${origin}", which is not an exact http(s) origin`,
797
+ );
798
+ });
799
+
700
800
  test("keeps a file name the runtime accepts", () => {
701
801
  expect(NativeConfig.fileNameOf("minimal")).toBe("minimal");
702
802
  expect(NativeConfig.fileNameOf("my app!")).toBe("my-app");
@@ -9,7 +9,7 @@ import type {
9
9
  NativePermission,
10
10
  } from "akanjs";
11
11
  import { type AkanI18nConfig, LocalePath, trimSlashes } from "akanjs/common";
12
- import type { AkanNativeConfig } from "akanjs/native/config";
12
+ import type { AkanNativeConfig, CapabilityPermission } from "akanjs/native/config";
13
13
  import type { DesktopServerBundle } from "./desktopServerStage";
14
14
  import { type NativePlatform, resolveAppId } from "./mobileTarget";
15
15
  import type { NativePluginFolder } from "./nativePluginFolders";
@@ -214,16 +214,7 @@ export class NativeConfig {
214
214
  const native = NativeConfig.#compact({ ios, macos, android, resources });
215
215
  const googleServices = target.android?.googleServices;
216
216
  const pushAndroid = target.android?.push;
217
- const desktop = NativeConfig.#compact<NonNullable<AkanNativeConfig["desktop"]>>({
218
- recovery: target.desktop?.recovery,
219
- screenCapture: target.desktop?.screenCapture,
220
- webview2: target.desktop?.webview2,
221
- publisher: target.desktop?.publisher,
222
- window: NativeConfig.#compact({ ...target.desktop?.window }),
223
- server: desktopServer,
224
- bin: desktopBin,
225
- dmg: NativeConfig.#dmg(target.desktop?.dmg, abs),
226
- });
217
+ const desktop = NativeConfig.#desktop(target.desktop, desktopServer, desktopBin, abs);
227
218
  const background = target.backgroundColor;
228
219
  const shell = NativeConfig.#compact<NonNullable<AkanNativeConfig["shell"]>>({
229
220
  backgroundColor: typeof background === "string" ? background : background?.light,
@@ -248,11 +239,7 @@ export class NativeConfig {
248
239
  {
249
240
  identifier: "app",
250
241
  description: `The plugins ${target.appName} ships, each with its default permissions`,
251
- permissions: pluginIds.map((id) =>
252
- id === "opener" && !openUrls.includes("*")
253
- ? { identifier: "opener:default", allow: openUrls.map((url) => ({ url })) }
254
- : `${id}:default`,
255
- ),
242
+ permissions: NativeConfig.#permissions(pluginIds, target, openUrls, warnings),
256
243
  },
257
244
  ],
258
245
  ...(csp ? { security: { csp } } : {}),
@@ -270,6 +257,7 @@ export class NativeConfig {
270
257
  }
271
258
  : {}),
272
259
  ...(target.ios?.privacy ? { privacy: target.ios.privacy } : {}),
260
+ ...(target.ios?.hideFormAccessoryBar ? { ios: { hideFormAccessoryBar: true } } : {}),
273
261
  //? assetlinks.json vouches for `<appId>.debug` outside main, the suffix a debug build installs under.
274
262
  android: {
275
263
  debugAppIdSuffix: ".debug",
@@ -336,6 +324,39 @@ export class NativeConfig {
336
324
  return policy;
337
325
  }
338
326
 
327
+ static #permissions(pluginIds: string[], target: AkanNativeTarget, openUrls: readonly string[], warnings: string[]) {
328
+ return pluginIds.flatMap((id): (string | CapabilityPermission)[] => {
329
+ if (id === "opener" && !openUrls.includes("*"))
330
+ return [{ identifier: "opener:default", allow: openUrls.map((url) => ({ url })) }];
331
+ if (id === "external-view") return NativeConfig.#externalView(target, warnings);
332
+ return [`${id}:default`];
333
+ });
334
+ }
335
+
336
+ //? `external-view:default` alone opens no origin and leaves out evaluate and sendKey (the plugin's manifest).
337
+ static #externalView({ name, desktop }: AkanNativeTarget, warnings: string[]): (string | CapabilityPermission)[] {
338
+ const { allowOrigins = [], evaluate, sendKey } = desktop?.externalView ?? {};
339
+ const origins = allowOrigins.map((origin) => NativeConfig.#exactOrigin(name, origin));
340
+ if (!origins.length)
341
+ warnings.push(
342
+ `Native target '${name}': external-view opens no origin until native.desktop.externalView.allowOrigins lists one.`,
343
+ );
344
+ return [
345
+ { identifier: "external-view:default", allow: origins.map((origin) => ({ origin })) },
346
+ ...(evaluate ? ["external-view:allow-evaluate"] : []),
347
+ ...(sendKey ? ["external-view:allow-sendKey"] : []),
348
+ ];
349
+ }
350
+
351
+ static #exactOrigin(name: string, origin: string) {
352
+ const url = URL.canParse(origin) ? new URL(origin) : null;
353
+ if (!url || !/^https?:$/.test(url.protocol) || url.hostname.includes("*") || url.href !== `${url.origin}/`)
354
+ throw new Error(
355
+ `Native target '${name}': native.desktop.externalView.allowOrigins holds "${origin}", which is not an exact http(s) origin such as "https://board.example".`,
356
+ );
357
+ return url.origin;
358
+ }
359
+
339
360
  //? https: and wss: cover a cloud API, so only plain-http origins are named; a carried server's port comes at launch.
340
361
  static #plainOrigins(publicEnv: Record<string, string | undefined>, env: NativeEnv | undefined, carried: boolean) {
341
362
  const origins = new Set<string>();
@@ -363,6 +384,24 @@ export class NativeConfig {
363
384
  return { ...splash, ...(splash.image ? { image: abs(splash.image) } : {}) };
364
385
  }
365
386
 
387
+ static #desktop(
388
+ desktop: AkanNativeTarget["desktop"],
389
+ server: DesktopServerBundle | undefined,
390
+ bin: string | undefined,
391
+ abs: (relative: string) => string,
392
+ ) {
393
+ return NativeConfig.#compact<NonNullable<AkanNativeConfig["desktop"]>>({
394
+ recovery: desktop?.recovery,
395
+ screenCapture: desktop?.screenCapture,
396
+ webview2: desktop?.webview2,
397
+ publisher: desktop?.publisher,
398
+ window: NativeConfig.#compact({ ...desktop?.window }),
399
+ server,
400
+ bin,
401
+ dmg: NativeConfig.#dmg(desktop?.dmg, abs),
402
+ });
403
+ }
404
+
366
405
  static #dmg(dmg: AkanNativeDmgConfig | undefined, abs: (relative: string) => string) {
367
406
  if (!dmg) return undefined;
368
407
  const { background, background2x, ...layout } = dmg;
@@ -1,7 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import type { App } from "../commandDecorators";
3
3
  import { WorkspaceExecutor } from "../executors";
4
- import { CsrArtifactBuilder } from "../frontendBuild/csrArtifactBuilder";
5
4
 
6
5
  export type PublicEnv = Record<string, string>;
7
6
 
@@ -68,6 +67,7 @@ export class NativePublicEnv {
68
67
 
69
68
  /** What the app's last `akan build` inlined, or null when it built no CSR bundle. */
70
69
  static async built(app: App): Promise<PublicEnv | null> {
70
+ const { CsrArtifactBuilder } = await import("../frontendBuild/csrArtifactBuilder");
71
71
  const file = Bun.file(CsrArtifactBuilder.publicEnvPath(app));
72
72
  if (!(await file.exists())) return null;
73
73
  return NativePublicEnv.of((await file.json()) as Record<string, unknown>);
@@ -75,6 +75,7 @@ export class NativePublicEnv {
75
75
 
76
76
  /** Every `AKAN_PUBLIC_*` the last `akan build` inlined, derived keys included, else the ones this process has. */
77
77
  static async inlined(app: App): Promise<PublicEnv> {
78
+ const { CsrArtifactBuilder } = await import("../frontendBuild/csrArtifactBuilder");
78
79
  const file = Bun.file(CsrArtifactBuilder.publicEnvPath(app));
79
80
  const env = (await file.exists()) ? ((await file.json()) as Record<string, unknown>) : process.env;
80
81
  return Object.fromEntries(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.0",
3
+ "version": "3.3.0-rc.10",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -30,6 +30,7 @@
30
30
  "./cloud": "./cloud/index.ts",
31
31
  "./codeAgent": "./codeAgent/index.ts",
32
32
  "./commandDecorators": "./commandDecorators/index.ts",
33
+ "./executors": "./executors/index.ts",
33
34
  "./frontendBuild": "./frontendBuild/index.ts",
34
35
  "./incrementalBuilder": "./incrementalBuilder/index.ts",
35
36
  "./mobile": "./mobile/index.ts",
@@ -37,175 +38,19 @@
37
38
  "./preview": "./preview/index.ts",
38
39
  "./transforms": "./transforms/index.ts",
39
40
  "./workflow": "./workflow/index.ts",
40
- "./abstractDoc": "./quality/abstractDoc.ts",
41
- "./abstractDoc.ts": "./quality/abstractDoc.ts",
42
- "./agentAssets": "./guideline/agentAssets.ts",
43
- "./agentAssets.ts": "./guideline/agentAssets.ts",
44
- "./agentsIndex": "./guideline/agentsIndex.ts",
45
- "./agentsIndex.ts": "./guideline/agentsIndex.ts",
46
- "./akanContext": "./context/akanContext.ts",
47
- "./akanContext.ts": "./context/akanContext.ts",
48
- "./akanMcpContract": "./context/akanMcpContract.ts",
49
- "./akanMcpContract.ts": "./context/akanMcpContract.ts",
50
- "./akanMcpToolError": "./context/akanMcpToolError.ts",
51
- "./akanMcpToolError.ts": "./context/akanMcpToolError.ts",
52
- "./apiReference": "./docs/apiReference.ts",
53
- "./apiReference.ts": "./docs/apiReference.ts",
54
- "./appSelectionMemory": "./workspace/appSelectionMemory.ts",
55
- "./appSelectionMemory.ts": "./workspace/appSelectionMemory.ts",
56
- "./applicationBuildReporter": "./app/applicationBuildReporter.ts",
57
- "./applicationBuildReporter.ts": "./app/applicationBuildReporter.ts",
58
- "./applicationBuildRunner": "./app/applicationBuildRunner.ts",
59
- "./applicationBuildRunner.ts": "./app/applicationBuildRunner.ts",
60
- "./applicationTestPreload": "./app/applicationTestPreload.ts",
61
- "./applicationTestPreload.ts": "./app/applicationTestPreload.ts",
62
- "./bareErrorScanner": "./quality/bareErrorScanner.ts",
63
- "./bareErrorScanner.ts": "./quality/bareErrorScanner.ts",
64
- "./biomeBase": "./lint/biomeBase.ts",
65
- "./biomeBase.ts": "./lint/biomeBase.ts",
66
- "./codegenLock": "./workspace/codegenLock.ts",
67
- "./codegenLock.ts": "./workspace/codegenLock.ts",
68
- "./commentDensityScanner": "./quality/commentDensityScanner.ts",
69
- "./commentDensityScanner.ts": "./quality/commentDensityScanner.ts",
70
- "./componentSizeScanner": "./quality/componentSizeScanner.ts",
71
- "./componentSizeScanner.ts": "./quality/componentSizeScanner.ts",
72
- "./componentWriteChainScanner": "./quality/componentWriteChainScanner.ts",
73
- "./componentWriteChainScanner.ts": "./quality/componentWriteChainScanner.ts",
74
- "./conventionSet": "./guideline/conventionSet.ts",
75
- "./conventionSet.ts": "./guideline/conventionSet.ts",
76
- "./createTunnel": "./tunnel/createTunnel.ts",
77
- "./createTunnel.ts": "./tunnel/createTunnel.ts",
78
- "./declarationReader": "./docs/declarationReader.ts",
79
- "./declarationReader.ts": "./docs/declarationReader.ts",
80
- "./dependencyScanner": "./workspace/dependencyScanner.ts",
81
- "./dependencyScanner.ts": "./workspace/dependencyScanner.ts",
82
- "./deprecatedCommentScanner": "./quality/deprecatedCommentScanner.ts",
83
- "./deprecatedCommentScanner.ts": "./quality/deprecatedCommentScanner.ts",
84
- "./endpointReach": "./quality/endpointReach.ts",
85
- "./endpointReach.ts": "./quality/endpointReach.ts",
86
- "./envSeed": "./workspace/envSeed.ts",
87
- "./envSeed.ts": "./workspace/envSeed.ts",
88
- "./errorCodeReference": "./docs/errorCodeReference.ts",
89
- "./errorCodeReference.ts": "./docs/errorCodeReference.ts",
90
- "./errorCodeScan": "./docs/errorCodeScan.ts",
91
- "./errorCodeScan.ts": "./docs/errorCodeScan.ts",
92
- "./executors": "./executors/index.ts",
93
- "./executors.ts": "./executors/index.ts",
94
- "./fileEditor": "./util/fileEditor.ts",
95
- "./fileEditor.ts": "./util/fileEditor.ts",
96
- "./fileSys": "./util/fileSys.ts",
97
- "./fileSys.ts": "./util/fileSys.ts",
98
- "./formSetterScanner": "./quality/formSetterScanner.ts",
99
- "./formSetterScanner.ts": "./quality/formSetterScanner.ts",
100
- "./frameworkGraph": "./docs/frameworkGraph.ts",
101
- "./frameworkGraph.ts": "./docs/frameworkGraph.ts",
102
- "./getRelatedCnsts": "./workspace/getRelatedCnsts.ts",
103
- "./getRelatedCnsts.ts": "./workspace/getRelatedCnsts.ts",
104
- "./gitRevision": "./workspace/gitRevision.ts",
105
- "./gitRevision.ts": "./workspace/gitRevision.ts",
106
- "./jsonFormatter": "./util/jsonFormatter.ts",
107
- "./jsonFormatter.ts": "./util/jsonFormatter.ts",
108
- "./kindBranchScanner": "./quality/kindBranchScanner.ts",
109
- "./kindBranchScanner.ts": "./quality/kindBranchScanner.ts",
110
- "./libSource": "./workspace/libSource.ts",
111
- "./libSource.ts": "./workspace/libSource.ts",
112
- "./linter": "./lint/linter.ts",
113
- "./linter.ts": "./lint/linter.ts",
114
- "./maintainabilityBaseline": "./quality/maintainabilityBaseline.ts",
115
- "./maintainabilityBaseline.ts": "./quality/maintainabilityBaseline.ts",
116
- "./maintainabilityContract": "./quality/maintainabilityContract.ts",
117
- "./maintainabilityContract.ts": "./quality/maintainabilityContract.ts",
118
- "./maintainabilityExceptionScanner": "./quality/maintainabilityExceptionScanner.ts",
119
- "./maintainabilityExceptionScanner.ts": "./quality/maintainabilityExceptionScanner.ts",
120
- "./maintainabilityLimits": "./quality/maintainabilityLimits.ts",
121
- "./maintainabilityLimits.ts": "./quality/maintainabilityLimits.ts",
122
- "./maintainabilityReport": "./quality/maintainabilityReport.ts",
123
- "./maintainabilityReport.ts": "./quality/maintainabilityReport.ts",
124
- "./manifestDependencies": "./workspace/manifestDependencies.ts",
125
- "./manifestDependencies.ts": "./workspace/manifestDependencies.ts",
126
- "./moduleFieldNames": "./context/moduleFieldNames.ts",
127
- "./moduleFieldNames.ts": "./context/moduleFieldNames.ts",
128
- "./packageExportsMap": "./workspace/packageExportsMap.ts",
129
- "./packageExportsMap.ts": "./workspace/packageExportsMap.ts",
130
- "./prompter": "./guideline/prompter.ts",
131
- "./prompter.ts": "./guideline/prompter.ts",
132
- "./qualityScanner": "./quality/qualityScanner.ts",
133
- "./qualityScanner.ts": "./quality/qualityScanner.ts",
134
- "./recipeScanner": "./context/recipeScanner.ts",
135
- "./recipeScanner.ts": "./context/recipeScanner.ts",
136
- "./renderMutationScanner": "./quality/renderMutationScanner.ts",
137
- "./renderMutationScanner.ts": "./quality/renderMutationScanner.ts",
138
- "./repoIdentity": "./workspace/repoIdentity.ts",
139
- "./repoIdentity.ts": "./workspace/repoIdentity.ts",
140
- "./routeJsBudget": "./app/routeJsBudget.ts",
141
- "./routeJsBudget.ts": "./app/routeJsBudget.ts",
142
- "./routeSourceValidator": "./app/routeSourceValidator.ts",
143
- "./routeSourceValidator.ts": "./app/routeSourceValidator.ts",
144
- "./scanInfo": "./workspace/scanInfo.ts",
145
- "./scanInfo.ts": "./workspace/scanInfo.ts",
146
- "./selectModel": "./util/selectModel.ts",
147
- "./selectModel.ts": "./util/selectModel.ts",
148
- "./semver": "./util/semver.ts",
149
- "./semver.ts": "./util/semver.ts",
150
- "./serviceLoopCallScanner": "./quality/serviceLoopCallScanner.ts",
151
- "./serviceLoopCallScanner.ts": "./quality/serviceLoopCallScanner.ts",
152
- "./shellOnlyEnv": "./util/shellOnlyEnv.ts",
153
- "./shellOnlyEnv.ts": "./util/shellOnlyEnv.ts",
154
- "./signalMutationIndex": "./quality/signalMutationIndex.ts",
155
- "./signalMutationIndex.ts": "./quality/signalMutationIndex.ts",
156
- "./slicePlanner": "./workspace/slicePlanner.ts",
157
- "./slicePlanner.ts": "./workspace/slicePlanner.ts",
158
- "./sourceComments": "./quality/sourceComments.ts",
159
- "./sourceComments.ts": "./quality/sourceComments.ts",
160
- "./spinner": "./util/spinner.ts",
161
- "./spinner.ts": "./util/spinner.ts",
162
- "./sshHostKeys": "./tunnel/sshHostKeys.ts",
163
- "./sshHostKeys.ts": "./tunnel/sshHostKeys.ts",
164
- "./sshTunnel": "./tunnel/sshTunnel.ts",
165
- "./sshTunnel.ts": "./tunnel/sshTunnel.ts",
166
- "./ssrScanner": "./quality/ssrScanner.ts",
167
- "./ssrScanner.ts": "./quality/ssrScanner.ts",
168
- "./storeAccessScanner": "./quality/storeAccessScanner.ts",
169
- "./storeAccessScanner.ts": "./quality/storeAccessScanner.ts",
170
- "./storeSource": "./quality/storeSource.ts",
171
- "./storeSource.ts": "./quality/storeSource.ts",
172
- "./storeWriteScanner": "./quality/storeWriteScanner.ts",
173
- "./storeWriteScanner.ts": "./quality/storeWriteScanner.ts",
174
- "./stripAnsi": "./util/stripAnsi.ts",
175
- "./stripAnsi.ts": "./util/stripAnsi.ts",
176
- "./structureScanner": "./quality/structureScanner.ts",
177
- "./structureScanner.ts": "./quality/structureScanner.ts",
178
- "./subspace": "./subspace/subspace.ts",
179
- "./subspace.ts": "./subspace/subspace.ts",
180
- "./subspaceClone": "./subspace/subspaceClone.ts",
181
- "./subspaceClone.ts": "./subspace/subspaceClone.ts",
182
- "./subspaceConfig": "./subspace/subspaceConfig.ts",
183
- "./subspaceConfig.ts": "./subspace/subspaceConfig.ts",
184
- "./subspaceReport": "./subspace/subspaceReport.ts",
185
- "./subspaceReport.ts": "./subspace/subspaceReport.ts",
186
- "./testHelpers": "./test/testHelpers.ts",
187
- "./testHelpers.ts": "./test/testHelpers.ts",
188
- "./testOnlyExportScanner": "./quality/testOnlyExportScanner.ts",
189
- "./testOnlyExportScanner.ts": "./quality/testOnlyExportScanner.ts",
190
- "./typeChecker": "./typecheck/typeChecker.ts",
191
- "./typeChecker.ts": "./typecheck/typeChecker.ts",
192
- "./types": "./workspace/types.ts",
193
- "./types.ts": "./workspace/types.ts",
194
- "./workspaceGraph": "./workspace/workspaceGraph.ts",
195
- "./workspaceGraph.ts": "./workspace/workspaceGraph.ts",
196
- "./workspaceLayout": "./workspace/workspaceLayout.ts",
197
- "./workspaceLayout.ts": "./workspace/workspaceLayout.ts",
198
- "./writePath": "./quality/writePath.ts",
199
- "./writePath.ts": "./quality/writePath.ts",
200
- "./writePlacementScanner": "./quality/writePlacementScanner.ts",
201
- "./writePlacementScanner.ts": "./quality/writePlacementScanner.ts",
202
- "./writingActionIndex": "./quality/writingActionIndex.ts",
203
- "./writingActionIndex.ts": "./quality/writingActionIndex.ts",
204
- "./*.ts": "./*.ts",
205
- "./*": "./*.ts"
41
+ "./app/applicationBuildRunner": "./app/applicationBuildRunner.ts",
42
+ "./cloud/cloudApi": "./cloud/cloudApi.ts",
43
+ "./cloud/cloudUpdates": "./cloud/cloudUpdates.ts",
44
+ "./commandDecorators/exitCodeError": "./commandDecorators/exitCodeError.ts",
45
+ "./mobile/desktopRelease": "./mobile/desktopRelease.ts",
46
+ "./mobile/serverBundleSecrets": "./mobile/serverBundleSecrets.ts",
47
+ "./transforms/serverEnvProfile": "./transforms/serverEnvProfile.ts",
48
+ "./util/fileEditor": "./util/fileEditor.ts",
49
+ "./util/selectModel": "./util/selectModel.ts",
50
+ "./workspace/getRelatedCnsts": "./workspace/getRelatedCnsts.ts"
206
51
  },
207
52
  "dependencies": {
208
- "@akanjs/language": "3.3.0-rc.0",
53
+ "@akanjs/language": "3.3.0-rc.10",
209
54
  "@earendil-works/pi-agent-core": "1.5.2",
210
55
  "@earendil-works/pi-ai": "1.5.2",
211
56
  "@earendil-works/pi-codemode": "1.5.2",
@@ -214,7 +59,7 @@
214
59
  "@earendil-works/pi-tui": "1.5.2",
215
60
  "@inquirer/prompts": "^8.7.3",
216
61
  "@tailwindcss/node": "^4.3.3",
217
- "akanjs": "3.3.0-rc.0",
62
+ "akanjs": "3.3.0-rc.10",
218
63
  "chalk": "^6.0.1",
219
64
  "commander": "^15.0.0",
220
65
  "dayjs": "^1.11.23",
@@ -14,12 +14,19 @@ const barrelFacets = async (): Promise<string[]> => {
14
14
  return [...barrel.matchAll(/^export (?:type )?\* from "\.\/([^"]+)";$/gm)].map((match) => `./${match[1]}`);
15
15
  };
16
16
 
17
+ //? The CLI's dist inlines devkit: once installed, only devkit's own sources, the CLI's templates and the README
18
+ //? examples a tool author copies import a subpath.
17
19
  const importedSubpaths = async (): Promise<string[]> => {
18
20
  const repoRoot = path.resolve(packageDir, "../../..");
19
- const glob = new Bun.Glob("pkgs/@akanjs/{cli,devkit}/**/*.{ts,tsx}");
20
21
  const found = new Set<string>();
21
- for await (const relative of glob.scan({ cwd: repoRoot })) {
22
- if (relative.includes("node_modules/") || relative.includes("/dist/")) continue;
22
+ const sources = [
23
+ ...new Bun.Glob("pkgs/@akanjs/devkit/**/*.{ts,tsx}").scanSync({ cwd: repoRoot }),
24
+ ...new Bun.Glob("pkgs/@akanjs/devkit/README*.md").scanSync({ cwd: repoRoot }),
25
+ ...new Bun.Glob("pkgs/@akanjs/cli/templates/**/*").scanSync({ cwd: repoRoot }),
26
+ ];
27
+ for (const relative of sources) {
28
+ if (relative.includes("node_modules/") || relative.includes("/dist/") || /\.(test|spec)\.tsx?$/.test(relative))
29
+ continue;
23
30
  const source = await Bun.file(path.join(repoRoot, relative)).text();
24
31
  for (const match of source.matchAll(/"@akanjs\/devkit\/([a-zA-Z0-9_./-]+)"/g)) found.add(`./${match[1]}`);
25
32
  }
@@ -27,29 +34,45 @@ const importedSubpaths = async (): Promise<string[]> => {
27
34
  };
28
35
 
29
36
  describe("published exports map", () => {
30
- test("resolves every facet the root barrel re-exports", async () => {
31
- const facets = await barrelFacets();
32
- expect(facets.length).toBeGreaterThan(30);
33
- expect(exportsMap.findUnreachable(facets)).toEqual([]);
37
+ test("names every public subpath, with no wildcard to reach a file it does not", async () => {
38
+ const manifest = (await Bun.file(path.join(packageDir, "package.json")).json()) as {
39
+ exports: Record<string, unknown>;
40
+ };
41
+ const subpaths = Object.keys(manifest.exports);
42
+ expect(subpaths.filter((subpath) => subpath.includes("*"))).toEqual([]);
43
+ expect(subpaths.length).toBeGreaterThan(20);
44
+ expect(exportsMap.findUnreachable(subpaths)).toEqual([]);
34
45
  });
35
46
 
36
- test("resolves every subpath the monorepo actually imports", async () => {
47
+ test("resolves every subpath a published install imports", async () => {
37
48
  const subpaths = await importedSubpaths();
38
- expect(subpaths.length).toBeGreaterThan(20);
49
+ expect(subpaths).toContain("./executors");
39
50
  expect(exportsMap.findUnreachable(subpaths)).toEqual([]);
40
51
  });
41
52
 
42
- test("covers both facet shapes and keeps explicit extensions intact", () => {
43
- // One wildcard cannot serve bare files, directory facets and already-suffixed specifiers (no `.ts.ts`) at once.
53
+ test("points a directory facet at its index and a nested entry at its file", () => {
44
54
  expect(exportsMap.resolve("./executors")).toBe("./executors/index.ts");
45
- expect(exportsMap.resolve("./fileSys")).toBe("./util/fileSys.ts");
46
- expect(exportsMap.resolve("./workspaceLayout.ts")).toBe("./workspace/workspaceLayout.ts");
47
55
  expect(exportsMap.resolve("./frontendBuild")).toBe("./frontendBuild/index.ts");
48
- expect(exportsMap.resolve("./cloud/cloudApi.ts")).toBe("./cloud/cloudApi.ts");
56
+ expect(exportsMap.resolve("./cloud/cloudApi")).toBe("./cloud/cloudApi.ts");
49
57
  expect(exportsMap.resolve("./package.json")).toBe("./package.json");
50
58
  });
51
59
 
52
- test("every directory facet has a literal entry, since the wildcard cannot probe index.ts", async () => {
60
+ test("keeps an entry for each nested file a consumer workspace imports", () => {
61
+ const nested = [
62
+ "cloud/cloudApi",
63
+ "cloud/cloudUpdates",
64
+ "commandDecorators/exitCodeError",
65
+ "mobile/desktopRelease",
66
+ "mobile/serverBundleSecrets",
67
+ "transforms/serverEnvProfile",
68
+ "util/fileEditor",
69
+ "util/selectModel",
70
+ "workspace/getRelatedCnsts",
71
+ ];
72
+ expect(nested.filter((file) => exportsMap.resolve(`./${file}`) !== `./${file}.ts`)).toEqual([]);
73
+ });
74
+
75
+ test("every directory facet the root barrel re-exports has a literal entry", async () => {
53
76
  const facets = await barrelFacets();
54
77
  const missing = facets.filter(
55
78
  (subpath) =>
@@ -58,15 +81,6 @@ describe("published exports map", () => {
58
81
  expect(missing).toEqual([]);
59
82
  });
60
83
 
61
- test("points every literal entry at a file, so a subpath the root once held still loads from its folder", async () => {
62
- const manifest = (await Bun.file(path.join(packageDir, "package.json")).json()) as {
63
- exports: Record<string, unknown>;
64
- };
65
- const literals = Object.keys(manifest.exports).filter((subpath) => !subpath.includes("*"));
66
- expect(literals.length).toBeGreaterThan(100);
67
- expect(exportsMap.findUnreachable(literals)).toEqual([]);
68
- });
69
-
70
84
  test("keeps every source out of the package root but its type barrel", () => {
71
85
  const loose = [...new Bun.Glob("*.{ts,tsx}").scanSync({ cwd: packageDir })].filter(
72
86
  (file) => file !== "index.ts" && !file.endsWith(".test.ts"),
@@ -18,7 +18,7 @@ export interface PackageEntry {
18
18
  entryFile: string;
19
19
  /** Absolute base directory for subpath computation, typically `dirname(entryFile)`. */
20
20
  pkgDir: string;
21
- /** Emit concrete file paths, for package exports that do not support extensionless deep imports. */
21
+ /** Emit absolute file paths: an installed package's exports name its barrels, never the files behind them. */
22
22
  preserveFilePath?: boolean;
23
23
  }
24
24
 
@@ -211,7 +211,7 @@ export class BarrelAnalyzer {
211
211
  #subpathFor(pkg: PackageEntry, absFile: string): string | null {
212
212
  const rel = path.relative(pkg.pkgDir, absFile);
213
213
  if (!rel || rel.startsWith("..") || path.isAbsolute(rel)) return null;
214
- if (pkg.preserveFilePath) return `${pkg.pkgName}/${rel.split(path.sep).join("/")}`;
214
+ if (pkg.preserveFilePath) return absFile.split(path.sep).join("/");
215
215
  const ext = CANDIDATE_EXTS.find((candidate) => rel.endsWith(candidate));
216
216
  const parts = (ext ? rel.slice(0, -ext.length) : rel).split(path.sep);
217
217
  // `xxx/index` collapses to `xxx`: callers import `@pkg/xxx`, never `@pkg/xxx/index`.
@@ -517,7 +517,7 @@ describe("BarrelAnalyzer and rewriteBarrelImports", () => {
517
517
  expect(rewritten).toBe('import { BottomInset } from "akanjs/ui/Layout/BottomInset";\n');
518
518
  });
519
519
 
520
- test("preserves concrete file paths for package-exported barrels", async () => {
520
+ test("writes an installed package's targets as files, which its exports map does not have to reach", async () => {
521
521
  const root = await makeTempRoot();
522
522
  await write(
523
523
  path.join(root, "node_modules/akanjs/ui/index.ts"),
@@ -543,8 +543,8 @@ describe("BarrelAnalyzer and rewriteBarrelImports", () => {
543
543
 
544
544
  expect(rewritten).toBe(
545
545
  `${[
546
- 'import { Link } from "akanjs/ui/Link/index.tsx";',
547
- 'import { System } from "akanjs/ui/System/index.tsx";',
546
+ `import { Link } from ${JSON.stringify(path.join(root, "node_modules/akanjs/ui/Link/index.tsx"))};`,
547
+ `import { System } from ${JSON.stringify(path.join(root, "node_modules/akanjs/ui/System/index.tsx"))};`,
548
548
  ].join("\n")}\n`,
549
549
  );
550
550
  });