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

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 (360) hide show
  1. package/DEV_RUNTIME_KNOBS.md +1 -1
  2. package/README.ko.md +10 -3
  3. package/README.md +10 -4
  4. package/akanApp/akanApp.host.test.ts +4 -2
  5. package/akanApp/akanApp.host.ts +26 -2
  6. package/akanApp/akanApp.host.wiring.test.ts +111 -0
  7. package/akanApp/devHostPolicy.ts +5 -0
  8. package/akanApp/devMetadataRestart.ts +93 -0
  9. package/akanApp/devRecycler.test.ts +2 -0
  10. package/akanApp/devRecycler.ts +9 -0
  11. package/akanConfig/akanBin.ts +4 -0
  12. package/akanConfig/akanConfig.test.ts +358 -21
  13. package/akanConfig/akanConfig.ts +113 -272
  14. package/akanConfig/akanPreview.test.ts +28 -0
  15. package/akanConfig/akanPreview.ts +24 -0
  16. package/akanConfig/akanWorkers.test.ts +73 -0
  17. package/akanConfig/akanWorkers.ts +61 -0
  18. package/akanConfig/desktopServerConfig.ts +96 -0
  19. package/akanConfig/dockerImage.ts +250 -0
  20. package/akanConfig/index.ts +3 -0
  21. package/akanConfig/nativeFileSettings.ts +33 -0
  22. package/akanConfig/nativeKeys.ts +52 -0
  23. package/akanConfig/types.ts +4 -0
  24. package/app/appBin.test.ts +63 -0
  25. package/app/appBin.ts +50 -0
  26. package/app/applicationBuildReporter.test.ts +51 -1
  27. package/app/applicationBuildReporter.ts +6 -1
  28. package/app/applicationBuildRunner.test.ts +427 -5
  29. package/app/applicationBuildRunner.ts +232 -37
  30. package/app/clientServerBoundary.test.ts +115 -0
  31. package/app/clientServerBoundary.ts +89 -0
  32. package/app/dictionarySizes.test.ts +40 -0
  33. package/app/dictionarySizes.ts +95 -0
  34. package/app/routeFilesReport.test.ts +59 -0
  35. package/app/routeFilesReport.ts +46 -0
  36. package/app/routeJsBudget.ts +18 -4
  37. package/artifact/implicitRootLayout.test.ts +19 -0
  38. package/artifact/implicitRootLayout.ts +16 -2
  39. package/artifact/implicitRootLayoutRender.test.tsx +4 -1
  40. package/artifact/storeBootstrap.test.ts +28 -0
  41. package/artifact/storeBootstrap.ts +64 -8
  42. package/biome.base.json +7 -5
  43. package/codeAgent/index.ts +1 -34
  44. package/codeAgent/skills/akan-agent/SKILL.md +8 -1
  45. package/codeAgent/skills/akan-code/SKILL.md +38 -3
  46. package/codeAgent/skills/akan-debug/SKILL.md +8 -3
  47. package/codeAgent/skills/akan-deps/SKILL.md +10 -3
  48. package/codeAgent/skills/akan-err/SKILL.md +13 -8
  49. package/codeAgent/skills/akan-mcp/SKILL.md +1 -1
  50. package/codeAgent/skills/akan-module/SKILL.md +2 -2
  51. package/codeAgent/skills/akan-page/SKILL.md +65 -30
  52. package/codeAgent/skills/akan-query/SKILL.md +13 -20
  53. package/codeAgent/skills/akan-runtime/SKILL.md +21 -1
  54. package/codeAgent/skills/akan-service/SKILL.md +21 -20
  55. package/codeAgent/skills/akan-transport/SKILL.md +5 -14
  56. package/codeAgent/skills/akan-ui/SKILL.md +16 -21
  57. package/codeAgent/skills/akan-validate/SKILL.md +8 -2
  58. package/commandDecorators/command.ts +28 -12
  59. package/commandDecorators/commandBuilder.ts +8 -1
  60. package/commandDecorators/commandDecorators.test.ts +70 -3
  61. package/commandDecorators/helpFormatter.ts +14 -12
  62. package/context/akanContext.ts +2 -0
  63. package/csrE2e/devHmrLatency.e2e.test.ts +1 -1
  64. package/csrE2e/ssrRegistry.e2e.test.ts +108 -22
  65. package/docs/apiReference.test.ts +25 -0
  66. package/docs/apiReference.ts +38 -5
  67. package/docs/declarationReader.ts +30 -0
  68. package/executors/appExecutor.ts +26 -12
  69. package/executors/clientRuntimeKeyOrder.fixture.json +682 -0
  70. package/executors/clientRuntimeKeys.fixture.json +393 -0
  71. package/executors/clientRuntimeKeys.test.ts +1690 -0
  72. package/executors/executor.ts +14 -6
  73. package/executors/executors.test.ts +155 -1
  74. package/executors/pkgExecutor.ts +2 -1
  75. package/executors/sysExecutor.ts +112 -8
  76. package/executors/workspaceExecutor.ts +7 -4
  77. package/frontendBuild/allRoutesBuilder.ts +99 -7
  78. package/frontendBuild/autoImportSync.ts +3 -2
  79. package/frontendBuild/buildRouteClient.test.ts +686 -13
  80. package/frontendBuild/clientBuildTypes.ts +26 -0
  81. package/frontendBuild/clientEntriesBundler.ts +49 -1
  82. package/frontendBuild/clientEntryDiscovery.test.ts +308 -1
  83. package/frontendBuild/clientEntryDiscovery.ts +136 -14
  84. package/frontendBuild/clientEntryGroups.test.ts +77 -0
  85. package/frontendBuild/clientEntryGroups.ts +61 -0
  86. package/frontendBuild/csrDevArtifactWriter.ts +2 -2
  87. package/frontendBuild/csrDevModuleCompiler.test.ts +86 -0
  88. package/frontendBuild/csrDevModuleCompiler.ts +44 -8
  89. package/frontendBuild/csrDevPatcher.test.ts +4 -5
  90. package/frontendBuild/csrDevPatcher.ts +37 -11
  91. package/frontendBuild/csrDevTypes.ts +9 -0
  92. package/frontendBuild/devBarrelImports.test.ts +154 -0
  93. package/frontendBuild/devBarrelImports.ts +83 -23
  94. package/frontendBuild/devChangePlanner.ts +0 -1
  95. package/frontendBuild/devRegistryBundler.ts +4 -2
  96. package/frontendBuild/devRouteRuntime.test.ts +492 -0
  97. package/frontendBuild/devRouteRuntime.ts +167 -0
  98. package/frontendBuild/dictionaryAssetBuilder.test.ts +408 -0
  99. package/frontendBuild/dictionaryAssetBuilder.ts +185 -17
  100. package/frontendBuild/dictionaryConstants.ts +136 -0
  101. package/frontendBuild/dictionaryOwnParts.ts +88 -0
  102. package/frontendBuild/dictionaryPackState.ts +131 -0
  103. package/frontendBuild/dictionaryPacking.test.ts +207 -0
  104. package/frontendBuild/dictionaryPacking.ts +160 -0
  105. package/frontendBuild/dictionaryRoutes.test.ts +251 -0
  106. package/frontendBuild/dictionaryRoutes.ts +227 -0
  107. package/frontendBuild/frontendBuild.test.ts +5 -3
  108. package/frontendBuild/pagesBundleBuilder.test.ts +84 -0
  109. package/frontendBuild/pagesBundleBuilder.ts +78 -2
  110. package/frontendBuild/precompressArtifacts.test.ts +22 -0
  111. package/frontendBuild/precompressArtifacts.ts +34 -8
  112. package/frontendBuild/registryMetadataFingerprint.ts +3 -3
  113. package/frontendBuild/renderedEntries.ts +144 -0
  114. package/frontendBuild/routeClientBuilder.ts +407 -43
  115. package/frontendBuild/routeHandoffs.test.ts +155 -0
  116. package/frontendBuild/routeHandoffs.ts +117 -0
  117. package/frontendBuild/routeModulePreloads.test.ts +32 -0
  118. package/frontendBuild/routeModulePreloads.ts +20 -11
  119. package/frontendBuild/routeRuntimeCheck.test.ts +280 -0
  120. package/frontendBuild/routeRuntimeCheck.ts +248 -0
  121. package/frontendBuild/routeRuntimePays.test.ts +143 -0
  122. package/frontendBuild/routeRuntimePays.ts +117 -0
  123. package/frontendBuild/ssrBaseArtifactBuilder.ts +30 -35
  124. package/frontendBuild/ssrDevBundler.test.ts +150 -1
  125. package/frontendBuild/ssrDevBundler.ts +66 -11
  126. package/frontendBuild/vendorFileImports.test.ts +254 -0
  127. package/frontendBuild/vendorFileImports.ts +163 -0
  128. package/frontendBuild/vendorNarrowing.test.ts +47 -3
  129. package/frontendBuild/vendorNarrowing.ts +38 -2
  130. package/frontendBuild/vendorSpecifiers.ts +2 -0
  131. package/guideline/agentAssets.ts +1 -1
  132. package/incrementalBuilder/buildBatch.proc.ts +35 -9
  133. package/incrementalBuilder/buildBatchProtocol.ts +2 -1
  134. package/incrementalBuilder/builderBoot.ts +5 -5
  135. package/incrementalBuilder/builderGraphPayloads.ts +4 -4
  136. package/incrementalBuilder/builderLanes.ts +2 -2
  137. package/incrementalBuilder/builderWatch.ts +19 -9
  138. package/incrementalBuilder/csrRegistry.ts +4 -4
  139. package/incrementalBuilder/incrementalBuilder.proc.test.ts +159 -0
  140. package/incrementalBuilder/incrementalBuilder.proc.ts +38 -10
  141. package/incrementalBuilder/pendingMetadata.test.ts +27 -0
  142. package/incrementalBuilder/pendingMetadata.ts +19 -0
  143. package/incrementalBuilder/ssrRegistry.ts +6 -6
  144. package/index.ts +1 -1
  145. package/integration/devResourceProbe.ts +14 -0
  146. package/integration/devStability.integration.test.ts +46 -21
  147. package/integration/renderAdmissionSoak.test.ts +99 -0
  148. package/integration/renderAdmissionSoak.ts +615 -0
  149. package/integration/ssrMemoryProbe.ts +5 -0
  150. package/lint/__fixtures__/no-arbitrary-color/every-color-function/bad.tsx +11 -0
  151. package/lint/__fixtures__/no-arbitrary-color/every-color-function/good.tsx +2 -0
  152. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/bad.tsx +34 -0
  153. package/lint/__fixtures__/no-daisyui-legacy-class/every-class/good.tsx +2 -0
  154. package/lint/__fixtures__/no-inline-color/every-color-function/bad.tsx +10 -0
  155. package/lint/__fixtures__/no-inline-color/every-color-function/good.tsx +2 -0
  156. package/lint/__fixtures__/no-raw-palette-class/every-palette/bad.tsx +22 -0
  157. package/lint/__fixtures__/no-raw-palette-class/every-palette/good.tsx +2 -0
  158. package/lint/biomeBase.test.ts +50 -3
  159. package/lint/biomeBase.ts +1 -1
  160. package/lint/biomeCheck.test.ts +162 -0
  161. package/lint/biomeCheck.ts +131 -0
  162. package/lint/linter.test.ts +16 -11
  163. package/lint/no-arbitrary-color.grit +5 -0
  164. package/lint/no-conditional-st-hook.grit +5 -1
  165. package/lint/no-daisyui-legacy-class.grit +8 -0
  166. package/lint/no-document-cookie.grit +3 -0
  167. package/lint/no-inline-color.grit +10 -2
  168. package/lint/no-oversized-list-limit.grit +2 -0
  169. package/lint/no-raw-palette-class.grit +7 -0
  170. package/lint/no-unpublished-form-setter.grit +2 -0
  171. package/lint/no-web-only-api-outside-webkit.grit +5 -0
  172. package/lint/no-web-storage.grit +3 -0
  173. package/lint/withheldEnvFile.ts +17 -0
  174. package/mobile/desktopBin.ts +2 -2
  175. package/mobile/desktopServerStage.test.ts +18 -3
  176. package/mobile/desktopServerStage.ts +7 -2
  177. package/mobile/nativeApp.test.ts +13 -5
  178. package/mobile/nativeApp.ts +9 -4
  179. package/mobile/nativeConfig.test.ts +96 -1
  180. package/mobile/nativeConfig.ts +46 -12
  181. package/mobile/nativePublicEnv.ts +1 -1
  182. package/mobile/serverBundleSecrets.ts +43 -0
  183. package/package.json +22 -178
  184. package/packageExports.test.ts +39 -24
  185. package/preview/PreviewView.ts +25 -3
  186. package/quality/dictionaryKeys.test.ts +356 -0
  187. package/quality/dictionaryKeys.ts +488 -0
  188. package/quality/objectImportReport.test.ts +36 -0
  189. package/quality/objectImportReport.ts +105 -0
  190. package/quality/qualityScanner.ts +1 -1
  191. package/quality/routeRuntimeReport.test.ts +91 -0
  192. package/quality/routeRuntimeReport.ts +121 -0
  193. package/quality/runtimeConstantFacts.ts +71 -0
  194. package/quality/runtimeConstantGraph.ts +123 -0
  195. package/quality/runtimeConstantReads.ts +116 -0
  196. package/quality/runtimeImports.test.ts +190 -0
  197. package/quality/runtimeImports.ts +233 -0
  198. package/quality/runtimeKeyNames.ts +46 -0
  199. package/quality/runtimeLexicalScope.ts +132 -0
  200. package/quality/runtimeMarkerReach.test.ts +84 -0
  201. package/quality/runtimeMarkerReach.ts +255 -0
  202. package/quality/runtimeModuleFacts.ts +290 -0
  203. package/quality/runtimeNameTable.test.ts +172 -0
  204. package/quality/runtimeNameTable.ts +477 -0
  205. package/quality/runtimeScopeReport.test.ts +123 -0
  206. package/quality/runtimeScopeReport.ts +167 -0
  207. package/quality/runtimeSliceKey.ts +269 -0
  208. package/quality/runtimeSyntax.ts +133 -0
  209. package/quality/runtimeTable.fixture.ts +189 -0
  210. package/quality/runtimeUse.test.ts +737 -0
  211. package/quality/runtimeUse.ts +696 -0
  212. package/quality/runtimeUseReadable.test.ts +393 -0
  213. package/quality/ssrScanner.test.ts +13 -0
  214. package/quality/ssrScanner.ts +1 -1
  215. package/quality/translatorBindings.ts +187 -0
  216. package/test/fakeTerminal.ts +45 -0
  217. package/test/secretEnvFixture.ts +134 -0
  218. package/test/testHelpers.ts +11 -0
  219. package/transforms/barrelAnalyzer.ts +26 -4
  220. package/transforms/barrelImportsPlugin.ts +121 -32
  221. package/transforms/exportReach.test.ts +162 -0
  222. package/transforms/exportReach.ts +308 -0
  223. package/transforms/frameworkObjects.fixture.tsx +58 -0
  224. package/transforms/frameworkObjects.test.ts +54 -0
  225. package/transforms/modelReference.test.ts +196 -0
  226. package/transforms/modelReference.ts +39 -0
  227. package/transforms/moduleParts.test.ts +225 -0
  228. package/transforms/moduleParts.ts +418 -0
  229. package/transforms/objectImportEdits.ts +150 -0
  230. package/transforms/objectMemberImports.test.ts +633 -0
  231. package/transforms/objectMemberImports.ts +571 -0
  232. package/transforms/objectMemberLookup.ts +150 -0
  233. package/transforms/objectModule.test.ts +307 -0
  234. package/transforms/objectModule.ts +482 -0
  235. package/transforms/objectModuleAnalyzer.ts +104 -0
  236. package/transforms/partImports.test.ts +76 -0
  237. package/transforms/partImports.ts +110 -0
  238. package/transforms/partModules.test.ts +187 -0
  239. package/transforms/partModules.ts +90 -0
  240. package/transforms/partPurity.ts +124 -0
  241. package/transforms/reactIconImports.test.ts +231 -0
  242. package/transforms/reactIconImports.ts +325 -0
  243. package/transforms/routeConstants.ts +122 -0
  244. package/transforms/routeRuntime.test.ts +835 -0
  245. package/transforms/routeRuntime.ts +703 -0
  246. package/transforms/routeRuntimeEdits.ts +92 -0
  247. package/transforms/routeRuntimeGraph.ts +66 -0
  248. package/transforms/routeRuntimePlan.ts +244 -0
  249. package/transforms/secretEnvDeclaration.test.ts +211 -0
  250. package/transforms/secretEnvDeclaration.ts +219 -0
  251. package/transforms/secretEnvFile.test.ts +117 -0
  252. package/transforms/secretEnvFile.ts +113 -0
  253. package/transforms/secretEnvName.test.ts +54 -0
  254. package/transforms/secretEnvName.ts +29 -0
  255. package/transforms/secretEnvSource.test.ts +152 -0
  256. package/transforms/secretEnvSource.ts +197 -0
  257. package/transforms/serverEnvEvaluationError.ts +11 -0
  258. package/transforms/serverEnvPlugin.test.ts +118 -1
  259. package/transforms/serverEnvPlugin.ts +95 -2
  260. package/transforms/serverEnvProfile.test.ts +129 -2
  261. package/transforms/serverEnvProfile.ts +133 -43
  262. package/transforms/serverEnvSecrets.test.ts +268 -0
  263. package/transforms/signalDescriptors.test.ts +280 -0
  264. package/transforms/signalDescriptors.ts +227 -0
  265. package/transforms/thisFreeExports.ts +87 -0
  266. package/transforms/transforms.test.ts +180 -3
  267. package/transforms/tsconfigPackageResolver.test.ts +1 -0
  268. package/tunnel/createTunnel.test.ts +29 -8
  269. package/tunnel/createTunnel.ts +22 -11
  270. package/tunnel/ssh2Module.test.ts +37 -0
  271. package/tunnel/ssh2Module.ts +28 -0
  272. package/tunnel/sshTunnel.ts +4 -2
  273. package/typecheck/projectTypecheck.test.ts +32 -1
  274. package/typecheck/projectTypecheck.ts +3 -3
  275. package/typecheck/typeChecker.test.ts +49 -0
  276. package/typecheck/typeChecker.ts +9 -7
  277. package/typecheck/withheldDiagnostics.ts +41 -0
  278. package/util/devInstallCommand.ts +7 -0
  279. package/util/fileEditor.ts +1 -0
  280. package/util/jsonFormatter.test.ts +13 -9
  281. package/util/selectModel.ts +1 -0
  282. package/workflow/executor.ts +6 -2
  283. package/workflow/index.ts +1 -0
  284. package/workflow/plan.ts +36 -7
  285. package/workflow/types.ts +1 -1
  286. package/workflow/uiTarget.ts +50 -0
  287. package/workspace/envSeed.test.ts +30 -1
  288. package/workspace/envSeed.ts +30 -1
  289. package/workspace/getRelatedCnsts.ts +7 -0
  290. package/workspace/mainCheckout.test.ts +55 -0
  291. package/workspace/mainCheckout.ts +38 -0
  292. package/workspace/scanInfo.test.ts +39 -0
  293. package/workspace/scanInfo.ts +55 -6
  294. package/workspace/slicePlanner.ts +2 -1
  295. package/workspace/workspaceLayout.test.ts +22 -1
  296. package/workspace/workspaceLayout.ts +3 -3
  297. package/CHANGELOG.md +0 -2718
  298. package/codeAgent/agent/AkanCodeCompaction.ts +0 -49
  299. package/codeAgent/agent/AkanCodeServices.ts +0 -122
  300. package/codeAgent/agent/AkanContextFiles.ts +0 -94
  301. package/codeAgent/agent/CodeAgent.ts +0 -606
  302. package/codeAgent/agent/CodeAgentAsks.ts +0 -66
  303. package/codeAgent/agent/CodeAgentEventMapper.ts +0 -225
  304. package/codeAgent/agent/CodeAgentGate.ts +0 -239
  305. package/codeAgent/agent/CodeAgentProxy.ts +0 -83
  306. package/codeAgent/agent/CodeAgentRpcHost.ts +0 -109
  307. package/codeAgent/agent/CodeAgentRpcListener.ts +0 -195
  308. package/codeAgent/agent/CodeAgentStreamPrinter.ts +0 -86
  309. package/codeAgent/agent/CodeAgentSuspended.ts +0 -85
  310. package/codeAgent/agent/CodeAgentUi.ts +0 -47
  311. package/codeAgent/agent/CodeMailbox.ts +0 -148
  312. package/codeAgent/agent/CodeSessionFork.ts +0 -56
  313. package/codeAgent/agent/CodeSessionIndex.ts +0 -78
  314. package/codeAgent/agent/SubagentPool.ts +0 -219
  315. package/codeAgent/agent/WorkspaceTrust.ts +0 -200
  316. package/codeAgent/agent/akanCodeCompaction.test.ts +0 -36
  317. package/codeAgent/agent/akanCodeModel.ts +0 -47
  318. package/codeAgent/agent/akanCodeServices.test.ts +0 -54
  319. package/codeAgent/agent/akanContextFiles.test.ts +0 -116
  320. package/codeAgent/agent/akanSystemPrompt.ts +0 -50
  321. package/codeAgent/agent/codeAgent.test.ts +0 -275
  322. package/codeAgent/agent/codeAgentContract.test.ts +0 -643
  323. package/codeAgent/agent/codeAgentHosts.ts +0 -30
  324. package/codeAgent/agent/codeAgentProxy.test.ts +0 -126
  325. package/codeAgent/agent/codeAgentRpcListener.test.ts +0 -215
  326. package/codeAgent/agent/codeAgentSuspended.test.ts +0 -47
  327. package/codeAgent/agent/codeMailbox.test.ts +0 -76
  328. package/codeAgent/agent/codeSessionFork.test.ts +0 -58
  329. package/codeAgent/agent/codeSessionIndex.test.ts +0 -77
  330. package/codeAgent/agent/consoleToStderr.ts +0 -8
  331. package/codeAgent/agent/jsonLines.ts +0 -29
  332. package/codeAgent/agent/stringArg.ts +0 -5
  333. package/codeAgent/feedback/DevLogFeedback.ts +0 -82
  334. package/codeAgent/feedback/PreviewFeedback.ts +0 -46
  335. package/codeAgent/feedback/TurnFeedback.ts +0 -98
  336. package/codeAgent/feedback/VerifyFeedback.ts +0 -39
  337. package/codeAgent/tools/AkanCli.ts +0 -51
  338. package/codeAgent/tools/AkanCodePlugins.ts +0 -142
  339. package/codeAgent/tools/AkanEditScope.ts +0 -53
  340. package/codeAgent/tools/AkanEnvKeys.ts +0 -50
  341. package/codeAgent/tools/AkanToolPack.ts +0 -86
  342. package/codeAgent/tools/AkanVerifier.ts +0 -30
  343. package/codeAgent/tools/AskToolPack.ts +0 -99
  344. package/codeAgent/tools/DeepSeekWeb.ts +0 -127
  345. package/codeAgent/tools/MailToolPack.ts +0 -76
  346. package/codeAgent/tools/McpClient.ts +0 -209
  347. package/codeAgent/tools/McpOAuth.ts +0 -233
  348. package/codeAgent/tools/McpOAuthLoopback.ts +0 -64
  349. package/codeAgent/tools/McpServerConfig.ts +0 -131
  350. package/codeAgent/tools/McpSignIn.ts +0 -158
  351. package/codeAgent/tools/McpTokenStore.ts +0 -128
  352. package/codeAgent/tools/McpToolPack.ts +0 -206
  353. package/codeAgent/tools/SessionToolPack.ts +0 -91
  354. package/codeAgent/tools/WebToolPack.ts +0 -315
  355. package/codeAgent/tools/akanCodePlugins.test.ts +0 -954
  356. package/codeAgent/tools/askToolPack.test.ts +0 -116
  357. package/codeAgent/tools/deepSeekWeb.test.ts +0 -113
  358. package/codeAgent/tools/mcpOAuth.test.ts +0 -648
  359. package/codeAgent/tools/mcpServerConfig.test.ts +0 -341
  360. package/piDependencyPins.test.ts +0 -45
@@ -1,82 +0,0 @@
1
- import { existsSync, statSync } from "node:fs";
2
- import path from "node:path";
3
- import { AkanEditScope } from "../tools/AkanEditScope";
4
- import type { TurnFeedbackSource } from "./TurnFeedback";
5
-
6
- export interface DevLogFeedbackOptions {
7
- workspaceRoot: string;
8
- cwd: string;
9
- apps: string[];
10
- /** Hot reload finishes after the turn does, so the read waits for it. */
11
- graceMs?: number;
12
- maxLines?: number;
13
- }
14
-
15
- const errorPattern = /\bERROR\b|\bFATAL\b|\[stderr\]|error:|Error:|✖|Unhandled|Cannot find|is not a function/;
16
- const noisePattern = /DEBUG|\bWARN\b|MCP catalogue|rate limit/;
17
-
18
- // dev.log is the only file carrying the dev host's own build output; lint and typecheck pass on code that dies at run.
19
- export class DevLogFeedback implements TurnFeedbackSource {
20
- readonly key = "dev-server";
21
- readonly #options: Required<DevLogFeedbackOptions>;
22
- readonly #marks = new Map<string, number>();
23
- #baseline: ReadonlySet<string> = new Set();
24
-
25
- constructor(options: DevLogFeedbackOptions) {
26
- this.#options = { graceMs: 1_500, maxLines: 30, ...options };
27
- }
28
-
29
- async begin() {
30
- for (const app of this.#options.apps) this.#marks.set(app, DevLogFeedback.#sizeOf(this.#pathOf(app)));
31
- this.#baseline = await AkanEditScope.baseline(this.#options.cwd);
32
- }
33
-
34
- async observe() {
35
- const running = this.#options.apps.filter((app) => existsSync(this.#pathOf(app)));
36
- if (!running.length) return undefined;
37
- // A turn that wrote nothing cannot have broken the app; without this gate another person's dev server reopens it.
38
- if (!(await AkanEditScope.since(this.#options.cwd, this.#baseline)).paths.length) return undefined;
39
- await Bun.sleep(this.#options.graceMs);
40
- const reports: string[] = [];
41
- for (const app of running) {
42
- const lines = await this.#linesSince(app);
43
- if (lines.length) reports.push(`**${app}** dev server:\n\`\`\`\n${lines.join("\n")}\n\`\`\``);
44
- }
45
- if (!reports.length) return undefined;
46
- return [
47
- "The dev server logged errors after your edits:",
48
- ...reports,
49
- `Full log: ${running.map((app) => path.relative(this.#options.workspaceRoot, this.#pathOf(app))).join(", ")}`,
50
- ].join("\n\n");
51
- }
52
-
53
- async #linesSince(app: string) {
54
- const file = this.#pathOf(app);
55
- const from = this.#marks.get(app) ?? 0;
56
- const size = DevLogFeedback.#sizeOf(file);
57
- // A smaller file means `akan start` rotated to a new session mid-turn; its own boot output is not a finding.
58
- if (size <= from) return [];
59
- const text = await Bun.file(file).slice(from, size).text();
60
- this.#marks.set(app, size);
61
- return text
62
- .split("\n")
63
- .filter((line) => errorPattern.test(line) && !noisePattern.test(line))
64
- .slice(-this.#options.maxLines);
65
- }
66
-
67
- #pathOf(app: string) {
68
- return path.join(this.#options.workspaceRoot, "local", "apps", app, "runtime", "dev.log");
69
- }
70
-
71
- /** The port is allocated, not predicted, so the log's `ready` line is the only record of this session's URL. */
72
- static async previewUrl(workspaceRoot: string, app: string) {
73
- const file = path.join(workspaceRoot, "local", "apps", app, "runtime", "dev.log");
74
- if (!existsSync(file)) return undefined;
75
- const matches = [...(await Bun.file(file).text()).matchAll(/ready \(pid=\d+\) — (https?:\/\/\S+)/g)];
76
- return matches.at(-1)?.[1];
77
- }
78
-
79
- static #sizeOf(file: string) {
80
- return existsSync(file) ? statSync(file).size : 0;
81
- }
82
- }
@@ -1,46 +0,0 @@
1
- import { PreviewView } from "../../preview/PreviewView";
2
- import { AkanEditScope } from "../tools/AkanEditScope";
3
- import type { TurnFeedbackFinding, TurnFeedbackSource } from "./TurnFeedback";
4
-
5
- export interface PreviewFeedbackOptions {
6
- cwd: string;
7
- /** Origin of a running dev server. Without one the source is inert. */
8
- previewUrl?: string;
9
- /** Every akan route sits under `/:lang`, so a bare path renders nothing. */
10
- routes?: string[];
11
- /** Only a model whose input includes images gets a screenshot attached. */
12
- canSeeImages?: boolean;
13
- }
14
-
15
- // Findings are text, not screenshots: a few hundred tokens, readable by any model, and naming the defect.
16
- export class PreviewFeedback implements TurnFeedbackSource {
17
- readonly key = "preview";
18
- readonly #options: PreviewFeedbackOptions;
19
- #baseline: ReadonlySet<string> = new Set();
20
-
21
- constructor(options: PreviewFeedbackOptions) {
22
- this.#options = options;
23
- }
24
-
25
- async begin() {
26
- this.#baseline = await AkanEditScope.baseline(this.#options.cwd);
27
- }
28
-
29
- async observe(): Promise<TurnFeedbackFinding | undefined> {
30
- if (!this.#options.previewUrl || !PreviewView.available) return undefined;
31
- const scope = await AkanEditScope.since(this.#options.cwd, this.#baseline);
32
- if (!scope.touchesTsx) return undefined;
33
- const findings: string[] = [];
34
- const images: { data: string; mimeType: string }[] = [];
35
- for (const route of this.#options.routes ?? ["/en/"]) {
36
- const url = new URL(route, this.#options.previewUrl).toString();
37
- const probe = await PreviewView.probe(url, { screenshot: !!this.#options.canSeeImages });
38
- const problems = [...probe.pageErrors, ...probe.consoleErrors, ...probe.consoleWarnings, ...probe.domFindings];
39
- if (!problems.length) continue;
40
- findings.push(`**${url}**\n${problems.map((line) => `- ${line}`).join("\n")}`);
41
- if (probe.screenshot) images.push({ data: probe.screenshot, mimeType: "image/png" });
42
- }
43
- if (!findings.length) return undefined;
44
- return { text: ["The rendered page has problems after your UI edits:", ...findings].join("\n\n"), images };
45
- }
46
- }
@@ -1,98 +0,0 @@
1
- import type { ExtensionAPI, InlineExtension } from "@earendil-works/pi-coding-agent";
2
-
3
- /** A base64 PNG, attached only when the active model can read one. */
4
- export interface TurnFeedbackImage {
5
- data: string;
6
- mimeType: string;
7
- }
8
-
9
- export interface TurnFeedbackFinding {
10
- text: string;
11
- images?: TurnFeedbackImage[];
12
- }
13
-
14
- export interface TurnFeedbackSource {
15
- /** Budget is counted per key, so one stuck source cannot spend another's attempts. */
16
- key: string;
17
- /** Record whatever "before" this source compares against. Never throws — a source that cannot arm is skipped. */
18
- begin(): Promise<void> | void;
19
- /** What the turn caused that the agent cannot see, or `undefined` when there is nothing to say. */
20
- observe(): Promise<TurnFeedbackFinding | string | undefined> | TurnFeedbackFinding | string | undefined;
21
- }
22
-
23
- export interface TurnFeedbackOptions {
24
- /** How many times one source may reopen a turn before it gives up and lets the human see it. */
25
- budget: number;
26
- onNotice?: (message: string) => void;
27
- }
28
-
29
- // The engine's `agent_end` hook cannot veto the end of a turn, so a finding is a follow-up that opens a new one.
30
- // The budget is load-bearing: without it one unfixable error reopens turns until the context or the wallet runs out.
31
- export class TurnFeedback {
32
- readonly #sources: TurnFeedbackSource[];
33
- readonly #options: TurnFeedbackOptions;
34
- readonly #spent = new Map<string, number>();
35
-
36
- constructor(sources: TurnFeedbackSource[], options: TurnFeedbackOptions) {
37
- this.#sources = sources;
38
- this.#options = options;
39
- }
40
-
41
- extension(): InlineExtension {
42
- return {
43
- name: "akan-turn-feedback",
44
- factory: (pi: ExtensionAPI) => {
45
- pi.on("agent_start", async () => {
46
- await Promise.all(this.#sources.map((source) => TurnFeedback.#quietly(() => source.begin())));
47
- });
48
- pi.on("agent_end", async () => {
49
- const message = await this.collect();
50
- if (message) pi.sendUserMessage(message, { deliverAs: "followUp" });
51
- });
52
- },
53
- };
54
- }
55
-
56
- async collect() {
57
- const texts: string[] = [];
58
- const images: TurnFeedbackImage[] = [];
59
- const reopened: string[] = [];
60
- for (const source of this.#sources) {
61
- const finding = await TurnFeedback.#quietly(() => source.observe());
62
- if (!finding) {
63
- this.#spent.delete(source.key);
64
- continue;
65
- }
66
- const spent = this.#spent.get(source.key) ?? 0;
67
- if (spent >= this.#options.budget) {
68
- this.#options.onNotice?.(`${source.key}: still failing after ${spent} attempts — handing back to you.`);
69
- continue;
70
- }
71
- this.#spent.set(source.key, spent + 1);
72
- reopened.push(source.key);
73
- if (typeof finding === "string") texts.push(finding);
74
- else {
75
- texts.push(finding.text);
76
- images.push(...(finding.images ?? []));
77
- }
78
- }
79
- if (!texts.length) return undefined;
80
- this.#options.onNotice?.(`${reopened.join(" · ")} reopened the turn — esc stops it`);
81
- const text = [
82
- "The previous turn left problems you cannot see from the transcript. Fix them, then stop.",
83
- ...texts,
84
- ].join("\n\n");
85
- return images.length
86
- ? [{ type: "text" as const, text }, ...images.map((image) => ({ type: "image" as const, ...image }))]
87
- : text;
88
- }
89
-
90
- /** Every source is best-effort: no dev server, no git, no preview — all of them mean "nothing to report". */
91
- static async #quietly<T>(fn: () => T | Promise<T>) {
92
- try {
93
- return await fn();
94
- } catch {
95
- return undefined;
96
- }
97
- }
98
- }
@@ -1,39 +0,0 @@
1
- import { AkanEditScope } from "../tools/AkanEditScope";
2
- import { AkanVerifier } from "../tools/AkanVerifier";
3
- import type { TurnFeedbackSource } from "./TurnFeedback";
4
-
5
- export interface VerifyFeedbackOptions {
6
- cwd: string;
7
- /** A read-only profile reports what is stale instead of running a chain that would write generated files. */
8
- readOnly?: boolean;
9
- }
10
-
11
- // A hook, not a reliance on the akan_verify tool: the observed failure is a model finishing without calling it.
12
- export class VerifyFeedback implements TurnFeedbackSource {
13
- readonly key = "verify";
14
- readonly #options: VerifyFeedbackOptions;
15
- readonly #verifier: AkanVerifier;
16
- #baseline: ReadonlySet<string> = new Set();
17
-
18
- constructor(options: VerifyFeedbackOptions) {
19
- this.#options = options;
20
- this.#verifier = new AkanVerifier(options.cwd);
21
- }
22
-
23
- async begin() {
24
- this.#baseline = await AkanEditScope.baseline(this.#options.cwd);
25
- }
26
-
27
- async observe() {
28
- const scope = await AkanEditScope.since(this.#options.cwd, this.#baseline);
29
- if (!scope.apps.length && !scope.libs.length && !scope.pkgs.length) return undefined;
30
- if (this.#options.readOnly) return VerifyFeedback.#readOnlyNotice(scope.needsSync, [...scope.apps, ...scope.libs]);
31
- const report = await this.#verifier.verify(scope.paths);
32
- return report.ok ? undefined : report.text;
33
- }
34
-
35
- static #readOnlyNotice(needsSync: boolean, targets: string[]) {
36
- if (!needsSync) return undefined;
37
- return `Files were added or removed under ${targets.join(", ")}, so the generated barrels are stale. This profile does not write, so run \`akan sync ${targets.join(" ")}\` yourself before trusting a typecheck.`;
38
- }
39
- }
@@ -1,51 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import path from "node:path";
3
- import { stripAnsi } from "../../util/stripAnsi";
4
-
5
- export interface AkanCliResult {
6
- command: string;
7
- ok: boolean;
8
- exitCode: number;
9
- output: string;
10
- }
11
-
12
- // A subprocess: the akan runners print to inherited stdio and return nothing; it also isolates their crashes.
13
- export class AkanCli {
14
- readonly #cwd: string;
15
- readonly #entry: string;
16
-
17
- constructor(cwd: string) {
18
- this.#cwd = cwd;
19
- this.#entry = AkanCli.#resolveEntry();
20
- }
21
-
22
- async run(args: string[], { timeoutMs = 300_000 }: { timeoutMs?: number } = {}): Promise<AkanCliResult> {
23
- const proc = Bun.spawn([process.execPath, this.#entry, ...args], {
24
- cwd: this.#cwd,
25
- stdout: "pipe",
26
- stderr: "pipe",
27
- //? A workspace .env's AKAN_PUBLIC_LOG_LEVEL=verbose reaches the child too, and buried its error under 90 lines.
28
- env: { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1", AKAN_LOG_STDOUT_LEVEL: "warn" },
29
- });
30
- const timer = setTimeout(() => proc.kill(), timeoutMs);
31
- const [stdout, stderr, exitCode] = await Promise.all([
32
- new Response(proc.stdout).text(),
33
- new Response(proc.stderr).text(),
34
- proc.exited,
35
- ]);
36
- clearTimeout(timer);
37
- // tsgo colours regardless of NO_COLOR, and escape sequences are tokens the model pays for and cannot read.
38
- const output = stripAnsi(`${stdout}${stderr}`).trim();
39
- return { command: `akan ${args.join(" ")}`, ok: exitCode === 0, exitCode, output };
40
- }
41
-
42
- // Bundled, import.meta.dir is the CLI's output dir with index.js beside it; Bun.main fits only when the CLI is the
43
- // process. The path is written out because devkit does not depend on the CLI, and must not start.
44
- static #resolveEntry() {
45
- const candidates = [
46
- path.join(import.meta.dir, "index.js"),
47
- path.join(import.meta.dir, "..", "..", "..", "cli", "index.ts"),
48
- ];
49
- return candidates.find((candidate) => existsSync(candidate)) ?? Bun.main;
50
- }
51
- }
@@ -1,142 +0,0 @@
1
- import type { InlineExtension } from "@earendil-works/pi-coding-agent";
2
- import type { CodeAgentMcpStatus, CodeAgentProfile, CodeAgentQuestion, CodeAgentSubagent } from "akanjs/common";
3
- import type { Workspace } from "../../commandDecorators";
4
- import { PreviewView } from "../../preview/PreviewView";
5
- import type { CodeAgentModelRef } from "../agent/akanCodeModel";
6
- import type { CodeMailbox } from "../agent/CodeMailbox";
7
- import { SubagentPool, type SubagentSpend } from "../agent/SubagentPool";
8
- import { DevLogFeedback } from "../feedback/DevLogFeedback";
9
- import { PreviewFeedback } from "../feedback/PreviewFeedback";
10
- import { TurnFeedback, type TurnFeedbackSource } from "../feedback/TurnFeedback";
11
- import { VerifyFeedback } from "../feedback/VerifyFeedback";
12
- import { AkanToolPack } from "./AkanToolPack";
13
- import { AskToolPack } from "./AskToolPack";
14
- import type { DeepSeekWeb } from "./DeepSeekWeb";
15
- import { MailToolPack } from "./MailToolPack";
16
- import { McpToolPack } from "./McpToolPack";
17
- import { SessionToolPack } from "./SessionToolPack";
18
- import { WebToolPack } from "./WebToolPack";
19
-
20
- export interface AkanCodePluginsOptions {
21
- workspace: Workspace;
22
- cwd: string;
23
- profile: CodeAgentProfile;
24
- /** Apps whose dev server should be watched, and whose page should be probed. */
25
- apps: string[];
26
- canSeeImages: boolean;
27
- /** The owning agent's model as it is now; a `task` child runs on it. */
28
- model?: () => CodeAgentModelRef | undefined;
29
- deepseek?: DeepSeekWeb | undefined;
30
- /** How many `task` levels deep the owning agent is. */
31
- depth: number;
32
- /** The tally of the sub-agent tree the owning agent belongs to, when a `task` opened it. */
33
- subagentSpend?: SubagentSpend;
34
- /** Reading the current session back would spend its own window twice, so it is excluded from search. */
35
- currentSessionId: () => string;
36
- /** Late, because the session this announces to its peers does not exist yet when the pack is built. */
37
- mailbox: () => CodeMailbox | undefined;
38
- onNotice?: (message: string) => void;
39
- onAgents?: (agents: CodeAgentSubagent[]) => void;
40
- /** How `ask_user` reaches the person. Absent on a host that has nobody to reach. */
41
- onAsk?: (question: Omit<CodeAgentQuestion, "questionId">) => Promise<string | undefined>;
42
- }
43
-
44
- export interface AkanCodePluginsResult {
45
- extensions: InlineExtension[];
46
- /** Names the session's tool allowlist has to carry, or the model is told these tools do not exist. */
47
- toolNames: string[];
48
- /** Every declared MCP server and what it published, including the ones that published nothing. */
49
- mcp: CodeAgentMcpStatus[];
50
- /** Closes anything the pack holds open — currently the MCP server connections. */
51
- dispose: () => void;
52
- }
53
-
54
- // Gated at assembly, not at call time: a capability the profile excludes is never built and costs no prompt tokens.
55
- export class AkanCodePlugins {
56
- static async build(options: AkanCodePluginsOptions): Promise<AkanCodePluginsResult> {
57
- const mcp = await McpToolPack.connect({
58
- workspaceRoot: options.workspace.workspaceRoot,
59
- profile: options.profile,
60
- ...(options.onNotice ? { onNotice: options.onNotice } : {}),
61
- });
62
- const dispose = () => mcp?.close();
63
- const mcpStatus = mcp?.status ?? [];
64
- const web = new WebToolPack({ profile: options.profile, deepseek: options.deepseek });
65
- const sessions = new SessionToolPack({
66
- workspaceRoot: options.workspace.workspaceRoot,
67
- cwd: options.cwd,
68
- profile: options.profile,
69
- currentSessionId: options.currentSessionId,
70
- });
71
- const mail = new MailToolPack({ profile: options.profile, mailbox: options.mailbox });
72
- const onAsk = options.onAsk;
73
- const ask = onAsk ? new AskToolPack({ profile: options.profile, ask: onAsk }) : undefined;
74
- const shared = {
75
- extensions: [mcp?.extension(), web.extension(), sessions.extension(), mail.extension(), ask?.extension()].filter(
76
- (entry) => !!entry,
77
- ),
78
- toolNames: [
79
- ...(mcp?.toolNames ?? []),
80
- ...web.names(),
81
- ...sessions.names(),
82
- ...mail.names(),
83
- ...(ask?.names() ?? []),
84
- ],
85
- };
86
- if (!options.profile.tools.akan) return { ...shared, mcp: mcpStatus, dispose };
87
- const readOnly = !options.profile.tools.builtin.includes("write");
88
- const pack = new AkanToolPack({
89
- workspace: options.workspace,
90
- cwd: options.cwd,
91
- mode: readOnly ? "readonly" : "apply",
92
- });
93
- const extensions: InlineExtension[] = [pack.extension()];
94
- const subagent = SubagentPool.extensionFor({
95
- workspace: options.workspace,
96
- cwd: options.cwd,
97
- parent: options.profile,
98
- ...(options.model ? { model: options.model } : {}),
99
- depth: options.depth,
100
- ...(options.subagentSpend ? { spend: options.subagentSpend } : {}),
101
- ...(options.onNotice ? { onNotice: options.onNotice } : {}),
102
- ...(options.onAgents ? { onAgents: options.onAgents } : {}),
103
- });
104
- if (subagent) extensions.push(subagent);
105
- const sources = await AkanCodePlugins.#sources(options, readOnly);
106
- if (sources.length)
107
- extensions.push(
108
- new TurnFeedback(sources, {
109
- budget: options.profile.limits.feedback,
110
- ...(options.onNotice ? { onNotice: options.onNotice } : {}),
111
- }).extension(),
112
- );
113
- return {
114
- extensions: [...extensions, ...shared.extensions],
115
- toolNames: [...(await pack.names()), ...(subagent ? [SubagentPool.toolName] : []), ...shared.toolNames],
116
- mcp: mcpStatus,
117
- dispose,
118
- };
119
- }
120
-
121
- static async #sources(options: AkanCodePluginsOptions, readOnly: boolean): Promise<TurnFeedbackSource[]> {
122
- const sources: TurnFeedbackSource[] = [
123
- new VerifyFeedback({ cwd: options.cwd, readOnly }),
124
- new DevLogFeedback({ workspaceRoot: options.workspace.workspaceRoot, cwd: options.cwd, apps: options.apps }),
125
- ];
126
- const previewUrl = await AkanCodePlugins.#previewUrl(options);
127
- if (!previewUrl) return sources;
128
- // Said once here, or a UI turn silently skips its only visual check and reads as a clean run.
129
- const reason = PreviewView.unavailableReason();
130
- if (reason) options.onNotice?.(reason);
131
- else sources.push(new PreviewFeedback({ cwd: options.cwd, previewUrl, canSeeImages: options.canSeeImages }));
132
- return sources;
133
- }
134
-
135
- static async #previewUrl(options: AkanCodePluginsOptions) {
136
- for (const app of options.apps) {
137
- const url = await DevLogFeedback.previewUrl(options.workspace.workspaceRoot, app);
138
- if (url) return url;
139
- }
140
- return undefined;
141
- }
142
- }
@@ -1,53 +0,0 @@
1
- export interface AkanEditScopeResult {
2
- paths: string[];
3
- apps: string[];
4
- libs: string[];
5
- pkgs: string[];
6
- /** A created, deleted or renamed file under `apps/**` or `libs/**` — the only kind a barrel has to catch up with. */
7
- needsSync: boolean;
8
- touchesTsx: boolean;
9
- }
10
-
11
- const empty: AkanEditScopeResult = { paths: [], apps: [], libs: [], pkgs: [], needsSync: false, touchesTsx: false };
12
-
13
- // Read from git, not tool events: an edit made through `bash` (a heredoc, sed, a codemod) produces no write tool call.
14
- export class AkanEditScope {
15
- static async since(cwd: string, baseline: ReadonlySet<string>): Promise<AkanEditScopeResult> {
16
- const current = await AkanEditScope.baseline(cwd);
17
- const changed = [...current].filter((line) => !baseline.has(line));
18
- if (!changed.length) return empty;
19
- const entries = changed.map((line) => ({ code: line.slice(0, 2), file: line.slice(3).split(" -> ").at(-1) ?? "" }));
20
- const paths = entries.map((entry) => entry.file).filter(Boolean);
21
- return {
22
- paths,
23
- apps: AkanEditScope.#targets(paths, "apps"),
24
- libs: AkanEditScope.#targets(paths, "libs"),
25
- pkgs: AkanEditScope.#targets(paths, "pkgs"),
26
- needsSync: entries.some((entry) => /[ARD?]/.test(entry.code) && /^(apps|libs)\//.test(entry.file)),
27
- touchesTsx: paths.some((file) => file.endsWith(".tsx")),
28
- };
29
- }
30
-
31
- /** The porcelain lines before a turn, so the turn is judged on what it changed rather than on a dirty tree. */
32
- static async baseline(cwd: string) {
33
- const proc = Bun.spawn(["git", "status", "--porcelain=v1", "--untracked-files=all"], {
34
- cwd,
35
- stdout: "pipe",
36
- stderr: "ignore",
37
- });
38
- const text = await new Response(proc.stdout).text();
39
- await proc.exited;
40
- return new Set(text.split("\n").filter((line) => line.trim().length > 3));
41
- }
42
-
43
- static #targets(paths: string[], root: "apps" | "libs" | "pkgs") {
44
- const names = paths
45
- .filter((file) => file.startsWith(`${root}/`))
46
- .map((file) => {
47
- const [, first = "", second = ""] = file.split("/");
48
- return first.startsWith("@") && second ? `${first}/${second}` : first;
49
- })
50
- .filter(Boolean);
51
- return [...new Set(names)];
52
- }
53
- }
@@ -1,50 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import path from "node:path";
3
- import type { ModelRuntime } from "@earendil-works/pi-coding-agent";
4
-
5
- // Bun auto-loads .env from the current directory only, so a run from a subdirectory sees none of the workspace's keys.
6
- // Applied as runtime overrides, never stored: copying a key into ~/.akan/code/auth.json gives it a second lifetime.
7
- export class AkanEnvKeys {
8
- static async apply(runtime: ModelRuntime, workspaceRoot: string) {
9
- const applied: string[] = [];
10
- for (const [name, value] of AkanEnvKeys.#entries(workspaceRoot)) {
11
- const provider = AkanEnvKeys.#providerOf(name);
12
- if (!provider || !value) continue;
13
- // Serially: the runtime's credential writes share one file, and a key written mid-write goes missing.
14
- await runtime.setRuntimeApiKey(provider, value);
15
- applied.push(provider);
16
- }
17
- return applied;
18
- }
19
-
20
- static #entries(workspaceRoot: string): [string, string][] {
21
- const fromProcess = Object.entries(process.env).filter(([, value]) => typeof value === "string") as [
22
- string,
23
- string,
24
- ][];
25
- const file = path.join(workspaceRoot, ".env");
26
- if (!existsSync(file)) return fromProcess;
27
- const fromFile = readFileSync(file, "utf8")
28
- .split("\n")
29
- .map((line) => line.trim())
30
- .filter((line) => line && !line.startsWith("#") && line.includes("="))
31
- .map((line): [string, string] => {
32
- const index = line.indexOf("=");
33
- return [
34
- line.slice(0, index).trim(),
35
- line
36
- .slice(index + 1)
37
- .trim()
38
- .replace(/^["']|["']$/g, ""),
39
- ];
40
- });
41
- // The real environment wins: an operator exporting a key for one run should not be overridden by the file.
42
- return [...fromFile, ...fromProcess];
43
- }
44
-
45
- /** `DEEPSEEK_API_KEY` names the provider `deepseek`; the engine's provider ids are lower-kebab. */
46
- static #providerOf(name: string) {
47
- const match = /^([A-Z0-9_]+)_API_KEY$/.exec(name);
48
- return match?.[1]?.toLowerCase().replace(/_/g, "-");
49
- }
50
- }
@@ -1,86 +0,0 @@
1
- import type { ExtensionAPI, InlineExtension } from "@earendil-works/pi-coding-agent";
2
- import { Type } from "typebox";
3
- import type { Workspace } from "../../commandDecorators";
4
- import { AkanVerifier } from "./AkanVerifier";
5
-
6
- export interface AkanToolPackOptions {
7
- workspace: Workspace;
8
- cwd: string;
9
- /** `readonly` for a reviewer, `apply` for an agent that may run a workflow. */
10
- mode: "readonly" | "plan" | "apply";
11
- }
12
-
13
- // Wraps the akan MCP catalogue's in-process dispatcher (ContextRunner.callMcpTool); a second copy would drift from it.
14
- export class AkanToolPack {
15
- readonly #options: AkanToolPackOptions;
16
-
17
- constructor(options: AkanToolPackOptions) {
18
- this.#options = options;
19
- }
20
-
21
- extension(): InlineExtension {
22
- return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
23
- }
24
-
25
- // The session allowlist covers extension tools too; a name missing here tells the model the tool does not exist.
26
- // devkit must not depend on the CLI, so ContextRunner is reached by relative path; publishing bundles both.
27
- async names() {
28
- const { ContextRunner } = await import("../../../cli/context/context.runner");
29
- return [
30
- ...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
31
- AkanToolPack.verifyToolName,
32
- ];
33
- }
34
-
35
- static readonly verifyToolName = "akan_verify";
36
-
37
- async #register(pi: ExtensionAPI) {
38
- const { ContextRunner } = await import("../../../cli/context/context.runner");
39
- const runner = new ContextRunner();
40
- const guidelineNames = await AkanToolPack.#guidelineNames();
41
- for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
42
- const description = tool.description ?? tool.name;
43
- pi.registerTool({
44
- name: tool.name,
45
- label: tool.name,
46
- description,
47
- // Without a snippet the engine leaves a custom tool out of the system prompt's tool list entirely.
48
- promptSnippet: `${tool.name}: ${description.split(".")[0] ?? description}`,
49
- parameters: Type.Unsafe<Record<string, unknown>>(tool.inputSchema),
50
- execute: async (_id, params) => {
51
- const result = await runner.callMcpTool(this.#options.workspace, tool.name, params ?? {}, {
52
- mode: this.#options.mode,
53
- });
54
- const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
55
- return { content: [{ type: "text", text }], details: undefined };
56
- },
57
- });
58
- }
59
- this.#registerVerify(pi);
60
- }
61
-
62
- #registerVerify(pi: ExtensionAPI) {
63
- const verifier = new AkanVerifier(this.#options.cwd);
64
- pi.registerTool({
65
- name: AkanToolPack.verifyToolName,
66
- label: "akan verify",
67
- description:
68
- "Run `akan verify` over everything the working tree has changed: sync, lint (with fixes), typecheck, a build of each changed app's server and SSR routes, and the SSR check for .tsx changes, in one call. It prints one line when it passes and one line per problem when it fails. Call this after editing, before you finish; never run lint, typecheck or build separately.",
69
- promptSnippet: "akan_verify: sync, lint, typecheck and build what the working tree changed, in one call",
70
- parameters: Type.Object({}),
71
- execute: async () => {
72
- const report = await verifier.verify();
73
- return { content: [{ type: "text", text: report.text }], details: undefined, isError: !report.ok };
74
- },
75
- });
76
- }
77
-
78
- static async #guidelineNames() {
79
- try {
80
- const { Prompter } = await import("../../guideline/prompter");
81
- return await Prompter.listGuidelines();
82
- } catch {
83
- return [];
84
- }
85
- }
86
- }