@modusensus/dsh-mneme 0.10.0 → 0.11.0
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/README.md +11 -3
- package/bin/dsh-mneme-choro.mjs +254 -0
- package/docs/CONFIGURATION.md +8 -1
- package/lib/api-standalone.js +17 -21
- package/lib/api.js +298 -12
- package/lib/bootstrap-http.js +105 -0
- package/lib/bootstrap.js +5 -1
- package/lib/choro-command.js +104 -0
- package/lib/client.js +1153 -106
- package/lib/config-keys.js +144 -0
- package/lib/config.js +28 -0
- package/lib/graph/anchoring.js +7 -2
- package/lib/index.js +50 -4
- package/lib/inject.js +15 -3
- package/lib/lang.js +54 -0
- package/lib/quality-filter.js +48 -12
- package/lib/service.js +72 -8
- package/lib/settings.js +8 -1
- package/lib/store.js +657 -0
- package/lib/tools.js +127 -1
- package/lib/wiki/inject.js +164 -0
- package/lib/wiki/partition.js +200 -0
- package/lib/wiki/plan.js +214 -0
- package/lib/wiki/queries.js +220 -0
- package/lib/wiki/render.js +187 -0
- package/lib/wiki/scan.js +371 -0
- package/lib/wiki/t0.js +463 -0
- package/lib/wiki/t1.js +496 -0
- package/lib/write-admission.js +5 -3
- package/package.json +4 -2
- package/src/api-standalone.js +17 -21
- package/src/api.js +298 -12
- package/src/bootstrap-http.js +105 -0
- package/src/bootstrap.js +5 -1
- package/src/choro-command.js +104 -0
- package/src/config-keys.js +144 -0
- package/src/config.js +28 -0
- package/src/graph/anchoring.js +7 -2
- package/src/index.js +50 -4
- package/src/inject.js +15 -3
- package/src/lang.js +54 -0
- package/src/quality-filter.js +48 -12
- package/src/service.js +72 -8
- package/src/settings.js +8 -1
- package/src/store.js +657 -0
- package/src/tools.js +127 -1
- package/src/wiki/inject.js +164 -0
- package/src/wiki/partition.js +200 -0
- package/src/wiki/plan.js +214 -0
- package/src/wiki/queries.js +220 -0
- package/src/wiki/render.js +187 -0
- package/src/wiki/scan.js +371 -0
- package/src/wiki/t0.js +463 -0
- package/src/wiki/t1.js +496 -0
- package/src/write-admission.js +5 -3
- package/test/api-routes-gaps.test.js +131 -1
- package/test/api.test.js +7 -1
- package/test/bootstrap.test.js +8 -0
- package/test/choro-command.test.js +218 -0
- package/test/client.test.js +820 -19
- package/test/config-keys-routes.test.js +233 -0
- package/test/contrast.test.js +14 -7
- package/test/graph-boosted-relations.test.js +189 -0
- package/test/graph-multipath.test.js +269 -0
- package/test/inject.test.js +51 -0
- package/test/llm-audit.test.js +29 -1
- package/test/quality-backfill.test.js +290 -0
- package/test/quality-filter.test.js +113 -4
- package/test/service.test.js +1 -1
- package/test/wiki-api.test.js +153 -0
- package/test/wiki-inject.test.js +265 -0
- package/test/wiki-partition.test.js +112 -0
- package/test/wiki-plan.test.js +80 -0
- package/test/wiki-queries.test.js +187 -0
- package/test/wiki-scan.test.js +208 -0
- package/test/wiki-store.test.js +190 -0
- package/test/wiki-t0.test.js +380 -0
- package/test/wiki-t1.test.js +235 -0
- package/test/wiki-tools.test.js +121 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// chorography 只读工具的回归锁(M1)。锁四件事:
|
|
2
|
+
// 1. 默认配置下三个 choro_* 工具根本不注册(模型连名字都看不到,与 memory_organize
|
|
3
|
+
// 同款反向语义)——tools.test.js 的 11 工具清单锁管默认面,这里管开启面;
|
|
4
|
+
// 2. chorographyEnabled 开 + queries 装配 → 三工具在场;
|
|
5
|
+
// 3. 开了开关但 queries 缺装配(null)→ 同样不在场(「开了没装配」与「没开」
|
|
6
|
+
// 对模型都不可见,可区分性由面板路由的 409/503 负责);
|
|
7
|
+
// 4. execute 的错误形状:多仓歧义带回可选清单、未知 slug 报 page-not-found。
|
|
8
|
+
import test from "node:test";
|
|
9
|
+
import assert from "node:assert/strict";
|
|
10
|
+
import { mkdtempSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { execFileSync } from "node:child_process";
|
|
14
|
+
import { createStore } from "../src/store.js";
|
|
15
|
+
import { createService } from "../src/service.js";
|
|
16
|
+
import { createTools } from "../src/tools.js";
|
|
17
|
+
import { createChoroQueries } from "../src/wiki/queries.js";
|
|
18
|
+
import { runChoroT0 } from "../src/wiki/t0.js";
|
|
19
|
+
|
|
20
|
+
function setup(config = {}, choro) {
|
|
21
|
+
const store = createStore(":memory:");
|
|
22
|
+
const service = createService({ store, mirror: null, config: {} });
|
|
23
|
+
const registered = [];
|
|
24
|
+
const ctx = {
|
|
25
|
+
tools: {
|
|
26
|
+
register(def) {
|
|
27
|
+
registered.push(def);
|
|
28
|
+
return () => {};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
createTools(ctx, service, config, null, null, choro);
|
|
33
|
+
return { registered, store };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function makeRepo(store) {
|
|
37
|
+
const root = mkdtempSync(join(tmpdir(), "choro-tools-"));
|
|
38
|
+
writeFileSync(join(root, "package.json"), JSON.stringify({ name: "toolfix", scripts: { test: "node --test" } }, null, 2) + "\n", "utf8");
|
|
39
|
+
mkdirSync(join(root, "src"), { recursive: true });
|
|
40
|
+
writeFileSync(join(root, "src", "a.js"), 'import { b } from "./b.js";\nexport const a = () => b();\n', "utf8");
|
|
41
|
+
writeFileSync(join(root, "src", "b.js"), "export const b = () => 1;\n", "utf8");
|
|
42
|
+
execFileSync("git", ["init", "-b", "main"], { cwd: root, stdio: "pipe" });
|
|
43
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "add", "-A"], { cwd: root, stdio: "pipe" });
|
|
44
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "commit", "-m", "init", "--no-gpg-sign"], { cwd: root, stdio: "pipe" });
|
|
45
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: () => "T" });
|
|
46
|
+
return root;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function rmTempBestEffort(dir) {
|
|
50
|
+
try {
|
|
51
|
+
rmSync(dir, { recursive: true, force: true });
|
|
52
|
+
} catch {
|
|
53
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
|
|
54
|
+
try { rmSync(dir, { recursive: true, force: true }); } catch { /* 留给系统清理 */ }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
test("默认配置下三个 choro 工具不注册(模型看不到就不会调)", () => {
|
|
59
|
+
const { registered } = setup();
|
|
60
|
+
const names = registered.map((t) => t.name);
|
|
61
|
+
for (const name of ["choro_module_map", "choro_read_page", "choro_search"]) {
|
|
62
|
+
assert.ok(!names.includes(name), `${name} 默认缺席`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("开关关但 queries 缺装配 → 同样缺席(可区分性归路由层)", () => {
|
|
67
|
+
const { registered } = setup({ chorographyEnabled: true }, null);
|
|
68
|
+
const names = registered.map((t) => t.name);
|
|
69
|
+
assert.ok(!names.includes("choro_search"));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("开启后三工具在场,execute 走通读侧三件套", async () => {
|
|
73
|
+
const store = createStore(":memory:");
|
|
74
|
+
const root = makeRepo(store);
|
|
75
|
+
try {
|
|
76
|
+
const choro = createChoroQueries({ store });
|
|
77
|
+
const { registered } = setup({ chorographyEnabled: true }, choro);
|
|
78
|
+
const names = registered.map((t) => t.name);
|
|
79
|
+
for (const name of ["choro_module_map", "choro_read_page", "choro_search"]) {
|
|
80
|
+
assert.ok(names.includes(name), `${name} 在场`);
|
|
81
|
+
}
|
|
82
|
+
const byName = Object.fromEntries(registered.map((t) => [t.name, t]));
|
|
83
|
+
|
|
84
|
+
const map = await byName.choro_module_map.execute({});
|
|
85
|
+
assert.ok(map.modules.length >= 2);
|
|
86
|
+
assert.equal(map.repo, "toolfix");
|
|
87
|
+
|
|
88
|
+
const page = await byName.choro_read_page.execute({ slug: "src" });
|
|
89
|
+
assert.equal(page.slug, "src");
|
|
90
|
+
assert.ok(page.content.includes("## 文件清单"));
|
|
91
|
+
|
|
92
|
+
const missing = await byName.choro_read_page.execute({ slug: "nope" });
|
|
93
|
+
assert.equal(missing.error, "page-not-found");
|
|
94
|
+
|
|
95
|
+
const hits = await byName.choro_search.execute({ query: "b.js" });
|
|
96
|
+
assert.ok(hits.hits.length >= 1);
|
|
97
|
+
} finally {
|
|
98
|
+
store.close();
|
|
99
|
+
rmTempBestEffort(root);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("多仓歧义:execute 返回可选清单而不是猜一个", async () => {
|
|
104
|
+
const store = createStore(":memory:");
|
|
105
|
+
const root1 = makeRepo(store);
|
|
106
|
+
const root2 = makeRepo(store);
|
|
107
|
+
try {
|
|
108
|
+
const choro = createChoroQueries({ store });
|
|
109
|
+
const { registered } = setup({ chorographyEnabled: true }, choro);
|
|
110
|
+
const map = registered.find((t) => t.name === "choro_module_map");
|
|
111
|
+
const result = await map.execute({});
|
|
112
|
+
assert.equal(result.error, "repo-ambiguous");
|
|
113
|
+
assert.equal(result.repos.length, 2);
|
|
114
|
+
const named = await map.execute({ repo: "toolfix" });
|
|
115
|
+
assert.ok(named.modules, "显式给名后解析成功(fixture 同名仓按 id 序取先者)");
|
|
116
|
+
} finally {
|
|
117
|
+
store.close();
|
|
118
|
+
rmTempBestEffort(root1);
|
|
119
|
+
rmTempBestEffort(root2);
|
|
120
|
+
}
|
|
121
|
+
});
|