@modusensus/dsh-mneme 0.6.8 → 0.6.10
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/LICENSE +21 -21
- package/README.md +468 -463
- package/cordis.patch.yml +15 -15
- package/lib/api.js +783 -783
- package/lib/client.js +1754 -1757
- package/lib/commands.js +64 -64
- package/lib/config.js +298 -288
- package/lib/dream/clustering.js +118 -118
- package/lib/dream/decisions.js +488 -439
- package/lib/dream/sleep.js +561 -561
- package/lib/dream/tag-extractor.js +156 -156
- package/lib/dream.js +958 -935
- package/lib/embedding.js +154 -154
- package/lib/entities/extractor.js +242 -242
- package/lib/hot-memory.js +53 -53
- package/lib/index.js +361 -361
- package/lib/inject.js +208 -208
- package/lib/local-embedder.js +282 -282
- package/lib/mirror.js +170 -170
- package/lib/parser/tag.js +59 -59
- package/lib/parser/wiki-link.js +38 -38
- package/lib/quality-filter.js +123 -123
- package/lib/reranker.js +218 -218
- package/lib/search/adaptive.js +22 -22
- package/lib/search/bm25.js +96 -96
- package/lib/search/tag-boost.js +61 -61
- package/lib/service.js +1726 -1726
- package/lib/settings.js +172 -172
- package/lib/store.js +2238 -2238
- package/lib/summarize.js +236 -236
- package/lib/tools.js +290 -290
- package/lib/vector-index.js +116 -116
- package/package.json +80 -80
- package/scripts/benchmark-embed.js +201 -201
- package/scripts/benchmark-recall.js +133 -133
- package/scripts/benchmark-rerank.js +166 -166
- package/scripts/e2e-dsh.js +218 -218
- package/scripts/stress-dsh.js +255 -255
- package/scripts/sync-lib.js +52 -52
- package/src/api.js +783 -783
- package/src/commands.js +64 -64
- package/src/config.js +298 -288
- package/src/dream/clustering.js +118 -118
- package/src/dream/decisions.js +488 -439
- package/src/dream/sleep.js +561 -561
- package/src/dream/tag-extractor.js +156 -156
- package/src/dream.js +958 -935
- package/src/embedding.js +154 -154
- package/src/entities/extractor.js +242 -242
- package/src/hot-memory.js +53 -53
- package/src/index.js +361 -361
- package/src/inject.js +208 -208
- package/src/local-embedder.js +282 -282
- package/src/mirror.js +170 -170
- package/src/parser/tag.js +59 -59
- package/src/parser/wiki-link.js +38 -38
- package/src/quality-filter.js +123 -123
- package/src/reranker.js +218 -218
- package/src/search/adaptive.js +22 -22
- package/src/search/bm25.js +96 -96
- package/src/search/tag-boost.js +61 -61
- package/src/service.js +1726 -1726
- package/src/settings.js +172 -172
- package/src/store.js +2238 -2238
- package/src/summarize.js +236 -236
- package/src/tools.js +290 -290
- package/src/vector-index.js +116 -116
- package/test/api.test.js +594 -594
- package/test/audit.test.js +448 -448
- package/test/benchmark.test.js +35 -35
- package/test/boundary-v0625.test.js +82 -82
- package/test/client.test.js +368 -368
- package/test/clustering.test.js +100 -100
- package/test/commands.test.js +69 -69
- package/test/config.test.js +50 -50
- package/test/conflict-freeze.test.js +290 -290
- package/test/directory.test.js +134 -134
- package/test/dream.test.js +1060 -903
- package/test/entities.test.js +522 -522
- package/test/epistemic.test.js +298 -298
- package/test/fnew-0112.test.js +311 -311
- package/test/fnew-03.test.js +422 -422
- package/test/graph-api.test.js +175 -175
- package/test/helpers/dream-mock.js +82 -82
- package/test/hot-memory.test.js +174 -174
- package/test/inject.test.js +103 -103
- package/test/llm-audit.test.js +279 -279
- package/test/local-embedder.test.js +227 -227
- package/test/mirror-dirty.test.js +424 -424
- package/test/mirror-edit-digest.test.js +187 -187
- package/test/mirror-generation.test.js +499 -499
- package/test/mirror.test.js +249 -249
- package/test/normalize-decisions.test.js +120 -120
- package/test/peer-blockers.test.js +190 -190
- package/test/policy-epoch.test.js +259 -259
- package/test/provenance.test.js +103 -103
- package/test/quality-filter.test.js +118 -118
- package/test/reasoning-effort.test.js +199 -199
- package/test/recall-evals.test.js +235 -235
- package/test/recall-layer.test.js +315 -315
- package/test/receipt-chain.test.js +451 -451
- package/test/reflection.test.js +226 -226
- package/test/reranker.test.js +240 -240
- package/test/search-fusion.test.js +90 -90
- package/test/semantic.test.js +124 -124
- package/test/service-search.test.js +199 -199
- package/test/service.test.js +435 -435
- package/test/settings.test.js +118 -118
- package/test/sleep.test.js +365 -365
- package/test/store.test.js +436 -436
- package/test/stress.test.js +209 -209
- package/test/summarize.test.js +191 -191
- package/test/tag-boost.test.js +125 -125
- package/test/tag.test.js +312 -312
- package/test/tools.test.js +285 -285
- package/test/vector-index.test.js +221 -221
- package/test/wiki-link.test.js +332 -332
package/test/settings.test.js
CHANGED
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { createStore } from "../src/store.js";
|
|
4
|
-
import { createSettings } from "../src/settings.js";
|
|
5
|
-
|
|
6
|
-
function setup() {
|
|
7
|
-
const store = createStore(":memory:");
|
|
8
|
-
const settings = createSettings(store.db);
|
|
9
|
-
return { store, settings };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
test("profile defaults to empty and round-trips", () => {
|
|
13
|
-
const { store, settings } = setup();
|
|
14
|
-
assert.equal(settings.getProfile(), "");
|
|
15
|
-
settings.setProfile("我是后端工程师,偏好简洁代码");
|
|
16
|
-
assert.equal(settings.getProfile(), "我是后端工程师,偏好简洁代码");
|
|
17
|
-
settings.setProfile("");
|
|
18
|
-
assert.equal(settings.getProfile(), "");
|
|
19
|
-
store.close();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("rules default to empty list and round-trip", () => {
|
|
23
|
-
const { store, settings } = setup();
|
|
24
|
-
assert.deepEqual(settings.getRules(), []);
|
|
25
|
-
settings.setRules(["规则一", "规则二"]);
|
|
26
|
-
assert.deepEqual(settings.getRules(), ["规则一", "规则二"]);
|
|
27
|
-
settings.setRules([]);
|
|
28
|
-
assert.deepEqual(settings.getRules(), []);
|
|
29
|
-
store.close();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("rules filters non-string entries", () => {
|
|
33
|
-
const { store, settings } = setup();
|
|
34
|
-
settings.setRules(["ok", 42, null, "also-ok"]);
|
|
35
|
-
assert.deepEqual(settings.getRules(), ["ok", "also-ok"]);
|
|
36
|
-
store.close();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("addCommand stores and lists sorted by name", () => {
|
|
40
|
-
const { store, settings } = setup();
|
|
41
|
-
settings.addCommand({ name: "banner", description: "b", instruction: "打印横幅" });
|
|
42
|
-
settings.addCommand({ name: "agenda", instruction: "列出今日议程" });
|
|
43
|
-
const list = settings.listCommands();
|
|
44
|
-
assert.equal(list.length, 2);
|
|
45
|
-
assert.deepEqual(list.map((c) => c.name), ["agenda", "banner"]);
|
|
46
|
-
assert.ok(list[1].id, "has id");
|
|
47
|
-
store.close();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("addCommand replaces existing name", () => {
|
|
51
|
-
const { store, settings } = setup();
|
|
52
|
-
settings.addCommand({ name: "fmt", instruction: "旧指令" });
|
|
53
|
-
const updated = settings.addCommand({ name: "fmt", instruction: "新指令" });
|
|
54
|
-
assert.equal(updated.instruction, "新指令");
|
|
55
|
-
assert.equal(settings.listCommands().length, 1);
|
|
56
|
-
store.close();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("addCommand rejects invalid names and empty instructions", () => {
|
|
60
|
-
const { store, settings } = setup();
|
|
61
|
-
assert.throws(() => settings.addCommand({ name: "Bad Name", instruction: "x" }), /command name/);
|
|
62
|
-
assert.throws(() => settings.addCommand({ name: "123abc", instruction: "x" }), /command name/);
|
|
63
|
-
assert.throws(() => settings.addCommand({ name: "ok", instruction: " " }), /instruction/);
|
|
64
|
-
assert.equal(settings.listCommands().length, 0);
|
|
65
|
-
store.close();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("removeCommand removes by id and returns false for missing", () => {
|
|
69
|
-
const { store, settings } = setup();
|
|
70
|
-
const { id } = settings.addCommand({ name: "tmp", instruction: "x" });
|
|
71
|
-
assert.equal(settings.removeCommand(id), true);
|
|
72
|
-
assert.equal(settings.removeCommand(id), false);
|
|
73
|
-
assert.equal(settings.listCommands().length, 0);
|
|
74
|
-
store.close();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test("vector config defaults to undefined and round-trips", () => {
|
|
78
|
-
const { store, settings } = setup();
|
|
79
|
-
assert.equal(settings.getVectorConfig(), undefined);
|
|
80
|
-
const saved = settings.setVectorConfig({
|
|
81
|
-
enabled: true,
|
|
82
|
-
baseUrl: " https://api.openai.com/v1/ ",
|
|
83
|
-
apiKey: " sk-123 ",
|
|
84
|
-
model: "text-embedding-3-small"
|
|
85
|
-
});
|
|
86
|
-
assert.equal(saved.enabled, true);
|
|
87
|
-
assert.equal(saved.baseUrl, "https://api.openai.com/v1", "trims baseUrl");
|
|
88
|
-
assert.equal(saved.apiKey, "sk-123", "trims apiKey");
|
|
89
|
-
assert.equal(saved.model, "text-embedding-3-small");
|
|
90
|
-
const read = settings.getVectorConfig();
|
|
91
|
-
assert.equal(read.enabled, true);
|
|
92
|
-
assert.equal(read.model, "text-embedding-3-small");
|
|
93
|
-
store.close();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test("vector config disabled value is stored as false", () => {
|
|
97
|
-
const { store, settings } = setup();
|
|
98
|
-
settings.setVectorConfig({ enabled: false, baseUrl: "x", apiKey: "k", model: "m" });
|
|
99
|
-
assert.equal(settings.getVectorConfig().enabled, false);
|
|
100
|
-
store.close();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test("autoTag config defaults to disabled and round-trips", () => {
|
|
104
|
-
const { store, settings } = setup();
|
|
105
|
-
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: false });
|
|
106
|
-
settings.setAutoTagConfig({ autoTagEnabled: true, manualTagEnabled: true });
|
|
107
|
-
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: true, manualTagEnabled: true });
|
|
108
|
-
settings.setAutoTagConfig({ autoTagEnabled: false });
|
|
109
|
-
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: true });
|
|
110
|
-
store.close();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test("autoTag config coerces non-boolean to false", () => {
|
|
114
|
-
const { store, settings } = setup();
|
|
115
|
-
settings.setAutoTagConfig({ autoTagEnabled: "yes", manualTagEnabled: 1 });
|
|
116
|
-
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: false });
|
|
117
|
-
store.close();
|
|
118
|
-
});
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { createStore } from "../src/store.js";
|
|
4
|
+
import { createSettings } from "../src/settings.js";
|
|
5
|
+
|
|
6
|
+
function setup() {
|
|
7
|
+
const store = createStore(":memory:");
|
|
8
|
+
const settings = createSettings(store.db);
|
|
9
|
+
return { store, settings };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
test("profile defaults to empty and round-trips", () => {
|
|
13
|
+
const { store, settings } = setup();
|
|
14
|
+
assert.equal(settings.getProfile(), "");
|
|
15
|
+
settings.setProfile("我是后端工程师,偏好简洁代码");
|
|
16
|
+
assert.equal(settings.getProfile(), "我是后端工程师,偏好简洁代码");
|
|
17
|
+
settings.setProfile("");
|
|
18
|
+
assert.equal(settings.getProfile(), "");
|
|
19
|
+
store.close();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("rules default to empty list and round-trip", () => {
|
|
23
|
+
const { store, settings } = setup();
|
|
24
|
+
assert.deepEqual(settings.getRules(), []);
|
|
25
|
+
settings.setRules(["规则一", "规则二"]);
|
|
26
|
+
assert.deepEqual(settings.getRules(), ["规则一", "规则二"]);
|
|
27
|
+
settings.setRules([]);
|
|
28
|
+
assert.deepEqual(settings.getRules(), []);
|
|
29
|
+
store.close();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("rules filters non-string entries", () => {
|
|
33
|
+
const { store, settings } = setup();
|
|
34
|
+
settings.setRules(["ok", 42, null, "also-ok"]);
|
|
35
|
+
assert.deepEqual(settings.getRules(), ["ok", "also-ok"]);
|
|
36
|
+
store.close();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("addCommand stores and lists sorted by name", () => {
|
|
40
|
+
const { store, settings } = setup();
|
|
41
|
+
settings.addCommand({ name: "banner", description: "b", instruction: "打印横幅" });
|
|
42
|
+
settings.addCommand({ name: "agenda", instruction: "列出今日议程" });
|
|
43
|
+
const list = settings.listCommands();
|
|
44
|
+
assert.equal(list.length, 2);
|
|
45
|
+
assert.deepEqual(list.map((c) => c.name), ["agenda", "banner"]);
|
|
46
|
+
assert.ok(list[1].id, "has id");
|
|
47
|
+
store.close();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("addCommand replaces existing name", () => {
|
|
51
|
+
const { store, settings } = setup();
|
|
52
|
+
settings.addCommand({ name: "fmt", instruction: "旧指令" });
|
|
53
|
+
const updated = settings.addCommand({ name: "fmt", instruction: "新指令" });
|
|
54
|
+
assert.equal(updated.instruction, "新指令");
|
|
55
|
+
assert.equal(settings.listCommands().length, 1);
|
|
56
|
+
store.close();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("addCommand rejects invalid names and empty instructions", () => {
|
|
60
|
+
const { store, settings } = setup();
|
|
61
|
+
assert.throws(() => settings.addCommand({ name: "Bad Name", instruction: "x" }), /command name/);
|
|
62
|
+
assert.throws(() => settings.addCommand({ name: "123abc", instruction: "x" }), /command name/);
|
|
63
|
+
assert.throws(() => settings.addCommand({ name: "ok", instruction: " " }), /instruction/);
|
|
64
|
+
assert.equal(settings.listCommands().length, 0);
|
|
65
|
+
store.close();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("removeCommand removes by id and returns false for missing", () => {
|
|
69
|
+
const { store, settings } = setup();
|
|
70
|
+
const { id } = settings.addCommand({ name: "tmp", instruction: "x" });
|
|
71
|
+
assert.equal(settings.removeCommand(id), true);
|
|
72
|
+
assert.equal(settings.removeCommand(id), false);
|
|
73
|
+
assert.equal(settings.listCommands().length, 0);
|
|
74
|
+
store.close();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("vector config defaults to undefined and round-trips", () => {
|
|
78
|
+
const { store, settings } = setup();
|
|
79
|
+
assert.equal(settings.getVectorConfig(), undefined);
|
|
80
|
+
const saved = settings.setVectorConfig({
|
|
81
|
+
enabled: true,
|
|
82
|
+
baseUrl: " https://api.openai.com/v1/ ",
|
|
83
|
+
apiKey: " sk-123 ",
|
|
84
|
+
model: "text-embedding-3-small"
|
|
85
|
+
});
|
|
86
|
+
assert.equal(saved.enabled, true);
|
|
87
|
+
assert.equal(saved.baseUrl, "https://api.openai.com/v1", "trims baseUrl");
|
|
88
|
+
assert.equal(saved.apiKey, "sk-123", "trims apiKey");
|
|
89
|
+
assert.equal(saved.model, "text-embedding-3-small");
|
|
90
|
+
const read = settings.getVectorConfig();
|
|
91
|
+
assert.equal(read.enabled, true);
|
|
92
|
+
assert.equal(read.model, "text-embedding-3-small");
|
|
93
|
+
store.close();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("vector config disabled value is stored as false", () => {
|
|
97
|
+
const { store, settings } = setup();
|
|
98
|
+
settings.setVectorConfig({ enabled: false, baseUrl: "x", apiKey: "k", model: "m" });
|
|
99
|
+
assert.equal(settings.getVectorConfig().enabled, false);
|
|
100
|
+
store.close();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("autoTag config defaults to disabled and round-trips", () => {
|
|
104
|
+
const { store, settings } = setup();
|
|
105
|
+
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: false });
|
|
106
|
+
settings.setAutoTagConfig({ autoTagEnabled: true, manualTagEnabled: true });
|
|
107
|
+
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: true, manualTagEnabled: true });
|
|
108
|
+
settings.setAutoTagConfig({ autoTagEnabled: false });
|
|
109
|
+
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: true });
|
|
110
|
+
store.close();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("autoTag config coerces non-boolean to false", () => {
|
|
114
|
+
const { store, settings } = setup();
|
|
115
|
+
settings.setAutoTagConfig({ autoTagEnabled: "yes", manualTagEnabled: 1 });
|
|
116
|
+
assert.deepEqual(settings.getAutoTagConfig(), { autoTagEnabled: false, manualTagEnabled: false });
|
|
117
|
+
store.close();
|
|
118
|
+
});
|