akm-cli 0.9.17-alpha.8 → 0.9.17
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 +277 -1694
- package/STABILITY.md +9 -8
- package/dist/assets/hints/cli-hints-full.md +6 -7
- package/dist/assets/improve-strategies/catchup.json +0 -3
- package/dist/assets/improve-strategies/consolidate.json +0 -1
- package/dist/assets/improve-strategies/default.json +1 -2
- package/dist/assets/improve-strategies/proactive-maintenance.json +1 -2
- package/dist/assets/improve-strategies/quick.json +1 -2
- package/dist/assets/improve-strategies/reflect-distill.json +1 -2
- package/dist/assets/improve-strategies/thorough.json +0 -3
- package/dist/assets/prompts/consolidate-pair.md +20 -0
- package/dist/assets/stash-skeleton/facts/conventions/backlinks.md +17 -19
- package/dist/assets/stash-skeleton/facts/conventions/domains.md +2 -2
- package/dist/assets/templates/html/health.html +3 -5
- package/dist/cli/retired-commands.js +1 -1
- package/dist/cli/unknown-flags.js +24 -1
- package/dist/cli.js +46 -1
- package/dist/commands/health/archive-usage.js +92 -0
- package/dist/commands/health/data-dir-usage.js +25 -13
- package/dist/commands/health/html-report.js +1 -4
- package/dist/commands/health/improve-metrics.js +25 -37
- package/dist/commands/health/md-report.js +1 -6
- package/dist/commands/health/report-view-model.js +4 -14
- package/dist/commands/health/windows.js +0 -1
- package/dist/commands/health.js +13 -0
- package/dist/commands/improve/consolidate/continuity-check.js +137 -0
- package/dist/commands/improve/consolidate/pair-pass.js +791 -0
- package/dist/commands/improve/consolidate.js +38 -63
- package/dist/commands/improve/extract-prompt.js +1 -2
- package/dist/commands/improve/improve-cli.js +1 -1
- package/dist/commands/improve/improve-strategies.js +23 -5
- package/dist/commands/improve/improve.js +19 -30
- package/dist/commands/improve/ledger.js +3 -2
- package/dist/commands/improve/loop-stages.js +5 -85
- package/dist/commands/improve/memory/memory-belief.js +3 -1
- package/dist/commands/improve/memory/memory-improve.js +262 -11
- package/dist/commands/improve/planner.js +0 -5
- package/dist/commands/improve/preparation.js +20 -135
- package/dist/commands/improve/retrieval-scope.js +19 -4
- package/dist/commands/improve/salience.js +1 -14
- package/dist/commands/improve/stage.js +0 -1
- package/dist/commands/lint/base-linter.js +19 -11
- package/dist/commands/proposal/drain.js +8 -1
- package/dist/commands/proposal/proposal-cli.js +16 -2
- package/dist/commands/proposal/proposal-types.js +7 -0
- package/dist/commands/proposal/proposal.js +37 -6
- package/dist/commands/proposal/repository.js +613 -4
- package/dist/commands/proposal/validators/proposals.js +9 -0
- package/dist/commands/read/knowledge.js +3 -2
- package/dist/commands/read/show.js +0 -14
- package/dist/commands/sources/info.js +122 -18
- package/dist/commands/sources/stash-cli.js +23 -3
- package/dist/core/bundle-rename.js +1 -7
- package/dist/core/config/config-schema.js +8 -1
- package/dist/core/config/config.js +23 -48
- package/dist/core/config/engine-semantics.js +0 -2
- package/dist/core/config/schema/improve-processes.js +17 -42
- package/dist/core/config/schema/index-config.js +5 -25
- package/dist/core/file-change.js +13 -5
- package/dist/core/improve-result.js +22 -6
- package/dist/core/improve-types.js +0 -1
- package/dist/core/loopback.js +7 -12
- package/dist/core/parse.js +13 -16
- package/dist/core/state/migrations.js +15 -0
- package/dist/core/time.js +0 -20
- package/dist/indexer/db/llm-cache.js +2 -2
- package/dist/indexer/ensure-index.js +2 -2
- package/dist/indexer/index-written-assets.js +2 -3
- package/dist/indexer/indexer.js +18 -418
- package/dist/indexer/passes/metadata.js +0 -19
- package/dist/indexer/walk/walker.js +3 -4
- package/dist/llm/client.js +8 -10
- package/dist/llm/embedders/remote.js +1 -2
- package/dist/llm/feature-gate.js +0 -5
- package/dist/output/shapes/helpers.js +20 -4
- package/dist/output/text/command-format.js +9 -8
- package/dist/output/text/proposal-format.js +47 -1
- package/dist/output/text/show-format.js +0 -20
- package/dist/scripts/akm-migrate-node.js +923 -950
- package/dist/scripts/akm-migrate.js +923 -950
- package/dist/setup/steps/connection.js +5 -6
- package/dist/setup/steps/platforms.js +2 -2
- package/dist/sources/providers/git-stash.js +83 -4
- package/dist/storage/repositories/improve-ledger-repository.js +48 -7
- package/dist/storage/repositories/index-connection.js +5 -2
- package/dist/storage/repositories/index-entries-repository.js +4 -7
- package/dist/storage/repositories/index-entry-schema.js +4 -2
- package/dist/storage/repositories/index-llm-cache-repository.js +7 -26
- package/dist/storage/repositories/index-schema.js +55 -104
- package/dist/storage/repositories/proposals-repository.js +61 -0
- package/dist/storage/repositories/salience-repository.js +1 -19
- package/docs/migration/README.md +1 -1
- package/docs/migration/release-notes/0.9.17.md +130 -41
- package/docs/migration/release-notes/README.md +7 -0
- package/docs/reference/cli.md +27 -21
- package/docs/reference/configuration.md +21 -12
- package/docs/reference/data-and-telemetry.md +0 -1
- package/package.json +1 -1
- package/schemas/akm-config.json +0 -342
- package/dist/assets/improve-strategies/graph-refresh.json +0 -15
- package/dist/assets/prompts/contradiction-judge.md +0 -33
- package/dist/assets/prompts/graph-extract-system.md +0 -1
- package/dist/assets/prompts/graph-extract-user-prompt.md +0 -35
- package/dist/assets/prompts/metadata-enhance-system.md +0 -1
- package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +0 -4
- package/dist/indexer/db/graph-db.js +0 -399
- package/dist/indexer/graph/graph-extraction.js +0 -809
- package/dist/indexer/graph/graph-related.js +0 -131
- package/dist/indexer/graph/graph-types.js +0 -4
- package/dist/llm/graph-extract.js +0 -892
- package/dist/llm/metadata-enhance.js +0 -95
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
* LLM-driven metadata enhancement for stash entries.
|
|
6
|
-
*
|
|
7
|
-
* Keeps the higher-level workflow for improving descriptions, tags, and search
|
|
8
|
-
* hints separate from the low-level transport client.
|
|
9
|
-
*/
|
|
10
|
-
import metadataEnhanceSystemPrompt from "../assets/prompts/metadata-enhance-system.md" with { type: "text" };
|
|
11
|
-
import { parseJsonResponse } from "../core/parse.js";
|
|
12
|
-
import { callStructured } from "./structured-call.js";
|
|
13
|
-
const SYSTEM_PROMPT = metadataEnhanceSystemPrompt;
|
|
14
|
-
/**
|
|
15
|
-
* Use an LLM to enhance a stash entry's metadata: improve description,
|
|
16
|
-
* generate searchHints, and suggest tags.
|
|
17
|
-
*
|
|
18
|
-
* When `akmConfig` is provided, routes through
|
|
19
|
-
* `tryLlmFeature("metadata_enhance", ...)` so the feature gate is honoured: a
|
|
20
|
-
* closed gate yields `{ status: "skipped" }` and a thrown/timed-out call yields
|
|
21
|
-
* `{ status: "failed" }` — neither is reported as an enrichment. When
|
|
22
|
-
* `akmConfig` is `undefined` the gate is bypassed entirely: the LLM call runs
|
|
23
|
-
* unconditionally and errors propagate to direct callers such as tests.
|
|
24
|
-
*/
|
|
25
|
-
export async function enhanceMetadata(runner, entry, fileContent, signal, akmConfig, onNotices) {
|
|
26
|
-
const contextParts = [`Name: ${entry.name}`, `Type: ${entry.type}`];
|
|
27
|
-
if (entry.description)
|
|
28
|
-
contextParts.push(`Current description: ${entry.description}`);
|
|
29
|
-
if (entry.tags?.length)
|
|
30
|
-
contextParts.push(`Current tags: ${entry.tags.join(", ")}`);
|
|
31
|
-
if (fileContent) {
|
|
32
|
-
// Limit content to first 4000 chars to stay within token limits (matches other modules)
|
|
33
|
-
const truncated = fileContent.length > 4000 ? `${fileContent.slice(0, 4000)}\n... (truncated)` : fileContent;
|
|
34
|
-
contextParts.push(`File content:\n${truncated}`);
|
|
35
|
-
}
|
|
36
|
-
const userPrompt = `${contextParts.join("\n")}
|
|
37
|
-
|
|
38
|
-
Generate improved metadata for this ${entry.type}. Return JSON with these fields:
|
|
39
|
-
- "description": a clear, concise one-sentence description of what this does
|
|
40
|
-
- "searchHints": an array of 3-6 natural language task phrases an agent might use to find this (e.g. "deploy a docker container", "run database migrations")
|
|
41
|
-
- "tags": an array of 3-8 relevant keyword tags
|
|
42
|
-
|
|
43
|
-
Return ONLY the JSON object, no explanation.`;
|
|
44
|
-
// `parse` owns the raw response: the `!raw`/unparseable case ⇒ empty metadata
|
|
45
|
-
// (still a genuine success), plus the description/searchHints/tags shaping.
|
|
46
|
-
// `enhanceMetadata` never warns and never bumps telemetry — `onError` (gated
|
|
47
|
-
// path only) reports `failed` WITHOUT warning, carrying the message so the
|
|
48
|
-
// caller can surface it. The ungated path (akmConfig === undefined) propagates
|
|
49
|
-
// errors via callStructured.
|
|
50
|
-
let timedOut = false;
|
|
51
|
-
const outcome = await callStructured({
|
|
52
|
-
feature: "metadata_enhance",
|
|
53
|
-
akmConfig,
|
|
54
|
-
runner,
|
|
55
|
-
messages: [
|
|
56
|
-
{ role: "system", content: SYSTEM_PROMPT },
|
|
57
|
-
{ role: "user", content: userPrompt },
|
|
58
|
-
],
|
|
59
|
-
request: { signal, timeoutMs: runner.timeoutMs },
|
|
60
|
-
onNotices,
|
|
61
|
-
parse: (raw) => {
|
|
62
|
-
const parsed = raw ? parseJsonResponse(raw) : undefined;
|
|
63
|
-
const metadata = {};
|
|
64
|
-
if (parsed) {
|
|
65
|
-
if (typeof parsed.description === "string" && parsed.description) {
|
|
66
|
-
metadata.description = parsed.description;
|
|
67
|
-
}
|
|
68
|
-
if (Array.isArray(parsed.searchHints)) {
|
|
69
|
-
metadata.searchHints = parsed.searchHints
|
|
70
|
-
.filter((s) => typeof s === "string" && s.trim().length > 0)
|
|
71
|
-
.slice(0, 8);
|
|
72
|
-
}
|
|
73
|
-
if (Array.isArray(parsed.tags)) {
|
|
74
|
-
metadata.tags = parsed.tags
|
|
75
|
-
.filter((s) => typeof s === "string" && s.trim().length > 0)
|
|
76
|
-
.slice(0, 10);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return { status: "enriched", metadata };
|
|
80
|
-
},
|
|
81
|
-
onError: (_cls, err) => ({ status: "failed", error: err instanceof Error ? err.message : String(err) }),
|
|
82
|
-
fallback: { status: "skipped" },
|
|
83
|
-
// The seam returns the `skipped` fallback for a closed gate AND for a
|
|
84
|
-
// wrapper-level timeout. Record the timeout so we can reclassify it below —
|
|
85
|
-
// a timed-out call is a failure, not a silent skip.
|
|
86
|
-
onFallback: (event) => {
|
|
87
|
-
if (event.reason === "timeout")
|
|
88
|
-
timedOut = true;
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
if (outcome.status === "skipped" && timedOut) {
|
|
92
|
-
return { status: "failed", error: "metadata_enhance timed out" };
|
|
93
|
-
}
|
|
94
|
-
return outcome;
|
|
95
|
-
}
|