dsh-cross-memory 0.2.11 → 0.2.13
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/docs/DETAIL.md +5 -5
- package/docs/DETAIL.zh.md +5 -5
- package/lib/consolidate.js +41 -39
- package/lib/dense.js +2 -2
- package/lib/extract.js +39 -11
- package/lib/gate.js +35 -19
- package/lib/index.js +77 -48
- package/lib/mcp.js +328 -0
- package/lib/persona.js +99 -1
- package/lib/reflection.js +10 -1
- package/lib/storage.js +11 -1
- package/lib/sync.js +30 -14
- package/lib/test/archive.test.js +19 -0
- package/lib/test/consolidate.test.js +48 -10
- package/lib/test/extract.test.js +30 -1
- package/lib/test/loops.test.js +3 -2
- package/lib/test/mcp.test.js +98 -0
- package/lib/test/notices.test.js +67 -0
- package/lib/test/persona.test.js +40 -1
- package/lib/test/reflection.test.js +60 -1
- package/lib/test/subagent-contract.test.js +18 -12
- package/lib/tool.js +4 -3
- package/lib/types/consolidate.d.ts +34 -51
- package/lib/types/extract.d.ts +14 -0
- package/lib/types/gate.d.ts +4 -0
- package/lib/types/mcp.d.ts +183 -0
- package/lib/types/persona.d.ts +17 -0
- package/lib/types/sync.d.ts +6 -5
- package/lib/types/test/mcp.test.d.ts +1 -0
- package/package.json +8 -1
|
@@ -75,7 +75,7 @@ function descriptorOf(spec) {
|
|
|
75
75
|
/** A request naming a route and a preset, i.e. the common production case. */
|
|
76
76
|
function routedRequest() {
|
|
77
77
|
return {
|
|
78
|
-
parent: {},
|
|
78
|
+
parent: { id: 'agent-1' },
|
|
79
79
|
provider: 'test-provider',
|
|
80
80
|
model: 'test-model',
|
|
81
81
|
agentPreset: 'memories-consolidator',
|
|
@@ -91,7 +91,7 @@ function routedRequest() {
|
|
|
91
91
|
/** A request with no route and no preset: both optionals must be absent, not undefined. */
|
|
92
92
|
function bareRequest() {
|
|
93
93
|
return {
|
|
94
|
-
parent: {},
|
|
94
|
+
parent: { id: 'agent-1' },
|
|
95
95
|
entries: [],
|
|
96
96
|
projectLabel: 'demo',
|
|
97
97
|
maxUpserts: 3,
|
|
@@ -113,10 +113,11 @@ test('the label is a non-empty string, so the kernel never sees undefined', () =
|
|
|
113
113
|
});
|
|
114
114
|
test('a bare request omits optional fields instead of setting them to undefined', () => {
|
|
115
115
|
const spec = buildActivationSpec(bareRequest(), PROMPT, AbortSignal.timeout(1000));
|
|
116
|
-
assert.ok(!('agentOptions' in spec
|
|
117
|
-
assert.ok(!('agentPreset' in spec
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
assert.ok(!('agentOptions' in spec));
|
|
117
|
+
assert.ok(!('agentPreset' in spec));
|
|
118
|
+
assert.ok(!('request' in spec), 'the kernel takes a flat SubagentActivationSpec, never a nested request');
|
|
119
|
+
for (const [key, value] of Object.entries(spec)) {
|
|
120
|
+
assert.ok(value !== undefined, `spec.${key} is present but undefined`);
|
|
120
121
|
}
|
|
121
122
|
assert.doesNotThrow(() => assertLossless(descriptorOf(spec)));
|
|
122
123
|
});
|
|
@@ -133,15 +134,20 @@ test("the child's result is delivered to the caller, not announced to the parent
|
|
|
133
134
|
const spec = buildActivationSpec(routedRequest(), PROMPT, AbortSignal.timeout(1_000));
|
|
134
135
|
assert.equal(spec.delivery, 'caller');
|
|
135
136
|
});
|
|
136
|
-
test('the spec carries the
|
|
137
|
-
// The kernel
|
|
138
|
-
// `spec.
|
|
139
|
-
//
|
|
140
|
-
//
|
|
137
|
+
test('the spec carries the flattened SubagentActivationSpec fields at the top level', () => {
|
|
138
|
+
// The kernel reads `spec.signal`, `spec.parent.id`, `spec.prompt`,
|
|
139
|
+
// `spec.agentPreset`, `spec.outputSchema`, and `spec.maxDepth` at the top level.
|
|
140
|
+
// Nesting them under `spec.request` caused `Cannot read properties of undefined (reading 'id')`
|
|
141
|
+
// inside `startActivation` at `spec.parent.id`.
|
|
141
142
|
const timeout = AbortSignal.timeout(1_000);
|
|
142
143
|
const spec = buildActivationSpec(routedRequest(), PROMPT, timeout);
|
|
143
144
|
assert.equal(spec.signal, timeout, 'the top-level signal is the one the caller passed');
|
|
144
|
-
assert.equal(spec.
|
|
145
|
+
assert.equal(spec.parent.id, 'agent-1', 'spec.parent must be readable at the top level');
|
|
146
|
+
assert.deepEqual(spec.prompt, PROMPT);
|
|
147
|
+
assert.equal(spec.agentPreset, 'memories-consolidator');
|
|
148
|
+
assert.equal(spec.maxDepth, 1);
|
|
149
|
+
assert.ok(spec.outputSchema !== undefined);
|
|
150
|
+
assert.equal('request' in spec, false);
|
|
145
151
|
assert.equal(typeof spec.signal.throwIfAborted, 'function');
|
|
146
152
|
assert.doesNotThrow(() => spec.signal.throwIfAborted());
|
|
147
153
|
});
|
package/lib/tool.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @module dsh-cross-memory/tool
|
|
9
9
|
*/
|
|
10
10
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
11
|
+
import { redactSecrets } from './extract.js';
|
|
11
12
|
import { renderEntry, renderEvidence, renderHit } from './render.js';
|
|
12
13
|
/** The scopes the model may name. */
|
|
13
14
|
const SCOPES = ['global', 'project'];
|
|
@@ -166,12 +167,12 @@ export function registerMemoryTool(ctx, runtime) {
|
|
|
166
167
|
}
|
|
167
168
|
const result = await runtime.write(session, {
|
|
168
169
|
scope: args.scope,
|
|
169
|
-
title: title.slice(0, 120),
|
|
170
|
-
body,
|
|
170
|
+
title: redactSecrets(title).slice(0, 120),
|
|
171
|
+
body: redactSecrets(body),
|
|
171
172
|
tags: args.tags ?? [],
|
|
172
173
|
...args.kind === undefined ? {} : { kind: args.kind },
|
|
173
174
|
...args.keys === undefined ? {} : { keys: args.keys },
|
|
174
|
-
...args.appliesTo === undefined ? {} : { appliesTo: args.appliesTo },
|
|
175
|
+
...args.appliesTo === undefined ? {} : { appliesTo: redactSecrets(args.appliesTo) },
|
|
175
176
|
...args.durability === undefined ? {} : { durability: args.durability },
|
|
176
177
|
...asOf === undefined ? {} : { asOf },
|
|
177
178
|
...args.pinned === undefined ? {} : { pinned: args.pinned },
|
|
@@ -194,7 +194,10 @@ export interface ConsolidationPlan {
|
|
|
194
194
|
readonly persona?: string;
|
|
195
195
|
}
|
|
196
196
|
/** Render the input document handed to the consolidation agent. */
|
|
197
|
-
export declare function renderConsolidationInput(entries: readonly MemoryEntry[], projectLabel: string, currentPersona?: string
|
|
197
|
+
export declare function renderConsolidationInput(entries: readonly MemoryEntry[], projectLabel: string, currentPersona?: string, existingSkills?: readonly {
|
|
198
|
+
readonly name: string;
|
|
199
|
+
readonly description: string;
|
|
200
|
+
}[]): string;
|
|
198
201
|
/** Parse and validate the agent's JSON reply into a plan. */
|
|
199
202
|
export declare function parsePlan(text: string, knownIds: ReadonlySet<string>, maxUpserts: number): ConsolidationPlan | undefined;
|
|
200
203
|
/**
|
|
@@ -237,6 +240,11 @@ export interface ConsolidateRequest {
|
|
|
237
240
|
readonly entries: readonly MemoryEntry[];
|
|
238
241
|
/** The profile as it stands, so the pass refines it rather than re-inventing it. */
|
|
239
242
|
readonly persona?: string;
|
|
243
|
+
/** Existing skill drafts so the pass reuses names instead of creating duplicates. */
|
|
244
|
+
readonly existingSkills?: readonly {
|
|
245
|
+
readonly name: string;
|
|
246
|
+
readonly description: string;
|
|
247
|
+
}[];
|
|
240
248
|
/** Model-facing project label. */
|
|
241
249
|
readonly projectLabel: string;
|
|
242
250
|
/** Cap on returned memories. */
|
|
@@ -269,10 +277,10 @@ export interface ConsolidateRequest {
|
|
|
269
277
|
*
|
|
270
278
|
* Two kernel shapes live here, because the seam changed under this plugin:
|
|
271
279
|
*
|
|
272
|
-
* - `startActivation` is the
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
280
|
+
* - `startActivation` is the current flattened `SubagentActivationSpec` shape.
|
|
281
|
+
* `provider`, `label`, `signal`, `delivery`, `prompt`, `parent`,
|
|
282
|
+
* `agentOptions`, `outputSchema`, `maxDepth`, and `agentPreset` all live at
|
|
283
|
+
* the top level (`toolFilter` and `persona` are gone).
|
|
276
284
|
* - `start` is the pre-0.2.1 shape: a name-addressed call whose request carries
|
|
277
285
|
* `toolFilter` and `persona`.
|
|
278
286
|
*
|
|
@@ -290,55 +298,30 @@ export interface ActivationSpec {
|
|
|
290
298
|
* descriptor with `snapshotJsonValue`, which rejects `undefined`. Omitting
|
|
291
299
|
* it therefore does not mean "no label" — it means "this descriptor cannot be
|
|
292
300
|
* serialized", and the pass dies with `subagent descriptor is not losslessly
|
|
293
|
-
* JSON-serializable`.
|
|
294
|
-
* 2026-10-20 until this field was declared here.
|
|
301
|
+
* JSON-serializable`.
|
|
295
302
|
*/
|
|
296
303
|
label: string;
|
|
297
|
-
/**
|
|
298
|
-
* Cancellation for the whole activation.
|
|
299
|
-
*
|
|
300
|
-
* Top-level, NOT inside `request`: the kernel reads `spec.signal` directly
|
|
301
|
-
* (`spec.signal.throwIfAborted()`, and `prepareContinuable({ signal })`), so a
|
|
302
|
-
* spec that carries the signal only in its request throws
|
|
303
|
-
* `Cannot read properties of undefined (reading 'throwIfAborted')` — after the
|
|
304
|
-
* child has already been reserved, which is why it reads as a crash rather than
|
|
305
|
-
* a refusal.
|
|
306
|
-
*
|
|
307
|
-
* The kernel's continuable path reads exactly these top-level fields —
|
|
308
|
-
* `provider`, `label`, `signal`, `childId`, `delivery`, `request` — and these
|
|
309
|
-
* on the request: `prompt`, `parent`, `maxDepth`, `outputSchema`,
|
|
310
|
-
* `agentOptions`, `agentPreset`, `cwd`. Anything omitted here fails at the
|
|
311
|
-
* kernel boundary, not at this module's type boundary.
|
|
312
|
-
*/
|
|
304
|
+
/** Cancellation for the whole activation. */
|
|
313
305
|
signal: AbortSignal;
|
|
314
306
|
/**
|
|
315
307
|
* Where the child's settlement notice goes.
|
|
316
308
|
*
|
|
317
309
|
* `caller` is right for this pass: the plugin consumes `run.result` itself, so
|
|
318
|
-
* a settlement message pushed into the parent's inbox is noise.
|
|
319
|
-
* actively misleading — the kernel marks a child that answers in plain text
|
|
320
|
-
* instead of calling `structured_output` as `error`, so the parent was told
|
|
321
|
-
* "Background subagent ... failed before it finished" while the plan had in fact
|
|
322
|
-
* arrived intact (2026-11-06). The kernel's own plugin-creator starts its
|
|
323
|
-
* children the same way.
|
|
310
|
+
* a settlement message pushed into the parent's inbox is noise.
|
|
324
311
|
*/
|
|
325
312
|
delivery?: 'caller' | 'parent';
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
agentOptions?: {
|
|
335
|
-
provider?: string;
|
|
336
|
-
model?: string;
|
|
337
|
-
};
|
|
338
|
-
outputSchema?: unknown;
|
|
339
|
-
maxDepth?: number;
|
|
340
|
-
agentPreset?: string;
|
|
313
|
+
prompt: {
|
|
314
|
+
type: 'text';
|
|
315
|
+
text: string;
|
|
316
|
+
}[];
|
|
317
|
+
parent: Agent;
|
|
318
|
+
agentOptions?: {
|
|
319
|
+
provider?: string;
|
|
320
|
+
model?: string;
|
|
341
321
|
};
|
|
322
|
+
outputSchema?: unknown;
|
|
323
|
+
maxDepth?: number;
|
|
324
|
+
agentPreset?: string;
|
|
342
325
|
}
|
|
343
326
|
/**
|
|
344
327
|
* One finished child run, as the seam reports it.
|
|
@@ -358,6 +341,7 @@ export interface ChildRunResult {
|
|
|
358
341
|
export interface SubagentSeam {
|
|
359
342
|
startActivation?: (spec: ActivationSpec) => Promise<{
|
|
360
343
|
result: Promise<ChildRunResult>;
|
|
344
|
+
dispose?: () => Promise<void>;
|
|
361
345
|
}>;
|
|
362
346
|
start?: (name: string, request: {
|
|
363
347
|
prompt: {
|
|
@@ -429,18 +413,17 @@ export declare function denyToolsFor(available: ReadonlySet<string>): string[];
|
|
|
429
413
|
*/
|
|
430
414
|
export declare function runConsolidation(seam: SubagentSeam, request: ConsolidateRequest): Promise<ConsolidationPlan | undefined>;
|
|
431
415
|
/**
|
|
432
|
-
* Build the
|
|
416
|
+
* Build the flattened `SubagentActivationSpec` the kernel seam takes.
|
|
433
417
|
*
|
|
434
|
-
* Extracted so a test can inspect it without a kernel: the
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
* kernel's descriptor validator, three calls away from here. See
|
|
438
|
-
* {@link ActivationSpec.label}.
|
|
418
|
+
* Extracted so a test can inspect it without a kernel: the kernel reads
|
|
419
|
+
* `provider`, `label`, `signal`, `delivery`, `prompt`, `parent`, `maxDepth`,
|
|
420
|
+
* `outputSchema`, `agentOptions`, and `agentPreset` at the top level.
|
|
439
421
|
*
|
|
440
422
|
* @param request - route, preset and lineage parent.
|
|
441
423
|
* @param prompt - the child's single user message.
|
|
442
424
|
* @param timeout - the child's deadline.
|
|
443
|
-
* @
|
|
425
|
+
* @param outputSchema - JSON schema for structured output.
|
|
426
|
+
* @returns the flattened spec, with optional fields omitted rather than `undefined`.
|
|
444
427
|
*/
|
|
445
428
|
export declare function buildActivationSpec(request: ConsolidateRequest, prompt: {
|
|
446
429
|
type: 'text';
|
package/lib/types/extract.d.ts
CHANGED
|
@@ -167,6 +167,12 @@ export declare const EXTRACT_JSON_SCHEMA: {
|
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
|
+
readonly closedLoops: {
|
|
171
|
+
readonly type: 'array';
|
|
172
|
+
readonly items: {
|
|
173
|
+
readonly type: 'string';
|
|
174
|
+
};
|
|
175
|
+
};
|
|
170
176
|
readonly summary: {
|
|
171
177
|
readonly type: 'string';
|
|
172
178
|
};
|
|
@@ -255,6 +261,7 @@ export declare function parseExtraction(text: string, maxMemories: number, sessi
|
|
|
255
261
|
text: string;
|
|
256
262
|
dueAt?: number;
|
|
257
263
|
}[];
|
|
264
|
+
closedLoops: string[];
|
|
258
265
|
summary: string;
|
|
259
266
|
dropped: number;
|
|
260
267
|
};
|
|
@@ -352,6 +359,11 @@ export interface ExtractionRequest {
|
|
|
352
359
|
* the title differently and ids come from titles.
|
|
353
360
|
*/
|
|
354
361
|
readonly knownTitles?: readonly string[];
|
|
362
|
+
/** Open loops currently tracked, so the extractor can close completed ones. */
|
|
363
|
+
readonly openLoops?: readonly {
|
|
364
|
+
readonly id: string;
|
|
365
|
+
readonly text: string;
|
|
366
|
+
}[];
|
|
355
367
|
/** Explicit route override. */
|
|
356
368
|
readonly provider?: string;
|
|
357
369
|
readonly model?: string;
|
|
@@ -403,6 +415,8 @@ export type ExtractionOutcome = {
|
|
|
403
415
|
text: string;
|
|
404
416
|
dueAt?: number;
|
|
405
417
|
}[];
|
|
418
|
+
/** Ids of previously open loops that this transcript shows are now done. */
|
|
419
|
+
readonly closedLoops?: readonly string[];
|
|
406
420
|
/** What the session was about, stored as the evidence behind the drafts. */
|
|
407
421
|
readonly summary: string;
|
|
408
422
|
/** Usable drafts the reply offered beyond `maxMemories`, reported to the caller. */
|
package/lib/types/gate.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const GATE_JSON_SCHEMA: {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
|
+
/** Output token cap for one gate call (leaves room for reasoning tokens). */
|
|
41
|
+
export declare const DEFAULT_GATE_MAX_OUTPUT_TOKENS = 2048;
|
|
40
42
|
/** Everything one gate call needs. */
|
|
41
43
|
export interface GateRequest {
|
|
42
44
|
/** LLM runtime. */
|
|
@@ -50,6 +52,8 @@ export interface GateRequest {
|
|
|
50
52
|
/** Explicit route override. */
|
|
51
53
|
readonly provider?: string;
|
|
52
54
|
readonly model?: string;
|
|
55
|
+
/** Output token cap for the gate call. */
|
|
56
|
+
readonly maxOutputTokens?: number;
|
|
53
57
|
/** Deadline for the call. */
|
|
54
58
|
readonly timeoutMs: number;
|
|
55
59
|
/** Plugin lifecycle signal. */
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { MemoryStore } from './storage.js';
|
|
3
|
+
/** Runtime options for the MCP server. */
|
|
4
|
+
export interface McpServerOptions {
|
|
5
|
+
readonly memoriesDir: string;
|
|
6
|
+
readonly denseEnabled: boolean;
|
|
7
|
+
readonly denseUrl: string;
|
|
8
|
+
readonly denseModel: string;
|
|
9
|
+
}
|
|
10
|
+
/** One incoming JSON-RPC 2.0 request or notification. */
|
|
11
|
+
export interface JsonRpcRequest {
|
|
12
|
+
readonly jsonrpc?: string;
|
|
13
|
+
readonly id?: string | number | null;
|
|
14
|
+
readonly method: string;
|
|
15
|
+
readonly params?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
/** One outgoing JSON-RPC 2.0 response. */
|
|
18
|
+
export interface JsonRpcResponse {
|
|
19
|
+
readonly jsonrpc: '2.0';
|
|
20
|
+
readonly id: string | number | null;
|
|
21
|
+
readonly result?: unknown;
|
|
22
|
+
readonly error?: {
|
|
23
|
+
readonly code: number;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Tool definitions exposed to MCP clients (compact on purpose). */
|
|
28
|
+
export declare const MCP_TOOLS: readonly [{
|
|
29
|
+
readonly name: 'memory_persona';
|
|
30
|
+
readonly description: 'Read the user profile (persona/human.md): who the user is, their working conventions, standards, environment, and communication preferences. Call this early in a new session when user preferences matter.';
|
|
31
|
+
readonly inputSchema: {
|
|
32
|
+
readonly type: 'object';
|
|
33
|
+
readonly properties: {};
|
|
34
|
+
readonly additionalProperties: false;
|
|
35
|
+
};
|
|
36
|
+
}, {
|
|
37
|
+
readonly name: 'memory_search';
|
|
38
|
+
readonly description: 'Search durable cross-session memories (global and/or one project workspace) using BM25 + optional local embedding hybrid ranking. Omit query to browse recent entries.';
|
|
39
|
+
readonly inputSchema: {
|
|
40
|
+
readonly type: 'object';
|
|
41
|
+
readonly properties: {
|
|
42
|
+
readonly query: {
|
|
43
|
+
readonly type: 'string';
|
|
44
|
+
readonly description: 'Search query (Chinese or English). Empty lists most recent entries.';
|
|
45
|
+
};
|
|
46
|
+
readonly scope: {
|
|
47
|
+
readonly type: 'string';
|
|
48
|
+
readonly enum: readonly ['global', 'project', 'all'];
|
|
49
|
+
readonly description: 'Target scope; defaults to all (project + global when projectRoot/projectSlug is given, otherwise global).';
|
|
50
|
+
};
|
|
51
|
+
readonly projectRoot: {
|
|
52
|
+
readonly type: 'string';
|
|
53
|
+
readonly description: 'Absolute path of the current workspace root (used to resolve project scope).';
|
|
54
|
+
};
|
|
55
|
+
readonly projectSlug: {
|
|
56
|
+
readonly type: 'string';
|
|
57
|
+
readonly description: 'Explicit project directory slug under memories/projects/ (alternative to projectRoot).';
|
|
58
|
+
};
|
|
59
|
+
readonly kind: {
|
|
60
|
+
readonly type: 'string';
|
|
61
|
+
readonly enum: readonly ['fact', 'preference', 'knowledge', 'failure', 'procedure'];
|
|
62
|
+
readonly description: 'Filter by memory kind.';
|
|
63
|
+
};
|
|
64
|
+
readonly tags: {
|
|
65
|
+
readonly type: 'array';
|
|
66
|
+
readonly items: {
|
|
67
|
+
readonly type: 'string';
|
|
68
|
+
};
|
|
69
|
+
readonly description: 'Optional lowercase tag filters.';
|
|
70
|
+
};
|
|
71
|
+
readonly limit: {
|
|
72
|
+
readonly type: 'integer';
|
|
73
|
+
readonly minimum: 1;
|
|
74
|
+
readonly maximum: 25;
|
|
75
|
+
readonly description: 'Maximum hits to return (default 8, max 25).';
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly additionalProperties: false;
|
|
79
|
+
};
|
|
80
|
+
}, {
|
|
81
|
+
readonly name: 'memory_read';
|
|
82
|
+
readonly description: 'Read the full body and metadata of one memory entry by id.';
|
|
83
|
+
readonly inputSchema: {
|
|
84
|
+
readonly type: 'object';
|
|
85
|
+
readonly properties: {
|
|
86
|
+
readonly id: {
|
|
87
|
+
readonly type: 'string';
|
|
88
|
+
readonly description: 'Entry id returned by memory_search.';
|
|
89
|
+
};
|
|
90
|
+
readonly scope: {
|
|
91
|
+
readonly type: 'string';
|
|
92
|
+
readonly enum: readonly ['global', 'project'];
|
|
93
|
+
readonly description: 'Scope to read from (defaults to project then global).';
|
|
94
|
+
};
|
|
95
|
+
readonly projectRoot: {
|
|
96
|
+
readonly type: 'string';
|
|
97
|
+
readonly description: 'Workspace root for project scope.';
|
|
98
|
+
};
|
|
99
|
+
readonly projectSlug: {
|
|
100
|
+
readonly type: 'string';
|
|
101
|
+
readonly description: 'Explicit project slug for project scope.';
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
readonly required: readonly ['id'];
|
|
105
|
+
readonly additionalProperties: false;
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: 'memory_write';
|
|
109
|
+
readonly description: 'Write or update a durable memory entry. Title is the identity (same title updates in place). Credentials and passwords are automatically redacted before persistence.';
|
|
110
|
+
readonly inputSchema: {
|
|
111
|
+
readonly type: 'object';
|
|
112
|
+
readonly properties: {
|
|
113
|
+
readonly scope: {
|
|
114
|
+
readonly type: 'string';
|
|
115
|
+
readonly enum: readonly ['global', 'project'];
|
|
116
|
+
readonly description: 'global for cross-project facts/preferences, project for one workspace.';
|
|
117
|
+
};
|
|
118
|
+
readonly title: {
|
|
119
|
+
readonly type: 'string';
|
|
120
|
+
readonly description: 'Short imperative heading (max 120 chars).';
|
|
121
|
+
};
|
|
122
|
+
readonly body: {
|
|
123
|
+
readonly type: 'string';
|
|
124
|
+
readonly description: 'Self-contained fact, 1-4 sentences.';
|
|
125
|
+
};
|
|
126
|
+
readonly kind: {
|
|
127
|
+
readonly type: 'string';
|
|
128
|
+
readonly enum: readonly ['fact', 'preference', 'knowledge', 'failure', 'procedure'];
|
|
129
|
+
};
|
|
130
|
+
readonly tags: {
|
|
131
|
+
readonly type: 'array';
|
|
132
|
+
readonly items: {
|
|
133
|
+
readonly type: 'string';
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
readonly keys: {
|
|
137
|
+
readonly type: 'array';
|
|
138
|
+
readonly items: {
|
|
139
|
+
readonly type: 'string';
|
|
140
|
+
};
|
|
141
|
+
readonly description: 'Aliases and bilingual search keywords.';
|
|
142
|
+
};
|
|
143
|
+
readonly appliesTo: {
|
|
144
|
+
readonly type: 'string';
|
|
145
|
+
readonly description: 'Short phrase saying when this memory matters.';
|
|
146
|
+
};
|
|
147
|
+
readonly durability: {
|
|
148
|
+
readonly type: 'string';
|
|
149
|
+
readonly enum: readonly ['durable', 'snapshot'];
|
|
150
|
+
};
|
|
151
|
+
readonly pinned: {
|
|
152
|
+
readonly type: 'boolean';
|
|
153
|
+
};
|
|
154
|
+
readonly permanent: {
|
|
155
|
+
readonly type: 'boolean';
|
|
156
|
+
};
|
|
157
|
+
readonly projectRoot: {
|
|
158
|
+
readonly type: 'string';
|
|
159
|
+
readonly description: 'Workspace root (required when scope=project unless projectSlug is given).';
|
|
160
|
+
};
|
|
161
|
+
readonly projectSlug: {
|
|
162
|
+
readonly type: 'string';
|
|
163
|
+
readonly description: 'Explicit project slug (alternative to projectRoot).';
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
readonly required: readonly ['scope', 'title', 'body'];
|
|
167
|
+
readonly additionalProperties: false;
|
|
168
|
+
};
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: 'memory_projects';
|
|
171
|
+
readonly description: 'List known project memory scopes with their slugs, recorded workspace roots, and entry counts.';
|
|
172
|
+
readonly inputSchema: {
|
|
173
|
+
readonly type: 'object';
|
|
174
|
+
readonly properties: {};
|
|
175
|
+
readonly additionalProperties: false;
|
|
176
|
+
};
|
|
177
|
+
}];
|
|
178
|
+
/** Resolve default options from environment variables. */
|
|
179
|
+
export declare function defaultMcpOptions(env?: NodeJS.ProcessEnv): McpServerOptions;
|
|
180
|
+
/** Handle one JSON-RPC 2.0 request. Returns `undefined` for notifications. */
|
|
181
|
+
export declare function handleMcpRequest(request: JsonRpcRequest, options: McpServerOptions, store?: MemoryStore): Promise<JsonRpcResponse | undefined>;
|
|
182
|
+
/** Run the newline-delimited JSON-RPC 2.0 stdio loop. */
|
|
183
|
+
export declare function startStdioServer(options?: McpServerOptions): void;
|
package/lib/types/persona.d.ts
CHANGED
|
@@ -20,11 +20,28 @@ export declare function personaLockPath(memoriesDir: string): string;
|
|
|
20
20
|
* @returns the markdown body, or `undefined` when it does not exist yet.
|
|
21
21
|
*/
|
|
22
22
|
export declare function readPersona(memoriesDir: string): Promise<string | undefined>;
|
|
23
|
+
/**
|
|
24
|
+
* Whether two persona bullets express the same rule (rephrased or tightened).
|
|
25
|
+
*
|
|
26
|
+
* A consolidation pass often tightens a bullet's wording on one machine while
|
|
27
|
+
* another machine still holds the older phrasing. Exact-string matching treats
|
|
28
|
+
* both as distinct rules and doubles every section on sync. Token overlap +
|
|
29
|
+
* containment catches rewrites without merging genuinely different rules.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isNearDuplicateBullet(left: string, right: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Deduplicate exact and near-duplicate bullets inside each section of a persona
|
|
34
|
+
* markdown document, keeping the earlier bullet when two bullets state the same
|
|
35
|
+
* rule. Also collapses repeated blank lines.
|
|
36
|
+
*/
|
|
37
|
+
export declare function dedupePersona(body: string): string;
|
|
23
38
|
/**
|
|
24
39
|
* Replace the profile atomically.
|
|
25
40
|
*
|
|
26
41
|
* A half-written profile is worse than a stale one — it would be injected into
|
|
27
42
|
* every conversation — so the write goes through a temp file and a rename.
|
|
43
|
+
* Deduplicates near-identical bullets within each section before persisting so
|
|
44
|
+
* neither consolidation nor multi-machine sync can double the profile.
|
|
28
45
|
*
|
|
29
46
|
* @param memoriesDir - the memory store root.
|
|
30
47
|
* @param body - the new markdown profile.
|
package/lib/types/sync.d.ts
CHANGED
|
@@ -93,13 +93,14 @@ export declare function sessionNoteStamp(text: string): number;
|
|
|
93
93
|
/** Whether one path is a persona file: prose the assistant maintains for the user. */
|
|
94
94
|
export declare function isPersonaPath(path: string): boolean;
|
|
95
95
|
/**
|
|
96
|
-
* Merge two versions of a persona file as a bullet union.
|
|
96
|
+
* Merge two versions of a persona file as a deduplicated bullet union.
|
|
97
97
|
*
|
|
98
98
|
* A persona file is headings plus bullet lists; both machines append their own
|
|
99
|
-
* observations, so a
|
|
100
|
-
* Bullets are matched on
|
|
101
|
-
*
|
|
102
|
-
*
|
|
99
|
+
* observations, so a section-aware union keeps every rule either machine
|
|
100
|
+
* recorded. Bullets are matched not only on exact text but also on near-duplicate
|
|
101
|
+
* token overlap within the same section — otherwise a consolidation pass that
|
|
102
|
+
* tightens wording on one machine causes the next sync to append the older
|
|
103
|
+
* phrasing beside it and double every section. Non-bullet lines come from `ours`.
|
|
103
104
|
*/
|
|
104
105
|
export declare function mergePersona(ours: string, theirs: string): string;
|
|
105
106
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cross-memory",
|
|
3
3
|
"description": "Cross-session memory for the DeepSeek Harness: project-scoped and global memories with an explicit memory tool, idle-time background extraction, consolidation, and layered summary injection",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.13",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "lib/index.js",
|
|
11
11
|
"types": "lib/types/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"dsh-cross-memory-mcp": "./lib/mcp.js"
|
|
14
|
+
},
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
17
|
"types": "./lib/types/index.d.ts",
|
|
@@ -17,6 +20,10 @@
|
|
|
17
20
|
"./client": {
|
|
18
21
|
"default": "./lib/client.js"
|
|
19
22
|
},
|
|
23
|
+
"./mcp": {
|
|
24
|
+
"types": "./lib/types/mcp.d.ts",
|
|
25
|
+
"default": "./lib/mcp.js"
|
|
26
|
+
},
|
|
20
27
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
21
28
|
"./package.json": "./package.json"
|
|
22
29
|
},
|