@waynesutton/agent-memory 0.0.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 (201) 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 +1 -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 +72 -0
  160. package/prds/API-REFERENCE.md +935 -0
  161. package/prds/README.md +988 -0
  162. package/prds/SETUP.md +682 -0
  163. package/src/cli/index.ts +254 -0
  164. package/src/cli/parsers/claude-code.ts +80 -0
  165. package/src/cli/parsers/codex.ts +45 -0
  166. package/src/cli/parsers/conductor.ts +47 -0
  167. package/src/cli/parsers/cursor.ts +55 -0
  168. package/src/cli/parsers/index.ts +30 -0
  169. package/src/cli/parsers/opencode.ts +84 -0
  170. package/src/cli/parsers/parsers.test.ts +201 -0
  171. package/src/cli/parsers/pi.ts +47 -0
  172. package/src/cli/parsers/types.ts +26 -0
  173. package/src/cli/parsers/vscode-copilot.ts +78 -0
  174. package/src/cli/parsers/zed.ts +47 -0
  175. package/src/cli/sync.ts +110 -0
  176. package/src/cli/type-extractor.test.ts +241 -0
  177. package/src/cli/type-extractor.ts +331 -0
  178. package/src/client/http.ts +415 -0
  179. package/src/client/index.ts +519 -0
  180. package/src/component/_generated/api.ts +14 -0
  181. package/src/component/_generated/dataModel.ts +20 -0
  182. package/src/component/_generated/server.ts +64 -0
  183. package/src/component/actions.ts +558 -0
  184. package/src/component/apiKeyMutations.ts +175 -0
  185. package/src/component/apiKeyQueries.ts +156 -0
  186. package/src/component/checksum.test.ts +31 -0
  187. package/src/component/checksum.ts +13 -0
  188. package/src/component/convex.config.ts +5 -0
  189. package/src/component/cronActions.ts +52 -0
  190. package/src/component/cronQueries.ts +42 -0
  191. package/src/component/crons.ts +34 -0
  192. package/src/component/format.test.ts +133 -0
  193. package/src/component/format.ts +232 -0
  194. package/src/component/mutations.ts +824 -0
  195. package/src/component/queries.ts +684 -0
  196. package/src/component/schema.ts +207 -0
  197. package/src/mcp/server.ts +695 -0
  198. package/src/shared.ts +251 -0
  199. package/src/test.ts +32 -0
  200. package/tsconfig.json +21 -0
  201. package/vitest.config.ts +8 -0
package/src/shared.ts ADDED
@@ -0,0 +1,251 @@
1
+ import { v } from "convex/values";
2
+
3
+ // ── Memory types ────────────────────────────────────────────────────
4
+ // instruction: maps to CLAUDE.md / .cursor/rules / AGENTS.md
5
+ // learning: auto-discovered patterns (auto-memory)
6
+ // reference: architecture docs, API specs
7
+ // feedback: corrections, preferences
8
+ // journal: session logs (OpenCode-style)
9
+
10
+ export const MEMORY_TYPES = [
11
+ "instruction",
12
+ "learning",
13
+ "reference",
14
+ "feedback",
15
+ "journal",
16
+ ] as const;
17
+
18
+ export type MemoryType = (typeof MEMORY_TYPES)[number];
19
+
20
+ export const memoryTypeValidator = v.union(
21
+ v.literal("instruction"),
22
+ v.literal("learning"),
23
+ v.literal("reference"),
24
+ v.literal("feedback"),
25
+ v.literal("journal"),
26
+ );
27
+
28
+ // ── Scope types ─────────────────────────────────────────────────────
29
+ // project: shared across team via Convex
30
+ // user: personal to one user
31
+ // org: organization-wide policies
32
+
33
+ export const SCOPES = ["project", "user", "org"] as const;
34
+ export type Scope = (typeof SCOPES)[number];
35
+
36
+ export const scopeValidator = v.union(
37
+ v.literal("project"),
38
+ v.literal("user"),
39
+ v.literal("org"),
40
+ );
41
+
42
+ // ── Sync direction ──────────────────────────────────────────────────
43
+
44
+ export const syncDirectionValidator = v.union(
45
+ v.literal("push"),
46
+ v.literal("pull"),
47
+ );
48
+
49
+ // ── Tool formats ────────────────────────────────────────────────────
50
+
51
+ export const TOOL_FORMATS = [
52
+ "claude-code",
53
+ "cursor",
54
+ "opencode",
55
+ "codex",
56
+ "conductor",
57
+ "zed",
58
+ "vscode-copilot",
59
+ "pi",
60
+ "raw",
61
+ ] as const;
62
+
63
+ export type ToolFormat = (typeof TOOL_FORMATS)[number];
64
+
65
+ export const toolFormatValidator = v.union(
66
+ v.literal("claude-code"),
67
+ v.literal("cursor"),
68
+ v.literal("opencode"),
69
+ v.literal("codex"),
70
+ v.literal("conductor"),
71
+ v.literal("zed"),
72
+ v.literal("vscode-copilot"),
73
+ v.literal("pi"),
74
+ v.literal("raw"),
75
+ );
76
+
77
+ // ── History events ──────────────────────────────────────────────────
78
+
79
+ export const HISTORY_EVENTS = [
80
+ "created",
81
+ "updated",
82
+ "archived",
83
+ "restored",
84
+ "merged",
85
+ ] as const;
86
+
87
+ export type HistoryEvent = (typeof HISTORY_EVENTS)[number];
88
+
89
+ // ── Feedback sentiments ─────────────────────────────────────────────
90
+
91
+ export const FEEDBACK_SENTIMENTS = [
92
+ "positive",
93
+ "negative",
94
+ "very_negative",
95
+ ] as const;
96
+
97
+ export type FeedbackSentiment = (typeof FEEDBACK_SENTIMENTS)[number];
98
+
99
+ // ── Ingest events ───────────────────────────────────────────────────
100
+
101
+ export const INGEST_EVENTS = [
102
+ "added",
103
+ "updated",
104
+ "deleted",
105
+ "skipped",
106
+ ] as const;
107
+
108
+ export type IngestEvent = (typeof INGEST_EVENTS)[number];
109
+
110
+ // ── Memory document shape (for client-side typing) ──────────────────
111
+
112
+ export interface Memory {
113
+ _id: string;
114
+ _creationTime: number;
115
+ projectId: string;
116
+ scope: Scope;
117
+ userId?: string;
118
+ agentId?: string;
119
+ sessionId?: string;
120
+ title: string;
121
+ content: string;
122
+ memoryType: MemoryType;
123
+ tags: string[];
124
+ paths?: string[];
125
+ priority?: number;
126
+ source?: string;
127
+ lastSyncedAt?: number;
128
+ checksum: string;
129
+ archived: boolean;
130
+ embeddingId?: string;
131
+ // Access tracking
132
+ accessCount?: number;
133
+ lastAccessedAt?: number;
134
+ // Feedback aggregation
135
+ positiveCount?: number;
136
+ negativeCount?: number;
137
+ }
138
+
139
+ export interface ContextBundle {
140
+ pinned: Memory[];
141
+ relevant: Memory[];
142
+ available: Array<{
143
+ _id: string;
144
+ title: string;
145
+ memoryType: MemoryType;
146
+ priority: number;
147
+ }>;
148
+ }
149
+
150
+ export interface ExportedFile {
151
+ path: string;
152
+ content: string;
153
+ checksum: string;
154
+ }
155
+
156
+ export interface ImportResult {
157
+ created: number;
158
+ updated: number;
159
+ unchanged: number;
160
+ }
161
+
162
+ // ── History record ──────────────────────────────────────────────────
163
+
164
+ export interface MemoryHistoryEntry {
165
+ _id: string;
166
+ _creationTime: number;
167
+ memoryId: string;
168
+ projectId: string;
169
+ previousContent?: string;
170
+ newContent?: string;
171
+ previousTitle?: string;
172
+ newTitle?: string;
173
+ event: HistoryEvent;
174
+ actor: string;
175
+ timestamp: number;
176
+ }
177
+
178
+ // ── Feedback record ─────────────────────────────────────────────────
179
+
180
+ export interface MemoryFeedbackEntry {
181
+ _id: string;
182
+ _creationTime: number;
183
+ memoryId: string;
184
+ projectId: string;
185
+ sentiment: FeedbackSentiment;
186
+ comment?: string;
187
+ actor: string;
188
+ timestamp: number;
189
+ }
190
+
191
+ // ── Memory relation ─────────────────────────────────────────────────
192
+
193
+ export interface MemoryRelation {
194
+ _id: string;
195
+ _creationTime: number;
196
+ projectId: string;
197
+ fromMemoryId: string;
198
+ toMemoryId: string;
199
+ relationship: string;
200
+ metadata?: {
201
+ confidence?: number;
202
+ createdBy?: string;
203
+ };
204
+ timestamp: number;
205
+ }
206
+
207
+ // ── Ingest result ───────────────────────────────────────────────────
208
+
209
+ export interface IngestResult {
210
+ results: Array<{
211
+ memoryId: string;
212
+ content: string;
213
+ event: IngestEvent;
214
+ previousContent?: string;
215
+ }>;
216
+ totalProcessed: number;
217
+ }
218
+
219
+ // ── API key types ───────────────────────────────────────────────────
220
+
221
+ export interface ApiKeyInfo {
222
+ _id: string;
223
+ keyHash: string;
224
+ projectId: string;
225
+ name: string;
226
+ permissions: string[];
227
+ rateLimitOverride?: {
228
+ requestsPerWindow: number;
229
+ windowMs: number;
230
+ };
231
+ lastUsedAt?: number;
232
+ expiresAt?: number;
233
+ revoked: boolean;
234
+ }
235
+
236
+ export interface ApiKeyCreateResult {
237
+ key: string; // plaintext key — only returned once
238
+ keyHash: string;
239
+ }
240
+
241
+ export const API_PERMISSIONS = [
242
+ "list",
243
+ "get",
244
+ "search",
245
+ "context",
246
+ "export",
247
+ "history",
248
+ "relations",
249
+ ] as const;
250
+
251
+ export type ApiPermission = (typeof API_PERMISSIONS)[number];
package/src/test.ts ADDED
@@ -0,0 +1,32 @@
1
+ import schema from "./component/schema.js";
2
+
3
+ // Vite's import.meta.glob — typed for convex-test compatibility
4
+ declare global {
5
+ interface ImportMeta {
6
+ glob(pattern: string): Record<string, () => Promise<unknown>>;
7
+ }
8
+ }
9
+
10
+ const modules = import.meta.glob("./component/**/*.ts");
11
+
12
+ /**
13
+ * Register the agentMemory component in a convex-test instance.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import agentMemoryTest from "@waynesutton/agent-memory/test";
18
+ * import { convexTest } from "convex-test";
19
+ *
20
+ * const t = convexTest();
21
+ * agentMemoryTest.register(t);
22
+ * ```
23
+ */
24
+ export function register(
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ t: any,
27
+ name: string = "agentMemory",
28
+ ) {
29
+ t.registerComponent(name, schema, modules);
30
+ }
31
+
32
+ export default { register };
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "jsx": "react-jsx"
18
+ },
19
+ "include": ["src/**/*"],
20
+ "exclude": ["node_modules", "dist", "example"]
21
+ }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: "node",
6
+ include: ["src/**/*.test.ts"],
7
+ },
8
+ });