@prmichaelsen/remember-mcp 2.5.2 → 2.6.2
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/CHANGELOG.md +123 -0
- package/agent/milestones/milestone-12-comment-system.md +239 -0
- package/agent/tasks/task-55-add-comment-fields-to-schema.md +171 -0
- package/agent/tasks/task-56-update-search-space-for-comments.md +192 -0
- package/agent/tasks/task-57-update-query-space-for-comments.md +167 -0
- package/agent/tasks/task-58-add-comment-unit-tests.md +255 -0
- package/agent/tasks/task-59-update-documentation-for-comments.md +324 -0
- package/agent/tasks/task-60-standardize-structured-logging.md +300 -0
- package/agent/tasks/task-61-enhance-confirmation-tool-descriptions.md +267 -0
- package/dist/server-factory.js +364 -143
- package/dist/server.js +407 -160
- package/dist/tools/confirm.d.ts +12 -0
- package/dist/tools/deny.d.ts +12 -0
- package/dist/tools/query-space.d.ts +1 -0
- package/dist/tools/search-space.d.ts +1 -0
- package/package.json +1 -1
- package/src/config.ts +8 -1
- package/src/firestore/init.ts +21 -6
- package/src/services/confirmation-token.service.ts +42 -23
- package/src/tools/confirm.ts +69 -16
- package/src/tools/deny.ts +23 -1
- package/src/tools/publish.ts +34 -9
- package/src/tools/query-space.ts +23 -6
- package/src/tools/search-space.ts +14 -1
- package/src/weaviate/client.ts +29 -7
- package/src/weaviate/schema.ts +34 -4
- package/src/weaviate/space-schema.ts +28 -3
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# Task 59: Update Documentation for Comments
|
|
2
|
+
|
|
3
|
+
**Milestone**: M12 (Comment System - Phase 1)
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Tasks 55-58 (Implementation complete)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update project documentation to explain the comment system, including usage examples, API documentation, and architectural notes. Ensure users understand how to create comments, fetch threads, and control comment visibility in searches.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update README.md
|
|
19
|
+
|
|
20
|
+
Add a new "Comments & Discussions" section:
|
|
21
|
+
|
|
22
|
+
```markdown
|
|
23
|
+
## Comments & Discussions
|
|
24
|
+
|
|
25
|
+
### Creating Comments
|
|
26
|
+
|
|
27
|
+
Use the existing `remember_create_memory` tool with `type: "comment"`:
|
|
28
|
+
|
|
29
|
+
\`\`\`typescript
|
|
30
|
+
// Reply to a memory
|
|
31
|
+
remember_create_memory({
|
|
32
|
+
type: "comment",
|
|
33
|
+
content: "Great post! Which trail specifically?",
|
|
34
|
+
parent_id: "memory123",
|
|
35
|
+
thread_root_id: "memory123",
|
|
36
|
+
spaces: ["the_void"]
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Reply to a comment (nested)
|
|
40
|
+
remember_create_memory({
|
|
41
|
+
type: "comment",
|
|
42
|
+
content: "I think they mean Bear Lake Trail",
|
|
43
|
+
parent_id: "comment456",
|
|
44
|
+
thread_root_id: "memory123", // Still points to root
|
|
45
|
+
spaces: ["the_void"]
|
|
46
|
+
})
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
### Fetching Threads
|
|
50
|
+
|
|
51
|
+
Get all comments for a memory:
|
|
52
|
+
|
|
53
|
+
\`\`\`typescript
|
|
54
|
+
remember_search_space({
|
|
55
|
+
spaces: ["the_void"],
|
|
56
|
+
query: "",
|
|
57
|
+
content_type: "comment",
|
|
58
|
+
// Filter by thread_root_id in Weaviate
|
|
59
|
+
limit: 100
|
|
60
|
+
})
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
### Clean Discovery
|
|
64
|
+
|
|
65
|
+
By default, searches exclude comments:
|
|
66
|
+
|
|
67
|
+
\`\`\`typescript
|
|
68
|
+
// Default: No comments
|
|
69
|
+
remember_search_space({
|
|
70
|
+
spaces: ["the_void"],
|
|
71
|
+
query: "hiking trails"
|
|
72
|
+
})
|
|
73
|
+
// Returns only memories
|
|
74
|
+
|
|
75
|
+
// Opt-in: Include comments
|
|
76
|
+
remember_search_space({
|
|
77
|
+
spaces: ["the_void"],
|
|
78
|
+
query: "hiking trails",
|
|
79
|
+
include_comments: true
|
|
80
|
+
})
|
|
81
|
+
// Returns memories + comments
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
### Features
|
|
85
|
+
|
|
86
|
+
- ✅ **Infinite nesting**: Comments can nest to any depth
|
|
87
|
+
- ✅ **Per-space moderation**: Moderation flags are space-specific
|
|
88
|
+
- ✅ **Clean discovery**: Comments excluded from search by default
|
|
89
|
+
- ✅ **Zero new tools**: Reuses existing `remember_create_memory`
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
**Location**: Add after "Shared Spaces" section
|
|
93
|
+
|
|
94
|
+
### 2. Update Design Document
|
|
95
|
+
|
|
96
|
+
Update [`agent/design/comment-memory-type.md`](../../agent/design/comment-memory-type.md):
|
|
97
|
+
|
|
98
|
+
Add implementation status:
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
**Status**: Implemented (v2.6.0) - Phase 1 Complete
|
|
102
|
+
|
|
103
|
+
## Implementation Status
|
|
104
|
+
|
|
105
|
+
### Phase 1: Basic Comments (v2.6.0) ✅
|
|
106
|
+
|
|
107
|
+
- ✅ Added 3 schema fields: `parent_id`, `thread_root_id`, `moderation_flags`
|
|
108
|
+
- ✅ Updated `remember_search_space` with `include_comments` parameter
|
|
109
|
+
- ✅ Updated `remember_query_space` with `include_comments` parameter
|
|
110
|
+
- ✅ Comments excluded from search by default
|
|
111
|
+
- ✅ Infinite nesting supported
|
|
112
|
+
- ✅ Per-space moderation flags implemented
|
|
113
|
+
- ✅ Unit tests passing
|
|
114
|
+
- ✅ Documentation updated
|
|
115
|
+
|
|
116
|
+
### Phase 2: Engagement (Future)
|
|
117
|
+
|
|
118
|
+
- [ ] Voting system (requires ACL)
|
|
119
|
+
- [ ] Sort by popularity
|
|
120
|
+
- [ ] Vote tracking in Firestore
|
|
121
|
+
|
|
122
|
+
### Phase 3: Moderation (Future)
|
|
123
|
+
|
|
124
|
+
- [ ] Moderator tools (requires ACL)
|
|
125
|
+
- [ ] Auto-hide spam
|
|
126
|
+
- [ ] Moderator dashboard
|
|
127
|
+
|
|
128
|
+
### Phase 4: Notifications (Future)
|
|
129
|
+
|
|
130
|
+
- [ ] Notify authors of comments
|
|
131
|
+
- [ ] Email/push notifications
|
|
132
|
+
- [ ] Notification preferences
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 3. Update CHANGELOG.md
|
|
136
|
+
|
|
137
|
+
Add v2.6.0 entry:
|
|
138
|
+
|
|
139
|
+
```markdown
|
|
140
|
+
## [2.6.0] - YYYY-MM-DD
|
|
141
|
+
|
|
142
|
+
### Added
|
|
143
|
+
- Comment system for threaded discussions in shared spaces
|
|
144
|
+
- 3 new schema fields: `parent_id`, `thread_root_id`, `moderation_flags`
|
|
145
|
+
- `include_comments` parameter to `remember_search_space` (default: false)
|
|
146
|
+
- `include_comments` parameter to `remember_query_space` (default: false)
|
|
147
|
+
- Support for infinite comment nesting
|
|
148
|
+
- Per-space moderation flags
|
|
149
|
+
|
|
150
|
+
### Changed
|
|
151
|
+
- Search and query tools now exclude comments by default for cleaner discovery
|
|
152
|
+
- Comments can be created using existing `remember_create_memory` with `type: "comment"`
|
|
153
|
+
|
|
154
|
+
### Documentation
|
|
155
|
+
- Added "Comments & Discussions" section to README
|
|
156
|
+
- Updated comment design document with implementation status
|
|
157
|
+
- Added comment usage examples
|
|
158
|
+
|
|
159
|
+
### Notes
|
|
160
|
+
- Zero new tools required - reuses existing infrastructure
|
|
161
|
+
- Backward compatible - existing functionality unchanged
|
|
162
|
+
- Comments are opt-in via `include_comments: true`
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 4. Add API Examples
|
|
166
|
+
|
|
167
|
+
Create examples document or add to README:
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
### Comment System Examples
|
|
171
|
+
|
|
172
|
+
#### Example 1: Simple Reply
|
|
173
|
+
|
|
174
|
+
\`\`\`typescript
|
|
175
|
+
// 1. User finds interesting memory
|
|
176
|
+
const memory = await remember_search_space({
|
|
177
|
+
spaces: ["the_void"],
|
|
178
|
+
query: "hiking trails"
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 2. User replies
|
|
182
|
+
await remember_create_memory({
|
|
183
|
+
type: "comment",
|
|
184
|
+
content: "Which trail? I'm planning a trip!",
|
|
185
|
+
parent_id: memory.id,
|
|
186
|
+
thread_root_id: memory.id,
|
|
187
|
+
spaces: ["the_void"]
|
|
188
|
+
});
|
|
189
|
+
\`\`\`
|
|
190
|
+
|
|
191
|
+
#### Example 2: Nested Discussion
|
|
192
|
+
|
|
193
|
+
\`\`\`typescript
|
|
194
|
+
// 1. Original memory
|
|
195
|
+
const memory = { id: "mem123", content: "Best TypeScript tips" };
|
|
196
|
+
|
|
197
|
+
// 2. First comment
|
|
198
|
+
const comment1 = await remember_create_memory({
|
|
199
|
+
type: "comment",
|
|
200
|
+
content: "Great point about generics!",
|
|
201
|
+
parent_id: "mem123",
|
|
202
|
+
thread_root_id: "mem123",
|
|
203
|
+
spaces: ["the_void"]
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// 3. Reply to comment (nested)
|
|
207
|
+
await remember_create_memory({
|
|
208
|
+
type: "comment",
|
|
209
|
+
content: "Have you tried conditional types?",
|
|
210
|
+
parent_id: comment1.id,
|
|
211
|
+
thread_root_id: "mem123", // Still points to root
|
|
212
|
+
spaces: ["the_void"]
|
|
213
|
+
});
|
|
214
|
+
\`\`\`
|
|
215
|
+
|
|
216
|
+
#### Example 3: Fetching Thread
|
|
217
|
+
|
|
218
|
+
\`\`\`typescript
|
|
219
|
+
// Get all comments for a memory
|
|
220
|
+
const thread = await remember_search_space({
|
|
221
|
+
spaces: ["the_void"],
|
|
222
|
+
query: "",
|
|
223
|
+
content_type: "comment",
|
|
224
|
+
// Add filter for thread_root_id
|
|
225
|
+
limit: 100
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// UI builds tree from flat list using parent_id
|
|
229
|
+
\`\`\`
|
|
230
|
+
|
|
231
|
+
#### Example 4: Per-Space Moderation
|
|
232
|
+
|
|
233
|
+
\`\`\`typescript
|
|
234
|
+
// Comment hidden in one space but visible in another
|
|
235
|
+
const comment = {
|
|
236
|
+
id: "comment123",
|
|
237
|
+
content: "Controversial opinion...",
|
|
238
|
+
moderation_flags: [
|
|
239
|
+
"the_void:hidden", // Hidden in The Void
|
|
240
|
+
// Visible in other spaces
|
|
241
|
+
],
|
|
242
|
+
spaces: ["the_void", "dogs"]
|
|
243
|
+
};
|
|
244
|
+
\`\`\`
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 5. Update Tool Descriptions
|
|
248
|
+
|
|
249
|
+
Ensure tool descriptions in code match documentation:
|
|
250
|
+
|
|
251
|
+
- `remember_create_memory`: Mention comment creation
|
|
252
|
+
- `remember_search_space`: Explain comment filtering
|
|
253
|
+
- `remember_query_space`: Explain comment filtering
|
|
254
|
+
|
|
255
|
+
### 6. Verify Documentation
|
|
256
|
+
|
|
257
|
+
**Check**:
|
|
258
|
+
- All examples are accurate
|
|
259
|
+
- Code snippets are valid TypeScript
|
|
260
|
+
- Links work correctly
|
|
261
|
+
- Formatting is consistent
|
|
262
|
+
- No typos or errors
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Verification
|
|
267
|
+
|
|
268
|
+
- [ ] README.md updated with comment section
|
|
269
|
+
- [ ] Design document updated with implementation status
|
|
270
|
+
- [ ] CHANGELOG.md has v2.6.0 entry
|
|
271
|
+
- [ ] API examples added
|
|
272
|
+
- [ ] Tool descriptions updated
|
|
273
|
+
- [ ] All examples are accurate
|
|
274
|
+
- [ ] Code snippets are valid
|
|
275
|
+
- [ ] Links work correctly
|
|
276
|
+
- [ ] No typos or formatting errors
|
|
277
|
+
- [ ] Documentation is clear and comprehensive
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Documentation Checklist
|
|
282
|
+
|
|
283
|
+
### User-Facing Documentation
|
|
284
|
+
- [ ] README.md - Usage examples
|
|
285
|
+
- [ ] CHANGELOG.md - Version entry
|
|
286
|
+
- [ ] API examples - Code snippets
|
|
287
|
+
|
|
288
|
+
### Developer Documentation
|
|
289
|
+
- [ ] Design document - Implementation status
|
|
290
|
+
- [ ] Tool descriptions - Updated in code
|
|
291
|
+
- [ ] Architecture notes - Comment system design
|
|
292
|
+
|
|
293
|
+
### Quality Checks
|
|
294
|
+
- [ ] Examples tested and verified
|
|
295
|
+
- [ ] Links checked
|
|
296
|
+
- [ ] Formatting consistent
|
|
297
|
+
- [ ] Clear and concise
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Files Modified
|
|
302
|
+
|
|
303
|
+
- [`README.md`](../../README.md) - Add comment section
|
|
304
|
+
- [`CHANGELOG.md`](../../CHANGELOG.md) - Add v2.6.0 entry
|
|
305
|
+
- [`agent/design/comment-memory-type.md`](../../agent/design/comment-memory-type.md) - Update status
|
|
306
|
+
- [`src/tools/create-memory.ts`](../../src/tools/create-memory.ts) - Update description (optional)
|
|
307
|
+
- [`src/tools/search-space.ts`](../../src/tools/search-space.ts) - Verify description
|
|
308
|
+
- [`src/tools/query-space.ts`](../../src/tools/query-space.ts) - Verify description
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Files Created
|
|
313
|
+
|
|
314
|
+
None (documentation updates only)
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Next Steps
|
|
319
|
+
|
|
320
|
+
After completing this task:
|
|
321
|
+
1. Review all documentation for accuracy
|
|
322
|
+
2. Test all examples to ensure they work
|
|
323
|
+
3. Get feedback from users
|
|
324
|
+
4. Consider Phase 2 (Engagement) features
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# Task 60: Standardize Structured Logging
|
|
2
|
+
|
|
3
|
+
**Milestone**: [M8 - Testing and Quality](../milestones/milestone-8-testing-quality.md)
|
|
4
|
+
**Estimated Time**: 3 hours
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Replace all direct `console.log()` calls with the structured logger utility to ensure consistent, filterable, and searchable logging across the codebase, particularly in production Cloud Run environments.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Context
|
|
17
|
+
|
|
18
|
+
The codebase has a structured logger utility at [`src/utils/logger.ts`](../../src/utils/logger.ts) that provides:
|
|
19
|
+
- Log level filtering based on `LOG_LEVEL` environment variable
|
|
20
|
+
- Structured JSON output for cloud environments
|
|
21
|
+
- Consistent formatting with proper severity levels (debug, info, warn, error)
|
|
22
|
+
|
|
23
|
+
However, many files are using `console.log()` directly, which bypasses this system and results in:
|
|
24
|
+
- **No log level filtering** - all logs appear regardless of LOG_LEVEL setting
|
|
25
|
+
- **Inconsistent formatting** - mix of structured and unstructured logs
|
|
26
|
+
- **Harder to search** - no consistent prefixes or structure in Cloud Run logs
|
|
27
|
+
- **Missing context** - logs don't include proper severity levels for cloud log aggregation
|
|
28
|
+
|
|
29
|
+
Files currently using direct console.log:
|
|
30
|
+
- `src/services/confirmation-token.service.ts` (lines 72-301)
|
|
31
|
+
- `src/tools/publish.ts` (lines 63-192)
|
|
32
|
+
- `src/tools/confirm.ts` (lines 44-200)
|
|
33
|
+
- `src/config.ts` (line 55)
|
|
34
|
+
- And potentially others
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Steps
|
|
39
|
+
|
|
40
|
+
### 1. Audit All Console.log Usage
|
|
41
|
+
|
|
42
|
+
Search the entire codebase for direct console usage:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cd /home/prmichaelsen/remember-mcp
|
|
46
|
+
grep -rn "console\." src/ --include="*.ts" | grep -v ".spec.ts" | grep -v "logger.ts"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Create a list of all files that need updating.
|
|
50
|
+
|
|
51
|
+
### 2. Update ConfirmationTokenService
|
|
52
|
+
|
|
53
|
+
Replace all console.log calls in `src/services/confirmation-token.service.ts`:
|
|
54
|
+
|
|
55
|
+
**Import the logger**:
|
|
56
|
+
```typescript
|
|
57
|
+
import { logger } from '../utils/logger.js';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Replace console.log patterns**:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// OLD:
|
|
64
|
+
console.log('[ConfirmationTokenService] Creating request:', {
|
|
65
|
+
userId,
|
|
66
|
+
action,
|
|
67
|
+
targetCollection,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// NEW:
|
|
71
|
+
logger.info('Creating confirmation request', {
|
|
72
|
+
service: 'ConfirmationTokenService',
|
|
73
|
+
userId,
|
|
74
|
+
action,
|
|
75
|
+
targetCollection,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Replace console.error patterns**:
|
|
80
|
+
```typescript
|
|
81
|
+
// OLD:
|
|
82
|
+
console.error('[ConfirmationTokenService] FAILED to create request:', {
|
|
83
|
+
error: error instanceof Error ? error.message : String(error),
|
|
84
|
+
userId,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// NEW:
|
|
88
|
+
logger.error('Failed to create confirmation request', {
|
|
89
|
+
service: 'ConfirmationTokenService',
|
|
90
|
+
error: error instanceof Error ? error.message : String(error),
|
|
91
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
92
|
+
userId,
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 3. Update Publish Tool
|
|
97
|
+
|
|
98
|
+
Replace all console.log calls in `src/tools/publish.ts`:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// Import logger
|
|
102
|
+
import { logger } from '../utils/logger.js';
|
|
103
|
+
|
|
104
|
+
// OLD:
|
|
105
|
+
console.log('[remember_publish] Starting publish request:', {
|
|
106
|
+
userId,
|
|
107
|
+
memoryId: args.memory_id,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// NEW:
|
|
111
|
+
logger.info('Starting publish request', {
|
|
112
|
+
tool: 'remember_publish',
|
|
113
|
+
userId,
|
|
114
|
+
memoryId: args.memory_id,
|
|
115
|
+
spaces: args.spaces,
|
|
116
|
+
spaceCount: args.spaces.length,
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. Update Confirm Tool
|
|
121
|
+
|
|
122
|
+
Replace all console.log calls in `src/tools/confirm.ts`:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Import logger
|
|
126
|
+
import { logger } from '../utils/logger.js';
|
|
127
|
+
|
|
128
|
+
// OLD:
|
|
129
|
+
console.log('[remember_confirm] Starting confirmation:', {
|
|
130
|
+
userId,
|
|
131
|
+
token: args.token,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// NEW:
|
|
135
|
+
logger.info('Starting confirmation', {
|
|
136
|
+
tool: 'remember_confirm',
|
|
137
|
+
userId,
|
|
138
|
+
token: args.token,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// OLD:
|
|
142
|
+
console.log('[executePublishMemory] Starting execution:', {
|
|
143
|
+
userId,
|
|
144
|
+
memoryId: request.payload.memory_id,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// NEW:
|
|
148
|
+
logger.info('Executing publish memory action', {
|
|
149
|
+
function: 'executePublishMemory',
|
|
150
|
+
userId,
|
|
151
|
+
memoryId: request.payload.memory_id,
|
|
152
|
+
spaces: request.payload.spaces,
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 5. Update Config Validation
|
|
157
|
+
|
|
158
|
+
Replace console.log in `src/config.ts`:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Import logger at top
|
|
162
|
+
import { logger } from './utils/logger.js';
|
|
163
|
+
|
|
164
|
+
// In validateConfig():
|
|
165
|
+
// OLD:
|
|
166
|
+
console.log('[Config] Configuration validated');
|
|
167
|
+
|
|
168
|
+
// NEW:
|
|
169
|
+
logger.info('Configuration validated', { module: 'config' });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 6. Search for Other Console Usage
|
|
173
|
+
|
|
174
|
+
Check for any remaining console usage:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
grep -rn "console\." src/ --include="*.ts" | grep -v ".spec.ts" | grep -v "logger.ts"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Update any remaining instances following the same pattern.
|
|
181
|
+
|
|
182
|
+
### 7. Update Tests if Needed
|
|
183
|
+
|
|
184
|
+
If any tests are checking for console.log output, update them to work with the logger:
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
// Tests can still use console.log for test output
|
|
188
|
+
// But production code should use logger
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 8. Verify Log Level Filtering
|
|
192
|
+
|
|
193
|
+
Test that log level filtering works correctly:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Set LOG_LEVEL to 'warn' and verify debug/info logs don't appear
|
|
197
|
+
LOG_LEVEL=warn npm start
|
|
198
|
+
|
|
199
|
+
# Set LOG_LEVEL to 'debug' and verify all logs appear
|
|
200
|
+
LOG_LEVEL=debug npm start
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Verification
|
|
206
|
+
|
|
207
|
+
- [ ] All `console.log()` calls in production code replaced with `logger.info()`
|
|
208
|
+
- [ ] All `console.error()` calls in production code replaced with `logger.error()`
|
|
209
|
+
- [ ] All `console.warn()` calls in production code replaced with `logger.warn()`
|
|
210
|
+
- [ ] All `console.debug()` calls in production code replaced with `logger.debug()`
|
|
211
|
+
- [ ] Logger imported in all modified files: `import { logger } from '../utils/logger.js';`
|
|
212
|
+
- [ ] All log messages include context object with relevant fields (userId, tool name, etc.)
|
|
213
|
+
- [ ] No console.* calls remain in src/ (except in logger.ts and *.spec.ts files)
|
|
214
|
+
- [ ] TypeScript compiles without errors: `npm run typecheck`
|
|
215
|
+
- [ ] Tests pass: `npm test`
|
|
216
|
+
- [ ] Log level filtering works: logs respect LOG_LEVEL environment variable
|
|
217
|
+
- [ ] Structured logs appear correctly in Cloud Run (JSON format with severity)
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Expected Output
|
|
222
|
+
|
|
223
|
+
**Before** (inconsistent logging):
|
|
224
|
+
```
|
|
225
|
+
[ConfirmationTokenService] Creating request: { userId: '123', action: 'publish' }
|
|
226
|
+
[remember_publish] Starting publish request: { userId: '123' }
|
|
227
|
+
[Config] Configuration validated
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**After** (structured logging):
|
|
231
|
+
```json
|
|
232
|
+
{"level":"INFO","message":"Creating confirmation request","service":"ConfirmationTokenService","userId":"123","action":"publish"}
|
|
233
|
+
{"level":"INFO","message":"Starting publish request","tool":"remember_publish","userId":"123","memoryId":"abc","spaces":["the_void"]}
|
|
234
|
+
{"level":"INFO","message":"Configuration validated","module":"config"}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Log Level Filtering**:
|
|
238
|
+
- `LOG_LEVEL=error`: Only error logs appear
|
|
239
|
+
- `LOG_LEVEL=warn`: Warn and error logs appear
|
|
240
|
+
- `LOG_LEVEL=info`: Info, warn, and error logs appear (default)
|
|
241
|
+
- `LOG_LEVEL=debug`: All logs appear including debug
|
|
242
|
+
|
|
243
|
+
**Cloud Run Benefits**:
|
|
244
|
+
- Logs have proper severity levels (INFO, WARN, ERROR, DEBUG)
|
|
245
|
+
- Structured JSON makes filtering easier in Cloud Console
|
|
246
|
+
- Consistent format across all services
|
|
247
|
+
- Better integration with Cloud Logging filters
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Common Issues and Solutions
|
|
252
|
+
|
|
253
|
+
### Issue 1: Logger not found error
|
|
254
|
+
**Symptom**: `Cannot find module '../utils/logger.js'`
|
|
255
|
+
**Solution**: Check the relative path from the file to logger.ts. Adjust `../` depth as needed.
|
|
256
|
+
|
|
257
|
+
### Issue 2: TypeScript errors about logger methods
|
|
258
|
+
**Symptom**: `Property 'info' does not exist on type...`
|
|
259
|
+
**Solution**: Ensure logger is imported correctly and TypeScript can resolve the module.
|
|
260
|
+
|
|
261
|
+
### Issue 3: Logs still appearing when LOG_LEVEL=error
|
|
262
|
+
**Symptom**: Info logs appear even with LOG_LEVEL=error
|
|
263
|
+
**Solution**: Verify the logger is being used, not console.log. Check that LOG_LEVEL environment variable is set correctly.
|
|
264
|
+
|
|
265
|
+
### Issue 4: Tests failing after logger changes
|
|
266
|
+
**Symptom**: Tests that checked console.log output now fail
|
|
267
|
+
**Solution**: Update tests to either:
|
|
268
|
+
- Mock the logger module
|
|
269
|
+
- Check for logger calls instead of console calls
|
|
270
|
+
- Or keep console.log in test files (tests are excluded from this change)
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Resources
|
|
275
|
+
|
|
276
|
+
- [Structured Logging Best Practices](https://cloud.google.com/logging/docs/structured-logging): Google Cloud structured logging guide
|
|
277
|
+
- [Logger Utility](../../src/utils/logger.ts): The existing logger implementation
|
|
278
|
+
- [Cloud Run Logging](https://cloud.google.com/run/docs/logging): How Cloud Run handles logs
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Notes
|
|
283
|
+
|
|
284
|
+
- **Test files (*.spec.ts) can continue using console.log** - this task only affects production code
|
|
285
|
+
- **The logger.ts file itself uses console.* internally** - this is correct and should not be changed
|
|
286
|
+
- **Structured logging improves observability** - makes debugging production issues much easier
|
|
287
|
+
- **Log level filtering reduces noise** - production can run at 'info' or 'warn' level
|
|
288
|
+
- **Context objects should include relevant identifiers** - userId, memoryId, tool name, etc.
|
|
289
|
+
- **Keep messages concise** - put details in the context object, not the message string
|
|
290
|
+
- **Use appropriate log levels**:
|
|
291
|
+
- `debug`: Detailed diagnostic information (rarely needed in production)
|
|
292
|
+
- `info`: General informational messages (normal operations)
|
|
293
|
+
- `warn`: Warning messages (something unexpected but not an error)
|
|
294
|
+
- `error`: Error messages (something failed)
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
**Next Task**: TBD
|
|
299
|
+
**Related Design Docs**: None
|
|
300
|
+
**Estimated Completion Date**: TBD
|