@akanjs/devkit 3.3.0-rc.7 → 3.3.0-rc.8

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 (45) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/README.ko.md +3 -2
  3. package/README.md +3 -3
  4. package/akanApp/akanApp.host.test.ts +1 -1
  5. package/akanConfig/akanConfig.test.ts +55 -7
  6. package/akanConfig/akanConfig.ts +12 -65
  7. package/akanConfig/dockerImage.ts +17 -0
  8. package/akanConfig/nativeKeys.ts +52 -0
  9. package/codeAgent/agent/CodeAgent.ts +36 -16
  10. package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
  11. package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
  12. package/codeAgent/agent/CodeAgentGate.ts +23 -4
  13. package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
  14. package/codeAgent/agent/codeAgent.test.ts +62 -0
  15. package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
  16. package/codeAgent/agent/codeAgentContract.test.ts +117 -5
  17. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  18. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  19. package/frontendBuild/buildRouteClient.test.ts +2 -7
  20. package/frontendBuild/clientEntryDiscovery.ts +2 -2
  21. package/frontendBuild/devBarrelImports.test.ts +30 -0
  22. package/frontendBuild/devBarrelImports.ts +2 -2
  23. package/incrementalBuilder/buildBatch.proc.ts +9 -9
  24. package/incrementalBuilder/buildBatchProtocol.ts +1 -1
  25. package/incrementalBuilder/builderBoot.ts +5 -5
  26. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  27. package/incrementalBuilder/builderLanes.ts +2 -2
  28. package/incrementalBuilder/builderWatch.ts +8 -8
  29. package/incrementalBuilder/csrRegistry.ts +4 -4
  30. package/incrementalBuilder/incrementalBuilder.proc.ts +8 -8
  31. package/incrementalBuilder/ssrRegistry.ts +6 -6
  32. package/index.ts +1 -1
  33. package/integration/renderAdmissionSoak.test.ts +99 -0
  34. package/integration/renderAdmissionSoak.ts +609 -0
  35. package/mobile/nativeConfig.test.ts +79 -0
  36. package/mobile/nativeConfig.ts +35 -6
  37. package/package.json +14 -169
  38. package/packageExports.test.ts +38 -24
  39. package/transforms/barrelAnalyzer.ts +2 -2
  40. package/transforms/transforms.test.ts +3 -3
  41. package/tunnel/createTunnel.test.ts +29 -8
  42. package/tunnel/createTunnel.ts +18 -11
  43. package/util/fileEditor.ts +1 -0
  44. package/util/selectModel.ts +1 -0
  45. 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";
@@ -718,6 +721,82 @@ describe("NativeConfig.build", () => {
718
721
  expect(opener(["*"])).toBe("opener:default");
719
722
  });
720
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
+
721
800
  test("keeps a file name the runtime accepts", () => {
722
801
  expect(NativeConfig.fileNameOf("minimal")).toBe("minimal");
723
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";
@@ -239,11 +239,7 @@ export class NativeConfig {
239
239
  {
240
240
  identifier: "app",
241
241
  description: `The plugins ${target.appName} ships, each with its default permissions`,
242
- permissions: pluginIds.map((id) =>
243
- id === "opener" && !openUrls.includes("*")
244
- ? { identifier: "opener:default", allow: openUrls.map((url) => ({ url })) }
245
- : `${id}:default`,
246
- ),
242
+ permissions: NativeConfig.#permissions(pluginIds, target, openUrls, warnings),
247
243
  },
248
244
  ],
249
245
  ...(csp ? { security: { csp } } : {}),
@@ -328,6 +324,39 @@ export class NativeConfig {
328
324
  return policy;
329
325
  }
330
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
+
331
360
  //? https: and wss: cover a cloud API, so only plain-http origins are named; a carried server's port comes at launch.
332
361
  static #plainOrigins(publicEnv: Record<string, string | undefined>, env: NativeEnv | undefined, carried: boolean) {
333
362
  const origins = new Set<string>();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.7",
3
+ "version": "3.3.0-rc.8",
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.7",
53
+ "@akanjs/language": "3.3.0-rc.8",
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.7",
62
+ "akanjs": "3.3.0-rc.8",
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
  });
@@ -90,7 +90,7 @@ describe("createTunnel", () => {
90
90
  const listener = Bun.listen({ hostname: "127.0.0.1", port: 0, socket: { data() {} } });
91
91
  const port = listener.port;
92
92
  listener.stop(true);
93
- process.env.SSH_TUNNEL_PORT = String(port);
93
+ Object.assign(process.env, { SSH_TUNNEL_PORT: String(port), SSH_TUNNEL_PASSWORD: "test-password" });
94
94
 
95
95
  let originalError: Error | undefined;
96
96
  const connect = Client.prototype.connect;
@@ -193,7 +193,7 @@ describe("createTunnel", () => {
193
193
  expect(ssh.methods.filter((method) => method !== "none")).toEqual(["password"]);
194
194
  });
195
195
 
196
- test("warns when it signs in with the default shared credential", async () => {
196
+ test("a tunnel needs a configured credential and names the settings that provide one", async () => {
197
197
  const { root, app } = track(await createTempApp("demo"));
198
198
  const ssh = await startSshServer();
199
199
  Object.assign(process.env, {
@@ -203,13 +203,34 @@ describe("createTunnel", () => {
203
203
  //? `akan test` runs from the workspace root, whose dotenv may name a password; this case is the one with none.
204
204
  delete process.env.SSH_TUNNEL_PASSWORD;
205
205
  delete process.env.SSH_TUNNEL_PRIVATE_KEY_PATH;
206
- const warn = spyOn(app.logger, "warn");
207
-
208
- await createTunnel("redis", { app, environment: "testing", port: freePort() });
206
+ const connect = spyOn(Client.prototype, "connect");
207
+ try {
208
+ await expect(createTunnel("redis", { app, environment: "testing", port: freePort() })).rejects.toThrow(
209
+ "The redis tunnel for demo-testing needs an SSH credential: export SSH_TUNNEL_PRIVATE_KEY_PATH",
210
+ );
211
+ await expect(createTunnel("postgres", { app, environment: "testing", port: freePort() })).rejects.toThrow(
212
+ "or set SSH_TUNNEL_PASSWORD",
213
+ );
214
+ expect(connect).not.toHaveBeenCalled();
215
+ } finally {
216
+ connect.mockRestore();
217
+ }
218
+ expect(ssh.methods).toEqual([]);
219
+ });
209
220
 
210
- expect(warn.mock.calls.map(([message]) => String(message)).join("\n")).toContain(
211
- "uses the default shared credential",
212
- );
221
+ test("a key file the tunnel cannot read fails naming the tunnel, the setting and the path", async () => {
222
+ const { root, app } = track(await createTempApp("demo"));
223
+ const keyPath = path.join(root, "missing_key");
224
+ process.env.SSH_TUNNEL_PRIVATE_KEY_PATH = keyPath;
225
+ const connect = spyOn(Client.prototype, "connect");
226
+ try {
227
+ await expect(createTunnel("redis", { app, environment: "testing", port: freePort() })).rejects.toThrow(
228
+ `The redis tunnel for demo-testing could not read the key SSH_TUNNEL_PRIVATE_KEY_PATH names, ${keyPath} (ENOENT)`,
229
+ );
230
+ expect(connect).not.toHaveBeenCalled();
231
+ } finally {
232
+ connect.mockRestore();
233
+ }
213
234
  });
214
235
 
215
236
  test("listens where SSH_TUNNEL_BIND_HOST says and warns when that is not loopback", async () => {
@@ -20,19 +20,25 @@ interface TunnelOption {
20
20
  port?: number;
21
21
  }
22
22
 
23
- const tunnelAuth = (
24
- app: AppExecutor,
25
- repoName: string,
26
- ): Pick<ConnectConfig, "privateKey" | "passphrase" | "password"> => {
23
+ const readTunnelKey = (purpose: string, keyPath: string) => {
24
+ try {
25
+ return readFileSync(keyPath);
26
+ } catch (error) {
27
+ const reason = (error as NodeJS.ErrnoException).code ?? (error instanceof Error ? error.message : String(error));
28
+ throw new Error(`${purpose} could not read the key SSH_TUNNEL_PRIVATE_KEY_PATH names, ${keyPath} (${reason}).`, {
29
+ cause: error,
30
+ });
31
+ }
32
+ };
33
+
34
+ const tunnelAuth = (purpose: string): Pick<ConnectConfig, "privateKey" | "passphrase" | "password"> => {
27
35
  const keyPath = tunnelEnv.get("SSH_TUNNEL_PRIVATE_KEY_PATH");
28
36
  const passphrase = tunnelEnv.get("SSH_TUNNEL_PASSPHRASE");
29
- if (keyPath) return { privateKey: readFileSync(keyPath), ...(passphrase ? { passphrase } : {}) };
37
+ if (keyPath) return { privateKey: readTunnelKey(purpose, keyPath), ...(passphrase ? { passphrase } : {}) };
30
38
  if (process.env.SSH_TUNNEL_PASSWORD) return { password: process.env.SSH_TUNNEL_PASSWORD };
31
- app.logger.warn(
32
- "The SSH tunnel uses the default shared credential. " +
33
- "Set SSH_TUNNEL_PRIVATE_KEY_PATH to a key (or SSH_TUNNEL_PASSWORD) once the cluster's tunnel endpoint accepts it.",
39
+ throw new Error(
40
+ `${purpose} needs an SSH credential: export SSH_TUNNEL_PRIVATE_KEY_PATH (with SSH_TUNNEL_PASSPHRASE if the key has one) in the shell, or set SSH_TUNNEL_PASSWORD.`,
34
41
  );
35
- return { password: repoName };
36
42
  };
37
43
 
38
44
  const tunnelHostVerifier = (app: AppExecutor, hostId: string, onRefusal: (reason: string) => void) => {
@@ -75,7 +81,8 @@ export const createTunnel = async (
75
81
  const baseDevEnv = WorkspaceExecutor.getBaseDevEnv();
76
82
  WorkspaceExecutor.assertDeployableEnv(baseDevEnv, environment, `The ${service} tunnel`);
77
83
  for (const line of tunnelEnv.ignored()) app.logger.warn(line);
78
- const { serveDomain, repoName } = baseDevEnv;
84
+ const auth = tunnelAuth(`The ${service} tunnel for ${app.name}-${environment}`);
85
+ const { serveDomain } = baseDevEnv;
79
86
  const host = `${app.name}-${environment}.${serveDomain}`;
80
87
  //? RFC 6761 makes *.localhost loopback, but only macOS resolves it; glibc without systemd-resolved and Windows answer ENOTFOUND
81
88
  const sshHost = host.endsWith(".localhost") ? "localhost" : host;
@@ -101,7 +108,7 @@ export const createTunnel = async (
101
108
  host: sshHost,
102
109
  port: sshPort,
103
110
  username: process.env.SSH_TUNNEL_USERNAME ?? "root",
104
- ...tunnelAuth(app, repoName),
111
+ ...auth,
105
112
  hostVerifier: tunnelHostVerifier(app, `${sshHost}:${sshPort}`, (reason) => {
106
113
  refusal = reason;
107
114
  }),
@@ -1,3 +1,4 @@
1
+ /** @deprecated Nothing in akanjs uses it; removed in a later minor. */
1
2
  export class FileEditor {
2
3
  #filePath: string;
3
4
  #content: string;
@@ -1,6 +1,7 @@
1
1
  import { readdirSync } from "node:fs";
2
2
  import { select } from "@inquirer/prompts";
3
3
 
4
+ /** @deprecated Nothing in akanjs uses it; removed in a later minor. */
4
5
  export const selectModel = async (modulePath: string) => {
5
6
  const modelNames = readdirSync(`${modulePath}/lib`).filter((dir) => !dir.includes(".") && !dir.startsWith("_"));
6
7
  return await select({