@prmichaelsen/remember-mcp 2.3.4 → 2.5.0
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 +42 -0
- package/README.md +50 -5
- package/agent/milestones/milestone-11-unified-public-collection.md +205 -0
- package/agent/tasks/task-46-update-spacememory-types.md +94 -0
- package/agent/tasks/task-47-update-space-schema.md +102 -0
- package/agent/tasks/task-48-create-memory-public-collection.md +96 -0
- package/agent/tasks/task-49-update-remember-publish.md +153 -0
- package/agent/tasks/task-50-update-remember-confirm.md +111 -0
- package/agent/tasks/task-51-update-remember-search-space.md +154 -0
- package/agent/tasks/task-52-update-remember-query-space.md +142 -0
- package/agent/tasks/task-53-add-multispace-tests.md +193 -0
- package/agent/tasks/task-54-update-documentation-multispace.md +191 -0
- package/dist/server-factory.js +137 -80
- package/dist/server.js +137 -80
- package/dist/tools/publish.d.ts +1 -1
- package/dist/tools/query-space.d.ts +1 -1
- package/dist/tools/search-space.d.ts +1 -1
- package/dist/types/space-memory.d.ts +5 -3
- package/dist/weaviate/space-schema.d.ts +16 -0
- package/package.json +1 -1
- package/src/tools/confirm.ts +15 -16
- package/src/tools/publish.ts +42 -20
- package/src/tools/query-space.ts +38 -24
- package/src/tools/search-space.ts +51 -28
- package/src/types/space-memory.ts +5 -3
- package/src/weaviate/space-schema.spec.ts +55 -0
- package/src/weaviate/space-schema.ts +45 -6
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Task 49: Update remember_publish for Multi-Space
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Task 48
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update the `remember_publish` tool to accept a `spaces` array parameter, enabling users to publish memories to multiple spaces in a single operation.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update Tool Input Schema
|
|
19
|
+
|
|
20
|
+
**File**: `src/tools/publish.ts`
|
|
21
|
+
|
|
22
|
+
**Change**:
|
|
23
|
+
```typescript
|
|
24
|
+
// Before
|
|
25
|
+
target: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: SUPPORTED_SPACES,
|
|
28
|
+
default: 'the_void',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// After
|
|
32
|
+
spaces: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: SUPPORTED_SPACES
|
|
37
|
+
},
|
|
38
|
+
description: 'Spaces to publish to (e.g., ["the_void", "dogs"])',
|
|
39
|
+
minItems: 1,
|
|
40
|
+
default: ['the_void']
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Update Tool Description
|
|
45
|
+
|
|
46
|
+
**File**: `src/tools/publish.ts`
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
description: 'Publish a memory to one or more shared spaces. The memory will be COPIED (not moved) from your personal collection. Generates a confirmation token. Use remember_confirm to execute.',
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. Update handlePublish Function
|
|
53
|
+
|
|
54
|
+
**File**: `src/tools/publish.ts`
|
|
55
|
+
|
|
56
|
+
**Changes**:
|
|
57
|
+
- Accept `spaces: string[]` instead of `target: string`
|
|
58
|
+
- Validate all spaces in array
|
|
59
|
+
- Store `spaces` array in confirmation token payload
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
interface PublishArgs {
|
|
63
|
+
memory_id: string;
|
|
64
|
+
spaces: string[]; // ✅ Changed from target: string
|
|
65
|
+
additional_tags?: string[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function handlePublish(
|
|
69
|
+
args: PublishArgs,
|
|
70
|
+
userId: string
|
|
71
|
+
): Promise<string> {
|
|
72
|
+
// Validate all spaces
|
|
73
|
+
const invalidSpaces = args.spaces.filter(s => !isValidSpaceId(s));
|
|
74
|
+
if (invalidSpaces.length > 0) {
|
|
75
|
+
return JSON.stringify({
|
|
76
|
+
success: false,
|
|
77
|
+
error: 'Invalid space IDs',
|
|
78
|
+
message: `Invalid spaces: ${invalidSpaces.join(', ')}`,
|
|
79
|
+
context: {
|
|
80
|
+
invalid_spaces: invalidSpaces,
|
|
81
|
+
supported_spaces: SUPPORTED_SPACES
|
|
82
|
+
}
|
|
83
|
+
}, null, 2);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ... rest of validation
|
|
87
|
+
|
|
88
|
+
// Store spaces array in payload
|
|
89
|
+
const payload = {
|
|
90
|
+
memory_id: args.memory_id,
|
|
91
|
+
spaces: args.spaces, // ✅ Array
|
|
92
|
+
additional_tags: args.additional_tags || [],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const { requestId, token } = await confirmationTokenService.createRequest(
|
|
96
|
+
userId,
|
|
97
|
+
'publish_memory',
|
|
98
|
+
payload,
|
|
99
|
+
undefined // No single target_collection anymore
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return JSON.stringify({
|
|
103
|
+
success: true,
|
|
104
|
+
token,
|
|
105
|
+
}, null, 2);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 4. Add Backward Compatibility (Optional)
|
|
110
|
+
|
|
111
|
+
Support both `target` and `spaces` during migration:
|
|
112
|
+
```typescript
|
|
113
|
+
// Accept both formats
|
|
114
|
+
const spaces = args.spaces || (args.target ? [args.target] : ['the_void']);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Update Tests
|
|
118
|
+
|
|
119
|
+
**File**: `tests/unit/publish.test.ts` (create if doesn't exist)
|
|
120
|
+
|
|
121
|
+
**Add tests**:
|
|
122
|
+
- Publish to single space
|
|
123
|
+
- Publish to multiple spaces
|
|
124
|
+
- Invalid space validation
|
|
125
|
+
- Empty spaces array error
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Verification
|
|
130
|
+
|
|
131
|
+
- [ ] Tool accepts `spaces` array parameter
|
|
132
|
+
- [ ] Can publish to single space: `spaces: ["the_void"]`
|
|
133
|
+
- [ ] Can publish to multiple spaces: `spaces: ["the_void", "dogs"]`
|
|
134
|
+
- [ ] Invalid spaces rejected with clear error
|
|
135
|
+
- [ ] Empty spaces array rejected
|
|
136
|
+
- [ ] Token payload includes `spaces` array
|
|
137
|
+
- [ ] Tests passing
|
|
138
|
+
- [ ] TypeScript compiles without errors
|
|
139
|
+
- [ ] Build successful
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Files Modified
|
|
144
|
+
|
|
145
|
+
- `src/tools/publish.ts` - Update to accept spaces array
|
|
146
|
+
|
|
147
|
+
## Files Created
|
|
148
|
+
|
|
149
|
+
- `tests/unit/publish.test.ts` - Add multi-space tests (if doesn't exist)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
**Next Task**: Task 50 - Update remember_confirm for Multi-Space
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Task 50: Update remember_confirm for Multi-Space
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Task 49
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update the `remember_confirm` tool to handle multi-space publishing, storing memories in the unified `Memory_public` collection with the `spaces` array field.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update executePublishMemory Function
|
|
19
|
+
|
|
20
|
+
**File**: `src/tools/confirm.ts`
|
|
21
|
+
|
|
22
|
+
**Key Changes**:
|
|
23
|
+
```typescript
|
|
24
|
+
async function executePublishMemory(
|
|
25
|
+
request: ConfirmationRequest & { request_id: string },
|
|
26
|
+
userId: string
|
|
27
|
+
): Promise<string> {
|
|
28
|
+
// ... fetch original memory
|
|
29
|
+
|
|
30
|
+
// Use unified public collection instead of per-space
|
|
31
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
32
|
+
|
|
33
|
+
// Create published memory with spaces array
|
|
34
|
+
const publishedMemory = {
|
|
35
|
+
...originalMemory.properties,
|
|
36
|
+
spaces: request.payload.spaces, // ✅ Array from payload
|
|
37
|
+
author_id: userId,
|
|
38
|
+
published_at: new Date().toISOString(),
|
|
39
|
+
discovery_count: 0,
|
|
40
|
+
doc_type: 'space_memory',
|
|
41
|
+
attribution: 'user' as const,
|
|
42
|
+
tags: [...originalTags, ...additionalTags],
|
|
43
|
+
created_at: new Date().toISOString(),
|
|
44
|
+
updated_at: new Date().toISOString(),
|
|
45
|
+
version: 1,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Insert into Memory_public
|
|
49
|
+
const result = await publicCollection.data.insert(publishedMemory as any);
|
|
50
|
+
|
|
51
|
+
return JSON.stringify({
|
|
52
|
+
success: true,
|
|
53
|
+
space_memory_id: result,
|
|
54
|
+
spaces: request.payload.spaces // ✅ Return spaces array
|
|
55
|
+
}, null, 2);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. Update Logging
|
|
60
|
+
|
|
61
|
+
**File**: `src/tools/confirm.ts`
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
console.log('[executePublishMemory] Inserting into Memory_public:', {
|
|
65
|
+
spaces: request.payload.spaces, // ✅ Log array
|
|
66
|
+
memoryId: request.payload.memory_id,
|
|
67
|
+
spaceCount: request.payload.spaces.length,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 3. Handle Migration (Optional)
|
|
72
|
+
|
|
73
|
+
Support old `target_collection` format during transition:
|
|
74
|
+
```typescript
|
|
75
|
+
const spaces = request.payload.spaces ||
|
|
76
|
+
(request.target_collection ? [request.target_collection] : ['the_void']);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 4. Update Response Format
|
|
80
|
+
|
|
81
|
+
Return spaces array in success response:
|
|
82
|
+
```typescript
|
|
83
|
+
{
|
|
84
|
+
"success": true,
|
|
85
|
+
"space_memory_id": "new-id",
|
|
86
|
+
"spaces": ["the_void", "dogs"] // ✅ Show which spaces
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Verification
|
|
93
|
+
|
|
94
|
+
- [ ] Uses `ensurePublicCollection()` instead of `ensureSpaceCollection()`
|
|
95
|
+
- [ ] Stores `spaces` array in published memory
|
|
96
|
+
- [ ] Memory inserted into `Memory_public` collection
|
|
97
|
+
- [ ] Response includes `spaces` array
|
|
98
|
+
- [ ] Logging shows multi-space publishing
|
|
99
|
+
- [ ] Tests passing
|
|
100
|
+
- [ ] TypeScript compiles without errors
|
|
101
|
+
- [ ] Build successful
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Files Modified
|
|
106
|
+
|
|
107
|
+
- `src/tools/confirm.ts` - Update executePublishMemory
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
**Next Task**: Task 51 - Update remember_search_space for Multi-Space
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Task 51: Update remember_search_space for Multi-Space
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 3 hours
|
|
5
|
+
**Dependencies**: Task 50
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update the `remember_search_space` tool to accept a `spaces` array parameter, enabling users to search multiple spaces in a single query.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update Tool Input Schema
|
|
19
|
+
|
|
20
|
+
**File**: `src/tools/search-space.ts`
|
|
21
|
+
|
|
22
|
+
**Change**:
|
|
23
|
+
```typescript
|
|
24
|
+
// Before
|
|
25
|
+
space: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: SUPPORTED_SPACES,
|
|
28
|
+
default: 'the_void'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// After
|
|
32
|
+
spaces: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: SUPPORTED_SPACES
|
|
37
|
+
},
|
|
38
|
+
description: 'Spaces to search (e.g., ["the_void", "dogs"])',
|
|
39
|
+
minItems: 1,
|
|
40
|
+
default: ['the_void']
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Update handleSearchSpace Function
|
|
45
|
+
|
|
46
|
+
**File**: `src/tools/search-space.ts`
|
|
47
|
+
|
|
48
|
+
**Key Changes**:
|
|
49
|
+
```typescript
|
|
50
|
+
interface SearchSpaceArgs {
|
|
51
|
+
query: string;
|
|
52
|
+
spaces: string[]; // ✅ Changed from space: string
|
|
53
|
+
content_type?: string;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
// ... other filters
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function handleSearchSpace(
|
|
59
|
+
args: SearchSpaceArgs,
|
|
60
|
+
userId: string
|
|
61
|
+
): Promise<string> {
|
|
62
|
+
// Validate all spaces
|
|
63
|
+
const invalidSpaces = args.spaces.filter(s => !isValidSpaceId(s));
|
|
64
|
+
if (invalidSpaces.length > 0) {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
success: false,
|
|
67
|
+
error: 'Invalid space IDs',
|
|
68
|
+
message: `Invalid spaces: ${invalidSpaces.join(', ')}`
|
|
69
|
+
}, null, 2);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Use unified public collection
|
|
73
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
74
|
+
|
|
75
|
+
// Build filter for spaces array
|
|
76
|
+
const spacesFilter = publicCollection.filter
|
|
77
|
+
.byProperty('spaces')
|
|
78
|
+
.containsAny(args.spaces); // ✅ Search multiple spaces!
|
|
79
|
+
|
|
80
|
+
// Combine with other filters
|
|
81
|
+
const filters = [spacesFilter, ...otherFilters];
|
|
82
|
+
const combinedFilter = Filters.and(...filters);
|
|
83
|
+
|
|
84
|
+
// Execute search
|
|
85
|
+
const results = await publicCollection.query
|
|
86
|
+
.hybrid(args.query, { alpha: 0.5 })
|
|
87
|
+
.filter(combinedFilter)
|
|
88
|
+
.limit(args.limit || 10)
|
|
89
|
+
.offset(args.offset || 0);
|
|
90
|
+
|
|
91
|
+
// ... format and return results
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 3. Update Result Formatting
|
|
96
|
+
|
|
97
|
+
**File**: `src/tools/search-space.ts`
|
|
98
|
+
|
|
99
|
+
Include which spaces were searched:
|
|
100
|
+
```typescript
|
|
101
|
+
return JSON.stringify({
|
|
102
|
+
success: true,
|
|
103
|
+
spaces_searched: args.spaces, // ✅ Show what was searched
|
|
104
|
+
results: formattedResults,
|
|
105
|
+
total: results.length
|
|
106
|
+
}, null, 2);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 4. Add Backward Compatibility (Optional)
|
|
110
|
+
|
|
111
|
+
Support both `space` and `spaces` during migration:
|
|
112
|
+
```typescript
|
|
113
|
+
const spaces = args.spaces || (args.space ? [args.space] : ['the_void']);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 5. Update Tests
|
|
117
|
+
|
|
118
|
+
**File**: `tests/unit/search-space.test.ts` (create if doesn't exist)
|
|
119
|
+
|
|
120
|
+
**Add tests**:
|
|
121
|
+
- Search single space
|
|
122
|
+
- Search multiple spaces
|
|
123
|
+
- Results from all spaces returned
|
|
124
|
+
- Invalid space validation
|
|
125
|
+
- Empty spaces array error
|
|
126
|
+
- Filter by spaces with containsAny
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Verification
|
|
131
|
+
|
|
132
|
+
- [ ] Tool accepts `spaces` array parameter
|
|
133
|
+
- [ ] Can search single space: `spaces: ["the_void"]`
|
|
134
|
+
- [ ] Can search multiple spaces: `spaces: ["the_void", "dogs"]`
|
|
135
|
+
- [ ] Uses `containsAny` filter for spaces array
|
|
136
|
+
- [ ] Results include memories from all requested spaces
|
|
137
|
+
- [ ] Invalid spaces rejected
|
|
138
|
+
- [ ] Tests passing
|
|
139
|
+
- [ ] TypeScript compiles without errors
|
|
140
|
+
- [ ] Build successful
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Files Modified
|
|
145
|
+
|
|
146
|
+
- `src/tools/search-space.ts` - Update for multi-space search
|
|
147
|
+
|
|
148
|
+
## Files Created
|
|
149
|
+
|
|
150
|
+
- `tests/unit/search-space.test.ts` - Add multi-space tests (if doesn't exist)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
**Next Task**: Task 52 - Update remember_query_space for Multi-Space
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Task 52: Update remember_query_space for Multi-Space
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Task 51
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update the `remember_query_space` tool to accept a `spaces` array parameter, enabling RAG queries across multiple spaces simultaneously.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update Tool Input Schema
|
|
19
|
+
|
|
20
|
+
**File**: `src/tools/query-space.ts`
|
|
21
|
+
|
|
22
|
+
**Change**:
|
|
23
|
+
```typescript
|
|
24
|
+
// Before
|
|
25
|
+
space: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
enum: SUPPORTED_SPACES,
|
|
28
|
+
default: 'the_void'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// After
|
|
32
|
+
spaces: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: SUPPORTED_SPACES
|
|
37
|
+
},
|
|
38
|
+
description: 'Spaces to query (e.g., ["the_void", "dogs"])',
|
|
39
|
+
minItems: 1,
|
|
40
|
+
default: ['the_void']
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Update handleQuerySpace Function
|
|
45
|
+
|
|
46
|
+
**File**: `src/tools/query-space.ts`
|
|
47
|
+
|
|
48
|
+
**Key Changes**:
|
|
49
|
+
```typescript
|
|
50
|
+
interface QuerySpaceArgs {
|
|
51
|
+
question: string;
|
|
52
|
+
spaces: string[]; // ✅ Changed from space: string
|
|
53
|
+
content_type?: string;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
// ... other filters
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function handleQuerySpace(
|
|
59
|
+
args: QuerySpaceArgs,
|
|
60
|
+
userId: string
|
|
61
|
+
): Promise<string> {
|
|
62
|
+
// Validate all spaces
|
|
63
|
+
const invalidSpaces = args.spaces.filter(s => !isValidSpaceId(s));
|
|
64
|
+
if (invalidSpaces.length > 0) {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
success: false,
|
|
67
|
+
error: 'Invalid space IDs'
|
|
68
|
+
}, null, 2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Use unified public collection
|
|
72
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
73
|
+
|
|
74
|
+
// Build filter for spaces array
|
|
75
|
+
const spacesFilter = publicCollection.filter
|
|
76
|
+
.byProperty('spaces')
|
|
77
|
+
.containsAny(args.spaces); // ✅ Query multiple spaces!
|
|
78
|
+
|
|
79
|
+
// ... rest of RAG query logic
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Update Response Format
|
|
84
|
+
|
|
85
|
+
**File**: `src/tools/query-space.ts`
|
|
86
|
+
|
|
87
|
+
Include which spaces were queried:
|
|
88
|
+
```typescript
|
|
89
|
+
return JSON.stringify({
|
|
90
|
+
success: true,
|
|
91
|
+
spaces_queried: args.spaces, // ✅ Show what was queried
|
|
92
|
+
question: args.question,
|
|
93
|
+
results: formattedResults,
|
|
94
|
+
total: results.length
|
|
95
|
+
}, null, 2);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. Add Backward Compatibility (Optional)
|
|
99
|
+
|
|
100
|
+
Support both `space` and `spaces` during migration:
|
|
101
|
+
```typescript
|
|
102
|
+
const spaces = args.spaces || (args.space ? [args.space] : ['the_void']);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 5. Update Tests
|
|
106
|
+
|
|
107
|
+
**File**: `tests/unit/query-space.test.ts` (create if doesn't exist)
|
|
108
|
+
|
|
109
|
+
**Add tests**:
|
|
110
|
+
- Query single space
|
|
111
|
+
- Query multiple spaces
|
|
112
|
+
- Results from all spaces returned
|
|
113
|
+
- Invalid space validation
|
|
114
|
+
- RAG query works across spaces
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Verification
|
|
119
|
+
|
|
120
|
+
- [ ] Tool accepts `spaces` array parameter
|
|
121
|
+
- [ ] Can query single space: `spaces: ["the_void"]`
|
|
122
|
+
- [ ] Can query multiple spaces: `spaces: ["the_void", "dogs"]`
|
|
123
|
+
- [ ] Uses `containsAny` filter for spaces array
|
|
124
|
+
- [ ] RAG results include memories from all requested spaces
|
|
125
|
+
- [ ] Invalid spaces rejected
|
|
126
|
+
- [ ] Tests passing
|
|
127
|
+
- [ ] TypeScript compiles without errors
|
|
128
|
+
- [ ] Build successful
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Files Modified
|
|
133
|
+
|
|
134
|
+
- `src/tools/query-space.ts` - Update for multi-space query
|
|
135
|
+
|
|
136
|
+
## Files Created
|
|
137
|
+
|
|
138
|
+
- `tests/unit/query-space.test.ts` - Add multi-space tests (if doesn't exist)
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
**Next Task**: Task 53 - Add Multi-Space Unit Tests
|