@akanjs/devkit 3.3.0-rc.2 → 3.3.0-rc.20

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 (111) hide show
  1. package/CHANGELOG.md +284 -20
  2. package/DEV_RUNTIME_KNOBS.md +1 -1
  3. package/README.ko.md +3 -2
  4. package/README.md +3 -3
  5. package/akanApp/akanApp.host.test.ts +1 -1
  6. package/akanConfig/akanConfig.test.ts +57 -8
  7. package/akanConfig/akanConfig.ts +16 -69
  8. package/akanConfig/dockerImage.ts +17 -0
  9. package/akanConfig/nativeKeys.ts +52 -0
  10. package/app/applicationBuildRunner.test.ts +321 -1
  11. package/app/applicationBuildRunner.ts +90 -3
  12. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  13. package/codeAgent/agent/CodeAgent.ts +36 -16
  14. package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
  15. package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
  16. package/codeAgent/agent/CodeAgentGate.ts +23 -4
  17. package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
  18. package/codeAgent/agent/codeAgent.test.ts +62 -0
  19. package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
  20. package/codeAgent/agent/codeAgentContract.test.ts +117 -5
  21. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  22. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  23. package/codeAgent/skills/akan-err/SKILL.md +11 -2
  24. package/codeAgent/skills/akan-page/SKILL.md +21 -26
  25. package/codeAgent/skills/akan-runtime/SKILL.md +41 -16
  26. package/codeAgent/skills/akan-service/SKILL.md +2 -2
  27. package/docs/apiReference.test.ts +14 -0
  28. package/docs/apiReference.ts +21 -3
  29. package/docs/declarationReader.ts +28 -1
  30. package/executors/appExecutor.ts +16 -7
  31. package/executors/workspaceExecutor.ts +7 -4
  32. package/frontendBuild/buildRouteClient.test.ts +2 -7
  33. package/frontendBuild/clientEntryDiscovery.test.ts +35 -0
  34. package/frontendBuild/clientEntryDiscovery.ts +16 -3
  35. package/frontendBuild/cssCompiler.test.ts +112 -0
  36. package/frontendBuild/cssCompiler.ts +41 -21
  37. package/frontendBuild/devBarrelImports.test.ts +30 -0
  38. package/frontendBuild/devBarrelImports.ts +2 -2
  39. package/frontendBuild/pagesBundleBuilder.ts +3 -1
  40. package/frontendBuild/plainStylesheet.test.ts +155 -0
  41. package/frontendBuild/plainStylesheet.ts +197 -0
  42. package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
  43. package/frontendBuild/rscServerRendererGuard.ts +68 -0
  44. package/guideline/agentAssets.test.ts +10 -0
  45. package/guideline/agentAssets.ts +52 -11
  46. package/incrementalBuilder/buildBatch.proc.ts +9 -9
  47. package/incrementalBuilder/buildBatchProtocol.ts +1 -1
  48. package/incrementalBuilder/builderBoot.ts +5 -5
  49. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  50. package/incrementalBuilder/builderLanes.ts +2 -2
  51. package/incrementalBuilder/builderWatch.ts +8 -8
  52. package/incrementalBuilder/csrRegistry.ts +4 -4
  53. package/incrementalBuilder/incrementalBuilder.proc.ts +8 -8
  54. package/incrementalBuilder/ssrRegistry.ts +6 -6
  55. package/index.ts +1 -1
  56. package/integration/renderAdmissionSoak.test.ts +99 -0
  57. package/integration/renderAdmissionSoak.ts +609 -0
  58. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  59. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  60. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  61. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  62. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  63. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  64. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  65. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  66. package/lint/biomeCheck.test.ts +145 -0
  67. package/lint/biomeCheck.ts +131 -0
  68. package/lint/no-arbitrary-color.grit +5 -0
  69. package/lint/no-conditional-st-hook.grit +5 -1
  70. package/lint/no-daisyui-legacy-class.grit +8 -0
  71. package/lint/no-document-cookie.grit +3 -0
  72. package/lint/no-inline-color.grit +10 -2
  73. package/lint/no-oversized-list-limit.grit +2 -0
  74. package/lint/no-raw-palette-class.grit +7 -0
  75. package/lint/no-unpublished-form-setter.grit +2 -0
  76. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  77. package/lint/no-web-storage.grit +3 -0
  78. package/lint/withheldEnvFile.ts +17 -0
  79. package/mobile/nativeApp.test.ts +7 -5
  80. package/mobile/nativeApp.ts +2 -2
  81. package/mobile/nativeConfig.test.ts +117 -1
  82. package/mobile/nativeConfig.ts +66 -22
  83. package/mobile/serverBundleSecrets.ts +43 -0
  84. package/package.json +14 -169
  85. package/packageExports.test.ts +38 -24
  86. package/test/secretEnvFixture.ts +134 -0
  87. package/transforms/barrelAnalyzer.ts +2 -2
  88. package/transforms/secretEnvDeclaration.test.ts +208 -0
  89. package/transforms/secretEnvDeclaration.ts +213 -0
  90. package/transforms/secretEnvFile.test.ts +117 -0
  91. package/transforms/secretEnvFile.ts +113 -0
  92. package/transforms/secretEnvName.test.ts +54 -0
  93. package/transforms/secretEnvName.ts +29 -0
  94. package/transforms/secretEnvSource.test.ts +148 -0
  95. package/transforms/secretEnvSource.ts +166 -0
  96. package/transforms/serverEnvEvaluationError.ts +11 -0
  97. package/transforms/serverEnvPlugin.test.ts +2 -1
  98. package/transforms/serverEnvPlugin.ts +13 -0
  99. package/transforms/serverEnvProfile.test.ts +115 -2
  100. package/transforms/serverEnvProfile.ts +117 -40
  101. package/transforms/serverEnvSecrets.test.ts +292 -0
  102. package/transforms/transforms.test.ts +3 -3
  103. package/tunnel/createTunnel.test.ts +29 -8
  104. package/tunnel/createTunnel.ts +18 -11
  105. package/typecheck/projectTypecheck.test.ts +29 -0
  106. package/typecheck/typeChecker.test.ts +49 -0
  107. package/typecheck/typeChecker.ts +9 -7
  108. package/typecheck/withheldDiagnostics.ts +41 -0
  109. package/util/fileEditor.ts +1 -0
  110. package/util/selectModel.ts +1 -0
  111. 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";
@@ -139,6 +142,7 @@ describe("NativeConfig.build", () => {
139
142
  googleServices: path.resolve("/repo/apps/minimal", "secrets/google-services.json"),
140
143
  },
141
144
  keyboard: { resize: "none" },
145
+ splash: { autoHide: false },
142
146
  });
143
147
  });
144
148
 
@@ -184,7 +188,7 @@ describe("NativeConfig.build", () => {
184
188
  android: { debugAppIdSuffix: ".debug" },
185
189
  keyboard: { resize: "none" },
186
190
  icon: path.resolve("/repo/apps/portal", "assets/icon.png"),
187
- splash: { image: path.resolve("/repo/apps/portal", "assets/splash.png") },
191
+ splash: { image: path.resolve("/repo/apps/portal", "assets/splash.png"), autoHide: false },
188
192
  });
189
193
  });
190
194
 
@@ -303,6 +307,21 @@ describe("NativeConfig.build", () => {
303
307
  expect(build()).toBeUndefined();
304
308
  });
305
309
 
310
+ test("the runtime hides the splash once the first page is drawn, unless the app hands that back to the shell", () => {
311
+ const splashOf = (splash: Parameters<typeof NativeConfig.build>[0]["target"]["splash"]) =>
312
+ NativeConfig.build({
313
+ appPath: "/repo/apps/portal",
314
+ target: { ...adminTarget, splash },
315
+ webDir: "/web",
316
+ contributions: [],
317
+ locales: ["en"],
318
+ platform: "ios",
319
+ }).config.splash;
320
+ expect(splashOf(undefined)).toEqual({ autoHide: false });
321
+ expect(splashOf({ autoHide: true, timeout: 3000 })).toEqual({ autoHide: true, timeout: 3000 });
322
+ expect(NativeConfig.basePlugins).toContain("splash-screen");
323
+ });
324
+
306
325
  test("push, privacy and the icon and splash objects reach the runtime, paths from the app folder", () => {
307
326
  const { config } = NativeConfig.build({
308
327
  appPath: "/repo/apps/portal",
@@ -484,6 +503,27 @@ describe("NativeConfig.build", () => {
484
503
  expect((await NativeApi.load(repoApp)).validateConfig(config, { appDir: root })).toEqual([]);
485
504
  });
486
505
 
506
+ test("ios.hideFormAccessoryBar reaches the iOS shell, and the runtime accepts it; left out, the bar stays", async () => {
507
+ const root = await makeTempRoot();
508
+ const build = (ios?: { hideFormAccessoryBar?: boolean }) =>
509
+ NativeConfig.build({
510
+ appPath: root,
511
+ target: { ...minimalTarget, permissions: [], deepLinks: undefined, android: undefined, ios },
512
+ webDir: path.join(root, "web"),
513
+ contributions: [],
514
+ locales: ["en"],
515
+ platform: "ios",
516
+ }).config;
517
+ const config = build({ hideFormAccessoryBar: true });
518
+
519
+ expect(config.ios).toEqual({ hideFormAccessoryBar: true });
520
+ expect(build().ios).toBeUndefined();
521
+ expect(build({ hideFormAccessoryBar: false }).ios).toBeUndefined();
522
+ await mkdir(path.join(root, "web"), { recursive: true });
523
+ await writeFile(path.join(root, "web/index.html"), "<html><head></head><body></body></html>");
524
+ expect((await NativeApi.load(repoApp)).validateConfig(config, { appDir: root })).toEqual([]);
525
+ });
526
+
487
527
  test("an app with updates ships the updates plugin and its settings", () => {
488
528
  const updates = { url: "https://releases.example.com/board", publicKey: `${"a".repeat(43)}=`, channel: "pilot" };
489
529
  const { config } = NativeConfig.build({
@@ -697,6 +737,82 @@ describe("NativeConfig.build", () => {
697
737
  expect(opener(["*"])).toBe("opener:default");
698
738
  });
699
739
 
740
+ test("an external view opens only the origins native.desktop.externalView lists, and evaluates or types only when it says so", () => {
741
+ const externalView = (setting?: NonNullable<AkanNativeTarget["desktop"]>["externalView"]) => {
742
+ const { config, warnings } = NativeConfig.build({
743
+ appPath: "/repo/apps/minimal",
744
+ target: {
745
+ ...minimalTarget,
746
+ plugins: ["external-view"],
747
+ ...(setting ? { desktop: { externalView: setting } } : {}),
748
+ },
749
+ webDir: "/web",
750
+ contributions: [],
751
+ locales: ["en"],
752
+ platform: "windows",
753
+ publicEnv: cloudEnv,
754
+ });
755
+ const permissions = config.capabilities?.[0]?.permissions.filter((p) =>
756
+ JSON.stringify(p).includes("external-view"),
757
+ );
758
+ const plugin = { spec: "external-view", dir: "/plugins/external-view", manifest: externalViewManifest as never };
759
+ const acl = resolveAcl([{ identifier: "app", permissions: permissions ?? [] }], [plugin], "windows");
760
+ return {
761
+ permissions,
762
+ warnings: warnings.filter((warning) => warning.includes("external-view")),
763
+ open: aclCheck(acl, "external-view", "open").scope?.allow,
764
+ evaluate: aclCheck(acl, "external-view", "evaluate").allowed,
765
+ sendKey: aclCheck(acl, "external-view", "sendKey").allowed,
766
+ };
767
+ };
768
+
769
+ expect(externalView()).toEqual({
770
+ permissions: [{ identifier: "external-view:default", allow: [] }],
771
+ warnings: [
772
+ "Native target 'default': external-view opens no origin until native.desktop.externalView.allowOrigins lists one.",
773
+ ],
774
+ open: [],
775
+ evaluate: false,
776
+ sendKey: false,
777
+ });
778
+ expect(
779
+ externalView({
780
+ allowOrigins: ["https://Board.example:443", "http://10.0.0.5:8080"],
781
+ evaluate: true,
782
+ sendKey: true,
783
+ }),
784
+ ).toEqual({
785
+ permissions: [
786
+ {
787
+ identifier: "external-view:default",
788
+ allow: [{ origin: "https://board.example" }, { origin: "http://10.0.0.5:8080" }],
789
+ },
790
+ "external-view:allow-evaluate",
791
+ "external-view:allow-sendKey",
792
+ ],
793
+ warnings: [],
794
+ open: [{ origin: "https://board.example" }, { origin: "http://10.0.0.5:8080" }],
795
+ evaluate: true,
796
+ sendKey: true,
797
+ });
798
+ expect(externalView({ allowOrigins: ["https://b\u00fccher.example"], sendKey: true })).toMatchObject({
799
+ open: [{ origin: "https://xn--bcher-kva.example" }],
800
+ evaluate: false,
801
+ sendKey: true,
802
+ });
803
+ for (const origin of [
804
+ "https://board.example/screen",
805
+ "https://*.example",
806
+ "https://user@board.example",
807
+ "board.example",
808
+ "ftp://board.example",
809
+ "https://board.example?x=1",
810
+ ])
811
+ expect(() => externalView({ allowOrigins: [origin] })).toThrow(
812
+ `native.desktop.externalView.allowOrigins holds "${origin}", which is not an exact http(s) origin`,
813
+ );
814
+ });
815
+
700
816
  test("keeps a file name the runtime accepts", () => {
701
817
  expect(NativeConfig.fileNameOf("minimal")).toBe("minimal");
702
818
  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";
@@ -46,8 +46,9 @@ export interface NativeConfigResult {
46
46
  type NativeIos = NonNullable<NonNullable<AkanNativeConfig["native"]>["ios"]>;
47
47
 
48
48
  export class NativeConfig {
49
- //* What every akanjs page may call: routing, lifecycle, links, storage, the device facts the runtime reads, and the
50
- //* system sheet useCamera asks camera-or-library with.
49
+ //* What every akanjs page may call: routing, lifecycle, links, storage, the device facts the runtime reads, the
50
+ //* system sheet useCamera asks camera-or-library with, and the splash the CSR runtime hides once the first page is
51
+ //* drawn.
51
52
  static readonly basePlugins = [
52
53
  "app",
53
54
  "app-state",
@@ -60,6 +61,7 @@ export class NativeConfig {
60
61
  "preferences",
61
62
  "secure-storage",
62
63
  "haptics",
64
+ "splash-screen",
63
65
  ] as const;
64
66
  //? Only scripts stay strict ('self', inline ones by hash): injected script must not reach the native bridge.
65
67
  static readonly defaultCsp: Readonly<Record<string, readonly string[]>> = {
@@ -214,16 +216,7 @@ export class NativeConfig {
214
216
  const native = NativeConfig.#compact({ ios, macos, android, resources });
215
217
  const googleServices = target.android?.googleServices;
216
218
  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
- });
219
+ const desktop = NativeConfig.#desktop(target.desktop, desktopServer, desktopBin, abs);
227
220
  const background = target.backgroundColor;
228
221
  const shell = NativeConfig.#compact<NonNullable<AkanNativeConfig["shell"]>>({
229
222
  backgroundColor: typeof background === "string" ? background : background?.light,
@@ -248,11 +241,7 @@ export class NativeConfig {
248
241
  {
249
242
  identifier: "app",
250
243
  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
- ),
244
+ permissions: NativeConfig.#permissions(pluginIds, target, openUrls, warnings),
256
245
  },
257
246
  ],
258
247
  ...(csp ? { security: { csp } } : {}),
@@ -270,6 +259,7 @@ export class NativeConfig {
270
259
  }
271
260
  : {}),
272
261
  ...(target.ios?.privacy ? { privacy: target.ios.privacy } : {}),
262
+ ...(target.ios?.hideFormAccessoryBar ? { ios: { hideFormAccessoryBar: true } } : {}),
273
263
  //? assetlinks.json vouches for `<appId>.debug` outside main, the suffix a debug build installs under.
274
264
  android: {
275
265
  debugAppIdSuffix: ".debug",
@@ -279,7 +269,7 @@ export class NativeConfig {
279
269
  keyboard: { resize: "none" },
280
270
  ...(desktop ? { desktop } : {}),
281
271
  ...(target.icon ? { icon: NativeConfig.#icon(target.icon, abs) } : {}),
282
- ...(target.splash ? { splash: NativeConfig.#splash(target.splash, abs) } : {}),
272
+ splash: NativeConfig.#splash(target.splash, abs),
283
273
  ...(shell ? { shell } : {}),
284
274
  };
285
275
  return { config, warnings };
@@ -336,6 +326,39 @@ export class NativeConfig {
336
326
  return policy;
337
327
  }
338
328
 
329
+ static #permissions(pluginIds: string[], target: AkanNativeTarget, openUrls: readonly string[], warnings: string[]) {
330
+ return pluginIds.flatMap((id): (string | CapabilityPermission)[] => {
331
+ if (id === "opener" && !openUrls.includes("*"))
332
+ return [{ identifier: "opener:default", allow: openUrls.map((url) => ({ url })) }];
333
+ if (id === "external-view") return NativeConfig.#externalView(target, warnings);
334
+ return [`${id}:default`];
335
+ });
336
+ }
337
+
338
+ //? `external-view:default` alone opens no origin and leaves out evaluate and sendKey (the plugin's manifest).
339
+ static #externalView({ name, desktop }: AkanNativeTarget, warnings: string[]): (string | CapabilityPermission)[] {
340
+ const { allowOrigins = [], evaluate, sendKey } = desktop?.externalView ?? {};
341
+ const origins = allowOrigins.map((origin) => NativeConfig.#exactOrigin(name, origin));
342
+ if (!origins.length)
343
+ warnings.push(
344
+ `Native target '${name}': external-view opens no origin until native.desktop.externalView.allowOrigins lists one.`,
345
+ );
346
+ return [
347
+ { identifier: "external-view:default", allow: origins.map((origin) => ({ origin })) },
348
+ ...(evaluate ? ["external-view:allow-evaluate"] : []),
349
+ ...(sendKey ? ["external-view:allow-sendKey"] : []),
350
+ ];
351
+ }
352
+
353
+ static #exactOrigin(name: string, origin: string) {
354
+ const url = URL.canParse(origin) ? new URL(origin) : null;
355
+ if (!url || !/^https?:$/.test(url.protocol) || url.hostname.includes("*") || url.href !== `${url.origin}/`)
356
+ throw new Error(
357
+ `Native target '${name}': native.desktop.externalView.allowOrigins holds "${origin}", which is not an exact http(s) origin such as "https://board.example".`,
358
+ );
359
+ return url.origin;
360
+ }
361
+
339
362
  //? https: and wss: cover a cloud API, so only plain-http origins are named; a carried server's port comes at launch.
340
363
  static #plainOrigins(publicEnv: Record<string, string | undefined>, env: NativeEnv | undefined, carried: boolean) {
341
364
  const origins = new Set<string>();
@@ -355,12 +378,33 @@ export class NativeConfig {
355
378
  return typeof icon === "string" ? abs(icon) : { ...icon, image: abs(icon.image) };
356
379
  }
357
380
 
381
+ //? The shell's own hide fires when the document has loaded, before the CSR page is drawn; the runtime hides it then
382
+ //? (`NativeSplash`), so it stays off unless the app says otherwise.
358
383
  static #splash(
359
- splash: NonNullable<AkanNativeTarget["splash"]>,
384
+ splash: AkanNativeTarget["splash"],
360
385
  abs: (relative: string) => string,
361
386
  ): NonNullable<AkanNativeConfig["splash"]> {
362
- if (typeof splash === "string") return { image: abs(splash) };
363
- return { ...splash, ...(splash.image ? { image: abs(splash.image) } : {}) };
387
+ if (!splash) return { autoHide: false };
388
+ if (typeof splash === "string") return { image: abs(splash), autoHide: false };
389
+ return { autoHide: false, ...splash, ...(splash.image ? { image: abs(splash.image) } : {}) };
390
+ }
391
+
392
+ static #desktop(
393
+ desktop: AkanNativeTarget["desktop"],
394
+ server: DesktopServerBundle | undefined,
395
+ bin: string | undefined,
396
+ abs: (relative: string) => string,
397
+ ) {
398
+ return NativeConfig.#compact<NonNullable<AkanNativeConfig["desktop"]>>({
399
+ recovery: desktop?.recovery,
400
+ screenCapture: desktop?.screenCapture,
401
+ webview2: desktop?.webview2,
402
+ publisher: desktop?.publisher,
403
+ window: NativeConfig.#compact({ ...desktop?.window }),
404
+ server,
405
+ bin,
406
+ dmg: NativeConfig.#dmg(desktop?.dmg, abs),
407
+ });
364
408
  }
365
409
 
366
410
  static #dmg(dmg: AkanNativeDmgConfig | undefined, abs: (relative: string) => string) {
@@ -1,5 +1,6 @@
1
1
  import { readdir, readFile, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import type { SecretEnvMoved } from "../transforms/secretEnvDeclaration";
3
4
  import { ServerEnvProfile } from "../transforms/serverEnvProfile";
4
5
 
5
6
  interface SecretValue {
@@ -66,6 +67,48 @@ export class ServerBundleSecrets {
66
67
  return unread;
67
68
  }
68
69
 
70
+ //* An image's own check: the build left each secret string out at its key, and the same string may sit in what it
71
+ //* wrote for another reason. A long mixed one stops the build; a short or plain one, which code holds by chance
72
+ //* (a password equal to a database's name), comes back as a warning. Neither names a value.
73
+ async assertImageClean(bundleDir: string, moved: readonly SecretEnvMoved[]): Promise<string | null> {
74
+ //? A string under eight characters is in any bundle by chance, so it is not looked for: the env alone says
75
+ //? whether a key the build leaves as written holds it too.
76
+ const searched = (value: string) => value.length >= 8;
77
+ const sought = moved
78
+ .filter(({ value }) => searched(value))
79
+ .map((secret) => ({ secret, needles: ServerBundleSecrets.#needles(secret.value) }));
80
+ const holders = new Map<SecretEnvMoved, string[]>();
81
+ if (sought.length)
82
+ for (const bundled of await ServerBundleSecrets.#files(bundleDir)) {
83
+ const text = await readFile(bundled, "latin1");
84
+ for (const { secret, needles } of sought)
85
+ if (needles.some((needle) => text.includes(needle)))
86
+ holders.set(secret, [...(holders.get(secret) ?? []), ServerBundleSecrets.#relative(bundleDir, bundled)]);
87
+ }
88
+ const stops: string[] = [];
89
+ const notes: string[] = [];
90
+ for (const secret of moved) {
91
+ const files = holders.get(secret) ?? [];
92
+ const key = `${secret.path} (${secret.name})`;
93
+ const twins = secret.twins.length ? `the env's ${secret.twins.join(", ")}` : "";
94
+ if (files.length && ServerEnvProfile.distinctive(secret.value))
95
+ stops.push(
96
+ ...files.map((file) => `${file} holds the value of ${key}${twins ? `, which ${twins} holds as well` : ""}`),
97
+ );
98
+ else if (files.length || (twins && !searched(secret.value)))
99
+ notes.push(
100
+ `${key}: ${[files.join(", "), twins ? `${twins} holds the same string` : ""].filter(Boolean).join("; ")}`,
101
+ );
102
+ }
103
+ if (stops.length)
104
+ throw new Error(
105
+ `The build holds secret values the server reads from its process env, so it stops here:\n ${[...new Set(stops)].join("\n ")}\nThe build left each out at its secret-named key of the env file, and the same string is in what it wrote for another reason: another key of the env holds it too, or the app's code, or a file the build copies. Take it out there, or read it there from the same variable. \`akan build --inline-secrets\` builds with the env files as written until akanjs 3.5.0 removes it.`,
106
+ );
107
+ if (!notes.length) return null;
108
+ const lines = [...new Set(notes)];
109
+ return `${lines.length} secret value${lines.length === 1 ? "" : "s"} the server reads from its process env ${lines.length === 1 ? "is" : "are"} also in what this build wrote, short or plain enough to be there for another reason, so the build goes on:\n ${lines.join("\n ")}\nWhere another key of the env or the app's code holds a secret's own string, the image holds it too: change one of the two.`;
110
+ }
111
+
69
112
  //? A short or plain value the app's or a lib's own code holds as well (a default password) is that code's, which
70
113
  //? the bundle carries with or without the env file; a long mixed one is a secret copied into the code.
71
114
  async #coded(values: string[]): Promise<Set<string>> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/devkit",
3
- "version": "3.3.0-rc.2",
3
+ "version": "3.3.0-rc.20",
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.2",
53
+ "@akanjs/language": "3.3.0-rc.20",
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.2",
62
+ "akanjs": "3.3.0-rc.20",
218
63
  "chalk": "^6.0.1",
219
64
  "commander": "^15.0.0",
220
65
  "dayjs": "^1.11.23",