dsh-cortex-memory 0.4.14 → 0.4.16
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 +17 -8
- package/README.md +38 -18
- package/bench/README.md +29 -0
- package/bench/results/semantic-cn.json +24 -0
- package/bench/semantic-cn.js +116 -0
- package/docs/install-windows.md +1 -2
- package/examples/README.md +2 -3
- package/examples/uninstall-cortex.ps1 +0 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/core/config.js +1 -1
- package/src/core/feature-overrides.js +1 -1
- package/src/core/profile.js +8 -1
- package/test/unit/profile-paths.test.js +21 -0
- package/test/unit/profile.test.js +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.4.
|
|
3
|
+
## 0.4.16 — 2026-11-13
|
|
4
|
+
|
|
5
|
+
- Default data root moves to `DSH_HOME/cortex-memory` (desktop) and `DSH_HOME/cortex-memory/profiles/<profile>` for other profiles.
|
|
6
|
+
- Legacy `DSH_HOME/cortex` is never moved or deleted. Migration scripts copy it, keep a backup, and verify the copy before DSH opens the new root.
|
|
7
|
+
- Loader id stays `cortex` in this release; a later migration-scripted release will rename it.
|
|
8
|
+
- README extractor version corrected to 0.3.5; mojibake repaired.
|
|
9
|
+
|
|
10
|
+
## 0.4.13 — 2026-11-13
|
|
4
11
|
|
|
5
12
|
### Added
|
|
6
13
|
- `evolution` guard in Config schema (`autoActivate`, `maxPerDay`, `minIntervalMs`, `canaryTicks`, `rollbackOnError`).
|
|
@@ -14,7 +21,7 @@
|
|
|
14
21
|
- Canary ticks are persisted, not just kept in memory.
|
|
15
22
|
- Schema version bumped to 7 for the additive `canary_json` column.
|
|
16
23
|
|
|
17
|
-
## 0.4.12
|
|
24
|
+
## 0.4.12 — 2026-11-13
|
|
18
25
|
|
|
19
26
|
### Fixed
|
|
20
27
|
- `promptBudget` is normalized instead of being silently dropped and falling back to 1600.
|
|
@@ -30,12 +37,12 @@
|
|
|
30
37
|
- `gated` count in the retrieval trace.
|
|
31
38
|
- Regression tests for the prompt gate, importance exposure, identity L0, per-session recall, light/deep guardian, and configurable `promptBudget`.
|
|
32
39
|
|
|
33
|
-
## 0.4.11
|
|
40
|
+
## 0.4.11 — 2026-11-12
|
|
34
41
|
|
|
35
42
|
- Life/date fixes, graph candidate labels, neutral public package surface.
|
|
36
43
|
- Recent timeline endpoint and incremental summon rebuild.
|
|
37
44
|
|
|
38
|
-
## 0.4.0
|
|
45
|
+
## 0.4.0 — 2026-11-12
|
|
39
46
|
|
|
40
47
|
### Fixed
|
|
41
48
|
- Prompt-only injection gate; full search/API/CLI remain available.
|
|
@@ -47,15 +54,15 @@
|
|
|
47
54
|
- Tests and docs are included in the package; `npm test` works after install.
|
|
48
55
|
|
|
49
56
|
### Added
|
|
50
|
-
- `persona.selfName` / `persona.userAddress`; neutral public defaults (
|
|
57
|
+
- `persona.selfName` / `persona.userAddress`; neutral public defaults (`助手` / `用户`).
|
|
51
58
|
- `injectionGate`, `recentMinMatch`, `allowRestoreOutsideRoot` config.
|
|
52
59
|
|
|
53
60
|
### Compatibility
|
|
54
61
|
- Additive config only; no schema migration.
|
|
55
62
|
- Existing 0.3.x databases open in place.
|
|
56
|
-
- Local profiles can restore the
|
|
63
|
+
- Local profiles can restore the 本鲸 / 主人 persona through config.
|
|
57
64
|
|
|
58
|
-
## 0.3.1
|
|
65
|
+
## 0.3.1 — 026-11-12
|
|
59
66
|
|
|
60
67
|
- AI diary entries no longer append a 閳ユ粌寮懓鍐b偓?footer; web sources still inform the model but are not stored in the diary body.
|
|
61
68
|
- Manual dream generation timeout raised from 4s to 20s; `aiOnlyLife` still fails closed instead of falling back to a template.
|
|
@@ -109,3 +116,5 @@
|
|
|
109
116
|
|
|
110
117
|
|
|
111
118
|
|
|
119
|
+
|
|
120
|
+
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# DSH Cortex
|
|
2
2
|
|
|
3
3
|
A local-first, layered memory engine for DeepSeek Harness.
|
|
4
4
|
|
|
@@ -9,14 +9,20 @@ core engine.
|
|
|
9
9
|
|
|
10
10
|
## Status
|
|
11
11
|
|
|
12
|
-
- Package: `dsh-cortex-memory@0.4.
|
|
13
|
-
- Optional extractor: `dsh-cortex-extractors@0.3.
|
|
12
|
+
- Package: `dsh-cortex-memory@0.4.16`
|
|
13
|
+
- Optional extractor: `dsh-cortex-extractors@0.3.5`
|
|
14
14
|
- DSH: `>=0.2.1-rc.2 <0.4.0`
|
|
15
15
|
- Node: `>=24`
|
|
16
|
-
- Tests:
|
|
16
|
+
- Tests: 437/437 (main)
|
|
17
17
|
- CI: GitHub Actions on Windows, Node 24
|
|
18
18
|
|
|
19
|
-
### What 0.4.
|
|
19
|
+
### What 0.4.16 changes
|
|
20
|
+
|
|
21
|
+
- **Public data path is now `~/.dsh/cortex-memory`**. The old `~/.dsh/cortex` directory is never moved or deleted; the oneclick/upgrade script copies it, verifies it, and keeps a backup.
|
|
22
|
+
- **No loader-id change in 0.4.16**: the bundle row remains `cortex` for compatibility. Renaming it to `cortex-memory` is reserved for a migration-scripted release.
|
|
23
|
+
- README extractor version corrected to 0.3.5 and corrupted characters repaired.
|
|
24
|
+
|
|
25
|
+
### What 0.4.15 changes
|
|
20
26
|
|
|
21
27
|
- **Evolution guard is configurable**: `autoActivate`, `maxPerDay`,
|
|
22
28
|
`minIntervalMs`, `canaryTicks` and `rollbackOnError` are now in the Config
|
|
@@ -58,7 +64,7 @@ core engine.
|
|
|
58
64
|
- Life/date fixes: serialized LLM calls, timeouts, `Asia/Shanghai` diary time,
|
|
59
65
|
and date-header stripping.
|
|
60
66
|
- Graph candidate labels (`fromName` / `toName` / `relLabel`) and cleanup.
|
|
61
|
-
- Neutral public package surface: default `selfName:
|
|
67
|
+
- Neutral public package surface: default `selfName: 助手`, `userAddress: 用户`.
|
|
62
68
|
- Recent timeline endpoint and incremental summon rebuild.
|
|
63
69
|
|
|
64
70
|
### What 0.3.0 changes
|
|
@@ -75,18 +81,31 @@ core engine.
|
|
|
75
81
|
The npm package is named `dsh-cortex-memory` because `dsh-cortex` was already
|
|
76
82
|
taken; the installed bundle is still the Cortex memory engine.
|
|
77
83
|
|
|
84
|
+
## Data path migration
|
|
85
|
+
|
|
86
|
+
0.4.16 defaults to `DSH_HOME/cortex-memory` (or `DSH_HOME/cortex-memory/profiles/<profile>`).
|
|
87
|
+
The old `DSH_HOME/cortex` directory is never moved or deleted.
|
|
88
|
+
|
|
89
|
+
Before starting 0.4.16 with existing memories, close DSH and run:
|
|
90
|
+
|
|
91
|
+
```powershell
|
|
92
|
+
powershell -ExecutionPolicy Bypass -File .\tools\migrate-cortex-path.ps1
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The script copies the old root, verifies the copied `cortex.sqlite` size, and leaves the old root as rollback.
|
|
96
|
+
|
|
78
97
|
## Install
|
|
79
98
|
|
|
80
99
|
```powershell
|
|
81
|
-
npm i dsh-cortex-memory@0.4.
|
|
82
|
-
npm i dsh-cortex-extractors@0.3.
|
|
100
|
+
npm i dsh-cortex-memory@0.4.16
|
|
101
|
+
npm i dsh-cortex-extractors@0.3.5 # optional OCR/ASR
|
|
83
102
|
```
|
|
84
103
|
|
|
85
104
|
Or let DSH add the bundles:
|
|
86
105
|
|
|
87
106
|
```powershell
|
|
88
|
-
dsh plugin --profile desktop add dsh-cortex-memory@0.4.
|
|
89
|
-
dsh plugin --profile desktop add dsh-cortex-extractors@0.3.
|
|
107
|
+
dsh plugin --profile desktop add dsh-cortex-memory@0.4.16
|
|
108
|
+
dsh plugin --profile desktop add dsh-cortex-extractors@0.3.5
|
|
90
109
|
```
|
|
91
110
|
|
|
92
111
|
Or use the Windows one-click zip from the GitHub Release. The installer
|
|
@@ -117,20 +136,20 @@ left sidebar by default.
|
|
|
117
136
|
|
|
118
137
|
```text
|
|
119
138
|
conversation / event
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
→ L1 trace (source of truth)
|
|
140
|
+
→ appraisal + emotion + drives
|
|
141
|
+
→ L2 summon card (atomic, triggerable)
|
|
142
|
+
→ L3 summon volume (index + representatives)
|
|
143
|
+
→ explicit use / feedback → DSR update
|
|
125
144
|
```
|
|
126
145
|
|
|
127
146
|
The per-turn order is:
|
|
128
147
|
|
|
129
148
|
```text
|
|
130
149
|
L0 identity and boundaries
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
150
|
+
→ working memory
|
|
151
|
+
→ recalled traces and summon cards
|
|
152
|
+
→ user message
|
|
134
153
|
```
|
|
135
154
|
|
|
136
155
|
Summon cards are injected as **untrusted historical references**, never as instructions. Identity and boundaries always outrank them.
|
|
@@ -220,3 +239,4 @@ MIT.
|
|
|
220
239
|
|
|
221
240
|
|
|
222
241
|
|
|
242
|
+
|
package/bench/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Cortex benchmarks
|
|
2
|
+
|
|
3
|
+
## semantic-cn.js
|
|
4
|
+
|
|
5
|
+
Reproducible controlled Chinese retrieval probe.
|
|
6
|
+
|
|
7
|
+
```powershell
|
|
8
|
+
node bench/semantic-cn.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
It creates a temporary Cortex database, writes 12 controlled memories, runs
|
|
12
|
+
12 queries through full search and injection-tiered recall, and reports
|
|
13
|
+
recall@3, MRR@3, nDCG@3, p50 and p95. Output is written to
|
|
14
|
+
`bench/results/semantic-cn.json`.
|
|
15
|
+
|
|
16
|
+
This is deliberately labeled **synthetic-controlled**. It is not LoCoMo,
|
|
17
|
+
LongMemEval, MemoryAgentBench or an official score.
|
|
18
|
+
|
|
19
|
+
## LoCoMo / LongMemEval
|
|
20
|
+
|
|
21
|
+
Adapters live in `bench/locomo.js` and `bench/longmemeval.js`. They evaluate
|
|
22
|
+
retrieval only; do not claim official end-to-end QA scores from them.
|
|
23
|
+
|
|
24
|
+
## OCR / ASR
|
|
25
|
+
|
|
26
|
+
OCR and ASR microbenchmarks belong to `dsh-cortex-extractors`, because the
|
|
27
|
+
engine and model choices are external. The extractor package includes its
|
|
28
|
+
layout/TSV/empty-text/link tests. Real Chinese screenshot/audio accuracy needs
|
|
29
|
+
explicit samples and environments; no numbers are fabricated here.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "semantic-cn",
|
|
3
|
+
"kind": "synthetic-controlled",
|
|
4
|
+
"note": "Not an official LoCoMo/LongMemEval score. Controlled Chinese memories and queries; no real user data.",
|
|
5
|
+
"at": "2026-11-13T03:53:09.106Z",
|
|
6
|
+
"memories": 12,
|
|
7
|
+
"queries": 12,
|
|
8
|
+
"full": {
|
|
9
|
+
"n": 12,
|
|
10
|
+
"recallAt3": 1,
|
|
11
|
+
"mrrAt3": 0.9166666666666666,
|
|
12
|
+
"ndcgAt3": 0.9384882922619097,
|
|
13
|
+
"p50Ms": 1.31,
|
|
14
|
+
"p95Ms": 4.07
|
|
15
|
+
},
|
|
16
|
+
"inject": {
|
|
17
|
+
"n": 12,
|
|
18
|
+
"recallAt3": 1,
|
|
19
|
+
"mrrAt3": 0.9166666666666666,
|
|
20
|
+
"ndcgAt3": 0.9384882922619097,
|
|
21
|
+
"p50Ms": 1.11,
|
|
22
|
+
"p95Ms": 3.34
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Reproducible synthetic Chinese semantic retrieval probe.
|
|
4
|
+
*
|
|
5
|
+
* This is not LoCoMo/LongMemEval and must not be reported as an official
|
|
6
|
+
* benchmark score. It checks whether the current hybrid retrieval can find a
|
|
7
|
+
* known target among controlled distractors before/after the injection gate.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { performance } from 'node:perf_hooks';
|
|
13
|
+
import { createCortex } from '../src/service/cortex.js';
|
|
14
|
+
|
|
15
|
+
const dir = mkdtempSync(path.join(os.tmpdir(), 'cortex-semantic-cn-'));
|
|
16
|
+
const cortex = createCortex({
|
|
17
|
+
config: {
|
|
18
|
+
dataRoot: dir,
|
|
19
|
+
dbFile: path.join(dir, 'cortex.sqlite'),
|
|
20
|
+
features: { autoFacts: false, llmFacts: false, autoGraphCandidates: false },
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const data = [
|
|
25
|
+
['便宜订阅', '涵儿喜欢便宜的音乐订阅,不买贵的套餐。'],
|
|
26
|
+
['白饭承诺', '涵儿答应下班带白饭,汐儿记得这个承诺。'],
|
|
27
|
+
['颈椎', '久坐后颈椎会疼,汐儿提醒涵儿起身。'],
|
|
28
|
+
['猫粮', '家里的猫只吃鸡肉味猫粮。'],
|
|
29
|
+
['雨天', '下雨天要带伞,涵儿常忘记。'],
|
|
30
|
+
['周末', '周末计划去河边散步。'],
|
|
31
|
+
['白饭', '白饭要热的,不要隔夜。'],
|
|
32
|
+
['订阅', '订阅续费前先看价格。'],
|
|
33
|
+
['颈椎', '颈椎疼时不要继续低头。'],
|
|
34
|
+
['猫', '猫晚上会在门口等。'],
|
|
35
|
+
['伞', '伞放在玄关的右边。'],
|
|
36
|
+
['散步', '散步时不看手机。'],
|
|
37
|
+
];
|
|
38
|
+
const written = new Map();
|
|
39
|
+
for (const [title, text] of data) {
|
|
40
|
+
const row = cortex.write({ text, title, kind: 'observation', explicit: true, importance: 0.72 });
|
|
41
|
+
written.set(title, row.trace.id);
|
|
42
|
+
}
|
|
43
|
+
const queries = [
|
|
44
|
+
['白饭', '白饭承诺'],
|
|
45
|
+
['便宜 订阅', '便宜订阅'],
|
|
46
|
+
['颈椎 疼', '颈椎'],
|
|
47
|
+
['猫 吃 什么', '猫粮'],
|
|
48
|
+
['下雨 带伞', '雨天'],
|
|
49
|
+
['周末 散步', '周末'],
|
|
50
|
+
['白饭 热', '白饭'],
|
|
51
|
+
['订阅 价格', '订阅'],
|
|
52
|
+
['低头 颈椎', '颈椎'],
|
|
53
|
+
['猫 晚上', '猫'],
|
|
54
|
+
['玄关 伞', '伞'],
|
|
55
|
+
['散步 手机', '散步'],
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
function metrics(rows) {
|
|
59
|
+
let hits = 0;
|
|
60
|
+
let mrr = 0;
|
|
61
|
+
let ndcg = 0;
|
|
62
|
+
for (const row of rows) {
|
|
63
|
+
const index = row.ids.indexOf(row.expected);
|
|
64
|
+
if (index >= 0) {
|
|
65
|
+
hits += 1;
|
|
66
|
+
mrr += 1 / (index + 1);
|
|
67
|
+
ndcg += 1 / Math.log2(index + 2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const n = rows.length;
|
|
71
|
+
return {
|
|
72
|
+
n,
|
|
73
|
+
recallAt3: hits / n,
|
|
74
|
+
mrrAt3: mrr / n,
|
|
75
|
+
ndcgAt3: ndcg / n,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function run(mode) {
|
|
80
|
+
const rows = [];
|
|
81
|
+
const latencies = [];
|
|
82
|
+
for (const [query, expectedTitle] of queries) {
|
|
83
|
+
const started = performance.now();
|
|
84
|
+
const result = mode === 'inject'
|
|
85
|
+
? cortex.recallTiered({ query, limit: 3 }).result
|
|
86
|
+
: cortex.search(query, { limit: 3 });
|
|
87
|
+
latencies.push(performance.now() - started);
|
|
88
|
+
rows.push({ query, expected: written.get(expectedTitle), ids: result.items.map((item) => item.id) });
|
|
89
|
+
}
|
|
90
|
+
latencies.sort((a, b) => a - b);
|
|
91
|
+
const p50 = latencies[Math.floor(latencies.length * 0.5)] ?? null;
|
|
92
|
+
const p95 = latencies[Math.max(0, Math.ceil(latencies.length * 0.95) - 1)] ?? null;
|
|
93
|
+
return { ...metrics(rows), p50Ms: Math.round(p50 * 100) / 100, p95Ms: Math.round(p95 * 100) / 100 };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const full = run('full');
|
|
98
|
+
const injected = run('inject');
|
|
99
|
+
const result = {
|
|
100
|
+
name: 'semantic-cn',
|
|
101
|
+
kind: 'synthetic-controlled',
|
|
102
|
+
note: 'Not an official LoCoMo/LongMemEval score. Controlled Chinese memories and queries; no real user data.',
|
|
103
|
+
at: new Date().toISOString(),
|
|
104
|
+
memories: data.length,
|
|
105
|
+
queries: queries.length,
|
|
106
|
+
full,
|
|
107
|
+
inject: injected,
|
|
108
|
+
};
|
|
109
|
+
const out = path.join(import.meta.dirname, 'results');
|
|
110
|
+
mkdirSync(out, { recursive: true });
|
|
111
|
+
writeFileSync(path.join(out, 'semantic-cn.json'), JSON.stringify(result, null, 2) + '\n', 'utf8');
|
|
112
|
+
console.log(JSON.stringify(result, null, 2));
|
|
113
|
+
} finally {
|
|
114
|
+
cortex.close();
|
|
115
|
+
rmSync(dir, { recursive: true, force: true });
|
|
116
|
+
}
|
package/docs/install-windows.md
CHANGED
|
@@ -92,7 +92,7 @@ dsh plugin --profile desktop remove dsh-cortex
|
|
|
92
92
|
|
|
93
93
|
```powershell
|
|
94
94
|
powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
95
|
-
-Dsh "
|
|
95
|
+
-Dsh "D:\path\to\dsh.cmd" -Profile <profile>
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
脚本只删 `- id: cortex` 段,保留其他 patch,并跑一次 `--dump-config`;不删 dataRoot。已手动移除时也会跳过 remove、继续清 patch。
|
|
@@ -142,4 +142,3 @@ dsh --profile <profile> --dump-config > $null
|
|
|
142
142
|
- 零运行时 npm 依赖;SQLite 用 Node 内置。
|
|
143
143
|
- Windows 路径手写 `C:\...` 即可;包内没有 shell 脚本。
|
|
144
144
|
- 不修改全局 patch,不覆盖系统提示,不碰 shiori。
|
|
145
|
-
|
package/examples/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
```powershell
|
|
13
13
|
powershell -ExecutionPolicy Bypass -File .\examples\setup-cortex-bge.ps1 `
|
|
14
|
-
-Dsh "
|
|
14
|
+
-Dsh "D:\path\to\dsh.cmd" `
|
|
15
15
|
-Profile cortex-bge `
|
|
16
16
|
-Package "C:\path\to\dsh-cortex-memory-0.1.0.tgz"
|
|
17
17
|
```
|
|
@@ -58,7 +58,7 @@ dim: 1024
|
|
|
58
58
|
|
|
59
59
|
```powershell
|
|
60
60
|
powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
61
|
-
-Dsh "
|
|
61
|
+
-Dsh "D:\path\to\dsh.cmd" `
|
|
62
62
|
-Profile cortex-bge
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -70,4 +70,3 @@ powershell -ExecutionPolicy Bypass -File .\examples\uninstall-cortex.ps1 `
|
|
|
70
70
|
4. **不删 dataRoot**
|
|
71
71
|
|
|
72
72
|
如果已经手动移除,脚本会跳过 remove,仍清理残留 patch。
|
|
73
|
-
|
package/index.js
CHANGED
|
@@ -20,7 +20,7 @@ try {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const Config = Schema ? Schema.object({
|
|
23
|
-
dataRoot: Schema.string().description('Cortex 数据目录(默认 DSH_HOME/cortex
|
|
23
|
+
dataRoot: Schema.string().description('Cortex 数据目录(默认 DSH_HOME/cortex-memory;旧库由迁移脚本复制)'),
|
|
24
24
|
dbFile: Schema.string().description('SQLite 文件;默认 dataRoot/cortex.sqlite'),
|
|
25
25
|
scope: Schema.string().default('global').description('默认 scope'),
|
|
26
26
|
persona: Schema.object({
|
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -4,7 +4,7 @@ import { clamp } from './time.js';
|
|
|
4
4
|
import { profileDataRoot } from './profile.js';
|
|
5
5
|
|
|
6
6
|
const DSH_HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
|
|
7
|
-
const DEFAULT_ROOT = process.env.CORTEX_HOME || path.join(DSH_HOME, 'cortex');
|
|
7
|
+
const DEFAULT_ROOT = process.env.CORTEX_HOME || path.join(DSH_HOME, 'cortex-memory');
|
|
8
8
|
|
|
9
9
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
10
10
|
dataRoot: DEFAULT_ROOT,
|
|
@@ -25,7 +25,7 @@ export function readOverrides(dataRoot) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function loadFeatureOverrides(config = {}) {
|
|
28
|
-
const dataRoot = config.dataRoot ?? path.join(process.env.DSH_HOME || path.join(process.env.USERPROFILE || process.env.HOME || '.', '.dsh'), 'cortex');
|
|
28
|
+
const dataRoot = config.dataRoot ?? path.join(process.env.DSH_HOME || path.join(process.env.USERPROFILE || process.env.HOME || '.', '.dsh'), 'cortex-memory');
|
|
29
29
|
return readOverrides(dataRoot).current;
|
|
30
30
|
}
|
|
31
31
|
|
package/src/core/profile.js
CHANGED
|
@@ -26,7 +26,14 @@ export function detectProfileName({ argv = process.argv, env = process.env } = {
|
|
|
26
26
|
export function profileDataRoot({ argv = process.argv, env = process.env } = {}) {
|
|
27
27
|
const profile = detectProfileName({ argv, env });
|
|
28
28
|
const home = homeFromEnv(env);
|
|
29
|
-
//
|
|
29
|
+
// Keep the public bundle identity separate from legacy `cortex` data.
|
|
30
|
+
if (!profile || profile === 'desktop') return path.join(home, 'cortex-memory');
|
|
31
|
+
return path.join(home, 'cortex-memory', 'profiles', profile);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function legacyProfileDataRoot({ argv = process.argv, env = process.env } = {}) {
|
|
35
|
+
const profile = detectProfileName({ argv, env });
|
|
36
|
+
const home = homeFromEnv(env);
|
|
30
37
|
if (!profile || profile === 'desktop') return path.join(home, 'cortex');
|
|
31
38
|
return path.join(home, 'cortex', 'profiles', profile);
|
|
32
39
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { profileDataRoot, legacyProfileDataRoot } from '../../src/core/profile.js';
|
|
5
|
+
|
|
6
|
+
const home = 'C:/tmp/cortex-profile-test';
|
|
7
|
+
|
|
8
|
+
test('desktop data root is cortex-memory', () => {
|
|
9
|
+
const root = profileDataRoot({ argv: [], env: { DSH_HOME: home, DSH_PROFILE: 'desktop' } });
|
|
10
|
+
assert.equal(root, path.join(home, 'cortex-memory'));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('other profiles are isolated under cortex-memory/profiles', () => {
|
|
14
|
+
const root = profileDataRoot({ argv: [], env: { DSH_HOME: home, DSH_PROFILE: 'work' } });
|
|
15
|
+
assert.equal(root, path.join(home, 'cortex-memory', 'profiles', 'work'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('legacy data root remains readable for migration', () => {
|
|
19
|
+
const root = legacyProfileDataRoot({ argv: [], env: { DSH_HOME: home, DSH_PROFILE: 'desktop' } });
|
|
20
|
+
assert.equal(root, path.join(home, 'cortex'));
|
|
21
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from 'node:test';
|
|
2
2
|
import assert from 'node:assert/strict';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { detectProfileName, profileDataRoot } from '../../src/core/profile.js';
|
|
4
|
+
import { detectProfileName, profileDataRoot, legacyProfileDataRoot } from '../../src/core/profile.js';
|
|
5
5
|
|
|
6
6
|
test('detectProfileName reads --profile, --profile= and profile paths', () => {
|
|
7
7
|
assert.equal(detectProfileName({ argv: ['node', 'dsh', '--profile', 'cortex-clean'], env: {} }), 'cortex-clean');
|
|
@@ -12,9 +12,15 @@ test('detectProfileName reads --profile, --profile= and profile paths', () => {
|
|
|
12
12
|
assert.equal(detectProfileName({ argv: [], env: {} }), null);
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
test('profileDataRoot isolates non-desktop profiles
|
|
15
|
+
test('profileDataRoot isolates non-desktop profiles under the new cortex-memory root', () => {
|
|
16
16
|
const env = { DSH_HOME: 'C:\\dsh-home' };
|
|
17
|
-
assert.equal(profileDataRoot({ argv: ['dsh', '--profile', 'agent-a'], env }), path.join('C:\\dsh-home', 'cortex', 'profiles', 'agent-a'));
|
|
18
|
-
assert.equal(profileDataRoot({ argv: ['dsh', '--profile', 'desktop'], env }), path.join('C:\\dsh-home', 'cortex'));
|
|
19
|
-
assert.equal(profileDataRoot({ argv: [], env }), path.join('C:\\dsh-home', 'cortex'));
|
|
17
|
+
assert.equal(profileDataRoot({ argv: ['dsh', '--profile', 'agent-a'], env }), path.join('C:\\dsh-home', 'cortex-memory', 'profiles', 'agent-a'));
|
|
18
|
+
assert.equal(profileDataRoot({ argv: ['dsh', '--profile', 'desktop'], env }), path.join('C:\\dsh-home', 'cortex-memory'));
|
|
19
|
+
assert.equal(profileDataRoot({ argv: [], env }), path.join('C:\\dsh-home', 'cortex-memory'));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('legacyProfileDataRoot keeps the old cortex path for migration', () => {
|
|
23
|
+
const env = { DSH_HOME: 'C:\\dsh-home' };
|
|
24
|
+
assert.equal(legacyProfileDataRoot({ argv: ['dsh', '--profile', 'agent-a'], env }), path.join('C:\\dsh-home', 'cortex', 'profiles', 'agent-a'));
|
|
25
|
+
assert.equal(legacyProfileDataRoot({ argv: ['dsh', '--profile', 'desktop'], env }), path.join('C:\\dsh-home', 'cortex'));
|
|
20
26
|
});
|