@akanjs/devkit 3.2.0-rc.3 → 3.2.0-rc.31

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 (365) hide show
  1. package/CHANGELOG.md +369 -11
  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 +257 -1
  7. package/akanApp/akanApp.host.ts +146 -1223
  8. package/akanApp/akanApp.host.wiring.test.ts +727 -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 +392 -0
  14. package/akanApp/devBuildStatusBoard.ts +128 -0
  15. package/akanApp/devBuilder.ts +196 -0
  16. package/akanApp/devHostPolicy.test.ts +11 -11
  17. package/akanApp/devHostPolicy.ts +2 -4
  18. package/akanApp/devIdleSuspend.test.ts +221 -0
  19. package/akanApp/devIdleSuspend.ts +192 -0
  20. package/akanApp/devIdleSuspend.watcher.test.ts +120 -0
  21. package/akanApp/devRecycler.test.ts +66 -0
  22. package/akanApp/devRecycler.ts +305 -0
  23. package/akanApp/processRss.ts +61 -0
  24. package/akanConfig/akanConfig.test.ts +24 -1
  25. package/akanConfig/akanConfig.ts +10 -10
  26. package/akanConfig/akanWorkspaceConfig.ts +1 -1
  27. package/akanConfig/productionLockfile.ts +1 -1
  28. package/apiReport/apiDeclarationPrinter.ts +120 -0
  29. package/apiReport/apiReport.test.ts +526 -0
  30. package/apiReport/apiReport.ts +232 -0
  31. package/apiReport/apiReportDiff.ts +160 -0
  32. package/apiReport/apiReportPolicy.ts +65 -0
  33. package/apiReport/apiTargets.ts +311 -0
  34. package/apiReport/changesetBump.ts +19 -0
  35. package/{applicationBuildReporter.test.ts → app/applicationBuildReporter.test.ts} +21 -0
  36. package/{applicationBuildReporter.ts → app/applicationBuildReporter.ts} +10 -49
  37. package/{applicationBuildRunner.test.ts → app/applicationBuildRunner.test.ts} +74 -7
  38. package/{applicationBuildRunner.ts → app/applicationBuildRunner.ts} +20 -15
  39. package/{applicationTestPreload.ts → app/applicationTestPreload.ts} +1 -1
  40. package/{routeJsBudget.test.ts → app/routeJsBudget.test.ts} +48 -12
  41. package/{routeJsBudget.ts → app/routeJsBudget.ts} +90 -27
  42. package/{routeSourceValidator.test.ts → app/routeSourceValidator.test.ts} +17 -0
  43. package/{routeSourceValidator.ts → app/routeSourceValidator.ts} +5 -1
  44. package/artifact/implicitRootLayout.test.ts +71 -3
  45. package/artifact/implicitRootLayout.ts +21 -4
  46. package/artifact/implicitRootLayoutRender.test.tsx +297 -0
  47. package/biome.base.json +2 -1
  48. package/cloud/cloudApi.test.ts +1 -1
  49. package/cloud/configLock.test.ts +1 -1
  50. package/cloud/globalConfig.test.ts +1 -1
  51. package/cloud/globalConfig.ts +1 -1
  52. package/cloud/updatePackUpload.test.ts +1 -1
  53. package/codeAgent/agent/AkanCodeEnv.ts +1 -1
  54. package/codeAgent/agent/akanCodePaths.ts +1 -1
  55. package/codeAgent/agent/akanSystemPrompt.ts +1 -1
  56. package/codeAgent/agent/codeAgent.test.ts +1 -1
  57. package/codeAgent/skills/akan-debug/SKILL.md +10 -3
  58. package/codeAgent/skills/akan-err/SKILL.md +7 -0
  59. package/codeAgent/skills/akan-mcp/SKILL.md +17 -2
  60. package/codeAgent/skills/akan-scaffold/SKILL.md +2 -2
  61. package/codeAgent/skills/akan-transport/SKILL.md +2 -0
  62. package/codeAgent/skills/akan-validate/SKILL.md +1 -0
  63. package/codeAgent/tools/AkanCli.ts +1 -1
  64. package/codeAgent/tools/AkanToolPack.ts +1 -1
  65. package/codeAgent/tools/McpClient.ts +28 -6
  66. package/codeAgent/tools/McpToolPack.ts +1 -1
  67. package/codeAgent/tools/akanCodePlugins.test.ts +14 -2
  68. package/commandDecorators/argMeta.ts +4 -0
  69. package/commandDecorators/cliError.ts +72 -0
  70. package/commandDecorators/command.ts +165 -91
  71. package/commandDecorators/commandBuilder.ts +1 -1
  72. package/commandDecorators/commandDecorators.test.ts +191 -16
  73. package/commandDecorators/exitCodeError.ts +6 -7
  74. package/commandDecorators/index.ts +1 -0
  75. package/commandDecorators/targetMeta.ts +1 -0
  76. package/commandDecorators/workspaceVersionCheck.test.ts +1 -1
  77. package/commandDecorators/workspaceVersionCheck.ts +1 -1
  78. package/context/akanContext.ts +576 -0
  79. package/context/akanContextInspection.ts +296 -0
  80. package/{akanMcpContract.test.ts → context/akanMcpContract.test.ts} +1 -1
  81. package/{akanMcpContract.ts → context/akanMcpContract.ts} +32 -262
  82. package/context/akanMcpToolError.ts +16 -0
  83. package/context/doctor/agentGuideCheck.ts +81 -0
  84. package/context/doctor/configLeftoverCheck.ts +35 -0
  85. package/context/doctor/doctorFindings.ts +70 -0
  86. package/context/doctor/generatedFreshness.ts +56 -0
  87. package/context/doctor/moduleShapeCheck.ts +88 -0
  88. package/context/doctor/recipeDuplicateCheck.ts +39 -0
  89. package/context/doctor/recipeIndexCheck.ts +87 -0
  90. package/context/doctor/rootShapeCheck.ts +55 -0
  91. package/context/doctor/workflowScope.ts +97 -0
  92. package/{constantFieldNames.test.ts → context/moduleFieldNames.test.ts} +24 -2
  93. package/context/moduleFieldNames.ts +25 -0
  94. package/{recipeScanner.test.ts → context/recipeScanner.test.ts} +1 -1
  95. package/context/safeRead.ts +9 -0
  96. package/csrE2e/csrE2eHarness.fixture.ts +1 -1
  97. package/devkitUtils.test.ts +39 -5
  98. package/{apiReference.test.ts → docs/apiReference.test.ts} +4 -4
  99. package/{apiReference.ts → docs/apiReference.ts} +2 -2
  100. package/docs/errorCodeReference.test.ts +282 -0
  101. package/docs/errorCodeReference.ts +71 -0
  102. package/docs/errorCodeScan.ts +551 -0
  103. package/{frameworkGraph.test.ts → docs/frameworkGraph.test.ts} +1 -1
  104. package/executors/appExecutor.ts +448 -0
  105. package/executors/commandExecutionError.ts +53 -0
  106. package/executors/executor.ts +527 -0
  107. package/{executors.linkFallback.test.ts → executors/executors.linkFallback.test.ts} +1 -1
  108. package/{executors.test.ts → executors/executors.test.ts} +76 -15
  109. package/executors/index.ts +8 -0
  110. package/executors/libExecutor.ts +23 -0
  111. package/executors/moduleExecutor.ts +18 -0
  112. package/executors/pkgExecutor.ts +129 -0
  113. package/executors/sysExecutor.ts +301 -0
  114. package/executors/workspaceExecutor.ts +277 -0
  115. package/frontendBuild/allRoutesBuilder.test.ts +17 -5
  116. package/frontendBuild/allRoutesBuilder.ts +24 -6
  117. package/frontendBuild/autoImportSync.test.ts +1 -1
  118. package/frontendBuild/autoImportSync.ts +1 -1
  119. package/frontendBuild/buildRouteClient.test.ts +1 -1
  120. package/frontendBuild/bundleDefine.ts +2 -0
  121. package/frontendBuild/clientBuildTypes.ts +5 -2
  122. package/frontendBuild/clientEntriesBundler.test.ts +1 -1
  123. package/frontendBuild/clientEntryDiscovery.test.ts +28 -0
  124. package/frontendBuild/clientEntryDiscovery.ts +25 -6
  125. package/frontendBuild/csrArtifactBuilder.test.ts +1 -1
  126. package/frontendBuild/csrDevArtifactWriter.ts +1 -1
  127. package/frontendBuild/cssCompiler.test.ts +1 -1
  128. package/frontendBuild/devGeneratedIndexSync.test.ts +1 -1
  129. package/frontendBuild/devGeneratedIndexSync.ts +7 -38
  130. package/frontendBuild/dictionaryAssetBuilder.test.ts +1 -1
  131. package/frontendBuild/fontOptimizer.test.ts +1 -1
  132. package/frontendBuild/fontPruner.test.ts +1 -1
  133. package/frontendBuild/frontendBuild.test.ts +3 -3
  134. package/frontendBuild/hmrWatcher.stop.test.ts +63 -0
  135. package/frontendBuild/hmrWatcher.test.ts +1 -1
  136. package/frontendBuild/hmrWatcher.ts +22 -1
  137. package/frontendBuild/mcpAppViewBuilder.test.ts +1 -1
  138. package/frontendBuild/mcpAppViewBuilder.ts +1 -1
  139. package/frontendBuild/nativeCore.test.ts +148 -0
  140. package/frontendBuild/optionalPeers.test.ts +36 -8
  141. package/frontendBuild/pagesBundleBuilder.test.ts +2 -3
  142. package/frontendBuild/pagesBundleBuilder.ts +1 -1
  143. package/frontendBuild/precompressArtifacts.test.ts +1 -1
  144. package/frontendBuild/precompressArtifacts.ts +1 -1
  145. package/frontendBuild/serverGraphFile.ts +1 -1
  146. package/frontendBuild/sourceMtimeIndex.test.ts +1 -1
  147. package/frontendBuild/ssrBaseArtifactBuilder.test.ts +26 -0
  148. package/frontendBuild/ssrBaseArtifactBuilder.ts +23 -19
  149. package/frontendBuild/ssrDevBundler.test.ts +1 -1
  150. package/frontendBuild/vendorImportScanner.test.ts +25 -4
  151. package/frontendBuild/vendorImportScanner.ts +25 -10
  152. package/frontendBuild/vendorNarrowing.test.ts +1 -1
  153. package/frontendBuild/watchRootResolver.test.ts +1 -1
  154. package/{agentAssets.test.ts → guideline/agentAssets.test.ts} +1 -1
  155. package/{agentAssets.ts → guideline/agentAssets.ts} +2 -2
  156. package/{agentsIndex.test.ts → guideline/agentsIndex.test.ts} +2 -2
  157. package/{agentsIndex.ts → guideline/agentsIndex.ts} +13 -10
  158. package/{conventionSet.test.ts → guideline/conventionSet.test.ts} +7 -4
  159. package/{conventionSet.ts → guideline/conventionSet.ts} +1 -1
  160. package/{prompter.ts → guideline/prompter.ts} +2 -3
  161. package/incrementalBuilder/buildBatch.proc.ts +14 -4
  162. package/incrementalBuilder/buildBatchProtocol.ts +2 -0
  163. package/incrementalBuilder/buildBatchRunner.test.ts +108 -1
  164. package/incrementalBuilder/buildBatchRunner.ts +17 -4
  165. package/incrementalBuilder/builderBoot.ts +106 -0
  166. package/incrementalBuilder/builderBuildStatus.ts +23 -0
  167. package/incrementalBuilder/builderChannel.test.ts +1 -1
  168. package/incrementalBuilder/builderChannel.ts +11 -0
  169. package/incrementalBuilder/builderGraphPayloads.ts +3 -3
  170. package/incrementalBuilder/builderLanes.ts +157 -0
  171. package/incrementalBuilder/builderWatch.ts +213 -0
  172. package/incrementalBuilder/csrRegistry.ts +234 -0
  173. package/incrementalBuilder/incrementalBuilder.host.test.ts +30 -1
  174. package/incrementalBuilder/incrementalBuilder.host.ts +10 -22
  175. package/incrementalBuilder/incrementalBuilder.proc.test.ts +93 -2
  176. package/incrementalBuilder/incrementalBuilder.proc.ts +81 -823
  177. package/incrementalBuilder/ssrRegistry.ts +278 -0
  178. package/index.ts +22 -22
  179. package/integration/devStability.integration.test.ts +62 -56
  180. package/integration/devStabilityHarness.test.ts +1 -1
  181. package/lint/__fixtures__/no-import-common-err/bad.tsx +13 -0
  182. package/lint/__fixtures__/no-import-common-err/good.tsx +12 -0
  183. package/{biomeBase.test.ts → lint/biomeBase.test.ts} +1 -1
  184. package/lint/gritRules.test.ts +1 -1
  185. package/{linter.test.ts → lint/linter.test.ts} +1 -1
  186. package/lint/no-import-common-err.grit +31 -0
  187. package/lint/no-init-fetch-in-client.grit +1 -1
  188. package/lint/no-web-only-api-outside-webkit.grit +3 -3
  189. package/mobile/desktopBin.test.ts +1 -1
  190. package/mobile/desktopRelease.test.ts +1 -1
  191. package/mobile/desktopServerStage.test.ts +2 -2
  192. package/mobile/desktopServerStage.ts +1 -1
  193. package/mobile/nativeApi.test.ts +1 -1
  194. package/mobile/nativeApp.test.ts +1 -1
  195. package/mobile/nativeConfig.test.ts +1 -1
  196. package/mobile/nativePluginFolders.test.ts +1 -1
  197. package/mobile/nativePublicEnv.test.ts +1 -1
  198. package/mobile/nativeWebDir.test.ts +1 -1
  199. package/mobile/serverBundleSecrets.test.ts +1 -1
  200. package/mobile/tarWriter.test.ts +1 -1
  201. package/mobile/updatePackFolder.test.ts +1 -1
  202. package/package.json +167 -3
  203. package/packageExports.test.ts +20 -2
  204. package/piDependencyPins.test.ts +1 -1
  205. package/pipeline/PipelineDefinition.ts +1 -1
  206. package/platformTest/IdleWatchedProcess.test.ts +1 -1
  207. package/platformTest/PlatformTestRun.test.ts +1 -1
  208. package/platformTest/TestSnapshot.test.ts +1 -1
  209. package/preview/PreviewView.ts +32 -13
  210. package/preview/previewView.test.ts +33 -3
  211. package/{abstractDoc.test.ts → quality/abstractDoc.test.ts} +2 -2
  212. package/{abstractDoc.ts → quality/abstractDoc.ts} +1 -1
  213. package/quality/bareErrorScanner.ts +126 -0
  214. package/{maintainabilityBaseline.test.ts → quality/maintainabilityBaseline.test.ts} +73 -0
  215. package/{maintainabilityBaseline.ts → quality/maintainabilityBaseline.ts} +97 -9
  216. package/{maintainabilityContract.test.ts → quality/maintainabilityContract.test.ts} +383 -2
  217. package/{maintainabilityContract.ts → quality/maintainabilityContract.ts} +151 -29
  218. package/{maintainabilityExceptionScanner.test.ts → quality/maintainabilityExceptionScanner.test.ts} +15 -1
  219. package/{maintainabilityExceptionScanner.ts → quality/maintainabilityExceptionScanner.ts} +5 -1
  220. package/{maintainabilityLimits.ts → quality/maintainabilityLimits.ts} +12 -0
  221. package/{maintainabilityReport.ts → quality/maintainabilityReport.ts} +20 -3
  222. package/{qualityScanner.test.ts → quality/qualityScanner.test.ts} +1 -1
  223. package/{qualityScanner.ts → quality/qualityScanner.ts} +8 -8
  224. package/{storeAccessScanner.ts → quality/storeAccessScanner.ts} +15 -2
  225. package/{subspace.test.ts → subspace/subspace.test.ts} +25 -4
  226. package/{subspace.ts → subspace/subspace.ts} +5 -5
  227. package/{subspaceClone.ts → subspace/subspaceClone.ts} +8 -8
  228. package/{subspaceConfig.ts → subspace/subspaceConfig.ts} +5 -1
  229. package/{testHelpers.ts → test/testHelpers.ts} +37 -1
  230. package/transforms/barrelAnalyzer.ts +31 -10
  231. package/transforms/browserDirnamePlugin.test.ts +1 -1
  232. package/transforms/externalizeFrameworkPlugin.test.ts +1 -1
  233. package/transforms/mcpAppPageTrimmer.test.ts +1 -1
  234. package/transforms/pureLazyMarker.test.ts +1 -1
  235. package/transforms/serverEnvPlugin.test.ts +1 -1
  236. package/transforms/serverEnvProfile.test.ts +1 -1
  237. package/transforms/sideEffectImportOrder.test.ts +1 -1
  238. package/transforms/transforms.test.ts +52 -2
  239. package/transforms/tsconfigPackageResolver.test.ts +1 -1
  240. package/{createTunnel.test.ts → tunnel/createTunnel.test.ts} +1 -1
  241. package/{createTunnel.ts → tunnel/createTunnel.ts} +2 -2
  242. package/{sshHostKeys.ts → tunnel/sshHostKeys.ts} +2 -2
  243. package/typecheck/projectTypecheck.test.ts +1 -1
  244. package/typecheck/projectTypecheck.ts +6 -2
  245. package/{typeChecker.test.ts → typecheck/typeChecker.test.ts} +1 -1
  246. package/{typeChecker.ts → typecheck/typeChecker.ts} +1 -1
  247. package/typecheck/typecheck.proc.ts +4 -3
  248. package/typecheck/typecheckFailure.ts +7 -2
  249. package/util/errorReport.ts +66 -0
  250. package/{jsonFormatter.test.ts → util/jsonFormatter.test.ts} +1 -1
  251. package/workflow/artifacts.ts +8 -7
  252. package/workflow/constantSource.ts +187 -0
  253. package/workflow/dictionarySource.ts +184 -0
  254. package/workflow/executor.ts +6 -9
  255. package/workflow/fieldExpression.ts +153 -0
  256. package/workflow/fieldLabel.ts +61 -0
  257. package/workflow/fieldOrder.ts +117 -0
  258. package/workflow/fieldType.ts +93 -0
  259. package/workflow/guardCatalog.test.ts +1 -1
  260. package/workflow/index.ts +1 -0
  261. package/workflow/keyRename.ts +1 -1
  262. package/workflow/moduleIndex.test.ts +2 -2
  263. package/workflow/moduleIndex.ts +2 -2
  264. package/workflow/modulePaths.ts +27 -0
  265. package/workflow/mutationScaffold.ts +7 -15
  266. package/workflow/mutationSource.ts +2 -1
  267. package/workflow/plainName.ts +16 -3
  268. package/workflow/plan.ts +14 -2
  269. package/workflow/primitiveReport.ts +78 -0
  270. package/workflow/rolloutGate.test.ts +1 -1
  271. package/workflow/rolloutGate.ts +1 -1
  272. package/workflow/serviceSource.ts +33 -0
  273. package/workflow/signalSource.ts +96 -0
  274. package/workflow/source.ts +50 -1105
  275. package/workflow/sourceAst.ts +30 -0
  276. package/workflow/sourceImports.ts +105 -0
  277. package/workflow/sourceText.ts +13 -0
  278. package/workflow/templateSource.ts +30 -0
  279. package/workflow/testSource.ts +31 -0
  280. package/workflow/types.ts +1 -1
  281. package/workflow/uiPolicy.ts +1 -1
  282. package/{appSelectionMemory.ts → workspace/appSelectionMemory.ts} +1 -1
  283. package/{codegenLock.test.ts → workspace/codegenLock.test.ts} +1 -1
  284. package/{dependencyScanner.test.ts → workspace/dependencyScanner.test.ts} +1 -1
  285. package/{dependencyScanner.ts → workspace/dependencyScanner.ts} +2 -2
  286. package/{envSeed.test.ts → workspace/envSeed.test.ts} +2 -2
  287. package/{envSeed.ts → workspace/envSeed.ts} +1 -1
  288. package/{libSource.test.ts → workspace/libSource.test.ts} +2 -2
  289. package/{libSource.ts → workspace/libSource.ts} +1 -1
  290. package/{scanInfo.ts → workspace/scanInfo.ts} +21 -10
  291. package/{slicePlanner.test.ts → workspace/slicePlanner.test.ts} +2 -2
  292. package/{slicePlanner.ts → workspace/slicePlanner.ts} +1 -1
  293. package/{workspaceGraph.test.ts → workspace/workspaceGraph.test.ts} +1 -1
  294. package/{workspaceGraph.ts → workspace/workspaceGraph.ts} +1 -1
  295. package/{workspaceLayout.test.ts → workspace/workspaceLayout.test.ts} +1 -1
  296. package/{workspaceLayout.ts → workspace/workspaceLayout.ts} +3 -1
  297. package/akanContext.ts +0 -1084
  298. package/constantFieldNames.ts +0 -18
  299. package/executors.ts +0 -1749
  300. /package/{recipeScanner.ts → context/recipeScanner.ts} +0 -0
  301. /package/{declarationReader.ts → docs/declarationReader.ts} +0 -0
  302. /package/{frameworkGraph.ts → docs/frameworkGraph.ts} +0 -0
  303. /package/{biomeBase.ts → lint/biomeBase.ts} +0 -0
  304. /package/{linter.ts → lint/linter.ts} +0 -0
  305. /package/{commentDensityScanner.test.ts → quality/commentDensityScanner.test.ts} +0 -0
  306. /package/{commentDensityScanner.ts → quality/commentDensityScanner.ts} +0 -0
  307. /package/{componentSizeScanner.test.ts → quality/componentSizeScanner.test.ts} +0 -0
  308. /package/{componentSizeScanner.ts → quality/componentSizeScanner.ts} +0 -0
  309. /package/{componentWriteChainScanner.test.ts → quality/componentWriteChainScanner.test.ts} +0 -0
  310. /package/{componentWriteChainScanner.ts → quality/componentWriteChainScanner.ts} +0 -0
  311. /package/{deprecatedCommentScanner.test.ts → quality/deprecatedCommentScanner.test.ts} +0 -0
  312. /package/{deprecatedCommentScanner.ts → quality/deprecatedCommentScanner.ts} +0 -0
  313. /package/{endpointReach.test.ts → quality/endpointReach.test.ts} +0 -0
  314. /package/{endpointReach.ts → quality/endpointReach.ts} +0 -0
  315. /package/{formSetterScanner.test.ts → quality/formSetterScanner.test.ts} +0 -0
  316. /package/{formSetterScanner.ts → quality/formSetterScanner.ts} +0 -0
  317. /package/{kindBranchScanner.test.ts → quality/kindBranchScanner.test.ts} +0 -0
  318. /package/{kindBranchScanner.ts → quality/kindBranchScanner.ts} +0 -0
  319. /package/{maintainabilityReport.test.ts → quality/maintainabilityReport.test.ts} +0 -0
  320. /package/{renderMutationScanner.test.ts → quality/renderMutationScanner.test.ts} +0 -0
  321. /package/{renderMutationScanner.ts → quality/renderMutationScanner.ts} +0 -0
  322. /package/{serviceLoopCallScanner.test.ts → quality/serviceLoopCallScanner.test.ts} +0 -0
  323. /package/{serviceLoopCallScanner.ts → quality/serviceLoopCallScanner.ts} +0 -0
  324. /package/{signalMutationIndex.test.ts → quality/signalMutationIndex.test.ts} +0 -0
  325. /package/{signalMutationIndex.ts → quality/signalMutationIndex.ts} +0 -0
  326. /package/{sourceComments.test.ts → quality/sourceComments.test.ts} +0 -0
  327. /package/{sourceComments.ts → quality/sourceComments.ts} +0 -0
  328. /package/{ssrScanner.test.ts → quality/ssrScanner.test.ts} +0 -0
  329. /package/{ssrScanner.ts → quality/ssrScanner.ts} +0 -0
  330. /package/{storeAccessScanner.test.ts → quality/storeAccessScanner.test.ts} +0 -0
  331. /package/{storeSource.ts → quality/storeSource.ts} +0 -0
  332. /package/{storeWriteScanner.test.ts → quality/storeWriteScanner.test.ts} +0 -0
  333. /package/{storeWriteScanner.ts → quality/storeWriteScanner.ts} +0 -0
  334. /package/{structureScanner.test.ts → quality/structureScanner.test.ts} +0 -0
  335. /package/{structureScanner.ts → quality/structureScanner.ts} +0 -0
  336. /package/{testOnlyExportScanner.test.ts → quality/testOnlyExportScanner.test.ts} +0 -0
  337. /package/{testOnlyExportScanner.ts → quality/testOnlyExportScanner.ts} +0 -0
  338. /package/{writePath.test.ts → quality/writePath.test.ts} +0 -0
  339. /package/{writePath.ts → quality/writePath.ts} +0 -0
  340. /package/{writePlacementScanner.test.ts → quality/writePlacementScanner.test.ts} +0 -0
  341. /package/{writePlacementScanner.ts → quality/writePlacementScanner.ts} +0 -0
  342. /package/{writingActionIndex.test.ts → quality/writingActionIndex.test.ts} +0 -0
  343. /package/{writingActionIndex.ts → quality/writingActionIndex.ts} +0 -0
  344. /package/{subspaceReport.ts → subspace/subspaceReport.ts} +0 -0
  345. /package/{sshTunnel.ts → tunnel/sshTunnel.ts} +0 -0
  346. /package/{fileEditor.ts → util/fileEditor.ts} +0 -0
  347. /package/{fileSys.test.ts → util/fileSys.test.ts} +0 -0
  348. /package/{fileSys.ts → util/fileSys.ts} +0 -0
  349. /package/{jsonFormatter.ts → util/jsonFormatter.ts} +0 -0
  350. /package/{selectModel.ts → util/selectModel.ts} +0 -0
  351. /package/{semver.test.ts → util/semver.test.ts} +0 -0
  352. /package/{semver.ts → util/semver.ts} +0 -0
  353. /package/{shellOnlyEnv.test.ts → util/shellOnlyEnv.test.ts} +0 -0
  354. /package/{shellOnlyEnv.ts → util/shellOnlyEnv.ts} +0 -0
  355. /package/{spinner.test.ts → util/spinner.test.ts} +0 -0
  356. /package/{spinner.ts → util/spinner.ts} +0 -0
  357. /package/{stripAnsi.ts → util/stripAnsi.ts} +0 -0
  358. /package/{codegenLock.ts → workspace/codegenLock.ts} +0 -0
  359. /package/{getRelatedCnsts.ts → workspace/getRelatedCnsts.ts} +0 -0
  360. /package/{gitRevision.test.ts → workspace/gitRevision.test.ts} +0 -0
  361. /package/{gitRevision.ts → workspace/gitRevision.ts} +0 -0
  362. /package/{manifestDependencies.ts → workspace/manifestDependencies.ts} +0 -0
  363. /package/{packageExportsMap.ts → workspace/packageExportsMap.ts} +0 -0
  364. /package/{repoIdentity.ts → workspace/repoIdentity.ts} +0 -0
  365. /package/{types.ts → workspace/types.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import { extractBlockVersion, readDevkitVersion } from "../../guideline/agentsIndex";
4
+ import type { AkanSysContext } from "../akanContext";
5
+ import { safeReadText } from "../safeRead";
6
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
7
+
8
+ export class AgentGuideCheck {
9
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
10
+ const agentDrift = await AgentGuideCheck.#drift(workspace);
11
+ if (agentDrift)
12
+ findings.report(
13
+ { severity: "warning", code: agentDrift.code, path: "AGENTS.md", message: agentDrift.message },
14
+ repairAction("generated", "akan agent install agents-md", agentDrift.hint, true),
15
+ );
16
+ const sysPaths = systems.map((sys) => sys.path);
17
+ const oversize = await AgentGuideCheck.#oversize(workspace, sysPaths);
18
+ if (oversize)
19
+ findings.push({ severity: "warning", code: "agent-guide-oversized", path: "AGENTS.md", message: oversize });
20
+ for (const leftover of await AgentGuideCheck.#leftovers(workspace))
21
+ findings.push({ severity: "warning", code: "agent-guide-leftover", ...leftover });
22
+ }
23
+
24
+ // Nothing re-renders the AGENTS.md block on `bun update`, so the version stamp is the only staleness signal.
25
+ static async #drift(workspace: WorkspaceExecutor) {
26
+ const installed = await readDevkitVersion();
27
+ if (!installed) return null;
28
+ const content = await safeReadText(path.join(workspace.workspaceRoot, "AGENTS.md"));
29
+ if (content === null) return null;
30
+ const stamped = extractBlockVersion(content);
31
+ if (stamped === installed) return null;
32
+ const hint = "Re-render the AGENTS.md managed block from the installed framework release.";
33
+ if (!stamped)
34
+ return {
35
+ code: "agent-guide-unstamped",
36
+ message: `AGENTS.md carries no generated-version stamp, so its conventions may predate @akanjs/devkit ${installed}`,
37
+ hint,
38
+ };
39
+ return {
40
+ code: "agent-guide-stale",
41
+ message: `AGENTS.md was generated by @akanjs/devkit ${stamped}, but ${installed} is installed`,
42
+ hint,
43
+ };
44
+ }
45
+
46
+ //? Codex joins every AGENTS.md from the repo root down to its folder and drops what passes 32 KiB (`project_doc_max_bytes`).
47
+ static async #oversize(workspace: WorkspaceExecutor, sysPaths: string[]) {
48
+ const sizeOf = async (file: string) => {
49
+ const content = await safeReadText(path.join(workspace.workspaceRoot, file));
50
+ return { file, bytes: content === null ? 0 : Buffer.byteLength(content) };
51
+ };
52
+ const root = await sizeOf("AGENTS.md");
53
+ if (root.bytes === 0) return null;
54
+ const scoped = await Promise.all(sysPaths.map((sysPath) => sizeOf(`${sysPath}/AGENTS.md`)));
55
+ const largest = scoped.reduce((max, entry) => (entry.bytes > max.bytes ? entry : max), { file: "", bytes: 0 });
56
+ const total = root.bytes + largest.bytes;
57
+ if (total <= 32 * 1024 * 0.8) return null;
58
+ const subject = largest.bytes ? `AGENTS.md and ${largest.file} add up to` : "AGENTS.md is";
59
+ return `${subject} ${Math.ceil(total / 1024)} KiB of the 32 KiB Codex reads — run \`akan agent install\`, then shorten the text outside the akan:agent markers or move it into a skill.`;
60
+ }
61
+
62
+ static async #leftovers(workspace: WorkspaceExecutor) {
63
+ const root = workspace.workspaceRoot;
64
+ const guide = (await safeReadText(path.join(root, "AGENTS.md"))) ?? "";
65
+ const leftovers: { path: string; message: string }[] = [];
66
+ for (const doc of ["docs/AI-DEVELOPMENT.md", "docs/GENERATED.md"]) {
67
+ const pointer = guide.includes(doc);
68
+ if ((await safeReadText(path.join(root, doc))) !== null)
69
+ leftovers.push({
70
+ path: doc,
71
+ message: `${doc} is an older template's copy of the agent guide, and nothing reads it now — delete it${pointer ? " and the AGENTS.md sentence that points to it" : ""}.`,
72
+ });
73
+ else if (pointer)
74
+ leftovers.push({
75
+ path: "AGENTS.md",
76
+ message: `AGENTS.md points to ${doc}, which is gone — delete that sentence.`,
77
+ });
78
+ }
79
+ return leftovers;
80
+ }
81
+ }
@@ -0,0 +1,35 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { safeReadText } from "../safeRead";
5
+ import type { DoctorFindings } from "./doctorFindings";
6
+
7
+ export class ConfigLeftoverCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ const sysPaths = systems.map((sys) => sys.path);
10
+ for (const leftover of await ConfigLeftoverCheck.#leftovers(workspace, sysPaths))
11
+ findings.push({ severity: "warning", code: "config-leftover", ...leftover });
12
+ }
13
+
14
+ //? Older templates wrote these for Next.js: nothing installs or reads them, and editors warn about the plugin.
15
+ static async #leftovers(workspace: WorkspaceExecutor, sysPaths: string[]) {
16
+ const leftovers: { path: string; message: string }[] = [];
17
+ for (const sysPath of sysPaths) {
18
+ const tsconfigPath = `${sysPath}/tsconfig.json`;
19
+ const tsconfig = await safeReadText(path.join(workspace.workspaceRoot, tsconfigPath));
20
+ if (tsconfig && (/"name"\s*:\s*"next"/.test(tsconfig) || tsconfig.includes(".next/types")))
21
+ leftovers.push({
22
+ path: tsconfigPath,
23
+ message: `${tsconfigPath} still names the Next.js TS plugin or .next/types, which Akan never uses — delete the "next" plugin entry and the ".next/types/**/*.ts" include.`,
24
+ });
25
+ }
26
+ const bunfig = await safeReadText(path.join(workspace.workspaceRoot, "bunfig.toml"));
27
+ if (bunfig?.includes("bun-plugin-tailwind"))
28
+ leftovers.push({
29
+ path: "bunfig.toml",
30
+ message:
31
+ "bunfig.toml still loads bun-plugin-tailwind, which is not installed and which Akan never uses (it compiles Tailwind itself) — delete the [serve.static] section, which Akan never reads.",
32
+ });
33
+ return leftovers;
34
+ }
35
+ }
@@ -0,0 +1,70 @@
1
+ import type { WorkspaceExecutor } from "../../executors";
2
+ import type { RepairAction } from "../../workflow";
3
+ import type { AkanDiagnostic, AkanDoctorResult, AkanWorkspaceContext } from "../akanContext";
4
+ import { generatedFreshnessFromStates } from "./generatedFreshness";
5
+ import { isWorkflowRelatedDiagnostic } from "./workflowScope";
6
+
7
+ export const repairAction = (
8
+ kind: RepairAction["kind"],
9
+ command: string,
10
+ reason: string,
11
+ safeToRun: boolean,
12
+ ): RepairAction => ({
13
+ kind,
14
+ command,
15
+ reason,
16
+ safeToRun,
17
+ });
18
+
19
+ export class DoctorFindings {
20
+ readonly #diagnostics: AkanDiagnostic[] = [];
21
+ readonly #repairActions: RepairAction[] = [
22
+ repairAction("generated", "akan repair generated --app <app-or-lib>", "Refresh generated Akan files.", true),
23
+ repairAction(
24
+ "format",
25
+ "akan repair format --target <app-or-lib-or-pkg>",
26
+ "Run the formatter/linter repair path.",
27
+ true,
28
+ ),
29
+ ];
30
+
31
+ report(diagnostic: AkanDiagnostic, action: RepairAction) {
32
+ this.#diagnostics.push({ ...diagnostic, repairActions: [action] });
33
+ this.#repairActions.push(action);
34
+ }
35
+
36
+ push(diagnostic: AkanDiagnostic) {
37
+ this.#diagnostics.push(diagnostic);
38
+ }
39
+
40
+ async result(
41
+ workspace: WorkspaceExecutor,
42
+ context: AkanWorkspaceContext,
43
+ { strict, workflowPaths }: { strict: boolean; workflowPaths: string[] },
44
+ ): Promise<AkanDoctorResult> {
45
+ const scopedDiagnostics = this.#diagnostics.map((diagnostic) => ({
46
+ ...diagnostic,
47
+ scope: workflowPaths.length
48
+ ? isWorkflowRelatedDiagnostic(diagnostic, workflowPaths)
49
+ ? ("workflow" as const)
50
+ : ("baseline" as const)
51
+ : diagnostic.scope,
52
+ context: workflowPaths.length ? { ...diagnostic.context, paths: workflowPaths } : diagnostic.context,
53
+ }));
54
+ const workflowDiagnostics = scopedDiagnostics.filter((diagnostic) => diagnostic.scope === "workflow");
55
+ const baselineDiagnostics = scopedDiagnostics.filter((diagnostic) => diagnostic.scope === "baseline");
56
+ return {
57
+ schemaVersion: 1,
58
+ repoName: context.repoName,
59
+ root: context.root,
60
+ strict,
61
+ status: scopedDiagnostics.some((diagnostic) => diagnostic.severity === "error") ? "failed" : "passed",
62
+ diagnostics: scopedDiagnostics,
63
+ generatedFiles: context.generatedFiles,
64
+ generatedFilesFreshness: await generatedFreshnessFromStates(workspace),
65
+ validationCommands: context.validationCommands,
66
+ repairActions: this.#repairActions,
67
+ ...(workflowPaths.length ? { baselineDiagnostics, workflowDiagnostics } : {}),
68
+ };
69
+ }
70
+ }
@@ -0,0 +1,56 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import { type GeneratedSyncState, workflowSyncDir } from "../../workflow";
4
+ import type { GeneratedFilesFreshness } from "../akanContext";
5
+ import { safeReadDir, safeReadJson } from "../safeRead";
6
+
7
+ const unknownGeneratedFilesFreshness: GeneratedFilesFreshness = {
8
+ status: "unknown" as const,
9
+ message: "Run sync before validation so generated Akan files match the current source conventions.",
10
+ refreshCommand: "akan sync <app-or-lib>",
11
+ verifyingCommands: ["akan verify <app-or-lib>"],
12
+ };
13
+
14
+ const readGeneratedSyncStates = async (workspace: WorkspaceExecutor) => {
15
+ const syncDir = path.join(workspace.workspaceRoot, workflowSyncDir);
16
+ const entries = await safeReadDir(syncDir);
17
+ const states = await Promise.all(
18
+ entries
19
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
20
+ .map((entry) => safeReadJson<GeneratedSyncState>(path.join(syncDir, entry.name))),
21
+ );
22
+ return states.filter(
23
+ (state): state is GeneratedSyncState =>
24
+ !!state && state.schemaVersion === 1 && typeof state.target === "string" && typeof state.syncedAt === "string",
25
+ );
26
+ };
27
+
28
+ export const generatedFreshnessFromStates = async (workspace: WorkspaceExecutor): Promise<GeneratedFilesFreshness> => {
29
+ const states = await readGeneratedSyncStates(workspace);
30
+ if (states.length === 0) return unknownGeneratedFilesFreshness;
31
+ const targets = states
32
+ .sort((a, b) => a.target.localeCompare(b.target))
33
+ .map((state) => ({
34
+ target: state.target,
35
+ status: state.status === "passed" ? ("fresh" as const) : ("stale" as const),
36
+ lastSyncedAt: state.syncedAt,
37
+ runId: state.runId,
38
+ generatedFiles: state.generatedFiles.map((file) => file.path),
39
+ reason:
40
+ state.status === "passed"
41
+ ? `Generated files were refreshed by ${state.command}.`
42
+ : `Last generated repair command failed: ${state.command}.`,
43
+ }));
44
+ const lastFresh = targets
45
+ .filter((target) => target.status === "fresh" && target.lastSyncedAt)
46
+ .sort((a, b) => (b.lastSyncedAt ?? "").localeCompare(a.lastSyncedAt ?? ""))[0];
47
+ return {
48
+ status: targets.some((target) => target.status === "fresh") ? "fresh" : "stale",
49
+ message: lastFresh
50
+ ? `Generated files were refreshed for ${lastFresh.target} at ${lastFresh.lastSyncedAt}.`
51
+ : "Generated sync state exists, but the last recorded repair did not pass.",
52
+ refreshCommand: "akan sync <app-or-lib>",
53
+ verifyingCommands: ["akan verify <app-or-lib>"],
54
+ targets,
55
+ };
56
+ };
@@ -0,0 +1,88 @@
1
+ import path from "node:path";
2
+ import { capitalize } from "akanjs/common";
3
+ import type { WorkspaceExecutor } from "../../executors";
4
+ import type { AkanModuleContext, AkanSysContext } from "../akanContext";
5
+ import { unlabeledFieldNames } from "../moduleFieldNames";
6
+ import { safeReadText } from "../safeRead";
7
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
8
+
9
+ const moduleShapeFiles = (module: AkanModuleContext) => {
10
+ if (module.kind === "service") {
11
+ return [`${module.name}.dictionary.ts`, `${module.name}.service.ts`, `${module.name}.signal.ts`];
12
+ }
13
+ if (module.kind === "scalar") return [`${module.name}.constant.ts`, `${module.name}.dictionary.ts`];
14
+ return [
15
+ `${module.name}.constant.ts`,
16
+ `${module.name}.dictionary.ts`,
17
+ `${module.name}.service.ts`,
18
+ `${module.name}.store.ts`,
19
+ `${module.name}.signal.ts`,
20
+ ];
21
+ };
22
+
23
+ export class ModuleShapeCheck {
24
+ static async run(
25
+ workspace: WorkspaceExecutor,
26
+ systems: AkanSysContext[],
27
+ findings: DoctorFindings,
28
+ { strict }: { strict: boolean },
29
+ ) {
30
+ for (const sys of systems) {
31
+ for (const module of sys.modules) {
32
+ const moduleShapeCommand = `akan repair module-shape --app ${sys.name} --module ${module.name}`;
33
+ if (!module.abstract.exists)
34
+ findings.report(
35
+ {
36
+ severity: strict ? "error" : "warning",
37
+ code: "module-abstract-missing",
38
+ path: module.abstract.path,
39
+ message: `${capitalize(module.kind)} module ${sys.name}:${module.name} should include ${module.abstract.path}`,
40
+ },
41
+ repairAction(
42
+ "module-shape",
43
+ moduleShapeCommand,
44
+ "Create the missing module abstract or inspect required source files.",
45
+ false,
46
+ ),
47
+ );
48
+ const missingFiles = moduleShapeFiles(module).filter((filename) => !module.files.includes(filename));
49
+ if (missingFiles.length)
50
+ findings.report(
51
+ {
52
+ severity: "error",
53
+ code: "module-shape-invalid",
54
+ path: module.path,
55
+ message: `${capitalize(module.kind)} module ${sys.name}:${module.name} is missing required files: ${missingFiles.join(", ")}`,
56
+ },
57
+ repairAction("module-shape", moduleShapeCommand, "Review missing required module source files.", false),
58
+ );
59
+ if (module.kind !== "service" && module.files.includes(`${module.name}.dictionary.ts`)) {
60
+ const constantPath = path.join(workspace.workspaceRoot, module.path, `${module.name}.constant.ts`);
61
+ const dictionaryPath = path.join(workspace.workspaceRoot, module.path, `${module.name}.dictionary.ts`);
62
+ const [constantContent, dictionaryContent] = await Promise.all([
63
+ safeReadText(constantPath),
64
+ safeReadText(dictionaryPath),
65
+ ]);
66
+ if (constantContent && dictionaryContent) {
67
+ for (const fieldName of unlabeledFieldNames(constantContent, dictionaryContent)) {
68
+ findings.report(
69
+ {
70
+ severity: "warning",
71
+ code: "dictionary-label-missing",
72
+ path: `${module.path}/${module.name}.dictionary.ts`,
73
+ message: `Dictionary labels for ${sys.name}:${module.name}.${fieldName} were not found.`,
74
+ },
75
+ repairAction(
76
+ "dictionary",
77
+ `akan repair dictionary --app ${sys.name} --module ${module.name}`,
78
+ "Add missing dictionary labels for source constant fields.",
79
+ false,
80
+ ),
81
+ );
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,39 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { collectRecipeSources, findInlineRecipeDuplicates, scanRecipes } from "../recipeScanner";
5
+ import type { DoctorFindings } from "./doctorFindings";
6
+
7
+ export class RecipeDuplicateCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ //* Advisory only (warning): promoted to lint only if inline re-authoring actually recurs.
10
+ for (const sys of systems) {
11
+ const sources = await collectRecipeSources(path.join(workspace.workspaceRoot, sys.path, "ui"), "ui");
12
+ if (sources.length === 0) continue;
13
+ const recipes = scanRecipes(sources);
14
+ const files: { path: string; content: string }[] = [];
15
+ const glob = new Bun.Glob("**/*.tsx");
16
+ for await (const abs of glob.scan({ cwd: path.join(workspace.workspaceRoot, sys.path), absolute: true })) {
17
+ if (/[\\/](node_modules|\.akan|dist)[\\/]|[\\/]v1[\\/]/.test(abs) || /\.(test|spec)\.tsx$/.test(abs)) continue;
18
+ files.push({
19
+ path: abs,
20
+ content: await Bun.file(abs)
21
+ .text()
22
+ .catch(() => ""),
23
+ });
24
+ }
25
+ const duplicates = findInlineRecipeDuplicates(recipes, files);
26
+ if (duplicates.length === 0) continue;
27
+ const preview = duplicates
28
+ .slice(0, 3)
29
+ .map((duplicate) => `${path.relative(workspace.workspaceRoot, duplicate.path)}:${duplicate.line}`)
30
+ .join(", ");
31
+ findings.push({
32
+ severity: "warning",
33
+ code: "recipe-inline-duplicate",
34
+ path: path.join(sys.path, "ui/Recipe"),
35
+ message: `${sys.name}: ${duplicates.length} inline className(s) re-author a recipe fingerprint (${preview}${duplicates.length > 3 ? ", …" : ""}) — consume the recipe instead.`,
36
+ });
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,87 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import type { AkanSysContext } from "../akanContext";
4
+ import { collectRecipeSources, scanRecipes } from "../recipeScanner";
5
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
6
+
7
+ export class RecipeIndexCheck {
8
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
9
+ // Doctor never writes, so this is what catches a committed stale recipe index (lint and sync self-heal the tree).
10
+ const scanNames = async (uiDirPath: string, basename?: string) =>
11
+ new Set(scanRecipes(await collectRecipeSources(uiDirPath, "ui", basename)).map((info) => info.name));
12
+ const declaredByImport = new Map<string, Set<string>>();
13
+ declaredByImport.set("akanjs/ui", await scanNames(path.join(workspace.workspaceRoot, "pkgs/akanjs/ui"), "recipe"));
14
+ for (const sys of systems)
15
+ declaredByImport.set(`@${sys.path}/ui`, await scanNames(path.join(workspace.workspaceRoot, sys.path, "ui")));
16
+ // Section slice anchors the heading to a full line — the same string appears back-ticked in prose.
17
+ const sectionOf = (content: string, heading: string) => {
18
+ const match = new RegExp(`^${heading}$`, "m").exec(content);
19
+ if (!match) return "";
20
+ const section = content.slice(match.index);
21
+ const sectionEnd = section.indexOf("\n## ", 1);
22
+ return sectionEnd === -1 ? section : section.slice(0, sectionEnd);
23
+ };
24
+ // `Import from \`<path>\`:` groups with their `- \`name\`` items, so each name checks against its owner.
25
+ const listedByImport = (body: string) => {
26
+ const groups = new Map<string, Set<string>>();
27
+ let current: Set<string> | null = null;
28
+ for (const line of body.split("\n")) {
29
+ const group = /^Import from `([^`]+)`:/.exec(line);
30
+ if (group) {
31
+ current = groups.get(group[1]) ?? new Set();
32
+ groups.set(group[1], current);
33
+ continue;
34
+ }
35
+ const item = /^- `([A-Za-z0-9_$]+)`/.exec(line);
36
+ if (item && current) current.add(item[1]);
37
+ else if (!item) current = null;
38
+ }
39
+ return groups;
40
+ };
41
+ const pushIndexDiagnostic = (indexPath: string, missing: string[], stale: string[], repairCommand: string) => {
42
+ if (missing.length === 0 && stale.length === 0) return;
43
+ const parts = [
44
+ missing.length > 0 ? `${missing.length} declared but unlisted (${missing.slice(0, 5).join(", ")})` : "",
45
+ stale.length > 0 ? `${stale.length} listed but gone (${stale.slice(0, 5).join(", ")})` : "",
46
+ ].filter(Boolean);
47
+ findings.report(
48
+ {
49
+ severity: "error",
50
+ code: "recipe-index-stale",
51
+ path: indexPath,
52
+ message: `${indexPath} recipe index is out of date — ${parts.join("; ")}. Agents read this list as authoritative.`,
53
+ },
54
+ repairAction("generated", repairCommand, "Regenerate the recipe index from the scanned recipes.", true),
55
+ );
56
+ };
57
+ const frameworkDeclared = declaredByImport.get("akanjs/ui") ?? new Set<string>();
58
+ if (frameworkDeclared.size > 0) {
59
+ const agentsMd = await Bun.file(path.join(workspace.workspaceRoot, "AGENTS.md"))
60
+ .text()
61
+ .catch(() => "");
62
+ const listed = listedByImport(sectionOf(agentsMd, "## Recipes")).get("akanjs/ui") ?? new Set<string>();
63
+ pushIndexDiagnostic(
64
+ "AGENTS.md",
65
+ [...frameworkDeclared].filter((name) => !listed.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
66
+ [...listed].filter((name) => !frameworkDeclared.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)),
67
+ "akan agent install agents-md",
68
+ );
69
+ }
70
+ for (const sys of systems) {
71
+ const own = declaredByImport.get(`@${sys.path}/ui`) ?? new Set<string>();
72
+ const scopeMd = await Bun.file(path.join(workspace.workspaceRoot, sys.path, "AGENTS.md"))
73
+ .text()
74
+ .catch(() => "");
75
+ const groups = listedByImport(sectionOf(scopeMd, "## Recipes In Scope"));
76
+ const ownListed = groups.get(`@${sys.path}/ui`) ?? new Set<string>();
77
+ const missing = [...own].filter((name) => !ownListed.has(name)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
78
+ // Every listed name — the scope's own and its dependency libs' — must still exist at its owner.
79
+ const stale = [...groups.entries()]
80
+ .flatMap(([importFrom, names]) =>
81
+ [...names].filter((name) => !(declaredByImport.get(importFrom) ?? new Set()).has(name)),
82
+ )
83
+ .sort();
84
+ pushIndexDiagnostic(`${sys.path}/AGENTS.md`, missing, stale, `akan sync ${sys.name}`);
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,55 @@
1
+ import path from "node:path";
2
+ import type { WorkspaceExecutor } from "../../executors";
3
+ import {
4
+ barrelFacetDirs,
5
+ facetIndexShadowOf,
6
+ isScannedRootEntry,
7
+ rootAllowedDirs,
8
+ rootAllowedFiles,
9
+ rootEntryHintOf,
10
+ } from "../../workspace/workspaceLayout";
11
+ import type { AkanSysContext } from "../akanContext";
12
+ import { safeReadDir } from "../safeRead";
13
+ import { type DoctorFindings, repairAction } from "./doctorFindings";
14
+
15
+ export class RootShapeCheck {
16
+ static async run(workspace: WorkspaceExecutor, systems: AkanSysContext[], findings: DoctorFindings) {
17
+ for (const sys of systems) {
18
+ const sysPath = path.join(workspace.workspaceRoot, sys.path);
19
+ for (const entry of await safeReadDir(sysPath)) {
20
+ if (!isScannedRootEntry(sys.type, entry.name)) continue;
21
+ const allowed = entry.isDirectory()
22
+ ? rootAllowedDirs[sys.type].has(entry.name)
23
+ : rootAllowedFiles[sys.type].has(entry.name);
24
+ const rootEntryHint = rootEntryHintOf(sys.type, entry.name);
25
+ if (!allowed)
26
+ findings.report(
27
+ {
28
+ severity: "error",
29
+ code: `${sys.type}-root-unknown-entry`,
30
+ path: `${sys.path}/${entry.name}`,
31
+ message: `Unexpected ${entry.isDirectory() ? "folder" : "file"} in ${sys.type} root: ${sys.path}/${entry.name}${
32
+ rootEntryHint ? ` (${rootEntryHint})` : ""
33
+ }`,
34
+ },
35
+ repairAction(
36
+ "module-shape",
37
+ `akan repair module-shape --app ${sys.name}`,
38
+ `Review ${sys.type} root shape and remove or move the unknown entry.`,
39
+ false,
40
+ ),
41
+ );
42
+ }
43
+ for (const facet of barrelFacetDirs)
44
+ for (const entry of await safeReadDir(path.join(sysPath, facet))) {
45
+ const shadow = entry.isDirectory() ? null : facetIndexShadowOf(`${facet}/${entry.name}`);
46
+ if (!shadow) continue;
47
+ const entryPath = `${sys.path}/${facet}/${entry.name}`;
48
+ findings.report(
49
+ { severity: "error", code: "facet-index-shadowed", path: entryPath, message: `${entryPath} ${shadow}` },
50
+ repairAction("generated", `akan sync ${sys.name}`, `Delete ${entryPath} by hand, then sync.`, false),
51
+ );
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,97 @@
1
+ import path from "node:path";
2
+ import { isRecord } from "akanjs/common";
3
+ import type { WorkspaceExecutor } from "../../executors";
4
+ import {
5
+ type WorkflowApplyReport,
6
+ type WorkflowPlan,
7
+ type WorkflowRunArtifact,
8
+ workflowPathsForPlan,
9
+ workflowRunArtifactPath,
10
+ } from "../../workflow";
11
+ import type { AkanDiagnostic } from "../akanContext";
12
+ import { safeReadJson } from "../safeRead";
13
+
14
+ const isWorkflowPlan = (value: unknown): value is WorkflowPlan =>
15
+ typeof value === "object" &&
16
+ value !== null &&
17
+ "schemaVersion" in value &&
18
+ value.schemaVersion === 1 &&
19
+ "mode" in value &&
20
+ value.mode === "plan" &&
21
+ "inputs" in value &&
22
+ isRecord(value.inputs) &&
23
+ "predictedChanges" in value &&
24
+ Array.isArray(value.predictedChanges) &&
25
+ value.predictedChanges.every((change) => isRecord(change) && typeof change.target === "string");
26
+
27
+ const isPathList = (value: unknown) =>
28
+ Array.isArray(value) && value.every((file) => isRecord(file) && typeof file.path === "string");
29
+
30
+ const isWorkflowApplyReport = (value: unknown): value is WorkflowApplyReport =>
31
+ typeof value === "object" &&
32
+ value !== null &&
33
+ "schemaVersion" in value &&
34
+ value.schemaVersion === 1 &&
35
+ "mode" in value &&
36
+ (value.mode === "apply" || value.mode === "dry-run") &&
37
+ "changedFiles" in value &&
38
+ isPathList(value.changedFiles) &&
39
+ "generatedFiles" in value &&
40
+ isPathList(value.generatedFiles) &&
41
+ "plan" in value &&
42
+ isWorkflowPlan(value.plan);
43
+
44
+ const isWorkflowRunArtifact = (value: unknown): value is WorkflowRunArtifact =>
45
+ typeof value === "object" && value !== null && "schemaVersion" in value && value.schemaVersion === 1;
46
+
47
+ const workflowPathsForArtifact = (artifact: WorkflowRunArtifact) => {
48
+ if (isWorkflowPlan(artifact)) return workflowPathsForPlan(artifact);
49
+ if (isWorkflowApplyReport(artifact)) {
50
+ return [
51
+ ...artifact.changedFiles.map((file) => file.path),
52
+ ...artifact.generatedFiles.map((file) => file.path),
53
+ ...workflowPathsForPlan(artifact.plan),
54
+ ];
55
+ }
56
+ if ("mode" in artifact && artifact.mode === "validate" && isWorkflowPlan(artifact.plan))
57
+ return workflowPathsForPlan(artifact.plan);
58
+ return [];
59
+ };
60
+
61
+ export const loadWorkflowContextPaths = async (
62
+ workspace: WorkspaceExecutor,
63
+ runIdOrPlan: string | null,
64
+ changedFiles: string[],
65
+ ) => {
66
+ const paths = [...changedFiles];
67
+ if (!runIdOrPlan) return paths;
68
+ const inputPath = path.isAbsolute(runIdOrPlan) ? runIdOrPlan : path.join(workspace.workspaceRoot, runIdOrPlan);
69
+ const artifact =
70
+ (await safeReadJson<WorkflowRunArtifact | WorkflowPlan>(inputPath)) ??
71
+ (await safeReadJson<WorkflowRunArtifact>(path.join(workspace.workspaceRoot, workflowRunArtifactPath(runIdOrPlan))));
72
+ if (artifact && isWorkflowRunArtifact(artifact)) paths.push(...workflowPathsForArtifact(artifact));
73
+ return [...new Set(paths.filter(Boolean))];
74
+ };
75
+
76
+ const withoutPlaceholders = (value: string) =>
77
+ value
78
+ .split("<")
79
+ .map((part, index) => (index === 0 ? part : part.slice(part.indexOf(">") + 1)))
80
+ .join("");
81
+
82
+ const pathKey = (value: string) =>
83
+ withoutPlaceholders(value.replaceAll("\\", "/").replaceAll("*", ""))
84
+ .replace(/\/+/g, "/")
85
+ .replace(/^\/|\/$/g, "");
86
+
87
+ export const isWorkflowRelatedDiagnostic = (diagnostic: AkanDiagnostic, workflowPaths: string[]) => {
88
+ if (!diagnostic.path) return false;
89
+ const diagnosticPath = pathKey(diagnostic.path);
90
+ return workflowPaths.some((workflowPath) => {
91
+ const candidate = pathKey(workflowPath);
92
+ if (!candidate) return false;
93
+ return (
94
+ diagnosticPath.startsWith(candidate) || candidate.startsWith(diagnosticPath) || diagnosticPath.includes(candidate)
95
+ );
96
+ });
97
+ };
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "bun:test";
2
- import { constantFieldNames } from "./constantFieldNames";
2
+ import { constantFieldNames, unlabeledFieldNames } from "./moduleFieldNames";
3
3
 
4
- describe("constantFieldNames", () => {
4
+ describe("moduleFieldNames", () => {
5
5
  test("names each field the code declares, chained or not", () => {
6
6
  const content = `export class TaskInput extends via((field) => ({
7
7
  title: field(String),
@@ -31,4 +31,26 @@ export const example = \`previousStatus: field(TaskStatus)\`;
31
31
 
32
32
  expect(constantFieldNames(content)).toEqual(["title", "note"]);
33
33
  });
34
+
35
+ test("unlabeledFieldNames finds a real label and reports one that is only commented out or inside a string", () => {
36
+ const constant = `export class TaskInput extends via((field) => ({
37
+ title: field(String),
38
+ content: field(String),
39
+ status: field(TaskStatus),
40
+ due: field(Date).optional(),
41
+ })) {}
42
+ `;
43
+ const dictionary = `export const dictionary = modelDictionary(["en", "ko"])
44
+ .model<Task>((t) => ({
45
+ title: t(["Title", "제목"]).desc(["Task title", "할 일 제목"]),
46
+ // content: t(["Content", "내용"]),
47
+ /* status: t(["Status", "상태"]), */
48
+ }))
49
+ .translate({
50
+ taskDueHint: ["due: pick a date", "마감: 날짜를 고르세요"],
51
+ });
52
+ `;
53
+
54
+ expect(unlabeledFieldNames(constant, dictionary)).toEqual(["content", "status", "due"]);
55
+ });
34
56
  });