dsh-mnemon-source-runtime 0.5.7 → 0.5.9
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.md +2 -0
- package/lib/index.js +23 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ Choose an existing data authority deliberately. Without `dataDir`, each stable S
|
|
|
19
19
|
|
|
20
20
|
Disabling participation does not delete stored entries. Source data remains separate from the current turn's projection and access grants.
|
|
21
21
|
|
|
22
|
+
Model projections annotate each entry with its recorded importance and elapsed whole-day ages, for example `[importance=critical; created=14d; updated=2d]`, followed by the exact content. Future timestamps show `future`; unparseable ones show `unknown`. Ages are captured once per projection and remain fixed for that turn. Annotations count toward the Strategy's projection budget, but do not change stored JSON/Markdown, content matching or storage capacity. For replacement/removal, use only the entry content. Current instructions retain priority.
|
|
23
|
+
|
|
22
24
|
## Source-owned UI and tests
|
|
23
25
|
|
|
24
26
|
The optional `./client` entry is an ordinary DSH Client plugin. This package owns its pages and `presentation/` resources and uses `dsh-mnemon/client` for the shared frame and scoped management client. It never receives a Host Context, credentials or another Source's controller.
|
package/lib/index.js
CHANGED
|
@@ -50,7 +50,8 @@ function resolveGitBranch(cwd) {
|
|
|
50
50
|
"ignore",
|
|
51
51
|
"pipe",
|
|
52
52
|
"ignore"
|
|
53
|
-
]
|
|
53
|
+
],
|
|
54
|
+
windowsHide: true
|
|
54
55
|
}).trim();
|
|
55
56
|
return branch === "" ? void 0 : branch;
|
|
56
57
|
} catch {
|
|
@@ -161,6 +162,16 @@ function markdown(entries, target) {
|
|
|
161
162
|
const content = entries.filter((entry) => entry.target === target).map((entry) => entry.content).join(RUNTIME_ENTRY_DELIMITER);
|
|
162
163
|
return content === "" ? "" : `${content}\n`;
|
|
163
164
|
}
|
|
165
|
+
function age(timestamp, projectedAt) {
|
|
166
|
+
const time = Date.parse(timestamp);
|
|
167
|
+
if (!Number.isFinite(time)) return "unknown";
|
|
168
|
+
if (time > projectedAt) return "future";
|
|
169
|
+
return `${Math.floor((projectedAt - time) / 864e5)}d`;
|
|
170
|
+
}
|
|
171
|
+
/** Prompt-only annotations; stored content, matching and capacity stay unchanged. */
|
|
172
|
+
function contextMarkdown(entries, target, projectedAt) {
|
|
173
|
+
return entries.filter((entry) => entry.target === target).map((entry) => `[importance=${entry.importance}; created=${age(entry.created_at, projectedAt)}; updated=${age(entry.updated_at, projectedAt)}]\n${entry.content}`).join(RUNTIME_ENTRY_DELIMITER);
|
|
174
|
+
}
|
|
164
175
|
function revision(file) {
|
|
165
176
|
return createHash("sha256").update(JSON.stringify(file)).digest("hex");
|
|
166
177
|
}
|
|
@@ -298,7 +309,7 @@ function sleepSync(milliseconds) {
|
|
|
298
309
|
}
|
|
299
310
|
/**
|
|
300
311
|
* Single authority for hot memory. JSON is the durable source of truth;
|
|
301
|
-
* Markdown files
|
|
312
|
+
* Markdown files retain plain content; prompt projections add recorded metadata.
|
|
302
313
|
*/
|
|
303
314
|
var RuntimeMemoryController = class RuntimeMemoryController {
|
|
304
315
|
now;
|
|
@@ -351,8 +362,9 @@ var RuntimeMemoryController = class RuntimeMemoryController {
|
|
|
351
362
|
*/
|
|
352
363
|
contextProjection(branch) {
|
|
353
364
|
const branchScope = scopeBranch(branch);
|
|
354
|
-
const
|
|
355
|
-
const
|
|
365
|
+
const projectedAt = this.now().getTime();
|
|
366
|
+
const local = this.localContextProjection(projectedAt, branchScope);
|
|
367
|
+
const global = this.userController?.localContextProjection(projectedAt);
|
|
356
368
|
const user = global?.user ?? local.user;
|
|
357
369
|
const memory = local.memory;
|
|
358
370
|
const entries = global === void 0 ? local.snapshot.entries : [...global.snapshot.entries.filter((entry) => entry.target === "user"), ...local.snapshot.entries.filter((entry) => entry.target === "memory")];
|
|
@@ -365,7 +377,7 @@ var RuntimeMemoryController = class RuntimeMemoryController {
|
|
|
365
377
|
version: 1,
|
|
366
378
|
entries
|
|
367
379
|
}),
|
|
368
|
-
generatedAt:
|
|
380
|
+
generatedAt: new Date(projectedAt).toISOString(),
|
|
369
381
|
entries,
|
|
370
382
|
targets: {
|
|
371
383
|
memory: {
|
|
@@ -391,6 +403,7 @@ var RuntimeMemoryController = class RuntimeMemoryController {
|
|
|
391
403
|
totalEntries: entries.length,
|
|
392
404
|
text: `MNEMON RUNTIME MEMORY SNAPSHOT
|
|
393
405
|
Revision: ${snapshot.revision}${branchLine}
|
|
406
|
+
Metadata lines are annotations; created/updated are ages at projection in whole days (future/unknown for future/invalid timestamps). Current instructions win. For old_text/oldText, use entry content only.
|
|
394
407
|
|
|
395
408
|
Contents of USER.md (user profile; entries: ${visibleUser.entryCount}; UTF-8 bytes: ${storeUser.used}/${storeUser.limit})
|
|
396
409
|
<runtime-memory-file name="USER.md">
|
|
@@ -403,7 +416,7 @@ ${memory || "(empty)"}
|
|
|
403
416
|
</runtime-memory-file>`
|
|
404
417
|
};
|
|
405
418
|
}
|
|
406
|
-
localContextProjection(branch) {
|
|
419
|
+
localContextProjection(projectedAt, branch) {
|
|
407
420
|
const branchScope = scopeBranch(branch);
|
|
408
421
|
return this.withLock(() => {
|
|
409
422
|
const file = this.readSource();
|
|
@@ -415,15 +428,15 @@ ${memory || "(empty)"}
|
|
|
415
428
|
directory: this.directory,
|
|
416
429
|
sourcePath: this.sourcePath,
|
|
417
430
|
revision: revision(file),
|
|
418
|
-
generatedAt:
|
|
431
|
+
generatedAt: new Date(projectedAt).toISOString(),
|
|
419
432
|
entries,
|
|
420
433
|
targets: {
|
|
421
434
|
memory: this.targetView(visible, "memory"),
|
|
422
435
|
user: this.targetView(visible, "user")
|
|
423
436
|
}
|
|
424
437
|
},
|
|
425
|
-
user:
|
|
426
|
-
memory:
|
|
438
|
+
user: contextMarkdown(visible, "user", projectedAt),
|
|
439
|
+
memory: contextMarkdown(visible, "memory", projectedAt),
|
|
427
440
|
hidden: branchScope === void 0 ? 0 : entries.length - visible.length
|
|
428
441
|
};
|
|
429
442
|
});
|
|
@@ -736,7 +749,7 @@ function createRuntimeMemorySource(config = {}) {
|
|
|
736
749
|
content: { type: "string" },
|
|
737
750
|
oldText: {
|
|
738
751
|
type: "string",
|
|
739
|
-
description: "Full content of the existing entry, or a unique substring. A unique full-content match takes precedence within the selected target. Required for replace and remove."
|
|
752
|
+
description: "Full content of the existing entry, or a unique substring, excluding the generated metadata line. A unique full-content match takes precedence within the selected target. Required for replace and remove."
|
|
740
753
|
},
|
|
741
754
|
importance: {
|
|
742
755
|
type: "string",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mnemon-source-runtime",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Self-contained runtime Source for Composable View Memory.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/node": "^22.0.0",
|
|
62
62
|
"@types/react": "^18.3.0",
|
|
63
63
|
"@types/react-dom": "^18.3.0",
|
|
64
|
-
"dsh-mnemon": "^0.5.
|
|
64
|
+
"dsh-mnemon": "^0.5.15",
|
|
65
65
|
"jsdom": "^26.0.0",
|
|
66
66
|
"react": "^18.2.0",
|
|
67
67
|
"react-dom": "^18.2.0",
|