@prmichaelsen/remember-mcp 2.3.4 → 2.5.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.
- package/AGENT.md +2 -2
- package/CHANGELOG.md +63 -0
- package/README.md +50 -5
- package/agent/commands/git.commit.md +511 -0
- package/agent/commands/git.init.md +513 -0
- package/agent/milestones/milestone-11-unified-public-collection.md +205 -0
- package/agent/scripts/install.sh +31 -16
- package/agent/scripts/update.sh +32 -17
- package/agent/tasks/task-45-fix-publish-false-success-bug.md +114 -181
- 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 +203 -107
- package/dist/server.js +203 -107
- 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/services/confirmation-token.service.ts +74 -30
- 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,102 @@
|
|
|
1
|
+
# Task 47: Update Space Schema with Spaces Array
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Task 46
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Update the Weaviate space collection schema to include a `spaces` array field and prepare for the unified `Memory_public` collection.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Add Spaces Field to Schema
|
|
19
|
+
|
|
20
|
+
**File**: `src/weaviate/space-schema.ts`
|
|
21
|
+
|
|
22
|
+
**Add property**:
|
|
23
|
+
```typescript
|
|
24
|
+
{
|
|
25
|
+
name: 'spaces',
|
|
26
|
+
dataType: 'text[]' as any,
|
|
27
|
+
description: 'Spaces this memory is published to (e.g., ["the_void", "dogs"])',
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Update Collection Name Constant
|
|
32
|
+
|
|
33
|
+
**File**: `src/weaviate/space-schema.ts`
|
|
34
|
+
|
|
35
|
+
**Add**:
|
|
36
|
+
```typescript
|
|
37
|
+
export const PUBLIC_COLLECTION_NAME = 'Memory_public';
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. Create ensurePublicCollection Function
|
|
41
|
+
|
|
42
|
+
**File**: `src/weaviate/space-schema.ts`
|
|
43
|
+
|
|
44
|
+
**Add**:
|
|
45
|
+
```typescript
|
|
46
|
+
/**
|
|
47
|
+
* Ensure the unified public collection exists
|
|
48
|
+
*/
|
|
49
|
+
export async function ensurePublicCollection(
|
|
50
|
+
client: WeaviateClient
|
|
51
|
+
): Promise<Collection<any>> {
|
|
52
|
+
const collectionName = PUBLIC_COLLECTION_NAME;
|
|
53
|
+
|
|
54
|
+
const exists = await client.collections.exists(collectionName);
|
|
55
|
+
|
|
56
|
+
if (!exists) {
|
|
57
|
+
await createSpaceCollection(client, 'public');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return client.collections.get(collectionName);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 4. Keep Backward Compatibility
|
|
65
|
+
|
|
66
|
+
**File**: `src/weaviate/space-schema.ts`
|
|
67
|
+
|
|
68
|
+
- Keep `ensureSpaceCollection()` function for now
|
|
69
|
+
- Keep `getSpaceCollectionName()` function for now
|
|
70
|
+
- Add deprecation comments
|
|
71
|
+
|
|
72
|
+
### 5. Update Schema Tests
|
|
73
|
+
|
|
74
|
+
**File**: `src/weaviate/space-schema.spec.ts`
|
|
75
|
+
|
|
76
|
+
**Add tests**:
|
|
77
|
+
- Test `ensurePublicCollection()` creates `Memory_public`
|
|
78
|
+
- Test `spaces` field is in schema
|
|
79
|
+
- Test backward compatibility functions still work
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Verification
|
|
84
|
+
|
|
85
|
+
- [ ] `spaces` field added to schema as `text[]`
|
|
86
|
+
- [ ] `PUBLIC_COLLECTION_NAME` constant defined
|
|
87
|
+
- [ ] `ensurePublicCollection()` function created
|
|
88
|
+
- [ ] Backward compatibility maintained
|
|
89
|
+
- [ ] Schema tests updated and passing
|
|
90
|
+
- [ ] TypeScript compiles without errors
|
|
91
|
+
- [ ] Build successful
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Files Modified
|
|
96
|
+
|
|
97
|
+
- `src/weaviate/space-schema.ts` - Add spaces field, public collection
|
|
98
|
+
- `src/weaviate/space-schema.spec.ts` - Add tests
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
**Next Task**: Task 48 - Create Memory_public Collection
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Task 48: Create Memory_public Collection
|
|
2
|
+
|
|
3
|
+
**Milestone**: M11 - Unified Public Collection
|
|
4
|
+
**Estimated Time**: 1 hour
|
|
5
|
+
**Dependencies**: Task 47
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Create the unified `Memory_public` Weaviate collection that will store all public space memories with the new `spaces` array field.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Update Collection Creation Logic
|
|
19
|
+
|
|
20
|
+
**File**: `src/weaviate/space-schema.ts`
|
|
21
|
+
|
|
22
|
+
**Modify `createSpaceCollection`**:
|
|
23
|
+
```typescript
|
|
24
|
+
async function createSpaceCollection(
|
|
25
|
+
client: WeaviateClient,
|
|
26
|
+
spaceId: string
|
|
27
|
+
): Promise<void> {
|
|
28
|
+
// Handle 'public' as special case
|
|
29
|
+
const collectionName = spaceId === 'public'
|
|
30
|
+
? PUBLIC_COLLECTION_NAME
|
|
31
|
+
: getSpaceCollectionName(spaceId);
|
|
32
|
+
|
|
33
|
+
console.log(`[Weaviate] Creating space collection ${collectionName}...`);
|
|
34
|
+
|
|
35
|
+
// ... rest of schema creation
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Test Collection Creation
|
|
40
|
+
|
|
41
|
+
**File**: `src/weaviate/space-schema.spec.ts`
|
|
42
|
+
|
|
43
|
+
**Add test**:
|
|
44
|
+
```typescript
|
|
45
|
+
it('should create Memory_public collection', async () => {
|
|
46
|
+
const collection = await ensurePublicCollection(mockClient);
|
|
47
|
+
|
|
48
|
+
expect(mockClient.collections.exists).toHaveBeenCalledWith('Memory_public');
|
|
49
|
+
expect(mockClient.collections.create).toHaveBeenCalled();
|
|
50
|
+
expect(collection.name).toBe('Memory_public');
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Verify Schema Properties
|
|
55
|
+
|
|
56
|
+
Ensure `Memory_public` has all required fields:
|
|
57
|
+
- `spaces` array (new)
|
|
58
|
+
- `space_id` (deprecated, for migration)
|
|
59
|
+
- `author_id`
|
|
60
|
+
- `attribution`
|
|
61
|
+
- `published_at`
|
|
62
|
+
- `discovery_count`
|
|
63
|
+
- All standard memory fields
|
|
64
|
+
|
|
65
|
+
### 4. Test with Actual Weaviate (Optional)
|
|
66
|
+
|
|
67
|
+
If Weaviate instance available:
|
|
68
|
+
```typescript
|
|
69
|
+
// Manual test
|
|
70
|
+
const client = getWeaviateClient();
|
|
71
|
+
const collection = await ensurePublicCollection(client);
|
|
72
|
+
console.log('Collection created:', collection.name);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Verification
|
|
78
|
+
|
|
79
|
+
- [ ] `Memory_public` collection can be created
|
|
80
|
+
- [ ] Collection has `spaces` array field
|
|
81
|
+
- [ ] Collection has all required properties
|
|
82
|
+
- [ ] `ensurePublicCollection()` works correctly
|
|
83
|
+
- [ ] Tests passing
|
|
84
|
+
- [ ] TypeScript compiles without errors
|
|
85
|
+
- [ ] Build successful
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Files Modified
|
|
90
|
+
|
|
91
|
+
- `src/weaviate/space-schema.ts` - Update collection creation
|
|
92
|
+
- `src/weaviate/space-schema.spec.ts` - Add tests
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**Next Task**: Task 49 - Update remember_publish for Multi-Space
|
|
@@ -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
|