akm-cli 0.9.17-alpha.7 → 0.9.17-alpha.9
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 +473 -0
- package/STABILITY.md +9 -8
- package/dist/akm +55 -22
- package/dist/akm-migrate +38 -19
- 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 +20 -20
- 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/commands/health/archive-usage.js +98 -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 +0 -25
- 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 -84
- package/dist/commands/improve/memory/memory-belief.js +3 -1
- package/dist/commands/improve/memory/memory-improve.js +269 -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/curate.js +40 -13
- package/dist/commands/read/knowledge.js +3 -2
- package/dist/commands/read/show.js +55 -16
- package/dist/commands/sources/info.js +3 -0
- package/dist/commands/sources/stash-cli.js +2 -2
- package/dist/core/adapter/adapters/akm-adapter.js +2 -0
- package/dist/core/adapter/adapters/akm-metadata.js +31 -0
- 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 +16 -5
- 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/links/declared-links.js +90 -0
- package/dist/indexer/passes/metadata.js +0 -19
- package/dist/indexer/scan/doc-to-entry.js +1 -0
- 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 +23 -4
- package/dist/output/text/command-format.js +0 -8
- package/dist/output/text/proposal-format.js +47 -1
- package/dist/output/text/show-format.js +13 -17
- package/dist/scripts/akm-migrate-node.js +2754 -2836
- package/dist/scripts/akm-migrate.js +2754 -2836
- package/dist/setup/steps/connection.js +5 -6
- package/dist/setup/steps/platforms.js +2 -2
- package/dist/sources/providers/git-stash.js +55 -4
- package/dist/storage/repositories/improve-ledger-repository.js +48 -7
- package/dist/storage/repositories/index-entries-repository.js +16 -13
- package/dist/storage/repositories/index-entry-schema.js +22 -3
- package/dist/storage/repositories/index-links-repository.js +143 -0
- package/dist/storage/repositories/index-llm-cache-repository.js +7 -26
- package/dist/storage/repositories/index-schema.js +82 -104
- package/dist/storage/repositories/proposals-repository.js +61 -0
- package/dist/storage/repositories/salience-repository.js +1 -19
- package/dist/tasks/source/task-to-v4.js +462 -74
- package/docs/migration/release-notes/0.9.17.md +7 -5
- package/docs/reference/cli.md +33 -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 -431
- package/dist/indexer/graph/graph-extraction.js +0 -807
- 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 -903
- package/dist/llm/metadata-enhance.js +0 -95
- package/dist/tasks/source/task-to-v3.js +0 -453
|
@@ -1,131 +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
|
-
* Find graph files that share entities with the given file.
|
|
6
|
-
*
|
|
7
|
-
* Implementation: SQL self-join on graph_file_entities, scoped by stash_root,
|
|
8
|
-
* grouped by file_path, ordered by shared-entity count desc. Touches ~50-200
|
|
9
|
-
* rows instead of loading the entire snapshot into memory. Cold-call latency
|
|
10
|
-
* drops from ~30-60ms (full snapshot parse) to ~2-5ms on typical stashes.
|
|
11
|
-
*
|
|
12
|
-
* #624-P1: the graph tables are keyed on (stash_root, file_path, body_hash) —
|
|
13
|
-
* NOT entries.id — so candidates are identified by file_path (the unique index
|
|
14
|
-
* idx_graph_files_path guarantees one graph_files row per path).
|
|
15
|
-
*
|
|
16
|
-
* The returned `ref` field carries the canonical indexed `concept_id`, never a
|
|
17
|
-
* value re-derived from presentation fields. It is undefined
|
|
18
|
-
* when the graph row has no matching entry with current indexed provenance.
|
|
19
|
-
*/
|
|
20
|
-
export function listRelatedPathsForFile(stashRoot, filePath, limit = 5, db) {
|
|
21
|
-
if (!db) {
|
|
22
|
-
// Fallback: opening a transient DB here is not currently a use case (all
|
|
23
|
-
// callers pass a handle), so degrade to empty rather than reopening.
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
// Confirm the target file has a graph row; without it there is nothing to
|
|
27
|
-
// relate. (Identity is file_path within the stash — one row per path.)
|
|
28
|
-
const row = db
|
|
29
|
-
.prepare("SELECT 1 AS present FROM graph_files WHERE stash_root = ? AND file_path = ? LIMIT 1")
|
|
30
|
-
.get(stashRoot, filePath);
|
|
31
|
-
if (row === undefined)
|
|
32
|
-
return [];
|
|
33
|
-
const effectiveLimit = Math.max(1, limit);
|
|
34
|
-
// Distinct shared entities per candidate file_path. The target's entities
|
|
35
|
-
// are the rows for `filePath`; candidates are any OTHER file_path in the
|
|
36
|
-
// stash that shares a normalized entity. Counting distinct keys keeps two
|
|
37
|
-
// stored forms of one entity (rows older extractors wrote) from counting twice.
|
|
38
|
-
const candidateRows = db
|
|
39
|
-
.prepare(`SELECT gf.file_path AS file_path,
|
|
40
|
-
gf.file_type AS file_type,
|
|
41
|
-
COUNT(DISTINCT e.entity_norm) AS shared
|
|
42
|
-
FROM graph_file_entities target
|
|
43
|
-
JOIN graph_file_entities e
|
|
44
|
-
ON e.stash_root = target.stash_root
|
|
45
|
-
AND e.entity_norm = target.entity_norm
|
|
46
|
-
AND e.file_path != target.file_path
|
|
47
|
-
JOIN graph_files gf
|
|
48
|
-
ON gf.stash_root = e.stash_root
|
|
49
|
-
AND gf.file_path = e.file_path
|
|
50
|
-
AND gf.body_hash = e.body_hash
|
|
51
|
-
WHERE target.file_path = ?
|
|
52
|
-
AND target.stash_root = ?
|
|
53
|
-
GROUP BY gf.file_path
|
|
54
|
-
ORDER BY shared DESC, gf.file_path ASC
|
|
55
|
-
LIMIT ?`)
|
|
56
|
-
.all(filePath, stashRoot, effectiveLimit);
|
|
57
|
-
if (candidateRows.length === 0)
|
|
58
|
-
return [];
|
|
59
|
-
const candidatePaths = candidateRows.map((r) => r.file_path);
|
|
60
|
-
const placeholders = candidatePaths.map(() => "?").join(",");
|
|
61
|
-
// Pull the shared entity names (joined by normalized casing) for display, in
|
|
62
|
-
// a fixed order so identical calls return identical results.
|
|
63
|
-
const sharedRows = db
|
|
64
|
-
.prepare(`SELECT e.file_path AS file_path, e.entity AS entity
|
|
65
|
-
FROM graph_file_entities e
|
|
66
|
-
JOIN graph_file_entities target
|
|
67
|
-
ON target.stash_root = e.stash_root
|
|
68
|
-
AND target.entity_norm = e.entity_norm
|
|
69
|
-
WHERE e.file_path IN (${placeholders})
|
|
70
|
-
AND e.stash_root = ?
|
|
71
|
-
AND target.file_path = ?
|
|
72
|
-
AND target.stash_root = ?
|
|
73
|
-
ORDER BY e.file_path, e.entity`)
|
|
74
|
-
.all(...candidatePaths, stashRoot, filePath, stashRoot);
|
|
75
|
-
const sharedByPath = new Map();
|
|
76
|
-
for (const row of sharedRows) {
|
|
77
|
-
let bucket = sharedByPath.get(row.file_path);
|
|
78
|
-
if (!bucket) {
|
|
79
|
-
bucket = new Set();
|
|
80
|
-
sharedByPath.set(row.file_path, bucket);
|
|
81
|
-
}
|
|
82
|
-
bucket.add(row.entity);
|
|
83
|
-
}
|
|
84
|
-
// Relation count for each candidate (relations where either endpoint
|
|
85
|
-
// matches one of the shared entities).
|
|
86
|
-
const relationCountByPath = new Map();
|
|
87
|
-
const relationRows = db
|
|
88
|
-
.prepare(`SELECT file_path, from_entity, to_entity
|
|
89
|
-
FROM graph_file_relations
|
|
90
|
-
WHERE file_path IN (${placeholders})
|
|
91
|
-
AND stash_root = ?`)
|
|
92
|
-
.all(...candidatePaths, stashRoot);
|
|
93
|
-
for (const row of relationRows) {
|
|
94
|
-
const shared = sharedByPath.get(row.file_path);
|
|
95
|
-
if (!shared)
|
|
96
|
-
continue;
|
|
97
|
-
if (shared.has(row.from_entity) || shared.has(row.to_entity)) {
|
|
98
|
-
relationCountByPath.set(row.file_path, (relationCountByPath.get(row.file_path) ?? 0) + 1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// This related list is scoped to one source root, so the user-facing ref is
|
|
102
|
-
// the indexed bundle-less conceptId.
|
|
103
|
-
const refByPath = new Map();
|
|
104
|
-
try {
|
|
105
|
-
const entryRows = db
|
|
106
|
-
.prepare(`SELECT file_path, concept_id FROM entries
|
|
107
|
-
WHERE file_path IN (${placeholders})
|
|
108
|
-
ORDER BY file_path, concept_id`)
|
|
109
|
-
.all(...candidatePaths);
|
|
110
|
-
// Several entries can index one file; the first concept id wins.
|
|
111
|
-
for (const row of entryRows) {
|
|
112
|
-
if (!refByPath.has(row.file_path))
|
|
113
|
-
refByPath.set(row.file_path, row.concept_id);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
/* ignore — refs are best-effort */
|
|
118
|
-
}
|
|
119
|
-
return candidateRows.map((row) => {
|
|
120
|
-
const sharedSet = sharedByPath.get(row.file_path) ?? new Set();
|
|
121
|
-
const sharedEntities = [...sharedSet].sort((a, b) => a.localeCompare(b));
|
|
122
|
-
const ref = refByPath.get(row.file_path);
|
|
123
|
-
return {
|
|
124
|
-
...(ref ? { ref } : {}),
|
|
125
|
-
path: row.file_path,
|
|
126
|
-
type: row.file_type,
|
|
127
|
-
sharedEntities,
|
|
128
|
-
relationCount: relationCountByPath.get(row.file_path) ?? 0,
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
}
|