dsh-cross-memory 0.0.0-stage → 0.2.1
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 -0
- package/README.md +253 -2
- package/cordis.patch.yml +27 -0
- package/docs/DETAIL.md +13 -0
- package/docs/DETAIL.zh.md +17 -0
- package/icon.svg +1 -0
- package/lib/backfill.js +273 -0
- package/lib/citations.js +305 -0
- package/lib/client.js +1660 -0
- package/lib/config.js +736 -0
- package/lib/consolidate.js +1119 -0
- package/lib/extract.js +570 -0
- package/lib/gate.js +137 -0
- package/lib/git-origin.js +224 -0
- package/lib/index.js +4482 -0
- package/lib/log.js +260 -0
- package/lib/loops.js +186 -0
- package/lib/notices.js +195 -0
- package/lib/notify.js +33 -0
- package/lib/persona.js +163 -0
- package/lib/query.js +93 -0
- package/lib/raw-recall.js +286 -0
- package/lib/reflection.js +291 -0
- package/lib/remote.js +490 -0
- package/lib/render.js +678 -0
- package/lib/retention.js +64 -0
- package/lib/schedule.js +245 -0
- package/lib/search.js +1068 -0
- package/lib/skills.js +220 -0
- package/lib/state.js +701 -0
- package/lib/storage.js +1424 -0
- package/lib/sync-runtime.js +268 -0
- package/lib/sync.js +620 -0
- package/lib/test/activity.test.js +74 -0
- package/lib/test/archive.test.js +182 -0
- package/lib/test/backfill.test.js +144 -0
- package/lib/test/citations.test.js +91 -0
- package/lib/test/client-wiring.test.js +134 -0
- package/lib/test/consolidate-job.test.js +95 -0
- package/lib/test/consolidate.test.js +430 -0
- package/lib/test/consolidation-selection.test.js +152 -0
- package/lib/test/dedupe-keys.test.js +230 -0
- package/lib/test/delta.test.js +93 -0
- package/lib/test/derived.test.js +110 -0
- package/lib/test/disputes-panel.test.js +341 -0
- package/lib/test/eval.test.js +171 -0
- package/lib/test/expand.test.js +164 -0
- package/lib/test/extract.test.js +1020 -0
- package/lib/test/git-origin.test.js +189 -0
- package/lib/test/injection.test.js +440 -0
- package/lib/test/kind-filter.test.js +49 -0
- package/lib/test/legacy-state.test.js +69 -0
- package/lib/test/log.test.js +156 -0
- package/lib/test/loops.test.js +86 -0
- package/lib/test/memory.test.js +855 -0
- package/lib/test/notices.test.js +142 -0
- package/lib/test/persona.test.js +86 -0
- package/lib/test/prefilter.test.js +73 -0
- package/lib/test/preset.test.js +77 -0
- package/lib/test/raw-recall.test.js +186 -0
- package/lib/test/recall.test.js +433 -0
- package/lib/test/reflection.test.js +64 -0
- package/lib/test/remote.test.js +238 -0
- package/lib/test/retention.test.js +117 -0
- package/lib/test/retrieval.test.js +142 -0
- package/lib/test/rotation.test.js +228 -0
- package/lib/test/schedule.test.js +112 -0
- package/lib/test/settings-card.test.js +58 -0
- package/lib/test/skills.test.js +129 -0
- package/lib/test/state.test.js +212 -0
- package/lib/test/subagent-contract.test.js +139 -0
- package/lib/test/sweep.test.js +159 -0
- package/lib/test/sync.test.js +314 -0
- package/lib/test/time.test.js +171 -0
- package/lib/time.js +303 -0
- package/lib/tool.js +330 -0
- package/lib/types/backfill.d.ts +96 -0
- package/lib/types/citations.d.ts +105 -0
- package/lib/types/config.d.ts +811 -0
- package/lib/types/consolidate.d.ts +742 -0
- package/lib/types/extract.d.ts +352 -0
- package/lib/types/gate.d.ts +83 -0
- package/lib/types/git-origin.d.ts +23 -0
- package/lib/types/index.d.ts +1316 -0
- package/lib/types/log.d.ts +144 -0
- package/lib/types/loops.d.ts +82 -0
- package/lib/types/notices.d.ts +117 -0
- package/lib/types/notify.d.ts +12 -0
- package/lib/types/persona.d.ts +76 -0
- package/lib/types/query.d.ts +45 -0
- package/lib/types/raw-recall.d.ts +84 -0
- package/lib/types/reflection.d.ts +122 -0
- package/lib/types/remote.d.ts +246 -0
- package/lib/types/render.d.ts +286 -0
- package/lib/types/retention.d.ts +66 -0
- package/lib/types/schedule.d.ts +116 -0
- package/lib/types/search.d.ts +583 -0
- package/lib/types/skills.d.ts +71 -0
- package/lib/types/state.d.ts +294 -0
- package/lib/types/storage.d.ts +458 -0
- package/lib/types/sync-runtime.d.ts +103 -0
- package/lib/types/sync.d.ts +222 -0
- package/lib/types/test/activity.test.d.ts +1 -0
- package/lib/types/test/archive.test.d.ts +1 -0
- package/lib/types/test/backfill.test.d.ts +1 -0
- package/lib/types/test/citations.test.d.ts +1 -0
- package/lib/types/test/client-wiring.test.d.ts +1 -0
- package/lib/types/test/consolidate-job.test.d.ts +1 -0
- package/lib/types/test/consolidate.test.d.ts +1 -0
- package/lib/types/test/consolidation-selection.test.d.ts +1 -0
- package/lib/types/test/dedupe-keys.test.d.ts +1 -0
- package/lib/types/test/delta.test.d.ts +1 -0
- package/lib/types/test/derived.test.d.ts +1 -0
- package/lib/types/test/disputes-panel.test.d.ts +1 -0
- package/lib/types/test/eval.test.d.ts +1 -0
- package/lib/types/test/expand.test.d.ts +1 -0
- package/lib/types/test/extract.test.d.ts +1 -0
- package/lib/types/test/git-origin.test.d.ts +1 -0
- package/lib/types/test/injection.test.d.ts +1 -0
- package/lib/types/test/kind-filter.test.d.ts +1 -0
- package/lib/types/test/legacy-state.test.d.ts +1 -0
- package/lib/types/test/log.test.d.ts +1 -0
- package/lib/types/test/loops.test.d.ts +1 -0
- package/lib/types/test/memory.test.d.ts +1 -0
- package/lib/types/test/notices.test.d.ts +1 -0
- package/lib/types/test/persona.test.d.ts +1 -0
- package/lib/types/test/prefilter.test.d.ts +1 -0
- package/lib/types/test/preset.test.d.ts +1 -0
- package/lib/types/test/raw-recall.test.d.ts +1 -0
- package/lib/types/test/recall.test.d.ts +1 -0
- package/lib/types/test/reflection.test.d.ts +1 -0
- package/lib/types/test/remote.test.d.ts +1 -0
- package/lib/types/test/retention.test.d.ts +1 -0
- package/lib/types/test/retrieval.test.d.ts +1 -0
- package/lib/types/test/rotation.test.d.ts +1 -0
- package/lib/types/test/schedule.test.d.ts +1 -0
- package/lib/types/test/settings-card.test.d.ts +1 -0
- package/lib/types/test/skills.test.d.ts +1 -0
- package/lib/types/test/state.test.d.ts +1 -0
- package/lib/types/test/subagent-contract.test.d.ts +1 -0
- package/lib/types/test/sweep.test.d.ts +1 -0
- package/lib/types/test/sync.test.d.ts +1 -0
- package/lib/types/test/time.test.d.ts +1 -0
- package/lib/types/time.d.ts +67 -0
- package/lib/types/tool.d.ts +9 -0
- package/lib/types/types.d.ts +374 -0
- package/lib/types/workspace.d.ts +20 -0
- package/lib/types.js +47 -0
- package/lib/workspace.js +65 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +126 -4
package/lib/config.js
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for `dsh-cross-memory`.
|
|
3
|
+
*
|
|
4
|
+
* One row config, two kinds of field, deliberately separated:
|
|
5
|
+
*
|
|
6
|
+
* - **Deployment** (`dshHome`, `memoriesDir`, `projectRootMarkers`, `logFile`):
|
|
7
|
+
* where the store lives and how a workspace root is identified. Composition
|
|
8
|
+
* facts; changing one means remounting the row.
|
|
9
|
+
* - **Tunables**: every behavioural knob, declared in {@link Config} with
|
|
10
|
+
* `.volatile()`. That marker is what makes a field live — the Loader hands it
|
|
11
|
+
* to `apply` as a reference rather than a value, the settings domain projects
|
|
12
|
+
* it into the browser, and a write from the Memories page updates the
|
|
13
|
+
* reference in place (announced as `loader/volatile-update`), so a knob takes
|
|
14
|
+
* effect without a restart or a reload. {@link MemoriesSettings} is the same
|
|
15
|
+
* field list as plain data, which is what the runtime reads.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-cross-memory/config
|
|
18
|
+
*/
|
|
19
|
+
import z from '@deepseek-ai/schemastery';
|
|
20
|
+
import { isVolatile } from '@deepseek-ai/cosmokit';
|
|
21
|
+
import { resolveDshHome } from '@deepseek-ai/dsh-home-paths';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join, resolve } from 'node:path';
|
|
24
|
+
import { logPath, toLogLevel } from './log.js';
|
|
25
|
+
/**
|
|
26
|
+
* Profile entry id owning this plugin, and therefore the key its tunables are
|
|
27
|
+
* addressed by: the Memories page and the Plugins-page configuration card both
|
|
28
|
+
* ask for this form as `ctx.configForms.get('memories')`, and a composition row
|
|
29
|
+
* in `cordis.patch.yml` overrides it under the same id.
|
|
30
|
+
*/
|
|
31
|
+
export const ENTRY_ID = 'memories';
|
|
32
|
+
/** Default child-name markers that identify a workspace root. */
|
|
33
|
+
export const DEFAULT_PROJECT_ROOT_MARKERS = ['.git'];
|
|
34
|
+
/** Default background sync interval, in minutes; used when no clock times are set. */
|
|
35
|
+
export const DEFAULT_SYNC_INTERVAL_MINUTES = 10;
|
|
36
|
+
/** Default clock times: just after DeepSeek off-peak pricing starts (12:00 and 18:00 local). */
|
|
37
|
+
export const DEFAULT_SYNC_CLOCK = '12:05,18:05';
|
|
38
|
+
/** Default debounce before a burst of memory writes becomes one commit, in seconds. */
|
|
39
|
+
export const DEFAULT_SYNC_DEBOUNCE_SECONDS = 2;
|
|
40
|
+
/** Default byte budget for the injected memory summary. */
|
|
41
|
+
export const DEFAULT_MAX_SUMMARY_BYTES = 4096;
|
|
42
|
+
/** Default cap on entries listed in the injected summary per scope. */
|
|
43
|
+
export const DEFAULT_MAX_SUMMARY_ENTRIES = 12;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a conversation is told about memories written after its summary.
|
|
46
|
+
*
|
|
47
|
+
* The summary is a snapshot from the first step of the conversation, so a
|
|
48
|
+
* memory extracted or consolidated ten turns later would otherwise stay
|
|
49
|
+
* invisible until the model thought to search for it. The delta block is
|
|
50
|
+
* bounded (two per conversation, 800 bytes each) and only names entries whose
|
|
51
|
+
* `updated` stamp is newer than the last injection, so it costs one short
|
|
52
|
+
* paragraph rather than a second summary.
|
|
53
|
+
*/
|
|
54
|
+
export const DEFAULT_INJECT_DELTA = true;
|
|
55
|
+
/**
|
|
56
|
+
* How many additional memories one conversation lists by title only.
|
|
57
|
+
*
|
|
58
|
+
* The summary can only name a dozen entries and reserves at most a third of its
|
|
59
|
+
* slots for never-surfaced material; measured on a real store at baseline that
|
|
60
|
+
* left 58.6% of live entries never injected or read. Sixteen titles cost about
|
|
61
|
+
* 1.6 KB and are enough to make the whole store discoverable over a couple of
|
|
62
|
+
* dozen sessions: each conversation rotates through the entries the summary did
|
|
63
|
+
* not have room for, oldest-unseen first. The global scope takes three quarters
|
|
64
|
+
* of the block, so a global library of 600 entries moves about 12 a session.
|
|
65
|
+
* 0 disables the rotation block.
|
|
66
|
+
*/
|
|
67
|
+
export const DEFAULT_ROTATION_ENTRIES = 16;
|
|
68
|
+
/**
|
|
69
|
+
* User turns between rotation blocks inside one long conversation.
|
|
70
|
+
*
|
|
71
|
+
* Once per conversation is not enough for a session that runs for hours: the
|
|
72
|
+
* store keeps growing and the model keeps needing names it has not seen yet.
|
|
73
|
+
* Re-arming the block every this many USER turns keeps the cost bounded (one
|
|
74
|
+
* ~1.6 KB block per span) and lets coverage accumulate within a single long
|
|
75
|
+
* session. 0 keeps the old once-per-conversation behaviour.
|
|
76
|
+
*/
|
|
77
|
+
export const DEFAULT_ROTATION_EVERY_TURNS = 8;
|
|
78
|
+
/** Byte budget for the title-only rotation block. */
|
|
79
|
+
export const DEFAULT_ROTATION_MAX_BYTES = 1600;
|
|
80
|
+
/**
|
|
81
|
+
* Default cap on the GLOBAL section's bullets, below {@link DEFAULT_MAX_SUMMARY_ENTRIES}.
|
|
82
|
+
*
|
|
83
|
+
* The two scopes share one byte budget and the global section renders first, so
|
|
84
|
+
* an uncapped global scope absorbs whatever the project scope leaves over.
|
|
85
|
+
* Measured on a real store: a two-memory project session spent 87% of its budget
|
|
86
|
+
* on global entries, and in every session the same six were unrelated to the
|
|
87
|
+
* workspace (a plugin's logger threshold, a sidebar adapter, a model catalog).
|
|
88
|
+
* Four keeps the portable half visible without letting it bury the scope that is
|
|
89
|
+
* actually about this conversation.
|
|
90
|
+
*/
|
|
91
|
+
export const DEFAULT_GLOBAL_SUMMARY_ENTRIES = 4;
|
|
92
|
+
/**
|
|
93
|
+
* Default byte budget for the global section alone, inside {@link DEFAULT_MAX_SUMMARY_BYTES}.
|
|
94
|
+
*
|
|
95
|
+
* A count cap is not enough. Chinese entries cost roughly three bytes per
|
|
96
|
+
* character, so four of them fill about 2.6 KB of a 4 KB block — measured on a
|
|
97
|
+
* real store the global half still took 45–81% of every session after the count
|
|
98
|
+
* cap was added. Reserving bytes is what actually leaves room for the scope that
|
|
99
|
+
* is about this conversation.
|
|
100
|
+
*
|
|
101
|
+
* 1200 is about a third of the content budget: the block's frame (intro and
|
|
102
|
+
* guidance) costs ~700 bytes of the 4096, so the two scopes divide ~3400, and a
|
|
103
|
+
* third to the half that every session shares leaves two thirds to the half that
|
|
104
|
+
* is actually about this workspace.
|
|
105
|
+
*/
|
|
106
|
+
export const DEFAULT_GLOBAL_SUMMARY_BYTES = 1200;
|
|
107
|
+
/**
|
|
108
|
+
* Default number of those entries reserved for memories never listed before.
|
|
109
|
+
*
|
|
110
|
+
* Three, because the reservation is a queue that drains: once an entry has been
|
|
111
|
+
* listed it leaves the pool, and unused slots fall back to the ranking, so the
|
|
112
|
+
* steady-state cost is one slot per newly written memory. It only ever costs
|
|
113
|
+
* more than that while there is a backlog of never-listed memories — which is
|
|
114
|
+
* exactly when showing them matters. Measured on a real store, two slots pushed
|
|
115
|
+
* the correction of an already-listed memory to the *next* session and three
|
|
116
|
+
* showed both in the first one. `0` restores pure ranking, which on a saturated
|
|
117
|
+
* scope is a fixed point that never shows anything new.
|
|
118
|
+
*/
|
|
119
|
+
export const DEFAULT_SUMMARY_FRESH_SLOTS = 3;
|
|
120
|
+
/**
|
|
121
|
+
* Default cap on stored entries per scope before the least recently used are evicted.
|
|
122
|
+
*
|
|
123
|
+
* 1000 rather than 200 as of 2026-10-24, after the recall path got an inverted
|
|
124
|
+
* index (`prefilterEntries`): measured on this machine, 1000 entries cost 63 ms
|
|
125
|
+
* per turn scanning everything and 25 ms through the index, and the index falls
|
|
126
|
+
* back to a full scan when it would leave too few candidates to be trusted.
|
|
127
|
+
* `scripts/recall-bench.mjs` is the probe that decided it; re-run it before
|
|
128
|
+
* raising this again.
|
|
129
|
+
*/
|
|
130
|
+
export const DEFAULT_MAX_ENTRIES_PER_SCOPE = 1000;
|
|
131
|
+
/** Default hours between periodic maintenance sweeps; `0` disables the sweep. */
|
|
132
|
+
export const DEFAULT_SWEEP_INTERVAL_HOURS = 12;
|
|
133
|
+
/** Default days an unused memory survives before it is archived; `0` disables archival. */
|
|
134
|
+
export const DEFAULT_MAX_UNUSED_DAYS = 90;
|
|
135
|
+
/**
|
|
136
|
+
* Default days a `snapshot` memory survives before it is archived; `0` disables.
|
|
137
|
+
*
|
|
138
|
+
* A reading taken at one moment is wrong from the day after it was taken, and
|
|
139
|
+
* reading it does not make it right, so it cannot be judged by the unused clock
|
|
140
|
+
* that a convention is judged by. Sixty days is long enough to be useful as
|
|
141
|
+
* history and short enough that a stale number stops being quoted.
|
|
142
|
+
*/
|
|
143
|
+
export const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 60;
|
|
144
|
+
/** Default share of title/body tokens two memories must have in common to be merged. */
|
|
145
|
+
export const DEFAULT_DEDUPE_SIMILARITY = 0.7;
|
|
146
|
+
/** Default recall mode: how much of a conversation pays for cross-session memory. */
|
|
147
|
+
export const DEFAULT_RECALL_MODE = 'on-demand';
|
|
148
|
+
/**
|
|
149
|
+
* Default minimum relevance a recall delta must reach.
|
|
150
|
+
*
|
|
151
|
+
* 20 was the old value and it silently disabled Chinese recall: a Chinese
|
|
152
|
+
* paraphrase that shares two bigrams with a title scores around 9-12, so nothing
|
|
153
|
+
* ever cleared it. The floor is now a strictness knob, and the PRECISION lives in
|
|
154
|
+
* `recallMinTerms` — the structural evidence gate, which a score threshold cannot
|
|
155
|
+
* replace. 9 is just above one shared bigram in a title (8) so that a single
|
|
156
|
+
* common word is never sufficient on its own.
|
|
157
|
+
*/
|
|
158
|
+
export const DEFAULT_RECALL_MIN_SCORE = 9;
|
|
159
|
+
/** Default cap on recall deltas injected into one conversation. */
|
|
160
|
+
export const DEFAULT_RECALL_MAX_PER_CONVERSATION = 4;
|
|
161
|
+
/**
|
|
162
|
+
* Default byte budget for one recall delta block.
|
|
163
|
+
*
|
|
164
|
+
* Sized for the several short entries a single turn can legitimately match, not
|
|
165
|
+
* for one: the frame and the preamble cost roughly 250 bytes, and a one-line
|
|
166
|
+
* entry costs about 90. At 800 a two-entry block would not fit, which is why
|
|
167
|
+
* this is not 400 as it was when a delta could only ever hold one memory.
|
|
168
|
+
*/
|
|
169
|
+
export const DEFAULT_RECALL_MAX_BYTES = 1_200;
|
|
170
|
+
/** Default minimum length of a user turn worth a recall decision. */
|
|
171
|
+
export const DEFAULT_RECALL_MIN_QUERY_CHARS = 2;
|
|
172
|
+
/**
|
|
173
|
+
* Whether a recall block may also carry original conversation excerpts.
|
|
174
|
+
*
|
|
175
|
+
* Off by default: this injects prose from *other* sessions, which is a privacy
|
|
176
|
+
* step beyond recalling a memory summary, so it is opt-in.
|
|
177
|
+
*/
|
|
178
|
+
export const DEFAULT_RAW_RECALL = false;
|
|
179
|
+
/** Byte budget for the raw excerpt half of one recall block. */
|
|
180
|
+
export const DEFAULT_RAW_RECALL_BYTES = 2_400;
|
|
181
|
+
/** Most raw excerpts one recall block may carry. */
|
|
182
|
+
export const DEFAULT_RAW_RECALL_EXCERPTS = 3;
|
|
183
|
+
/**
|
|
184
|
+
* Default number of distinct strong-field terms a recall needs.
|
|
185
|
+
*
|
|
186
|
+
* Two is what makes a paraphrased question reachable without letting a shared
|
|
187
|
+
* common word in: "这个插件的日志在哪里" shares 插件 and 日志 with a memory titled
|
|
188
|
+
* "插件日志的查看方式" (two terms, credited), while "该插件是否有日志" shares only
|
|
189
|
+
* 插件 with a title about plugin registration order (one term, not credited).
|
|
190
|
+
*/
|
|
191
|
+
export const DEFAULT_RECALL_MIN_TERMS = 2;
|
|
192
|
+
/**
|
|
193
|
+
* Every valid recall mode.
|
|
194
|
+
*
|
|
195
|
+
* `once` is the original behaviour (one bounded summary per conversation, every
|
|
196
|
+
* later recall through the tool); `on-demand` additionally injects a small delta
|
|
197
|
+
* when the current turn clearly matches a stored memory; `off` leaves only the
|
|
198
|
+
* tool. The mode decides what a conversation pays for, so it is a user knob.
|
|
199
|
+
*/
|
|
200
|
+
export const RECALL_MODES = ['once', 'on-demand', 'off'];
|
|
201
|
+
/** Narrow an unknown value to a recall mode, defaulting to `on-demand`. */
|
|
202
|
+
export function toRecallMode(value) {
|
|
203
|
+
return typeof value === 'string' && RECALL_MODES.includes(value)
|
|
204
|
+
? value
|
|
205
|
+
: DEFAULT_RECALL_MODE;
|
|
206
|
+
}
|
|
207
|
+
/** Default idle delay before a finished session is mined for memories. */
|
|
208
|
+
export const DEFAULT_AUTO_EXTRACT_IDLE_MS = 300_000;
|
|
209
|
+
/** Default number of surface messages handed to the extractor. */
|
|
210
|
+
export const DEFAULT_EXTRACT_WINDOW_MESSAGES = 60;
|
|
211
|
+
/** Default character budget for the extraction transcript. */
|
|
212
|
+
export const DEFAULT_EXTRACT_MAX_INPUT_CHARS = 48_000;
|
|
213
|
+
/**
|
|
214
|
+
* Default minutes between periodic extraction checks; `0` disables them.
|
|
215
|
+
*
|
|
216
|
+
* A settle-only pass mines a session once, after it has been quiet for the whole
|
|
217
|
+
* quiet window, and reads only the newest slice of it — so a long working session
|
|
218
|
+
* loses everything before that slice for good, because the watermark moves past
|
|
219
|
+
* it. A periodic check mines in slices as the session runs, which is also why the
|
|
220
|
+
* window above is sized for one interval rather than for a whole conversation.
|
|
221
|
+
*/
|
|
222
|
+
export const DEFAULT_EXTRACT_INTERVAL_MINUTES = 30;
|
|
223
|
+
/**
|
|
224
|
+
* Default output-token cap for one extraction call.
|
|
225
|
+
*
|
|
226
|
+
* Raised from 2048 to 4096 on 2026-09-23: asked for up to five memories with
|
|
227
|
+
* tags, keys, `appliesTo` and a summary paragraph in Chinese, a rich reply runs
|
|
228
|
+
* past 2048 tokens, and the first real `/memories mine` in the field came back
|
|
229
|
+
* cut in half (`max-tokens`).
|
|
230
|
+
*
|
|
231
|
+
* Raised again to 8192 on 2026-09-24, because the measured cause was not reply
|
|
232
|
+
* length. A background extraction call inherits the session's route, reasoning
|
|
233
|
+
* level included, and a thinking model bills its reasoning against this same
|
|
234
|
+
* ceiling — so the cap can be spent before the first visible token. The store's
|
|
235
|
+
* own log recorded five calls that came back pinned to the cap with nothing
|
|
236
|
+
* usable (`[5766 in / 4096 out]` … `[24490 in / 4096 out]`), four of them on
|
|
237
|
+
* `deepseek-flash` at `reasoningEffort: high` and one on `gpt-6-astra`; raising
|
|
238
|
+
* the ceiling without the `memories`-first reply order would only have moved the
|
|
239
|
+
* cliff. The cap is still a ceiling rather than a spend, so replies that finish
|
|
240
|
+
* early cost exactly as much as before.
|
|
241
|
+
*/
|
|
242
|
+
export const DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS = 8192;
|
|
243
|
+
/** Default timeout for one extraction call. */
|
|
244
|
+
export const DEFAULT_EXTRACT_TIMEOUT_MS = 120_000;
|
|
245
|
+
/** Default max drafts one extraction may produce. */
|
|
246
|
+
export const DEFAULT_EXTRACT_MAX_MEMORIES = 5;
|
|
247
|
+
/** Default idle hours a session must accumulate before it is mined. */
|
|
248
|
+
export const DEFAULT_MIN_IDLE_HOURS = 6;
|
|
249
|
+
/** Default age limit: sessions idle longer than this are never mined. */
|
|
250
|
+
export const DEFAULT_MAX_AGE_DAYS = 10;
|
|
251
|
+
/** Default cap on sessions mined per pass. */
|
|
252
|
+
export const DEFAULT_MAX_SESSIONS_PER_PASS = 2;
|
|
253
|
+
/** Default hours between consolidation passes. */
|
|
254
|
+
export const DEFAULT_CONSOLIDATE_COOLDOWN_HOURS = 6;
|
|
255
|
+
/**
|
|
256
|
+
* Default hours a consolidation proposal waits for a decision before a new pass
|
|
257
|
+
* may replace it.
|
|
258
|
+
*
|
|
259
|
+
* A proposal is a question, and questions go stale: entries keep being written
|
|
260
|
+
* while it waits, so an old proposal describes a store that no longer exists.
|
|
261
|
+
* Inside this window a running pass leaves the pending one alone — proposing
|
|
262
|
+
* again would spend a model call to overwrite a question nobody has answered —
|
|
263
|
+
* and past it the fresh proposal wins. `/memories consolidate` ignores the
|
|
264
|
+
* window, because a user who types the command is asking now.
|
|
265
|
+
*/
|
|
266
|
+
export const DEFAULT_CONSOLIDATE_PROPOSAL_MAX_AGE_HOURS = 72;
|
|
267
|
+
/** Default cap on entries one consolidation pass considers. */
|
|
268
|
+
export const DEFAULT_CONSOLIDATE_MAX_ENTRIES = 64;
|
|
269
|
+
/** Default timeout for one consolidation sub-agent run. */
|
|
270
|
+
export const DEFAULT_CONSOLIDATE_TIMEOUT_MS = 180_000;
|
|
271
|
+
/** Default wait after a provider refuses a background pass for quota or rate. */
|
|
272
|
+
export const DEFAULT_QUOTA_COOLDOWN_MINUTES = 30;
|
|
273
|
+
/** Default ceiling for that wait as consecutive refusals double it. */
|
|
274
|
+
export const DEFAULT_QUOTA_COOLDOWN_MAX_MINUTES = 480;
|
|
275
|
+
/** Default verbosity of the plugin's own log file. */
|
|
276
|
+
export const DEFAULT_LOG_LEVEL = 'info';
|
|
277
|
+
/** Default for logging every maintenance decision rather than only pass summaries. */
|
|
278
|
+
export const DEFAULT_TRACE_MAINTENANCE = false;
|
|
279
|
+
/**
|
|
280
|
+
* Share of a scope above which a query term stops being recall evidence.
|
|
281
|
+
*
|
|
282
|
+
* Measured on the real 200-entry global scope: `dsh` sits in 44 of 200 strong
|
|
283
|
+
* fields (22%), `mac` in 24 (12%), then a long tail below 11%. At 0.15 exactly
|
|
284
|
+
* one term qualifies — the one the README singles out — and the effect is
|
|
285
|
+
* large and one-sided: the turn "dsh 插件 配置" admits 37 memories without the
|
|
286
|
+
* discount and 9 with it, "dsh 版本" 35 → 4, while "插件 内核 版本" and
|
|
287
|
+
* "mac 代理 端口" are unchanged and all ten labelled retrieval probes keep their
|
|
288
|
+
* gate verdict.
|
|
289
|
+
*/
|
|
290
|
+
export const DEFAULT_EVIDENCE_MAX_DF = 0.15;
|
|
291
|
+
/**
|
|
292
|
+
* Default peak-hours spec: none.
|
|
293
|
+
*
|
|
294
|
+
* Deliberately empty rather than pre-filled with one provider's timetable: this
|
|
295
|
+
* plugin can run on any route, and silently refusing to work at certain hours
|
|
296
|
+
* would be a surprising default. The description names a value that suits
|
|
297
|
+
* DeepSeek.
|
|
298
|
+
*/
|
|
299
|
+
export const DEFAULT_PEAK_HOURS = '';
|
|
300
|
+
/**
|
|
301
|
+
* This plugin's entry config: the deployment facts plus every tunable.
|
|
302
|
+
*
|
|
303
|
+
* The tunables are live — declared `.volatile()`, which is what the settings
|
|
304
|
+
* domain projects into the Memories page and what makes the Loader hand them to
|
|
305
|
+
* `apply` as references rather than values, so a committed write reaches the
|
|
306
|
+
* running plugin in place. The deployment fields stay ordinary: changing a path
|
|
307
|
+
* is a remount, not a knob.
|
|
308
|
+
*/
|
|
309
|
+
export const Config = z.object({
|
|
310
|
+
/** Harness home; defaults to `$DSH_HOME` (or `~/.dsh`). */
|
|
311
|
+
dshHome: z.string(),
|
|
312
|
+
/** Directory holding every memory store; defaults to `<dshHome>/memories`. */
|
|
313
|
+
memoriesDir: z.string(),
|
|
314
|
+
/** Child names that mark a workspace root during the upward walk. */
|
|
315
|
+
projectRootMarkers: z.array(z.string()).default([...DEFAULT_PROJECT_ROOT_MARKERS]),
|
|
316
|
+
/** Plugin log file; defaults to `<dshHome>/logs/dsh-cross-memory.log`. Empty disables file logging. */
|
|
317
|
+
logFile: z.string(),
|
|
318
|
+
/** Git remote the memory store syncs through; empty keeps the repository local-only. */
|
|
319
|
+
syncConflictProvider: z.string().default('').description('Provider used to merge two conflicting revisions of the same memory. Empty falls back to the extraction route; when neither is configured the newer revision wins and the older one stays in git history.').volatile(),
|
|
320
|
+
syncConflictModel: z.string().default('').description('Model used to merge two conflicting revisions of the same memory. Empty falls back to the extraction model.').volatile(),
|
|
321
|
+
syncRemote: z.string().default('').description('Git remote the memory store pushes to and pulls from. Empty leaves the store a local repository: writes are still committed, nothing leaves the machine. Point it at one private repository shared by every machine you use, e.g. git@github.com:<you>/dsh-cross-memory-store.git.').volatile(),
|
|
322
|
+
/** Local clock times to sync at, e.g. `12:05,18:05`; wins over the interval. */
|
|
323
|
+
syncClock: z.string().default(DEFAULT_SYNC_CLOCK).description('Local clock times (HH:MM, comma separated) at which the store syncs. Defaults to 12:05 and 18:05 — a few minutes after DeepSeek off-peak pricing starts, when a conflict merge is cheapest. Empty falls back to syncIntervalMinutes.').volatile(),
|
|
324
|
+
/** Background sync interval in minutes; 0 disables the timer. */
|
|
325
|
+
syncIntervalMinutes: z.number().default(DEFAULT_SYNC_INTERVAL_MINUTES).description('How often the store fetches, rebases and pushes in the background. 0 keeps the repository but stops the timer, so only a manual sync moves it.').volatile(),
|
|
326
|
+
/** Debounce before a memory write is committed locally. */
|
|
327
|
+
syncDebounceSeconds: z.number().default(DEFAULT_SYNC_DEBOUNCE_SECONDS).description('How long a burst of memory writes is folded into one commit. The commit is local and cheap; the network never runs on the write path.').volatile(),
|
|
328
|
+
/** Byte budget for the injected summary. `0` disables injection. */
|
|
329
|
+
maxSummaryBytes: z.number().default(DEFAULT_MAX_SUMMARY_BYTES).description('Byte budget for the memory summary injected once per conversation. 0 disables injection and leaves only the memory tool.').volatile(),
|
|
330
|
+
/** Max entries listed per scope in the injected summary. */
|
|
331
|
+
maxSummaryEntries: z.number().default(DEFAULT_MAX_SUMMARY_ENTRIES).description('How many memories each scope lists in the injected summary.').volatile(),
|
|
332
|
+
/** Max entries listed for the global scope, which every session shares. */
|
|
333
|
+
globalSummaryEntries: z.number().default(DEFAULT_GLOBAL_SUMMARY_ENTRIES).description('How many memories the GLOBAL section may list, capped below maxSummaryEntries. Both scopes share one byte budget and global renders first, so without this the global half grows to fill whatever the project half leaves (measured: 87% of a small project\'s summary). 0 removes the global section entirely.').volatile(),
|
|
334
|
+
/** Byte budget for the global section alone. */
|
|
335
|
+
globalSummaryBytes: z.number().default(DEFAULT_GLOBAL_SUMMARY_BYTES).description('Byte budget for the GLOBAL section, inside maxSummaryBytes. A count cap is not enough because Chinese entries are ~3 bytes per character: four of them still filled 60% of a 4 KB block. 0 removes the global section entirely.').volatile(),
|
|
336
|
+
/** How many of those entries are reserved for never-listed memories. */
|
|
337
|
+
summaryFreshSlots: z.number().default(DEFAULT_SUMMARY_FRESH_SLOTS).description('How many of each scope\'s summary entries are reserved for memories that have never been listed before, preferring ones written deliberately over extracted ones. 0 leaves selection to the ranking alone, which on a full scope never shows anything new.').volatile(),
|
|
338
|
+
/** How the injected summary is refreshed as the conversation moves on. */
|
|
339
|
+
recallMode: z.string().default(DEFAULT_RECALL_MODE).description('once injects the summary once per conversation; on-demand also injects a small delta when the current turn clearly matches a memory; off disables injection and leaves only the memory tool.').volatile(),
|
|
340
|
+
/** Minimum relevance a recall delta must reach. */
|
|
341
|
+
recallMinScore: z.number().default(DEFAULT_RECALL_MIN_SCORE).description('Minimum relevance a memory must reach before it is injected as a recall delta. A strictness knob, not the precision gate: recallMinTerms is what keeps generic overlap out. Raise it to demand a stronger lexical match.').volatile(),
|
|
342
|
+
/** Cap on recall deltas injected into one conversation. */
|
|
343
|
+
recallMaxPerConversation: z.number().default(DEFAULT_RECALL_MAX_PER_CONVERSATION).description('Maximum recall deltas injected into one conversation, counted per memory. 0 disables them.').volatile(),
|
|
344
|
+
/** Byte budget for one recall delta block. */
|
|
345
|
+
recallMaxBytes: z.number().default(DEFAULT_RECALL_MAX_BYTES).description('Byte budget for one on-demand recall block. 0 disables recall deltas.').volatile(),
|
|
346
|
+
rawRecall: z.boolean().default(DEFAULT_RAW_RECALL).description('Also put original conversation excerpts from the memory source sessions into the on-demand recall block. Off by default: it injects prose from earlier sessions, and it is read from the persisted session logs on this machine only.').volatile(),
|
|
347
|
+
rawRecallBytes: z.number().default(DEFAULT_RAW_RECALL_BYTES).description('Byte budget for the original-excerpt half of one recall block.').volatile(),
|
|
348
|
+
rawRecallExcerpts: z.number().default(DEFAULT_RAW_RECALL_EXCERPTS).description('Most original conversation excerpts one recall block may carry.').volatile(),
|
|
349
|
+
/** Shortest user turn worth a recall decision. */
|
|
350
|
+
recallMinQueryChars: z.number().default(DEFAULT_RECALL_MIN_QUERY_CHARS).description('Shortest user turn, in characters, that may trigger a recall delta. Short acknowledgements are skipped instead of scanning the store.').volatile(),
|
|
351
|
+
/** Distinct strong-field terms a recall needs before it is credited. */
|
|
352
|
+
recallMinTerms: z.number().default(DEFAULT_RECALL_MIN_TERMS).description('Distinct query terms that must land in the title, keys, tags, or appliesTo before a memory may be recalled on demand. This is what keeps a Chinese turn from recalling every memory that shares a common word like 插件 or 日志. 1 makes the relevance floor the only gate, which is noticeably noisier for Chinese; 0 disables the check.').volatile(),
|
|
353
|
+
/**
|
|
354
|
+
* Whether memories written after the summary was injected get a small delta.
|
|
355
|
+
*
|
|
356
|
+
* Off leaves the once-per-conversation summary as the only automatic block;
|
|
357
|
+
* the `memory` tool and the on-demand recall path still work.
|
|
358
|
+
*/
|
|
359
|
+
injectDelta: z.boolean().default(DEFAULT_INJECT_DELTA).description('Inject a small block when memories are written after the summary was already shown (at most twice per conversation). Off keeps the summary as the only automatic block.').volatile(),
|
|
360
|
+
/**
|
|
361
|
+
* How many extra memories one conversation lists by title only.
|
|
362
|
+
*
|
|
363
|
+
* The summary names at most a dozen entries, so most of a large store is never
|
|
364
|
+
* seen. The rotation block spends about a kilobyte on titles the summary had
|
|
365
|
+
* no room for, oldest-unseen first, so the whole store becomes discoverable
|
|
366
|
+
* over a few dozen sessions. 0 disables it.
|
|
367
|
+
*/
|
|
368
|
+
rotationEntries: z.number().default(DEFAULT_ROTATION_ENTRIES).description('List this many additional memory titles (not bodies) in each conversation, rotating through the entries the summary did not name, oldest-unseen first. 0 disables the rotation block.').volatile(),
|
|
369
|
+
/**
|
|
370
|
+
* User turns between rotation blocks inside one long conversation.
|
|
371
|
+
*
|
|
372
|
+
* A session that runs for hours outlives its first block: the store grows and
|
|
373
|
+
* the model needs names it has not seen. Re-arming every this many turns keeps
|
|
374
|
+
* the cost bounded (one block per span) and lets coverage accumulate within a
|
|
375
|
+
* single long session. 0 keeps once-per-conversation.
|
|
376
|
+
*/
|
|
377
|
+
rotationEveryTurns: z.number().default(DEFAULT_ROTATION_EVERY_TURNS).description('Inside one conversation, emit a fresh rotation block every this many user turns (0 keeps the old once-per-conversation behaviour).').volatile(),
|
|
378
|
+
/** Max stored entries per scope; the least-recently-updated are evicted. */
|
|
379
|
+
maxEntriesPerScope: z.number().default(DEFAULT_MAX_ENTRIES_PER_SCOPE).description('Stored memories per scope; past this cap the least recently used are deleted.').volatile(),
|
|
380
|
+
/** Days an unused memory survives before it is archived. `0` disables archival. */
|
|
381
|
+
maxUnusedDays: z.number().default(DEFAULT_MAX_UNUSED_DAYS).description('Days an unused memory survives before it is archived. Archived entries are recoverable with /memories restore. 0 disables archival.').volatile(),
|
|
382
|
+
/** Days a snapshot memory survives regardless of use. `0` disables. */
|
|
383
|
+
snapshotMaxAgeDays: z.number().default(DEFAULT_SNAPSHOT_MAX_AGE_DAYS).description('Days a memory marked durability=snapshot survives before it is archived, counted from when it was measured rather than from when it was last read. A stale number is worse than no number, and being read does not make it right. 0 disables snapshot expiry.').volatile(),
|
|
384
|
+
/** Token overlap above which a new memory supersedes an existing one. */
|
|
385
|
+
dedupeSimilarity: z.number().default(DEFAULT_DEDUPE_SIMILARITY).description('Share of title and body tokens two memories must have in common before the newer one supersedes the older. 0 keeps only the exact-match rule.').volatile(),
|
|
386
|
+
/** Hours between periodic maintenance sweeps. `0` disables the sweep. */
|
|
387
|
+
sweepIntervalHours: z.number().default(DEFAULT_SWEEP_INTERVAL_HOURS).description('Hours between periodic maintenance sweeps, which apply retention across every known workspace. 0 disables the sweep.').volatile(),
|
|
388
|
+
/** Whether the idle-time background extractor runs at all. */
|
|
389
|
+
autoExtract: z.boolean().default(true).description('Mine finished sessions for durable facts after they have been idle.').volatile(),
|
|
390
|
+
/** Idle milliseconds before a session is mined. */
|
|
391
|
+
autoExtractIdleMs: z.number().default(DEFAULT_AUTO_EXTRACT_IDLE_MS).description('How long a session must stay idle before it is mined.').volatile(),
|
|
392
|
+
/** Surface messages included in one extraction window. */
|
|
393
|
+
extractWindowMessages: z.number().default(DEFAULT_EXTRACT_WINDOW_MESSAGES).description('How many recent conversation messages one extraction reads.').volatile(),
|
|
394
|
+
/** Character budget for the extraction transcript. */
|
|
395
|
+
extractMaxInputChars: z.number().default(DEFAULT_EXTRACT_MAX_INPUT_CHARS).description('Character budget for the transcript handed to the extractor.').volatile(),
|
|
396
|
+
/** Output-token cap for one extraction call. */
|
|
397
|
+
extractMaxOutputTokens: z.number().default(DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS).description('Output token cap for one extraction call.').volatile(),
|
|
398
|
+
/** Timeout for one extraction call. */
|
|
399
|
+
extractTimeoutMs: z.number().default(DEFAULT_EXTRACT_TIMEOUT_MS).description('Timeout for one extraction call.').volatile(),
|
|
400
|
+
/** Max drafts one extraction may produce. */
|
|
401
|
+
extractMaxMemories: z.number().default(DEFAULT_EXTRACT_MAX_MEMORIES).description('Maximum memories one extraction pass may store.').volatile(),
|
|
402
|
+
/** Minutes between periodic extraction checks over every open session. */
|
|
403
|
+
extractIntervalMinutes: z.number().default(DEFAULT_EXTRACT_INTERVAL_MINUTES).description('How often to check every open session for new material and mine it in slices. Fractions are allowed. 0 disables the periodic check, leaving mining to the settle timer and the exit flush. Peak hours and the quota gate still apply; a session with nothing new costs no model call.').volatile(),
|
|
404
|
+
/** A session must have been idle this long before it is mined. */
|
|
405
|
+
minIdleHours: z.number().default(DEFAULT_MIN_IDLE_HOURS).description('A session must have been idle at least this many hours before it is mined.').volatile(),
|
|
406
|
+
/** Sessions older than this are never mined. */
|
|
407
|
+
maxAgeDays: z.number().default(DEFAULT_MAX_AGE_DAYS).description('Sessions whose last activity is older than this are never mined.').volatile(),
|
|
408
|
+
/** Sessions mined per pass; bounds one pass\'s quota cost. */
|
|
409
|
+
maxSessionsPerPass: z.number().default(DEFAULT_MAX_SESSIONS_PER_PASS).description('How many sessions one extraction pass may mine, newest first.').volatile(),
|
|
410
|
+
consolidate: z.boolean().default(true).description('After new memories land, merge and reconcile them through a restricted sub-agent.').volatile(),
|
|
411
|
+
consolidateCooldownHours: z.number().default(DEFAULT_CONSOLIDATE_COOLDOWN_HOURS).description('Minimum hours between consolidation passes; bounds background quota use.').volatile(),
|
|
412
|
+
consolidateProposalMaxAgeHours: z.number().default(DEFAULT_CONSOLIDATE_PROPOSAL_MAX_AGE_HOURS).description('Hours a staged consolidation proposal waits for /memories apply or reject before a later pass may replace it with a fresh one. Inside the window a background pass leaves the pending question alone (proposing again would spend a model call to overwrite it); /memories consolidate always proposes now. 0 keeps a proposal until it is answered.').volatile(),
|
|
413
|
+
consolidateMaxEntries: z.number().default(DEFAULT_CONSOLIDATE_MAX_ENTRIES).description('How many memories one consolidation pass may consider.').volatile(),
|
|
414
|
+
consolidateTimeoutMs: z.number().default(DEFAULT_CONSOLIDATE_TIMEOUT_MS).description('Timeout for one consolidation sub-agent run.').volatile(),
|
|
415
|
+
/** Stop background passes while the provider is refusing for quota or rate. */
|
|
416
|
+
pauseOnQuotaError: z.boolean().default(true).description('Stop background extraction and consolidation after a rate-limit or exhausted-quota error, until the cooldown elapses.').volatile(),
|
|
417
|
+
/** Wait after the first such refusal; doubles per consecutive refusal. */
|
|
418
|
+
quotaCooldownMinutes: z.number().default(DEFAULT_QUOTA_COOLDOWN_MINUTES).description('Minutes to wait after a rate-limit or quota refusal. Doubles per consecutive refusal.').volatile(),
|
|
419
|
+
/** Ceiling for that doubling. */
|
|
420
|
+
quotaCooldownMaxMinutes: z.number().default(DEFAULT_QUOTA_COOLDOWN_MAX_MINUTES).description('Upper bound for the quota cooldown.').volatile(),
|
|
421
|
+
/** Explicit extraction provider route; empty reuses the session route. */
|
|
422
|
+
extractProvider: z.string().default('').description("Provider route for extraction. Empty reuses the session's own logged route.").volatile(),
|
|
423
|
+
/** Explicit extraction model; empty reuses the session route. */
|
|
424
|
+
extractModel: z.string().default('').description("Model for extraction. Empty reuses the session's own logged route.").volatile(),
|
|
425
|
+
/**
|
|
426
|
+
* Whether an AI may decide the consolidation questions that used to wait for a person.
|
|
427
|
+
*
|
|
428
|
+
* Every merge used to stop at the human panel as soon as an entry had been read
|
|
429
|
+
* once, which on a real store meant all nine proposals waited — and the panel is
|
|
430
|
+
* where automation can be added safely, because the alternative to a decision is
|
|
431
|
+
* not "safer", it is "nothing ever happens".
|
|
432
|
+
*/
|
|
433
|
+
autoDecide: z.boolean().default(true).description('Let an AI adjudicate the consolidation changes that would otherwise wait for you: it is asked only whether the change loses information, and answers accept or reject with a confidence. Permanent and user-written memories still wait for you. Off sends everything to the 待裁决 panel.').volatile(),
|
|
434
|
+
/** Confidence floor under which an AI verdict is treated as "no answer". */
|
|
435
|
+
autoDecideMinConfidence: z.number().default(0.7).description('Below this confidence an AI adjudication is ignored and the item stays in 待裁决. 0 accepts every verdict; 1 accepts none unless certain.').volatile(),
|
|
436
|
+
/** Explicit consolidation provider route; empty falls back to the extraction route. */
|
|
437
|
+
consolidateProvider: z.string().default('').description('Provider route for consolidation. Empty falls back to the extraction route, then the session route.').volatile(),
|
|
438
|
+
/** Explicit consolidation model; empty falls back to the extraction route. */
|
|
439
|
+
consolidateModel: z.string().default('').description('Model for consolidation. Empty falls back to the extraction route, then the session route.').volatile(),
|
|
440
|
+
/** Whether the `memory` tool is registered for the model. */
|
|
441
|
+
enableTool: z.boolean().default(true).description('Register the model-facing memory tool.').volatile(),
|
|
442
|
+
/** Whether `/memories` is registered. */
|
|
443
|
+
enableCommand: z.boolean().default(true).description('Register the /memories slash command.').volatile(),
|
|
444
|
+
/** How much this plugin records in its own log file. */
|
|
445
|
+
logLevel: z.string().default(DEFAULT_LOG_LEVEL).description('How much dsh-cross-memory writes to its log file: off, error, warn, info, or debug. info keeps errors, warnings, and pass summaries; debug adds per-entry decisions.').volatile(),
|
|
446
|
+
/** Whether maintenance decisions are logged at info, where a stock logLevel keeps them. */
|
|
447
|
+
traceMaintenance: z.boolean().default(DEFAULT_TRACE_MAINTENANCE).description('Log every retention, recall, and selection decision at info instead of debug. Off keeps the file to one line per pass.').volatile(),
|
|
448
|
+
/** Whether the plugin may speak without being asked. */
|
|
449
|
+
noticesEnabled: z.boolean().default(true).description('Let the plugin raise a notice on its own: a daily digest of what it maintained, a backlog warning when decisions have waited too long, and open loops whose deadline passed. Delivered as an operating-system notification. Off means the plugin only ever answers.').volatile(),
|
|
450
|
+
/** Windows during which nothing is delivered. */
|
|
451
|
+
noticeQuietHours: z.string().default('').description('Local-time windows during which notices are held rather than delivered, for example "22:00-08:00". Empty means always allowed. Held notices fire when the window ends; they are not dropped.').volatile(),
|
|
452
|
+
/** Whether the weekly reflection pass may run. */
|
|
453
|
+
reflectionEnabled: z.boolean().default(true).description('Once a week, synthesize a few observations from the memory store that no single memory states — patterns across projects, habits, things the user keeps getting burned by. Every observation must cite the memories behind it or it is dropped. Written as dated markdown under memories/reflections, never injected into conversations.').volatile(),
|
|
454
|
+
/** Whether a model decides if a judgement-based notice is worth an interruption. */
|
|
455
|
+
noticeGate: z.boolean().default(true).description('Before raising a notice that has no rule behind it (an undated promise that has been sitting for days), ask a model whether it is worth interrupting for. The default answer is silence: a gate that cannot run, or that fails, suppresses the notice. Rule-based notices (daily digest, backlog warning, a promise whose deadline passed) are never gated.').volatile(),
|
|
456
|
+
/** Byte budget for the persona block injected ahead of the memory summary. */
|
|
457
|
+
personaMaxBytes: z.number().default(12000).description('Byte budget for the persona block (who the user is, in their own words) injected once per conversation ahead of the memory summary. 0 disables the block. The profile is edited in Settings → Memories → Persona; locking it there stops the consolidation pass from rewriting it. Kept separate from the summary budget because the profile is context for the whole turn, not one of the memories being listed.').volatile(),
|
|
458
|
+
/** Share of a scope above which a query term stops counting as recall evidence. */
|
|
459
|
+
evidenceMaxDf: z.number().default(DEFAULT_EVIDENCE_MAX_DF).description('A query term that appears in more than this share of one scope does not count towards the recall gate\'s evidence requirement. 0.15 is measured on a real 200-entry store: it catches exactly one term (dsh, 22% of entries) and cuts false admissions by three quarters without changing any of ten labelled probes. 0 disables the discount and restores the pre-2026-10-23 behaviour.').volatile(),
|
|
460
|
+
/** Local-time windows whose tokens are the expensive ones. */
|
|
461
|
+
peakHours: z.string().default(DEFAULT_PEAK_HOURS).description('Local-time peak windows to keep the plugin\'s model calls out of, for example "Mon-Fri 09:00-12:00, Mon-Fri 14:00-18:00" (DeepSeek charges double then, Beijing time). Background extraction and consolidation are deferred to the next off-peak moment; /memories mine and /memories consolidate ignore this. Empty disables the restriction.').volatile(),
|
|
462
|
+
});
|
|
463
|
+
/**
|
|
464
|
+
* Every tunable with its shipped value.
|
|
465
|
+
*
|
|
466
|
+
* The runtime never reads this object for behaviour — the Loader resolves the
|
|
467
|
+
* schema defaults — but it is the same set as plain data: the key list the
|
|
468
|
+
* runtime and the card are both checked against, with the values a harness (or
|
|
469
|
+
* any deployment that configures nothing) starts from.
|
|
470
|
+
*/
|
|
471
|
+
export const MEMORIES_SETTINGS_DEFAULTS = {
|
|
472
|
+
maxSummaryBytes: DEFAULT_MAX_SUMMARY_BYTES,
|
|
473
|
+
maxSummaryEntries: DEFAULT_MAX_SUMMARY_ENTRIES,
|
|
474
|
+
globalSummaryEntries: DEFAULT_GLOBAL_SUMMARY_ENTRIES,
|
|
475
|
+
globalSummaryBytes: DEFAULT_GLOBAL_SUMMARY_BYTES,
|
|
476
|
+
summaryFreshSlots: DEFAULT_SUMMARY_FRESH_SLOTS,
|
|
477
|
+
recallMode: DEFAULT_RECALL_MODE,
|
|
478
|
+
recallMinScore: DEFAULT_RECALL_MIN_SCORE,
|
|
479
|
+
recallMaxPerConversation: DEFAULT_RECALL_MAX_PER_CONVERSATION,
|
|
480
|
+
recallMaxBytes: DEFAULT_RECALL_MAX_BYTES,
|
|
481
|
+
rawRecall: DEFAULT_RAW_RECALL,
|
|
482
|
+
rawRecallBytes: DEFAULT_RAW_RECALL_BYTES,
|
|
483
|
+
rawRecallExcerpts: DEFAULT_RAW_RECALL_EXCERPTS,
|
|
484
|
+
recallMinQueryChars: DEFAULT_RECALL_MIN_QUERY_CHARS,
|
|
485
|
+
recallMinTerms: DEFAULT_RECALL_MIN_TERMS,
|
|
486
|
+
injectDelta: DEFAULT_INJECT_DELTA,
|
|
487
|
+
rotationEntries: DEFAULT_ROTATION_ENTRIES,
|
|
488
|
+
rotationEveryTurns: DEFAULT_ROTATION_EVERY_TURNS,
|
|
489
|
+
maxEntriesPerScope: DEFAULT_MAX_ENTRIES_PER_SCOPE,
|
|
490
|
+
maxUnusedDays: DEFAULT_MAX_UNUSED_DAYS,
|
|
491
|
+
snapshotMaxAgeDays: DEFAULT_SNAPSHOT_MAX_AGE_DAYS,
|
|
492
|
+
dedupeSimilarity: DEFAULT_DEDUPE_SIMILARITY,
|
|
493
|
+
sweepIntervalHours: DEFAULT_SWEEP_INTERVAL_HOURS,
|
|
494
|
+
autoExtract: true,
|
|
495
|
+
autoExtractIdleMs: DEFAULT_AUTO_EXTRACT_IDLE_MS,
|
|
496
|
+
extractWindowMessages: DEFAULT_EXTRACT_WINDOW_MESSAGES,
|
|
497
|
+
extractMaxInputChars: DEFAULT_EXTRACT_MAX_INPUT_CHARS,
|
|
498
|
+
extractMaxOutputTokens: DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS,
|
|
499
|
+
extractTimeoutMs: DEFAULT_EXTRACT_TIMEOUT_MS,
|
|
500
|
+
extractMaxMemories: DEFAULT_EXTRACT_MAX_MEMORIES,
|
|
501
|
+
extractIntervalMinutes: DEFAULT_EXTRACT_INTERVAL_MINUTES,
|
|
502
|
+
minIdleHours: DEFAULT_MIN_IDLE_HOURS,
|
|
503
|
+
maxAgeDays: DEFAULT_MAX_AGE_DAYS,
|
|
504
|
+
maxSessionsPerPass: DEFAULT_MAX_SESSIONS_PER_PASS,
|
|
505
|
+
syncRemote: '',
|
|
506
|
+
syncConflictProvider: '',
|
|
507
|
+
syncConflictModel: '',
|
|
508
|
+
syncClock: DEFAULT_SYNC_CLOCK,
|
|
509
|
+
syncIntervalMinutes: DEFAULT_SYNC_INTERVAL_MINUTES,
|
|
510
|
+
syncDebounceSeconds: DEFAULT_SYNC_DEBOUNCE_SECONDS,
|
|
511
|
+
consolidate: true,
|
|
512
|
+
consolidateCooldownHours: DEFAULT_CONSOLIDATE_COOLDOWN_HOURS,
|
|
513
|
+
consolidateProposalMaxAgeHours: DEFAULT_CONSOLIDATE_PROPOSAL_MAX_AGE_HOURS,
|
|
514
|
+
consolidateMaxEntries: DEFAULT_CONSOLIDATE_MAX_ENTRIES,
|
|
515
|
+
consolidateTimeoutMs: DEFAULT_CONSOLIDATE_TIMEOUT_MS,
|
|
516
|
+
autoDecide: true,
|
|
517
|
+
autoDecideMinConfidence: 0.7,
|
|
518
|
+
personaMaxBytes: 12000,
|
|
519
|
+
noticeGate: true,
|
|
520
|
+
reflectionEnabled: true,
|
|
521
|
+
noticesEnabled: true,
|
|
522
|
+
noticeQuietHours: '',
|
|
523
|
+
pauseOnQuotaError: true,
|
|
524
|
+
quotaCooldownMinutes: DEFAULT_QUOTA_COOLDOWN_MINUTES,
|
|
525
|
+
quotaCooldownMaxMinutes: DEFAULT_QUOTA_COOLDOWN_MAX_MINUTES,
|
|
526
|
+
extractProvider: '',
|
|
527
|
+
extractModel: '',
|
|
528
|
+
consolidateProvider: '',
|
|
529
|
+
consolidateModel: '',
|
|
530
|
+
enableTool: true,
|
|
531
|
+
enableCommand: true,
|
|
532
|
+
logLevel: DEFAULT_LOG_LEVEL,
|
|
533
|
+
traceMaintenance: DEFAULT_TRACE_MAINTENANCE,
|
|
534
|
+
evidenceMaxDf: DEFAULT_EVIDENCE_MAX_DF,
|
|
535
|
+
peakHours: DEFAULT_PEAK_HOURS,
|
|
536
|
+
};
|
|
537
|
+
/** Clamp one tunable into a usable range. */
|
|
538
|
+
function positive(value, fallback, min = 1) {
|
|
539
|
+
if (value === undefined || !Number.isFinite(value))
|
|
540
|
+
return fallback;
|
|
541
|
+
return value < min ? min : Math.trunc(value);
|
|
542
|
+
}
|
|
543
|
+
/** Clamp one ratio into `[0, 1]`, where `0` disables the behaviour it gates. */
|
|
544
|
+
function clampUnit(value, fallback) {
|
|
545
|
+
if (value === undefined || !Number.isFinite(value))
|
|
546
|
+
return fallback;
|
|
547
|
+
if (value <= 0)
|
|
548
|
+
return 0;
|
|
549
|
+
return value >= 1 ? 1 : value;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Clamp one tunable that accepts fractions, such as a wait in hours.
|
|
553
|
+
*
|
|
554
|
+
* `positive` truncates, which would turn `minIdleHours: 0.5` — half an hour —
|
|
555
|
+
* into `0`, silently disabling the gate it configures.
|
|
556
|
+
*/
|
|
557
|
+
function decimal(value, fallback, min = 0) {
|
|
558
|
+
if (value === undefined || !Number.isFinite(value))
|
|
559
|
+
return fallback;
|
|
560
|
+
return value < min ? min : value;
|
|
561
|
+
}
|
|
562
|
+
/** Coerce one possibly-absent tunable set into a complete, clamped section. */
|
|
563
|
+
export function normalizeSettings(input) {
|
|
564
|
+
const value = input ?? {};
|
|
565
|
+
const provider = value.extractProvider?.trim() ?? '';
|
|
566
|
+
const model = value.extractModel?.trim() ?? '';
|
|
567
|
+
const route = provider.length > 0 && model.length > 0
|
|
568
|
+
? { extractProvider: provider, extractModel: model }
|
|
569
|
+
: { extractProvider: '', extractModel: '' };
|
|
570
|
+
const consolidateProvider = value.consolidateProvider?.trim() ?? '';
|
|
571
|
+
const consolidateModel = value.consolidateModel?.trim() ?? '';
|
|
572
|
+
// A lone half is not a route: the pair resolves together or not at all, and an
|
|
573
|
+
// empty consolidation route falls back to the extraction one at call time.
|
|
574
|
+
const consolidateRoute = consolidateProvider.length > 0 && consolidateModel.length > 0
|
|
575
|
+
? { consolidateProvider, consolidateModel }
|
|
576
|
+
: { consolidateProvider: '', consolidateModel: '' };
|
|
577
|
+
return {
|
|
578
|
+
maxSummaryBytes: positive(value.maxSummaryBytes, DEFAULT_MAX_SUMMARY_BYTES, 0),
|
|
579
|
+
maxSummaryEntries: positive(value.maxSummaryEntries, DEFAULT_MAX_SUMMARY_ENTRIES),
|
|
580
|
+
globalSummaryEntries: positive(value.globalSummaryEntries, DEFAULT_GLOBAL_SUMMARY_ENTRIES, 0),
|
|
581
|
+
globalSummaryBytes: positive(value.globalSummaryBytes, DEFAULT_GLOBAL_SUMMARY_BYTES, 0),
|
|
582
|
+
summaryFreshSlots: positive(value.summaryFreshSlots, DEFAULT_SUMMARY_FRESH_SLOTS, 0),
|
|
583
|
+
recallMode: toRecallMode(value.recallMode),
|
|
584
|
+
recallMinScore: positive(value.recallMinScore, DEFAULT_RECALL_MIN_SCORE, 0),
|
|
585
|
+
recallMaxPerConversation: positive(value.recallMaxPerConversation, DEFAULT_RECALL_MAX_PER_CONVERSATION, 0),
|
|
586
|
+
recallMaxBytes: positive(value.recallMaxBytes, DEFAULT_RECALL_MAX_BYTES, 0),
|
|
587
|
+
rawRecall: value.rawRecall ?? DEFAULT_RAW_RECALL,
|
|
588
|
+
rawRecallBytes: positive(value.rawRecallBytes, DEFAULT_RAW_RECALL_BYTES, 0),
|
|
589
|
+
rawRecallExcerpts: positive(value.rawRecallExcerpts, DEFAULT_RAW_RECALL_EXCERPTS, 0),
|
|
590
|
+
recallMinQueryChars: positive(value.recallMinQueryChars, DEFAULT_RECALL_MIN_QUERY_CHARS, 0),
|
|
591
|
+
recallMinTerms: positive(value.recallMinTerms, DEFAULT_RECALL_MIN_TERMS, 0),
|
|
592
|
+
injectDelta: value.injectDelta ?? DEFAULT_INJECT_DELTA,
|
|
593
|
+
rotationEntries: positive(value.rotationEntries, DEFAULT_ROTATION_ENTRIES, 0),
|
|
594
|
+
rotationEveryTurns: positive(value.rotationEveryTurns, DEFAULT_ROTATION_EVERY_TURNS, 0),
|
|
595
|
+
maxEntriesPerScope: positive(value.maxEntriesPerScope, DEFAULT_MAX_ENTRIES_PER_SCOPE),
|
|
596
|
+
maxUnusedDays: positive(value.maxUnusedDays, DEFAULT_MAX_UNUSED_DAYS, 0),
|
|
597
|
+
snapshotMaxAgeDays: positive(value.snapshotMaxAgeDays, DEFAULT_SNAPSHOT_MAX_AGE_DAYS, 0),
|
|
598
|
+
dedupeSimilarity: clampUnit(value.dedupeSimilarity, DEFAULT_DEDUPE_SIMILARITY),
|
|
599
|
+
sweepIntervalHours: decimal(value.sweepIntervalHours, DEFAULT_SWEEP_INTERVAL_HOURS),
|
|
600
|
+
autoExtract: value.autoExtract ?? true,
|
|
601
|
+
autoExtractIdleMs: positive(value.autoExtractIdleMs, DEFAULT_AUTO_EXTRACT_IDLE_MS, 1000),
|
|
602
|
+
extractWindowMessages: positive(value.extractWindowMessages, DEFAULT_EXTRACT_WINDOW_MESSAGES),
|
|
603
|
+
extractMaxInputChars: positive(value.extractMaxInputChars, DEFAULT_EXTRACT_MAX_INPUT_CHARS),
|
|
604
|
+
extractMaxOutputTokens: positive(value.extractMaxOutputTokens, DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS),
|
|
605
|
+
extractTimeoutMs: positive(value.extractTimeoutMs, DEFAULT_EXTRACT_TIMEOUT_MS),
|
|
606
|
+
extractMaxMemories: positive(value.extractMaxMemories, DEFAULT_EXTRACT_MAX_MEMORIES),
|
|
607
|
+
extractIntervalMinutes: decimal(value.extractIntervalMinutes, DEFAULT_EXTRACT_INTERVAL_MINUTES),
|
|
608
|
+
minIdleHours: decimal(value.minIdleHours, DEFAULT_MIN_IDLE_HOURS),
|
|
609
|
+
maxAgeDays: positive(value.maxAgeDays, DEFAULT_MAX_AGE_DAYS, 0),
|
|
610
|
+
maxSessionsPerPass: positive(value.maxSessionsPerPass, DEFAULT_MAX_SESSIONS_PER_PASS),
|
|
611
|
+
syncRemote: value.syncRemote?.trim() ?? '',
|
|
612
|
+
syncConflictProvider: value.syncConflictProvider?.trim() ?? '',
|
|
613
|
+
syncConflictModel: value.syncConflictModel?.trim() ?? '',
|
|
614
|
+
syncClock: value.syncClock?.trim() ?? DEFAULT_SYNC_CLOCK,
|
|
615
|
+
syncIntervalMinutes: positive(value.syncIntervalMinutes, DEFAULT_SYNC_INTERVAL_MINUTES, 0),
|
|
616
|
+
syncDebounceSeconds: positive(value.syncDebounceSeconds, DEFAULT_SYNC_DEBOUNCE_SECONDS, 0),
|
|
617
|
+
consolidate: value.consolidate ?? true,
|
|
618
|
+
consolidateCooldownHours: decimal(value.consolidateCooldownHours, DEFAULT_CONSOLIDATE_COOLDOWN_HOURS),
|
|
619
|
+
consolidateProposalMaxAgeHours: decimal(value.consolidateProposalMaxAgeHours, DEFAULT_CONSOLIDATE_PROPOSAL_MAX_AGE_HOURS, 0),
|
|
620
|
+
consolidateMaxEntries: positive(value.consolidateMaxEntries, DEFAULT_CONSOLIDATE_MAX_ENTRIES),
|
|
621
|
+
consolidateTimeoutMs: positive(value.consolidateTimeoutMs, DEFAULT_CONSOLIDATE_TIMEOUT_MS),
|
|
622
|
+
autoDecide: value.autoDecide ?? true,
|
|
623
|
+
autoDecideMinConfidence: clampUnit(value.autoDecideMinConfidence, 0.7),
|
|
624
|
+
personaMaxBytes: positive(value.personaMaxBytes, 12000, 0),
|
|
625
|
+
noticeGate: value.noticeGate ?? true,
|
|
626
|
+
reflectionEnabled: value.reflectionEnabled ?? true,
|
|
627
|
+
noticesEnabled: value.noticesEnabled ?? true,
|
|
628
|
+
noticeQuietHours: value.noticeQuietHours ?? '',
|
|
629
|
+
pauseOnQuotaError: value.pauseOnQuotaError ?? true,
|
|
630
|
+
quotaCooldownMinutes: positive(value.quotaCooldownMinutes, DEFAULT_QUOTA_COOLDOWN_MINUTES, 0),
|
|
631
|
+
quotaCooldownMaxMinutes: positive(value.quotaCooldownMaxMinutes, DEFAULT_QUOTA_COOLDOWN_MAX_MINUTES, 0),
|
|
632
|
+
...route,
|
|
633
|
+
...consolidateRoute,
|
|
634
|
+
enableTool: value.enableTool ?? true,
|
|
635
|
+
enableCommand: value.enableCommand ?? true,
|
|
636
|
+
logLevel: toLogLevel(value.logLevel, DEFAULT_LOG_LEVEL),
|
|
637
|
+
traceMaintenance: value.traceMaintenance ?? false,
|
|
638
|
+
evidenceMaxDf: clampUnit(value.evidenceMaxDf, DEFAULT_EVIDENCE_MAX_DF),
|
|
639
|
+
peakHours: (value.peakHours ?? '').replace(/\s+/gu, ' ').trim(),
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* The route one consolidation pass runs on.
|
|
644
|
+
*
|
|
645
|
+
* Codex keeps `memories.extract_model` and `memories.consolidation_model`
|
|
646
|
+
* separate; here an unset consolidation route falls back to the extraction one
|
|
647
|
+
* and then to the session's own logged route, so an existing configuration that
|
|
648
|
+
* only names `extractProvider`/`extractModel` keeps behaving as before.
|
|
649
|
+
*
|
|
650
|
+
* @param settings - the tunables in force.
|
|
651
|
+
* @returns the provider/model pair, or `{}` to reuse the session route.
|
|
652
|
+
*/
|
|
653
|
+
export function consolidationRouteOf(settings) {
|
|
654
|
+
if (settings.consolidateProvider.length > 0 && settings.consolidateModel.length > 0) {
|
|
655
|
+
return { provider: settings.consolidateProvider, model: settings.consolidateModel };
|
|
656
|
+
}
|
|
657
|
+
if (settings.extractProvider.length > 0 && settings.extractModel.length > 0) {
|
|
658
|
+
return { provider: settings.extractProvider, model: settings.extractModel };
|
|
659
|
+
}
|
|
660
|
+
return {};
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* One entry config with its live references read out.
|
|
664
|
+
*
|
|
665
|
+
* A row the Loader mounted arrives with every tunable as a `Volatile` reference
|
|
666
|
+
* that a committed settings write updates in place; a plain row (a test harness,
|
|
667
|
+
* a hand-written composition) arrives with the values themselves. Both pass
|
|
668
|
+
* through here unchanged in shape, so every reader downstream sees plain data
|
|
669
|
+
* and the same code serves the two cases.
|
|
670
|
+
*
|
|
671
|
+
* @param config - the row as `apply` received it.
|
|
672
|
+
* @returns the same row with references replaced by their current values.
|
|
673
|
+
*/
|
|
674
|
+
export function plainRow(config) {
|
|
675
|
+
return Object.fromEntries(Object.entries(config).map(([key, value]) => [key, isVolatile(value) ? value.get() : value]));
|
|
676
|
+
}
|
|
677
|
+
/** The tunables a plain row carries, in one place, keyed by tunable name. */
|
|
678
|
+
function flatTunables(row) {
|
|
679
|
+
const source = row;
|
|
680
|
+
const tunables = {};
|
|
681
|
+
for (const key of Object.keys(MEMORIES_SETTINGS_DEFAULTS)) {
|
|
682
|
+
const value = source[key];
|
|
683
|
+
if (value !== undefined)
|
|
684
|
+
tunables[key] = value;
|
|
685
|
+
}
|
|
686
|
+
return tunables;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* The tunables an entry config holds right now.
|
|
690
|
+
*
|
|
691
|
+
* A read rather than a value on purpose: a committed settings write lands in the
|
|
692
|
+
* row's references without re-mounting the plugin, so the runtime asks again
|
|
693
|
+
* instead of holding a snapshot.
|
|
694
|
+
*
|
|
695
|
+
* @param config - the row as `apply` received it.
|
|
696
|
+
* @returns the normalized tunables in force.
|
|
697
|
+
*/
|
|
698
|
+
export function readTunables(config) {
|
|
699
|
+
return normalizeSettings(flatTunables(plainRow(config)));
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Resolve the deployment facts and the tunables of one entry config.
|
|
703
|
+
*
|
|
704
|
+
* @param config - the entry configuration the Loader hands `apply`.
|
|
705
|
+
* @returns normalized paths, workspace markers, and tunables.
|
|
706
|
+
*/
|
|
707
|
+
/** Expand a leading `~` and leave everything else to `resolve`. */
|
|
708
|
+
function expandHome(path) {
|
|
709
|
+
if (path === '~')
|
|
710
|
+
return homedir();
|
|
711
|
+
return path.startsWith('~/') ? join(homedir(), path.slice(2)) : path;
|
|
712
|
+
}
|
|
713
|
+
export function resolveConfig(config = {}) {
|
|
714
|
+
const row = plainRow(config);
|
|
715
|
+
const dshHome = resolveDshHome(row.dshHome);
|
|
716
|
+
const memoriesDir = row.memoriesDir !== undefined && row.memoriesDir.trim().length > 0
|
|
717
|
+
? row.memoriesDir
|
|
718
|
+
: `${dshHome}/memories`;
|
|
719
|
+
const markers = (row.projectRootMarkers ?? [...DEFAULT_PROJECT_ROOT_MARKERS])
|
|
720
|
+
.filter((marker) => marker.trim().length > 0);
|
|
721
|
+
const overrides = Object.entries(row.projectRootOverrides ?? {})
|
|
722
|
+
.filter(([prefix, root]) => prefix.trim().length > 0 && typeof root === 'string' && root.trim().length > 0)
|
|
723
|
+
.map(([prefix, root]) => [resolve(expandHome(prefix.trim())), resolve(expandHome(root.trim()))])
|
|
724
|
+
// Longest prefix first, so a nested workspace beats the tree it lives in.
|
|
725
|
+
.sort((left, right) => right[0].length - left[0].length);
|
|
726
|
+
return {
|
|
727
|
+
dshHome,
|
|
728
|
+
memoriesDir,
|
|
729
|
+
projectRootMarkers: markers.length > 0 ? markers : [...DEFAULT_PROJECT_ROOT_MARKERS],
|
|
730
|
+
projectRootOverrides: overrides,
|
|
731
|
+
// Only `undefined` falls back to the default location, so an explicit empty
|
|
732
|
+
// string disables file logging.
|
|
733
|
+
logFile: row.logFile?.trim() ?? logPath(dshHome),
|
|
734
|
+
tunables: normalizeSettings(flatTunables(row)),
|
|
735
|
+
};
|
|
736
|
+
}
|