@akanjs/devkit 3.2.0-rc.9 → 3.2.1-rc.0

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 (353) hide show
  1. package/CHANGELOG.md +0 -529
  2. package/DEV_RUNTIME_KNOBS.md +4 -3
  3. package/README.ko.md +3 -2
  4. package/README.md +4 -2
  5. package/akanApp/BackendImportGraph.test.ts +1 -1
  6. package/akanApp/akanApp.host.test.ts +152 -6
  7. package/akanApp/akanApp.host.ts +187 -1220
  8. package/akanApp/akanApp.host.wiring.test.ts +931 -0
  9. package/akanApp/builderGap.ts +68 -0
  10. package/akanApp/builderRequestRelay.test.ts +93 -0
  11. package/akanApp/builderRequestRelay.ts +100 -0
  12. package/akanApp/builderRssRecycler.ts +182 -0
  13. package/akanApp/devBackend.ts +394 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +200 -0
  16. package/akanApp/devIdleSuspend.test.ts +221 -0
  17. package/akanApp/devIdleSuspend.ts +192 -0
  18. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  19. package/akanApp/devRecycler.test.ts +66 -0
  20. package/akanApp/devRecycler.ts +305 -0
  21. package/akanApp/devStartTimeline.test.ts +115 -0
  22. package/akanApp/devStartTimeline.ts +69 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +45 -17
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiReport.test.ts +34 -3
  29. package/apiReport/apiReportDiff.ts +35 -1
  30. package/apiReport/apiReportPolicy.ts +3 -2
  31. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +2 -49
  32. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +71 -8
  33. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +60 -21
  34. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  35. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +17 -1
  36. package/{routeJsBudget.ts → app/routeJsBudget.ts} +9 -3
  37. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  38. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  39. package/artifact/implicitRootLayout.test.ts +71 -3
  40. package/artifact/implicitRootLayout.ts +9 -3
  41. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  42. package/biome.base.json +2 -1
  43. package/cloud/cloudApi.test.ts +1 -1
  44. package/cloud/configLock.test.ts +1 -1
  45. package/cloud/globalConfig.test.ts +1 -1
  46. package/cloud/globalConfig.ts +1 -1
  47. package/cloud/updatePackUpload.test.ts +1 -1
  48. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  49. package/codeAgent/agent/AkanCodeServices.ts +23 -0
  50. package/codeAgent/agent/akanCodePaths.ts +1 -1
  51. package/codeAgent/agent/akanCodeServices.test.ts +54 -0
  52. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  53. package/codeAgent/agent/codeAgent.test.ts +1 -1
  54. package/codeAgent/skills/akan-debug/SKILL.md +8 -5
  55. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  56. package/codeAgent/skills/akan-mcp/SKILL.md +19 -1
  57. package/codeAgent/skills/akan-scaffold/SKILL.md +1 -1
  58. package/codeAgent/skills/akan-validate/SKILL.md +3 -3
  59. package/codeAgent/tools/AkanCli.ts +1 -1
  60. package/codeAgent/tools/AkanToolPack.ts +2 -2
  61. package/codeAgent/tools/akanCodePlugins.test.ts +1 -1
  62. package/commandDecorators/command.ts +35 -6
  63. package/commandDecorators/commandBuilder.ts +1 -1
  64. package/commandDecorators/commandDecorators.test.ts +107 -6
  65. package/commandDecorators/targetMeta.ts +2 -0
  66. package/commandDecorators/workspaceVersionCheck.test.ts +70 -1
  67. package/commandDecorators/workspaceVersionCheck.ts +64 -14
  68. package/context/akanContext.ts +576 -0
  69. package/context/akanContextInspection.ts +296 -0
  70. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  71. package/{akanMcpContract.ts → context/akanMcpContract.ts} +16 -256
  72. package/context/doctor/agentGuideCheck.ts +81 -0
  73. package/context/doctor/configLeftoverCheck.ts +35 -0
  74. package/context/doctor/doctorFindings.ts +70 -0
  75. package/context/doctor/generatedFreshness.ts +56 -0
  76. package/context/doctor/moduleShapeCheck.ts +88 -0
  77. package/context/doctor/recipeDuplicateCheck.ts +42 -0
  78. package/context/doctor/recipeIndexCheck.ts +87 -0
  79. package/context/doctor/rootShapeCheck.ts +55 -0
  80. package/context/doctor/workflowScope.ts +97 -0
  81. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  82. package/context/safeRead.ts +9 -0
  83. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  84. package/devkitUtils.test.ts +39 -5
  85. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  86. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  87. package/docs/errorCodeReference.test.ts +282 -0
  88. package/docs/errorCodeReference.ts +71 -0
  89. package/docs/errorCodeScan.ts +551 -0
  90. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  91. package/executors/appExecutor.ts +463 -0
  92. package/executors/commandExecutionError.ts +53 -0
  93. package/executors/executor.ts +527 -0
  94. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  95. package/{executors.test.ts → executors/executors.test.ts} +106 -18
  96. package/executors/index.ts +8 -0
  97. package/executors/libExecutor.ts +23 -0
  98. package/executors/moduleExecutor.ts +18 -0
  99. package/executors/pkgExecutor.ts +129 -0
  100. package/executors/sysExecutor.ts +301 -0
  101. package/executors/workspaceExecutor.ts +277 -0
  102. package/frontendBuild/allRoutesBuilder.test.ts +1 -1
  103. package/frontendBuild/autoImportSync.test.ts +1 -1
  104. package/frontendBuild/autoImportSync.ts +1 -1
  105. package/frontendBuild/buildCacheStamp.test.ts +42 -0
  106. package/frontendBuild/buildCacheStamp.ts +23 -0
  107. package/frontendBuild/buildRouteClient.test.ts +1 -1
  108. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  109. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  110. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  111. package/frontendBuild/cssCandidateCache.test.ts +70 -1
  112. package/frontendBuild/cssCandidateCache.ts +17 -10
  113. package/frontendBuild/cssCompiler.test.ts +3 -2
  114. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  115. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  116. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  117. package/frontendBuild/fontOptimizer.test.ts +145 -4
  118. package/frontendBuild/fontOptimizer.ts +103 -18
  119. package/frontendBuild/fontPruner.test.ts +1 -1
  120. package/frontendBuild/frontendBuild.test.ts +3 -3
  121. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  122. package/frontendBuild/hmrWatcher.test.ts +1 -1
  123. package/frontendBuild/hmrWatcher.ts +22 -1
  124. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  125. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  126. package/frontendBuild/nativeCore.test.ts +1 -1
  127. package/frontendBuild/optionalPeers.test.ts +36 -8
  128. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  129. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  130. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  131. package/frontendBuild/precompressArtifacts.ts +19 -6
  132. package/frontendBuild/serverGraphFile.ts +1 -1
  133. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  134. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +30 -1
  135. package/frontendBuild/ssrBaseArtifactBuilder.ts +40 -12
  136. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  137. package/frontendBuild/vendorImportScanner.test.ts +1 -1
  138. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  139. package/frontendBuild/watchRootResolver.test.ts +1 -1
  140. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  141. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  142. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  143. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  144. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  145. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  146. package/{prompter.ts → guideline/prompter.ts} +2 -3
  147. package/incrementalBuilder/buildBatch.proc.ts +16 -5
  148. package/incrementalBuilder/buildBatchProtocol.ts +3 -0
  149. package/incrementalBuilder/buildBatchRunner.test.ts +122 -2
  150. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  151. package/incrementalBuilder/builderBoot.ts +113 -0
  152. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  153. package/incrementalBuilder/builderChannel.test.ts +1 -1
  154. package/incrementalBuilder/builderChannel.ts +19 -2
  155. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  156. package/incrementalBuilder/builderLanes.ts +157 -0
  157. package/incrementalBuilder/builderWatch.ts +213 -0
  158. package/incrementalBuilder/csrRegistry.ts +234 -0
  159. package/incrementalBuilder/incrementalBuilder.host.test.ts +16 -0
  160. package/incrementalBuilder/incrementalBuilder.host.ts +7 -1
  161. package/incrementalBuilder/incrementalBuilder.proc.test.ts +142 -7
  162. package/incrementalBuilder/incrementalBuilder.proc.ts +82 -823
  163. package/incrementalBuilder/ssrRegistry.ts +282 -0
  164. package/index.ts +22 -22
  165. package/integration/devStability.integration.test.ts +62 -56
  166. package/integration/devStabilityHarness.test.ts +1 -1
  167. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  168. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  169. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  170. package/lint/gritRules.test.ts +1 -1
  171. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  172. package/lint/no-import-common-err.grit +31 -0
  173. package/lint/no-init-fetch-in-client.grit +1 -1
  174. package/mobile/desktopBin.test.ts +1 -1
  175. package/mobile/desktopRelease.test.ts +1 -1
  176. package/mobile/desktopServerStage.test.ts +2 -2
  177. package/mobile/desktopServerStage.ts +1 -1
  178. package/mobile/nativeApi.test.ts +1 -1
  179. package/mobile/nativeApp.test.ts +1 -1
  180. package/mobile/nativeConfig.test.ts +1 -1
  181. package/mobile/nativePluginFolders.test.ts +1 -1
  182. package/mobile/nativePublicEnv.test.ts +1 -1
  183. package/mobile/nativePublicEnv.ts +2 -1
  184. package/mobile/nativeWebDir.test.ts +1 -1
  185. package/mobile/serverBundleSecrets.test.ts +1 -1
  186. package/mobile/tarWriter.test.ts +1 -1
  187. package/mobile/updatePackFolder.test.ts +1 -1
  188. package/package.json +173 -9
  189. package/packageExports.test.ts +20 -2
  190. package/piDependencyPins.test.ts +1 -1
  191. package/pipeline/PipelineDefinition.ts +1 -1
  192. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  193. package/platformTest/LinuxDockerTarget.ts +1 -1
  194. package/platformTest/PlatformTestRun.test.ts +1 -1
  195. package/platformTest/TestSnapshot.test.ts +1 -1
  196. package/platformTest/WindowsSshTarget.ts +1 -1
  197. package/preview/previewView.test.ts +23 -1
  198. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  199. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  200. package/quality/bareErrorScanner.ts +126 -0
  201. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  202. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  203. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  204. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  205. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  206. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  207. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  208. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  209. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +41 -1
  210. package/{qualityScanner.ts → quality/qualityScanner.ts} +25 -91
  211. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  212. package/quality/workspaceSourceFiles.ts +82 -0
  213. package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
  214. package/{subspace.ts → subspace/subspace.ts} +5 -5
  215. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  216. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  217. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  218. package/transforms/barrelAnalyzer.ts +31 -10
  219. package/transforms/browserDirnamePlugin.test.ts +1 -1
  220. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  221. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  222. package/transforms/pureLazyMarker.test.ts +1 -1
  223. package/transforms/serverEnvPlugin.test.ts +1 -1
  224. package/transforms/serverEnvProfile.test.ts +1 -1
  225. package/transforms/sideEffectImportOrder.test.ts +1 -1
  226. package/transforms/transforms.test.ts +52 -2
  227. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  228. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  229. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  230. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  231. package/typecheck/projectTypecheck.test.ts +23 -1
  232. package/typecheck/projectTypecheck.ts +10 -2
  233. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  234. package/{typeChecker.ts → typecheck/typeChecker.ts} +5 -4
  235. package/typecheck/typecheck.proc.ts +6 -2
  236. package/typecheck/typecheckFailure.ts +1 -1
  237. package/util/errorReport.ts +66 -0
  238. package/{fileSys.test.ts → util/fileSys.test.ts} +13 -0
  239. package/{fileSys.ts → util/fileSys.ts} +2 -2
  240. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  241. package/workflow/constantSource.ts +187 -0
  242. package/workflow/dictionarySource.ts +184 -0
  243. package/workflow/executor.ts +6 -9
  244. package/workflow/fieldExpression.ts +153 -0
  245. package/workflow/fieldLabel.ts +61 -0
  246. package/workflow/fieldOrder.ts +117 -0
  247. package/workflow/fieldType.ts +2 -1
  248. package/workflow/guardCatalog.test.ts +1 -1
  249. package/workflow/keyRename.ts +1 -1
  250. package/workflow/moduleIndex.test.ts +2 -2
  251. package/workflow/moduleIndex.ts +2 -2
  252. package/workflow/modulePaths.ts +27 -0
  253. package/workflow/mutationScaffold.ts +7 -15
  254. package/workflow/mutationSource.ts +2 -1
  255. package/workflow/plan.ts +2 -1
  256. package/workflow/primitiveReport.ts +78 -0
  257. package/workflow/rolloutGate.test.ts +1 -1
  258. package/workflow/rolloutGate.ts +1 -1
  259. package/workflow/serviceSource.ts +33 -0
  260. package/workflow/signalSource.ts +96 -0
  261. package/workflow/source.ts +50 -1100
  262. package/workflow/sourceAst.ts +30 -0
  263. package/workflow/sourceImports.ts +105 -0
  264. package/workflow/sourceText.ts +13 -0
  265. package/workflow/templateSource.ts +30 -0
  266. package/workflow/testSource.ts +31 -0
  267. package/workflow/types.ts +1 -1
  268. package/workflow/uiPolicy.ts +1 -1
  269. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  270. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  271. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  272. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  273. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  274. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  275. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  276. package/{libSource.ts → workspace/libSource.ts} +1 -1
  277. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  278. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  279. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  280. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
  281. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  282. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  283. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  284. package/akanContext.ts +0 -1083
  285. package/executors.ts +0 -1749
  286. /package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +0 -0
  287. /package/{akanMcpToolError.ts → context/akanMcpToolError.ts} +0 -0
  288. /package/{moduleFieldNames.test.ts → context/moduleFieldNames.test.ts} +0 -0
  289. /package/{moduleFieldNames.ts → context/moduleFieldNames.ts} +0 -0
  290. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  291. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  292. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  293. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  294. /package/{linter.ts → lint/linter.ts} +0 -0
  295. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  296. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  297. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  298. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  299. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  300. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  301. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  302. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  303. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  304. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  305. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  306. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  307. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  308. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  309. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  310. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  311. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  312. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  313. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  314. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  315. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  316. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  317. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  318. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  319. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  320. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  321. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  322. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  323. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  324. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  325. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  326. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  327. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  328. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  329. /package/{writePath.ts → quality/writePath.ts} +0 -0
  330. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  331. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  332. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  333. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  334. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  335. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  336. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  337. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  338. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  339. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  340. /package/{semver.ts → util/semver.ts} +0 -0
  341. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  342. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  343. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  344. /package/{spinner.ts → util/spinner.ts} +0 -0
  345. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  346. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  347. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  348. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  349. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  350. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  351. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  352. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  353. /package/{types.ts → workspace/types.ts} +0 -0
@@ -0,0 +1,527 @@
1
+ import {
2
+ type ChildProcess,
3
+ type ExecOptions,
4
+ exec,
5
+ type ForkOptions,
6
+ fork,
7
+ type SpawnOptions,
8
+ spawn,
9
+ } from "node:child_process";
10
+ import { copyFile, cp as cpEntry, mkdir, readdir as readDirEntries, rm, stat } from "node:fs/promises";
11
+ import path from "node:path";
12
+ import { capitalize, Logger, toError } from "akanjs/common";
13
+ import { $ } from "bun";
14
+ import chalk from "chalk";
15
+ import { Linter } from "../lint/linter";
16
+ import { ProjectTypecheck } from "../typecheck/projectTypecheck";
17
+ // Type-only: `getTypeChecker` loads it on demand to keep `typescript` out of the resident module graph.
18
+ import type { TypeChecker } from "../typecheck/typeChecker";
19
+ import { FileSys, getDirname } from "../util/fileSys";
20
+ import { JsonFormatter } from "../util/jsonFormatter";
21
+ import { Spinner } from "../util/spinner";
22
+ import type { AppInfo, LibInfo } from "../workspace/scanInfo";
23
+ import type { FileContent, PackageJson, TsConfigJson } from "../workspace/types";
24
+ import { CommandExecutionError } from "./commandExecutionError";
25
+
26
+ export interface WrittenFileContent extends FileContent {
27
+ written: boolean;
28
+ }
29
+
30
+ const staticTemplateFileExtensions = new Set(
31
+ ".avif .bmp .cjs .css .eot .gif .html .ico .jpeg .jpg .js .json .map .md .mjs .mp3 .mp4 .ogg .otf .pdf .png .svg"
32
+ .split(" ")
33
+ .concat(".ttf .txt .wasm .wav .webm .webp .woff .woff2 .xml".split(" ")),
34
+ );
35
+
36
+ export const execEmoji = {
37
+ workspace: "🏠",
38
+ app: "🚀",
39
+ lib: "🔧",
40
+ pkg: "📦",
41
+ dist: "💿",
42
+ module: "⚙️",
43
+ default: "✈️",
44
+ };
45
+
46
+ const withCapitalizedDict = (dict: { [key: string]: string } = {}) => ({
47
+ ...dict,
48
+ ...Object.fromEntries(Object.entries(dict).map(([key, value]) => [capitalize(key), capitalize(value)])),
49
+ });
50
+
51
+ export class Executor {
52
+ static verbose = false;
53
+ static setVerbose(verbose: boolean) {
54
+ Executor.verbose = verbose;
55
+ }
56
+
57
+ name: string;
58
+ logger: Logger;
59
+ logs: string[];
60
+ cwdPath: string;
61
+ emoji = execEmoji.default;
62
+ typeChecker: TypeChecker | null = null;
63
+ linter: Linter | null = null;
64
+ constructor(name: string, cwdPath: string) {
65
+ this.name = name;
66
+ this.logger = new Logger(name);
67
+ this.logs = [] as string[];
68
+ this.cwdPath = cwdPath;
69
+ }
70
+ #stdout(data: Buffer) {
71
+ if (Executor.verbose) Logger.raw(chalk.dim(data.toString()));
72
+ }
73
+ #stderr(data: Buffer) {
74
+ Logger.raw(chalk.red(data.toString()));
75
+ }
76
+ #settle(
77
+ proc: ChildProcess,
78
+ target: { command: string; args?: string[]; cwd: string },
79
+ { onClose = false, keepLogs = false, redStderr = false } = {},
80
+ ): Promise<{ code: number | null; signal: NodeJS.Signals | null; stdout: string }> {
81
+ let stdout = "";
82
+ let stderr = "";
83
+ proc.stdout?.on("data", (data: Buffer) => {
84
+ stdout += data.toString();
85
+ if (keepLogs) this.logs.push(data.toString());
86
+ this.#stdout(data);
87
+ });
88
+ proc.stderr?.on("data", (data: Buffer) => {
89
+ stderr += data.toString();
90
+ if (keepLogs) this.logs.push(data.toString());
91
+ if (redStderr) this.#stderr(data);
92
+ else this.#stdout(data); // 정상로그도 stderr로 나옴
93
+ });
94
+ return new Promise((resolve, reject) => {
95
+ proc.on("error", (cause) =>
96
+ reject(new CommandExecutionError({ ...target, code: null, signal: null, stdout, stderr, cause })),
97
+ );
98
+ proc.on(onClose ? "close" : "exit", (code: number | null, signal: NodeJS.Signals | null) => {
99
+ if ((onClose ? code !== 0 : code) || signal)
100
+ reject(new CommandExecutionError({ ...target, code, signal, stdout, stderr }));
101
+ else resolve({ code, signal, stdout });
102
+ });
103
+ });
104
+ }
105
+ exec(command: string, options: ExecOptions = {}): Promise<unknown> {
106
+ const target = { command, cwd: options.cwd?.toString() ?? this.cwdPath };
107
+ const proc = exec(command, { cwd: this.cwdPath, ...options });
108
+ return this.#settle(proc, target).then(({ code, signal }) => ({ code, signal }));
109
+ }
110
+
111
+ spawn(command: string, args: string[] = [], options: SpawnOptions = {}): Promise<string> {
112
+ const target = { command, args, cwd: options.cwd?.toString() ?? this.cwdPath };
113
+ const proc = spawn(command, args, { cwd: this.cwdPath, ...options });
114
+ return this.#settle(proc, target, { onClose: true, keepLogs: true }).then(({ stdout }) => stdout);
115
+ }
116
+ spawnSync(command: string, args: string[] = [], options: SpawnOptions = {}): ChildProcess {
117
+ return spawn(command, args, { cwd: this.cwdPath, ...options });
118
+ }
119
+ fork(modulePath: string, args: string[] = [], options: ForkOptions = {}): Promise<unknown> {
120
+ const target = { command: modulePath, args, cwd: options.cwd?.toString() ?? this.cwdPath };
121
+ const proc = fork(modulePath, args, { cwd: this.cwdPath, ...options });
122
+ return this.#settle(proc, target, { redStderr: true }).then(({ code, signal }) => ({ code, signal }));
123
+ }
124
+ getPath(filePath: string) {
125
+ if (path.isAbsolute(filePath)) return filePath;
126
+ if (filePath.startsWith(".")) return path.join(this.cwdPath, filePath);
127
+ const baseParts = this.cwdPath.split(/[\\/]/).filter(Boolean);
128
+ const targetParts = filePath.split(/[\\/]/).filter(Boolean);
129
+
130
+ let overlapLength = 0;
131
+ for (let i = 1; i <= Math.min(baseParts.length, targetParts.length); i++) {
132
+ let isOverlap = true;
133
+ for (let j = 0; j < i; j++)
134
+ if (baseParts[baseParts.length - i + j] !== targetParts[j]) {
135
+ isOverlap = false;
136
+ break;
137
+ }
138
+ if (isOverlap) overlapLength = i;
139
+ }
140
+ return path.join(this.cwdPath, ...targetParts.slice(overlapLength));
141
+ }
142
+ async mkdir(dirPath: string) {
143
+ const writePath = this.getPath(dirPath);
144
+ if (!(await FileSys.dirExists(writePath))) await mkdir(writePath, { recursive: true });
145
+ this.logger.verbose(`Make directory ${writePath}`);
146
+ return this;
147
+ }
148
+ async readdir(dirPath: string): Promise<string[]> {
149
+ const readPath = this.getPath(dirPath);
150
+ try {
151
+ const glob = new Bun.Glob("*");
152
+ return Array.from(glob.scanSync({ cwd: readPath, onlyFiles: false })).sort();
153
+ } catch {
154
+ return [];
155
+ }
156
+ }
157
+ async getAllFiles(pattern = "**/*", { cwd }: { cwd?: string } = {}): Promise<string[]> {
158
+ const glob = new Bun.Glob(pattern);
159
+ return Array.from(glob.scanSync({ cwd: cwd ?? this.cwdPath, onlyFiles: true })).sort();
160
+ }
161
+ async getFilesAndDirs(dirPath: string): Promise<{ files: string[]; dirs: string[] }> {
162
+ const fullDirPath = this.getPath(dirPath);
163
+ const glob = new Bun.Glob("*");
164
+ const files = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: true })).sort();
165
+ const allEntries = Array.from(glob.scanSync({ cwd: fullDirPath, onlyFiles: false })).sort();
166
+ const dirs = allEntries.filter((entry) => !files.includes(entry));
167
+ return { files, dirs };
168
+ }
169
+ async exists(filePath: string) {
170
+ return await FileSys.exists(this.getPath(filePath));
171
+ }
172
+ async remove(filePath: string) {
173
+ const readPath = this.getPath(filePath);
174
+ if (await FileSys.fileExists(readPath)) await FileSys.delete(readPath);
175
+ this.logger.verbose(`Remove file ${readPath}`);
176
+ return this;
177
+ }
178
+ async removeDir(dirPath: string) {
179
+ //* XXX: `path.join(…, ".")` drops a trailing slash: `rm -rf link/` wipes the target, `rm -rf link` only unlinks.
180
+ const readPath = path.join(this.getPath(dirPath), ".");
181
+ if (await FileSys.entryExists(readPath)) await rm(readPath, { recursive: true, force: true });
182
+ this.logger.verbose(`Remove directory ${readPath}`);
183
+ return this;
184
+ }
185
+ async writeFile(
186
+ filePath: string,
187
+ content: string | object,
188
+ { overwrite = true, silent = false }: { overwrite?: boolean; silent?: boolean } = {},
189
+ ): Promise<WrittenFileContent> {
190
+ const writePath = this.getPath(filePath);
191
+ const dir = path.dirname(writePath);
192
+ if (!(await FileSys.dirExists(dir))) await mkdir(dir, { recursive: true });
193
+ let contentStr = typeof content === "string" ? content : JsonFormatter.stringify(content, writePath);
194
+ let written = true;
195
+
196
+ if (await FileSys.fileExists(writePath)) {
197
+ const currentContent = await FileSys.readText(writePath);
198
+ if (currentContent === contentStr || !overwrite) {
199
+ this.logger.verbose(`File ${writePath} is unchanged`);
200
+ contentStr = currentContent;
201
+ written = false;
202
+ } else {
203
+ await FileSys.writeText(writePath, contentStr);
204
+ if (Logger.isVerbose()) this.logger.rawLog(chalk.yellow(`File Update: ${filePath}`));
205
+ }
206
+ } else {
207
+ await FileSys.writeText(writePath, contentStr);
208
+ if (!silent) this.logger.rawLog(chalk.green(`File Create: ${filePath}`));
209
+ }
210
+ return { filePath: writePath, content: contentStr, written };
211
+ }
212
+ async writeJson(filePath: string, content: object) {
213
+ await this.writeFile(filePath, content);
214
+ }
215
+ async getLocalFile(targetPath: string) {
216
+ const filePath = path.isAbsolute(targetPath) ? targetPath : targetPath.replace(this.cwdPath, "");
217
+ const content = await this.readFile(filePath);
218
+ return { filePath, content };
219
+ }
220
+ async readFile(filePath: string) {
221
+ return await FileSys.readText(this.getPath(filePath));
222
+ }
223
+ async readJson(filePath: string) {
224
+ return await FileSys.readJson<object>(this.getPath(filePath));
225
+ }
226
+ async cp(srcPath: string, destPath: string, { dereference = false }: { dereference?: boolean } = {}) {
227
+ const src = this.getPath(srcPath);
228
+ const dest = this.getPath(destPath);
229
+ if (!(await FileSys.exists(src))) return;
230
+ const isDirectory = (await stat(src)).isDirectory();
231
+ if (!(await FileSys.exists(dest)) && isDirectory) await mkdir(dest, { recursive: true });
232
+ //* `cp -r` keeps symlinks on GNU but follows them on macOS; Windows has no `cp -r <dir>/.` and rarely the
233
+ //* privilege a symlink needs, so it always copies real files.
234
+ if (dereference || process.platform === "win32")
235
+ await cpEntry(src, dest, { recursive: isDirectory, dereference: true, force: true });
236
+ else await $`cp -r ${src}${isDirectory ? "/." : ""} ${dest}`;
237
+ }
238
+ log(msg: string) {
239
+ this.logger.info(msg);
240
+ return this;
241
+ }
242
+ verbose(msg: string) {
243
+ this.logger.verbose(msg);
244
+ return this;
245
+ }
246
+ debug(msg: string) {
247
+ this.logger.debug(msg);
248
+ return this;
249
+ }
250
+ spinning(msg: string, { prefix = `${this.emoji}${this.name}`, indent = 0, enableSpin = !Executor.verbose } = {}) {
251
+ return new Spinner(msg, { prefix, indent, enableSpin }).start();
252
+ }
253
+
254
+ #tsconfig: TsConfigJson | null = null;
255
+ async getTsConfig(pathname = "tsconfig.json", { refresh }: { refresh?: boolean } = {}): Promise<TsConfigJson> {
256
+ if (this.#tsconfig && !refresh) return this.#tsconfig;
257
+ let tsconfig = (await this.readJson(pathname)) as TsConfigJson;
258
+ if (tsconfig.extends) {
259
+ const base = await this.getTsConfig(tsconfig.extends, { refresh });
260
+ tsconfig = { ...base, ...tsconfig, compilerOptions: { ...base.compilerOptions, ...tsconfig.compilerOptions } };
261
+ }
262
+ this.#tsconfig = tsconfig;
263
+ return tsconfig;
264
+ }
265
+ async setTsConfig(tsconfig: TsConfigJson) {
266
+ await this.writeJson("tsconfig.json", tsconfig);
267
+ this.#tsconfig = tsconfig;
268
+ }
269
+
270
+ #packageJson: PackageJson | null = null;
271
+ async getPackageJson({ refresh }: { refresh?: boolean } = {}): Promise<PackageJson> {
272
+ if (this.#packageJson && !refresh) return this.#packageJson;
273
+ const packageJson = (await this.readJson("package.json")) as PackageJson;
274
+ this.#packageJson = packageJson;
275
+ return packageJson;
276
+ }
277
+ async setPackageJson(packageJson: PackageJson) {
278
+ await this.writeJson("package.json", packageJson);
279
+ this.#packageJson = packageJson;
280
+ }
281
+
282
+ #gitignorePatterns: string[] = [];
283
+ async getGitignorePatterns(): Promise<string[]> {
284
+ if (this.#gitignorePatterns.length) return this.#gitignorePatterns;
285
+ const gitignore = await this.readFile(".gitignore");
286
+ this.#gitignorePatterns = gitignore
287
+ .split("\n")
288
+ .map((line) => line.trim())
289
+ .filter((line) => !!line && !line.startsWith("#"));
290
+ return this.#gitignorePatterns;
291
+ }
292
+
293
+ async #applyTemplateFile(
294
+ {
295
+ templatePath,
296
+ targetPath,
297
+ scanInfo,
298
+ overwrite = true,
299
+ dryRun = false,
300
+ }: {
301
+ templatePath: string;
302
+ targetPath: string;
303
+ scanInfo?: AppInfo | LibInfo | null;
304
+ overwrite?: boolean;
305
+ dryRun?: boolean;
306
+ },
307
+ dict: { [key: string]: string } = {},
308
+ options: { [key: string]: unknown } = {},
309
+ ): Promise<WrittenFileContent | null> {
310
+ const convertPath = (target: string) =>
311
+ Object.entries(dict).reduce(
312
+ (converted, [key, value]) => converted.replace(new RegExp(`__${key}__`, "g"), value),
313
+ target,
314
+ );
315
+ if (targetPath.endsWith(".ts") || targetPath.endsWith(".tsx")) {
316
+ const getContent = (await import(templatePath)) as {
317
+ default: (
318
+ scanInfo: AppInfo | LibInfo | null,
319
+ dict: { [key: string]: string },
320
+ options?: { [key: string]: unknown },
321
+ ) => Promise<string | null | { filename: string; content: string }>;
322
+ };
323
+ const result = await getContent.default(scanInfo ?? null, dict, options);
324
+ if (result === null) return null;
325
+ const filename = typeof result === "object" ? result.filename : path.basename(targetPath).replace(".js", ".ts");
326
+ const content = typeof result === "object" ? result.content : result;
327
+ const convertedTargetPath = convertPath(`${path.dirname(targetPath)}/${filename}`);
328
+ if (dryRun) return { filePath: this.getPath(convertedTargetPath), content, written: false };
329
+ this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
330
+ return this.writeFile(convertedTargetPath, content, { overwrite });
331
+ } else if (targetPath.endsWith(".template")) {
332
+ const content = await FileSys.readText(templatePath);
333
+ const convertedTargetPath = convertPath(targetPath.slice(0, -9));
334
+ const convertedContent = Object.entries(dict).reduce(
335
+ (data, [key, value]) => data.replace(new RegExp(`<%= ${key} %>`, "g"), value),
336
+ content,
337
+ );
338
+ if (dryRun) return { filePath: this.getPath(convertedTargetPath), content: convertedContent, written: false };
339
+ this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
340
+ return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
341
+ } else if (staticTemplateFileExtensions.has(path.extname(targetPath).toLowerCase())) {
342
+ const convertedTargetPath = convertPath(targetPath);
343
+ const writePath = this.getPath(convertedTargetPath);
344
+ if (dryRun) return { filePath: writePath, content: "", written: false };
345
+ if (!overwrite && (await FileSys.fileExists(writePath)))
346
+ return { filePath: writePath, content: "", written: false };
347
+ const dirname = path.dirname(writePath);
348
+ if (!(await FileSys.dirExists(dirname))) await mkdir(dirname, { recursive: true });
349
+ await copyFile(templatePath, writePath);
350
+ this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
351
+ return { filePath: writePath, content: "", written: true };
352
+ } else return null;
353
+ }
354
+ async _applyTemplate({
355
+ basePath,
356
+ template,
357
+ scanInfo,
358
+ dict = {},
359
+ options = {},
360
+ overwrite = true,
361
+ dryRun = false,
362
+ }: {
363
+ basePath: string;
364
+ template: string;
365
+ scanInfo?: AppInfo | LibInfo | null;
366
+ dict?: { [key: string]: string };
367
+ options?: { [key: string]: unknown };
368
+ overwrite?: boolean;
369
+ dryRun?: boolean;
370
+ }): Promise<WrittenFileContent[]> {
371
+ const templateRoot = await this.#resolveTemplateRoot();
372
+ const templatePath = `${templateRoot}${template ? `/${template}` : ""}`;
373
+ if ((await stat(templatePath)).isFile()) {
374
+ const fileContent = await this.#applyTemplateFile(
375
+ {
376
+ templatePath,
377
+ targetPath: path.join(basePath, path.basename(templatePath)),
378
+ scanInfo,
379
+ overwrite,
380
+ dryRun,
381
+ },
382
+ dict,
383
+ options,
384
+ );
385
+ return fileContent ? [fileContent] : ([] as WrittenFileContent[]);
386
+ } else {
387
+ const subdirs = await readDirEntries(templatePath);
388
+ const fileContents = (
389
+ await Promise.all(
390
+ subdirs.map(async (subdir) => {
391
+ const subpath = path.join(templatePath, subdir);
392
+ if ((await stat(subpath)).isFile()) {
393
+ const fileContent = await this.#applyTemplateFile(
394
+ {
395
+ templatePath: subpath,
396
+ targetPath: path.join(basePath, subdir),
397
+ scanInfo,
398
+ overwrite,
399
+ dryRun,
400
+ },
401
+ dict,
402
+ options,
403
+ );
404
+ return fileContent ? [fileContent] : ([] as WrittenFileContent[]);
405
+ } else
406
+ return await this._applyTemplate({
407
+ basePath: path.join(basePath, subdir),
408
+ template: path.join(template, subdir),
409
+ scanInfo,
410
+ dict,
411
+ overwrite,
412
+ dryRun,
413
+ options,
414
+ });
415
+ }),
416
+ )
417
+ ).flat();
418
+ return fileContents;
419
+ }
420
+ }
421
+ async #resolveTemplateRoot() {
422
+ const candidates = [
423
+ path.resolve(getDirname(import.meta.url), "templates"),
424
+ path.resolve(getDirname(import.meta.url), "../../cli/templates"),
425
+ ];
426
+ for (const candidate of candidates) {
427
+ if (await FileSys.dirExists(candidate)) return candidate;
428
+ }
429
+ return candidates[0];
430
+ }
431
+ async applyTemplate(options: {
432
+ basePath: string;
433
+ template: string;
434
+ scanInfo?: AppInfo | LibInfo | null;
435
+ dict?: { [key: string]: string };
436
+ options?: { [key: string]: unknown };
437
+ overwrite?: boolean;
438
+ dryRun?: boolean;
439
+ }): Promise<FileContent[]> {
440
+ const fileContents = await this._applyTemplate({ ...options, dict: withCapitalizedDict(options.dict) });
441
+ await this.#formatAppliedTemplate(fileContents.filter((fileContent) => fileContent.written));
442
+ return fileContents;
443
+ }
444
+
445
+ // Best-effort: `create-akan-workspace` scaffolds before `bun install`, with no local Biome binary yet, so a
446
+ // template emits Biome's form itself (`templates/biomeForm.ts`).
447
+ async #formatAppliedTemplate(fileContents: FileContent[]) {
448
+ const filePaths = fileContents
449
+ .map((fileContent) => fileContent.filePath)
450
+ .filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx"));
451
+ if (filePaths.length === 0) return;
452
+ try {
453
+ const { fixed } = await this.getLinter().fixFiles(filePaths);
454
+ if (fixed.length > 0) this.logger.verbose(`Formatted ${fixed.length} scaffolded file(s)`);
455
+ } catch (err) {
456
+ this.logger.verbose(`Skipped formatting scaffolded files: ${toError(err).message}`);
457
+ }
458
+ }
459
+ // Async so `typescript` (~65MB resident) loads only in the commands that typecheck.
460
+ async getTypeChecker() {
461
+ const { TypeChecker } = await import("../typecheck/typeChecker");
462
+ this.typeChecker ??= new TypeChecker(this);
463
+ return this.typeChecker;
464
+ }
465
+ async typeCheck(filePath: string) {
466
+ const path = this.getPath(filePath);
467
+ const typeChecker = await this.getTypeChecker();
468
+ const { fileDiagnostics, fileErrors, fileWarnings } = typeChecker.check(path);
469
+ const message = typeChecker.formatDiagnostics(fileDiagnostics);
470
+ return { fileDiagnostics, fileErrors, fileWarnings, message };
471
+ }
472
+ async typeCheckAsync(filePath: string) {
473
+ const path = this.getPath(filePath);
474
+ const entry = await ProjectTypecheck.workerEntry(process.cwd());
475
+ const proc = Bun.spawn([process.execPath, entry], {
476
+ cwd: this.cwdPath,
477
+ env: {
478
+ ...process.env,
479
+ AKAN_TYPECHECK_CWD: this.cwdPath,
480
+ AKAN_TYPECHECK_FILE: path,
481
+ },
482
+ stdout: "pipe",
483
+ stderr: "pipe",
484
+ });
485
+ const [stdout, stderr, exitCode] = await Promise.all([
486
+ new Response(proc.stdout).text(),
487
+ new Response(proc.stderr).text(),
488
+ proc.exited,
489
+ ]);
490
+ if (exitCode !== 0) throw new Error((stderr || stdout).trim() || `Typecheck failed with exit code ${exitCode}`);
491
+
492
+ const result = JSON.parse(stdout) as {
493
+ fileDiagnosticsCount: number;
494
+ fileErrorsCount: number;
495
+ fileWarningsCount: number;
496
+ message: string;
497
+ };
498
+ return {
499
+ fileDiagnostics: Array.from({ length: result.fileDiagnosticsCount }),
500
+ fileErrors: Array.from({ length: result.fileErrorsCount }),
501
+ fileWarnings: Array.from({ length: result.fileWarningsCount }),
502
+ message: result.message,
503
+ };
504
+ }
505
+ getLinter() {
506
+ this.linter ??= new Linter(this.cwdPath);
507
+ return this.linter;
508
+ }
509
+ async lint(
510
+ filePath: string,
511
+ { fix = false, dryRun = false }: { fix?: boolean; dryRun?: boolean } = {},
512
+ ): Promise<{
513
+ results: unknown[];
514
+ message: string;
515
+ errors: unknown[];
516
+ warnings: unknown[];
517
+ }> {
518
+ const path = this.getPath(filePath);
519
+ const linter = this.getLinter();
520
+ const { results, errors, warnings } = await linter.lint(path, {
521
+ fix,
522
+ dryRun,
523
+ });
524
+ const message = linter.formatLintResults(results);
525
+ return { results, message, errors, warnings };
526
+ }
527
+ }
@@ -16,7 +16,7 @@ mock.module("node:fs/promises", () => ({
16
16
  return await realSymlink(...args);
17
17
  },
18
18
  }));
19
- const { AppExecutor, WorkspaceExecutor } = await import("./executors");
19
+ const { AppExecutor, WorkspaceExecutor } = await import("./");
20
20
 
21
21
  const { lstat, mkdir, mkdtemp, readFile, rm, writeFile } = fsPromises;
22
22
  const originalEnv = { ...process.env };