akm-cli 0.9.0-rc.4 → 0.9.0-rc.6

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 (438) hide show
  1. package/CHANGELOG.md +122 -26
  2. package/README.md +7 -7
  3. package/SECURITY.md +11 -10
  4. package/dist/akm +2 -2
  5. package/dist/akm-migrate-storage +2 -2
  6. package/dist/assets/hints/cli-hints-full.md +60 -73
  7. package/dist/assets/hints/cli-hints-short.md +8 -12
  8. package/dist/assets/improve-strategies/default.json +5 -7
  9. package/dist/assets/improve-strategies/frequent.json +2 -2
  10. package/dist/assets/improve-strategies/proactive-maintenance.json +2 -2
  11. package/dist/assets/improve-strategies/quick.json +1 -1
  12. package/dist/assets/improve-strategies/reflect-distill.json +3 -3
  13. package/dist/assets/improve-strategies/thorough.json +1 -1
  14. package/dist/assets/prompts/consolidate-system.md +5 -5
  15. package/dist/assets/prompts/extract-session.md +2 -6
  16. package/dist/assets/prompts/reflect-llm-framed-contract.md +11 -0
  17. package/dist/assets/prompts/reflect-llm-schema-contract.md +3 -0
  18. package/dist/assets/prompts/reflect-output-repair.md +3 -0
  19. package/dist/assets/stash-skeleton/README.md +10 -11
  20. package/dist/assets/stash-skeleton/facts/conventions/assets/agent.md +1 -1
  21. package/dist/assets/stash-skeleton/facts/conventions/assets/fact.md +1 -1
  22. package/dist/assets/stash-skeleton/facts/conventions/assets/knowledge.md +1 -1
  23. package/dist/assets/stash-skeleton/facts/conventions/assets/lesson.md +2 -2
  24. package/dist/assets/stash-skeleton/facts/conventions/assets/memory.md +2 -2
  25. package/dist/assets/stash-skeleton/facts/conventions/assets/script.md +1 -1
  26. package/dist/assets/stash-skeleton/facts/conventions/assets/skill.md +2 -2
  27. package/dist/assets/stash-skeleton/facts/conventions/assets/workflow.md +1 -1
  28. package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +18 -18
  29. package/dist/assets/stash-skeleton/facts/conventions/domains.md +8 -9
  30. package/dist/assets/stash-skeleton/facts/conventions/organization.md +13 -15
  31. package/dist/assets/tasks/core/extract.yml +2 -2
  32. package/dist/assets/tasks/core/improve.yml +1 -1
  33. package/dist/assets/templates/html/health.html +2 -3
  34. package/dist/cli/config-migrate.js +1328 -101
  35. package/dist/cli/invocation.js +255 -0
  36. package/dist/cli/parse-args.js +20 -83
  37. package/dist/cli/shared.js +15 -37
  38. package/dist/cli.js +18 -49
  39. package/dist/commands/agent/agent-dispatch.js +2 -2
  40. package/dist/commands/agent/contribute-cli.js +5 -4
  41. package/dist/commands/bundle/bundle-cli.js +68 -0
  42. package/dist/commands/bundle/bundle.js +219 -0
  43. package/dist/commands/completions.js +2 -2
  44. package/dist/commands/config-cli.js +6 -3
  45. package/dist/commands/env/env-binding.js +13 -9
  46. package/dist/commands/env/env-cli.js +49 -48
  47. package/dist/commands/env/secret-cli.js +24 -10
  48. package/dist/commands/events.js +2 -2
  49. package/dist/commands/feedback-cli.js +59 -33
  50. package/dist/commands/graph/graph.js +6 -4
  51. package/dist/commands/health/advisories.js +4 -4
  52. package/dist/commands/health/html-report.js +190 -593
  53. package/dist/commands/health/improve-metrics.js +240 -188
  54. package/dist/commands/health/metrics.js +9 -17
  55. package/dist/commands/health/report-view-model.js +509 -0
  56. package/dist/commands/health/surfaces.js +6 -3
  57. package/dist/commands/health/types-checks.js +4 -0
  58. package/dist/commands/health/types-improve.js +22 -0
  59. package/dist/commands/health/types-metrics.js +4 -0
  60. package/dist/commands/health/types-result.js +7 -0
  61. package/dist/commands/health/types-runs.js +4 -0
  62. package/dist/commands/health/types-session-log.js +4 -0
  63. package/dist/commands/health/types-windows.js +4 -0
  64. package/dist/commands/health/types.js +26 -21
  65. package/dist/commands/health/windows.js +1 -2
  66. package/dist/commands/health.js +219 -161
  67. package/dist/commands/improve/collapse-detector.js +25 -14
  68. package/dist/commands/improve/consolidate/chunking.js +7 -5
  69. package/dist/commands/improve/consolidate.js +640 -740
  70. package/dist/commands/improve/content-hash.js +39 -0
  71. package/dist/commands/improve/distill/content-repair.js +4 -10
  72. package/dist/commands/improve/distill/promote-memory.js +79 -49
  73. package/dist/commands/improve/distill/quality-gate.js +113 -35
  74. package/dist/commands/improve/distill-promotion-policy.js +24 -885
  75. package/dist/commands/improve/distill.js +565 -337
  76. package/dist/commands/improve/eligibility.js +75 -36
  77. package/dist/commands/improve/extract-cli.js +6 -6
  78. package/dist/commands/improve/extract-prompt.js +5 -34
  79. package/dist/commands/improve/extract.js +526 -357
  80. package/dist/commands/improve/feedback-valence.js +2 -12
  81. package/dist/commands/improve/improve-cli.js +11 -20
  82. package/dist/commands/improve/improve-result-file.js +7 -6
  83. package/dist/commands/improve/improve-run-types.js +4 -0
  84. package/dist/commands/improve/improve-strategies.js +3 -9
  85. package/dist/commands/improve/improve.js +822 -727
  86. package/dist/commands/improve/locks.js +27 -95
  87. package/dist/commands/improve/loop-stages.js +941 -963
  88. package/dist/commands/improve/memory/derived-ref.js +122 -0
  89. package/dist/commands/improve/memory/memory-contradiction-detect.js +35 -38
  90. package/dist/commands/improve/memory/memory-improve.js +24 -37
  91. package/dist/commands/improve/outcome-loop.js +13 -33
  92. package/dist/commands/improve/preparation.js +889 -691
  93. package/dist/commands/improve/proactive-maintenance.js +37 -9
  94. package/dist/commands/improve/proposal-envelope.js +31 -0
  95. package/dist/commands/improve/reflect.js +974 -588
  96. package/dist/commands/improve/run-context.js +119 -0
  97. package/dist/commands/improve/salience.js +8 -4
  98. package/dist/commands/improve/session-asset.js +7 -3
  99. package/dist/commands/improve/shared.js +14 -40
  100. package/dist/commands/improve/source-identity.js +39 -26
  101. package/dist/commands/improve/triage.js +20 -17
  102. package/dist/commands/lint/base-linter.js +288 -295
  103. package/dist/commands/lint/index.js +132 -19
  104. package/dist/commands/mv-cli.js +257 -234
  105. package/dist/commands/observability-cli.js +2 -1
  106. package/dist/commands/proposal/diff-format.js +50 -0
  107. package/dist/commands/proposal/drain-policies.js +0 -6
  108. package/dist/commands/proposal/drain.js +17 -16
  109. package/dist/commands/proposal/proposal-cli.js +40 -77
  110. package/dist/commands/proposal/proposal-types.js +56 -0
  111. package/dist/commands/proposal/proposal.js +39 -1
  112. package/dist/commands/proposal/propose.js +41 -19
  113. package/dist/commands/proposal/repository.js +566 -486
  114. package/dist/commands/proposal/validators/proposal-quality-validators.js +22 -6
  115. package/dist/commands/proposal/validators/proposal-validators.js +6 -5
  116. package/dist/commands/proposal/validators/proposals.js +5 -4
  117. package/dist/commands/read/curate.js +50 -28
  118. package/dist/commands/read/knowledge.js +25 -16
  119. package/dist/commands/read/remember-cli.js +12 -4
  120. package/dist/commands/read/search-cli.js +33 -33
  121. package/dist/commands/read/search.js +68 -55
  122. package/dist/commands/read/show.js +54 -135
  123. package/dist/commands/remember.js +7 -5
  124. package/dist/commands/sources/add-cli.js +10 -24
  125. package/dist/commands/sources/bundle-config-ops.js +58 -0
  126. package/dist/commands/sources/history.js +13 -8
  127. package/dist/commands/sources/info.js +10 -11
  128. package/dist/commands/sources/init.js +12 -21
  129. package/dist/commands/sources/installed-stashes.js +151 -138
  130. package/dist/commands/sources/schema-repair.js +5 -3
  131. package/dist/commands/sources/self-update.js +9 -7
  132. package/dist/commands/sources/source-add.js +116 -154
  133. package/dist/commands/sources/source-clone.js +33 -14
  134. package/dist/commands/sources/source-manage.js +43 -32
  135. package/dist/commands/sources/sources-cli.js +12 -7
  136. package/dist/commands/sources/stash-cli.js +12 -5
  137. package/dist/commands/sources/stash-skeleton.js +1 -1
  138. package/dist/commands/tasks/default-tasks.js +13 -13
  139. package/dist/commands/tasks/tasks-cli.js +3 -3
  140. package/dist/commands/tasks/tasks.js +71 -31
  141. package/dist/commands/workflow-cli.js +22 -26
  142. package/dist/core/action-contributors.js +1 -1
  143. package/dist/core/activation-policy.js +49 -0
  144. package/dist/core/adapter/adapters/agent-skills-adapter.js +181 -0
  145. package/dist/core/adapter/adapters/akm-adapter.js +509 -0
  146. package/dist/core/adapter/adapters/akm-lint.js +381 -0
  147. package/dist/core/adapter/adapters/akm-metadata.js +416 -0
  148. package/dist/core/adapter/adapters/akm-task-adapter.js +150 -0
  149. package/dist/core/adapter/adapters/akm-workflow-adapter.js +196 -0
  150. package/dist/core/adapter/adapters/claude-adapter.js +61 -0
  151. package/dist/core/adapter/adapters/dotenv-adapter.js +187 -0
  152. package/dist/core/adapter/adapters/generic-files-adapter.js +117 -0
  153. package/dist/core/adapter/adapters/index.js +80 -0
  154. package/dist/core/adapter/adapters/llm-wiki-adapter.js +413 -0
  155. package/dist/core/adapter/adapters/okf-adapter.js +223 -0
  156. package/dist/core/adapter/adapters/opencode-adapter.js +68 -0
  157. package/dist/core/adapter/adapters/shared.js +286 -0
  158. package/dist/core/adapter/adapters/tool-dir-shared.js +212 -0
  159. package/dist/core/adapter/adapters/website-snapshot-adapter.js +154 -0
  160. package/dist/core/adapter/bundle-adapter.js +4 -0
  161. package/dist/core/adapter/recognize-match.js +42 -0
  162. package/dist/core/adapter/registry.js +56 -0
  163. package/dist/core/adapter/types.js +4 -0
  164. package/dist/core/asset/asset-placement.js +229 -0
  165. package/dist/core/asset/asset-ref.js +107 -78
  166. package/dist/core/asset/asset-serialize.js +20 -0
  167. package/dist/core/asset/frontmatter.js +1 -1
  168. package/dist/core/asset/resolve-ref.js +223 -0
  169. package/dist/core/asset/stash-meta.js +1 -1
  170. package/dist/core/common.js +141 -49
  171. package/dist/core/config/config-io.js +0 -108
  172. package/dist/core/config/config-schema.js +94 -1039
  173. package/dist/core/config/config-sources.js +115 -36
  174. package/dist/core/config/config-types.js +16 -11
  175. package/dist/core/config/config-walker.js +4 -2
  176. package/dist/core/config/config.js +21 -26
  177. package/dist/core/config/engine-semantics.js +0 -4
  178. package/dist/core/config/schema/embedding.js +38 -0
  179. package/dist/core/config/schema/engines.js +116 -0
  180. package/dist/core/config/schema/feedback.js +31 -0
  181. package/dist/core/config/schema/improve-processes.js +395 -0
  182. package/dist/core/config/schema/improve.js +76 -0
  183. package/dist/core/config/schema/index-config.js +183 -0
  184. package/dist/core/config/schema/output.js +15 -0
  185. package/dist/core/config/schema/primitives.js +94 -0
  186. package/dist/core/config/schema/search.js +30 -0
  187. package/dist/core/config/schema/setup.js +27 -0
  188. package/dist/core/config/schema/sources-bundles.js +164 -0
  189. package/dist/core/config/schema/workflow.js +29 -0
  190. package/dist/core/env-secret-ref.js +113 -8
  191. package/dist/core/errors.js +1 -1
  192. package/dist/core/events-types.js +4 -0
  193. package/dist/core/extra-params.js +1 -0
  194. package/dist/core/file-change.js +16 -0
  195. package/dist/core/fs-txn.js +316 -0
  196. package/dist/core/git-message.js +59 -0
  197. package/dist/core/improve-result.js +9 -1
  198. package/dist/core/logs-db.js +1 -1
  199. package/dist/core/maintenance-barrier.js +16 -0
  200. package/dist/core/migration-backup.js +332 -160
  201. package/dist/core/paths.js +3 -6
  202. package/dist/core/platform.js +10 -0
  203. package/dist/core/recognition-util.js +130 -0
  204. package/dist/core/redaction.js +2 -2
  205. package/dist/core/standards/resolve-standards-context.js +47 -64
  206. package/dist/core/standards/resolve-type-conventions.js +3 -3
  207. package/dist/core/state/migrations.js +201 -8
  208. package/dist/core/state-db.js +38 -2
  209. package/dist/core/subprocess.js +303 -0
  210. package/dist/core/time.js +20 -0
  211. package/dist/core/type-presentation.js +130 -0
  212. package/dist/core/write-source.js +39 -67
  213. package/dist/indexer/bundle-identity-guard.js +91 -0
  214. package/dist/indexer/db/graph-db.js +1 -1
  215. package/dist/indexer/db/llm-cache.js +1 -1
  216. package/dist/indexer/ensure-index.js +29 -9
  217. package/dist/indexer/graph/graph-boost.js +28 -24
  218. package/dist/indexer/graph/graph-extraction.js +5 -6
  219. package/dist/indexer/graph/graph-types.js +4 -0
  220. package/dist/indexer/index-written-assets.js +44 -17
  221. package/dist/indexer/indexer.js +289 -153
  222. package/dist/indexer/init.js +18 -25
  223. package/dist/indexer/installations.js +224 -0
  224. package/dist/indexer/passes/dir-staleness.js +2 -1
  225. package/dist/indexer/passes/memory-inference.js +8 -4
  226. package/dist/indexer/passes/metadata.js +96 -243
  227. package/dist/indexer/scan/doc-to-entry.js +123 -0
  228. package/dist/indexer/scan/drain-dir.js +144 -0
  229. package/dist/indexer/search/db-search.js +171 -99
  230. package/dist/indexer/search/fts-query.js +1 -1
  231. package/dist/indexer/search/ranking-contributors.js +57 -7
  232. package/dist/indexer/search/ranking-types.js +4 -0
  233. package/dist/indexer/search/ranking.js +31 -6
  234. package/dist/indexer/search/search-attribution.js +67 -0
  235. package/dist/indexer/search/search-hit-enrichers.js +30 -40
  236. package/dist/indexer/search/search-source.js +109 -52
  237. package/dist/indexer/search/semantic-status.js +4 -1
  238. package/dist/indexer/usage/unmigrated-vaults-guard.js +2 -1
  239. package/dist/indexer/usage/usage-events.js +72 -9
  240. package/dist/indexer/walk/file-context.js +1 -44
  241. package/dist/indexer/walk/matchers.js +16 -32
  242. package/dist/indexer/walk/path-resolver.js +6 -5
  243. package/dist/indexer/walk/walker.js +4 -2
  244. package/dist/integrations/agent/engine-resolution.js +22 -0
  245. package/dist/integrations/agent/model-aliases.js +1 -1
  246. package/dist/integrations/agent/prompts.js +35 -11
  247. package/dist/integrations/agent/spawn.js +41 -270
  248. package/dist/integrations/harnesses/aider/agent-builder.js +2 -2
  249. package/dist/integrations/harnesses/aider/index.js +2 -11
  250. package/dist/integrations/harnesses/amazonq/agent-builder.js +1 -9
  251. package/dist/integrations/harnesses/amazonq/index.js +3 -16
  252. package/dist/integrations/harnesses/claude/config-import.js +1 -3
  253. package/dist/integrations/harnesses/claude/index.js +1 -12
  254. package/dist/integrations/harnesses/claude/session-log.js +27 -65
  255. package/dist/integrations/harnesses/codex/agent-builder.js +1 -2
  256. package/dist/integrations/harnesses/codex/index.js +2 -12
  257. package/dist/integrations/harnesses/copilot/agent-builder.js +2 -3
  258. package/dist/integrations/harnesses/copilot/index.js +1 -12
  259. package/dist/integrations/harnesses/gemini/agent-builder.js +1 -3
  260. package/dist/integrations/harnesses/gemini/index.js +1 -12
  261. package/dist/integrations/harnesses/ids.js +24 -0
  262. package/dist/integrations/harnesses/index.js +27 -2
  263. package/dist/integrations/harnesses/opencode/config-import.js +1 -3
  264. package/dist/integrations/harnesses/opencode/index.js +1 -12
  265. package/dist/integrations/harnesses/opencode/session-log.js +67 -110
  266. package/dist/integrations/harnesses/opencode-sdk/harness.js +2 -11
  267. package/dist/integrations/harnesses/openhands/agent-builder.js +3 -3
  268. package/dist/integrations/harnesses/openhands/index.js +2 -11
  269. package/dist/integrations/harnesses/pi/agent-builder.js +3 -11
  270. package/dist/integrations/harnesses/pi/index.js +3 -15
  271. package/dist/integrations/harnesses/shared.js +17 -0
  272. package/dist/integrations/harnesses/types.js +37 -2
  273. package/dist/integrations/lockfile.js +36 -0
  274. package/dist/integrations/session-logs/index.js +21 -12
  275. package/dist/integrations/session-logs/provider-base.js +113 -0
  276. package/dist/llm/client.js +7 -5
  277. package/dist/llm/embedders/deterministic.js +2 -2
  278. package/dist/llm/embedders/remote.js +8 -4
  279. package/dist/llm/graph-extract.js +7 -2
  280. package/dist/llm/metadata-enhance.js +43 -26
  281. package/dist/llm/structured-call.js +15 -7
  282. package/dist/migrate/legacy/config-source-migration.js +223 -0
  283. package/dist/migrate/legacy/content-migration.js +305 -0
  284. package/dist/migrate/legacy/legacy-layout.js +779 -0
  285. package/dist/migrate/legacy/legacy-paths.js +25 -0
  286. package/dist/migrate/legacy/legacy-stash-json.js +72 -0
  287. package/dist/migrate/legacy/proposal-fs-import.js +168 -0
  288. package/dist/migrate/legacy/task-target-ref-migration.js +272 -0
  289. package/dist/migrate/legacy/three-db-cutover.js +840 -0
  290. package/dist/migrate/legacy/workflow-migrations-bodies.js +52 -0
  291. package/dist/migrate/legacy/workflow-migrations-frozen.js +21 -0
  292. package/dist/migrate/legacy-ref-grammar.js +209 -0
  293. package/dist/output/command-registry.js +27 -0
  294. package/dist/output/html-render.js +11 -16
  295. package/dist/output/renderers.js +32 -276
  296. package/dist/output/shapes/passthrough.js +3 -9
  297. package/dist/output/shapes/registry.js +12 -6
  298. package/dist/output/text/command-format.js +547 -0
  299. package/dist/output/text/helpers.js +15 -1377
  300. package/dist/output/text/proposal-format.js +230 -0
  301. package/dist/output/text/registry.js +12 -6
  302. package/dist/output/text/show-directives.js +107 -0
  303. package/dist/output/text/show-format.js +103 -0
  304. package/dist/output/text/workflow-format.js +345 -0
  305. package/dist/output/text.js +1 -3
  306. package/dist/registry/build-index.js +13 -17
  307. package/dist/registry/providers/static-index.js +2 -2
  308. package/dist/registry/resolve.js +4 -90
  309. package/dist/registry/semver.js +93 -0
  310. package/dist/runtime.js +90 -0
  311. package/dist/schemas/akm-config.json +2956 -14890
  312. package/dist/schemas/akm-task.json +2 -2
  313. package/dist/schemas/akm-workflow.json +2 -2
  314. package/dist/scripts/migrate-storage.js +2312 -19642
  315. package/dist/setup/detect.js +5 -7
  316. package/dist/setup/engine-config.js +2 -1
  317. package/dist/setup/registry-stash-loader.js +1 -1
  318. package/dist/setup/semantic-assets.js +12 -9
  319. package/dist/setup/setup.js +109 -39
  320. package/dist/setup/steps/connection-shared.js +120 -0
  321. package/dist/setup/steps/connection.js +50 -274
  322. package/dist/setup/steps/platforms.js +1 -0
  323. package/dist/setup/steps/sources.js +13 -6
  324. package/dist/setup/steps/stashdir.js +5 -2
  325. package/dist/sources/freshness.js +39 -0
  326. package/dist/sources/providers/git-provider.js +29 -33
  327. package/dist/sources/providers/git-stash.js +10 -5
  328. package/dist/sources/providers/provider-utils.js +40 -18
  329. package/dist/sources/providers/website.js +1 -1
  330. package/dist/sources/resolve.js +5 -5
  331. package/dist/sources/snapshot-fetchers/types.js +4 -0
  332. package/dist/sources/{website-ingest.js → snapshot-fetchers/website-ingest.js} +105 -39
  333. package/dist/storage/database.js +47 -3
  334. package/dist/storage/engines/sqlite-migrations.js +34 -16
  335. package/dist/storage/locations.js +1 -2
  336. package/dist/storage/repositories/improve-runs-repository.js +0 -20
  337. package/dist/storage/repositories/index-connection.js +80 -0
  338. package/dist/storage/repositories/index-db.js +4 -3
  339. package/dist/storage/repositories/index-entries-repository.js +952 -0
  340. package/dist/{indexer/db/entry-mapper.js → storage/repositories/index-entry-mapper.js} +15 -2
  341. package/dist/storage/repositories/index-entry-types.js +4 -0
  342. package/dist/storage/repositories/index-fts-repository.js +164 -0
  343. package/dist/storage/repositories/index-llm-cache-repository.js +109 -0
  344. package/dist/storage/repositories/index-meta-repository.js +50 -0
  345. package/dist/{indexer/db/schema.js → storage/repositories/index-schema.js} +241 -100
  346. package/dist/storage/repositories/index-sql.js +12 -0
  347. package/dist/storage/repositories/index-utility-repository.js +369 -0
  348. package/dist/storage/repositories/index-vec-repository.js +245 -0
  349. package/dist/storage/repositories/proposals-repository.js +41 -50
  350. package/dist/storage/repositories/registry-cache.js +1 -1
  351. package/dist/storage/repositories/workflow-runs-repository.js +17 -11
  352. package/dist/tasks/backends/cron.js +5 -5
  353. package/dist/tasks/backends/exec-utils.js +21 -0
  354. package/dist/tasks/backends/index.js +6 -9
  355. package/dist/tasks/backends/launchd.js +16 -17
  356. package/dist/tasks/backends/schtasks.js +33 -41
  357. package/dist/tasks/backends/types.js +4 -0
  358. package/dist/tasks/parser.js +25 -5
  359. package/dist/tasks/runner.js +33 -39
  360. package/dist/tasks/validator.js +5 -6
  361. package/dist/workflows/authoring/authoring.js +8 -11
  362. package/dist/workflows/exec/brief.js +10 -7
  363. package/dist/workflows/exec/report.js +261 -156
  364. package/dist/workflows/exec/run-workflow.js +2 -1
  365. package/dist/workflows/exec/step-work.js +3 -9
  366. package/dist/workflows/program/parser.js +4 -60
  367. package/dist/workflows/renderer.js +11 -60
  368. package/dist/workflows/runtime/checkin.js +1 -1
  369. package/dist/workflows/runtime/plan-classifier.js +7 -4
  370. package/dist/workflows/runtime/runs.js +11 -10
  371. package/dist/workflows/runtime/unit-checkin.js +1 -1
  372. package/dist/workflows/runtime/unit-phases.js +20 -0
  373. package/dist/workflows/runtime/workflow-asset-loader.js +27 -16
  374. package/dist/workflows/validate-summary.js +2 -2
  375. package/dist/workflows/validator.js +18 -2
  376. package/docs/migration/release-notes/0.9.0.md +45 -3
  377. package/docs/migration/v0.8-to-v0.9.md +466 -262
  378. package/docs/{data-and-telemetry.md → reference/data-and-telemetry.md} +61 -17
  379. package/package.json +10 -9
  380. package/schemas/akm-config.json +2956 -14890
  381. package/schemas/akm-task.json +2 -2
  382. package/schemas/akm-workflow.json +2 -2
  383. package/dist/assets/help/help-accept.md +0 -12
  384. package/dist/assets/help/help-improve.md +0 -84
  385. package/dist/assets/help/help-proposals.md +0 -17
  386. package/dist/assets/help/help-propose.md +0 -17
  387. package/dist/assets/help/help-reject.md +0 -11
  388. package/dist/assets/improve-strategies/recombine-only.json +0 -23
  389. package/dist/assets/improve-strategies/synthesize.json +0 -17
  390. package/dist/assets/prompts/procedural-system.md +0 -44
  391. package/dist/assets/prompts/recombine-system.md +0 -40
  392. package/dist/assets/prompts/staleness-detect-system.md +0 -6
  393. package/dist/assets/templates/html/default.html +0 -78
  394. package/dist/assets/templates/html/vendor/echarts.min.js +0 -45
  395. package/dist/assets/wiki/index-template.md +0 -12
  396. package/dist/assets/wiki/ingest-workflow-template.md +0 -83
  397. package/dist/assets/wiki/log-template.md +0 -8
  398. package/dist/assets/wiki/schema-template.md +0 -61
  399. package/dist/commands/improve/calibration.js +0 -161
  400. package/dist/commands/improve/dedup.js +0 -482
  401. package/dist/commands/improve/hot-probation.js +0 -45
  402. package/dist/commands/improve/improve-auto-accept.js +0 -262
  403. package/dist/commands/improve/procedural.js +0 -403
  404. package/dist/commands/improve/recombine.js +0 -843
  405. package/dist/commands/improve/schema-similarity-gate.js +0 -168
  406. package/dist/commands/lint/agent-linter.js +0 -44
  407. package/dist/commands/lint/command-linter.js +0 -44
  408. package/dist/commands/lint/default-linter.js +0 -16
  409. package/dist/commands/lint/fact-linter.js +0 -39
  410. package/dist/commands/lint/knowledge-linter.js +0 -16
  411. package/dist/commands/lint/memory-linter.js +0 -61
  412. package/dist/commands/lint/registry.js +0 -41
  413. package/dist/commands/lint/skill-linter.js +0 -45
  414. package/dist/commands/lint/task-linter.js +0 -50
  415. package/dist/commands/lint/workflow-linter.js +0 -81
  416. package/dist/commands/proposal/legacy-import.js +0 -115
  417. package/dist/commands/wiki-cli.js +0 -291
  418. package/dist/core/asset/asset-registry.js +0 -76
  419. package/dist/core/asset/asset-spec.js +0 -316
  420. package/dist/core/eval/rank-metrics.js +0 -113
  421. package/dist/core/ripgrep/install.js +0 -163
  422. package/dist/core/ripgrep/resolve.js +0 -81
  423. package/dist/indexer/db/db.js +0 -1585
  424. package/dist/indexer/manifest.js +0 -170
  425. package/dist/indexer/passes/metadata-contributors.js +0 -31
  426. package/dist/integrations/harnesses/opencode-sdk/index.js +0 -25
  427. package/dist/output/text/wiki.js +0 -16
  428. package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +0 -18228
  429. package/dist/scripts/migrations/v16-to-v17.js +0 -141
  430. package/dist/storage/repositories/consolidation-repository.js +0 -38
  431. package/dist/storage/repositories/recombine-repository.js +0 -213
  432. package/dist/wiki/wiki-templates.js +0 -15
  433. package/dist/wiki/wiki.js +0 -1013
  434. package/dist/workflows/db.js +0 -413
  435. package/docs/README.md +0 -103
  436. package/docs/migration/release-notes/0.9.0-beta.60.md +0 -19
  437. /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/registry.js +0 -0
  438. /package/dist/sources/{wiki-fetchers → snapshot-fetchers}/youtube.js +0 -0
@@ -1,1383 +1,21 @@
1
1
  // This Source Code Form is subject to the terms of the Mozilla Public
2
2
  // License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
  // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
- export function formatInfoPlain(r) {
5
- const lines = [];
6
- if (r.version)
7
- lines.push(`version: ${String(r.version)}`);
8
- if (r.stashDir)
9
- lines.push(`stashDir: ${String(r.stashDir)}`);
10
- if (r.configPath)
11
- lines.push(`configPath: ${String(r.configPath)}`);
12
- if (r.cacheDir)
13
- lines.push(`cacheDir: ${String(r.cacheDir)}`);
14
- if (r.dbPath)
15
- lines.push(`dbPath: ${String(r.dbPath)}`);
16
- const capabilities = r.capabilities;
17
- if (capabilities) {
18
- lines.push("capabilities:");
19
- for (const [k, v] of Object.entries(capabilities)) {
20
- lines.push(` ${k}: ${typeof v === "object" ? JSON.stringify(v) : String(v)}`);
21
- }
22
- }
23
- const indexStats = r.index;
24
- if (indexStats) {
25
- lines.push("index:");
26
- for (const [k, v] of Object.entries(indexStats)) {
27
- lines.push(` ${k}: ${typeof v === "object" ? JSON.stringify(v) : String(v)}`);
28
- }
29
- }
30
- if (lines.length === 0)
31
- return JSON.stringify(r, null, 2);
32
- return lines.join("\n");
33
- }
34
- export function formatConfigPlain(r) {
35
- // Recursive flattener: prints `key=value` lines, and nested objects as
36
- // `parent.child=value`. Arrays render as JSON for compactness.
37
- const lines = [];
38
- const walk = (obj, prefix) => {
39
- for (const [k, v] of Object.entries(obj)) {
40
- const path = prefix ? `${prefix}.${k}` : k;
41
- if (v === null || v === undefined) {
42
- lines.push(`${path}=`);
43
- }
44
- else if (Array.isArray(v)) {
45
- lines.push(`${path}=${JSON.stringify(v)}`);
46
- }
47
- else if (typeof v === "object") {
48
- walk(v, path);
49
- }
50
- else {
51
- lines.push(`${path}=${String(v)}`);
52
- }
53
- }
54
- };
55
- walk(r, "");
56
- if (lines.length === 0)
57
- return "(empty config)";
58
- return lines.join("\n");
59
- }
60
- export function formatFeedbackPlain(r) {
61
- const ref = String(r.ref ?? "?");
62
- const signal = String(r.signal ?? "?");
63
- const note = typeof r.note === "string" && r.note ? ` — ${r.note}` : "";
64
- return `Recorded ${signal} feedback for ${ref}${note}`;
65
- }
66
- export function formatRememberPlain(r) {
67
- const ref = String(r.ref ?? "?");
68
- const pathValue = String(r.path ?? "?");
69
- return `Saved ${ref} at ${pathValue}`;
70
- }
71
- export function formatImportPlain(r) {
72
- const ref = String(r.ref ?? "?");
73
- const source = String(r.source ?? "?");
74
- const pathValue = String(r.path ?? "?");
75
- return `Imported ${source} → ${ref} at ${pathValue}`;
76
- }
77
- export function formatSavePlain(r) {
78
- if (r.ok === false) {
79
- const reason = typeof r.reason === "string" ? r.reason : "unknown";
80
- return `save: failed (${reason})`;
81
- }
82
- const name = typeof r.name === "string" ? r.name : "primary stash";
83
- const committed = r.committed === true;
84
- const pushed = r.pushed === true;
85
- const parts = [`save: ${name}`];
86
- parts.push(committed ? "committed" : "no changes");
87
- if (pushed)
88
- parts.push("pushed");
89
- return parts.join(" — ");
90
- }
91
- export function formatToggleComponentPlain(command, r) {
92
- const verb = command === "enable" ? "Enabled" : "Disabled";
93
- const component = String(r.component ?? "?");
94
- const changed = r.changed === true;
95
- return changed ? `${verb} ${component}` : `${component} was already ${command}d`;
96
- }
97
- export function formatRegistryListPlain(r) {
98
- const registries = Array.isArray(r.registries) ? r.registries : [];
99
- if (registries.length === 0) {
100
- return "No registries configured. Add one with `akm registry add <url>`.";
101
- }
102
- const lines = [];
103
- for (const reg of registries) {
104
- const url = String(reg.url ?? "?");
105
- const name = typeof reg.name === "string" ? reg.name : "";
106
- const provider = typeof reg.provider === "string" ? ` (${reg.provider})` : "";
107
- const enabled = reg.enabled === false ? " [disabled]" : "";
108
- const head = name ? `${name}: ${url}` : url;
109
- lines.push(`${head}${provider}${enabled}`);
110
- }
111
- return lines.join("\n");
112
- }
113
- export function formatRegistryAddPlain(r) {
114
- if (r.added === false) {
115
- return typeof r.message === "string" ? r.message : "Registry already configured.";
116
- }
117
- const registries = Array.isArray(r.registries) ? r.registries.length : 0;
118
- return `Registry added (${registries} total).`;
119
- }
120
- export function formatRegistryRemovePlain(r) {
121
- if (r.removed === false) {
122
- return typeof r.message === "string" ? r.message : "No matching registry found.";
123
- }
124
- const entry = r.entry;
125
- const url = entry ? String(entry.url ?? entry.name ?? "?") : "?";
126
- return `Removed registry ${url}`;
127
- }
128
- export function formatRegistrySearchPlain(r, detail) {
129
- // Reuse the same renderer as `search` — both share `hits` / `registryHits`.
130
- return formatSearchPlain(r, detail);
131
- }
132
- export function formatRegistryBuildIndexPlain(r) {
133
- const outPath = String(r.outPath ?? "?");
134
- const total = typeof r.totalKits === "number" ? r.totalKits : 0;
135
- const version = typeof r.version === "number" ? `v${r.version}` : "";
136
- return `Wrote registry index ${version} (${total} kits) → ${outPath}`.replace(/\s+/g, " ").trim();
137
- }
138
- export function formatEnvListPlain(r) {
139
- // Multi-env listing: { envs: [{ ref, path, keys }, ...] }
140
- const envs = Array.isArray(r.envs) ? r.envs : [];
141
- if (envs.length === 0) {
142
- return "No env files. Create one with `akm env create <name>`, then edit the .env file directly.";
143
- }
144
- const lines = [];
145
- for (const v of envs) {
146
- const ref = String(v.ref ?? "?");
147
- const keys = Array.isArray(v.keys) ? v.keys.map(String) : [];
148
- if (lines.length > 0)
149
- lines.push("");
150
- lines.push(`## ${ref}`);
151
- if (keys.length === 0) {
152
- lines.push("- (no keys)");
153
- continue;
154
- }
155
- for (const key of keys) {
156
- lines.push(`- ${key}`);
157
- }
158
- }
159
- return lines.join("\n");
160
- }
161
- export function formatEnvCreatePlain(r) {
162
- return `Created env ${String(r.ref ?? "?")}`;
163
- }
164
- export function formatEnvExportPlain(r) {
165
- return `Wrote ${String(r.ref ?? "?")} export script → ${String(r.out ?? "?")} (mode 0600; source it, then delete)`;
166
- }
167
- export function formatEnvRemovePlain(r) {
168
- const removed = r.removed === true;
169
- return removed ? `Removed env ${String(r.ref ?? "?")}` : `Env ${String(r.ref ?? "?")} was not present`;
170
- }
171
- export function formatEnvSetPlain(r) {
172
- return `Set ${String(r.key ?? "?")} in env ${String(r.ref ?? "?")} (value not displayed)`;
173
- }
174
- export function formatEnvUnsetPlain(r) {
175
- const removed = Array.isArray(r.removed) ? r.removed.map(String) : [];
176
- const missing = Array.isArray(r.missing) ? r.missing.map(String) : [];
177
- const ref = String(r.ref ?? "?");
178
- const parts = [];
179
- if (removed.length > 0)
180
- parts.push(`Removed ${removed.join(", ")} from env ${ref}`);
181
- if (missing.length > 0)
182
- parts.push(`Not present in env ${ref}: ${missing.join(", ")}`);
183
- return parts.join("\n") || `No keys changed in env ${ref}`;
184
- }
185
- export function formatWikiRegisterPlain(r) {
186
- const name = String(r.name ?? r.wiki ?? "?");
187
- const ref = String(r.ref ?? r.path ?? r.url ?? "?");
188
- return `Registered wiki ${name} → ${ref}`;
189
- }
190
- export function formatWorkflowValidatePlain(r) {
191
- const ok = r.ok !== false;
192
- const pathValue = String(r.path ?? "?");
193
- if (!ok)
194
- return `workflow validate: failed (${pathValue})`;
195
- const title = typeof r.title === "string" ? r.title : "";
196
- const stepCount = typeof r.stepCount === "number" ? r.stepCount : 0;
197
- const lines = [`workflow validate: ok — ${title || pathValue} (${stepCount} step(s))`];
198
- // Non-fatal advisories: clearly marked, printed after the ok line so `ok`
199
- // is never in doubt. Absent/empty for markdown and fully-typed programs.
200
- const warnings = Array.isArray(r.warnings) ? r.warnings : [];
201
- if (warnings.length > 0) {
202
- lines.push(` ${warnings.length} warning(s):`);
203
- for (const w of warnings) {
204
- const line = typeof w.line === "number" ? w.line : "?";
205
- lines.push(` warning: ${pathValue}:${line} — ${String(w.message ?? "")}`);
206
- }
207
- }
208
- return lines.join("\n");
209
- }
210
4
  /**
211
- * Plain-text rendering for a step-completion that was rejected by the
212
- * summary-validation gate (#506): the step stays pending and the agent gets
213
- * corrective feedback on what to finish/fix.
214
- */
215
- export function formatWorkflowCompleteRejectedPlain(r) {
216
- const stepId = String(r.stepId ?? "?");
217
- const feedback = typeof r.feedback === "string" ? r.feedback : "";
218
- const missing = Array.isArray(r.missing) ? r.missing.map((m) => String(m)) : [];
219
- const lines = [`workflow complete: rejected — step "${stepId}" does not meet its completion criteria`];
220
- if (feedback)
221
- lines.push(` feedback: ${feedback}`);
222
- if (missing.length > 0) {
223
- lines.push(" outstanding:");
224
- for (const m of missing)
225
- lines.push(` - ${m}`);
226
- }
227
- return lines.join("\n");
228
- }
229
- export function formatProposalProducerPlain(command, r) {
230
- if (r.ok === false) {
231
- const reason = String(r.reason ?? "unknown");
232
- const error = typeof r.error === "string" ? r.error : "";
233
- const lines = [`${command}: failed (${reason})`];
234
- if (error)
235
- lines.push(` error: ${error}`);
236
- if (r.ref)
237
- lines.push(` ref: ${String(r.ref)}`);
238
- if (r.exitCode !== undefined && r.exitCode !== null) {
239
- lines.push(` exitCode: ${String(r.exitCode)}`);
240
- }
241
- return lines.join("\n");
242
- }
243
- const proposal = r.proposal ?? {};
244
- const id = String(proposal.id ?? "?");
245
- const ref = String(r.ref ?? proposal.ref ?? "?");
246
- const status = String(proposal.status ?? "pending");
247
- return `${command}: queued proposal ${id} (${ref}) [${status}]`;
248
- }
249
- /**
250
- * Render a one-line gate-decision summary for the proposal list / show surfaces
251
- * (#577), e.g. `gate=deferred:below-threshold (0.72 < 0.90)`. Returns the empty
252
- * string for a missing or malformed decision so legacy proposals render cleanly.
253
- */
254
- export function formatGateDecisionSummary(raw) {
255
- if (typeof raw !== "object" || raw === null)
256
- return "";
257
- const d = raw;
258
- const outcome = typeof d.outcome === "string" ? d.outcome : undefined;
259
- if (!outcome)
260
- return "";
261
- const reason = typeof d.reason === "string" && d.reason.length > 0 ? `:${d.reason}` : "";
262
- const cmp = formatGateThresholdComparison(d);
263
- return `gate=${outcome}${reason}${cmp ? ` (${cmp})` : ""}`;
264
- }
265
- /**
266
- * Reconstruct the threshold comparison the gate applied, when both sides are
267
- * present (e.g. confidence 0.72 vs. autoAccept 0.90 → "0.72 < 0.90"). Returns
268
- * the empty string when the decision lacks the operands.
269
- */
270
- function formatGateThresholdComparison(d) {
271
- const thresholds = (typeof d.thresholds === "object" && d.thresholds !== null ? d.thresholds : {});
272
- const confidence = typeof d.confidence === "number" ? d.confidence : undefined;
273
- const autoAccept = typeof thresholds.autoAccept === "number" ? thresholds.autoAccept : undefined;
274
- if (confidence !== undefined && autoAccept !== undefined) {
275
- const op = confidence >= autoAccept ? ">=" : "<";
276
- return `${confidence.toFixed(2)} ${op} ${autoAccept.toFixed(2)}`;
277
- }
278
- // Drain bands: when the measured value is present, render the full comparison
279
- // ("210 > 200" / "1 < 5"); otherwise fall back to the bound alone (#577).
280
- const measured = typeof d.measured === "number" ? d.measured : undefined;
281
- if (typeof thresholds.maxDiffLines === "number") {
282
- return measured !== undefined
283
- ? `${measured} > ${thresholds.maxDiffLines}`
284
- : `maxDiffLines=${thresholds.maxDiffLines}`;
285
- }
286
- if (typeof thresholds.minContentLines === "number") {
287
- return measured !== undefined
288
- ? `${measured} < ${thresholds.minContentLines}`
289
- : `minContentLines=${thresholds.minContentLines}`;
290
- }
291
- return "";
292
- }
293
- export function formatProposalListPlain(r) {
294
- const proposals = Array.isArray(r.proposals) ? r.proposals : [];
295
- const total = typeof r.totalCount === "number" ? r.totalCount : proposals.length;
296
- if (proposals.length === 0) {
297
- return `${total} proposal(s).\nNo proposals.\nGenerate one with \`akm reflect <ref>\`, \`akm propose <type> <name> --task ...\`, or \`akm distill <ref>\`.`;
298
- }
299
- const lines = [`${total} proposal(s)`, ""];
300
- for (const p of proposals) {
301
- const id = String(p.id ?? "?");
302
- const ref = String(p.ref ?? "?");
303
- const status = String(p.status ?? "?");
304
- const source = String(p.source ?? "?");
305
- const created = String(p.createdAt ?? "?");
306
- // #577: surface the gate verdict inline so the queue explains itself
307
- // ("deferred: below-threshold"). Legacy proposals carry no gateDecision.
308
- const gate = formatGateDecisionSummary(p.gateDecision);
309
- const gateSuffix = gate ? ` ${gate}` : "";
310
- lines.push(`${id} [${status}] ${ref} source=${source} ${created}${gateSuffix}`);
311
- }
312
- return lines.join("\n").trimEnd();
313
- }
314
- export function formatProposalShowPlain(r) {
315
- const p = r.proposal ?? {};
316
- const lines = [];
317
- lines.push(`# proposal ${String(p.id ?? "?")}`);
318
- lines.push(`ref: ${String(p.ref ?? "?")}`);
319
- lines.push(`status: ${String(p.status ?? "?")}`);
320
- lines.push(`source: ${String(p.source ?? "?")}`);
321
- if (p.sourceRun)
322
- lines.push(`sourceRun: ${String(p.sourceRun)}`);
323
- if (p.createdAt)
324
- lines.push(`createdAt: ${String(p.createdAt)}`);
325
- if (p.updatedAt)
326
- lines.push(`updatedAt: ${String(p.updatedAt)}`);
327
- if (typeof p.confidence === "number")
328
- lines.push(`confidence: ${p.confidence.toFixed(2)}`);
329
- // #577: gate decision (auto-accepted / deferred / auto-rejected + reason +
330
- // thresholds). Absent on legacy proposals — render "unknown" so the field is
331
- // always present and the operator never sees a silent gap.
332
- const gate = p.gateDecision;
333
- if (gate && typeof gate.outcome === "string") {
334
- lines.push(`gate.decision: ${String(gate.outcome)}`);
335
- lines.push(`gate.reason: ${gate.reason ? String(gate.reason) : "unknown"}`);
336
- const cmp = formatGateThresholdComparison(gate);
337
- if (cmp)
338
- lines.push(`gate.thresholds: ${cmp}`);
339
- if (gate.gate)
340
- lines.push(`gate.by: ${String(gate.gate)}`);
341
- if (gate.decidedAt)
342
- lines.push(`gate.decidedAt: ${String(gate.decidedAt)}`);
343
- }
344
- else {
345
- lines.push("gate.decision: unknown");
346
- }
347
- const review = p.review;
348
- if (review) {
349
- lines.push(`review.outcome: ${String(review.outcome ?? "?")}`);
350
- if (review.reason)
351
- lines.push(`review.reason: ${String(review.reason)}`);
352
- if (review.decidedAt)
353
- lines.push(`review.decidedAt: ${String(review.decidedAt)}`);
354
- }
355
- const validation = r.validation;
356
- if (validation) {
357
- const findings = Array.isArray(validation.findings) ? validation.findings : [];
358
- // Partition findings by severity. `severity: "warn"` findings are
359
- // non-blocking (the validator reports `ok: true` for a warn-only proposal),
360
- // so they must read as advisory — a distinct icon/label from blocking errors.
361
- const warnings = findings.filter((f) => f.severity === "warn");
362
- const errors = findings.filter((f) => f.severity !== "warn");
363
- lines.push("");
364
- if (errors.length > 0) {
365
- const warnSuffix = warnings.length > 0 ? `, ${warnings.length} warning(s)` : "";
366
- lines.push(`✗ invalid (${errors.length} error(s)${warnSuffix})`);
367
- }
368
- else if (warnings.length > 0) {
369
- lines.push(`✓ valid (${warnings.length} warning(s))`);
370
- }
371
- else {
372
- lines.push("✓ valid");
373
- }
374
- // Errors first (blocking), then warnings (advisory, non-blocking).
375
- for (const f of errors) {
376
- lines.push(` ✗ error [${String(f.kind)}] ${String(f.message)}`);
377
- }
378
- for (const f of warnings) {
379
- lines.push(` ⚠ warning [${String(f.kind)}] ${String(f.message)} (non-blocking)`);
380
- }
381
- }
382
- const payload = p.payload;
383
- if (payload && typeof payload.content === "string") {
384
- lines.push("");
385
- lines.push("payload:");
386
- lines.push(payload.content);
387
- }
388
- return lines.join("\n").trimEnd();
389
- }
390
- export function formatProposalAcceptPlain(r) {
391
- return `Accepted proposal ${String(r.id ?? "?")} → ${String(r.ref ?? "?")} at ${String(r.assetPath ?? "?")}`;
392
- }
393
- export function formatProposalRejectPlain(r) {
394
- const reason = r.reason ? ` (${String(r.reason)})` : "";
395
- return `Rejected proposal ${String(r.id ?? "?")} (${String(r.ref ?? "?")})${reason}`;
396
- }
397
- export function formatProposalDrainPlain(r) {
398
- const policy = String(r.policy ?? "?");
399
- const applyMode = String(r.applyMode ?? "queue");
400
- const promoted = Array.isArray(r.promoted) ? r.promoted : [];
401
- const rejected = Array.isArray(r.rejected) ? r.rejected : [];
402
- const deferred = Array.isArray(r.deferred) ? r.deferred : [];
403
- const skippedByCap = Array.isArray(r.skippedByCap) ? r.skippedByCap : [];
404
- const staged = Array.isArray(r.staged) ? r.staged : [];
405
- const prefix = r.dryRun === true ? "[dry-run] " : "";
406
- const lines = [
407
- `${prefix}Drained proposal queue (strategy=${String(r.strategy ?? "?")}, policy=${policy}, applyMode=${applyMode})`,
408
- ` promoted: ${promoted.length}`,
409
- ` rejected: ${rejected.length}`,
410
- ` deferred: ${deferred.length}`,
411
- ` skippedByCap: ${skippedByCap.length}`,
412
- ` staged: ${staged.length}`,
413
- ];
414
- for (const d of deferred) {
415
- lines.push(` - ${String(d.id ?? "?")} (${String(d.reason ?? "?")})`);
416
- }
417
- return lines.join("\n").trimEnd();
418
- }
419
- export function formatDistillPlain(r) {
420
- const outcome = String(r.outcome ?? "unknown");
421
- const inputRef = String(r.inputRef ?? "?");
422
- const lessonRef = String(r.lessonRef ?? "?");
423
- if (outcome === "queued") {
424
- const id = String(r.proposalId ?? "?");
425
- return `Distilled ${inputRef} → proposal ${id} (${lessonRef}). Run \`akm proposal show ${id}\` to review.`;
426
- }
427
- if (outcome === "validation_failed") {
428
- const findings = Array.isArray(r.findings) ? r.findings : [];
429
- const lines = [`Distillation produced an invalid lesson for ${inputRef}; no proposal queued.`];
430
- for (const f of findings) {
431
- lines.push(` - ${String(f.message ?? f.kind ?? "validation finding")}`);
432
- }
433
- return lines.join("\n");
434
- }
435
- // skipped
436
- const message = typeof r.message === "string" ? r.message : "feature disabled or LLM unavailable";
437
- return `Distill skipped for ${inputRef}: ${message}`;
438
- }
439
- export function formatProposalDiffPlain(r) {
440
- const header = r.isNew
441
- ? `# proposal ${String(r.id ?? "?")} (new asset: ${String(r.ref ?? "?")})`
442
- : `# proposal ${String(r.id ?? "?")} (update: ${String(r.ref ?? "?")})`;
443
- const unified = typeof r.unified === "string" ? r.unified : "";
444
- if (!unified)
445
- return `${header}\n(no changes)`;
446
- return `${header}\n${unified}`;
447
- }
448
- export function formatEventsPlain(r) {
449
- const events = Array.isArray(r.events) ? r.events : [];
450
- const headerParts = [];
451
- if (typeof r.ref === "string" && r.ref)
452
- headerParts.push(`ref: ${r.ref}`);
453
- if (typeof r.type === "string" && r.type)
454
- headerParts.push(`type: ${r.type}`);
455
- if (typeof r.since === "string" && r.since)
456
- headerParts.push(`since: ${r.since}`);
457
- const totalCount = typeof r.totalCount === "number" ? r.totalCount : events.length;
458
- headerParts.push(`${totalCount} event(s)`);
459
- const header = headerParts.join(" ");
460
- if (events.length === 0) {
461
- return `${header}\nNo events.`;
462
- }
463
- const lines = [header, ""];
464
- for (const event of events) {
465
- lines.push(formatEventLine(event));
466
- }
467
- return lines.join("\n").trimEnd();
468
- }
469
- export function formatEventLine(event) {
470
- const ts = String(event.ts ?? "?");
471
- const eventType = String(event.eventType ?? "?");
472
- const ref = event.ref ? String(event.ref) : null;
473
- const head = ref ? `${ts} [${eventType}] ${ref}` : `${ts} [${eventType}]`;
474
- if (event.metadata != null && event.metadata !== "") {
475
- const meta = typeof event.metadata === "string" ? event.metadata : JSON.stringify(event.metadata);
476
- return `${head}\n metadata: ${meta}`;
477
- }
478
- return head;
479
- }
480
- export function formatHistoryPlain(r) {
481
- const entries = Array.isArray(r.entries) ? r.entries : [];
482
- const headerParts = [];
483
- if (typeof r.ref === "string" && r.ref)
484
- headerParts.push(`ref: ${r.ref}`);
485
- if (typeof r.since === "string" && r.since)
486
- headerParts.push(`since: ${r.since}`);
487
- const totalCount = typeof r.totalCount === "number" ? r.totalCount : entries.length;
488
- headerParts.push(`${totalCount} event(s)`);
489
- // Show active event sources so operators know which streams were consulted.
490
- if (Array.isArray(r.sources) && r.sources.length > 0) {
491
- headerParts.push(`sources: ${r.sources.join(", ")}`);
492
- }
493
- const header = headerParts.join(" ");
494
- if (entries.length === 0) {
495
- const scope = typeof r.ref === "string" && r.ref ? ` for ${r.ref}` : "";
496
- return `${header}\nNo history${scope}.`;
497
- }
498
- const lines = [header, ""];
499
- for (const entry of entries) {
500
- const created = String(entry.createdAt ?? "?");
501
- const eventType = String(entry.eventType ?? "?");
502
- const ref = entry.ref ? String(entry.ref) : null;
503
- const signal = entry.signal ? String(entry.signal) : null;
504
- const query = entry.query ? String(entry.query) : null;
505
- const head = ref ? `${created} [${eventType}] ${ref}` : `${created} [${eventType}]`;
506
- lines.push(head);
507
- if (signal)
508
- lines.push(` signal: ${signal}`);
509
- if (query)
510
- lines.push(` query: ${query}`);
511
- if (entry.metadata != null && entry.metadata !== "") {
512
- const meta = typeof entry.metadata === "string" ? entry.metadata : JSON.stringify(entry.metadata);
513
- lines.push(` metadata: ${meta}`);
514
- }
515
- }
516
- return lines.join("\n").trimEnd();
517
- }
518
- export function formatShowPlain(r, detail) {
519
- const lines = [];
520
- if (r.type || r.name) {
521
- lines.push(`# ${String(r.type ?? "asset")}: ${String(r.name ?? "unknown")}`);
522
- }
523
- if (r.path && r.editable !== false) {
524
- lines.push(`file: ${String(r.path)}`);
525
- }
526
- if (r.origin !== undefined)
527
- lines.push(`# origin: ${String(r.origin)}`);
528
- if (r.action)
529
- lines.push(`# ${String(r.action)}`);
530
- if (r.description)
531
- lines.push(`description: ${String(r.description)}`);
532
- if (r.workflowTitle)
533
- lines.push(`workflowTitle: ${String(r.workflowTitle)}`);
534
- if (r.agent)
535
- lines.push(`agent: ${String(r.agent)}`);
536
- if (Array.isArray(r.parameters) && r.parameters.length > 0)
537
- lines.push(`parameters: ${r.parameters.join(", ")}`);
538
- if (Array.isArray(r.workflowParameters) && r.workflowParameters.length > 0) {
539
- lines.push("workflowParameters:");
540
- for (const parameter of r.workflowParameters) {
541
- const name = typeof parameter.name === "string" ? parameter.name : "unknown";
542
- const description = typeof parameter.description === "string" && parameter.description.trim() ? `: ${parameter.description}` : "";
543
- lines.push(` - ${name}${description}`);
544
- }
545
- }
546
- if (r.modelHint != null)
547
- lines.push(`modelHint: ${String(r.modelHint)}`);
548
- if (r.toolPolicy != null)
549
- lines.push(`toolPolicy: ${JSON.stringify(r.toolPolicy)}`);
550
- if (r.run)
551
- lines.push(`run: ${String(r.run)}`);
552
- if (r.setup)
553
- lines.push(`setup: ${String(r.setup)}`);
554
- if (r.cwd)
555
- lines.push(`cwd: ${String(r.cwd)}`);
556
- if (detail === "full") {
557
- if (r.path)
558
- lines.push(`path: ${String(r.path)}`);
559
- if (r.editable !== undefined)
560
- lines.push(`editable: ${String(r.editable)}`);
561
- if (r.editHint)
562
- lines.push(`editHint: ${String(r.editHint)}`);
563
- if (r.schemaVersion !== undefined)
564
- lines.push(`schemaVersion: ${String(r.schemaVersion)}`);
565
- }
566
- const related = typeof r.related === "object" && r.related !== null ? r.related : undefined;
567
- const relatedHits = related && Array.isArray(related.hits) ? related.hits : [];
568
- if (related) {
569
- lines.push("");
570
- lines.push(`related: ${String(related.total ?? relatedHits.length)}`);
571
- for (const hit of relatedHits) {
572
- lines.push(` - ${String(hit.type ?? "?")}: ${formatRelatedLabel(hit)}`);
573
- const shared = Array.isArray(hit.sharedEntities) ? hit.sharedEntities.map(String) : [];
574
- if (shared.length > 0)
575
- lines.push(` shared: ${shared.join(", ")}`);
576
- lines.push(` relationCount: ${String(hit.relationCount ?? 0)}`);
577
- }
578
- }
579
- const payloads = [r.content, r.template, r.prompt].filter((value) => value != null).map(String);
580
- if (Array.isArray(r.steps) && r.steps.length > 0) {
581
- if (lines.length > 0)
582
- lines.push("");
583
- lines.push("steps:");
584
- for (const [index, step] of r.steps.entries()) {
585
- const title = typeof step.title === "string" ? step.title : "Untitled step";
586
- const id = typeof step.id === "string" ? step.id : "unknown";
587
- lines.push(` ${index + 1}. ${title} [${id}]`);
588
- if (typeof step.instructions === "string" && step.instructions.trim()) {
589
- const instrLines = step.instructions.trim().split("\n");
590
- lines.push(` instructions: ${instrLines[0]}`);
591
- for (const instrLine of instrLines.slice(1))
592
- lines.push(` ${instrLine}`);
593
- }
594
- if (Array.isArray(step.completionCriteria) && step.completionCriteria.length > 0) {
595
- lines.push(" completion:");
596
- for (const criterion of step.completionCriteria) {
597
- lines.push(` - ${String(criterion)}`);
598
- }
599
- }
600
- }
601
- }
602
- if (payloads.length > 0) {
603
- if (lines.length > 0)
604
- lines.push("");
605
- lines.push(...payloads);
606
- }
607
- // REC-01 / REC-09: Append a type-specific directive so agents apply the
608
- // content rather than substituting training-data approximations.
609
- const assetType = typeof r.type === "string" ? r.type : null;
610
- const assetRef = typeof r.name === "string" && assetType ? `${assetType}:${r.name}` : null;
611
- // Show-loop detection: if the agent has shown this asset 3+ times without
612
- // writing anything, surface a warning so it stops cycling and acts.
613
- const showLoopCount = typeof r.showLoopWarning === "number" ? r.showLoopWarning : 0;
614
- if (showLoopCount >= 3) {
615
- lines.push("");
616
- lines.push(`WARNING: You have shown this asset ${showLoopCount} times without completing the task.`);
617
- lines.push("Stop re-reading — you have the information you need. Act on it now:");
618
- lines.push(" - Write your output file using the content above.");
619
- lines.push(` - If this asset does not contain what you need, run \`akm feedback '${assetRef ?? "<ref>"}' --negative\` and search for a different asset.`);
620
- }
621
- if (assetType === "skill" || assetType === "knowledge") {
622
- const activeRun = r.activeRun;
623
- if (activeRun) {
624
- // Active workflow: redirect agent to workflow commands instead of direct apply
625
- lines.unshift(` akm workflow complete '${activeRun.runId}'${activeRun.stepId ? ` --step '${activeRun.stepId}'` : ""}`);
626
- lines.unshift("Read this schema, then follow your workflow step's instructions to edit the workspace file. When done, mark the step complete:");
627
- lines.unshift(`WORKFLOW ACTIVE — schema shown as reference (run: ${activeRun.runId})`);
628
- lines.unshift("---");
629
- lines.unshift("");
630
- // Still show feedback line at the end but skip the APPLY directive
631
- lines.push("");
632
- lines.push(`Run \`akm feedback ${assetRef ? `'${assetRef}'` : "<ref>"} --positive\` if the step succeeds, or \`--negative\` if this schema did not help.`);
633
- }
634
- else {
635
- // No active workflow: show the APPLY directive. Branch on whether this
636
- // skill primarily teaches CLI commands (shell output) vs YAML schema.
637
- const preApplyLines = [...lines];
638
- lines.push("");
639
- lines.push("---");
640
- if (isCommandOutputSkill(preApplyLines)) {
641
- lines.push("APPLY (only if no workflow step is required for this task):");
642
- lines.push(" 1. Identify the output file from README.md (typically commands.txt).");
643
- lines.push(" 2. Write the exact command syntax from the code blocks above — replace every placeholder (`<name>`, `<value>`) with a real, concrete value from your task context. Do not write placeholder text.");
644
- lines.push(" 3. Each command should be on a single line (no backslash line continuation unless the verifier expects it).");
645
- lines.push(`Run \`akm feedback ${assetRef ? `'${assetRef}'` : "<ref>"} --positive\` after the task succeeds, or \`--negative\` if this reference did not contain the needed command syntax.`);
646
- }
647
- else {
648
- lines.push("APPLY (only if no workflow step is required for this task):");
649
- lines.push(" 1. Identify the target file from README.md — write or edit it. If the file does not yet exist, CREATE it with the full structure from this schema.");
650
- lines.push(" 2. Add/edit the fields shown above using the exact field names from this schema.");
651
- lines.push(" 3. COPY the exact YAML structure and field names from the code blocks above — do not substitute synonyms or invent nesting. Replace every placeholder value with a real, concrete value from your task context. Do not leave any field as null, empty, or a placeholder.");
652
- lines.push(`Run \`akm feedback ${assetRef ? `'${assetRef}'` : "<ref>"} --positive\` after the task succeeds, or \`--negative\` if the task fails after following this guidance.`);
653
- }
654
- }
655
- }
656
- else if (assetType === "workflow") {
657
- const workflowName = typeof r.name === "string" ? r.name : null;
658
- const workflowRef = workflowName ? `workflow:${workflowName}` : "<ref>";
659
- // Insert action directive BEFORE the workflow content by prepending to lines at the
660
- // separator position. We find where the header ends and insert after the first `---`.
661
- // Since lines already contain the full content at this point, we locate the insertion
662
- // index: right after the first `---` separator if present, otherwise after the header.
663
- const separatorIdx = lines.indexOf("---");
664
- const insertIdx = separatorIdx >= 0 ? separatorIdx + 1 : r.type || r.name ? 1 : 0;
665
- const actionDirective = [
666
- `ACTION REQUIRED: Do not execute steps manually from this output.`,
667
- `Run \`akm workflow next '${workflowRef}'\` to get your current step with exact instructions.`,
668
- "---",
669
- ];
670
- lines.splice(insertIdx, 0, "", ...actionDirective);
671
- lines.push("");
672
- lines.push("---");
673
- lines.push(`NEXT STEP: Run \`akm workflow next '${workflowRef}'\` to see the current workflow step.`);
674
- lines.push("Do not edit workspace files before completing each step with `akm workflow complete`.");
675
- }
676
- return lines.length > 0 ? lines.join("\n") : null;
677
- }
678
- /**
679
- * Detect whether a skill's rendered content primarily teaches CLI commands
680
- * rather than YAML schema. Used to select the right APPLY directive variant.
5
+ * Pure plain-text formatting helper functions shared across per-command
6
+ * text formatter modules.
681
7
  *
682
- * Heuristic: count code-block lines that start with known shell command
683
- * prefixes vs lines that look like YAML key-value pairs. If CLI lines
684
- * outnumber YAML lines (and there is at least one CLI line), treat the
685
- * skill as command-output.
686
- */
687
- function isCommandOutputSkill(lines) {
688
- const codeLines = lines.filter((l) => l.startsWith(" ") || l.startsWith("\t") || /^`/.test(l));
689
- const cliPattern = /^(az |kubectl |docker |git |helm |terraform |aws |gcloud )/;
690
- const yamlPattern = /^\s+\w+:/;
691
- const cliCount = codeLines.filter((l) => cliPattern.test(l.trim())).length;
692
- const yamlCount = codeLines.filter((l) => yamlPattern.test(l)).length;
693
- return cliCount > yamlCount && cliCount > 0;
694
- }
695
- export function formatWorkflowListPlain(result) {
696
- const runs = Array.isArray(result.runs) ? result.runs : [];
697
- if (runs.length === 0) {
698
- return "No workflow runs in the current working scope. Start one with `akm workflow next workflow:<name>` or author one with `akm workflow create <name>`.";
699
- }
700
- return runs
701
- .map((run) => {
702
- const id = typeof run.id === "string" ? run.id : "unknown";
703
- const ref = typeof run.workflowRef === "string" ? run.workflowRef : "workflow:unknown";
704
- const status = typeof run.status === "string" ? run.status : "unknown";
705
- const currentStep = typeof run.currentStepId === "string" ? ` (current: ${run.currentStepId})` : "";
706
- return `${id} ${ref} [${status}]${currentStep}`;
707
- })
708
- .join("\n");
709
- }
710
- export function formatWorkflowStatusPlain(result) {
711
- const run = typeof result.run === "object" && result.run !== null ? result.run : undefined;
712
- const workflow = typeof result.workflow === "object" && result.workflow !== null
713
- ? result.workflow
714
- : undefined;
715
- if (!run || !workflow)
716
- return null;
717
- const lines = [
718
- `workflow: ${String(workflow.ref ?? "workflow:unknown")}`,
719
- `run: ${String(run.id ?? "unknown")}`,
720
- `title: ${String(run.workflowTitle ?? workflow.title ?? "Workflow")}`,
721
- `status: ${String(run.status ?? "unknown")}`,
722
- ];
723
- if (run.currentStepId)
724
- lines.push(`currentStep: ${String(run.currentStepId)}`);
725
- const steps = Array.isArray(workflow.steps) ? workflow.steps : [];
726
- if (steps.length > 0) {
727
- lines.push("steps:");
728
- for (const step of steps) {
729
- const title = typeof step.title === "string" ? step.title : "Untitled step";
730
- const id = typeof step.id === "string" ? step.id : "unknown";
731
- const status = typeof step.status === "string" ? step.status : "unknown";
732
- lines.push(` - ${title} [${id}] (${status})`);
733
- if (typeof step.notes === "string" && step.notes.trim()) {
734
- lines.push(` notes: ${step.notes}`);
735
- }
736
- }
737
- }
738
- // `workflow status --units` (#22): the honest per-unit diagnostic surface —
739
- // failure_reason plus any journaled result/error text. Diagnostics only; the
740
- // deterministic step evidence above is unaffected.
741
- const units = Array.isArray(result.units) ? result.units : undefined;
742
- if (units) {
743
- lines.push("");
744
- lines.push(units.length > 0 ? "units:" : "units: (none journaled)");
745
- for (const unit of units) {
746
- const id = typeof unit.unitId === "string" ? unit.unitId : "unknown";
747
- const status = typeof unit.status === "string" ? unit.status : "unknown";
748
- const node = typeof unit.nodeId === "string" ? unit.nodeId : "";
749
- const attempts = typeof unit.attempts === "number" ? unit.attempts : undefined;
750
- const suffix = attempts !== undefined && attempts > 1 ? `, attempt ${attempts}` : "";
751
- lines.push(` - ${id} [${node}] (${status}${suffix})`);
752
- // Codex round-3 finding B: a `running` claim gone silent past the check-in
753
- // window — the driver likely died. Surface it (with the claim holder) so a
754
- // human can reclaim/re-run the unit, matching what `brief` reports.
755
- if (unit.stale === true) {
756
- const holder = typeof unit.claimHolder === "string" && unit.claimHolder.trim() ? ` claimed by ${unit.claimHolder}` : "";
757
- lines.push(` stale: claim went silent past the check-in window${holder} — its driver may have died`);
758
- }
759
- if (typeof unit.failureReason === "string" && unit.failureReason.trim()) {
760
- lines.push(` failure_reason: ${unit.failureReason}`);
761
- }
762
- if (typeof unit.diagnostic === "string" && unit.diagnostic.trim()) {
763
- const diagLines = unit.diagnostic.split("\n");
764
- lines.push(` diagnostic: ${diagLines[0]}`);
765
- for (const diagLine of diagLines.slice(1))
766
- lines.push(` ${diagLine}`);
767
- }
768
- }
769
- }
770
- // Review C2: the check-in `continue` directive must survive plain-text
771
- // rendering — JSON consumers saw `checkin` but the text path dropped it.
772
- const checkinLine = formatWorkflowCheckinLine(result);
773
- if (checkinLine) {
774
- lines.push("");
775
- lines.push(checkinLine);
776
- }
777
- return lines.join("\n");
778
- }
779
- /**
780
- * Render the stalled-run check-in directive (#506) when present on a
781
- * workflow-next/status result. Returns null when the run is healthy.
8
+ * This module is a re-export BARREL: the actual implementations live in
9
+ * cohesive sibling modules (`show-format.ts`, `show-directives.ts`,
10
+ * `workflow-format.ts`, `proposal-format.ts`, `command-format.ts`) split out
11
+ * of what used to be a single 1418-line / 59-function file. Every name that
12
+ * was previously importable from `"./helpers"` (directly, or transitively via
13
+ * `../text.ts`) stays importable from here unchanged — no import site needed
14
+ * to move.
15
+ *
16
+ * No registry imports — no circular dependencies.
782
17
  */
783
- function formatWorkflowCheckinLine(result) {
784
- const checkin = typeof result.checkin === "object" && result.checkin !== null
785
- ? result.checkin
786
- : undefined;
787
- if (!checkin || typeof checkin.directive !== "string" || !checkin.directive.trim())
788
- return null;
789
- return checkin.directive.trim();
790
- }
791
- export function formatWorkflowNextPlain(result) {
792
- const base = formatWorkflowStatusPlain(result);
793
- const step = typeof result.step === "object" && result.step !== null ? result.step : undefined;
794
- if (!step)
795
- return base;
796
- const lines = base ? [base, "", "next:"] : ["next:"];
797
- lines.push(` ${String(step.title ?? "Untitled step")} [${String(step.id ?? "unknown")}]`);
798
- if (typeof step.instructions === "string" && step.instructions.trim()) {
799
- const instrLines = step.instructions.trim().split("\n");
800
- lines.push(` instructions: ${instrLines[0]}`);
801
- for (const instrLine of instrLines.slice(1))
802
- lines.push(` ${instrLine}`);
803
- }
804
- const completion = Array.isArray(step.completionCriteria) ? step.completionCriteria : [];
805
- if (completion.length > 0) {
806
- lines.push(" completion:");
807
- for (const criterion of completion) {
808
- lines.push(` - ${String(criterion)}`);
809
- }
810
- }
811
- // T2-3: surface run-id as labeled field
812
- const run = typeof result.run === "object" && result.run !== null ? result.run : undefined;
813
- const runId = typeof run?.id === "string" ? run.id : null;
814
- const stepId = typeof step?.id === "string" ? step.id : null;
815
- if (runId) {
816
- lines.push("");
817
- lines.push(`runId: ${runId}`);
818
- }
819
- // T1-6: complete command
820
- if (runId && stepId) {
821
- lines.push("");
822
- lines.push("COMPLETE THIS STEP:");
823
- lines.push(` akm workflow complete '${runId}' --step '${stepId}'`);
824
- }
825
- else if (runId) {
826
- lines.push("");
827
- lines.push("COMPLETE THIS STEP:");
828
- lines.push(` akm workflow complete '${runId}' --step '<step-id>'`);
829
- }
830
- return lines.join("\n");
831
- }
832
- export function formatWorkflowRunPlain(result) {
833
- const run = typeof result.run === "object" && result.run !== null ? result.run : undefined;
834
- if (!run)
835
- return null;
836
- const lines = [`run: ${String(run.id ?? "unknown")}`, `status: ${String(run.status ?? "unknown")}`];
837
- const executed = Array.isArray(result.executed) ? result.executed : [];
838
- if (executed.length === 0) {
839
- lines.push("executed: (no steps — run was already done or blocked)");
840
- }
841
- else {
842
- lines.push("executed:");
843
- for (const step of executed) {
844
- const marker = step.ok === true ? "ok" : "FAILED";
845
- lines.push(` - ${String(step.stepId ?? "?")} [${marker}] units: ${String(step.unitCount ?? 0)}` +
846
- (Number(step.failedUnits ?? 0) > 0 ? ` (${String(step.failedUnits)} failed)` : ""));
847
- if (typeof step.summary === "string" && step.summary.trim()) {
848
- lines.push(` ${step.summary}`);
849
- }
850
- }
851
- }
852
- const gate = typeof result.gateRejection === "object" && result.gateRejection !== null
853
- ? result.gateRejection
854
- : undefined;
855
- if (gate) {
856
- lines.push(`gate rejected step ${String(gate.stepId ?? "?")}: ${String(gate.feedback ?? "")}`);
857
- const missing = Array.isArray(gate.missing) ? gate.missing : [];
858
- for (const item of missing)
859
- lines.push(` missing: ${String(item)}`);
860
- }
861
- if (result.done === true)
862
- lines.push("workflow completed.");
863
- return lines.join("\n");
864
- }
865
- export function formatWorkflowBriefPlain(result) {
866
- const run = typeof result.run === "object" && result.run !== null ? result.run : undefined;
867
- if (!run)
868
- return null;
869
- const lines = [];
870
- lines.push(`# Workflow brief: ${String(run.id ?? "unknown")}`);
871
- lines.push(`workflow: ${String(run.workflowRef ?? "?")} (${String(run.workflowTitle ?? "")})`);
872
- lines.push(`status: ${String(run.status ?? "?")}`);
873
- if (typeof result.message === "string")
874
- lines.push(result.message);
875
- const lease = typeof result.engineLease === "object" && result.engineLease !== null
876
- ? result.engineLease
877
- : undefined;
878
- if (lease) {
879
- const live = lease.live === true ? "LIVE" : "expired";
880
- lines.push(`engine lease: ${String(lease.holder ?? "?")} (until ${String(lease.until ?? "?")}) [${live}]`);
881
- }
882
- const warnings = Array.isArray(result.warnings) ? result.warnings : [];
883
- for (const w of warnings)
884
- lines.push(`! ${String(w)}`);
885
- if (result.done === true) {
886
- lines.push("");
887
- lines.push("This run is completed — no work remains.");
888
- return lines.join("\n");
889
- }
890
- const step = typeof result.step === "object" && result.step !== null ? result.step : undefined;
891
- if (!step) {
892
- return lines.join("\n");
893
- }
894
- const gate = typeof step.gate === "object" && step.gate !== null ? step.gate : undefined;
895
- lines.push("");
896
- lines.push(`## Active step: ${String(step.stepId ?? "?")} — ${String(step.title ?? "")} [${String(step.kind ?? "execute")}]`);
897
- if (gate) {
898
- const criteria = Array.isArray(gate.criteria) ? gate.criteria : [];
899
- lines.push(`gate: loop ${String(gate.currentLoop ?? 1)} of max ${String(gate.maxLoops ?? 1)}` +
900
- (criteria.length > 0 ? `; criteria: ${criteria.map(String).join("; ")}` : "; no completion criteria") +
901
- (gate.judgesArtifact === true ? " (artifact-judged)" : ""));
902
- }
903
- if (step.outputSchema !== undefined)
904
- lines.push("outputSchema: declared (see JSON output)");
905
- const feedback = typeof result.gateFeedback === "object" && result.gateFeedback !== null
906
- ? result.gateFeedback
907
- : undefined;
908
- if (feedback) {
909
- lines.push(`gate feedback (previous loop rejected): ${String(feedback.feedback ?? "")}`);
910
- const missing = Array.isArray(feedback.missing) ? feedback.missing : [];
911
- for (const m of missing)
912
- lines.push(` - missing: ${String(m)}`);
913
- }
914
- const route = typeof result.route === "object" && result.route !== null ? result.route : undefined;
915
- if (route) {
916
- lines.push("");
917
- lines.push(`## Route contract on ${String(route.input ?? "?")}`);
918
- const when = typeof route.when === "object" && route.when !== null ? route.when : {};
919
- for (const [value, target] of Object.entries(when))
920
- lines.push(` when "${value}" → ${String(target)}`);
921
- if (route.defaultStepId !== undefined)
922
- lines.push(` default → ${String(route.defaultStepId)}`);
923
- const decision = typeof route.decision === "object" && route.decision !== null
924
- ? route.decision
925
- : undefined;
926
- if (decision)
927
- lines.push(` decision NOW: value "${String(decision.value)}" → ${String(decision.selected)}`);
928
- else if (typeof route.decisionError === "string")
929
- lines.push(` decision error: ${route.decisionError}`);
930
- else
931
- lines.push(" decision: pending this step's output (evaluated after units complete)");
932
- }
933
- const workList = typeof result.workList === "object" && result.workList !== null
934
- ? result.workList
935
- : undefined;
936
- const units = workList && Array.isArray(workList.units) ? workList.units : [];
937
- if (workList?.error) {
938
- lines.push("");
939
- lines.push(`work-list error: ${String(workList.error)}`);
940
- }
941
- else if (units.length > 0) {
942
- lines.push("");
943
- lines.push(`## Units (${units.length})`);
944
- for (const u of units) {
945
- const model = u.model ? ` model=${String(u.model)}` : "";
946
- const journaled = typeof u.journaled === "object" && u.journaled !== null ? u.journaled : undefined;
947
- const jstatus = journaled ? ` [journaled: ${String(journaled.status)}]` : "";
948
- lines.push(`- ${String(u.unitId)} (runner=${String(u.runner)}${model})${jstatus}`);
949
- const env = Array.isArray(u.env) ? u.env : [];
950
- if (env.length > 0)
951
- lines.push(` env (names): ${env.map(String).join(", ")}`);
952
- if (u.outputSchema !== undefined)
953
- lines.push(" outputSchema: declared (see JSON output)");
954
- const resolved = typeof u.resolved === "object" && u.resolved !== null ? u.resolved : undefined;
955
- if (resolved && resolved.ok === false)
956
- lines.push(` RESOLUTION ERROR: ${String(resolved.error)}`);
957
- if (typeof u.report === "string")
958
- lines.push(` report: ${u.report}`);
959
- }
960
- }
961
- // Finding D: a non-dispatching step (route-only / empty / all-unresolvable)
962
- // advances via the `--settle` verb, surfaced so a driver can advance the spine.
963
- if (typeof result.settleCommand === "string") {
964
- lines.push("");
965
- lines.push("## Advance (no reportable units)");
966
- lines.push(`settle: ${result.settleCommand}`);
967
- }
968
- const guidance = typeof result.reportGuidance === "object" && result.reportGuidance !== null
969
- ? result.reportGuidance
970
- : undefined;
971
- if (guidance) {
972
- lines.push("");
973
- lines.push("## Reporting");
974
- if (typeof guidance.checkin === "string")
975
- lines.push(`heartbeat: ${guidance.checkin}`);
976
- if (typeof guidance.failure === "string")
977
- lines.push(`on failure: ${guidance.failure}`);
978
- }
979
- return lines.join("\n");
980
- }
981
- export function formatSearchPlain(r, detail) {
982
- const hits = r.hits ?? [];
983
- const registryHits = r.registryHits ?? [];
984
- const allHits = [...hits, ...registryHits];
985
- if (allHits.length === 0) {
986
- const warnings = Array.isArray(r.warnings) ? r.warnings : [];
987
- const hasSetupWarning = warnings.some((w) => String(w).toLowerCase().includes("no stash") || String(w).toLowerCase().includes("not configured"));
988
- if (hasSetupWarning) {
989
- return "No stash configured. Run `akm init` to create your working stash, then `akm index` to build the search index.";
990
- }
991
- const base = r.tip ? String(r.tip) : "No matches found.";
992
- return `${base}\nTry:\n akm search '<broader-term>' # fewer keywords\n akm list # see all configured sources\n akm curate '<query>' # let akm select the best match`;
993
- }
994
- const lines = [];
995
- for (const hit of allHits) {
996
- const type = hit.type ?? "unknown";
997
- const name = hit.name ?? "unnamed";
998
- const score = hit.score != null ? ` (score: ${hit.score})` : "";
999
- const desc = hit.description ? ` ${hit.description}` : "";
1000
- lines.push(`${type}: ${name}${score}`);
1001
- if (desc)
1002
- lines.push(desc);
1003
- if (hit.id)
1004
- lines.push(` id: ${String(hit.id)}`);
1005
- if (hit.ref)
1006
- lines.push(` ref: ${String(hit.ref)}`);
1007
- if (hit.origin !== undefined)
1008
- lines.push(` origin: ${String(hit.origin)}`);
1009
- if (Array.isArray(hit.keys) && hit.keys.length > 0)
1010
- lines.push(` keys: ${hit.keys.join(", ")}`);
1011
- if (hit.size)
1012
- lines.push(` size: ${String(hit.size)}`);
1013
- if (hit.action)
1014
- lines.push(` action: ${String(hit.action)}`);
1015
- if (hit.run)
1016
- lines.push(` run: ${String(hit.run)}`);
1017
- if (Array.isArray(hit.tags) && hit.tags.length > 0)
1018
- lines.push(` tags: ${hit.tags.join(", ")}`);
1019
- // Optional v1 spec §4.2 quality marker (e.g. "curated" / "proposed").
1020
- if (typeof hit.quality === "string" && hit.quality)
1021
- lines.push(` quality: ${hit.quality}`);
1022
- // Surface optional hit-level warnings (v1 spec §4.2). The legacy
1023
- // `curated` boolean was removed in v1.
1024
- if (Array.isArray(hit.warnings) && hit.warnings.length > 0) {
1025
- lines.push(` warnings: ${hit.warnings.join("; ")}`);
1026
- }
1027
- const graph = typeof hit.graph === "object" && hit.graph !== null ? hit.graph : undefined;
1028
- if (graph) {
1029
- const entities = Array.isArray(graph.entities) ? graph.entities : [];
1030
- if (entities.length > 0) {
1031
- const matched = entities
1032
- .filter((entity) => String(entity.kind ?? "") === "matched")
1033
- .map((entity) => String(entity.name ?? "?"));
1034
- const neighbors = entities
1035
- .filter((entity) => String(entity.kind ?? "") !== "matched")
1036
- .map((entity) => String(entity.name ?? "?"));
1037
- lines.push(` graph: ${[
1038
- matched.length > 0 ? `query match=${matched.join(", ")}` : undefined,
1039
- neighbors.length > 0 ? `neighbors=${neighbors.join(", ")}` : undefined,
1040
- ]
1041
- .filter(Boolean)
1042
- .join("; ")}`);
1043
- }
1044
- }
1045
- if (detail === "full") {
1046
- if (hit.path)
1047
- lines.push(` path: ${String(hit.path)}`);
1048
- if (hit.editable != null)
1049
- lines.push(` editable: ${String(hit.editable)}`);
1050
- if (hit.editHint)
1051
- lines.push(` editHint: ${String(hit.editHint)}`);
1052
- const whyMatched = hit.whyMatched;
1053
- if (whyMatched && whyMatched.length > 0) {
1054
- lines.push(` whyMatched: ${whyMatched.join(", ")}`);
1055
- }
1056
- }
1057
- lines.push(""); // blank line between hits
1058
- }
1059
- if (detail === "full" && r.timing) {
1060
- const timing = r.timing;
1061
- const parts = [];
1062
- if (timing.totalMs != null)
1063
- parts.push(`total: ${timing.totalMs}ms`);
1064
- if (timing.rankMs != null)
1065
- parts.push(`rank: ${timing.rankMs}ms`);
1066
- if (timing.embedMs != null)
1067
- parts.push(`embed: ${timing.embedMs}ms`);
1068
- if (parts.length > 0)
1069
- lines.push(`timing: ${parts.join(", ")}`);
1070
- }
1071
- // REC-02: When stash hits exist, tell the agent the next required step so it
1072
- // doesn't skip `akm show` and write from training memory instead.
1073
- if (hits.length >= 1) {
1074
- // Prefer skill/command/agent type hits for the "Next:" ref — knowledge docs are
1075
- // supplementary context, not the authoritative schema agents should load first.
1076
- const preferredHit = hits.find((h) => h.type === "skill" || h.type === "command" || h.type === "agent") ?? hits[0];
1077
- const topRef = typeof preferredHit.ref === "string" ? preferredHit.ref : null;
1078
- const hasWorkflowHit = hits.some((h) => h.type === "workflow");
1079
- if (topRef) {
1080
- if (hasWorkflowHit) {
1081
- const workflowRef = hits.find((h) => h.type === "workflow");
1082
- const wfRef = workflowRef && typeof workflowRef.ref === "string" ? workflowRef.ref : topRef;
1083
- lines.push(`Next: akm show '${topRef}' | To start a workflow: akm workflow next '${wfRef}'`);
1084
- lines.push("After running workflow next: follow each step and run `akm workflow complete <run-id> --step <step-id>` when done.");
1085
- }
1086
- else {
1087
- lines.push(`Next: akm show '${topRef}'`);
1088
- lines.push("After reading the asset: check whether a workflow applies before editing — if so, use `akm workflow next` instead.");
1089
- }
1090
- }
1091
- }
1092
- return lines.join("\n").trimEnd();
1093
- }
1094
- export function formatWikiListPlain(r) {
1095
- const wikis = Array.isArray(r.wikis) ? r.wikis : [];
1096
- if (wikis.length === 0)
1097
- return "No wikis. Create one with `akm wiki create <name>` or register one with `akm wiki register <name> <path-or-repo>`.";
1098
- const lines = ["NAME\tPAGES\tRAWS\tLAST-MODIFIED"];
1099
- for (const w of wikis) {
1100
- const name = typeof w.name === "string" ? w.name : "?";
1101
- const pages = typeof w.pages === "number" ? w.pages : 0;
1102
- const raws = typeof w.raws === "number" ? w.raws : 0;
1103
- const modified = typeof w.lastModified === "string" ? w.lastModified : "-";
1104
- lines.push(`${name}\t${pages}\t${raws}\t${modified}`);
1105
- }
1106
- return lines.join("\n");
1107
- }
1108
- export function formatWikiShowPlain(r) {
1109
- const lines = [];
1110
- if (r.name)
1111
- lines.push(`# wiki: ${String(r.name)}`);
1112
- if (r.path)
1113
- lines.push(`path: ${String(r.path)}`);
1114
- if (r.description)
1115
- lines.push(`description: ${String(r.description)}`);
1116
- if (typeof r.pages === "number")
1117
- lines.push(`pages: ${r.pages}`);
1118
- if (typeof r.raws === "number")
1119
- lines.push(`raws: ${r.raws}`);
1120
- if (r.lastModified)
1121
- lines.push(`lastModified: ${String(r.lastModified)}`);
1122
- const recentLog = Array.isArray(r.recentLog) ? r.recentLog : [];
1123
- if (recentLog.length > 0) {
1124
- lines.push("", "recent log:");
1125
- for (const entry of recentLog) {
1126
- lines.push(entry);
1127
- lines.push("");
1128
- }
1129
- }
1130
- return lines.join("\n").trimEnd();
1131
- }
1132
- export function formatWikiCreatePlain(r) {
1133
- const created = Array.isArray(r.created) ? r.created : [];
1134
- const skipped = Array.isArray(r.skipped) ? r.skipped : [];
1135
- const lines = [`Created wiki ${String(r.ref ?? r.name)} at ${String(r.path ?? "?")}`];
1136
- if (created.length > 0)
1137
- lines.push(` created: ${created.length} file(s)`);
1138
- if (skipped.length > 0)
1139
- lines.push(` skipped: ${skipped.length} existing file(s)`);
1140
- return lines.join("\n");
1141
- }
1142
- export function formatWikiRemovePlain(r) {
1143
- const preserved = r.preservedRaw === true;
1144
- const removed = Array.isArray(r.removed) ? r.removed.length : 0;
1145
- const base = `Removed wiki ${String(r.name ?? "?")} (${removed} path(s))`;
1146
- return preserved ? `${base}; raw/ preserved at ${String(r.rawPath ?? "raw/")}` : base;
1147
- }
1148
- export function formatWikiPagesPlain(r) {
1149
- const pages = Array.isArray(r.pages) ? r.pages : [];
1150
- if (pages.length === 0)
1151
- return `No pages in wiki:${String(r.wiki ?? "?")}.`;
1152
- const lines = [];
1153
- for (const p of pages) {
1154
- const ref = String(p.ref ?? "?");
1155
- const kind = typeof p.pageKind === "string" ? ` [${p.pageKind}]` : "";
1156
- const desc = typeof p.description === "string" && p.description ? ` — ${p.description}` : "";
1157
- lines.push(`${ref}${kind}${desc}`);
1158
- }
1159
- return lines.join("\n");
1160
- }
1161
- export function formatWikiStashPlain(r) {
1162
- const slug = String(r.slug ?? "?");
1163
- const pathValue = String(r.path ?? "?");
1164
- return `Stashed ${slug} → ${pathValue}`;
1165
- }
1166
- export function formatWikiLintPlain(r) {
1167
- const findings = Array.isArray(r.findings) ? r.findings : [];
1168
- const pagesScanned = typeof r.pagesScanned === "number" ? r.pagesScanned : 0;
1169
- const rawsScanned = typeof r.rawsScanned === "number" ? r.rawsScanned : 0;
1170
- const header = `${findings.length} finding(s) in wiki:${String(r.wiki ?? "?")} (${pagesScanned} page(s), ${rawsScanned} raw(s))`;
1171
- if (findings.length === 0)
1172
- return `${header} — clean.`;
1173
- const lines = [header];
1174
- for (const f of findings) {
1175
- const kind = String(f.kind ?? "?");
1176
- const message = String(f.message ?? "");
1177
- lines.push(`- [${kind}] ${message}`);
1178
- }
1179
- return lines.join("\n");
1180
- }
1181
- export function formatWikiIngestPlain(r) {
1182
- if (typeof r.workflow === "string")
1183
- return r.workflow;
1184
- return JSON.stringify(r, null, 2);
1185
- }
1186
- export function formatCuratePlain(r, detail) {
1187
- const query = typeof r.query === "string" ? r.query : "";
1188
- const summary = typeof r.summary === "string" ? r.summary : "";
1189
- const items = Array.isArray(r.items) ? r.items : [];
1190
- const lines = [`Curated results for "${query}"`];
1191
- if (summary)
1192
- lines.push(summary);
1193
- if (items.length === 0) {
1194
- if (r.tip)
1195
- lines.push(String(r.tip));
1196
- return lines.join("\n");
1197
- }
1198
- for (const item of items) {
1199
- const type = typeof item.type === "string" ? item.type : "unknown";
1200
- const name = typeof item.name === "string" ? item.name : "unnamed";
1201
- lines.push("");
1202
- lines.push(`[${type}] ${name}`);
1203
- if (item.description)
1204
- lines.push(` ${String(item.description)}`);
1205
- if (item.preview)
1206
- lines.push(` preview: ${String(item.preview)}`);
1207
- if (item.ref)
1208
- lines.push(` ref: ${String(item.ref)}`);
1209
- if (item.id)
1210
- lines.push(` id: ${String(item.id)}`);
1211
- if (Array.isArray(item.keys) && item.keys.length > 0) {
1212
- lines.push(` keys: ${item.keys.join(", ")}`);
1213
- }
1214
- if (Array.isArray(item.parameters) && item.parameters.length > 0) {
1215
- lines.push(` parameters: ${item.parameters.join(", ")}`);
1216
- }
1217
- if (item.run)
1218
- lines.push(` run: ${String(item.run)}`);
1219
- if (item.followUp)
1220
- lines.push(` show: ${String(item.followUp)}`);
1221
- if (Array.isArray(item.supportRefs) && item.supportRefs.length > 0) {
1222
- for (const support of item.supportRefs) {
1223
- if (!support.ref)
1224
- continue;
1225
- const label = typeof support.type === "string" ? `[${support.type}] ` : "";
1226
- const why = typeof support.reason === "string" ? ` — ${support.reason}` : "";
1227
- lines.push(` support: ${label}${String(support.ref)}${why}`);
1228
- }
1229
- }
1230
- if (detail !== "brief" && item.reason)
1231
- lines.push(` why: ${String(item.reason)}`);
1232
- }
1233
- const warnings = Array.isArray(r.warnings) ? r.warnings : [];
1234
- if (warnings.length > 0) {
1235
- lines.push("");
1236
- lines.push("Warnings:");
1237
- for (const warning of warnings) {
1238
- lines.push(`- ${String(warning)}`);
1239
- }
1240
- }
1241
- lines.push("");
1242
- lines.push("Next steps:");
1243
- lines.push(" 1. Run `akm show <ref>` for the best result above to read the full schema.");
1244
- lines.push(" 2. Edit the workspace file using the schema field names and your task-specific values.");
1245
- lines.push(" 3. Run `akm feedback <ref> --positive` when the task succeeds.");
1246
- lines.push("To search further: akm search '<query>'");
1247
- return lines.join("\n");
1248
- }
1249
- export function formatInitPlain(r) {
1250
- let out = `Stash initialized at ${r.stashDir ?? "unknown"}`;
1251
- // When --dir scaffolded a secondary stash but the default was deliberately
1252
- // left untouched, tell the user instead of silently repointing their default.
1253
- if (r.defaultStashUpdated === false && typeof r.previousStashDir === "string" && r.previousStashDir) {
1254
- out += `\nYour default stash is unchanged (${r.previousStashDir}). Re-run with --set-default to make ${r.stashDir} the default.`;
1255
- }
1256
- else if (r.configPath) {
1257
- out += `\nConfig saved to ${r.configPath}`;
1258
- }
1259
- return out;
1260
- }
1261
- export function formatIndexPlain(r) {
1262
- const indexResult = r;
1263
- let out = `Indexed ${indexResult.totalEntries ?? 0} entries from ${indexResult.directoriesScanned ?? 0} directories (mode: ${indexResult.mode ?? "unknown"})`;
1264
- const warnings = indexResult.warnings;
1265
- if (Array.isArray(warnings) && warnings.length > 0) {
1266
- out += `\nWarnings (${warnings.length}):`;
1267
- for (const message of warnings)
1268
- out += `\n - ${String(message)}`;
1269
- }
1270
- const verification = indexResult.verification;
1271
- if (verification?.ok === false && verification.message) {
1272
- out += `\nVerification: ${String(verification.message)}`;
1273
- }
1274
- const timing = indexResult.timing;
1275
- if (timing) {
1276
- out +=
1277
- `\nTiming: total ${timing.totalMs}ms` +
1278
- `, preflight ${timing.preflightMs}ms` +
1279
- `, walk ${timing.walkMs}ms` +
1280
- `, llm ${timing.llmMs}ms` +
1281
- `, embeddings ${timing.embedMs}ms` +
1282
- `, fts ${timing.ftsMs}ms` +
1283
- `, finalize ${timing.finalizeMs}ms` +
1284
- `, clean ${timing.cleanMs}ms` +
1285
- `, end-to-end ${timing.endToEndMs}ms`;
1286
- }
1287
- return out;
1288
- }
1289
- export function formatListPlain(r) {
1290
- const sources = Array.isArray(r.sources) ? r.sources : [];
1291
- if (sources.length === 0)
1292
- return "No sources configured. Use `akm add` to add a source.";
1293
- const lines = [];
1294
- for (const src of sources) {
1295
- const kind = typeof src.kind === "string" ? src.kind : "unknown";
1296
- const name = typeof src.name === "string" ? src.name : "unnamed";
1297
- const ver = typeof src.version === "string" ? ` v${src.version}` : "";
1298
- const prov = typeof src.provider === "string" ? ` (${src.provider})` : "";
1299
- const flags = [];
1300
- if (typeof src.wiki === "string")
1301
- flags.push(`wiki:${src.wiki}`);
1302
- if (src.updatable === true)
1303
- flags.push("updatable");
1304
- if (src.writable === true)
1305
- flags.push("writable");
1306
- const flagText = flags.length > 0 ? ` [${flags.join(", ")}]` : "";
1307
- lines.push(`[${kind}] ${name}${ver}${prov}${flagText}`);
1308
- }
1309
- lines.push("");
1310
- lines.push("To search: akm search '<query>' | To view an asset: akm show <ref>");
1311
- return lines.join("\n");
1312
- }
1313
- export function formatAddPlain(r) {
1314
- const index = r.index;
1315
- const scanned = index?.directoriesScanned ?? 0;
1316
- const total = index?.totalEntries ?? 0;
1317
- const lines = [`Installed ${r.ref} (${scanned} directories scanned, ${total} total assets indexed)`];
1318
- const warnings = index?.warnings;
1319
- if (Array.isArray(warnings) && warnings.length > 0) {
1320
- lines.push(`Warnings (${warnings.length}):`);
1321
- for (const message of warnings)
1322
- lines.push(` - ${String(message)}`);
1323
- }
1324
- return lines.join("\n");
1325
- }
1326
- export function formatRemovePlain(r) {
1327
- const target = r.target ?? r.ref ?? "";
1328
- const ok = r.ok !== false ? "OK" : "FAILED";
1329
- return `remove: ${target} ${ok}`;
1330
- }
1331
- export function formatUpdatePlain(r) {
1332
- const processed = r.processed;
1333
- if (!processed?.length)
1334
- return `update: nothing to update`;
1335
- const lines = processed.map((item) => {
1336
- const changed = item.changed;
1337
- const installed = item.installed;
1338
- const previous = item.previous;
1339
- if (changed?.any) {
1340
- const prev = previous?.resolvedVersion ?? "unknown";
1341
- const next = installed?.resolvedVersion ?? "unknown";
1342
- return `update: ${item.id} v${prev} → v${next}`;
1343
- }
1344
- return `update: ${item.id} (unchanged)`;
1345
- });
1346
- return lines.join("\n");
1347
- }
1348
- export function formatUpgradePlain(r) {
1349
- if (r.upgraded === true) {
1350
- return `akm upgraded: v${r.currentVersion} → v${r.newVersion}`;
1351
- }
1352
- if (r.updateAvailable === true) {
1353
- return `akm v${r.currentVersion} → v${r.latestVersion} available (run 'akm upgrade' to install)`;
1354
- }
1355
- if (r.updateAvailable === false && r.latestVersion) {
1356
- return `akm v${r.currentVersion} is already the latest version`;
1357
- }
1358
- if (r.message)
1359
- return String(r.message);
1360
- return null;
1361
- }
1362
- export function formatClonePlain(r) {
1363
- const dst = r.destination?.path ?? "unknown";
1364
- const remote = r.remoteFetched ? " (fetched from remote)" : "";
1365
- const over = r.overwritten ? " (overwritten)" : "";
1366
- return `Cloned${remote} → ${dst}${over}`;
1367
- }
1368
- export function formatWorkflowCreatePlain(r) {
1369
- if (r.ref && r.path) {
1370
- return `Created ${String(r.ref)} at ${String(r.path)}`;
1371
- }
1372
- return null;
1373
- }
1374
- export function formatWorkflowResumePlain(r) {
1375
- return formatWorkflowStatusPlain(r) ?? `Resumed workflow run ${String(r.id ?? r.runId ?? "?")}`;
1376
- }
1377
- function formatRelatedLabel(hit) {
1378
- const ref = typeof hit.ref === "string" ? hit.ref : undefined;
1379
- if (ref)
1380
- return ref;
1381
- const pathValue = typeof hit.path === "string" ? hit.path : "?";
1382
- return pathValue.split("/").pop() ?? pathValue;
1383
- }
18
+ export { formatAddPlain, formatClonePlain, formatConfigPlain, formatCuratePlain, formatEnvCreatePlain, formatEnvExportPlain, formatEnvListPlain, formatEnvRemovePlain, formatEnvSetPlain, formatEnvUnsetPlain, formatEventLine, formatEventsPlain, formatFeedbackPlain, formatHistoryPlain, formatImportPlain, formatIndexPlain, formatInfoPlain, formatInitPlain, formatListPlain, formatRegistryAddPlain, formatRegistryBuildIndexPlain, formatRegistryListPlain, formatRegistryRemovePlain, formatRegistrySearchPlain, formatRememberPlain, formatRemovePlain, formatSavePlain, formatSearchPlain, formatToggleComponentPlain, formatUpdatePlain, formatUpgradePlain, } from "./command-format.js";
19
+ export { formatDistillPlain, formatGateDecisionSummary, formatProposalAcceptPlain, formatProposalDiffPlain, formatProposalDrainPlain, formatProposalListPlain, formatProposalProducerPlain, formatProposalRejectPlain, formatProposalShowPlain, } from "./proposal-format.js";
20
+ export { formatShowPlain } from "./show-format.js";
21
+ export { formatWorkflowBriefPlain, formatWorkflowCompleteRejectedPlain, formatWorkflowCreatePlain, formatWorkflowListPlain, formatWorkflowNextPlain, formatWorkflowResumePlain, formatWorkflowRunPlain, formatWorkflowStatusPlain, formatWorkflowValidatePlain, } from "./workflow-format.js";