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.
- package/CHANGELOG.md +16 -0
- package/README.md +2 -2
- package/dist/cli/shared.js +114 -0
- package/dist/cli.js +120 -1231
- package/dist/commands/add-cli.js +273 -0
- package/dist/commands/consolidate.js +572 -80
- package/dist/commands/distill.js +94 -11
- package/dist/commands/extract-cli.js +127 -0
- package/dist/commands/extract-prompt.js +204 -0
- package/dist/commands/extract.js +477 -0
- package/dist/commands/feedback-cli.js +324 -0
- package/dist/commands/health.js +962 -44
- package/dist/commands/help/help-improve.md +4 -12
- package/dist/commands/improve-auto-accept.js +97 -0
- package/dist/commands/improve-cli.js +217 -0
- package/dist/commands/improve-profiles.js +25 -5
- package/dist/commands/improve-result-file.js +64 -0
- package/dist/commands/improve.js +452 -262
- package/dist/commands/lint/index.js +10 -1
- package/dist/commands/reflect.js +33 -61
- package/dist/commands/registry-cli.js +141 -0
- package/dist/commands/remember-cli.js +257 -0
- package/dist/commands/tasks.js +3 -4
- package/dist/core/common.js +23 -0
- package/dist/core/config-migration.js +12 -15
- package/dist/core/config-schema.js +35 -4
- package/dist/core/config.js +52 -9
- package/dist/core/frontmatter.js +72 -2
- package/dist/core/proposal-quality-validators.js +22 -6
- package/dist/core/proposals.js +2 -0
- package/dist/core/state-db.js +144 -3
- package/dist/core/tty.js +59 -0
- package/dist/indexer/db-search.js +11 -1
- package/dist/indexer/db.js +25 -0
- package/dist/indexer/indexer.js +17 -10
- package/dist/indexer/llm-cache.js +7 -2
- package/dist/indexer/memory-inference.js +58 -5
- package/dist/indexer/semantic-status.js +1 -1
- package/dist/integrations/agent/index.js +1 -1
- package/dist/integrations/agent/prompts.js +64 -7
- package/dist/integrations/session-logs/index.js +1 -0
- package/dist/integrations/session-logs/inline-refs.js +35 -0
- package/dist/integrations/session-logs/pre-filter.js +152 -0
- package/dist/integrations/session-logs/providers/claude-code.js +223 -0
- package/dist/integrations/session-logs/providers/opencode.js +228 -25
- package/dist/llm/embedder.js +17 -10
- package/dist/llm/embedders/local.js +39 -1
- package/dist/llm/feature-gate.js +9 -3
- package/dist/llm/index-passes.js +39 -10
- package/dist/llm/memory-infer.js +25 -0
- package/dist/llm/prompts/extract-session.md +80 -0
- package/dist/output/context.js +2 -2
- package/dist/output/shapes/distill.js +10 -0
- package/dist/output/shapes/events.js +11 -0
- package/dist/output/shapes/helpers.js +423 -0
- package/dist/output/shapes/history.js +7 -0
- package/dist/output/shapes/passthrough.js +98 -0
- package/dist/output/shapes/proposal-accept.js +7 -0
- package/dist/output/shapes/proposal-diff.js +7 -0
- package/dist/output/shapes/proposal-list.js +7 -0
- package/dist/output/shapes/proposal-producer.js +11 -0
- package/dist/output/shapes/proposal-reject.js +7 -0
- package/dist/output/shapes/proposal-show.js +7 -0
- package/dist/output/shapes/registry-search.js +6 -0
- package/dist/output/shapes/registry.js +30 -0
- package/dist/output/shapes/search.js +6 -0
- package/dist/output/shapes/show.js +6 -0
- package/dist/output/shapes/vault-list.js +19 -0
- package/dist/output/shapes.js +32 -567
- package/dist/output/text/add.js +6 -0
- package/dist/output/text/clone.js +6 -0
- package/dist/output/text/config.js +6 -0
- package/dist/output/text/curate.js +6 -0
- package/dist/output/text/distill.js +7 -0
- package/dist/output/text/enable-disable.js +7 -0
- package/dist/output/text/events.js +10 -0
- package/dist/output/text/feedback.js +6 -0
- package/dist/output/text/helpers.js +1006 -0
- package/dist/output/text/history.js +7 -0
- package/dist/output/text/import.js +6 -0
- package/dist/output/text/index.js +6 -0
- package/dist/output/text/info.js +6 -0
- package/dist/output/text/init.js +6 -0
- package/dist/output/text/list.js +6 -0
- package/dist/output/text/proposal-producer.js +8 -0
- package/dist/output/text/proposal.js +11 -0
- package/dist/output/text/registry-commands.js +11 -0
- package/dist/output/text/registry.js +30 -0
- package/dist/output/text/remember.js +6 -0
- package/dist/output/text/remove.js +6 -0
- package/dist/output/text/save.js +6 -0
- package/dist/output/text/search.js +6 -0
- package/dist/output/text/show.js +6 -0
- package/dist/output/text/update.js +6 -0
- package/dist/output/text/upgrade.js +6 -0
- package/dist/output/text/vault.js +10 -0
- package/dist/output/text/wiki.js +15 -0
- package/dist/output/text/workflow.js +14 -0
- package/dist/output/text.js +41 -1377
- package/dist/registry/factory.js +1 -1
- package/dist/registry/providers/skills-sh.js +1 -1
- package/dist/scripts/migrate-storage.js +262 -51
- package/dist/scripts/migrations/import-fs-improve-runs-to-db.js +84 -2
- package/dist/sources/providers/git.js +126 -14
- package/dist/tasks/schedule.js +17 -1
- package/dist/workflows/runs.js +15 -1
- package/docs/README.md +1 -1
- 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
|
|
1
|
+
# akm -- Agent Knowledge Management
|
|
2
2
|
|
|
3
|
-
> **akm** (Agent
|
|
3
|
+
> **akm** (Agent Knowledge Management) -- A package manager for AI agent skills, commands, tools, and knowledge.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/akm-cli)
|
|
6
6
|
[](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
|
+
}
|