@akanjs/devkit 3.3.0-rc.4 → 3.3.0-rc.41

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 (252) hide show
  1. package/CHANGELOG.md +628 -0
  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/akanApp/akanApp.host.ts +11 -0
  7. package/akanConfig/akanBin.ts +4 -0
  8. package/akanConfig/akanConfig.test.ts +66 -7
  9. package/akanConfig/akanConfig.ts +53 -204
  10. package/akanConfig/akanWorkers.test.ts +39 -0
  11. package/akanConfig/akanWorkers.ts +32 -0
  12. package/akanConfig/desktopServerConfig.ts +96 -0
  13. package/akanConfig/dockerImage.ts +37 -0
  14. package/akanConfig/nativeKeys.ts +52 -0
  15. package/akanConfig/types.ts +1 -0
  16. package/app/appBin.test.ts +63 -0
  17. package/app/appBin.ts +50 -0
  18. package/app/applicationBuildReporter.test.ts +32 -0
  19. package/app/applicationBuildReporter.ts +4 -0
  20. package/app/applicationBuildRunner.test.ts +275 -0
  21. package/app/applicationBuildRunner.ts +133 -6
  22. package/app/dictionarySizes.ts +91 -0
  23. package/app/routeFilesReport.test.ts +59 -0
  24. package/app/routeFilesReport.ts +46 -0
  25. package/app/routeJsBudget.ts +18 -4
  26. package/artifact/implicitRootLayout.test.ts +19 -0
  27. package/artifact/implicitRootLayout.ts +16 -2
  28. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  29. package/artifact/storeBootstrap.test.ts +28 -0
  30. package/artifact/storeBootstrap.ts +64 -8
  31. package/biome.base.json +6 -4
  32. package/codeAgent/agent/CodeAgent.ts +36 -16
  33. package/codeAgent/agent/CodeAgentAllowed.ts +35 -0
  34. package/codeAgent/agent/CodeAgentCommandLine.ts +372 -0
  35. package/codeAgent/agent/CodeAgentGate.ts +23 -4
  36. package/codeAgent/agent/CodeAgentRpcHost.ts +1 -1
  37. package/codeAgent/agent/codeAgent.test.ts +62 -0
  38. package/codeAgent/agent/codeAgentCommandLine.test.ts +212 -0
  39. package/codeAgent/agent/codeAgentContract.test.ts +117 -5
  40. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  41. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  42. package/codeAgent/skills/akan-deps/SKILL.md +3 -2
  43. package/codeAgent/skills/akan-err/SKILL.md +13 -8
  44. package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
  45. package/codeAgent/skills/akan-module/SKILL.md +2 -2
  46. package/codeAgent/skills/akan-page/SKILL.md +31 -20
  47. package/codeAgent/skills/akan-query/SKILL.md +13 -20
  48. package/codeAgent/skills/akan-runtime/SKILL.md +20 -0
  49. package/codeAgent/skills/akan-service/SKILL.md +2 -5
  50. package/codeAgent/skills/akan-transport/SKILL.md +5 -14
  51. package/codeAgent/skills/akan-ui/SKILL.md +2 -5
  52. package/context/akanContext.ts +2 -0
  53. package/docs/apiReference.test.ts +9 -0
  54. package/docs/apiReference.ts +14 -0
  55. package/executors/appExecutor.ts +3 -1
  56. package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
  57. package/executors/clientRuntimeKeys.fixture.json +393 -0
  58. package/executors/clientRuntimeKeys.test.ts +1690 -0
  59. package/executors/executors.test.ts +2 -0
  60. package/executors/sysExecutor.ts +70 -4
  61. package/executors/workspaceExecutor.ts +7 -4
  62. package/frontendBuild/allRoutesBuilder.ts +88 -7
  63. package/frontendBuild/autoImportSync.ts +3 -2
  64. package/frontendBuild/buildRouteClient.test.ts +666 -12
  65. package/frontendBuild/clientBuildTypes.ts +26 -0
  66. package/frontendBuild/clientEntriesBundler.ts +49 -1
  67. package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
  68. package/frontendBuild/clientEntryDiscovery.ts +135 -13
  69. package/frontendBuild/clientEntryGroups.test.ts +77 -0
  70. package/frontendBuild/clientEntryGroups.ts +61 -0
  71. package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
  72. package/frontendBuild/csrDevModuleCompiler.ts +44 -8
  73. package/frontendBuild/csrDevPatcher.ts +33 -7
  74. package/frontendBuild/csrDevTypes.ts +9 -0
  75. package/frontendBuild/devBarrelImports.test.ts +154 -0
  76. package/frontendBuild/devBarrelImports.ts +83 -23
  77. package/frontendBuild/devRegistryBundler.ts +4 -2
  78. package/frontendBuild/devRouteRuntime.test.ts +492 -0
  79. package/frontendBuild/devRouteRuntime.ts +167 -0
  80. package/frontendBuild/dictionaryAssetBuilder.test.ts +324 -0
  81. package/frontendBuild/dictionaryAssetBuilder.ts +165 -16
  82. package/frontendBuild/dictionaryConstants.ts +136 -0
  83. package/frontendBuild/dictionaryPacking.test.ts +142 -0
  84. package/frontendBuild/dictionaryPacking.ts +135 -0
  85. package/frontendBuild/dictionaryRoutes.test.ts +251 -0
  86. package/frontendBuild/dictionaryRoutes.ts +227 -0
  87. package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
  88. package/frontendBuild/pagesBundleBuilder.ts +81 -3
  89. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  90. package/frontendBuild/precompressArtifacts.ts +22 -8
  91. package/frontendBuild/registryMetadataFingerprint.ts +3 -3
  92. package/frontendBuild/renderedEntries.ts +144 -0
  93. package/frontendBuild/routeClientBuilder.ts +405 -43
  94. package/frontendBuild/routeHandoffs.test.ts +155 -0
  95. package/frontendBuild/routeHandoffs.ts +117 -0
  96. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  97. package/frontendBuild/routeModulePreloads.ts +20 -11
  98. package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
  99. package/frontendBuild/routeRuntimeCheck.ts +248 -0
  100. package/frontendBuild/routeRuntimePays.test.ts +143 -0
  101. package/frontendBuild/routeRuntimePays.ts +117 -0
  102. package/frontendBuild/rscServerRendererGuard.test.ts +60 -0
  103. package/frontendBuild/rscServerRendererGuard.ts +68 -0
  104. package/frontendBuild/ssrBaseArtifactBuilder.ts +24 -34
  105. package/frontendBuild/ssrDevBundler.test.ts +150 -1
  106. package/frontendBuild/ssrDevBundler.ts +66 -11
  107. package/frontendBuild/vendorFileImports.test.ts +254 -0
  108. package/frontendBuild/vendorFileImports.ts +163 -0
  109. package/frontendBuild/vendorNarrowing.ts +28 -0
  110. package/frontendBuild/vendorSpecifiers.ts +2 -0
  111. package/incrementalBuilder/buildBatch.proc.ts +9 -9
  112. package/incrementalBuilder/buildBatchProtocol.ts +1 -1
  113. package/incrementalBuilder/builderBoot.ts +5 -5
  114. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  115. package/incrementalBuilder/builderLanes.ts +2 -2
  116. package/incrementalBuilder/builderWatch.ts +8 -8
  117. package/incrementalBuilder/csrRegistry.ts +4 -4
  118. package/incrementalBuilder/incrementalBuilder.proc.test.ts +79 -0
  119. package/incrementalBuilder/incrementalBuilder.proc.ts +27 -8
  120. package/incrementalBuilder/ssrRegistry.ts +6 -6
  121. package/index.ts +1 -1
  122. package/integration/renderAdmissionSoak.test.ts +99 -0
  123. package/integration/renderAdmissionSoak.ts +609 -0
  124. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  125. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  126. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  127. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  128. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  129. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  130. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  131. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  132. package/lint/biomeBase.test.ts +23 -3
  133. package/lint/biomeCheck.test.ts +145 -0
  134. package/lint/biomeCheck.ts +131 -0
  135. package/lint/no-arbitrary-color.grit +5 -0
  136. package/lint/no-conditional-st-hook.grit +5 -1
  137. package/lint/no-daisyui-legacy-class.grit +8 -0
  138. package/lint/no-document-cookie.grit +3 -0
  139. package/lint/no-inline-color.grit +10 -2
  140. package/lint/no-oversized-list-limit.grit +2 -0
  141. package/lint/no-raw-palette-class.grit +7 -0
  142. package/lint/no-unpublished-form-setter.grit +2 -0
  143. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  144. package/lint/no-web-storage.grit +3 -0
  145. package/lint/withheldEnvFile.ts +17 -0
  146. package/mobile/desktopBin.ts +2 -2
  147. package/mobile/desktopServerStage.ts +1 -0
  148. package/mobile/nativeApp.test.ts +7 -5
  149. package/mobile/nativeApp.ts +2 -2
  150. package/mobile/nativeConfig.test.ts +96 -1
  151. package/mobile/nativeConfig.ts +46 -12
  152. package/mobile/serverBundleSecrets.ts +43 -0
  153. package/package.json +15 -169
  154. package/packageExports.test.ts +38 -24
  155. package/quality/dictionaryKeys.test.ts +356 -0
  156. package/quality/dictionaryKeys.ts +488 -0
  157. package/quality/objectImportReport.test.ts +36 -0
  158. package/quality/objectImportReport.ts +105 -0
  159. package/quality/qualityScanner.ts +1 -1
  160. package/quality/routeRuntimeReport.test.ts +91 -0
  161. package/quality/routeRuntimeReport.ts +121 -0
  162. package/quality/runtimeConstantFacts.ts +71 -0
  163. package/quality/runtimeConstantGraph.ts +123 -0
  164. package/quality/runtimeConstantReads.ts +116 -0
  165. package/quality/runtimeImports.test.ts +190 -0
  166. package/quality/runtimeImports.ts +233 -0
  167. package/quality/runtimeKeyNames.ts +46 -0
  168. package/quality/runtimeLexicalScope.ts +132 -0
  169. package/quality/runtimeMarkerReach.test.ts +84 -0
  170. package/quality/runtimeMarkerReach.ts +255 -0
  171. package/quality/runtimeModuleFacts.ts +290 -0
  172. package/quality/runtimeNameTable.test.ts +172 -0
  173. package/quality/runtimeNameTable.ts +477 -0
  174. package/quality/runtimeScopeReport.test.ts +123 -0
  175. package/quality/runtimeScopeReport.ts +167 -0
  176. package/quality/runtimeSliceKey.ts +269 -0
  177. package/quality/runtimeSyntax.ts +133 -0
  178. package/quality/runtimeTable.fixture.ts +189 -0
  179. package/quality/runtimeUse.test.ts +737 -0
  180. package/quality/runtimeUse.ts +696 -0
  181. package/quality/runtimeUseReadable.test.ts +393 -0
  182. package/quality/ssrScanner.test.ts +13 -0
  183. package/quality/ssrScanner.ts +1 -1
  184. package/quality/translatorBindings.ts +187 -0
  185. package/test/secretEnvFixture.ts +134 -0
  186. package/test/testHelpers.ts +11 -0
  187. package/transforms/barrelAnalyzer.ts +26 -4
  188. package/transforms/barrelImportsPlugin.ts +121 -32
  189. package/transforms/exportReach.test.ts +162 -0
  190. package/transforms/exportReach.ts +308 -0
  191. package/transforms/frameworkObjects.fixture.tsx +58 -0
  192. package/transforms/frameworkObjects.test.ts +54 -0
  193. package/transforms/modelReference.test.ts +196 -0
  194. package/transforms/modelReference.ts +39 -0
  195. package/transforms/moduleParts.test.ts +225 -0
  196. package/transforms/moduleParts.ts +418 -0
  197. package/transforms/objectImportEdits.ts +150 -0
  198. package/transforms/objectMemberImports.test.ts +629 -0
  199. package/transforms/objectMemberImports.ts +571 -0
  200. package/transforms/objectMemberLookup.ts +150 -0
  201. package/transforms/objectModule.test.ts +307 -0
  202. package/transforms/objectModule.ts +482 -0
  203. package/transforms/objectModuleAnalyzer.ts +104 -0
  204. package/transforms/partImports.test.ts +76 -0
  205. package/transforms/partImports.ts +110 -0
  206. package/transforms/partModules.test.ts +187 -0
  207. package/transforms/partModules.ts +90 -0
  208. package/transforms/partPurity.ts +124 -0
  209. package/transforms/reactIconImports.test.ts +231 -0
  210. package/transforms/reactIconImports.ts +325 -0
  211. package/transforms/routeConstants.ts +122 -0
  212. package/transforms/routeRuntime.test.ts +835 -0
  213. package/transforms/routeRuntime.ts +703 -0
  214. package/transforms/routeRuntimeEdits.ts +92 -0
  215. package/transforms/routeRuntimeGraph.ts +66 -0
  216. package/transforms/routeRuntimePlan.ts +244 -0
  217. package/transforms/secretEnvDeclaration.test.ts +208 -0
  218. package/transforms/secretEnvDeclaration.ts +213 -0
  219. package/transforms/secretEnvFile.test.ts +117 -0
  220. package/transforms/secretEnvFile.ts +113 -0
  221. package/transforms/secretEnvName.test.ts +54 -0
  222. package/transforms/secretEnvName.ts +29 -0
  223. package/transforms/secretEnvSource.test.ts +148 -0
  224. package/transforms/secretEnvSource.ts +166 -0
  225. package/transforms/serverEnvEvaluationError.ts +11 -0
  226. package/transforms/serverEnvPlugin.test.ts +2 -1
  227. package/transforms/serverEnvPlugin.ts +13 -0
  228. package/transforms/serverEnvProfile.test.ts +115 -2
  229. package/transforms/serverEnvProfile.ts +117 -40
  230. package/transforms/serverEnvSecrets.test.ts +292 -0
  231. package/transforms/signalDescriptors.test.ts +280 -0
  232. package/transforms/signalDescriptors.ts +227 -0
  233. package/transforms/thisFreeExports.ts +87 -0
  234. package/transforms/transforms.test.ts +180 -3
  235. package/transforms/tsconfigPackageResolver.test.ts +1 -0
  236. package/tunnel/createTunnel.test.ts +29 -8
  237. package/tunnel/createTunnel.ts +18 -11
  238. package/typecheck/projectTypecheck.test.ts +29 -0
  239. package/typecheck/typeChecker.test.ts +49 -0
  240. package/typecheck/typeChecker.ts +9 -7
  241. package/typecheck/withheldDiagnostics.ts +41 -0
  242. package/util/fileEditor.ts +1 -0
  243. package/util/selectModel.ts +1 -0
  244. package/workflow/executor.ts +6 -2
  245. package/workflow/index.ts +1 -0
  246. package/workflow/plan.ts +36 -7
  247. package/workflow/types.ts +1 -1
  248. package/workflow/uiTarget.ts +50 -0
  249. package/workspace/getRelatedCnsts.ts +7 -0
  250. package/workspace/scanInfo.test.ts +39 -0
  251. package/workspace/scanInfo.ts +48 -5
  252. package/workspace/workspaceLayout.ts +1 -0
@@ -0,0 +1,150 @@
1
+ import type ts from "typescript";
2
+ import type { ObjectKeepReason } from "./objectMemberImports";
3
+
4
+ export interface ObjectImportCandidate {
5
+ declaration: ts.ImportDeclaration;
6
+ element: ts.ImportSpecifier;
7
+ local: string;
8
+ imported: string;
9
+ file?: string;
10
+ shadowed: boolean;
11
+ typeUse: boolean;
12
+ keep: { reason: ObjectKeepReason; node: ts.Node } | null;
13
+ paths: { path: string[]; nodes: ts.Expression[]; called: boolean }[];
14
+ destructures: { node: ts.Identifier; keys: string[] }[];
15
+ }
16
+
17
+ export interface ObjectMemberTarget {
18
+ file: string;
19
+ bare: string | null;
20
+ imported: string;
21
+ depth: 1 | 2;
22
+ }
23
+
24
+ export interface ObjectMemberUse {
25
+ member: string;
26
+ written: string;
27
+ target: ObjectMemberTarget;
28
+ nodes: ts.Node[];
29
+ }
30
+
31
+ interface Edit {
32
+ start: number;
33
+ end: number;
34
+ text: string;
35
+ }
36
+
37
+ const IDENTIFIER_RE = /^[A-Za-z_$][\w$]*$/;
38
+ const escapeRe = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39
+
40
+ export class ObjectImportEdits {
41
+ readonly #source: string;
42
+ readonly #sourceFile: ts.SourceFile;
43
+ readonly #keepLines: boolean;
44
+ readonly #edits: Edit[] = [];
45
+ readonly #declarations = new Map<ts.ImportDeclaration, { dropped: Set<ts.ImportSpecifier>; added: string[] }>();
46
+ readonly #taken = new Set<string>();
47
+
48
+ constructor(source: string, sourceFile: ts.SourceFile, keepLines: boolean) {
49
+ this.#source = source;
50
+ this.#sourceFile = sourceFile;
51
+ this.#keepLines = keepLines;
52
+ }
53
+
54
+ narrow(
55
+ candidate: ObjectImportCandidate,
56
+ uses: ObjectMemberUse[],
57
+ specifierOf: (target: ObjectMemberTarget) => string,
58
+ ) {
59
+ const locals = new Map<string, string>();
60
+ const named = new Map<string, string[]>();
61
+ const namespaces: string[] = [];
62
+ const localOf = (member: string, target: ObjectMemberTarget) => {
63
+ const key = `${target.file}\0${target.imported}`;
64
+ let local = locals.get(key);
65
+ if (local) return local;
66
+ local = this.#allocate([candidate.local, ...member.split(".")]);
67
+ locals.set(key, local);
68
+ const specifier = JSON.stringify(specifierOf(target));
69
+ if (target.imported === "*") namespaces.push(`import * as ${local} from ${specifier};`);
70
+ else named.set(specifier, [...(named.get(specifier) ?? []), `${target.imported} as ${local}`]);
71
+ return local;
72
+ };
73
+ const destructured = new Map<ts.Node, string[]>();
74
+ for (const { member, target, nodes } of uses) {
75
+ const local = localOf(member, target);
76
+ const node = nodes[target.depth - 1] ?? nodes[0];
77
+ if (!node) continue;
78
+ if (node.kind === candidate.element.name.kind) {
79
+ const key = member.split(".")[0] ?? member;
80
+ const entry = `${IDENTIFIER_RE.test(key) ? key : JSON.stringify(key)}: ${local}`;
81
+ destructured.set(node, [...(destructured.get(node) ?? []), entry]);
82
+ continue;
83
+ }
84
+ this.#replace(node, local);
85
+ }
86
+ for (const [node, entries] of destructured) this.#replace(node, `{ ${[...new Set(entries)].join(", ")} }`);
87
+ const declaration = this.#declarations.get(candidate.declaration) ?? { dropped: new Set(), added: [] };
88
+ declaration.dropped.add(candidate.element);
89
+ const specifier = candidate.declaration.moduleSpecifier.getText(this.#sourceFile);
90
+ if (candidate.typeUse)
91
+ declaration.added.push(`import type { ${candidate.element.getText(this.#sourceFile)} } from ${specifier};`);
92
+ for (const [from, items] of named) declaration.added.push(`import { ${items.join(", ")} } from ${from};`);
93
+ declaration.added.push(...namespaces);
94
+ this.#declarations.set(candidate.declaration, declaration);
95
+ }
96
+
97
+ apply(): string | null {
98
+ for (const [declaration, { dropped, added }] of this.#declarations)
99
+ this.#edits.push({
100
+ start: declaration.getStart(this.#sourceFile),
101
+ end: declaration.end,
102
+ text: this.#join([...this.#remainingOf(declaration, dropped), ...added], declaration),
103
+ });
104
+ if (this.#edits.length === 0) return null;
105
+ let out = this.#source;
106
+ for (const edit of [...this.#edits].sort((a, b) => b.start - a.start))
107
+ out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
108
+ return out;
109
+ }
110
+
111
+ #remainingOf(declaration: ts.ImportDeclaration, dropped: Set<ts.ImportSpecifier>): string[] {
112
+ const clause = declaration.importClause;
113
+ const bindings = clause?.namedBindings;
114
+ const kept =
115
+ bindings && "elements" in bindings
116
+ ? bindings.elements
117
+ .filter((element) => !dropped.has(element))
118
+ .map((element) => element.getText(this.#sourceFile))
119
+ : [];
120
+ const parts = [...(clause?.name ? [clause.name.text] : []), ...(kept.length > 0 ? [`{ ${kept.join(", ")} }`] : [])];
121
+ if (parts.length === 0) return [];
122
+ return [`import ${parts.join(", ")} from ${declaration.moduleSpecifier.getText(this.#sourceFile)};`];
123
+ }
124
+
125
+ #join(lines: string[], node: ts.Node) {
126
+ if (!this.#keepLines) return lines.join("\n");
127
+ return `${lines.join(" ")}${"\n".repeat(this.#newlinesOf(node))}`;
128
+ }
129
+
130
+ #replace(node: ts.Node, text: string) {
131
+ const padding = this.#keepLines ? "\n".repeat(this.#newlinesOf(node)) : "";
132
+ this.#edits.push({ start: node.getStart(this.#sourceFile), end: node.end, text: `${text}${padding}` });
133
+ }
134
+
135
+ #newlinesOf(node: ts.Node) {
136
+ return this.#source.slice(node.getStart(this.#sourceFile), node.end).split("\n").length - 1;
137
+ }
138
+
139
+ #allocate(parts: string[]) {
140
+ const base = `${/^[a-z]/.test(parts[0] ?? "") ? "$" : ""}${parts.join("$")}`;
141
+ let name = base;
142
+ for (let n = 1; this.#taken.has(name) || this.#appears(name); n++) name = `${base}$${n}`;
143
+ this.#taken.add(name);
144
+ return name;
145
+ }
146
+
147
+ #appears(name: string) {
148
+ return new RegExp(`(?<![\\w$])${escapeRe(name)}(?![\\w$])`).test(this.#source);
149
+ }
150
+ }