claude-mem-opencode 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 (59) hide show
  1. package/README.md +391 -0
  2. package/dist/bundle/claude-mem-opencode.js +542 -0
  3. package/dist/bundle/index.d.ts +13 -0
  4. package/dist/bundle/index.d.ts.map +1 -0
  5. package/dist/bundle/index.js.map +1 -0
  6. package/dist/bundle/package.json +10 -0
  7. package/dist/bundle/skill/SKILL.md +118 -0
  8. package/dist/bundle/skill/operations/search.md +178 -0
  9. package/dist/bundle/skill/operations/timeline.md +269 -0
  10. package/dist/bundle/skill/operations/workflow.md +375 -0
  11. package/dist/cli.d.ts +6 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +164 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/integration/context-injector.d.ts +19 -0
  16. package/dist/integration/context-injector.d.ts.map +1 -0
  17. package/dist/integration/context-injector.js +47 -0
  18. package/dist/integration/context-injector.js.map +1 -0
  19. package/dist/integration/event-listeners.d.ts +41 -0
  20. package/dist/integration/event-listeners.d.ts.map +1 -0
  21. package/dist/integration/event-listeners.js +156 -0
  22. package/dist/integration/event-listeners.js.map +1 -0
  23. package/dist/integration/index.d.ts +66 -0
  24. package/dist/integration/index.d.ts.map +1 -0
  25. package/dist/integration/index.js +127 -0
  26. package/dist/integration/index.js.map +1 -0
  27. package/dist/integration/session-mapper.d.ts +39 -0
  28. package/dist/integration/session-mapper.d.ts.map +1 -0
  29. package/dist/integration/session-mapper.js +63 -0
  30. package/dist/integration/session-mapper.js.map +1 -0
  31. package/dist/integration/test.d.ts +6 -0
  32. package/dist/integration/test.d.ts.map +1 -0
  33. package/dist/integration/test.js +73 -0
  34. package/dist/integration/test.js.map +1 -0
  35. package/dist/integration/utils/logger.d.ts +15 -0
  36. package/dist/integration/utils/logger.d.ts.map +1 -0
  37. package/dist/integration/utils/logger.js +26 -0
  38. package/dist/integration/utils/logger.js.map +1 -0
  39. package/dist/integration/utils/privacy.d.ts +32 -0
  40. package/dist/integration/utils/privacy.d.ts.map +1 -0
  41. package/dist/integration/utils/privacy.js +62 -0
  42. package/dist/integration/utils/privacy.js.map +1 -0
  43. package/dist/integration/utils/project-name.d.ts +16 -0
  44. package/dist/integration/utils/project-name.d.ts.map +1 -0
  45. package/dist/integration/utils/project-name.js +28 -0
  46. package/dist/integration/utils/project-name.js.map +1 -0
  47. package/dist/integration/version-checker.d.ts +52 -0
  48. package/dist/integration/version-checker.d.ts.map +1 -0
  49. package/dist/integration/version-checker.js +121 -0
  50. package/dist/integration/version-checker.js.map +1 -0
  51. package/dist/integration/worker-client.d.ts +94 -0
  52. package/dist/integration/worker-client.d.ts.map +1 -0
  53. package/dist/integration/worker-client.js +188 -0
  54. package/dist/integration/worker-client.js.map +1 -0
  55. package/dist/test.d.ts +6 -0
  56. package/dist/test.d.ts.map +1 -0
  57. package/dist/test.js +73 -0
  58. package/dist/test.js.map +1 -0
  59. package/package.json +69 -0
@@ -0,0 +1,375 @@
1
+ # Workflow Operation
2
+
3
+ 3-layer workflow pattern for systematic memory retrieval.
4
+
5
+ ## Description
6
+
7
+ The workflow operation implements a systematic 3-layer approach to memory retrieval. Each layer provides different context and filtering, helping you efficiently find relevant information from your coding history.
8
+
9
+ ## 3 Layers
10
+
11
+ ### Layer 1: Broad Overview
12
+ **Goal**: Get high-level context about your query
13
+
14
+ - Retrieves project context
15
+ - Shows recent sessions
16
+ - Provides timeline overview
17
+ - ~50 tokens of context
18
+
19
+ ### Layer 2: Focused Search
20
+ **Goal**: Find specific memories related to your query
21
+
22
+ - Natural language search
23
+ - Type-based filtering
24
+ - Relevance-ranked results
25
+ - ~200 tokens of context
26
+
27
+ ### Layer 3: Detailed Analysis
28
+ **Goal**: Drill into specific operations and context
29
+
30
+ - Detailed operation history
31
+ - File-by-file breakdown
32
+ - Timeline context around results
33
+ - ~500-1000 tokens of context
34
+
35
+ ## When to Use Each Layer
36
+
37
+ | Situation | Recommended Layer |
38
+ |-----------|-------------------|
39
+ | "What did we do yesterday?" | Layer 1 (Overview) |
40
+ | "Find all bash commands for X" | Layer 2 (Focused) |
41
+ | "How exactly did we implement Y?" | Layer 3 (Detailed) |
42
+ | "What's the context for this project?" | Layer 1 (Overview) |
43
+ | "Show me file operations in session X" | Layer 3 (Detailed) |
44
+ | "Find code related to authentication" | Layer 2 (Focused) |
45
+
46
+ ## Examples
47
+
48
+ ### Example 1: Feature Implementation
49
+
50
+ **User Query**: "How did we implement authentication?"
51
+
52
+ **Layer 1 - Overview**:
53
+ ```
54
+ Project Context: auth-project
55
+ Recent Sessions (last 3):
56
+ - Session 5 (2025-01-02): Added OAuth
57
+ - Session 4 (2025-01-02): Token validation
58
+ - Session 3 (2025-01-01): Login route
59
+
60
+ Summary: Implemented JWT-based authentication with OAuth support
61
+ (50 tokens)
62
+ ```
63
+
64
+ **Layer 2 - Focused Search**:
65
+ ```
66
+ Search Results for "authentication implementation":
67
+
68
+ 1. Created AuthContext.ts (2025-01-02 09:00)
69
+ - Implemented user context provider
70
+ - Added token storage logic
71
+
72
+ 2. Created login route (2025-01-02 10:30)
73
+ - Added /api/auth/login endpoint
74
+ - Implemented password verification
75
+
76
+ 3. Added JWT middleware (2025-01-02 11:15)
77
+ - Created token validation middleware
78
+ - Added protected route handler
79
+
80
+ (200 tokens)
81
+ ```
82
+
83
+ **Layer 3 - Detailed Analysis**:
84
+ ```
85
+ Detailed Timeline for Authentication:
86
+
87
+ Session 3 (2025-01-01 09:00-12:00):
88
+ - 09:00 - Created auth directory
89
+ - 09:05 - Created AuthContext.ts (15 lines)
90
+ - 09:10 - Created login route (23 lines)
91
+ - 09:15 - Installed jsonwebtoken
92
+ - 09:20 - Updated user model
93
+ - 09:30 - Added password hashing
94
+ - 09:45 - Created register route
95
+ - 10:00 - Added authentication tests
96
+ - 11:00 - Fixed login bug
97
+ - 11:30 - Added error handling
98
+ - 11:45 - Documented API endpoints
99
+
100
+ Session 4 (2025-01-02 09:00-11:00):
101
+ - 09:00 - Added JWT validation
102
+ - 09:15 - Created middleware
103
+ - 09:30 - Updated routes with auth
104
+ - 09:45 - Added token refresh
105
+ - 10:00 - Implemented logout
106
+ - 10:30 - Added user session tracking
107
+
108
+ Session 5 (2025-01-02 14:00-16:00):
109
+ - 14:00 - Added OAuth dependency
110
+ - 14:15 - Created OAuth service
111
+ - 14:30 - Implemented Google OAuth
112
+ - 14:45 - Added OAuth callback
113
+ - 15:00 - Updated user model with OAuth fields
114
+ - 15:15 - Created OAuth controller
115
+ - 15:30 - Added OAuth tests
116
+ - 15:45 - Updated documentation
117
+ - 16:00 - Tested OAuth flow
118
+
119
+ (800 tokens)
120
+ ```
121
+
122
+ ### Example 2: Bug Investigation
123
+
124
+ **User Query**: "When did we modify user.ts?"
125
+
126
+ **Layer 1 - Overview**:
127
+ ```
128
+ Recent User-related Activity:
129
+ - Session 7 (2025-01-03): Fixed user type
130
+ - Session 6 (2025-01-03): Added profile fields
131
+ - Session 5 (2025-01-02): OAuth integration
132
+
133
+ (50 tokens)
134
+ ```
135
+
136
+ **Layer 2 - Focused Search**:
137
+ ```
138
+ Search Results for "user.ts modification":
139
+
140
+ 1. Modified user.ts (2025-01-03 10:00)
141
+ - Added email field to User interface
142
+ - Updated type definition
143
+
144
+ 2. Modified user.ts (2025-01-03 14:00)
145
+ - Fixed optional email field
146
+ - Added profile picture URL
147
+
148
+ 3. Modified user.ts (2025-01-02 11:00)
149
+ - Added OAuth provider fields
150
+ - Updated user schema
151
+
152
+ (150 tokens)
153
+ ```
154
+
155
+ **Layer 3 - Detailed Analysis**:
156
+ ```
157
+ Detailed Timeline for user.ts Modifications:
158
+
159
+ Session 5 (2025-01-02 11:00-11:30):
160
+ - 11:00 - Read user.ts (original: 20 lines)
161
+ - 11:05 - Added email field to interface
162
+ - 11:10 - Updated type to include OAuth
163
+ - 11:15 - Added profile picture URL
164
+ - 11:20 - Updated export
165
+ - 11:25 - Saved file
166
+
167
+ Session 6 (2025-01-03 10:00-10:45):
168
+ - 10:00 - Read user.ts (30 lines)
169
+ - 10:05 - Modified email to optional
170
+ - 10:10 - Added profile picture URL field
171
+ - 10:15 - Updated TypeScript types
172
+ - 10:20 - Added validation functions
173
+ - 10:25 - Updated user service
174
+ - 10:30 - Added profile upload
175
+ - 10:35 - Updated tests
176
+ - 10:40 - Fixed TypeScript errors
177
+ - 10:45 - Committed changes
178
+
179
+ Session 7 (2025-01-03 14:00-14:30):
180
+ - 14:00 - Read user.ts
181
+ - 14:05 - Fixed email validation
182
+ - 14:10 - Added profile picture size validation
183
+ - 14:15 - Updated error messages
184
+ - 14:20 - Updated documentation
185
+ - 14:25 - Ran tests
186
+ - 14:30 - Verified all tests passing
187
+
188
+ (600 tokens)
189
+ ```
190
+
191
+ ### Example 3: Setup Context
192
+
193
+ **User Query**: "What was the setup process for this project?"
194
+
195
+ **Layer 1 - Overview**:
196
+ ```
197
+ Project Context: my-app
198
+ Setup Date: 2025-01-01
199
+
200
+ Initial Sessions:
201
+ - Session 1 (2025-01-01): Project initialization
202
+ - Session 2 (2025-01-01): Dependency installation
203
+ - Session 3 (2025-01-01): Database setup
204
+
205
+ (50 tokens)
206
+ ```
207
+
208
+ **Layer 2 - Focused Search**:
209
+ ```
210
+ Search Results for "project setup":
211
+
212
+ 1. Created package.json (2025-01-01 09:00)
213
+ - Initialized npm project
214
+ - Added dependencies
215
+
216
+ 2. Installed dependencies (2025-01-01 09:30)
217
+ - Installed TypeScript
218
+ - Installed Express
219
+ - Installed Prisma
220
+
221
+ 3. Database setup (2025-01-01 14:00)
222
+ - Initialized Prisma
223
+ - Created database schema
224
+ - Ran migrations
225
+
226
+ (150 tokens)
227
+ ```
228
+
229
+ **Layer 3 - Detailed Analysis**:
230
+ ```
231
+ Detailed Setup Timeline:
232
+
233
+ Session 1 (2025-01-01 09:00-10:00):
234
+ - 09:00 - mkdir my-app
235
+ - 09:05 - cd my-app
236
+ - 09:10 - npm init -y
237
+ - 09:15 - npm install typescript @types/node
238
+ - 09:20 - npm install express
239
+ - 09:25 - npx tsc --init
240
+ - 09:30 - Created tsconfig.json
241
+ - 09:35 - Created src directory
242
+ - 09:40 - Created index.ts
243
+ - 09:45 - Added basic Express server
244
+ - 09:50 - Tested server startup
245
+ - 09:55 - Added .gitignore
246
+
247
+ Session 2 (2025-01-01 10:00-11:00):
248
+ - 10:00 - npm install -D eslint prettier
249
+ - 10:05 - Created .eslintrc.js
250
+ - 10:10 - Created .prettierrc
251
+ - 10:15 - Added lint scripts to package.json
252
+ - 10:20 - npm install -D @types/express
253
+ - 10:25 - Fixed TypeScript errors
254
+ - 10:30 - npm install dotenv
255
+ - 10:35 - Created .env.example
256
+ - 10:40 - Created .gitignore for .env
257
+ - 10:45 - Added environment variable loading
258
+ - 10:50 - Tested environment variables
259
+ - 10:55 - Committed initial setup
260
+
261
+ Session 3 (2025-01-01 14:00-15:30):
262
+ - 14:00 - npm install prisma @prisma/client
263
+ - 14:05 - npx prisma init
264
+ - 14:10 - Created schema.prisma
265
+ - 14:15 - Added User model
266
+ - 14:20 - Added Post model
267
+ - 14:25 - Added Comment model
268
+ - 14:30 - Updated schema with relations
269
+ - 14:35 - npx prisma migrate dev --name init
270
+ - 14:40 - Verified database tables created
271
+ - 14:45 - Created prisma/client.ts
272
+ - 14:50 - Added Prisma to index.ts
273
+ - 14:55 - Tested database connection
274
+ - 15:00 - Created seed script
275
+ - 15:05 - Populated database with test data
276
+ - 15:10 - Verified seed data
277
+ - 15:15 - Updated .env with DATABASE_URL
278
+ - 15:20 - Added database documentation
279
+ - 15:25 - Committed database setup
280
+ - 15:30 - Ran lint and fixed issues
281
+
282
+ (1000 tokens)
283
+ ```
284
+
285
+ ## Workflow Steps
286
+
287
+ ### Step 1: Always Start with Layer 1
288
+
289
+ **Why**: Get context before diving deep
290
+ **How**: Ask for overview or timeline
291
+ **Benefit**: Avoids searching for wrong things
292
+
293
+ ### Step 2: Use Layer 2 for Specific Questions
294
+
295
+ **Why**: Focused search is more efficient
296
+ **How**: Ask with keywords and type filters
297
+ **Benefit**: Gets relevant results without noise
298
+
299
+ ### Step 3: Use Layer 3 for Deep Dive
300
+
301
+ **Why**: Detailed analysis shows exact steps
302
+ **How**: Ask for timeline or specific session
303
+ **Benefit**: Understand implementation details
304
+
305
+ ## Decision Tree
306
+
307
+ ```
308
+ User Query
309
+
310
+ Is it about specific topic? (e.g., "authentication")
311
+ ↓ YES → Layer 2 (Focused Search)
312
+
313
+ Need more details?
314
+ ↓ YES → Layer 3 (Detailed Analysis)
315
+ ↓ NO → Done
316
+
317
+ Is it general context? (e.g., "what did we do?")
318
+ ↓ YES → Layer 1 (Overview)
319
+
320
+ Interested in specific area?
321
+ ↓ YES → Layer 2 (Focused on that area)
322
+
323
+ Need exact steps?
324
+ ↓ YES → Layer 3 (Detailed)
325
+ ↓ NO → Done
326
+ ```
327
+
328
+ ## Token Efficiency
329
+
330
+ | Layer | Context Size | Use Case |
331
+ |-------|---------------|-----------|
332
+ | Layer 1 | ~50 tokens | Quick overview, project context |
333
+ | Layer 2 | ~200 tokens | Focused search, finding specific info |
334
+ | Layer 3 | ~500-1000 tokens | Detailed analysis, understanding implementation |
335
+
336
+ **Total efficiency**: ~10x vs. full tool outputs
337
+
338
+ ## Best Practices
339
+
340
+ 1. **Start broad, go deep**
341
+ - Layer 1: "What did we do on X?"
342
+ - Layer 2: "Find all bash commands for X"
343
+ - Layer 3: "Show me exact steps for X"
344
+
345
+ 2. **Use type filters in Layer 2**
346
+ - "Find all file operations"
347
+ - "Show me bash commands"
348
+ - "What grep searches did we do?"
349
+
350
+ 3. **Combine layers**
351
+ - Layer 1: Get project context
352
+ - Layer 2: Search for specific topic
353
+ - Layer 3: Drill into relevant sessions
354
+
355
+ 4. **Limit Layer 3 when possible**
356
+ - Use limit: 10 for quick review
357
+ - Use specific session ID
358
+ - Use project filter
359
+
360
+ ## Performance
361
+
362
+ - **Layer 1**: < 50ms retrieval
363
+ - **Layer 2**: < 100ms search
364
+ - **Layer 3**: < 300ms detailed timeline
365
+ - **Total workflow**: < 500ms for all 3 layers
366
+
367
+ ## Integration
368
+
369
+ The workflow operation automatically combines:
370
+ - [Timeline Operation](./timeline.md) for Layer 1 and 3
371
+ - [Search Operation](./search.md) for Layer 2
372
+
373
+ ## API Reference
374
+
375
+ See [API_CONTRACT.md](../../../docs/API_CONTRACT.md) for full API specification.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * CLI tool for opencode-mem
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG"}
package/dist/cli.js ADDED
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * CLI tool for opencode-mem
4
+ */
5
+ import { ClaudeMemIntegration } from './integration/index.js';
6
+ import { Logger } from './integration/utils/logger.js';
7
+ const logger = new Logger('CLI');
8
+ async function main() {
9
+ const args = process.argv.slice(2);
10
+ const command = args[0];
11
+ if (!command || command === '--help' || command === '-h') {
12
+ printHelp();
13
+ return;
14
+ }
15
+ if (command === '--version' || command === '-v') {
16
+ const packageJson = await import('../package.json');
17
+ console.log(`opencode-mem v${packageJson.version}`);
18
+ return;
19
+ }
20
+ switch (command) {
21
+ case 'check-compatibility':
22
+ await checkCompatibility();
23
+ break;
24
+ case 'status':
25
+ await getStatus();
26
+ break;
27
+ case 'search':
28
+ await searchMemory(args[1]);
29
+ break;
30
+ case 'context':
31
+ await getContext(args[1]);
32
+ break;
33
+ default:
34
+ console.error(`Unknown command: ${command}`);
35
+ printHelp();
36
+ process.exit(1);
37
+ }
38
+ }
39
+ function printHelp() {
40
+ console.log(`
41
+ opencode-mem - OpenCode integration for claude-mem
42
+
43
+ Usage:
44
+ opencode-mem <command> [options]
45
+
46
+ Commands:
47
+ check-compatibility Check compatibility with claude-mem
48
+ status Show integration status
49
+ search <query> Search memories
50
+ context [project] Get context for project
51
+
52
+ Options:
53
+ --help, -h Show this help message
54
+ --version, -v Show version
55
+
56
+ Examples:
57
+ opencode-mem check-compatibility
58
+ opencode-mem search "authentication"
59
+ opencode-mem context my-project
60
+
61
+ Documentation: https://github.com/your-org/opencode-mem
62
+ `);
63
+ }
64
+ async function checkCompatibility() {
65
+ logger.info('Checking compatibility with claude-mem...');
66
+ try {
67
+ const integration = new ClaudeMemIntegration();
68
+ await integration.initialize();
69
+ const checker = integration.getVersionChecker();
70
+ const result = await checker.checkCompatibility();
71
+ console.log('');
72
+ console.log('Compatibility Result:');
73
+ console.log(` Worker Version: ${result.workerVersion}`);
74
+ console.log(` API Version: ${result.apiVersion}`);
75
+ console.log(` Compatible: ${result.isCompatible ? 'Yes' : 'No'}`);
76
+ console.log(` Tested: ${result.isTested ? 'Yes' : 'No'}`);
77
+ console.log('');
78
+ console.log(`Recommendation: ${result.recommendation}`);
79
+ console.log('');
80
+ if (result.testedVersions.length > 0) {
81
+ console.log(`Tested Versions: ${result.testedVersions.slice(0, 5).join(', ')}`);
82
+ }
83
+ await integration.shutdown();
84
+ }
85
+ catch (error) {
86
+ logger.error('Compatibility check failed:', error);
87
+ process.exit(1);
88
+ }
89
+ }
90
+ async function getStatus() {
91
+ logger.info('Getting integration status...');
92
+ try {
93
+ const integration = new ClaudeMemIntegration();
94
+ await integration.initialize();
95
+ const status = await integration.getStatus();
96
+ console.log('');
97
+ console.log('Integration Status:');
98
+ console.log(` Initialized: ${status.initialized ? 'Yes' : 'No'}`);
99
+ console.log(` Worker Ready: ${status.workerReady ? 'Yes' : 'No'}`);
100
+ console.log(` Worker Version: ${status.workerVersion || 'N/A'}`);
101
+ console.log(` Current Project: ${status.currentProject}`);
102
+ console.log(` Worker URL: ${status.workerUrl}`);
103
+ console.log('');
104
+ await integration.shutdown();
105
+ }
106
+ catch (error) {
107
+ logger.error('Status check failed:', error);
108
+ process.exit(1);
109
+ }
110
+ }
111
+ async function searchMemory(query) {
112
+ if (!query) {
113
+ console.error('Error: query is required');
114
+ console.error('Usage: opencode-mem search <query>');
115
+ process.exit(1);
116
+ }
117
+ logger.info(`Searching memories: "${query}"`);
118
+ try {
119
+ const integration = new ClaudeMemIntegration();
120
+ await integration.initialize();
121
+ const results = await integration.searchMemory(query);
122
+ console.log('');
123
+ console.log(`Found ${results.total} results:`);
124
+ console.log('');
125
+ results.results.forEach((result, index) => {
126
+ console.log(`${index + 1}. ${result.toolName}`);
127
+ console.log(` ${result.summary}`);
128
+ console.log(` ${new Date(result.timestamp).toISOString()}`);
129
+ console.log('');
130
+ });
131
+ await integration.shutdown();
132
+ }
133
+ catch (error) {
134
+ logger.error('Search failed:', error);
135
+ process.exit(1);
136
+ }
137
+ }
138
+ async function getContext(project) {
139
+ logger.info('Getting project context...');
140
+ try {
141
+ const integration = new ClaudeMemIntegration();
142
+ await integration.initialize();
143
+ const context = await integration.getProjectContext(project);
144
+ console.log('');
145
+ if (context) {
146
+ console.log('Context:');
147
+ console.log(context);
148
+ console.log('');
149
+ }
150
+ else {
151
+ console.log('No context available');
152
+ }
153
+ await integration.shutdown();
154
+ }
155
+ catch (error) {
156
+ logger.error('Get context failed:', error);
157
+ process.exit(1);
158
+ }
159
+ }
160
+ main().catch(error => {
161
+ logger.error('CLI error:', error);
162
+ process.exit(1);
163
+ });
164
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAkB,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAEtD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;AAEhC,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAClC,MAAM,O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M,WAAW,GAAG,IAAI,oBAAoB,EAAE,CAAA;QAC9C,MAAM,WAAW,CAAC,UAAU,EAAE,CAAA;QAE9B,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;QAE5D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACf,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YACvB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACpB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACjB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACrC,CAAC;QAED,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAA;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Inject claude-mem memory context into OpenCode sessions
3
+ */
4
+ import { WorkerClient } from './worker-client.js';
5
+ export declare class ContextInjector {
6
+ private workerClient;
7
+ private projectNameExtractor;
8
+ constructor(workerClient: WorkerClient);
9
+ /**
10
+ * Inject memory context into a session
11
+ * Called when session is created
12
+ */
13
+ injectContext(project: string): Promise<string>;
14
+ /**
15
+ * Get memory context as system prompt addition
16
+ */
17
+ getSystemPromptAddition(project: string): Promise<string>;
18
+ }
19
+ //# sourceMappingURL=context-injector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-injector.d.ts","sourceRoot":"","sources":["../../src/integration/context-injector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,oBAAoB,CAAsB;gBAEtC,YAAY,EAAE,YAAY;IAKtC;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBrD;;OAEG;IACG,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAahE"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Inject claude-mem memory context into OpenCode sessions
3
+ */
4
+ import { ProjectNameExtractor } from './utils/project-name.js';
5
+ export class ContextInjector {
6
+ workerClient;
7
+ projectNameExtractor;
8
+ constructor(workerClient) {
9
+ this.workerClient = workerClient;
10
+ this.projectNameExtractor = new ProjectNameExtractor();
11
+ }
12
+ /**
13
+ * Inject memory context into a session
14
+ * Called when session is created
15
+ */
16
+ async injectContext(project) {
17
+ try {
18
+ const context = await this.workerClient.getProjectContext(project);
19
+ if (!context || !context.trim()) {
20
+ console.log(`[CONTEXT_INJECTOR] No memory context available for project: ${project}`);
21
+ return '';
22
+ }
23
+ console.log(`[CONTEXT_INJECTOR] Injected memory context for project: ${project} (${context.length} chars)`);
24
+ return context;
25
+ }
26
+ catch (error) {
27
+ console.warn(`[CONTEXT_INJECTOR] Failed to inject memory context for project: ${project}`, error);
28
+ return '';
29
+ }
30
+ }
31
+ /**
32
+ * Get memory context as system prompt addition
33
+ */
34
+ async getSystemPromptAddition(project) {
35
+ const context = await this.injectContext(project);
36
+ if (!context)
37
+ return '';
38
+ return `
39
+ ## Relevant Context from Past Sessions
40
+
41
+ ${context}
42
+
43
+ ---
44
+ `;
45
+ }
46
+ }
47
+ //# sourceMappingURL=context-injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-injector.js","sourceRoot":"","sources":["../../src/integration/context-injector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,MAAM,OAAO,eAAe;IAClB,YAAY,CAAc;IAC1B,oBAAoB,CAAsB;IAElD,YAAY,YAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAA;IACxD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,OAAe;QACjC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;YAElE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,+DAA+D,OAAO,EAAE,CAAC,CAAA;gBACrF,OAAO,EAAE,CAAA;YACX,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,2DAA2D,OAAO,KAAK,OAAO,CAAC,MAAM,SAAS,CAAC,CAAA;YAE3G,OAAO,OAAO,CAAA;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,mEAAmE,OAAO,EAAE,EAAE,KAAK,CAAC,CAAA;YACjG,OAAO,EAAE,CAAA;QACX,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,uBAAuB,CAAC,OAAe;QAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAEjD,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAA;QAEvB,OAAO;;;EAGT,OAAO;;;CAGR,CAAA;IACC,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Subscribe to OpenCode Bus events and bridge to claude-mem
3
+ * Adapted to use real OpenCode APIs (with fallback for testing)
4
+ */
5
+ import { WorkerClient } from './worker-client.js';
6
+ export declare class EventListeners {
7
+ private workerClient;
8
+ private sessionMapper;
9
+ private projectNameExtractor;
10
+ private privacyStripper;
11
+ private promptNumberTracker;
12
+ constructor(workerClient: WorkerClient);
13
+ /**
14
+ * Subscribe to all relevant OpenCode events using real Bus API
15
+ */
16
+ initialize(): Promise<void>;
17
+ /**
18
+ * Handle session creation - initialize claude-mem session
19
+ * Uses real Session.Info from OpenCode
20
+ */
21
+ private handleSessionCreated;
22
+ /**
23
+ * Handle message part updates - capture tool usage
24
+ * Uses real MessageV2.Part from OpenCode
25
+ */
26
+ private handleMessagePartUpdated;
27
+ /**
28
+ * Handle session updates - check for completion
29
+ * Uses real Session.Info from OpenCode
30
+ */
31
+ private handleSessionUpdated;
32
+ /**
33
+ * Get current prompt number for a session
34
+ */
35
+ getPromptNumber(sessionId: string): number;
36
+ /**
37
+ * Increment prompt number for a session
38
+ */
39
+ incrementPromptNumber(sessionId: string): void;
40
+ }
41
+ //# sourceMappingURL=event-listeners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-listeners.d.ts","sourceRoot":"","sources":["../../src/integration/event-listeners.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAmBjD,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,eAAe,CAAoB;IAC3C,OAAO,CAAC,mBAAmB,CAAiC;gBAEhD,YAAY,EAAE,YAAY;IAOtC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAejC;;;OAGG;YACW,oBAAoB;IAsClC;;;OAGG;YACW,wBAAwB;IA6CtC;;;OAGG;YACW,oBAAoB;IA8BlC;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAI1C;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAI/C"}