akm-cli 0.9.31 → 0.10.261001-beta

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 (270) hide show
  1. package/CHANGELOG.md +409 -0
  2. package/STABILITY.md +99 -57
  3. package/dist/api-node.mjs +20 -0
  4. package/dist/api.d.ts +23 -0
  5. package/dist/api.js +45 -0
  6. package/dist/assets/hints/cli-hints-full.md +15 -29
  7. package/dist/assets/hints/cli-hints-short.md +2 -2
  8. package/dist/assets/improve-strategies/default.json +3 -3
  9. package/dist/assets/prompts/consolidate-pair.md +9 -7
  10. package/dist/assets/stash-skeleton/README.md +1 -1
  11. package/dist/assets/tasks/improve/akm-improve-consolidate.yml +1 -1
  12. package/dist/cli/shared.js +31 -48
  13. package/dist/cli/unknown-flags.js +6 -43
  14. package/dist/cli.js +8 -34
  15. package/dist/commands/agent/contribute-cli.js +1 -1
  16. package/dist/commands/completions.js +1 -2
  17. package/dist/commands/config-cli.js +5 -28
  18. package/dist/commands/env/env-cli.js +5 -5
  19. package/dist/commands/env/secret-cli.js +2 -2
  20. package/dist/commands/feedback-cli.js +75 -49
  21. package/dist/commands/health/checks.js +41 -16
  22. package/dist/commands/health/plugin-staleness.js +52 -22
  23. package/dist/commands/improve/autonomy-gate.js +5 -3
  24. package/dist/commands/improve/consolidate/chunking.js +3 -10
  25. package/dist/commands/improve/consolidate/continuity-check.js +4 -4
  26. package/dist/commands/improve/consolidate/pair-pass.js +29 -10
  27. package/dist/commands/improve/consolidate.js +10 -65
  28. package/dist/commands/improve/distill/lesson-update.js +91 -0
  29. package/dist/commands/improve/distill-guards.js +1 -43
  30. package/dist/commands/improve/distill.js +148 -21
  31. package/dist/commands/improve/eligibility.js +14 -1
  32. package/dist/commands/improve/extract-cli.js +1 -1
  33. package/dist/commands/improve/extract-prompt.js +17 -7
  34. package/dist/commands/improve/extract.js +5 -7
  35. package/dist/commands/improve/improve-cli.js +92 -106
  36. package/dist/commands/improve/improve-strategies.js +8 -12
  37. package/dist/commands/improve/improve.js +134 -52
  38. package/dist/commands/improve/loop-stages.js +18 -5
  39. package/dist/commands/improve/planner.js +0 -1
  40. package/dist/commands/improve/preparation.js +40 -99
  41. package/dist/commands/improve/proactive-maintenance.js +2 -2
  42. package/dist/commands/improve/reflect-noise.js +3 -55
  43. package/dist/commands/improve/reflect.js +29 -34
  44. package/dist/commands/improve/retrieval-queries.js +37 -0
  45. package/dist/commands/improve/retrieval-scope.js +2 -2
  46. package/dist/commands/improve/salience.js +2 -9
  47. package/dist/commands/improve/session-asset.js +4 -1
  48. package/dist/commands/improve/stage.js +23 -12
  49. package/dist/commands/lint/index.js +5 -20
  50. package/dist/commands/observability-cli.js +3 -9
  51. package/dist/commands/proposal/drain.js +43 -6
  52. package/dist/commands/proposal/proposal-cli.js +11 -31
  53. package/dist/commands/proposal/repository.js +20 -14
  54. package/dist/commands/proposal/validators/proposal-quality-validators.js +0 -3
  55. package/dist/commands/read/knowledge.js +3 -3
  56. package/dist/commands/read/remember-cli.js +0 -13
  57. package/dist/commands/read/search-cli.js +29 -97
  58. package/dist/commands/read/search.js +0 -11
  59. package/dist/commands/read/show.js +0 -19
  60. package/dist/commands/sources/plugin-upgrade.js +164 -101
  61. package/dist/commands/sources/sources-cli.js +1 -15
  62. package/dist/commands/sources/stash-cli.js +6 -14
  63. package/dist/commands/tasks/tasks-cli.js +4 -115
  64. package/dist/commands/workflow/plan.js +11 -33
  65. package/dist/commands/workflow-cli.js +2 -7
  66. package/dist/core/adapter/adapter-ids.js +1 -2
  67. package/dist/core/adapter/adapters/agent-skills-adapter.js +0 -4
  68. package/dist/core/adapter/adapters/akm-adapter.js +9 -48
  69. package/dist/core/adapter/adapters/akm-lint.js +10 -26
  70. package/dist/core/adapter/adapters/akm-metadata.js +2 -72
  71. package/dist/core/adapter/adapters/akm-task-adapter.js +0 -5
  72. package/dist/core/adapter/adapters/akm-workflow-adapter.js +9 -28
  73. package/dist/core/adapter/adapters/dotenv-adapter.js +1 -20
  74. package/dist/core/adapter/adapters/generic-files-adapter.js +0 -10
  75. package/dist/core/adapter/adapters/llm-wiki-adapter.js +0 -4
  76. package/dist/core/adapter/adapters/tool-dir-shared.js +0 -24
  77. package/dist/core/adapter/adapters/website-snapshot-adapter.js +4 -4
  78. package/dist/core/adapter/recognize-match.js +3 -4
  79. package/dist/core/common.js +18 -2
  80. package/dist/core/config/config-schema.js +12 -15
  81. package/dist/core/config/config-types.js +6 -15
  82. package/dist/core/config/config-walker.js +6 -23
  83. package/dist/core/config/config.js +17 -80
  84. package/dist/core/config/engine-semantics.js +7 -3
  85. package/dist/core/config/schema/engines.js +7 -7
  86. package/dist/core/config/schema/improve-processes.js +10 -63
  87. package/dist/core/config/schema/improve.js +2 -21
  88. package/dist/core/config/schema/index-config.js +6 -39
  89. package/dist/core/env-secret-ref.js +2 -45
  90. package/dist/core/errors.js +1 -2
  91. package/dist/core/extra-params.js +2 -86
  92. package/dist/core/file-lock.js +2 -6
  93. package/dist/core/improve-result.js +13 -1
  94. package/dist/core/mutation-target.js +2 -2
  95. package/dist/core/paths.js +4 -0
  96. package/dist/core/recognition-util.js +4 -5
  97. package/dist/core/run-lock.js +1 -1
  98. package/dist/core/subprocess.js +49 -0
  99. package/dist/core/warn.js +21 -4
  100. package/dist/core/write-source.js +3 -3
  101. package/dist/execution/target-ref.js +1 -2
  102. package/dist/indexer/indexer.js +15 -6
  103. package/dist/indexer/passes/memory-inference.js +15 -6
  104. package/dist/indexer/search/db-search.js +49 -36
  105. package/dist/indexer/search/fts-query.js +0 -19
  106. package/dist/indexer/search/ranking.js +29 -1
  107. package/dist/indexer/usage/usage-events.js +21 -16
  108. package/dist/integrations/agent/engine-resolution.js +5 -2
  109. package/dist/integrations/agent/index.js +1 -1
  110. package/dist/integrations/agent/profiles.js +41 -98
  111. package/dist/integrations/agent/request-lowering.js +3 -3
  112. package/dist/integrations/harnesses/aider/index.js +5 -0
  113. package/dist/integrations/harnesses/amazonq/index.js +1 -0
  114. package/dist/integrations/harnesses/claude/config-import.js +2 -3
  115. package/dist/integrations/harnesses/claude/index.js +5 -0
  116. package/dist/integrations/harnesses/codex/index.js +1 -0
  117. package/dist/integrations/harnesses/copilot/index.js +1 -0
  118. package/dist/integrations/harnesses/gemini/index.js +1 -0
  119. package/dist/integrations/harnesses/index.js +18 -39
  120. package/dist/integrations/harnesses/opencode/agent-builder.js +60 -35
  121. package/dist/integrations/harnesses/opencode/config-import.js +121 -52
  122. package/dist/integrations/harnesses/opencode/index.js +22 -0
  123. package/dist/integrations/harnesses/opencode/plugin-layout.js +68 -0
  124. package/dist/integrations/harnesses/opencode/session-log-types.js +12 -0
  125. package/dist/integrations/harnesses/opencode/session-log-v1.js +72 -0
  126. package/dist/integrations/harnesses/opencode/session-log-v2.js +140 -0
  127. package/dist/integrations/harnesses/opencode/session-log.js +104 -115
  128. package/dist/integrations/harnesses/opencode/version.js +98 -0
  129. package/dist/integrations/harnesses/opencode-sdk/{harness.js → index.js} +5 -17
  130. package/dist/integrations/harnesses/opencode-sdk/sdk-runner.js +105 -206
  131. package/dist/integrations/harnesses/opencode-sdk/v1-adapter.js +199 -0
  132. package/dist/integrations/harnesses/opencode-sdk/v2-adapter.js +254 -0
  133. package/dist/integrations/harnesses/opencode-sdk/wire.js +66 -0
  134. package/dist/integrations/harnesses/openhands/index.js +1 -0
  135. package/dist/integrations/harnesses/pi/index.js +1 -0
  136. package/dist/integrations/harnesses/shared.js +2 -0
  137. package/dist/integrations/harnesses/types.js +2 -0
  138. package/dist/llm/client.js +41 -11
  139. package/dist/output/cli-hints.js +1 -1
  140. package/dist/output/context.js +10 -19
  141. package/dist/output/format-exempt.js +5 -8
  142. package/dist/output/shapes/helpers.js +1 -22
  143. package/dist/output/shapes/passthrough.js +0 -1
  144. package/dist/output/shapes.js +3 -31
  145. package/dist/output/stdout.js +5 -1
  146. package/dist/output/text/command-format.js +6 -1
  147. package/dist/output/text/workflow-format.js +4 -22
  148. package/dist/scripts/akm-migrate-node.js +15745 -16711
  149. package/dist/scripts/akm-migrate.js +16318 -17280
  150. package/dist/setup/detect.js +10 -4
  151. package/dist/setup/harness-config-import.js +5 -14
  152. package/dist/setup/setup.js +1 -1
  153. package/dist/setup/steps/tasks.js +12 -13
  154. package/dist/sources/providers/git-stash.js +94 -13
  155. package/dist/storage/repositories/index-utility-repository.js +2 -32
  156. package/dist/storage/repositories/index-vec-repository.js +4 -0
  157. package/dist/storage/repositories/task-history-repository.js +0 -5
  158. package/dist/storage/repositories/workflow-runs-repository.js +5 -15
  159. package/dist/tasks/embedded.js +2 -1
  160. package/dist/tasks/run/run-command-task.js +9 -1
  161. package/dist/tasks/run/run-workflow-task.js +4 -3
  162. package/dist/tasks/run/task-history.js +0 -2
  163. package/dist/tasks/run/task-log.js +38 -1
  164. package/dist/tasks/schedule-gates.js +39 -0
  165. package/dist/tasks/scheduler-binding.js +0 -16
  166. package/dist/tasks/scheduler-sync.js +3 -97
  167. package/dist/tasks/source/bounded-document.js +1 -1
  168. package/dist/tasks/source/task-source-v4.js +2 -12
  169. package/dist/tasks/task-run-reserved-flags.js +2 -31
  170. package/dist/workflows/authoring/authoring.js +6 -6
  171. package/dist/workflows/compile.js +8 -65
  172. package/dist/workflows/exec/child-workflow.js +22 -3
  173. package/dist/workflows/exec/native-executor.js +12 -147
  174. package/dist/workflows/exec/run-workflow.js +31 -103
  175. package/dist/workflows/exec/step-work.js +9 -178
  176. package/dist/workflows/exec/unit-dispatch.js +0 -10
  177. package/dist/workflows/freeze/environment.js +3 -44
  178. package/dist/workflows/freeze/freeze.js +8 -41
  179. package/dist/workflows/freeze/targets/child-workflow.js +27 -63
  180. package/dist/workflows/freeze/targets/command.js +2 -16
  181. package/dist/workflows/freeze/targets/shell.js +0 -2
  182. package/dist/workflows/freeze/task-bindings.js +2 -28
  183. package/dist/workflows/ir/params.js +12 -2
  184. package/dist/workflows/parser.js +82 -232
  185. package/dist/workflows/plan.js +1 -1
  186. package/dist/workflows/renderer.js +10 -19
  187. package/dist/workflows/runtime/run-plan.js +11 -53
  188. package/dist/workflows/runtime/runs.js +4 -27
  189. package/dist/workflows/source-files.js +12 -16
  190. package/dist/workflows/source-semantics.js +1 -93
  191. package/docs/README.md +1 -1
  192. package/docs/agents/README.md +3 -3
  193. package/docs/agents/agent-install.md +1 -1
  194. package/docs/architecture/0.10-process-rules.md +827 -0
  195. package/docs/architecture/adapters.md +17 -31
  196. package/docs/architecture/architecture.md +4 -5
  197. package/docs/architecture/improvement.md +115 -76
  198. package/docs/architecture/internals/improve-workflow.md +22 -16
  199. package/docs/architecture/internals/indexing.md +1 -1
  200. package/docs/architecture/internals/search.md +1 -2
  201. package/docs/architecture/internals/storage-locations.md +6 -6
  202. package/docs/architecture/persisted-data-compat.md +13 -4
  203. package/docs/architecture/specs/0.9.0-decisions.md +6 -2
  204. package/docs/architecture/specs/improve-collapse-churn-detector-design.md +2 -2
  205. package/docs/architecture/specs/workflow-format-unification.md +1 -6
  206. package/docs/architecture/testing/manual-testing-checklist.md +21 -30
  207. package/docs/architecture/testing/task-workflow-manual-tests.md +106 -203
  208. package/docs/architecture/testing/testing-workflow.md +1 -1
  209. package/docs/architecture/workflow-engine.md +5 -56
  210. package/docs/guides/author-workflows.md +39 -69
  211. package/docs/guides/bundles.md +3 -1
  212. package/docs/guides/capture-knowledge.md +1 -1
  213. package/docs/guides/claude-code-vs-akm-workflows.md +1 -2
  214. package/docs/guides/discover-and-load.md +4 -4
  215. package/docs/guides/getting-started.md +1 -1
  216. package/docs/guides/improve-the-library.md +10 -9
  217. package/docs/guides/recipes/headless-install.md +2 -2
  218. package/docs/guides/run-workflows.md +1 -1
  219. package/docs/guides/scheduling.md +9 -1
  220. package/docs/guides/use-with-any-agent.md +49 -4
  221. package/docs/integration/bundling-akm.md +7 -6
  222. package/docs/maintainers/curate-workmap.md +1 -2
  223. package/docs/maintainers/release-checklist.md +33 -1
  224. package/docs/migration/README.md +2 -0
  225. package/docs/migration/release-notes/0.10.0.md +201 -0
  226. package/docs/migration/release-notes/README.md +1 -0
  227. package/docs/migration/v0.9-to-v0.10.md +507 -0
  228. package/docs/posts/akm-command-tour.md +3 -3
  229. package/docs/product-surface.md +1 -1
  230. package/docs/reference/README.md +1 -0
  231. package/docs/reference/api.md +65 -0
  232. package/docs/reference/asset-types.md +3 -5
  233. package/docs/reference/bundle-types.md +2 -4
  234. package/docs/reference/cli.md +160 -188
  235. package/docs/reference/configuration.md +101 -20
  236. package/docs/reference/data-and-telemetry.md +2 -2
  237. package/docs/reference/env-and-secrets.md +2 -2
  238. package/docs/reference/supported-formats.md +3 -4
  239. package/docs/reference/tasks.md +12 -19
  240. package/docs/reference/website-sources.md +1 -1
  241. package/docs/reference/workflow-schema.md +89 -317
  242. package/docs/reference/workflows.md +20 -48
  243. package/package.json +12 -2
  244. package/schemas/akm-config.json +2 -243
  245. package/schemas/akm-task.json +2 -3
  246. package/schemas/akm-workflow.json +47 -84
  247. package/dist/assets/improve-strategies/catchup.json +0 -41
  248. package/dist/assets/improve-strategies/proactive-maintenance.json +0 -24
  249. package/dist/assets/improve-strategies/quick.json +0 -17
  250. package/dist/assets/improve-strategies/reflect-distill.json +0 -29
  251. package/dist/assets/improve-strategies/thorough.json +0 -49
  252. package/dist/assets/prompts/retrieval-relevance-judge.md +0 -6
  253. package/dist/assets/tasks/improve/akm-improve-catchup.yml +0 -6
  254. package/dist/assets/tasks/improve/akm-improve-frequent.yml +0 -4
  255. package/dist/assets/tasks/improve/akm-improve-nightly.yml +0 -4
  256. package/dist/cli/retired-commands.js +0 -118
  257. package/dist/commands/improve/retrieval-gate.js +0 -132
  258. package/dist/commands/tasks/validate.js +0 -176
  259. package/dist/core/config/legacy-source-shape-shim.js +0 -117
  260. package/dist/indexer/feedback/utility-policy.js +0 -75
  261. package/dist/integrations/harnesses/ids.js +0 -28
  262. package/dist/tasks/source/task-source-v3-frozen.js +0 -424
  263. package/dist/tasks/source/task-to-v4.js +0 -863
  264. package/dist/workflows/exec/worktree.js +0 -372
  265. package/dist/workflows/freeze/child-output-references.js +0 -83
  266. package/dist/workflows/freeze/identity.js +0 -22
  267. package/dist/workflows/freeze/targets/script.js +0 -50
  268. package/dist/workflows/freeze/targets/task.js +0 -124
  269. package/dist/workflows/github-yaml.js +0 -506
  270. package/dist/workflows/runtime/run-outputs.js +0 -80
@@ -156,19 +156,8 @@ export const GLOBAL_OUTPUT_ARGS = {
156
156
  format: { type: "string", description: "Output format: json|jsonl|yaml|text|md|html (global flag)" },
157
157
  detail: {
158
158
  type: "string",
159
- description: "Detail level (verbosity): brief|normal|full (global flag).",
160
- },
161
- // R-050(c): single-sourced with the root command's own `--shape` help
162
- // (`main.args.shape` in src/cli.ts, which spreads this object) so the
163
- // caveat is visible from every leaf's own `--help`, not only the top-level
164
- // one. `summary` outside `show` falls back to `agent` with a warning
165
- // (shapeForCommand in src/output/shapes.ts) — `--shape` is a global flag,
166
- // so a script that passes it to a mixed batch of commands still works.
167
- shape: {
168
- type: "string",
169
- description: "Output projection: human|agent|summary (global flag). 'agent' trims to agent-essential fields; " +
170
- "'summary' only has a dedicated projection on 'akm show' — elsewhere it falls back to 'agent' with a " +
171
- "warning. Default: human.",
159
+ description: "Detail level: brief|normal|full (verbosity), or agent (trims search, curate and show to agent-essential " +
160
+ "fields; other commands ignore it) (global flag).",
172
161
  },
173
162
  output: {
174
163
  type: "string",
@@ -294,51 +283,45 @@ export function outputWithExitCode(command, result, exitCode) {
294
283
  }
295
284
  export function output(command, result) {
296
285
  const mode = getOutputMode();
297
- const shaped = shapeForCommand(command, result, mode.detail, mode.shape);
298
- if (mode.format === "jsonl") {
299
- outputJsonl(command, shaped);
286
+ const { format } = mode;
287
+ if (format === "jsonl") {
288
+ outputJsonl(command, shapeForCommand(command, result, mode.detail, mode.shape));
300
289
  return;
301
290
  }
291
+ deliverRendered(renderOutput(command, result, { ...mode, format }), mode.outputPath);
292
+ }
293
+ /**
294
+ * Shape and render a command result into the document `output()` delivers.
295
+ * Pure: reads no process-level output mode and writes nothing, so in-process
296
+ * callers (`src/api.ts`) get text byte-identical to the CLI's stdout from an
297
+ * explicit `mode`.
298
+ */
299
+ export function renderOutput(command, result, mode) {
300
+ const shaped = shapeForCommand(command, result, mode.detail, mode.shape);
302
301
  switch (mode.format) {
303
302
  case "json":
304
- deliverRendered(JSON.stringify(shaped, null, 2), mode.outputPath);
305
- return;
303
+ return JSON.stringify(shaped, null, 2);
306
304
  case "yaml":
307
- deliverRendered(yamlStringify(shaped), mode.outputPath);
308
- return;
309
- case "text": {
305
+ return yamlStringify(shaped);
306
+ case "text":
310
307
  // D7 — registry first, generic rendering of the shaped envelope second.
311
- // Mirrors the md/html fallback immediately below: a command with no
312
- // registered text formatter used to fall through to
308
+ // A command with no registered text formatter used to fall through to
313
309
  // `JSON.stringify(shaped, null, 2)`, i.e. silently hand back JSON while
314
- // claiming `--format text` — the same "wrong format wearing the right
315
- // flag" bug D7 already closed for md/html. `renderGenericText` (a
316
- // DISTINCT function from `renderGenericMarkdown` — see its doc comment
317
- // in src/output/generic-render.ts for why reusing the md renderer here
318
- // was itself a version of the same bug) renders flat `key=value` text
319
- // matching the house style already established by registered text
320
- // formatters like `config list`.
321
- const plain = formatPlain(command, shaped, mode.detail);
322
- deliverRendered(plain ?? renderGenericText(command, shaped), mode.outputPath);
323
- return;
324
- }
325
- case "md": {
326
- // D7 — registry first, generic rendering of the shaped envelope second.
327
- // No command emits JSON under `--format md` any more: silently handing
328
- // back the wrong format was the worst of the three behaviours this
329
- // replaced.
330
- const rendered = getMdRendererHandler(command)?.(shaped, mode.detail);
331
- deliverRendered(rendered ?? renderGenericMarkdown(command, shaped), mode.outputPath);
332
- return;
333
- }
334
- case "html": {
310
+ // claiming `--format text`. `renderGenericText` renders flat
311
+ // `key=value` text matching the house style of registered formatters
312
+ // like `config list`; it is a DISTINCT function from
313
+ // `renderGenericMarkdown` (see src/output/generic-render.ts).
314
+ return formatPlain(command, shaped, mode.detail) ?? renderGenericText(command, shaped);
315
+ case "md":
316
+ // D7 — registry first, generic rendering second; no command emits JSON
317
+ // under `--format md`.
318
+ return getMdRendererHandler(command)?.(shaped, mode.detail) ?? renderGenericMarkdown(command, shaped);
319
+ case "html":
335
320
  // `akm health` and `akm metrics` are the only commands with a bespoke
336
321
  // HTML report, so they are called directly rather than through a
337
322
  // registry with two possible registrants (see `output/render-registry.ts`).
338
- const rendered = command === "health" ? renderHealthHtml(shaped) : command === "metrics" ? renderMetricsHtml(shaped) : null;
339
- deliverRendered(rendered ?? renderGenericHtml(command, shaped), mode.outputPath);
340
- return;
341
- }
323
+ return ((command === "health" ? renderHealthHtml(shaped) : command === "metrics" ? renderMetricsHtml(shaped) : null) ??
324
+ renderGenericHtml(command, shaped));
342
325
  }
343
326
  }
344
327
  // parseAllFlagValues moved to ./invocation (chunk-9 WI-9.9 argv-normalization
@@ -28,7 +28,6 @@
28
28
  import { UsageError } from "../core/errors.js";
29
29
  import { warn } from "../core/warn.js";
30
30
  import { cittyComparableName, findCittyTopLevelCommandIndex, toAliasArray, } from "./invocation.js";
31
- import { retiredFlagHint } from "./retired-commands.js";
32
31
  /**
33
32
  * Commands that must never refuse on an unrecognized flag — `akm info` warns
34
33
  * and continues instead of exiting 2, the same tolerance a bare `akm help
@@ -39,36 +38,6 @@ import { retiredFlagHint } from "./retired-commands.js";
39
38
  const UNKNOWN_FLAG_TOLERANT_COMMANDS = new Set(["info"]);
40
39
  /** Flags citty implements itself, which no command declares. */
41
40
  const IMPLICIT_FLAGS = ["help", "h", "version", "v"];
42
- /**
43
- * Retired flags whose commands still diagnose them THEMSELVES, with a message
44
- * that names the replacement ("`--scope` was removed, use `--filter`",
45
- * "`--source` was renamed to `--generator`"). A generic "unknown flag" would
46
- * preempt the better diagnosis, so these are passed through — but ONLY on the
47
- * command path that owns the diagnostic, keyed by the resolved path. On every
48
- * other command the same spelling is a genuine typo and still fails fast
49
- * A retired flag is rejected everywhere else, where silently dropping it could
50
- * run a real mutation.
51
- *
52
- * Shrink-only: when a command drops its bespoke diagnostic, drop the entry and
53
- * the generic error takes over.
54
- */
55
- const SELF_DIAGNOSED_FLAGS = new Map(Object.entries({
56
- show: ["akmView", "scope"], // removed view grammar; --scope points at --filter
57
- index: ["enrich", "re-enrich"], // removed index-time enrichment flags
58
- "proposal accept": ["source"], // renamed to --generator
59
- "proposal reject": ["source"], // renamed to --generator
60
- "proposal drain": ["profile"], // retired, points at --strategy
61
- search: ["source"], // renamed to --from
62
- curate: ["source"], // renamed to --from
63
- "task list": ["source"], // renamed to --from (alias of `search --type task`, #951)
64
- remember: ["target"], // renamed to --bundle
65
- clone: ["target"], // renamed to --bundle
66
- improve: ["auto-accept", "target"], // retired in 0.9.0 / renamed to --bundle
67
- "task add": ["target"], // renamed to --bundle
68
- "task run": ["target"], // renamed to --bundle
69
- "task history": ["target"], // renamed to --bundle
70
- "task sync": ["target"], // renamed to --bundle
71
- }).map(([path, flags]) => [path, new Set(flags.map(cittyComparableName))]));
72
41
  /**
73
42
  * Union the arg definitions declared along the resolved command path. The
74
43
  * subcommand walk delegates to {@link findCittyTopLevelCommandIndex} — the
@@ -111,6 +80,12 @@ function collectKnownArgs(root, rawArgs) {
111
80
  break;
112
81
  const idx = findCittyTopLevelCommandIndex(args, (cmd.args ?? {}));
113
82
  const token = idx >= 0 ? args[idx] : undefined;
83
+ // A command that takes a positional AND has subcommands (`improve [scope]`
84
+ // beside `improve report`) is itself the target when the token is absent
85
+ // or names none of them.
86
+ const takesPositional = Object.values(cmd.args ?? {}).some((def) => def.type === "positional");
87
+ if (takesPositional && (token === undefined || !subCommands[token]))
88
+ break;
114
89
  // A group with no subcommand token: citty reports "no command specified".
115
90
  if (token === undefined)
116
91
  return { names, valueFlags, booleanFlags, displayNames, path, resolved: false };
@@ -166,15 +141,6 @@ export function closestMatch(attempted, candidates, threshold) {
166
141
  * @param attempted The spelling to edit-distance against `--long` candidates.
167
142
  */
168
143
  function throwUnknownFlag(shown, attempted, known) {
169
- // Flags the 0.9 overhaul removed outright get their retirement note, not a
170
- // did-you-mean — same reasoning as `retiredCommandHint` in src/cli.ts:
171
- // edit distance can point at an unrelated survivor rather than the real
172
- // replacement procedure (e.g. `index --background` is closer to no other
173
- // `index` flag than it is to any useful suggestion).
174
- const retired = retiredFlagHint(known.path, attempted);
175
- if (retired) {
176
- throw new UsageError(`Unknown flag "${shown}".`, "UNKNOWN_FLAG", retired);
177
- }
178
144
  const threshold = Math.max(2, Math.ceil(attempted.length / 3));
179
145
  const suggestion = closestMatch(attempted, known.displayNames, threshold);
180
146
  throw new UsageError(`Unknown flag "${shown}".`, "UNKNOWN_FLAG", suggestion
@@ -207,7 +173,6 @@ export function assertKnownFlags(root, rawArgs) {
207
173
  // scanner, so it needs the identical exemption).
208
174
  const dynamicNamedFlagCommands = new Set(["workflow run", "task run", "task explain"]);
209
175
  const dynamicWorkflowParams = dynamicNamedFlagCommands.has(known.path.join(" "));
210
- const selfDiagnosed = SELF_DIAGNOSED_FLAGS.get(known.path.join(" "));
211
176
  const tolerant = UNKNOWN_FLAG_TOLERANT_COMMANDS.has(known.path.join(" "));
212
177
  for (let i = 0; i < ownArgs.length; i += 1) {
213
178
  const token = ownArgs[i];
@@ -250,8 +215,6 @@ export function assertKnownFlags(root, rawArgs) {
250
215
  ? rawName.slice(3)
251
216
  : undefined;
252
217
  const candidates = [cittyComparableName(rawName), ...(negated ? [cittyComparableName(negated)] : [])];
253
- if (selfDiagnosed !== undefined && candidates.some((name) => selfDiagnosed.has(name)))
254
- continue;
255
218
  if (!candidates.some((name) => known.names.has(name))) {
256
219
  // `workflow run` owns one deliberately dynamic namespace: long options
257
220
  // become exact-name workflow parameters and are checked against the
package/dist/cli.js CHANGED
@@ -58,7 +58,6 @@ process.on("uncaughtException", (err) => {
58
58
  import fs from "node:fs";
59
59
  import { defineCommand, parseArgs, renderUsage, runCommand, showUsage } from "citty";
60
60
  import { findCittyTopLevelCommandIndex, getParsedInvocation, parseAllFlagValues, resolveHelpMigrateVersionArg, setParsedInvocation, } from "./cli/invocation.js";
61
- import { retiredCommandHint } from "./cli/retired-commands.js";
62
61
  import { defineGroupCommand, EXIT_CODES, emitJsonError, GLOBAL_OUTPUT_ARGS, output, runWithJsonErrors, } from "./cli/shared.js";
63
62
  import { assertKnownFlags, closestMatch } from "./cli/unknown-flags.js";
64
63
  import { agentCommand, lintCommand } from "./commands/agent/contribute-cli.js";
@@ -137,7 +136,7 @@ function printSetupTtyHint(result) {
137
136
  if (!result?.bundleDir)
138
137
  return;
139
138
  console.error(plainize(`\n✓ Bundle created at ${result.bundleDir}\n` +
140
- ' Next: `akm bundle add <source>`, `akm index`, `akm search "<query>"`, `akm help agents`'));
139
+ ' Next: `akm bundle add <source>`, `akm index`, `akm search "<query>"`, `akm hints`'));
141
140
  }
142
141
  /**
143
142
  * Module Naming:
@@ -264,7 +263,7 @@ const healthCommand = defineCommand({
264
263
  args: {
265
264
  // R-051: `health` is a raw `defineCommand` (not `defineJsonCommand`), so
266
265
  // it does not get `GLOBAL_OUTPUT_ARGS` for free. `--format`/`--detail`/
267
- // `--shape`/`--output` already parsed correctly here (this command has
266
+ // `--output` already parsed correctly here (this command has
268
267
  // no positional for a stray value to fall into), so this is purely a
269
268
  // `--help` visibility / consistency fix, not a behavior change.
270
269
  ...GLOBAL_OUTPUT_ARGS,
@@ -383,9 +382,6 @@ const healthCommand = defineCommand({
383
382
  }
384
383
  },
385
384
  });
386
- function loadAgentHints(full) {
387
- return full ? EMBEDDED_HINTS_FULL : EMBEDDED_HINTS;
388
- }
389
385
  const hintsCommand = defineCommand({
390
386
  meta: {
391
387
  name: "hints",
@@ -401,7 +397,7 @@ const hintsCommand = defineCommand({
401
397
  run({ args }) {
402
398
  return runWithJsonErrors(() => {
403
399
  const detail = parseDetailLevel(args.detail) ?? "normal";
404
- process.stdout.write(loadAgentHints(detail !== "brief"));
400
+ process.stdout.write(detail === "brief" ? EMBEDDED_HINTS : EMBEDDED_HINTS_FULL);
405
401
  });
406
402
  },
407
403
  });
@@ -504,24 +500,6 @@ const helpCommand = defineGroupCommand({
504
500
  },
505
501
  subCommands: {
506
502
  ...commandHelpTopics,
507
- agents: defineCommand({
508
- meta: {
509
- name: "agents",
510
- description: "Print agent instructions on how to use akm — the short guide by default; pass --full for the complete guide",
511
- },
512
- args: {
513
- full: {
514
- type: "boolean",
515
- default: false,
516
- description: "Print the complete guide instead of the short one.",
517
- },
518
- },
519
- run({ args }) {
520
- return runWithJsonErrors(() => {
521
- process.stdout.write(loadAgentHints(args.full === true));
522
- });
523
- },
524
- }),
525
503
  migrate: defineCommand({
526
504
  meta: {
527
505
  name: "migrate",
@@ -855,7 +833,7 @@ function renderCommandSections() {
855
833
  * USAGE line + global OPTIONS, then cuts the string before citty's own
856
834
  * "COMMANDS" heading (present because `main` has `subCommands`) and appends
857
835
  * the grouped sections plus a one-line bundle/ref-grammar tagline and the
858
- * `akm help agents` pointer.
836
+ * `akm hints` pointer.
859
837
  */
860
838
  async function renderSectionedRootHelp() {
861
839
  const base = await renderUsage(main, undefined);
@@ -872,7 +850,7 @@ async function renderSectionedRootHelp() {
872
850
  "`akm search` output rather than synthesizing them.",
873
851
  "",
874
852
  "Run `akm help <command>` or `akm <command> --help` for details on any command.",
875
- "Agents: run `akm hints` for the complete guide or `akm help agents` for the short guide.",
853
+ "Agents: run `akm hints` for the complete guide, or `akm hints --detail brief` for the short one.",
876
854
  ].join("\n");
877
855
  return [head, "", renderCommandSections(), "", epilogue].join("\n");
878
856
  }
@@ -910,7 +888,7 @@ function findUnknownCommandAttempt(rawArgs) {
910
888
  }
911
889
  /** Closest command within a length-scaled distance threshold (shared DP in cli/unknown-flags.ts). */
912
890
  function closestCommandMatch(attempted, candidates) {
913
- return closestMatch(attempted, candidates, Math.max(2, Math.ceil(attempted.length / 2)));
891
+ return closestMatch(attempted, candidates, Math.floor(attempted.length / 3));
914
892
  }
915
893
  const CLI_HELP_POINTER = "Run `akm --help` for usage.";
916
894
  /**
@@ -944,12 +922,8 @@ function cittyCliErrorUsageCode(error) {
944
922
  function toUsageErrorFromCliError(error, rawArgs) {
945
923
  const code = cittyCliErrorUsageCode(error);
946
924
  const attempt = code === "UNKNOWN_COMMAND" ? findUnknownCommandAttempt(rawArgs) : undefined;
947
- // Retired spellings from the 0.9 hard break get their replacement, not a
948
- // did-you-mean: edit distance suggests the WRONG command for most of them
949
- // (`init`→`info`, `update`→`upgrade`), and agents follow suggestions.
950
- const retired = attempt ? retiredCommandHint(attempt.parentPath, attempt.attempted) : undefined;
951
- const suggestion = retired === undefined && attempt ? closestCommandMatch(attempt.attempted, attempt.candidates) : undefined;
952
- const hint = retired ?? (suggestion ? `Did you mean \`${suggestion}\`? ${CLI_HELP_POINTER}` : CLI_HELP_POINTER);
925
+ const suggestion = attempt ? closestCommandMatch(attempt.attempted, attempt.candidates) : undefined;
926
+ const hint = suggestion ? `Did you mean \`${suggestion}\`? ${CLI_HELP_POINTER}` : CLI_HELP_POINTER;
953
927
  // citty colorizes error.message with ANSI escapes even when stdout/stderr
954
928
  // is not a TTY. Strip them so the JSON envelope's `error` field is plain
955
929
  // text instead of embedding raw escape sequences.
@@ -112,7 +112,7 @@ export const lintCommand = defineCommand({
112
112
  args: {
113
113
  // R-051: `lint` is a raw `defineCommand` (not `defineJsonCommand`), so it
114
114
  // does not get `GLOBAL_OUTPUT_ARGS` for free. `--format`/`--detail`/
115
- // `--shape`/`--output` already parsed correctly here (this command has no
115
+ // `--output` already parsed correctly here (this command has no
116
116
  // positional for a stray value to fall into), so this is purely a
117
117
  // `--help` visibility / consistency fix, not a behavior change.
118
118
  ...GLOBAL_OUTPUT_ARGS,
@@ -7,8 +7,7 @@ import path from "node:path";
7
7
  import { placementTypes } from "../core/asset/asset-placement.js";
8
8
  const FLAG_VALUES = {
9
9
  "--format": [{ values: ["json", "jsonl", "yaml", "text", "md", "html"] }],
10
- "--detail": [{ values: ["brief", "normal", "full"] }],
11
- "--shape": [{ values: ["human", "agent", "summary"] }],
10
+ "--detail": [{ values: ["brief", "normal", "full", "agent"] }],
12
11
  "--type": [{ values: () => [...placementTypes(), "any"] }],
13
12
  "--shell": [{ values: ["bash"] }],
14
13
  "--from": [{ paths: ["akm search", "akm curate"], values: ["local", "registry", "all"] }],
@@ -14,11 +14,11 @@
14
14
  */
15
15
  import { isDeepStrictEqual } from "node:util";
16
16
  import { defineGroupCommand, defineJsonCommand, output } from "../cli/shared.js";
17
- import { isRecord, resolveStashDir } from "../core/common.js";
17
+ import { isRecord } from "../core/common.js";
18
18
  import { DEFAULT_CONFIG, getConfigValueSource, loadConfig, mutateConfig, parseAndValidateConfigText, resolveConfigRefSource, } from "../core/config/config.js";
19
19
  import { configGet, configSet, configUnset, unknownKeyHint } from "../core/config/config-walker.js";
20
20
  import { UsageError } from "../core/errors.js";
21
- import { getCacheDir, getConfigPath, getDbPath, getDefaultStashDir } from "../core/paths.js";
21
+ import { getConfigPath } from "../core/paths.js";
22
22
  import { formatRegistryUrl } from "../core/registry-url.js";
23
23
  // ── Public API ──────────────────────────────────────────────────────────────
24
24
  export function getConfigValue(config, key) {
@@ -118,32 +118,9 @@ export const configCommand = defineGroupCommand({
118
118
  meta: { name: "config", description: "Show and manage configuration" },
119
119
  subCommands: {
120
120
  path: defineJsonCommand({
121
- meta: { name: "path", description: "Show paths to config, bundle, cache, and index" },
122
- args: {
123
- all: { type: "boolean", description: "Show all paths (config, bundle, cache, index)", default: false },
124
- },
125
- run({ args }) {
126
- const configPath = getConfigPath();
127
- if (args.all) {
128
- let stashDir;
129
- try {
130
- stashDir = resolveStashDir();
131
- }
132
- catch {
133
- stashDir = `${getDefaultStashDir()} (not initialized)`;
134
- }
135
- const cacheDir = getCacheDir();
136
- const result = {
137
- config: configPath,
138
- bundle: stashDir,
139
- cache: cacheDir,
140
- index: getDbPath(),
141
- };
142
- output("config", result);
143
- }
144
- else {
145
- console.log(configPath);
146
- }
121
+ meta: { name: "path", description: "Print the path to the config file" },
122
+ run() {
123
+ console.log(getConfigPath());
147
124
  },
148
125
  }),
149
126
  list: defineJsonCommand({
@@ -56,7 +56,7 @@ const envCreateCommand = defineJsonCommand({
56
56
  description: "Exclude this env file from env list output and the search index",
57
57
  default: false,
58
58
  },
59
- target: {
59
+ bundle: {
60
60
  type: "string",
61
61
  description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
62
62
  },
@@ -64,8 +64,8 @@ const envCreateCommand = defineJsonCommand({
64
64
  async run({ args }) {
65
65
  const { createEnv, writeEnv } = await import("./env.js");
66
66
  // `create` always targets env/, never the frozen vaults/ copy. `--path` is
67
- // the subdirectory; `--target` selects the writable destination source.
68
- const { name, absPath, target, ref } = resolveEnvWriteTarget(args.name, args.target, {
67
+ // the subdirectory; `--bundle` selects the writable destination source.
68
+ const { name, absPath, target, ref } = resolveEnvWriteTarget(args.name, args.bundle, {
69
69
  subPath: getStringArg(args, "path"),
70
70
  });
71
71
  const fromFile = args["from-file"];
@@ -304,13 +304,13 @@ const envRemoveCommand = defineJsonCommand({
304
304
  args: {
305
305
  ref: { type: "positional", description: "Env ref", required: true },
306
306
  yes: { type: "boolean", alias: "y", description: "Skip confirmation prompt", default: false },
307
- target: {
307
+ bundle: {
308
308
  type: "string",
309
309
  description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
310
310
  },
311
311
  },
312
312
  async run({ args }) {
313
- const { name, absPath, target, ref } = resolveEnvWriteTarget(args.ref, args.target);
313
+ const { name, absPath, target, ref } = resolveEnvWriteTarget(args.ref, args.bundle);
314
314
  const { confirmDestructive } = await import("../../cli/confirm.js");
315
315
  const confirmed = await confirmDestructive(`Remove env "${args.ref}"? This cannot be undone.`, {
316
316
  yes: args.yes === true,
@@ -108,14 +108,14 @@ const secretSetCommand = defineJsonCommand({
108
108
  },
109
109
  "from-file": { type: "string", description: "Read the value from this file (stored byte-exact)" },
110
110
  "from-env": { type: "string", description: "Read the value from the named environment variable" },
111
- target: {
111
+ bundle: {
112
112
  type: "string",
113
113
  description: "Override the write destination. Accepts a source name from your config; falls back to defaultWriteTarget then the working bundle.",
114
114
  },
115
115
  },
116
116
  async run({ args }) {
117
117
  const { setSecret } = await import("./secret.js");
118
- const { name, absPath, target, ref } = resolveSecretWriteTarget(args.ref, args.target, {
118
+ const { name, absPath, target, ref } = resolveSecretWriteTarget(args.ref, args.bundle, {
119
119
  subPath: getStringArg(args, "path"),
120
120
  });
121
121
  const fromEnv = args["from-env"];