@waynesutton/agent-memory 0.0.1-alpha.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 (200) hide show
  1. package/.claude/settings.json +9 -0
  2. package/.claude/settings.local.json +7 -0
  3. package/AGENTS.md +113 -0
  4. package/CLAUDE.md +79 -0
  5. package/README.md +1003 -0
  6. package/dist/cli/index.d.ts +3 -0
  7. package/dist/cli/index.d.ts.map +1 -0
  8. package/dist/cli/index.js +192 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/cli/parsers/claude-code.d.ts +3 -0
  11. package/dist/cli/parsers/claude-code.d.ts.map +1 -0
  12. package/dist/cli/parsers/claude-code.js +75 -0
  13. package/dist/cli/parsers/claude-code.js.map +1 -0
  14. package/dist/cli/parsers/codex.d.ts +3 -0
  15. package/dist/cli/parsers/codex.d.ts.map +1 -0
  16. package/dist/cli/parsers/codex.js +42 -0
  17. package/dist/cli/parsers/codex.js.map +1 -0
  18. package/dist/cli/parsers/conductor.d.ts +3 -0
  19. package/dist/cli/parsers/conductor.d.ts.map +1 -0
  20. package/dist/cli/parsers/conductor.js +43 -0
  21. package/dist/cli/parsers/conductor.js.map +1 -0
  22. package/dist/cli/parsers/cursor.d.ts +3 -0
  23. package/dist/cli/parsers/cursor.d.ts.map +1 -0
  24. package/dist/cli/parsers/cursor.js +50 -0
  25. package/dist/cli/parsers/cursor.js.map +1 -0
  26. package/dist/cli/parsers/index.d.ts +12 -0
  27. package/dist/cli/parsers/index.d.ts.map +1 -0
  28. package/dist/cli/parsers/index.js +27 -0
  29. package/dist/cli/parsers/index.js.map +1 -0
  30. package/dist/cli/parsers/opencode.d.ts +3 -0
  31. package/dist/cli/parsers/opencode.d.ts.map +1 -0
  32. package/dist/cli/parsers/opencode.js +72 -0
  33. package/dist/cli/parsers/opencode.js.map +1 -0
  34. package/dist/cli/parsers/parsers.test.d.ts +2 -0
  35. package/dist/cli/parsers/parsers.test.d.ts.map +1 -0
  36. package/dist/cli/parsers/parsers.test.js +151 -0
  37. package/dist/cli/parsers/parsers.test.js.map +1 -0
  38. package/dist/cli/parsers/pi.d.ts +3 -0
  39. package/dist/cli/parsers/pi.d.ts.map +1 -0
  40. package/dist/cli/parsers/pi.js +43 -0
  41. package/dist/cli/parsers/pi.js.map +1 -0
  42. package/dist/cli/parsers/types.d.ts +25 -0
  43. package/dist/cli/parsers/types.d.ts.map +1 -0
  44. package/dist/cli/parsers/types.js +2 -0
  45. package/dist/cli/parsers/types.js.map +1 -0
  46. package/dist/cli/parsers/vscode-copilot.d.ts +3 -0
  47. package/dist/cli/parsers/vscode-copilot.d.ts.map +1 -0
  48. package/dist/cli/parsers/vscode-copilot.js +69 -0
  49. package/dist/cli/parsers/vscode-copilot.js.map +1 -0
  50. package/dist/cli/parsers/zed.d.ts +3 -0
  51. package/dist/cli/parsers/zed.d.ts.map +1 -0
  52. package/dist/cli/parsers/zed.js +43 -0
  53. package/dist/cli/parsers/zed.js.map +1 -0
  54. package/dist/cli/sync.d.ts +21 -0
  55. package/dist/cli/sync.d.ts.map +1 -0
  56. package/dist/cli/sync.js +78 -0
  57. package/dist/cli/sync.js.map +1 -0
  58. package/dist/cli/type-extractor.d.ts +25 -0
  59. package/dist/cli/type-extractor.d.ts.map +1 -0
  60. package/dist/cli/type-extractor.js +254 -0
  61. package/dist/cli/type-extractor.js.map +1 -0
  62. package/dist/cli/type-extractor.test.d.ts +2 -0
  63. package/dist/cli/type-extractor.test.d.ts.map +1 -0
  64. package/dist/cli/type-extractor.test.js +173 -0
  65. package/dist/cli/type-extractor.test.js.map +1 -0
  66. package/dist/client/http.d.ts +44 -0
  67. package/dist/client/http.d.ts.map +1 -0
  68. package/dist/client/http.js +311 -0
  69. package/dist/client/http.js.map +1 -0
  70. package/dist/client/index.d.ts +158 -0
  71. package/dist/client/index.d.ts.map +1 -0
  72. package/dist/client/index.js +256 -0
  73. package/dist/client/index.js.map +1 -0
  74. package/dist/component/_generated/api.d.ts +12 -0
  75. package/dist/component/_generated/api.d.ts.map +1 -0
  76. package/dist/component/_generated/api.js +13 -0
  77. package/dist/component/_generated/api.js.map +1 -0
  78. package/dist/component/_generated/dataModel.d.ts +18 -0
  79. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  80. package/dist/component/_generated/dataModel.js +11 -0
  81. package/dist/component/_generated/dataModel.js.map +1 -0
  82. package/dist/component/_generated/server.d.ts +42 -0
  83. package/dist/component/_generated/server.d.ts.map +1 -0
  84. package/dist/component/_generated/server.js +39 -0
  85. package/dist/component/_generated/server.js.map +1 -0
  86. package/dist/component/actions.d.ts +42 -0
  87. package/dist/component/actions.d.ts.map +1 -0
  88. package/dist/component/actions.js +405 -0
  89. package/dist/component/actions.js.map +1 -0
  90. package/dist/component/apiKeyMutations.d.ts +29 -0
  91. package/dist/component/apiKeyMutations.d.ts.map +1 -0
  92. package/dist/component/apiKeyMutations.js +149 -0
  93. package/dist/component/apiKeyMutations.js.map +1 -0
  94. package/dist/component/apiKeyQueries.d.ts +37 -0
  95. package/dist/component/apiKeyQueries.d.ts.map +1 -0
  96. package/dist/component/apiKeyQueries.js +127 -0
  97. package/dist/component/apiKeyQueries.js.map +1 -0
  98. package/dist/component/checksum.d.ts +6 -0
  99. package/dist/component/checksum.d.ts.map +1 -0
  100. package/dist/component/checksum.js +14 -0
  101. package/dist/component/checksum.js.map +1 -0
  102. package/dist/component/checksum.test.d.ts +2 -0
  103. package/dist/component/checksum.test.d.ts.map +1 -0
  104. package/dist/component/checksum.test.js +27 -0
  105. package/dist/component/checksum.test.js.map +1 -0
  106. package/dist/component/convex.config.d.ts +3 -0
  107. package/dist/component/convex.config.d.ts.map +1 -0
  108. package/dist/component/convex.config.js +4 -0
  109. package/dist/component/convex.config.js.map +1 -0
  110. package/dist/component/cronActions.d.ts +3 -0
  111. package/dist/component/cronActions.d.ts.map +1 -0
  112. package/dist/component/cronActions.js +38 -0
  113. package/dist/component/cronActions.js.map +1 -0
  114. package/dist/component/cronQueries.d.ts +6 -0
  115. package/dist/component/cronQueries.d.ts.map +1 -0
  116. package/dist/component/cronQueries.js +38 -0
  117. package/dist/component/cronQueries.js.map +1 -0
  118. package/dist/component/crons.d.ts +3 -0
  119. package/dist/component/crons.d.ts.map +1 -0
  120. package/dist/component/crons.js +18 -0
  121. package/dist/component/crons.js.map +1 -0
  122. package/dist/component/format.d.ts +11 -0
  123. package/dist/component/format.d.ts.map +1 -0
  124. package/dist/component/format.js +175 -0
  125. package/dist/component/format.js.map +1 -0
  126. package/dist/component/format.test.d.ts +2 -0
  127. package/dist/component/format.test.d.ts.map +1 -0
  128. package/dist/component/format.test.js +118 -0
  129. package/dist/component/format.test.js.map +1 -0
  130. package/dist/component/mutations.d.ts +158 -0
  131. package/dist/component/mutations.d.ts.map +1 -0
  132. package/dist/component/mutations.js +745 -0
  133. package/dist/component/mutations.js.map +1 -0
  134. package/dist/component/queries.d.ts +94 -0
  135. package/dist/component/queries.d.ts.map +1 -0
  136. package/dist/component/queries.js +574 -0
  137. package/dist/component/queries.js.map +1 -0
  138. package/dist/component/schema.d.ts +278 -0
  139. package/dist/component/schema.d.ts.map +1 -0
  140. package/dist/component/schema.js +161 -0
  141. package/dist/component/schema.js.map +1 -0
  142. package/dist/mcp/server.d.ts +11 -0
  143. package/dist/mcp/server.d.ts.map +1 -0
  144. package/dist/mcp/server.js +571 -0
  145. package/dist/mcp/server.js.map +1 -0
  146. package/dist/shared.d.ts +126 -0
  147. package/dist/shared.d.ts.map +1 -0
  148. package/dist/shared.js +67 -0
  149. package/dist/shared.js.map +1 -0
  150. package/dist/test.d.ts +23 -0
  151. package/dist/test.d.ts.map +1 -0
  152. package/dist/test.js +21 -0
  153. package/dist/test.js.map +1 -0
  154. package/eslint.config.js +15 -0
  155. package/example/convex/convex.config.ts +7 -0
  156. package/example/convex/memory.ts +129 -0
  157. package/llms.md +175 -0
  158. package/llms.txt +126 -0
  159. package/package.json +80 -0
  160. package/prds/API-REFERENCE.md +935 -0
  161. package/prds/SETUP.md +682 -0
  162. package/src/cli/index.ts +254 -0
  163. package/src/cli/parsers/claude-code.ts +80 -0
  164. package/src/cli/parsers/codex.ts +45 -0
  165. package/src/cli/parsers/conductor.ts +47 -0
  166. package/src/cli/parsers/cursor.ts +55 -0
  167. package/src/cli/parsers/index.ts +30 -0
  168. package/src/cli/parsers/opencode.ts +84 -0
  169. package/src/cli/parsers/parsers.test.ts +201 -0
  170. package/src/cli/parsers/pi.ts +47 -0
  171. package/src/cli/parsers/types.ts +26 -0
  172. package/src/cli/parsers/vscode-copilot.ts +78 -0
  173. package/src/cli/parsers/zed.ts +47 -0
  174. package/src/cli/sync.ts +110 -0
  175. package/src/cli/type-extractor.test.ts +241 -0
  176. package/src/cli/type-extractor.ts +331 -0
  177. package/src/client/http.ts +415 -0
  178. package/src/client/index.ts +519 -0
  179. package/src/component/_generated/api.ts +14 -0
  180. package/src/component/_generated/dataModel.ts +20 -0
  181. package/src/component/_generated/server.ts +64 -0
  182. package/src/component/actions.ts +558 -0
  183. package/src/component/apiKeyMutations.ts +175 -0
  184. package/src/component/apiKeyQueries.ts +156 -0
  185. package/src/component/checksum.test.ts +31 -0
  186. package/src/component/checksum.ts +13 -0
  187. package/src/component/convex.config.ts +5 -0
  188. package/src/component/cronActions.ts +52 -0
  189. package/src/component/cronQueries.ts +42 -0
  190. package/src/component/crons.ts +34 -0
  191. package/src/component/format.test.ts +133 -0
  192. package/src/component/format.ts +232 -0
  193. package/src/component/mutations.ts +824 -0
  194. package/src/component/queries.ts +684 -0
  195. package/src/component/schema.ts +207 -0
  196. package/src/mcp/server.ts +695 -0
  197. package/src/shared.ts +251 -0
  198. package/src/test.ts +32 -0
  199. package/tsconfig.json +21 -0
  200. package/vitest.config.ts +8 -0
@@ -0,0 +1,232 @@
1
+ import type { Doc } from "./_generated/dataModel.js";
2
+
3
+ type MemoryDoc = Doc<"memories">;
4
+
5
+ export interface FormattedFile {
6
+ path: string;
7
+ content: string;
8
+ checksum: string;
9
+ }
10
+
11
+ // ── Claude Code ─────────────────────────────────────────────────────
12
+
13
+ function formatClaudeCode(memory: MemoryDoc, projectSlug: string): FormattedFile {
14
+ const hasPaths = memory.paths && memory.paths.length > 0;
15
+ let content = "";
16
+
17
+ if (hasPaths) {
18
+ content += "---\n";
19
+ content += "paths:\n";
20
+ for (const p of memory.paths!) {
21
+ content += ` - "${p}"\n`;
22
+ }
23
+ content += "---\n\n";
24
+ }
25
+
26
+ content += memory.content;
27
+
28
+ const isInstruction = memory.memoryType === "instruction";
29
+ const path = isInstruction
30
+ ? `.claude/rules/${sanitizeFilename(memory.title)}.md`
31
+ : `.claude/projects/${projectSlug}/memory/${sanitizeFilename(memory.title)}.md`;
32
+
33
+ return { path, content, checksum: memory.checksum };
34
+ }
35
+
36
+ // ── Cursor ──────────────────────────────────────────────────────────
37
+
38
+ function formatCursor(memory: MemoryDoc): FormattedFile {
39
+ let content = "---\n";
40
+ content += `description: ${memory.title}\n`;
41
+
42
+ if (memory.paths && memory.paths.length > 0) {
43
+ content += "paths:\n";
44
+ for (const p of memory.paths) {
45
+ content += ` - "${p}"\n`;
46
+ }
47
+ }
48
+
49
+ const alwaysApply =
50
+ memory.priority !== undefined && memory.priority >= 0.8;
51
+ content += `alwaysApply: ${alwaysApply}\n`;
52
+ content += "---\n\n";
53
+ content += memory.content;
54
+
55
+ return {
56
+ path: `.cursor/rules/${sanitizeFilename(memory.title)}.mdc`,
57
+ content,
58
+ checksum: memory.checksum,
59
+ };
60
+ }
61
+
62
+ // ── OpenCode ────────────────────────────────────────────────────────
63
+
64
+ function formatOpenCode(memory: MemoryDoc): FormattedFile {
65
+ if (memory.memoryType === "journal") {
66
+ return {
67
+ path: `journal/${sanitizeFilename(memory.title)}.md`,
68
+ content: memory.content,
69
+ checksum: memory.checksum,
70
+ };
71
+ }
72
+
73
+ // Instructions get merged into AGENTS.md sections
74
+ return {
75
+ path: "AGENTS.md",
76
+ content: `## ${memory.title}\n\n${memory.content}`,
77
+ checksum: memory.checksum,
78
+ };
79
+ }
80
+
81
+ // ── Codex ───────────────────────────────────────────────────────────
82
+
83
+ function formatCodex(memory: MemoryDoc): FormattedFile {
84
+ // If paths all share a common directory prefix, place there
85
+ const dir = commonPathPrefix(memory.paths);
86
+ const path = dir ? `${dir}/AGENTS.md` : "AGENTS.md";
87
+
88
+ return {
89
+ path,
90
+ content: `## ${memory.title}\n\n${memory.content}`,
91
+ checksum: memory.checksum,
92
+ };
93
+ }
94
+
95
+ // ── Conductor ───────────────────────────────────────────────────────
96
+
97
+ function formatConductor(memory: MemoryDoc): FormattedFile {
98
+ return {
99
+ path: `.conductor/rules/${sanitizeFilename(memory.title)}.md`,
100
+ content: memory.content,
101
+ checksum: memory.checksum,
102
+ };
103
+ }
104
+
105
+ // ── Zed ─────────────────────────────────────────────────────────────
106
+
107
+ function formatZed(memory: MemoryDoc): FormattedFile {
108
+ return {
109
+ path: `.zed/rules/${sanitizeFilename(memory.title)}.md`,
110
+ content: memory.content,
111
+ checksum: memory.checksum,
112
+ };
113
+ }
114
+
115
+ // ── VS Code Copilot ─────────────────────────────────────────────────
116
+
117
+ function formatVSCodeCopilot(memory: MemoryDoc): FormattedFile {
118
+ return {
119
+ path: `.github/copilot-instructions.md`,
120
+ content: `## ${memory.title}\n\n${memory.content}`,
121
+ checksum: memory.checksum,
122
+ };
123
+ }
124
+
125
+ // ── Pi ──────────────────────────────────────────────────────────────
126
+
127
+ function formatPi(memory: MemoryDoc): FormattedFile {
128
+ return {
129
+ path: `.pi/rules/${sanitizeFilename(memory.title)}.md`,
130
+ content: memory.content,
131
+ checksum: memory.checksum,
132
+ };
133
+ }
134
+
135
+ // ── Raw (markdown as-is) ────────────────────────────────────────────
136
+
137
+ function formatRaw(memory: MemoryDoc): FormattedFile {
138
+ let content = "---\n";
139
+ content += `title: ${memory.title}\n`;
140
+ content += `type: ${memory.memoryType}\n`;
141
+ content += `scope: ${memory.scope}\n`;
142
+ if (memory.tags.length > 0) {
143
+ content += `tags: [${memory.tags.map((t: string) => `"${t}"`).join(", ")}]\n`;
144
+ }
145
+ if (memory.priority !== undefined) {
146
+ content += `priority: ${memory.priority}\n`;
147
+ }
148
+ if (memory.paths && memory.paths.length > 0) {
149
+ content += "paths:\n";
150
+ for (const p of memory.paths) {
151
+ content += ` - "${p}"\n`;
152
+ }
153
+ }
154
+ content += "---\n\n";
155
+ content += memory.content;
156
+
157
+ return {
158
+ path: `memories/${sanitizeFilename(memory.title)}.md`,
159
+ content,
160
+ checksum: memory.checksum,
161
+ };
162
+ }
163
+
164
+ // ── Public API ──────────────────────────────────────────────────────
165
+
166
+ export type ToolFormat =
167
+ | "claude-code"
168
+ | "cursor"
169
+ | "opencode"
170
+ | "codex"
171
+ | "conductor"
172
+ | "zed"
173
+ | "vscode-copilot"
174
+ | "pi"
175
+ | "raw";
176
+
177
+ export function formatMemoryForTool(
178
+ memory: MemoryDoc,
179
+ format: ToolFormat,
180
+ projectSlug?: string,
181
+ ): FormattedFile {
182
+ switch (format) {
183
+ case "claude-code":
184
+ return formatClaudeCode(memory, projectSlug ?? "default");
185
+ case "cursor":
186
+ return formatCursor(memory);
187
+ case "opencode":
188
+ return formatOpenCode(memory);
189
+ case "codex":
190
+ return formatCodex(memory);
191
+ case "conductor":
192
+ return formatConductor(memory);
193
+ case "zed":
194
+ return formatZed(memory);
195
+ case "vscode-copilot":
196
+ return formatVSCodeCopilot(memory);
197
+ case "pi":
198
+ return formatPi(memory);
199
+ case "raw":
200
+ return formatRaw(memory);
201
+ }
202
+ }
203
+
204
+ // ── Helpers ─────────────────────────────────────────────────────────
205
+
206
+ function sanitizeFilename(title: string): string {
207
+ return title
208
+ .toLowerCase()
209
+ .replace(/[^a-z0-9-_]/g, "-")
210
+ .replace(/-+/g, "-")
211
+ .replace(/^-|-$/g, "");
212
+ }
213
+
214
+ function commonPathPrefix(paths?: string[]): string {
215
+ if (!paths || paths.length === 0) return "";
216
+ if (paths.length === 1) {
217
+ const parts = paths[0].split("/");
218
+ return parts.length > 1 ? parts.slice(0, -1).join("/") : "";
219
+ }
220
+
221
+ const split = paths.map((p) => p.split("/"));
222
+ const prefix: string[] = [];
223
+ for (let i = 0; i < split[0].length; i++) {
224
+ const segment = split[0][i];
225
+ if (split.every((parts) => parts[i] === segment)) {
226
+ prefix.push(segment);
227
+ } else {
228
+ break;
229
+ }
230
+ }
231
+ return prefix.join("/");
232
+ }