@alanzhao/dsh-memory-lite 0.1.1

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/cordis.patch.yml +9 -0
  4. package/lib/catalog.d.ts +35 -0
  5. package/lib/catalog.js +145 -0
  6. package/lib/catalog.js.map +1 -0
  7. package/lib/client.js +631 -0
  8. package/lib/config.d.ts +133 -0
  9. package/lib/config.js +173 -0
  10. package/lib/config.js.map +1 -0
  11. package/lib/extract/checkpoint.d.ts +60 -0
  12. package/lib/extract/checkpoint.js +42 -0
  13. package/lib/extract/checkpoint.js.map +1 -0
  14. package/lib/extract/decision.d.ts +36 -0
  15. package/lib/extract/decision.js +118 -0
  16. package/lib/extract/decision.js.map +1 -0
  17. package/lib/extract/digest.d.ts +12 -0
  18. package/lib/extract/digest.js +25 -0
  19. package/lib/extract/digest.js.map +1 -0
  20. package/lib/extract/index.d.ts +52 -0
  21. package/lib/extract/index.js +489 -0
  22. package/lib/extract/index.js.map +1 -0
  23. package/lib/extract/prompt.d.ts +20 -0
  24. package/lib/extract/prompt.js +63 -0
  25. package/lib/extract/prompt.js.map +1 -0
  26. package/lib/extract/triggers.d.ts +15 -0
  27. package/lib/extract/triggers.js +26 -0
  28. package/lib/extract/triggers.js.map +1 -0
  29. package/lib/extract/window.d.ts +48 -0
  30. package/lib/extract/window.js +110 -0
  31. package/lib/extract/window.js.map +1 -0
  32. package/lib/index.d.ts +29 -0
  33. package/lib/index.js +92 -0
  34. package/lib/index.js.map +1 -0
  35. package/lib/inject.d.ts +45 -0
  36. package/lib/inject.js +102 -0
  37. package/lib/inject.js.map +1 -0
  38. package/lib/memory-store.d.ts +147 -0
  39. package/lib/memory-store.js +494 -0
  40. package/lib/memory-store.js.map +1 -0
  41. package/lib/path.d.ts +24 -0
  42. package/lib/path.js +54 -0
  43. package/lib/path.js.map +1 -0
  44. package/lib/peer.d.ts +16 -0
  45. package/lib/peer.js +38 -0
  46. package/lib/peer.js.map +1 -0
  47. package/lib/status.d.ts +44 -0
  48. package/lib/status.js +42 -0
  49. package/lib/status.js.map +1 -0
  50. package/lib/tool-utils.d.ts +25 -0
  51. package/lib/tool-utils.js +16 -0
  52. package/lib/tool-utils.js.map +1 -0
  53. package/lib/tools/forget-memory.d.ts +9 -0
  54. package/lib/tools/forget-memory.js +39 -0
  55. package/lib/tools/forget-memory.js.map +1 -0
  56. package/lib/tools/read-memory.d.ts +8 -0
  57. package/lib/tools/read-memory.js +41 -0
  58. package/lib/tools/read-memory.js.map +1 -0
  59. package/lib/tools/remember.d.ts +9 -0
  60. package/lib/tools/remember.js +65 -0
  61. package/lib/tools/remember.js.map +1 -0
  62. package/lib/tools/search-memory.d.ts +8 -0
  63. package/lib/tools/search-memory.js +49 -0
  64. package/lib/tools/search-memory.js.map +1 -0
  65. package/lib/tools/update-memory.d.ts +9 -0
  66. package/lib/tools/update-memory.js +46 -0
  67. package/lib/tools/update-memory.js.map +1 -0
  68. package/lib/types.d.ts +35 -0
  69. package/lib/types.js +7 -0
  70. package/lib/types.js.map +1 -0
  71. package/package.json +81 -0
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The `update_memory` tool: replaces a memory's current content, archiving
3
+ * the previous current into its History section (ADD-only).
4
+ * @module dsh-memory-lite/src/tools/update-memory
5
+ */
6
+ import { defineTool } from '@deepseek-ai/dsh-tools';
7
+ import { assertNotSubagent, peerForExec } from '../tool-utils.js';
8
+ import { normalizeContent, summaryOf } from '../memory-store.js';
9
+ /** Register update_memory. */
10
+ export function applyUpdateMemoryTool(ctx, deps) {
11
+ ctx.tools.register(defineTool({
12
+ name: 'update_memory',
13
+ description: "Replace a memory's current content with new content; the previous current content moves to its History section. Use when a memory is outdated or contradicts new facts.",
14
+ parameters: {
15
+ path: { type: 'string', required: true, description: 'Memory file path relative to the memory root, e.g. preferences/coding.md.' },
16
+ content: { type: 'string', required: true, description: 'The new current content of the memory.' },
17
+ },
18
+ output: {
19
+ schema: {
20
+ type: 'object',
21
+ additionalProperties: false,
22
+ properties: {
23
+ path: { type: 'string', required: true },
24
+ content: { type: 'string', required: true },
25
+ },
26
+ },
27
+ render: (_args, value) => [
28
+ { type: 'text', text: `Updated ${value.path} (previous content moved to History).\n<content>\n${value.content}\n</content>` },
29
+ ],
30
+ },
31
+ async execute(args, exec) {
32
+ assertNotSubagent(exec);
33
+ const peer = peerForExec(exec, deps.config());
34
+ const content = normalizeContent(args.content);
35
+ if (content === '')
36
+ throw new Error('content must be a non-empty string');
37
+ await deps.store.updateCurrent(peer, args.path, content);
38
+ await deps.store.refreshIndexEntry(peer, args.path, summaryOf(content));
39
+ return { path: args.path, content };
40
+ },
41
+ presentCall(args) {
42
+ return { card: 'generic', title: `Update memory ${args.path}`, kind: 'edit', locations: [{ path: args.path }] };
43
+ },
44
+ }));
45
+ }
46
+ //# sourceMappingURL=update-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-memory.js","sourceRoot":"","sources":["../../src/tools/update-memory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEhE,8BAA8B;AAC9B,MAAM,UAAU,qBAAqB,CAAC,GAAY,EAAE,IAAgB;IAClE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC5B,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,yKAAyK;QACtL,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2EAA2E,EAAE;YAClI,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,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AAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAA;QACjH,CAAC;KACF,CAAC,CAAC,CAAA;AACL,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared type contracts for dsh-memory-lite.
3
+ * @module dsh-memory-lite/src/types
4
+ */
5
+ /** The four memory categories the plugin generates. */
6
+ export declare const MEMORY_CATEGORIES: readonly ["preferences", "entities", "events", "experiences"];
7
+ /** One memory category name. */
8
+ export type MemoryCategory = (typeof MEMORY_CATEGORIES)[number];
9
+ /** One L0 index entry: a memory file and its one-line summary. */
10
+ export interface IndexEntry {
11
+ /** First path segment of {@link path} (the containing directory). */
12
+ readonly category: string;
13
+ /** Memory file path relative to the peer's memories root, e.g. `preferences/coding.md`. */
14
+ readonly path: string;
15
+ /** One-line summary rendered in the L0 catalog. */
16
+ readonly summary: string;
17
+ }
18
+ /**
19
+ * Durable provider record for one published memory catalog message: the
20
+ * entries it published beside the model-facing prose, so a consumer never
21
+ * re-parses the `<system-reminder>` framing, whose prose exists for the model.
22
+ */
23
+ export interface MemoryCatalogSource {
24
+ readonly kind: 'memory-catalog';
25
+ readonly form: 'catalog';
26
+ /** Marks a replacement catalog rather than this session's first publication. */
27
+ readonly update?: true;
28
+ /** Exactly the entries this message published, in catalog order. */
29
+ readonly entries: readonly IndexEntry[];
30
+ }
31
+ declare module '@deepseek-ai/dsh-llm' {
32
+ interface MessageSourceMap {
33
+ 'memory-catalog': MemoryCatalogSource;
34
+ }
35
+ }
package/lib/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared type contracts for dsh-memory-lite.
3
+ * @module dsh-memory-lite/src/types
4
+ */
5
+ /** The four memory categories the plugin generates. */
6
+ export const MEMORY_CATEGORIES = ['preferences', 'entities', 'events', 'experiences'];
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAU,CAAA"}
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@alanzhao/dsh-memory-lite",
3
+ "version": "0.1.1",
4
+ "description": "Lightweight zero-dependency memory plugin for DeepSeek Harness: Markdown-file memory store, L0 catalog injection, and 5 model-facing tools.",
5
+ "keywords": [
6
+ "dsh",
7
+ "dsh-plugin",
8
+ "memory",
9
+ "deepseek-harness"
10
+ ],
11
+ "type": "module",
12
+ "main": "lib/index.js",
13
+ "types": "lib/index.d.ts",
14
+ "files": [
15
+ "lib",
16
+ "cordis.patch.yml",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "license": "MIT",
21
+ "engines": {
22
+ "node": ">=22"
23
+ },
24
+ "dsh": {
25
+ "bundle": {
26
+ "patch": "./cordis.patch.yml"
27
+ },
28
+ "client": {
29
+ "inject": [
30
+ "@deepseek-ai/dsh-client-runtime",
31
+ "@deepseek-ai/dsh-client-connection",
32
+ "@deepseek-ai/dsh-client-locale",
33
+ "@deepseek-ai/dsh-client-ui-settings"
34
+ ],
35
+ "platform": "web"
36
+ }
37
+ },
38
+ "dependencies": {
39
+ "@deepseek-ai/dsh-atomic-write": "0.1.1-rc.2",
40
+ "@deepseek-ai/dsh-home-paths": "0.1.1-rc.2",
41
+ "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
42
+ "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
43
+ "@deepseek-ai/schemastery": "^3.18.1"
44
+ },
45
+ "peerDependencies": {
46
+ "@deepseek-ai/cordis": "^4.0.1"
47
+ },
48
+ "devDependencies": {
49
+ "@deepseek-ai/cordis": "^4.0.1",
50
+ "@deepseek-ai/cordis-plugin-loader": "^1.0.2",
51
+ "@deepseek-ai/dsh-agent": "0.1.1-rc.2",
52
+ "@deepseek-ai/dsh-app-boot": "^0.1.1-rc.2",
53
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
54
+ "@deepseek-ai/dsh-session": "0.1.1-rc.2",
55
+ "@deepseek-ai/dsh-tool-skill": "0.1.1-rc.2",
56
+ "@types/node": "^22.10.0",
57
+ "tsx": "^4.19.0",
58
+ "typescript": "^5.6.0",
59
+ "@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
60
+ "@deepseek-ai/cordis-plugin-timer": "^1.1.3"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc -p tsconfig.json",
64
+ "prepare": "npm run build",
65
+ "test": "node --import tsx --test tests/*.test.ts",
66
+ "clean": "rm -rf lib"
67
+ },
68
+ "exports": {
69
+ ".": {
70
+ "default": "./lib/index.js",
71
+ "types": "./lib/index.d.ts"
72
+ },
73
+ "./client": {
74
+ "default": "./lib/client.js"
75
+ },
76
+ "./package.json": "./package.json"
77
+ },
78
+ "publishConfig": {
79
+ "access": "public"
80
+ }
81
+ }