@chenhw7/dsh-memory 0.5.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -0
- package/README.md +24 -15
- package/{README.zh-CN.md → README.zh.md} +22 -14
- package/cordis.patch.yml +10 -4
- package/lib/benchmark/index.d.ts +24 -7
- package/lib/benchmark/index.d.ts.map +1 -1
- package/lib/benchmark/index.js +55 -7
- package/lib/benchmark/index.js.map +1 -1
- package/lib/client/index.js +47 -31
- package/lib/context/conflict.d.ts +23 -10
- package/lib/context/conflict.d.ts.map +1 -1
- package/lib/context/conflict.js +59 -20
- package/lib/context/conflict.js.map +1 -1
- package/lib/context/index.d.ts +2 -6
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +29 -25
- package/lib/context/index.js.map +1 -1
- package/lib/context/policy.d.ts +17 -5
- package/lib/context/policy.d.ts.map +1 -1
- package/lib/context/policy.js +27 -9
- package/lib/context/policy.js.map +1 -1
- package/lib/index.d.ts +23 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -1
- package/lib/notes/cleanup.d.ts +48 -0
- package/lib/notes/cleanup.d.ts.map +1 -0
- package/lib/notes/cleanup.js +98 -0
- package/lib/notes/cleanup.js.map +1 -0
- package/lib/notes/index.d.ts +23 -23
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +38 -131
- package/lib/notes/index.js.map +1 -1
- package/lib/notes/render.d.ts +13 -13
- package/lib/notes/render.d.ts.map +1 -1
- package/lib/notes/render.js +13 -13
- package/lib/notes/render.js.map +1 -1
- package/lib/notes/scope.d.ts +11 -10
- package/lib/notes/scope.d.ts.map +1 -1
- package/lib/notes/scope.js +11 -10
- package/lib/notes/scope.js.map +1 -1
- package/lib/notes/settings.d.ts +9 -20
- package/lib/notes/settings.d.ts.map +1 -1
- package/lib/notes/settings.js +9 -27
- package/lib/notes/settings.js.map +1 -1
- package/lib/remote/index.d.ts +67 -6
- package/lib/remote/index.d.ts.map +1 -1
- package/lib/remote/index.js +94 -9
- package/lib/remote/index.js.map +1 -1
- package/lib/remote/typert.remote-client.d.ts +8 -1
- package/lib/remote/typert.remote-client.js +6 -0
- package/lib/remote/types.d.ts +1 -1
- package/lib/remote/types.d.ts.map +1 -1
- package/lib/review/accumulator.d.ts +5 -5
- package/lib/review/accumulator.d.ts.map +1 -1
- package/lib/review/accumulator.js +3 -3
- package/lib/review/accumulator.js.map +1 -1
- package/lib/review/dedup.d.ts +23 -15
- package/lib/review/dedup.d.ts.map +1 -1
- package/lib/review/dedup.js +34 -83
- package/lib/review/dedup.js.map +1 -1
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +5 -2
- package/lib/review/extract.js.map +1 -1
- package/lib/review/index.d.ts.map +1 -1
- package/lib/review/index.js +28 -21
- package/lib/review/index.js.map +1 -1
- package/lib/scanner.d.ts +2 -0
- package/lib/scanner.d.ts.map +1 -1
- package/lib/scanner.js +22 -0
- package/lib/scanner.js.map +1 -1
- package/lib/store/bm25.d.ts +75 -1
- package/lib/store/bm25.d.ts.map +1 -1
- package/lib/store/bm25.js +162 -17
- package/lib/store/bm25.js.map +1 -1
- package/lib/store/cross-process.d.ts +155 -0
- package/lib/store/cross-process.d.ts.map +1 -0
- package/lib/store/cross-process.js +254 -0
- package/lib/store/cross-process.js.map +1 -0
- package/lib/store/index.d.ts +89 -7
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +466 -89
- package/lib/store/index.js.map +1 -1
- package/lib/tool/index.d.ts +17 -5
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +237 -24
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +31 -2
- package/lib/types.d.ts.map +1 -1
- package/package.json +40 -31
- package/lib/notes/writer.d.ts +0 -65
- package/lib/notes/writer.d.ts.map +0 -1
- package/lib/notes/writer.js +0 -131
- package/lib/notes/writer.js.map +0 -1
package/lib/notes/index.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@chenhw7/dsh-memory/notes`: the project-notes
|
|
2
|
+
* `@chenhw7/dsh-memory/notes`: the project-notes projection
|
|
3
|
+
* (TECH_DESIGN §7.4; rationale: the prompt-only Agent Note
|
|
4
|
+
* .agents/notes/implemented/architecture/2026-08-31-project-notes-writes-no-repository-files.md).
|
|
3
5
|
* A function plugin that renders habit/convention/pitfall entries from the
|
|
4
|
-
* memory store into
|
|
5
|
-
*
|
|
6
|
+
* memory store into the `project-notes` system-prompt section. Since 0.6 it
|
|
7
|
+
* writes NOTHING into the user's project — the store is the sole source of
|
|
8
|
+
* truth, the Memory settings UI is the management surface, and the one-time
|
|
9
|
+
* `cleanup` pass removes artifacts left by ≤0.5.x file exports.
|
|
6
10
|
*
|
|
7
|
-
* The store is the source of truth; the files are a read-only rendered view.
|
|
8
11
|
* Rendering is synchronous from the store's in-memory state — the same text
|
|
9
|
-
*
|
|
10
|
-
* into its per-session prompt snapshot, so prompt and files can never drift.
|
|
11
|
-
* Persistence is skipped when nothing changed since the last render.
|
|
12
|
+
* `memory-context` freezes into its per-session prompt snapshot.
|
|
12
13
|
*
|
|
13
14
|
* @module @chenhw7/dsh-memory/notes
|
|
14
15
|
*/
|
|
15
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
16
|
-
import path from 'node:path';
|
|
17
16
|
import { scanContent } from '../scanner.js';
|
|
18
17
|
import { isRenderedEntry } from './scope.js';
|
|
19
18
|
import { renderConventions, renderPitfalls } from './render.js';
|
|
20
|
-
import {
|
|
21
|
-
import { resolveNotesSettings
|
|
19
|
+
import { cleanupLegacyNotesArtifacts } from './cleanup.js';
|
|
20
|
+
import { resolveNotesSettings } from './settings.js';
|
|
22
21
|
export { isRenderedEntry } from './scope.js';
|
|
23
22
|
export { renderConventions, renderPitfalls } from './render.js';
|
|
24
|
-
export {
|
|
25
|
-
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED,
|
|
23
|
+
export { cleanupLegacyNotesArtifacts, stripAgentsPointerBlock, AGENTS_POINTER_BEGIN, AGENTS_POINTER_END, LEGACY_NOTES_DIR } from './cleanup.js';
|
|
24
|
+
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED, DEFAULT_NOTES_CHAR_LIMIT, DEFAULT_NOTES_MAX_ENTRIES_PER_FILE } from './settings.js';
|
|
26
25
|
/** Cordis plugin name. */
|
|
27
26
|
export const name = 'memory-notes';
|
|
28
27
|
/** Nothing is required: `memory` and `settings` are accessed optionally. */
|
|
29
28
|
export const inject = [];
|
|
30
29
|
/** The settings namespace owned by `memory-context`, read here defensively. */
|
|
31
|
-
const MEMORY_NS =
|
|
32
|
-
/** Debounce window for activity-triggered re-renders, in milliseconds. */
|
|
33
|
-
const RENDER_DEBOUNCE_MS = 2_000;
|
|
30
|
+
const MEMORY_NS = 'memory';
|
|
34
31
|
/** The empty snapshot. */
|
|
35
32
|
const EMPTY_SNAPSHOT = { conventions: '', pitfalls: '' };
|
|
36
33
|
/**
|
|
37
34
|
* The project-notes service, registered on `ctx.projectNotes` by this plugin.
|
|
38
|
-
* Consumers (memory-context and
|
|
39
|
-
* read through it.
|
|
35
|
+
* Consumers (memory-context) render and read through it. Pure — no I/O.
|
|
40
36
|
*/
|
|
41
37
|
export class ProjectNotesService {
|
|
42
38
|
constructor() {
|
|
@@ -54,16 +50,6 @@ function projectNameOf(cwd) {
|
|
|
54
50
|
class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
55
51
|
ctx;
|
|
56
52
|
settings;
|
|
57
|
-
/** Last persisted file texts per notes dir, for skip-if-unchanged and drift detection. */
|
|
58
|
-
persisted = new Map();
|
|
59
|
-
/** Set to true when a drift error was already reported for this dir (log-once). */
|
|
60
|
-
driftReported = new Set();
|
|
61
|
-
/** Last store health timestamp already rendered, for the dirty check. */
|
|
62
|
-
renderedHealthTs;
|
|
63
|
-
/** notesDir values already reported as escaping the project root (log-once). */
|
|
64
|
-
traversalReported = new Set();
|
|
65
|
-
/** Debounce timer for activity-triggered re-renders. */
|
|
66
|
-
timer;
|
|
67
53
|
constructor(ctx, settings) {
|
|
68
54
|
super();
|
|
69
55
|
this.ctx = ctx;
|
|
@@ -77,20 +63,19 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
77
63
|
return EMPTY_SNAPSHOT;
|
|
78
64
|
}
|
|
79
65
|
// No cwd → there is no current project, so project-scope entries drop
|
|
80
|
-
// out, but the global/user slices still render
|
|
81
|
-
// (there is no project root to write the files into).
|
|
66
|
+
// out, but the global/user slices still render.
|
|
82
67
|
const projectName = cwd === undefined || cwd.length === 0 ? undefined : projectNameOf(cwd);
|
|
83
68
|
const conventions = [];
|
|
84
69
|
const pitfalls = [];
|
|
85
70
|
for (const entry of memory.list()) {
|
|
86
71
|
// Load-time guard: entries that fail the scanner never reach the
|
|
87
|
-
// exported
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
//
|
|
72
|
+
// exported section (which feeds future injections). Unlike the prompt
|
|
73
|
+
// surfaces there is no placeholder here — an omitted section entry is
|
|
74
|
+
// simply absent; the store keeps the original for user inspection and
|
|
75
|
+
// removal.
|
|
91
76
|
if (!scanContent(entry.content).allowed)
|
|
92
77
|
continue;
|
|
93
|
-
// Soft-decayed entries drop out of every standing view,
|
|
78
|
+
// Soft-decayed entries drop out of every standing view, this one included.
|
|
94
79
|
if (entry.staleSince !== undefined)
|
|
95
80
|
continue;
|
|
96
81
|
const kind = isRenderedEntry(entry, projectName);
|
|
@@ -99,103 +84,21 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
99
84
|
else if (kind === 'pitfalls')
|
|
100
85
|
pitfalls.push(entry);
|
|
101
86
|
}
|
|
102
|
-
|
|
87
|
+
return {
|
|
103
88
|
conventions: renderConventions(conventions, settings.notesMaxEntriesPerFile),
|
|
104
89
|
pitfalls: renderPitfalls(pitfalls, settings.notesMaxEntriesPerFile),
|
|
105
90
|
};
|
|
106
|
-
if (cwd !== undefined && cwd.length > 0)
|
|
107
|
-
this.persist(cwd, snapshot, settings);
|
|
108
|
-
this.renderedHealthTs = memory.health().lastActivityTs;
|
|
109
|
-
return snapshot;
|
|
110
91
|
}
|
|
111
|
-
catch {
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.ctx.get('memory')?.reportFailure('notes-snapshot', error);
|
|
112
94
|
return EMPTY_SNAPSHOT;
|
|
113
95
|
}
|
|
114
96
|
}
|
|
115
|
-
/** Render + persist only when the store changed since the last render. */
|
|
116
|
-
reconcileIfStale(cwd) {
|
|
117
|
-
const memory = this.ctx.get('memory');
|
|
118
|
-
if (memory === undefined)
|
|
119
|
-
return;
|
|
120
|
-
const ts = memory.health().lastActivityTs;
|
|
121
|
-
if (ts === undefined || ts === this.renderedHealthTs)
|
|
122
|
-
return;
|
|
123
|
-
if (this.timer !== undefined)
|
|
124
|
-
clearTimeout(this.timer);
|
|
125
|
-
this.timer = setTimeout(() => {
|
|
126
|
-
this.timer = undefined;
|
|
127
|
-
try {
|
|
128
|
-
this.snapshotFor(cwd);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
// Best-effort: a re-render failure never propagates.
|
|
132
|
-
}
|
|
133
|
-
}, RENDER_DEBOUNCE_MS);
|
|
134
|
-
}
|
|
135
|
-
/** Persist the snapshot atomically when it differs from the last write. */
|
|
136
|
-
persist(cwd, snapshot, settings) {
|
|
137
|
-
const dir = resolveNotesDir(cwd, settings.notesDir);
|
|
138
|
-
if (dir === undefined) {
|
|
139
|
-
// Containment: an escaping notesDir must never direct writes outside
|
|
140
|
-
// the project. Rendered snapshots keep flowing to the prompt; only the
|
|
141
|
-
// file persistence is skipped.
|
|
142
|
-
if (!this.traversalReported.has(settings.notesDir)) {
|
|
143
|
-
this.traversalReported.add(settings.notesDir);
|
|
144
|
-
console.warn(`[dsh-memory] notesDir "${settings.notesDir}" resolves outside the project root; skipping notes persistence for it.`);
|
|
145
|
-
}
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const previous = this.persisted.get(dir);
|
|
149
|
-
if (previous !== undefined && previous.conventions === snapshot.conventions && previous.pitfalls === snapshot.pitfalls) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
void (async () => {
|
|
153
|
-
try {
|
|
154
|
-
await writeNotesFile(path.join(dir, 'CONVENTIONS.md'), snapshot.conventions, previous?.conventions);
|
|
155
|
-
await writeNotesFile(path.join(dir, 'PITFALLS.md'), snapshot.pitfalls, previous?.pitfalls);
|
|
156
|
-
if (settings.notesAgentsPointer) {
|
|
157
|
-
await ensureAgentsPointer(path.join(cwd, 'AGENTS.md'), settings.notesDir);
|
|
158
|
-
}
|
|
159
|
-
// Only after a successful write: record this snapshot as the drift
|
|
160
|
-
// baseline so the next write can detect external modifications.
|
|
161
|
-
this.persisted.set(dir, snapshot);
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
if (error instanceof DriftError) {
|
|
165
|
-
// Drift: external modification was backed up to `.bak.<ts>`;
|
|
166
|
-
// the store remains the source of truth and the in-memory
|
|
167
|
-
// snapshot continues to be served. Update the baseline to the
|
|
168
|
-
// drifted on-disk content so the NEXT persist attempt can write
|
|
169
|
-
// fresh content (the drift has been "absorbed" as the new base).
|
|
170
|
-
try {
|
|
171
|
-
const { readFile } = await import('node:fs/promises');
|
|
172
|
-
const driftedConventions = await readFile(path.join(dir, 'CONVENTIONS.md'), 'utf8').catch(() => undefined);
|
|
173
|
-
const driftedPitfalls = await readFile(path.join(dir, 'PITFALLS.md'), 'utf8').catch(() => undefined);
|
|
174
|
-
if (driftedConventions !== undefined || driftedPitfalls !== undefined) {
|
|
175
|
-
this.persisted.set(dir, {
|
|
176
|
-
conventions: driftedConventions ?? previous?.conventions ?? '',
|
|
177
|
-
pitfalls: driftedPitfalls ?? previous?.pitfalls ?? '',
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
catch { /* best-effort */ }
|
|
182
|
-
// Report once per notes dir so the log is not spammed on every
|
|
183
|
-
// reconcile cycle; the user should reconcile the .bak file.
|
|
184
|
-
if (!this.driftReported.has(dir)) {
|
|
185
|
-
this.driftReported.add(dir);
|
|
186
|
-
console.warn(`[dsh-memory] ${error.message}. The in-memory snapshot continues to be served; resolve the drift by reviewing the .bak file and re-saving via memory tools.`);
|
|
187
|
-
}
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
// Best-effort: persistence failures never surface to the session.
|
|
191
|
-
}
|
|
192
|
-
})();
|
|
193
|
-
}
|
|
194
97
|
}
|
|
195
98
|
/**
|
|
196
99
|
* Install the memory-notes plugin: register the `projectNotes` service and
|
|
197
|
-
* the
|
|
198
|
-
*
|
|
100
|
+
* the one-time legacy-artifact cleanup on `session/created` (≤0.5.x wrote
|
|
101
|
+
* rendered files + an AGENTS.md pointer into the repo; 0.6 removes them).
|
|
199
102
|
* @param ctx - Cordis context.
|
|
200
103
|
*/
|
|
201
104
|
export function apply(ctx) {
|
|
@@ -209,14 +112,18 @@ export function apply(ctx) {
|
|
|
209
112
|
};
|
|
210
113
|
const service = new ProjectNotesServiceImpl(ctx, settings);
|
|
211
114
|
ctx.provide('projectNotes', service);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
115
|
+
// One-time migration: strip the file-export artifacts a ≤0.5.x install
|
|
116
|
+
// left in this project (marker-managed AGENTS.md block, generated notes
|
|
117
|
+
// files). Once per project root per process; idempotent, best-effort.
|
|
118
|
+
const cleanedRoots = new Set();
|
|
119
|
+
ctx.on('session/created', (session) => {
|
|
120
|
+
const cwd = session.header?.cwd;
|
|
121
|
+
if (cwd === undefined || cwd.length === 0 || cleanedRoots.has(cwd))
|
|
122
|
+
return;
|
|
123
|
+
cleanedRoots.add(cwd);
|
|
124
|
+
void cleanupLegacyNotesArtifacts(cwd, ctx.logger).catch((error) => {
|
|
125
|
+
ctx.get('memory')?.reportFailure('legacy-cleanup', error);
|
|
126
|
+
});
|
|
127
|
+
}, { global: true });
|
|
221
128
|
}
|
|
222
129
|
//# sourceMappingURL=index.js.map
|
package/lib/notes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAsB,MAAM,eAAe,CAAA;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/I,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAA;AAGzI,0BAA0B;AAC1B,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAA;AAElC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAa,EAAE,CAAA;AAElC,+EAA+E;AAC/E,MAAM,SAAS,GAAG,QAAQ,CAAA;AAe1B,0BAA0B;AAC1B,MAAM,cAAc,GAAyB,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AAE9E;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AAC,CAAA;IACD,MAAM,OAAO,GAAG,IAAI,uBAAuB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1D,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IAEpC,uEAAuE;IACvE,wEAAwE;IACxE,sEAAsE;IACtE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;IACtC,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,CAAA;QAC/B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAM;QAC1E,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACrB,KAAK,2BAA2B,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACzE,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;QAC3D,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AACtB,CAAC"}
|
package/lib/notes/render.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Markdown renderers for the project-notes
|
|
3
|
-
* through {@link isRenderedEntry}) become
|
|
4
|
-
*
|
|
2
|
+
* Markdown renderers for the project-notes prompt section: store entries
|
|
3
|
+
* (pre-filtered through {@link isRenderedEntry}) become the conventions /
|
|
4
|
+
* pitfalls texts injected into the system prompt. Pure functions — no I/O.
|
|
5
5
|
*
|
|
6
6
|
* Section order doubles as the precedence hint (project > global > personal);
|
|
7
7
|
* the injected system-prompt wrapper states it explicitly. Section headings
|
|
8
|
-
* are English regardless of entry language — the
|
|
8
|
+
* are English regardless of entry language — the notes surface is English.
|
|
9
9
|
*
|
|
10
10
|
* @module @chenhw7/dsh-memory/notes/render
|
|
11
11
|
*/
|
|
12
12
|
import type { MemoryEntry } from '../types.ts';
|
|
13
|
-
/** The
|
|
14
|
-
export declare const AUTO_HEADER = "
|
|
13
|
+
/** The provenance line stamped under every rendered section title. */
|
|
14
|
+
export declare const AUTO_HEADER = "Managed by dsh-memory (auto-generated from the memory store) \u2014 correct outdated entries via the memory tools or the Memory UI.";
|
|
15
15
|
/**
|
|
16
|
-
* Render
|
|
17
|
-
* `## Personal habits` (empty sections omitted).
|
|
16
|
+
* Render the conventions text: `## Project conventions` / `## Global
|
|
17
|
+
* practices` / `## Personal habits` (empty sections omitted).
|
|
18
18
|
* @param entries - convention-kind entries (already filtered).
|
|
19
19
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
20
|
-
* @returns the full
|
|
20
|
+
* @returns the full section text.
|
|
21
21
|
*/
|
|
22
22
|
export declare function renderConventions(entries: readonly MemoryEntry[], cap: number): string;
|
|
23
23
|
/**
|
|
24
|
-
* Render
|
|
25
|
-
* pitfalls` (empty sections omitted). Entry content is emitted
|
|
26
|
-
* pitfall extraction prompt guarantees the structured wording.
|
|
24
|
+
* Render the pitfalls text: `## Project pitfalls` / `## Environment &
|
|
25
|
+
* cross-project pitfalls` (empty sections omitted). Entry content is emitted
|
|
26
|
+
* verbatim — the pitfall extraction prompt guarantees the structured wording.
|
|
27
27
|
* @param entries - pitfall-kind entries (already filtered).
|
|
28
28
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
29
|
-
* @returns the full
|
|
29
|
+
* @returns the full section text.
|
|
30
30
|
*/
|
|
31
31
|
export declare function renderPitfalls(entries: readonly MemoryEntry[], cap: number): string;
|
|
32
32
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAE3D,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAE3D,sEAAsE;AACtE,eAAO,MAAM,WAAW,wIAAmI,CAAA;AA4B3J;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQtF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAOnF"}
|
package/lib/notes/render.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Markdown renderers for the project-notes
|
|
3
|
-
* through {@link isRenderedEntry}) become
|
|
4
|
-
*
|
|
2
|
+
* Markdown renderers for the project-notes prompt section: store entries
|
|
3
|
+
* (pre-filtered through {@link isRenderedEntry}) become the conventions /
|
|
4
|
+
* pitfalls texts injected into the system prompt. Pure functions — no I/O.
|
|
5
5
|
*
|
|
6
6
|
* Section order doubles as the precedence hint (project > global > personal);
|
|
7
7
|
* the injected system-prompt wrapper states it explicitly. Section headings
|
|
8
|
-
* are English regardless of entry language — the
|
|
8
|
+
* are English regardless of entry language — the notes surface is English.
|
|
9
9
|
*
|
|
10
10
|
* @module @chenhw7/dsh-memory/notes/render
|
|
11
11
|
*/
|
|
12
|
-
/** The
|
|
13
|
-
export const AUTO_HEADER = '
|
|
12
|
+
/** The provenance line stamped under every rendered section title. */
|
|
13
|
+
export const AUTO_HEADER = 'Managed by dsh-memory (auto-generated from the memory store) — correct outdated entries via the memory tools or the Memory UI.';
|
|
14
14
|
/** Format an epoch-ms timestamp as `YYYY-MM-DD`. */
|
|
15
15
|
function isoDate(ts) {
|
|
16
16
|
return new Date(ts).toISOString().slice(0, 10);
|
|
@@ -34,11 +34,11 @@ function byScope(entries, scope) {
|
|
|
34
34
|
return entries.filter(entry => entry.scope === scope);
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Render
|
|
38
|
-
* `## Personal habits` (empty sections omitted).
|
|
37
|
+
* Render the conventions text: `## Project conventions` / `## Global
|
|
38
|
+
* practices` / `## Personal habits` (empty sections omitted).
|
|
39
39
|
* @param entries - convention-kind entries (already filtered).
|
|
40
40
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
41
|
-
* @returns the full
|
|
41
|
+
* @returns the full section text.
|
|
42
42
|
*/
|
|
43
43
|
export function renderConventions(entries, cap) {
|
|
44
44
|
const capped = capEntries(entries, cap);
|
|
@@ -50,12 +50,12 @@ export function renderConventions(entries, cap) {
|
|
|
50
50
|
return `# Conventions\n\n${AUTO_HEADER}\n\n${parts.join('\n\n')}\n`;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Render
|
|
54
|
-
* pitfalls` (empty sections omitted). Entry content is emitted
|
|
55
|
-
* pitfall extraction prompt guarantees the structured wording.
|
|
53
|
+
* Render the pitfalls text: `## Project pitfalls` / `## Environment &
|
|
54
|
+
* cross-project pitfalls` (empty sections omitted). Entry content is emitted
|
|
55
|
+
* verbatim — the pitfall extraction prompt guarantees the structured wording.
|
|
56
56
|
* @param entries - pitfall-kind entries (already filtered).
|
|
57
57
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
58
|
-
* @returns the full
|
|
58
|
+
* @returns the full section text.
|
|
59
59
|
*/
|
|
60
60
|
export function renderPitfalls(entries, cap) {
|
|
61
61
|
const capped = capEntries(entries, cap);
|
package/lib/notes/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,sEAAsE;AACtE,MAAM,CAAC,MAAM,WAAW,GAAG,gIAAgI,CAAA;AAE3J,oDAAoD;AACpD,SAAS,OAAO,CAAC,EAAU;IACzB,OAAO,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC;AAED,0CAA0C;AAC1C,SAAS,MAAM,CAAC,KAAkB;IAChC,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAA;AAC3D,CAAC;AAED,sEAAsE;AACtE,SAAS,OAAO,CAAC,KAAa,EAAE,OAA+B;IAC7D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACnC,OAAO,MAAM,KAAK,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;AAC3D,CAAC;AAED,uEAAuE;AACvE,SAAS,UAAU,CAAC,OAA+B,EAAE,GAAW;IAC9D,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAA;IACrE,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AAChD,CAAC;AAED,SAAS,OAAO,CAAC,OAA+B,EAAE,KAAkB;IAClE,OAAO,OA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|
2
|
-
* The scope×category render matrix for project notes (§4
|
|
3
|
-
*
|
|
4
|
-
* Pure functions, zero host imports — shared
|
|
5
|
-
* `memory-context` (which excludes the same set
|
|
6
|
-
* injection so content never appears twice in
|
|
2
|
+
* The scope×category render matrix for project notes (TECH_DESIGN §7.4):
|
|
3
|
+
* which store entries land in the
|
|
4
|
+
* `project-notes` prompt section. Pure functions, zero host imports — shared
|
|
5
|
+
* by the notes renderer and by `memory-context` (which excludes the same set
|
|
6
|
+
* from its own snapshot/index injection so content never appears twice in
|
|
7
|
+
* the prompt).
|
|
7
8
|
*
|
|
8
9
|
* @module @chenhw7/dsh-memory/notes/scope
|
|
9
10
|
*/
|
|
10
11
|
import type { MemoryCategory, MemoryEntry } from '../types.ts';
|
|
11
|
-
/** Categories rendered
|
|
12
|
+
/** Categories rendered as conventions. */
|
|
12
13
|
export declare const NOTES_CONVENTION_CATEGORIES: readonly MemoryCategory[];
|
|
13
|
-
/** Categories rendered
|
|
14
|
+
/** Categories rendered as pitfalls (project- and global-scoped only). */
|
|
14
15
|
export declare const NOTES_PITFALL_CATEGORIES: readonly MemoryCategory[];
|
|
15
16
|
/** The minimal entry shape the matrix needs. */
|
|
16
17
|
export type RenderableEntry = Pick<MemoryEntry, 'scope' | 'category' | 'projectName'>;
|
|
17
18
|
/** Which notes file an entry renders into, when any. */
|
|
18
19
|
export type NotesKind = 'conventions' | 'pitfalls';
|
|
19
20
|
/**
|
|
20
|
-
* Decide whether an entry is rendered into the notes
|
|
21
|
-
*
|
|
21
|
+
* Decide whether an entry is rendered into the `project-notes` section, and
|
|
22
|
+
* into which half (conventions or pitfalls). Rules:
|
|
22
23
|
* - `project`-scoped entries must match the current project name; an unknown
|
|
23
24
|
* project (no cwd) excludes them.
|
|
24
25
|
* - Conventions come from all three scopes (project > global > personal is
|
|
@@ -29,7 +30,7 @@ export type NotesKind = 'conventions' | 'pitfalls';
|
|
|
29
30
|
*
|
|
30
31
|
* @param entry - the entry to classify.
|
|
31
32
|
* @param projectName - the current project name (cwd basename), or undefined.
|
|
32
|
-
* @returns the target
|
|
33
|
+
* @returns the target render half, or `undefined` when not rendered.
|
|
33
34
|
*/
|
|
34
35
|
export declare function isRenderedEntry(entry: RenderableEntry, projectName: string | undefined): NotesKind | undefined;
|
|
35
36
|
//# sourceMappingURL=scope.d.ts.map
|
package/lib/notes/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/notes/scope.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/notes/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9D,0CAA0C;AAC1C,eAAO,MAAM,2BAA2B,EAAE,SAAS,cAAc,EAAiC,CAAA;AAElG,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,EAAE,SAAS,cAAc,EAA2C,CAAA;AAEzG,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC,CAAA;AAErF,wDAAwD;AACxD,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,CAAA;AAElD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAY9G"}
|
package/lib/notes/scope.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The scope×category render matrix for project notes (§4
|
|
3
|
-
*
|
|
4
|
-
* Pure functions, zero host imports — shared
|
|
5
|
-
* `memory-context` (which excludes the same set
|
|
6
|
-
* injection so content never appears twice in
|
|
2
|
+
* The scope×category render matrix for project notes (TECH_DESIGN §7.4):
|
|
3
|
+
* which store entries land in the
|
|
4
|
+
* `project-notes` prompt section. Pure functions, zero host imports — shared
|
|
5
|
+
* by the notes renderer and by `memory-context` (which excludes the same set
|
|
6
|
+
* from its own snapshot/index injection so content never appears twice in
|
|
7
|
+
* the prompt).
|
|
7
8
|
*
|
|
8
9
|
* @module @chenhw7/dsh-memory/notes/scope
|
|
9
10
|
*/
|
|
10
|
-
/** Categories rendered
|
|
11
|
+
/** Categories rendered as conventions. */
|
|
11
12
|
export const NOTES_CONVENTION_CATEGORIES = ['convention', 'preference'];
|
|
12
|
-
/** Categories rendered
|
|
13
|
+
/** Categories rendered as pitfalls (project- and global-scoped only). */
|
|
13
14
|
export const NOTES_PITFALL_CATEGORIES = ['failure', 'procedure', 'tool-quirk'];
|
|
14
15
|
/**
|
|
15
|
-
* Decide whether an entry is rendered into the notes
|
|
16
|
-
*
|
|
16
|
+
* Decide whether an entry is rendered into the `project-notes` section, and
|
|
17
|
+
* into which half (conventions or pitfalls). Rules:
|
|
17
18
|
* - `project`-scoped entries must match the current project name; an unknown
|
|
18
19
|
* project (no cwd) excludes them.
|
|
19
20
|
* - Conventions come from all three scopes (project > global > personal is
|
|
@@ -24,7 +25,7 @@ export const NOTES_PITFALL_CATEGORIES = ['failure', 'procedure', 'tool-quirk'];
|
|
|
24
25
|
*
|
|
25
26
|
* @param entry - the entry to classify.
|
|
26
27
|
* @param projectName - the current project name (cwd basename), or undefined.
|
|
27
|
-
* @returns the target
|
|
28
|
+
* @returns the target render half, or `undefined` when not rendered.
|
|
28
29
|
*/
|
|
29
30
|
export function isRenderedEntry(entry, projectName) {
|
|
30
31
|
const category = entry.category;
|
package/lib/notes/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/notes/scope.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/notes/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,0CAA0C;AAC1C,MAAM,CAAC,MAAM,2BAA2B,GAA8B,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;AAElG,yEAAyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAA8B,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC,CAAA;AAQzG;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,KAAsB,EAAE,WAA+B;IACrF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;IAC/B,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC5C,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAA;IAC3C,IAAI,SAAS,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC;QAAE,OAAO,SAAS,CAAA;IACnG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,2BAA2B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxH,OAAO,aAAa,CAAA;IACtB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3F,OAAO,UAAU,CAAA;IACnB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/lib/notes/settings.d.ts
CHANGED
|
@@ -5,41 +5,30 @@
|
|
|
5
5
|
* ownership) and the `memory-notes` plugin (defensive reads of the raw
|
|
6
6
|
* namespace value via `ctx.settings.get`).
|
|
7
7
|
*
|
|
8
|
+
* Since 0.6 the notes surface is prompt-only (no repo files), so there is no
|
|
9
|
+
* directory or AGENTS.md knob anymore — `notesEnabled` gates the injected
|
|
10
|
+
* `project-notes` section and the two budget keys cap its render.
|
|
11
|
+
*
|
|
8
12
|
* @module @chenhw7/dsh-memory/notes/settings
|
|
9
13
|
*/
|
|
10
|
-
/** Whether notes
|
|
14
|
+
/** Whether the project-notes prompt section is injected. */
|
|
11
15
|
export declare const DEFAULT_NOTES_ENABLED = true;
|
|
12
|
-
/**
|
|
13
|
-
export declare const DEFAULT_NOTES_DIR = "docs/agent-memory";
|
|
14
|
-
/** Total character budget for the injected notes section. */
|
|
16
|
+
/** Character budget for the injected project-notes section. */
|
|
15
17
|
export declare const DEFAULT_NOTES_CHAR_LIMIT = 4000;
|
|
16
|
-
/**
|
|
17
|
-
export declare const DEFAULT_NOTES_AGENTS_POINTER = true;
|
|
18
|
-
/** Max entries per generated file (oldest by updatedAt are truncated). */
|
|
18
|
+
/** Max entries rendered into the project-notes section (oldest by updatedAt are truncated). */
|
|
19
19
|
export declare const DEFAULT_NOTES_MAX_ENTRIES_PER_FILE = 100;
|
|
20
20
|
/** The notes slice of the `memory` settings namespace, fully resolved. */
|
|
21
21
|
export interface NotesSettings {
|
|
22
22
|
readonly notesEnabled: boolean;
|
|
23
|
-
readonly notesDir: string;
|
|
24
23
|
readonly notesCharLimit: number;
|
|
25
|
-
readonly notesAgentsPointer: boolean;
|
|
26
24
|
readonly notesMaxEntriesPerFile: number;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* Resolve the notes settings from an untyped namespace value (defaults for
|
|
30
|
-
* anything absent or mistyped).
|
|
28
|
+
* anything absent or mistyped). Unknown keys — including the pre-0.6
|
|
29
|
+
* `notesDir` / `notesAgentsPointer` — are ignored.
|
|
31
30
|
* @param value - the raw `memory` namespace value (`ctx.settings.get` returns `unknown`).
|
|
32
31
|
* @returns the fully-resolved notes settings.
|
|
33
32
|
*/
|
|
34
33
|
export declare function resolveNotesSettings(value: unknown): NotesSettings;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve `notesDir` against the project root, requiring containment: absolute
|
|
37
|
-
* values and `../`-style escapes resolve outside the root and are rejected, so
|
|
38
|
-
* a mistyped or hostile settings value cannot direct notes writes out of the
|
|
39
|
-
* project. Lexical check only — symlinks are not resolved.
|
|
40
|
-
* @param cwd - the project root (session working directory).
|
|
41
|
-
* @param notesDir - the settings value (repo-relative by convention).
|
|
42
|
-
* @returns the absolute contained directory, or undefined when rejected.
|
|
43
|
-
*/
|
|
44
|
-
export declare function resolveNotesDir(cwd: string, notesDir: string): string | undefined;
|
|
45
34
|
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB,OAAO,CAAA;AACzC,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAC5C,+FAA+F;AAC/F,eAAO,MAAM,kCAAkC,MAAM,CAAA;AAErD,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;CACxC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAOlE"}
|
package/lib/notes/settings.js
CHANGED
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
* ownership) and the `memory-notes` plugin (defensive reads of the raw
|
|
6
6
|
* namespace value via `ctx.settings.get`).
|
|
7
7
|
*
|
|
8
|
+
* Since 0.6 the notes surface is prompt-only (no repo files), so there is no
|
|
9
|
+
* directory or AGENTS.md knob anymore — `notesEnabled` gates the injected
|
|
10
|
+
* `project-notes` section and the two budget keys cap its render.
|
|
11
|
+
*
|
|
8
12
|
* @module @chenhw7/dsh-memory/notes/settings
|
|
9
13
|
*/
|
|
10
|
-
|
|
11
|
-
/** Whether notes export + injection are enabled. */
|
|
14
|
+
/** Whether the project-notes prompt section is injected. */
|
|
12
15
|
export const DEFAULT_NOTES_ENABLED = true;
|
|
13
|
-
/**
|
|
14
|
-
export const DEFAULT_NOTES_DIR = 'docs/agent-memory';
|
|
15
|
-
/** Total character budget for the injected notes section. */
|
|
16
|
+
/** Character budget for the injected project-notes section. */
|
|
16
17
|
export const DEFAULT_NOTES_CHAR_LIMIT = 4000;
|
|
17
|
-
/**
|
|
18
|
-
export const DEFAULT_NOTES_AGENTS_POINTER = true;
|
|
19
|
-
/** Max entries per generated file (oldest by updatedAt are truncated). */
|
|
18
|
+
/** Max entries rendered into the project-notes section (oldest by updatedAt are truncated). */
|
|
20
19
|
export const DEFAULT_NOTES_MAX_ENTRIES_PER_FILE = 100;
|
|
21
20
|
/**
|
|
22
21
|
* Resolve the notes settings from an untyped namespace value (defaults for
|
|
23
|
-
* anything absent or mistyped).
|
|
22
|
+
* anything absent or mistyped). Unknown keys — including the pre-0.6
|
|
23
|
+
* `notesDir` / `notesAgentsPointer` — are ignored.
|
|
24
24
|
* @param value - the raw `memory` namespace value (`ctx.settings.get` returns `unknown`).
|
|
25
25
|
* @returns the fully-resolved notes settings.
|
|
26
26
|
*/
|
|
@@ -28,26 +28,8 @@ export function resolveNotesSettings(value) {
|
|
|
28
28
|
const v = (typeof value === 'object' && value !== null ? value : {});
|
|
29
29
|
return {
|
|
30
30
|
notesEnabled: typeof v.notesEnabled === 'boolean' ? v.notesEnabled : DEFAULT_NOTES_ENABLED,
|
|
31
|
-
notesDir: typeof v.notesDir === 'string' && v.notesDir.trim().length > 0 ? v.notesDir.trim() : DEFAULT_NOTES_DIR,
|
|
32
31
|
notesCharLimit: typeof v.notesCharLimit === 'number' && v.notesCharLimit >= 0 ? Math.trunc(v.notesCharLimit) : DEFAULT_NOTES_CHAR_LIMIT,
|
|
33
|
-
notesAgentsPointer: typeof v.notesAgentsPointer === 'boolean' ? v.notesAgentsPointer : DEFAULT_NOTES_AGENTS_POINTER,
|
|
34
32
|
notesMaxEntriesPerFile: typeof v.notesMaxEntriesPerFile === 'number' && v.notesMaxEntriesPerFile >= 0 ? Math.trunc(v.notesMaxEntriesPerFile) : DEFAULT_NOTES_MAX_ENTRIES_PER_FILE,
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Resolve `notesDir` against the project root, requiring containment: absolute
|
|
39
|
-
* values and `../`-style escapes resolve outside the root and are rejected, so
|
|
40
|
-
* a mistyped or hostile settings value cannot direct notes writes out of the
|
|
41
|
-
* project. Lexical check only — symlinks are not resolved.
|
|
42
|
-
* @param cwd - the project root (session working directory).
|
|
43
|
-
* @param notesDir - the settings value (repo-relative by convention).
|
|
44
|
-
* @returns the absolute contained directory, or undefined when rejected.
|
|
45
|
-
*/
|
|
46
|
-
export function resolveNotesDir(cwd, notesDir) {
|
|
47
|
-
const root = path.resolve(cwd);
|
|
48
|
-
const dir = path.resolve(root, notesDir);
|
|
49
|
-
if (dir !== root && !dir.startsWith(root + path.sep))
|
|
50
|
-
return undefined;
|
|
51
|
-
return dir;
|
|
52
|
-
}
|
|
53
35
|
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AACzC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAA;AAC5C,+FAA+F;AAC/F,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAA;AASrD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAA4B,CAAA;IAC/F,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,qBAAqB;QAC1F,cAAc,EAAE,OAAO,CAAC,CAAC,cAAc,KAAK,QAAQ,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,wBAAwB;QACvI,sBAAsB,EAAE,OAAO,CAAC,CAAC,sBAAsB,KAAK,QAAQ,IAAI,CAAC,CAAC,sBAAsB,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,kCAAkC;KAClL,CAAA;AACH,CAAC"}
|