akm-cli 0.8.0-rc.6 → 0.8.0-rc.8

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 (108) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +2 -2
  3. package/dist/cli/shared.js +114 -0
  4. package/dist/cli.js +120 -1231
  5. package/dist/commands/add-cli.js +273 -0
  6. package/dist/commands/consolidate.js +572 -80
  7. package/dist/commands/distill.js +94 -11
  8. package/dist/commands/extract-cli.js +127 -0
  9. package/dist/commands/extract-prompt.js +204 -0
  10. package/dist/commands/extract.js +477 -0
  11. package/dist/commands/feedback-cli.js +324 -0
  12. package/dist/commands/health.js +962 -44
  13. package/dist/commands/help/help-improve.md +4 -12
  14. package/dist/commands/improve-auto-accept.js +97 -0
  15. package/dist/commands/improve-cli.js +217 -0
  16. package/dist/commands/improve-profiles.js +25 -5
  17. package/dist/commands/improve-result-file.js +64 -0
  18. package/dist/commands/improve.js +452 -262
  19. package/dist/commands/lint/index.js +10 -1
  20. package/dist/commands/reflect.js +33 -61
  21. package/dist/commands/registry-cli.js +141 -0
  22. package/dist/commands/remember-cli.js +257 -0
  23. package/dist/commands/tasks.js +3 -4
  24. package/dist/core/common.js +23 -0
  25. package/dist/core/config-migration.js +12 -15
  26. package/dist/core/config-schema.js +35 -4
  27. package/dist/core/config.js +52 -9
  28. package/dist/core/frontmatter.js +72 -2
  29. package/dist/core/proposal-quality-validators.js +22 -6
  30. package/dist/core/proposals.js +2 -0
  31. package/dist/core/state-db.js +144 -3
  32. package/dist/core/tty.js +59 -0
  33. package/dist/indexer/db-search.js +11 -1
  34. package/dist/indexer/db.js +25 -0
  35. package/dist/indexer/indexer.js +17 -10
  36. package/dist/indexer/llm-cache.js +7 -2
  37. package/dist/indexer/memory-inference.js +58 -5
  38. package/dist/indexer/semantic-status.js +1 -1
  39. package/dist/integrations/agent/index.js +1 -1
  40. package/dist/integrations/agent/prompts.js +64 -7
  41. package/dist/integrations/session-logs/index.js +1 -0
  42. package/dist/integrations/session-logs/inline-refs.js +35 -0
  43. package/dist/integrations/session-logs/pre-filter.js +152 -0
  44. package/dist/integrations/session-logs/providers/claude-code.js +223 -0
  45. package/dist/integrations/session-logs/providers/opencode.js +228 -25
  46. package/dist/llm/embedder.js +17 -10
  47. package/dist/llm/embedders/local.js +39 -1
  48. package/dist/llm/feature-gate.js +9 -3
  49. package/dist/llm/index-passes.js +39 -10
  50. package/dist/llm/memory-infer.js +25 -0
  51. package/dist/llm/prompts/extract-session.md +80 -0
  52. package/dist/output/context.js +2 -2
  53. package/dist/output/shapes/distill.js +10 -0
  54. package/dist/output/shapes/events.js +11 -0
  55. package/dist/output/shapes/helpers.js +423 -0
  56. package/dist/output/shapes/history.js +7 -0
  57. package/dist/output/shapes/passthrough.js +98 -0
  58. package/dist/output/shapes/proposal-accept.js +7 -0
  59. package/dist/output/shapes/proposal-diff.js +7 -0
  60. package/dist/output/shapes/proposal-list.js +7 -0
  61. package/dist/output/shapes/proposal-producer.js +11 -0
  62. package/dist/output/shapes/proposal-reject.js +7 -0
  63. package/dist/output/shapes/proposal-show.js +7 -0
  64. package/dist/output/shapes/registry-search.js +6 -0
  65. package/dist/output/shapes/registry.js +30 -0
  66. package/dist/output/shapes/search.js +6 -0
  67. package/dist/output/shapes/show.js +6 -0
  68. package/dist/output/shapes/vault-list.js +19 -0
  69. package/dist/output/shapes.js +32 -567
  70. package/dist/output/text/add.js +6 -0
  71. package/dist/output/text/clone.js +6 -0
  72. package/dist/output/text/config.js +6 -0
  73. package/dist/output/text/curate.js +6 -0
  74. package/dist/output/text/distill.js +7 -0
  75. package/dist/output/text/enable-disable.js +7 -0
  76. package/dist/output/text/events.js +10 -0
  77. package/dist/output/text/feedback.js +6 -0
  78. package/dist/output/text/helpers.js +1006 -0
  79. package/dist/output/text/history.js +7 -0
  80. package/dist/output/text/import.js +6 -0
  81. package/dist/output/text/index.js +6 -0
  82. package/dist/output/text/info.js +6 -0
  83. package/dist/output/text/init.js +6 -0
  84. package/dist/output/text/list.js +6 -0
  85. package/dist/output/text/proposal-producer.js +8 -0
  86. package/dist/output/text/proposal.js +11 -0
  87. package/dist/output/text/registry-commands.js +11 -0
  88. package/dist/output/text/registry.js +30 -0
  89. package/dist/output/text/remember.js +6 -0
  90. package/dist/output/text/remove.js +6 -0
  91. package/dist/output/text/save.js +6 -0
  92. package/dist/output/text/search.js +6 -0
  93. package/dist/output/text/show.js +6 -0
  94. package/dist/output/text/update.js +6 -0
  95. package/dist/output/text/upgrade.js +6 -0
  96. package/dist/output/text/vault.js +10 -0
  97. package/dist/output/text/wiki.js +15 -0
  98. package/dist/output/text/workflow.js +14 -0
  99. package/dist/output/text.js +41 -1377
  100. package/dist/registry/factory.js +1 -1
  101. package/dist/registry/providers/skills-sh.js +1 -1
  102. package/dist/scripts/migrate-storage.js +262 -51
  103. package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +84 -2
  104. package/dist/sources/providers/git.js +126 -14
  105. package/dist/tasks/schedule.js +17 -1
  106. package/dist/workflows/runs.js +15 -1
  107. package/docs/README.md +1 -1
  108. package/package.json +11 -5
package/CHANGELOG.md CHANGED
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.8.0] - 2026-05-28
10
+
11
+ ### Fixed
12
+
13
+ - **Consolidation `delete_failed` on stale index entries** — when consolidation
14
+ successfully deleted a memory file, the index DB was not re-indexed between
15
+ runs. Subsequent runs loaded the stale DB entry into their memory map, the LLM
16
+ re-proposed the deletion, and `deleteAssetFromSource` threw "not found in
17
+ source" — appearing as `delete_failed` in skipReasons. Fix: `loadMemoriesForSource`
18
+ now filters entries whose file no longer exists on disk before building chunks,
19
+ so phantom memories are never sent to the LLM. A secondary catch in the delete
20
+ handler emits `delete_already_gone` instead of `delete_failed` when the file
21
+ is confirmed absent.
22
+
9
23
  > **CI / Docker users:** the 0.8.0 storage split moved `akm.lock`, the event
10
24
  > database, and the registry cache out of `$XDG_CONFIG_HOME/akm/` into
11
25
  > `$XDG_DATA_HOME`, `$XDG_STATE_HOME`, and `$XDG_CACHE_HOME` respectively. If
@@ -65,6 +79,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
65
79
 
66
80
  ### Changed
67
81
 
82
+ - **Rebrand**: the full name "Agent Kit Manager" is now **Agent Knowledge Management** — `akm` stands for Agent Knowledge Management going forward. The binary name, npm package (`akm-cli`), and all APIs remain unchanged.
83
+
68
84
  - **Config layer rewrite** — single-source-of-truth Zod schema in
69
85
  `src/core/config-schema.ts` replaces the per-field parse switch AND
70
86
  the per-shape load-time parser. Adding a new config field is now one
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # akm -- Agent Kit Manager
1
+ # akm -- Agent Knowledge Management
2
2
 
3
- > **akm** (Agent Kit Manager) -- A package manager for AI agent skills, commands, tools, and knowledge.
3
+ > **akm** (Agent Knowledge Management) -- A package manager for AI agent skills, commands, tools, and knowledge.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/akm-cli)](https://www.npmjs.com/package/akm-cli)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/akm-cli)](https://www.npmjs.com/package/akm-cli)
@@ -0,0 +1,114 @@
1
+ // This Source Code Form is subject to the terms of the Mozilla Public
2
+ // License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ /**
5
+ * Shared CLI utilities extracted from `src/cli.ts` so that individual
6
+ * command modules can import them without a circular dependency.
7
+ *
8
+ * Exported: output, runWithJsonErrors, parseAllFlagValues, emitJsonError
9
+ */
10
+ import { stringify as yamlStringify } from "yaml";
11
+ import { ConfigError, NotFoundError, UsageError } from "../core/errors";
12
+ import { getOutputMode } from "../output/context";
13
+ import { shapeForCommand } from "../output/shapes";
14
+ import { formatPlain, outputJsonl } from "../output/text";
15
+ // ── Exit codes ───────────────────────────────────────────────────────────────
16
+ const EXIT_GENERAL = 1;
17
+ const EXIT_USAGE = 2;
18
+ const EXIT_CONFIG = 78;
19
+ // ── Helpers ──────────────────────────────────────────────────────────────────
20
+ function classifyExitCode(error) {
21
+ if (error instanceof UsageError)
22
+ return EXIT_USAGE;
23
+ if (error instanceof ConfigError)
24
+ return EXIT_CONFIG;
25
+ if (error instanceof NotFoundError)
26
+ return EXIT_GENERAL;
27
+ return EXIT_GENERAL;
28
+ }
29
+ function extractHint(error) {
30
+ if (error instanceof Error && "hint" in error && typeof error.hint === "function") {
31
+ return error.hint();
32
+ }
33
+ return undefined;
34
+ }
35
+ /**
36
+ * Serialize an error to the standard JSON envelope and exit.
37
+ * Used in both the startup try/catch and `runWithJsonErrors`.
38
+ */
39
+ export function emitJsonError(error) {
40
+ const message = error instanceof Error ? error.message : String(error);
41
+ const hint = extractHint(error);
42
+ const exitCode = classifyExitCode(error);
43
+ const code = error instanceof UsageError || error instanceof ConfigError || error instanceof NotFoundError
44
+ ? error.code
45
+ : undefined;
46
+ console.error(JSON.stringify({ ok: false, error: message, ...(code ? { code } : {}), hint }, null, 2));
47
+ process.exit(exitCode);
48
+ }
49
+ /**
50
+ * Run an async function and route any thrown error through the standard JSON
51
+ * error envelope so users never see a raw stack trace.
52
+ */
53
+ export async function runWithJsonErrors(fn) {
54
+ try {
55
+ await fn();
56
+ }
57
+ catch (error) {
58
+ emitJsonError(error);
59
+ }
60
+ }
61
+ /**
62
+ * Render a command result according to the active output mode (json/jsonl/yaml/text).
63
+ */
64
+ export function output(command, result) {
65
+ const mode = getOutputMode();
66
+ const shaped = shapeForCommand(command, result, mode.detail, mode.forAgent);
67
+ if (mode.format === "jsonl") {
68
+ outputJsonl(command, shaped);
69
+ return;
70
+ }
71
+ switch (mode.format) {
72
+ case "json":
73
+ console.log(JSON.stringify(shaped, null, 2));
74
+ return;
75
+ case "yaml":
76
+ console.log(yamlStringify(shaped));
77
+ return;
78
+ case "text": {
79
+ const plain = formatPlain(command, shaped, mode.detail);
80
+ console.log(plain ?? JSON.stringify(shaped, null, 2));
81
+ return;
82
+ }
83
+ case "md":
84
+ // `--format md` is currently only consumed by `akm health` for the
85
+ // per-run / window-compare table renderings. Commands that don't
86
+ // implement an md renderer fall back to the JSON envelope so
87
+ // pipelines never get an empty stdout.
88
+ console.log(JSON.stringify(shaped, null, 2));
89
+ return;
90
+ }
91
+ }
92
+ /**
93
+ * Collect all occurrences of a repeatable flag from process.argv.
94
+ * Citty's StringArgDef only exposes the last value when a flag is repeated,
95
+ * so for repeatable CLI args (like `--tag foo --tag bar`) we read argv directly.
96
+ * Supports both `--flag value` and `--flag=value` forms.
97
+ */
98
+ export function parseAllFlagValues(flag) {
99
+ const values = [];
100
+ for (let i = 0; i < process.argv.length; i++) {
101
+ const arg = process.argv[i];
102
+ if (arg === flag && i + 1 < process.argv.length) {
103
+ values.push(process.argv[i + 1]);
104
+ // BUG-M4: skip the value index so `--tag --tag` (literal `--tag`
105
+ // value) does not double-count the second `--tag` as a separate
106
+ // flag occurrence.
107
+ i++;
108
+ }
109
+ else if (arg.startsWith(`${flag}=`)) {
110
+ values.push(arg.slice(flag.length + 1));
111
+ }
112
+ }
113
+ return values;
114
+ }