@chenhw7/dsh-memory 0.9.1 → 0.9.3
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 -2
- package/README.md +70 -20
- package/README.zh.md +70 -20
- package/cordis.patch.yml +11 -4
- package/lib/benchmark/index.d.ts +1 -1
- package/lib/benchmark/index.d.ts.map +1 -1
- package/lib/client/index.js +388 -58
- package/lib/context/index.d.ts +93 -18
- package/lib/context/index.d.ts.map +1 -1
- package/lib/context/index.js +331 -71
- package/lib/context/index.js.map +1 -1
- package/lib/context/policy.d.ts +72 -11
- package/lib/context/policy.d.ts.map +1 -1
- package/lib/context/policy.js +250 -16
- package/lib/context/policy.js.map +1 -1
- package/lib/identity/index.d.ts +74 -0
- package/lib/identity/index.d.ts.map +1 -0
- package/lib/identity/index.js +150 -0
- package/lib/identity/index.js.map +1 -0
- package/lib/identity/seeds.d.ts +52 -0
- package/lib/identity/seeds.d.ts.map +1 -0
- package/lib/identity/seeds.js +130 -0
- package/lib/identity/seeds.js.map +1 -0
- package/lib/identity/settings.d.ts +32 -0
- package/lib/identity/settings.d.ts.map +1 -0
- package/lib/identity/settings.js +33 -0
- package/lib/identity/settings.js.map +1 -0
- package/lib/index.d.ts +53 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +62 -1
- package/lib/index.js.map +1 -1
- package/lib/notes/index.d.ts +5 -2
- package/lib/notes/index.d.ts.map +1 -1
- package/lib/notes/index.js +26 -14
- package/lib/notes/index.js.map +1 -1
- package/lib/notes/render.d.ts +15 -3
- package/lib/notes/render.d.ts.map +1 -1
- package/lib/notes/render.js +110 -27
- package/lib/notes/render.js.map +1 -1
- package/lib/notes/settings.d.ts +27 -14
- package/lib/notes/settings.d.ts.map +1 -1
- package/lib/notes/settings.js +42 -13
- package/lib/notes/settings.js.map +1 -1
- package/lib/remote/index.d.ts +83 -1
- package/lib/remote/index.d.ts.map +1 -1
- package/lib/remote/index.js +93 -2
- package/lib/remote/index.js.map +1 -1
- package/lib/remote/typert.remote-client.d.ts +29 -1
- package/lib/remote/typert.remote-client.js +19 -0
- package/lib/remote/types.d.ts +1 -1
- package/lib/remote/types.d.ts.map +1 -1
- package/lib/review/extract.d.ts +12 -1
- package/lib/review/extract.d.ts.map +1 -1
- package/lib/review/extract.js +72 -2
- package/lib/review/extract.js.map +1 -1
- package/lib/store/identity-util.d.ts +12 -0
- package/lib/store/identity-util.d.ts.map +1 -0
- package/lib/store/identity-util.js +19 -0
- package/lib/store/identity-util.js.map +1 -0
- package/lib/store/index.d.ts +64 -13
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +246 -26
- package/lib/store/index.js.map +1 -1
- package/lib/store/sqlite.d.ts +24 -7
- package/lib/store/sqlite.d.ts.map +1 -1
- package/lib/store/sqlite.js +181 -13
- package/lib/store/sqlite.js.map +1 -1
- package/lib/tool/index.d.ts +4 -11
- package/lib/tool/index.d.ts.map +1 -1
- package/lib/tool/index.js +117 -3
- package/lib/tool/index.js.map +1 -1
- package/lib/types.d.ts +90 -2
- package/lib/types.d.ts.map +1 -1
- package/package.json +5 -1
package/lib/notes/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { Context } from '@deepseek-ai/cordis';
|
|
|
17
17
|
export { isRenderedEntry } from './scope.ts';
|
|
18
18
|
export { renderConventions, renderPitfalls } from './render.ts';
|
|
19
19
|
export { cleanupLegacyNotesArtifacts, stripAgentsPointerBlock, AGENTS_POINTER_BEGIN, AGENTS_POINTER_END, LEGACY_NOTES_DIR } from './cleanup.ts';
|
|
20
|
-
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED,
|
|
20
|
+
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED, DEFAULT_NOTES_CONVENTIONS_CHAR_LIMIT, DEFAULT_NOTES_PITFALLS_CHAR_LIMIT, DEFAULT_NOTES_MAX_ENTRIES_PER_FILE } from './settings.ts';
|
|
21
21
|
export type { NotesSettings } from './settings.ts';
|
|
22
22
|
/** Cordis plugin name. */
|
|
23
23
|
export declare const name = "memory-notes";
|
|
@@ -45,7 +45,10 @@ export declare abstract class ProjectNotesService {
|
|
|
45
45
|
* Render and return the notes snapshot for a project root from the store.
|
|
46
46
|
* Idempotent and side-effect free. An undefined `cwd` means "no current
|
|
47
47
|
* project": project-scope entries drop out of the snapshot, but the
|
|
48
|
-
* global/user slices still render.
|
|
48
|
+
* global/user slices still render. The per-kind character budgets apply
|
|
49
|
+
* HERE — at render/freeze time — so a live budget change takes effect at
|
|
50
|
+
* the next snapshot (session/created or compaction/end), not per assembly;
|
|
51
|
+
* the section assembly's fence cap is the final defense.
|
|
49
52
|
* @param cwd - the session working directory (project root), or undefined.
|
|
50
53
|
* @returns the rendered snapshot; empty strings when disabled or unavailable.
|
|
51
54
|
*/
|
package/lib/notes/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAYlD,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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAYlD,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,oCAAoC,EAAE,iCAAiC,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAA;AACxL,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAElC,4EAA4E;AAC5E,eAAO,MAAM,MAAM,EAAE,MAAM,EAAO,CAAA;AAKlC;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAKD;;;GAGG;AACH,8BAAsB,mBAAmB;IACvC,cAIC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,oBAAoB,CAAA;CACpE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,YAAY,EAAE,mBAAmB,CAAA;KAClC;CACF;AAuDD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAmCxC"}
|
package/lib/notes/index.js
CHANGED
|
@@ -21,13 +21,13 @@ import { resolveNotesSettings } from './settings.js';
|
|
|
21
21
|
export { isRenderedEntry } from './scope.js';
|
|
22
22
|
export { renderConventions, renderPitfalls } from './render.js';
|
|
23
23
|
export { cleanupLegacyNotesArtifacts, stripAgentsPointerBlock, AGENTS_POINTER_BEGIN, AGENTS_POINTER_END, LEGACY_NOTES_DIR } from './cleanup.js';
|
|
24
|
-
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED,
|
|
24
|
+
export { resolveNotesSettings, DEFAULT_NOTES_ENABLED, DEFAULT_NOTES_CONVENTIONS_CHAR_LIMIT, DEFAULT_NOTES_PITFALLS_CHAR_LIMIT, DEFAULT_NOTES_MAX_ENTRIES_PER_FILE } from './settings.js';
|
|
25
25
|
/** Cordis plugin name. */
|
|
26
26
|
export const name = 'memory-notes';
|
|
27
27
|
/** Nothing is required: `memory` and `settings` are accessed optionally. */
|
|
28
28
|
export const inject = [];
|
|
29
|
-
/** The settings namespace owned by `memory-context
|
|
30
|
-
const
|
|
29
|
+
/** The notes settings namespace (owned by `memory-context`), read here defensively. */
|
|
30
|
+
const NOTES_NS = 'memory-notes';
|
|
31
31
|
/** The empty snapshot. */
|
|
32
32
|
const EMPTY_SNAPSHOT = { conventions: '', pitfalls: '' };
|
|
33
33
|
/**
|
|
@@ -85,8 +85,8 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
85
85
|
pitfalls.push(entry);
|
|
86
86
|
}
|
|
87
87
|
return {
|
|
88
|
-
conventions: renderConventions(conventions, settings.notesMaxEntriesPerFile),
|
|
89
|
-
pitfalls: renderPitfalls(pitfalls, settings.notesMaxEntriesPerFile),
|
|
88
|
+
conventions: renderConventions(conventions, settings.notesMaxEntriesPerFile, settings.notesConventionsCharLimit),
|
|
89
|
+
pitfalls: renderPitfalls(pitfalls, settings.notesMaxEntriesPerFile, settings.notesPitfallsCharLimit),
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
catch (error) {
|
|
@@ -102,15 +102,27 @@ class ProjectNotesServiceImpl extends ProjectNotesService {
|
|
|
102
102
|
* @param ctx - Cordis context.
|
|
103
103
|
*/
|
|
104
104
|
export function apply(ctx) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
// Settings read through a settings-injected fiber (the identity plugin's
|
|
106
|
+
// pattern): a plain `ctx.settings` access on this fiber throws "cannot get
|
|
107
|
+
// property without inject" whenever the service is present, and the silent
|
|
108
|
+
// `resolveNotesSettings(undefined)` fallback would pin the service to the
|
|
109
|
+
// builtin budgets forever — load-bearing since the budgets apply at
|
|
110
|
+
// snapshot (freeze) time. The stable indirection re-reads the variable per
|
|
111
|
+
// call, so the inject callback's reassignment takes effect mid-flight.
|
|
112
|
+
let readSettings = () => resolveNotesSettings(undefined);
|
|
113
|
+
ctx.inject(['settings'], (sctx) => {
|
|
114
|
+
readSettings = () => {
|
|
115
|
+
try {
|
|
116
|
+
return resolveNotesSettings(sctx.settings.get(NOTES_NS));
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Namespace not registered yet (or the provider tore down) — the
|
|
120
|
+
// builtin defaults stand until it registers.
|
|
121
|
+
return resolveNotesSettings(undefined);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const service = new ProjectNotesServiceImpl(ctx, () => readSettings());
|
|
114
126
|
ctx.provide('projectNotes', service);
|
|
115
127
|
// One-time migration: strip the file-export artifacts a ≤0.5.x install
|
|
116
128
|
// left in this project (marker-managed AGENTS.md block, generated notes
|
package/lib/notes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,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(pre-filtered through {@link isRenderedEntry}) become the conventions /
|
|
4
4
|
* pitfalls texts injected into the system prompt. Pure functions — no I/O.
|
|
5
5
|
*
|
|
6
|
+
* Selection is entry-level and budgeted at render time (frozen with the
|
|
7
|
+
* snapshot — a live budget change takes effect at the next freeze, and the
|
|
8
|
+
* section assembly's fence cap is the final defense). Entries the budget or
|
|
9
|
+
* the count cap squeeze out fold into a per-section count line pointing at
|
|
10
|
+
* memory_search — never silently dropped.
|
|
11
|
+
*
|
|
6
12
|
* Section order doubles as the precedence hint (project > global > personal);
|
|
7
13
|
* the injected system-prompt wrapper states it explicitly. Section headings
|
|
8
14
|
* are English regardless of entry language — the notes surface is English.
|
|
@@ -14,19 +20,25 @@ import type { MemoryEntry } from '../types.ts';
|
|
|
14
20
|
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
21
|
/**
|
|
16
22
|
* Render the conventions text: `## Project conventions` / `## Global
|
|
17
|
-
* practices` / `## Personal habits` (empty sections omitted).
|
|
23
|
+
* practices` / `## Personal habits` (empty sections omitted). Entries are
|
|
24
|
+
* selected under the conventions budget in priority order; squeezed entries
|
|
25
|
+
* fold into per-section count lines.
|
|
18
26
|
* @param entries - convention-kind entries (already filtered).
|
|
19
27
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
28
|
+
* @param charLimit - the conventions half's character budget (`0` → empty).
|
|
20
29
|
* @returns the full section text.
|
|
21
30
|
*/
|
|
22
|
-
export declare function renderConventions(entries: readonly MemoryEntry[], cap: number): string;
|
|
31
|
+
export declare function renderConventions(entries: readonly MemoryEntry[], cap: number, charLimit: number): string;
|
|
23
32
|
/**
|
|
24
33
|
* Render the pitfalls text: `## Project pitfalls` / `## Environment &
|
|
25
34
|
* cross-project pitfalls` (empty sections omitted). Entry content is emitted
|
|
26
35
|
* verbatim — the pitfall extraction prompt guarantees the structured wording.
|
|
36
|
+
* Entries are selected under the pitfalls budget in priority order; squeezed
|
|
37
|
+
* entries fold into per-section count lines.
|
|
27
38
|
* @param entries - pitfall-kind entries (already filtered).
|
|
28
39
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
40
|
+
* @param charLimit - the pitfalls half's character budget (`0` → empty).
|
|
29
41
|
* @returns the full section text.
|
|
30
42
|
*/
|
|
31
|
-
export declare function renderPitfalls(entries: readonly MemoryEntry[], cap: number): string;
|
|
43
|
+
export declare function renderPitfalls(entries: readonly MemoryEntry[], cap: number, charLimit: number): string;
|
|
32
44
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAE3D,sEAAsE;AACtE,eAAO,MAAM,WAAW,wIAAmI,CAAA;AA+G3J;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMzG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKtG"}
|
package/lib/notes/render.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* (pre-filtered through {@link isRenderedEntry}) become the conventions /
|
|
4
4
|
* pitfalls texts injected into the system prompt. Pure functions — no I/O.
|
|
5
5
|
*
|
|
6
|
+
* Selection is entry-level and budgeted at render time (frozen with the
|
|
7
|
+
* snapshot — a live budget change takes effect at the next freeze, and the
|
|
8
|
+
* section assembly's fence cap is the final defense). Entries the budget or
|
|
9
|
+
* the count cap squeeze out fold into a per-section count line pointing at
|
|
10
|
+
* memory_search — never silently dropped.
|
|
11
|
+
*
|
|
6
12
|
* Section order doubles as the precedence hint (project > global > personal);
|
|
7
13
|
* the injected system-prompt wrapper states it explicitly. Section headings
|
|
8
14
|
* are English regardless of entry language — the notes surface is English.
|
|
@@ -19,50 +25,127 @@ function isoDate(ts) {
|
|
|
19
25
|
function bullet(entry) {
|
|
20
26
|
return `- (${isoDate(entry.createdAt)}) ${entry.content}`;
|
|
21
27
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Selection priority for notes rendering: pinned entries first, then the
|
|
30
|
+
* model-assessed importance (absent reads as 0), then the freshest use
|
|
31
|
+
* signal. Importance outranks recency so a key convention that rarely
|
|
32
|
+
* matches queries is not the first to fold — query luck should not decide
|
|
33
|
+
* which standing rules stay visible.
|
|
34
|
+
*/
|
|
35
|
+
function byNotesPriority(a, b) {
|
|
36
|
+
return (b.pinned === true ? 1 : 0) - (a.pinned === true ? 1 : 0)
|
|
37
|
+
|| (b.importance ?? 0) - (a.importance ?? 0)
|
|
38
|
+
|| (b.lastRecalledAt ?? b.updatedAt) - (a.lastRecalledAt ?? a.updatedAt);
|
|
27
39
|
}
|
|
28
|
-
/**
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
return cap > 0 ? sorted.slice(0, cap) : sorted;
|
|
40
|
+
/** The per-section count line for squeezed entries — visible, never dropped. */
|
|
41
|
+
function foldedLine(folded, title) {
|
|
42
|
+
return `(another ${folded} ${title.toLowerCase()} — use memory_search)`;
|
|
32
43
|
}
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Render one notes document (`# <docTitle>` + AUTO_HEADER + the scope
|
|
46
|
+
* sections) from priority-ordered entries under a character budget: entries
|
|
47
|
+
* are added in priority order while they fit; the rest — including anything
|
|
48
|
+
* the count cap dropped — fold into their section's count line.
|
|
49
|
+
* @param docTitle - the document heading (`Conventions` / `Pitfalls`).
|
|
50
|
+
* @param sections - the scope sections in render order (precedence hint).
|
|
51
|
+
* @param entries - one kind's entries (already filtered by the matrix).
|
|
52
|
+
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
53
|
+
* @param charLimit - character budget for the rendered text (`0` → empty).
|
|
54
|
+
* @returns the document text; empty when the kind has no entries.
|
|
55
|
+
*/
|
|
56
|
+
function renderBudgeted(docTitle, sections, entries, cap, charLimit) {
|
|
57
|
+
if (charLimit <= 0 || entries.length === 0)
|
|
58
|
+
return '';
|
|
59
|
+
const docHeader = `# ${docTitle}\n\n${AUTO_HEADER}\n\n`;
|
|
60
|
+
const sectionScopes = new Set(sections.map(spec => spec.scope));
|
|
61
|
+
const ordered = [...entries].sort(byNotesPriority);
|
|
62
|
+
const capped = cap > 0 ? ordered.slice(0, cap) : ordered;
|
|
63
|
+
// The cap already dropped these; they fold regardless of the char budget.
|
|
64
|
+
const overflow = ordered.slice(capped.length);
|
|
65
|
+
// Render the first `selectCount` capped entries (priority order) as bullets
|
|
66
|
+
// and fold everything else — later capped entries plus the cap overflow —
|
|
67
|
+
// into per-section count lines. The returned text is the exact section, so
|
|
68
|
+
// its length counts the headings AND the fold lines: the budget check below
|
|
69
|
+
// is therefore a real cap, not a body-only estimate a later slice corrects.
|
|
70
|
+
const renderFor = (selectCount) => {
|
|
71
|
+
const bullets = new Map();
|
|
72
|
+
const folded = new Map();
|
|
73
|
+
for (let i = 0; i < capped.length; i++) {
|
|
74
|
+
const entry = capped[i];
|
|
75
|
+
// Scope without a section in this document (the caller pre-filters via
|
|
76
|
+
// the matrix; anything else here has no render home).
|
|
77
|
+
if (!sectionScopes.has(entry.scope))
|
|
78
|
+
continue;
|
|
79
|
+
if (i < selectCount) {
|
|
80
|
+
const list = bullets.get(entry.scope) ?? [];
|
|
81
|
+
list.push(bullet(entry));
|
|
82
|
+
bullets.set(entry.scope, list);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
folded.set(entry.scope, (folded.get(entry.scope) ?? 0) + 1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const entry of overflow) {
|
|
89
|
+
if (!sectionScopes.has(entry.scope))
|
|
90
|
+
continue;
|
|
91
|
+
folded.set(entry.scope, (folded.get(entry.scope) ?? 0) + 1);
|
|
92
|
+
}
|
|
93
|
+
const parts = [];
|
|
94
|
+
for (const spec of sections) {
|
|
95
|
+
const lines = [...(bullets.get(spec.scope) ?? [])];
|
|
96
|
+
const count = folded.get(spec.scope) ?? 0;
|
|
97
|
+
if (lines.length === 0 && count === 0)
|
|
98
|
+
continue;
|
|
99
|
+
if (count > 0)
|
|
100
|
+
lines.push(foldedLine(count, spec.title));
|
|
101
|
+
parts.push(`## ${spec.title}\n\n${lines.join('\n')}`);
|
|
102
|
+
}
|
|
103
|
+
return parts.length === 0 ? '' : `${docHeader}${parts.join('\n\n')}\n`;
|
|
104
|
+
};
|
|
105
|
+
// Promoting a folded entry to a bullet only grows the render (the bullet
|
|
106
|
+
// outweighs the fold-count digit it removes), so the largest prefix that
|
|
107
|
+
// fits is the best selection: scan upward, keep the last one within budget.
|
|
108
|
+
let best = '';
|
|
109
|
+
for (let selectCount = 0; selectCount <= capped.length; selectCount++) {
|
|
110
|
+
const text = renderFor(selectCount);
|
|
111
|
+
if (text.length > charLimit)
|
|
112
|
+
break;
|
|
113
|
+
best = text;
|
|
114
|
+
}
|
|
115
|
+
return best;
|
|
35
116
|
}
|
|
36
117
|
/**
|
|
37
118
|
* Render the conventions text: `## Project conventions` / `## Global
|
|
38
|
-
* practices` / `## Personal habits` (empty sections omitted).
|
|
119
|
+
* practices` / `## Personal habits` (empty sections omitted). Entries are
|
|
120
|
+
* selected under the conventions budget in priority order; squeezed entries
|
|
121
|
+
* fold into per-section count lines.
|
|
39
122
|
* @param entries - convention-kind entries (already filtered).
|
|
40
123
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
124
|
+
* @param charLimit - the conventions half's character budget (`0` → empty).
|
|
41
125
|
* @returns the full section text.
|
|
42
126
|
*/
|
|
43
|
-
export function renderConventions(entries, cap) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
].filter(text => text.length > 0);
|
|
50
|
-
return `# Conventions\n\n${AUTO_HEADER}\n\n${parts.join('\n\n')}\n`;
|
|
127
|
+
export function renderConventions(entries, cap, charLimit) {
|
|
128
|
+
return renderBudgeted('Conventions', [
|
|
129
|
+
{ title: 'Project conventions', scope: 'project' },
|
|
130
|
+
{ title: 'Global practices', scope: 'global' },
|
|
131
|
+
{ title: 'Personal habits', scope: 'user' },
|
|
132
|
+
], entries, cap, charLimit);
|
|
51
133
|
}
|
|
52
134
|
/**
|
|
53
135
|
* Render the pitfalls text: `## Project pitfalls` / `## Environment &
|
|
54
136
|
* cross-project pitfalls` (empty sections omitted). Entry content is emitted
|
|
55
137
|
* verbatim — the pitfall extraction prompt guarantees the structured wording.
|
|
138
|
+
* Entries are selected under the pitfalls budget in priority order; squeezed
|
|
139
|
+
* entries fold into per-section count lines.
|
|
56
140
|
* @param entries - pitfall-kind entries (already filtered).
|
|
57
141
|
* @param cap - max total entries (`notesMaxEntriesPerFile`); `0` = unlimited.
|
|
142
|
+
* @param charLimit - the pitfalls half's character budget (`0` → empty).
|
|
58
143
|
* @returns the full section text.
|
|
59
144
|
*/
|
|
60
|
-
export function renderPitfalls(entries, cap) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
].filter(text => text.length > 0);
|
|
66
|
-
return `# Pitfalls\n\n${AUTO_HEADER}\n\n${parts.join('\n\n')}\n`;
|
|
145
|
+
export function renderPitfalls(entries, cap, charLimit) {
|
|
146
|
+
return renderBudgeted('Pitfalls', [
|
|
147
|
+
{ title: 'Project pitfalls', scope: 'project' },
|
|
148
|
+
{ title: 'Environment & cross-project pitfalls', scope: 'global' },
|
|
149
|
+
], entries, cap, charLimit);
|
|
67
150
|
}
|
|
68
151
|
//# sourceMappingURL=render.js.map
|
package/lib/notes/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/notes/render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;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;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,CAAc,EAAE,CAAc;IACrD,OAAO,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;WAC3D,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC;WACzC,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,CAAC,SAAS,CAAC,CAAA;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cAAc,CAAC,OAA+B,EAAE,GAAW,EAAE,SAAiB;IAC5F,OAAO,cAAc,CAAC,UAAU,EAAE;QAChC,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,EAAE;QAC/C,EAAE,KAAK,EAAE,sCAAsC,EAAE,KAAK,EAAE,QAAQ,EAAE;KACnE,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;AAC7B,CAAC"}
|
package/lib/notes/settings.d.ts
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Defaults and the read-side view for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* namespace value via `ctx.settings.get`).
|
|
2
|
+
* Defaults and the read-side view for the `memory-notes` settings namespace.
|
|
3
|
+
* Both consumers pull from here so defaults cannot drift: `memory-context`'s
|
|
4
|
+
* notes schema and section assembly, and the `memory-notes` plugin (defensive
|
|
5
|
+
* reads of the raw namespace value via `ctx.settings.get`).
|
|
7
6
|
*
|
|
8
7
|
* Since 0.6 the notes surface is prompt-only (no repo files), so there is no
|
|
9
8
|
* directory or AGENTS.md knob anymore — `notesEnabled` gates the injected
|
|
10
|
-
* `project-notes` section and the
|
|
9
|
+
* `project-notes` section and the budget keys cap its render.
|
|
10
|
+
*
|
|
11
|
+
* The budgets are per-kind (`notesConventionsCharLimit` /
|
|
12
|
+
* `notesPitfallsCharLimit`) so the pitfall log can no longer be starved by the
|
|
13
|
+
* conventions half. Their schema fields carry NO default on purpose: absence
|
|
14
|
+
* is the signal the deprecated-key fallback below reads, so the builtin
|
|
15
|
+
* defaults live here — the one home. The deprecated combined
|
|
16
|
+
* `notesCharLimit` (released in v0.9.1) still derives both budgets at 60/40
|
|
17
|
+
* when it is the only key set; schemastery's non-strict object merge passes
|
|
18
|
+
* the unknown key through, so stored documents still read.
|
|
11
19
|
*
|
|
12
20
|
* @module @chenhw7/dsh-memory/notes/settings
|
|
13
21
|
*/
|
|
14
22
|
/** Whether the project-notes prompt section is injected. */
|
|
15
23
|
export declare const DEFAULT_NOTES_ENABLED = true;
|
|
16
|
-
/** Character budget for the
|
|
17
|
-
export declare const
|
|
18
|
-
/**
|
|
24
|
+
/** Character budget for the rendered conventions half of the notes section. */
|
|
25
|
+
export declare const DEFAULT_NOTES_CONVENTIONS_CHAR_LIMIT = 1600;
|
|
26
|
+
/** Character budget for the rendered pitfalls half of the notes section. */
|
|
27
|
+
export declare const DEFAULT_NOTES_PITFALLS_CHAR_LIMIT = 800;
|
|
28
|
+
/** Max entries selected into the project-notes section (the rest fold into count lines). */
|
|
19
29
|
export declare const DEFAULT_NOTES_MAX_ENTRIES_PER_FILE = 100;
|
|
20
|
-
/** The
|
|
30
|
+
/** The `memory-notes` settings namespace, fully resolved. */
|
|
21
31
|
export interface NotesSettings {
|
|
22
32
|
readonly notesEnabled: boolean;
|
|
23
|
-
readonly
|
|
33
|
+
readonly notesConventionsCharLimit: number;
|
|
34
|
+
readonly notesPitfallsCharLimit: number;
|
|
24
35
|
readonly notesMaxEntriesPerFile: number;
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* Resolve the notes settings from an untyped namespace value (defaults for
|
|
28
|
-
* anything absent or mistyped). Unknown keys —
|
|
29
|
-
* `notesDir` / `notesAgentsPointer`
|
|
30
|
-
*
|
|
39
|
+
* anything absent or mistyped). Unknown keys are ignored — except the
|
|
40
|
+
* deprecated pre-0.6 `notesDir` / `notesAgentsPointer` (still ignored) and
|
|
41
|
+
* the deprecated `notesCharLimit`, which derives the two budgets until the
|
|
42
|
+
* document is migrated to the new keys.
|
|
43
|
+
* @param value - the raw `memory-notes` namespace value (`ctx.settings.get` returns `unknown`).
|
|
31
44
|
* @returns the fully-resolved notes settings.
|
|
32
45
|
*/
|
|
33
46
|
export declare function resolveNotesSettings(value: unknown): NotesSettings;
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB,OAAO,CAAA;AACzC,+EAA+E;AAC/E,eAAO,MAAM,oCAAoC,OAAO,CAAA;AACxD,4EAA4E;AAC5E,eAAO,MAAM,iCAAiC,MAAM,CAAA;AACpD,4FAA4F;AAC5F,eAAO,MAAM,kCAAkC,MAAM,CAAA;AAIrD,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAA;IAC1C,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;IACvC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;CACxC;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAQlE"}
|
package/lib/notes/settings.js
CHANGED
|
@@ -1,34 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Defaults and the read-side view for the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* namespace value via `ctx.settings.get`).
|
|
2
|
+
* Defaults and the read-side view for the `memory-notes` settings namespace.
|
|
3
|
+
* Both consumers pull from here so defaults cannot drift: `memory-context`'s
|
|
4
|
+
* notes schema and section assembly, and the `memory-notes` plugin (defensive
|
|
5
|
+
* reads of the raw namespace value via `ctx.settings.get`).
|
|
7
6
|
*
|
|
8
7
|
* Since 0.6 the notes surface is prompt-only (no repo files), so there is no
|
|
9
8
|
* directory or AGENTS.md knob anymore — `notesEnabled` gates the injected
|
|
10
|
-
* `project-notes` section and the
|
|
9
|
+
* `project-notes` section and the budget keys cap its render.
|
|
10
|
+
*
|
|
11
|
+
* The budgets are per-kind (`notesConventionsCharLimit` /
|
|
12
|
+
* `notesPitfallsCharLimit`) so the pitfall log can no longer be starved by the
|
|
13
|
+
* conventions half. Their schema fields carry NO default on purpose: absence
|
|
14
|
+
* is the signal the deprecated-key fallback below reads, so the builtin
|
|
15
|
+
* defaults live here — the one home. The deprecated combined
|
|
16
|
+
* `notesCharLimit` (released in v0.9.1) still derives both budgets at 60/40
|
|
17
|
+
* when it is the only key set; schemastery's non-strict object merge passes
|
|
18
|
+
* the unknown key through, so stored documents still read.
|
|
11
19
|
*
|
|
12
20
|
* @module @chenhw7/dsh-memory/notes/settings
|
|
13
21
|
*/
|
|
14
22
|
/** Whether the project-notes prompt section is injected. */
|
|
15
23
|
export const DEFAULT_NOTES_ENABLED = true;
|
|
16
|
-
/** Character budget for the
|
|
17
|
-
export const
|
|
18
|
-
/**
|
|
24
|
+
/** Character budget for the rendered conventions half of the notes section. */
|
|
25
|
+
export const DEFAULT_NOTES_CONVENTIONS_CHAR_LIMIT = 1600;
|
|
26
|
+
/** Character budget for the rendered pitfalls half of the notes section. */
|
|
27
|
+
export const DEFAULT_NOTES_PITFALLS_CHAR_LIMIT = 800;
|
|
28
|
+
/** Max entries selected into the project-notes section (the rest fold into count lines). */
|
|
19
29
|
export const DEFAULT_NOTES_MAX_ENTRIES_PER_FILE = 100;
|
|
30
|
+
/** The deprecated combined budget's conventions share; pitfalls gets the rest. */
|
|
31
|
+
const DEPRECATED_CONVENTIONS_SHARE = 0.6;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve one budget: the new key wins when set; otherwise a present
|
|
34
|
+
* deprecated `notesCharLimit` derives both from its 60/40 split; otherwise
|
|
35
|
+
* the builtin default.
|
|
36
|
+
*/
|
|
37
|
+
function resolveBudget(value, key, share, fallback) {
|
|
38
|
+
const own = value[key];
|
|
39
|
+
if (typeof own === 'number' && own >= 0)
|
|
40
|
+
return Math.trunc(own);
|
|
41
|
+
if (typeof value.notesCharLimit === 'number' && value.notesCharLimit >= 0) {
|
|
42
|
+
return Math.trunc(value.notesCharLimit * share);
|
|
43
|
+
}
|
|
44
|
+
return fallback;
|
|
45
|
+
}
|
|
20
46
|
/**
|
|
21
47
|
* Resolve the notes settings from an untyped namespace value (defaults for
|
|
22
|
-
* anything absent or mistyped). Unknown keys —
|
|
23
|
-
* `notesDir` / `notesAgentsPointer`
|
|
24
|
-
*
|
|
48
|
+
* anything absent or mistyped). Unknown keys are ignored — except the
|
|
49
|
+
* deprecated pre-0.6 `notesDir` / `notesAgentsPointer` (still ignored) and
|
|
50
|
+
* the deprecated `notesCharLimit`, which derives the two budgets until the
|
|
51
|
+
* document is migrated to the new keys.
|
|
52
|
+
* @param value - the raw `memory-notes` namespace value (`ctx.settings.get` returns `unknown`).
|
|
25
53
|
* @returns the fully-resolved notes settings.
|
|
26
54
|
*/
|
|
27
55
|
export function resolveNotesSettings(value) {
|
|
28
56
|
const v = (typeof value === 'object' && value !== null ? value : {});
|
|
29
57
|
return {
|
|
30
58
|
notesEnabled: typeof v.notesEnabled === 'boolean' ? v.notesEnabled : DEFAULT_NOTES_ENABLED,
|
|
31
|
-
|
|
59
|
+
notesConventionsCharLimit: resolveBudget(v, 'notesConventionsCharLimit', DEPRECATED_CONVENTIONS_SHARE, DEFAULT_NOTES_CONVENTIONS_CHAR_LIMIT),
|
|
60
|
+
notesPitfallsCharLimit: resolveBudget(v, 'notesPitfallsCharLimit', 1 - DEPRECATED_CONVENTIONS_SHARE, DEFAULT_NOTES_PITFALLS_CHAR_LIMIT),
|
|
32
61
|
notesMaxEntriesPerFile: typeof v.notesMaxEntriesPerFile === 'number' && v.notesMaxEntriesPerFile >= 0 ? Math.trunc(v.notesMaxEntriesPerFile) : DEFAULT_NOTES_MAX_ENTRIES_PER_FILE,
|
|
33
62
|
};
|
|
34
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/notes/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":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