open-memex 0.8.0-alpha.2 → 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/AGENTS.md +8 -4
- package/CHANGELOG.md +4 -0
- package/README.md +36 -15
- package/README.zh-CN.md +8 -4
- package/dist/.build-stamp +1 -1
- package/dist/cli.js +19 -4
- package/dist/init.js +8 -8
- package/dist/retrieve/alias-memory.js +130 -0
- package/dist/retrieve/query.js +1 -1
- package/dist/retrieve/search.js +35 -5
- package/dist/store/db.js +3 -1
- package/dist/store/lifecycle.js +3 -0
- package/dist/store/markdown.js +7 -0
- package/dist/store/sync.js +6 -3
- package/dist/tools/ops.js +40 -3
- package/docs/V2-DESIGN.md +2 -0
- package/package.json +1 -1
- package/scripts/bench-longmemeval.ts +1 -1
- package/scripts/retrieval-eval/fixture.ts +17 -2
- package/scripts/retrieval-eval.ts +3 -1
- package/scripts/smoke-pure.ts +55 -0
- package/server.json +2 -2
- package/src/cli.ts +19 -4
- package/src/init.ts +8 -14
- package/src/retrieve/alias-memory.ts +154 -0
- package/src/retrieve/query.ts +1 -1
- package/src/retrieve/search.ts +40 -5
- package/src/store/db.ts +3 -1
- package/src/store/lifecycle.ts +6 -0
- package/src/store/markdown.ts +18 -0
- package/src/store/sync.ts +7 -2
- package/src/tools/ops.ts +52 -3
package/src/tools/ops.ts
CHANGED
|
@@ -101,7 +101,7 @@ export const aliasesArg = z
|
|
|
101
101
|
.array(z.string())
|
|
102
102
|
.optional()
|
|
103
103
|
.describe(
|
|
104
|
-
"Optional: alternate phrasings of this fact — synonyms, another way a question might be worded, equivalents in the user's other language (e.g. 节假日 for 'public holidays'). They are indexed with the memory so differently-worded questions still match.
|
|
104
|
+
"Optional: alternate phrasings of this fact — synonyms, another way a question might be worded, equivalents in the user's other language (e.g. 节假日 for 'public holidays'). They are indexed with the memory so differently-worded questions still match. Always on. Send at most 4; extras and blanks are dropped silently, never an error.",
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
export const memoryAddArgs = {
|
|
@@ -113,6 +113,18 @@ export const memoryAddArgs = {
|
|
|
113
113
|
scope: scopeArg,
|
|
114
114
|
tags: z.array(z.string()).optional().describe("Optional tags for filtering."),
|
|
115
115
|
aliases: aliasesArg,
|
|
116
|
+
alias: z
|
|
117
|
+
.string()
|
|
118
|
+
.optional()
|
|
119
|
+
.describe(
|
|
120
|
+
"D81: nickname this memory defines (e.g. 香蕉计划). Pairs with `target`: the alias memory expands queries in its scope at search time, both directions, no reindex. Explicit vocabulary — always stored, not gated by capture aliases.",
|
|
121
|
+
),
|
|
122
|
+
target: z
|
|
123
|
+
.string()
|
|
124
|
+
.optional()
|
|
125
|
+
.describe(
|
|
126
|
+
"D81: what `alias` refers to (e.g. 支付系统重构项目). Only meaningful with `alias`.",
|
|
127
|
+
),
|
|
116
128
|
source: z
|
|
117
129
|
.string()
|
|
118
130
|
.optional()
|
|
@@ -163,6 +175,18 @@ export const memorySupersedeArgs = {
|
|
|
163
175
|
.describe("Category of the new memory. Defaults to the old memory's type."),
|
|
164
176
|
tags: z.array(z.string()).optional().describe("Optional tags for the new memory."),
|
|
165
177
|
aliases: aliasesArg,
|
|
178
|
+
alias: z
|
|
179
|
+
.string()
|
|
180
|
+
.optional()
|
|
181
|
+
.describe(
|
|
182
|
+
"D81: nickname the new memory defines (e.g. 香蕉计划). Omitted = inherit the old memory's alias.",
|
|
183
|
+
),
|
|
184
|
+
target: z
|
|
185
|
+
.string()
|
|
186
|
+
.optional()
|
|
187
|
+
.describe(
|
|
188
|
+
"D81: what `alias` refers to (e.g. 支付系统重构项目). Omitted = inherit.",
|
|
189
|
+
),
|
|
166
190
|
};
|
|
167
191
|
export type MemorySupersedeArgs = z.infer<z.ZodObject<typeof memorySupersedeArgs>>;
|
|
168
192
|
|
|
@@ -242,6 +266,8 @@ function buildFrontmatter(
|
|
|
242
266
|
type: Frontmatter["type"];
|
|
243
267
|
tags: string[];
|
|
244
268
|
aliases?: string[];
|
|
269
|
+
alias?: string;
|
|
270
|
+
target?: string;
|
|
245
271
|
source: Frontmatter["source"];
|
|
246
272
|
},
|
|
247
273
|
): Frontmatter {
|
|
@@ -259,6 +285,11 @@ function buildFrontmatter(
|
|
|
259
285
|
status: "active",
|
|
260
286
|
tags: body.tags,
|
|
261
287
|
...(body.aliases && body.aliases.length > 0 ? { aliases: body.aliases } : {}),
|
|
288
|
+
// D81: explicit alias vocabulary — single trimmed strings, dropped
|
|
289
|
+
// when empty. Not gated by captureAliases (that gates agent-invented
|
|
290
|
+
// phrasings; this is deliberate vocabulary).
|
|
291
|
+
...(body.alias?.trim() ? { alias: body.alias.trim() } : {}),
|
|
292
|
+
...(body.target?.trim() ? { target: body.target.trim() } : {}),
|
|
262
293
|
source: body.source,
|
|
263
294
|
created_at: rfc,
|
|
264
295
|
updated_at: rfc,
|
|
@@ -319,8 +350,8 @@ export async function addMemory(
|
|
|
319
350
|
const fm = buildFrontmatter(s, {
|
|
320
351
|
type: args.type ?? "fact",
|
|
321
352
|
tags: args.tags ?? [],
|
|
322
|
-
// D61: aliases are stored
|
|
323
|
-
//
|
|
353
|
+
// D61: aliases are always stored (Stone 2026-10-07: init no longer asks;
|
|
354
|
+
// default on). Normalize caps at 4 and drops junk silently.
|
|
324
355
|
// Aliases pass through the same redaction as content (write-path
|
|
325
356
|
// invariant) — an alias carrying a token gets masked, not stored raw.
|
|
326
357
|
aliases: cfg.captureAliases
|
|
@@ -328,6 +359,14 @@ export async function addMemory(
|
|
|
328
359
|
(args.aliases ?? []).map((a) => redact(a, cfg.redactPatterns).content),
|
|
329
360
|
)
|
|
330
361
|
: [],
|
|
362
|
+
// D81: explicit alias vocabulary — same redaction as content, never
|
|
363
|
+
// gated by captureAliases.
|
|
364
|
+
alias: args.alias?.trim()
|
|
365
|
+
? redact(args.alias.trim(), cfg.redactPatterns).content
|
|
366
|
+
: undefined,
|
|
367
|
+
target: args.target?.trim()
|
|
368
|
+
? redact(args.target.trim(), cfg.redactPatterns).content
|
|
369
|
+
: undefined,
|
|
331
370
|
source: args.source ?? "tool",
|
|
332
371
|
});
|
|
333
372
|
const { filePath } = writeMemoryFile(fm, redacted);
|
|
@@ -447,6 +486,16 @@ export async function supersedeMemory(
|
|
|
447
486
|
args.aliases.map((a) => redact(a, cfg.redactPatterns).content),
|
|
448
487
|
)
|
|
449
488
|
: undefined,
|
|
489
|
+
// D81: explicit alias vocabulary — omitted inherits the old memory's
|
|
490
|
+
// pair; same redaction as content; never gated by captureAliases.
|
|
491
|
+
alias:
|
|
492
|
+
args.alias !== undefined
|
|
493
|
+
? redact(args.alias, cfg.redactPatterns).content || undefined
|
|
494
|
+
: undefined,
|
|
495
|
+
target:
|
|
496
|
+
args.target !== undefined
|
|
497
|
+
? redact(args.target, cfg.redactPatterns).content || undefined
|
|
498
|
+
: undefined,
|
|
450
499
|
source: "tool",
|
|
451
500
|
});
|
|
452
501
|
upsertFromFile(oldMf);
|