@sovant/claude-code-mcp 0.3.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/commands/memory.d.ts +28 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +166 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/recall.d.ts +32 -0
- package/dist/commands/recall.d.ts.map +1 -0
- package/dist/commands/recall.js +124 -0
- package/dist/commands/recall.js.map +1 -0
- package/dist/commands/remember.d.ts +20 -0
- package/dist/commands/remember.d.ts.map +1 -0
- package/dist/commands/remember.js +103 -0
- package/dist/commands/remember.js.map +1 -0
- package/dist/commands/shared.d.ts +56 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +182 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/format.d.ts +54 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +158 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +332 -0
- package/dist/index.js.map +1 -0
- package/dist/localStore.d.ts +39 -0
- package/dist/localStore.d.ts.map +1 -0
- package/dist/localStore.js +93 -0
- package/dist/localStore.js.map +1 -0
- package/dist/repo.d.ts +23 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +93 -0
- package/dist/repo.js.map +1 -0
- package/dist/sovant.d.ts +22 -0
- package/dist/sovant.d.ts.map +1 -0
- package/dist/sovant.js +57 -0
- package/dist/sovant.js.map +1 -0
- package/package.json +46 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
- **Dev-only isolation by default.** `sovant_recall` now sends `space=dev`, returning only memories tagged `source:claude-code`. Dashboard, CRM, and smart-capture memories are excluded unless `include_workspace=true` is passed.
|
|
6
|
+
- **New recall parameters:** `scope` (thread/global), `mode` (smart/exact), `debug` (bool), `include_workspace` (bool).
|
|
7
|
+
- **Debug output.** Pass `debug=true` to append token estimates, source/type counts, and recall metadata.
|
|
8
|
+
- Updated README with privacy default section and recall parameter table.
|
|
9
|
+
|
|
10
|
+
## 0.2.0
|
|
11
|
+
|
|
12
|
+
- Initial public release.
|
|
13
|
+
- Tools: `sovant_remember`, `sovant_remember_pref`, `sovant_remember_decision`, `sovant_recall`, `sovant_search`, `sovant_memory_list`, `sovant_memory_show`, `sovant_memory_update`, `sovant_memory_delete`, `sovant_thread_info`.
|
|
14
|
+
- Thread-per-repo mapping via `.sovant/thread.json`.
|
|
15
|
+
- Session-start recall for automatic project context loading.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sovant AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# sovant-claude-code-mcp
|
|
2
|
+
|
|
3
|
+
Sovant MCP is a local adapter for Claude Code that enables explicit, governed long-term memory per repository.
|
|
4
|
+
|
|
5
|
+
## What this does
|
|
6
|
+
|
|
7
|
+
- **Explicit memory only.** Every memory is written by a deliberate tool call. Nothing is captured automatically.
|
|
8
|
+
- **One repo = one memory thread.** Each git repository maps to a single Sovant thread by default.
|
|
9
|
+
- **Scoped per repository.** Each git repo gets its own memory thread. Memories don't leak between projects unless you explicitly search globally.
|
|
10
|
+
- **MCP runs locally.** This adapter runs as a local stdio process alongside Claude Code. It talks to the Sovant API over HTTPS.
|
|
11
|
+
- **Memory stored in Sovant cloud.** Memories are persisted, searchable, and manageable from the Sovant dashboard.
|
|
12
|
+
|
|
13
|
+
## What this does NOT do
|
|
14
|
+
|
|
15
|
+
- No auto-capture. No background listener. No passive memory.
|
|
16
|
+
- No silent recall. Context is only retrieved when explicitly requested.
|
|
17
|
+
- No scope expansion. Repo-scoped searches stay repo-scoped. Global search requires an explicit opt-in.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed and working
|
|
22
|
+
- Node.js 18+
|
|
23
|
+
- A Sovant API key (free at [sovant.ai/dashboard/keys](https://sovant.ai/dashboard/keys))
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/sovant-ai/sovant-claude-code-mcp.git
|
|
29
|
+
cd sovant-claude-code-mcp
|
|
30
|
+
npm install
|
|
31
|
+
npm run build
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Then register with Claude Code:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
claude mcp add sovant \
|
|
38
|
+
--transport stdio \
|
|
39
|
+
--env SOVANT_API_KEY=sk_live_your_key_here \
|
|
40
|
+
-- node /absolute/path/to/sovant-claude-code-mcp/dist/index.js
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Replace `/absolute/path/to/` with the actual path on your machine.
|
|
44
|
+
|
|
45
|
+
## Verify
|
|
46
|
+
|
|
47
|
+
Restart Claude Code, then try:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
> "Remember: we use PostgreSQL 16 with JSONB for the main database"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Claude will confirm the memory was saved via Sovant, including a short memory ID. Then:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
> "What database do we use?"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Sovant should recall the memory you just saved. If both work, you're set.
|
|
60
|
+
|
|
61
|
+
## Available tools
|
|
62
|
+
|
|
63
|
+
| Tool | Description |
|
|
64
|
+
|------|-------------|
|
|
65
|
+
| `sovant_remember` | Save a general note or fact |
|
|
66
|
+
| `sovant_remember_pref` | Save a coding preference |
|
|
67
|
+
| `sovant_remember_decision` | Save an architectural decision |
|
|
68
|
+
| `sovant_recall` | Retrieve relevant memories (dev-only by default; supports `scope`, `mode`, `debug`, `include_workspace`) |
|
|
69
|
+
| `sovant_search` | Search with explicit scope (`repo` or `global`) |
|
|
70
|
+
| `sovant_memory_list` | List recent memories with short IDs |
|
|
71
|
+
| `sovant_memory_show` | Show full details of a memory |
|
|
72
|
+
| `sovant_memory_update` | Edit a memory's content |
|
|
73
|
+
| `sovant_memory_delete` | Delete a memory |
|
|
74
|
+
| `sovant_thread_info` | Show current thread ID, repo, and memory count |
|
|
75
|
+
|
|
76
|
+
## Privacy default
|
|
77
|
+
|
|
78
|
+
By default, `sovant_recall` only returns **dev memories** — those tagged with `source:claude-code` (i.e., memories saved through this MCP adapter). Dashboard memories, CRM records, and smart-capture data are excluded.
|
|
79
|
+
|
|
80
|
+
To include all workspace memories in a recall, pass `include_workspace: true`.
|
|
81
|
+
|
|
82
|
+
### Recall parameters
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Default | Description |
|
|
85
|
+
|-----------|------|---------|-------------|
|
|
86
|
+
| `query` | string | (required) | The search query |
|
|
87
|
+
| `limit` | number | 10 | Max results (max 25) |
|
|
88
|
+
| `scope` | `"thread"` \| `"global"` | `"thread"` | `thread` = current repo only; `global` = all projects |
|
|
89
|
+
| `mode` | `"smart"` \| `"exact"` | `"smart"` | `smart` = hybrid AI recall; `exact` = keyword match |
|
|
90
|
+
| `debug` | boolean | false | Append debug info (token counts, sources) |
|
|
91
|
+
| `include_workspace` | boolean | false | Include non-dev memories (dashboard, CRM, smart capture) |
|
|
92
|
+
|
|
93
|
+
## Uninstall
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
claude mcp remove sovant
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This removes the MCP registration from Claude Code. Memories already stored in Sovant are not deleted — you can manage them from the [Sovant dashboard](https://sovant.ai/dashboard).
|
|
100
|
+
|
|
101
|
+
## Help and feedback
|
|
102
|
+
|
|
103
|
+
- **Issues:** [github.com/sovant-ai/sovant-claude-code-mcp/issues](https://github.com/sovant-ai/sovant-claude-code-mcp/issues) — please include your OS, Node version, and `claude --version`.
|
|
104
|
+
- **Docs:** [sovant.ai/docs/mcp](https://sovant.ai/docs/mcp)
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
The MCP adapter code in this repository is MIT licensed.
|
|
109
|
+
|
|
110
|
+
Memory storage and retrieval are provided by the Sovant managed service ([sovant.ai](https://sovant.ai)). Usage is subject to [Sovant's terms of service](https://sovant.ai/terms).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory management command handlers
|
|
3
|
+
*
|
|
4
|
+
* /memory list [n] - List recent memories (default 20)
|
|
5
|
+
* /memory delete <id> - Delete a memory by ID
|
|
6
|
+
* /memory show <id> - Show full memory details (optional)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Handle /memory list command
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleMemoryList(args: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Handle /memory delete command
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleMemoryDelete(memoryId: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Handle /memory show command - show full memory details
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleMemoryShow(memoryId: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Handle memory update — replace a memory's content by ID
|
|
22
|
+
*/
|
|
23
|
+
export declare function handleMemoryUpdate(memoryId: string, text: string): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Route memory subcommands
|
|
26
|
+
*/
|
|
27
|
+
export declare function handleMemory(args: string): Promise<string>;
|
|
28
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsCH;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BpE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiB1E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuCxE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBhE"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory management command handlers
|
|
3
|
+
*
|
|
4
|
+
* /memory list [n] - List recent memories (default 20)
|
|
5
|
+
* /memory delete <id> - Delete a memory by ID
|
|
6
|
+
* /memory show <id> - Show full memory details (optional)
|
|
7
|
+
*/
|
|
8
|
+
import { getSovantClient, formatSovantError } from "../sovant.js";
|
|
9
|
+
import { getThreadId } from "./shared.js";
|
|
10
|
+
import { formatMemoryList, shortId, formatDate } from "../format.js";
|
|
11
|
+
const DEFAULT_LIST_LIMIT = 20;
|
|
12
|
+
const MAX_LIST_LIMIT = 100;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a short ID (8+ chars) to a full UUID by searching recent memories.
|
|
15
|
+
* If the input is already a full UUID (36 chars), returns it as-is.
|
|
16
|
+
* Throws a user-friendly error if no match is found.
|
|
17
|
+
*/
|
|
18
|
+
async function resolveMemoryId(shortOrFullId) {
|
|
19
|
+
if (shortOrFullId.length >= 36) {
|
|
20
|
+
return shortOrFullId;
|
|
21
|
+
}
|
|
22
|
+
const client = getSovantClient();
|
|
23
|
+
const threadId = await getThreadId();
|
|
24
|
+
const listResult = await client.memory.list({
|
|
25
|
+
thread_id: threadId,
|
|
26
|
+
limit: 100,
|
|
27
|
+
});
|
|
28
|
+
const memories = listResult.memories || [];
|
|
29
|
+
const match = memories.find((m) => m.id.startsWith(shortOrFullId));
|
|
30
|
+
if (!match) {
|
|
31
|
+
throw new Error(`No memory found with ID starting with "${shortOrFullId}".\nUse /memory list to see available memories.`);
|
|
32
|
+
}
|
|
33
|
+
return match.id;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Handle /memory list command
|
|
37
|
+
*/
|
|
38
|
+
export async function handleMemoryList(args) {
|
|
39
|
+
try {
|
|
40
|
+
const client = getSovantClient();
|
|
41
|
+
const threadId = await getThreadId();
|
|
42
|
+
// Parse optional count argument
|
|
43
|
+
let limit = DEFAULT_LIST_LIMIT;
|
|
44
|
+
const countArg = args.trim();
|
|
45
|
+
if (countArg) {
|
|
46
|
+
const parsed = parseInt(countArg, 10);
|
|
47
|
+
if (isNaN(parsed) || parsed < 1) {
|
|
48
|
+
return `Invalid count. Usage: /memory list [count]\nExample: /memory list 10`;
|
|
49
|
+
}
|
|
50
|
+
limit = Math.min(parsed, MAX_LIST_LIMIT);
|
|
51
|
+
}
|
|
52
|
+
const result = await client.memory.list({
|
|
53
|
+
thread_id: threadId,
|
|
54
|
+
limit,
|
|
55
|
+
sort_by: "created_at",
|
|
56
|
+
sort_order: "desc",
|
|
57
|
+
});
|
|
58
|
+
const memories = result.memories || [];
|
|
59
|
+
const total = result.total || memories.length;
|
|
60
|
+
return formatMemoryList(memories, total);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return `Failed to list memories: ${formatSovantError(error)}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Handle /memory delete command
|
|
68
|
+
*/
|
|
69
|
+
export async function handleMemoryDelete(memoryId) {
|
|
70
|
+
const id = memoryId.trim();
|
|
71
|
+
if (!id) {
|
|
72
|
+
return "Please provide a memory ID. Usage: /memory delete <id>\nUse /memory list to see memory IDs.";
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const client = getSovantClient();
|
|
76
|
+
const fullId = await resolveMemoryId(id);
|
|
77
|
+
await client.memory.delete(fullId);
|
|
78
|
+
return `Deleted memory ${shortId(fullId)}`;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return `Failed to delete memory: ${formatSovantError(error)}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Handle /memory show command - show full memory details
|
|
86
|
+
*/
|
|
87
|
+
export async function handleMemoryShow(memoryId) {
|
|
88
|
+
const id = memoryId.trim();
|
|
89
|
+
if (!id) {
|
|
90
|
+
return "Please provide a memory ID. Usage: /memory show <id>\nUse /memory list to see memory IDs.";
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const client = getSovantClient();
|
|
94
|
+
const fullId = await resolveMemoryId(id);
|
|
95
|
+
const result = await client.memory.get(fullId);
|
|
96
|
+
if (!result) {
|
|
97
|
+
return `Memory ${shortId(fullId)} not found.`;
|
|
98
|
+
}
|
|
99
|
+
// Format full memory details
|
|
100
|
+
const memory = result;
|
|
101
|
+
const lines = [
|
|
102
|
+
`**Memory ${shortId(memory.id)}**`,
|
|
103
|
+
`Type: ${memory.type || "unknown"}`,
|
|
104
|
+
`Created: ${formatDate(memory.created_at)}`,
|
|
105
|
+
`Tags: ${(memory.tags || []).join(", ") || "none"}`,
|
|
106
|
+
"",
|
|
107
|
+
"**Content:**",
|
|
108
|
+
memory.content || "(empty)",
|
|
109
|
+
];
|
|
110
|
+
if (memory.metadata && Object.keys(memory.metadata).length > 0) {
|
|
111
|
+
lines.push("");
|
|
112
|
+
lines.push("**Metadata:**");
|
|
113
|
+
lines.push(JSON.stringify(memory.metadata, null, 2));
|
|
114
|
+
}
|
|
115
|
+
return lines.join("\n");
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return `Failed to get memory: ${formatSovantError(error)}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Handle memory update — replace a memory's content by ID
|
|
123
|
+
*/
|
|
124
|
+
export async function handleMemoryUpdate(memoryId, text) {
|
|
125
|
+
const id = memoryId.trim();
|
|
126
|
+
if (!id) {
|
|
127
|
+
return "Please provide a memory ID. Usage: sovant_memory_update { memory_id, text }";
|
|
128
|
+
}
|
|
129
|
+
if (!text.trim()) {
|
|
130
|
+
return "Please provide new text content.";
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const client = getSovantClient();
|
|
134
|
+
const fullId = await resolveMemoryId(id);
|
|
135
|
+
await client.memory.update(fullId, { data: text.trim() });
|
|
136
|
+
return `Updated memory ${shortId(fullId)}`;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return `Failed to update memory: ${formatSovantError(error)}`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Route memory subcommands
|
|
144
|
+
*/
|
|
145
|
+
export async function handleMemory(args) {
|
|
146
|
+
const parts = args.trim().split(/\s+/);
|
|
147
|
+
const subcommand = parts[0]?.toLowerCase();
|
|
148
|
+
const subArgs = parts.slice(1).join(" ");
|
|
149
|
+
switch (subcommand) {
|
|
150
|
+
case "list":
|
|
151
|
+
return handleMemoryList(subArgs);
|
|
152
|
+
case "delete":
|
|
153
|
+
return handleMemoryDelete(subArgs);
|
|
154
|
+
case "show":
|
|
155
|
+
return handleMemoryShow(subArgs);
|
|
156
|
+
case "":
|
|
157
|
+
case undefined:
|
|
158
|
+
return ("Memory commands:\n" +
|
|
159
|
+
" /memory list [n] - List recent memories (default 20)\n" +
|
|
160
|
+
" /memory delete <id> - Delete a memory by ID\n" +
|
|
161
|
+
" /memory show <id> - Show full memory details");
|
|
162
|
+
default:
|
|
163
|
+
return `Unknown subcommand: ${subcommand}\nUse /memory for available commands.`;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/commands/memory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAY,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B;;;;GAIG;AACH,KAA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OAAO,CAAC,CAAC;QACrC,KAAK,MAAM;YACT,OAAO,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACnC,KAAK,EAAE,CAAC;QACR,KAAK,SAAS;YACZ,OAAO,CACL,oBAAoB;gBACpB,6DAA6D;gBAC7D,iDAAiD;gBACjD,kDAAkD,CACnD,CAAC;QACJ;YACE,OAAO,uBAAuB,UAAU,uCAAuC,CAAC;IACpF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recall and search command handlers
|
|
3
|
+
*
|
|
4
|
+
* handleRecall — thread-scoped hybrid recall (current repo only)
|
|
5
|
+
* handleSearch — explicit-scope search (repo default, global opt-in)
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Handle /recall command — hybrid recall with optional scope/mode/debug
|
|
9
|
+
*
|
|
10
|
+
* scope="thread" (default): filters by current repo thread_id
|
|
11
|
+
* scope="global": omits thread_id for cross-project recall
|
|
12
|
+
* mode="smart" (default): full hybrid pipeline (LLM interpreter + vector + lexical)
|
|
13
|
+
* mode="exact": deterministic keyword-only recall
|
|
14
|
+
* debug=true: appends source/type counts and token estimates
|
|
15
|
+
* includeWorkspace=true: include non-dev memories (dashboard, CRM, smart capture)
|
|
16
|
+
* Default false — MCP recall is dev-only (source:claude-code tagged) by default
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleRecall(query: string, limit?: number, scope?: "thread" | "global", mode?: "smart" | "exact", debug?: boolean, includeWorkspace?: boolean): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Handle search command — explicit-scope memory search
|
|
21
|
+
*
|
|
22
|
+
* scope="repo" (default): filters by repo tag and/or thread_id
|
|
23
|
+
* scope="global": no repo or thread filtering
|
|
24
|
+
*/
|
|
25
|
+
export declare function handleSearch(params: {
|
|
26
|
+
query: string;
|
|
27
|
+
scope?: "repo" | "global";
|
|
28
|
+
tags?: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
limit?: number;
|
|
31
|
+
}): Promise<string>;
|
|
32
|
+
//# sourceMappingURL=recall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/commands/recall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAC3B,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,EACxB,KAAK,CAAC,EAAE,OAAO,EACf,gBAAgB,CAAC,EAAE,OAAO,GACzB,OAAO,CAAC,MAAM,CAAC,CAoDjB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkElB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recall and search command handlers
|
|
3
|
+
*
|
|
4
|
+
* handleRecall — thread-scoped hybrid recall (current repo only)
|
|
5
|
+
* handleSearch — explicit-scope search (repo default, global opt-in)
|
|
6
|
+
*/
|
|
7
|
+
import { getSovantClient, formatSovantError } from "../sovant.js";
|
|
8
|
+
import { getThreadId } from "./shared.js";
|
|
9
|
+
import { getRepoInfo } from "../repo.js";
|
|
10
|
+
import { formatRecallResults, formatSearchResults } from "../format.js";
|
|
11
|
+
const DEFAULT_RECALL_LIMIT = 10;
|
|
12
|
+
const MAX_RECALL_LIMIT = 25;
|
|
13
|
+
const DEFAULT_SEARCH_LIMIT = 10;
|
|
14
|
+
const MAX_SEARCH_LIMIT = 20;
|
|
15
|
+
/**
|
|
16
|
+
* Handle /recall command — hybrid recall with optional scope/mode/debug
|
|
17
|
+
*
|
|
18
|
+
* scope="thread" (default): filters by current repo thread_id
|
|
19
|
+
* scope="global": omits thread_id for cross-project recall
|
|
20
|
+
* mode="smart" (default): full hybrid pipeline (LLM interpreter + vector + lexical)
|
|
21
|
+
* mode="exact": deterministic keyword-only recall
|
|
22
|
+
* debug=true: appends source/type counts and token estimates
|
|
23
|
+
* includeWorkspace=true: include non-dev memories (dashboard, CRM, smart capture)
|
|
24
|
+
* Default false — MCP recall is dev-only (source:claude-code tagged) by default
|
|
25
|
+
*/
|
|
26
|
+
export async function handleRecall(query, limit, scope, mode, debug, includeWorkspace) {
|
|
27
|
+
if (!query.trim()) {
|
|
28
|
+
return "Please provide a search query. Usage: /recall <question>";
|
|
29
|
+
}
|
|
30
|
+
const effectiveLimit = Math.min(limit ?? DEFAULT_RECALL_LIMIT, MAX_RECALL_LIMIT);
|
|
31
|
+
try {
|
|
32
|
+
const client = getSovantClient();
|
|
33
|
+
// Build recall params — omit thread_id for global scope
|
|
34
|
+
// Default space=dev (only source:claude-code tagged memories)
|
|
35
|
+
// unless includeWorkspace=true, then space=all
|
|
36
|
+
const recallParams = {
|
|
37
|
+
query: query.trim(),
|
|
38
|
+
limit: effectiveLimit,
|
|
39
|
+
space: includeWorkspace ? "all" : "dev",
|
|
40
|
+
};
|
|
41
|
+
if (scope !== "global") {
|
|
42
|
+
recallParams.thread_id = await getThreadId();
|
|
43
|
+
}
|
|
44
|
+
if (mode) {
|
|
45
|
+
recallParams.mode = mode;
|
|
46
|
+
}
|
|
47
|
+
const result = await client.memory.recall(recallParams);
|
|
48
|
+
const results = result?.results || [];
|
|
49
|
+
let output = formatRecallResults(results, query.trim());
|
|
50
|
+
// Append debug block if requested
|
|
51
|
+
if (debug) {
|
|
52
|
+
const meta = result?.recall_metadata || {};
|
|
53
|
+
const spaceUsed = includeWorkspace ? "all" : "dev";
|
|
54
|
+
const bySource = {};
|
|
55
|
+
const byType = {};
|
|
56
|
+
for (const r of results) {
|
|
57
|
+
bySource[r.source || "unknown"] =
|
|
58
|
+
(bySource[r.source || "unknown"] || 0) + 1;
|
|
59
|
+
byType[r.type || "unknown"] = (byType[r.type || "unknown"] || 0) + 1;
|
|
60
|
+
}
|
|
61
|
+
output += `\n---\nDebug: scope=${scope || "thread"} mode=${mode || "smart"} space=${spaceUsed} returned=${results.length} pinned=${meta.pinned_count ?? 0} est_tokens=${meta.estimated_tokens ?? "?"} omitted=${meta.omitted_by_budget ?? 0} truncated=${meta.truncated ?? false}\n bySource: ${JSON.stringify(bySource)}\n byType: ${JSON.stringify(byType)}`;
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return `Recall failed: ${formatSovantError(error)}`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handle search command — explicit-scope memory search
|
|
71
|
+
*
|
|
72
|
+
* scope="repo" (default): filters by repo tag and/or thread_id
|
|
73
|
+
* scope="global": no repo or thread filtering
|
|
74
|
+
*/
|
|
75
|
+
export async function handleSearch(params) {
|
|
76
|
+
const query = params.query?.trim();
|
|
77
|
+
if (!query) {
|
|
78
|
+
return "Please provide a search query.";
|
|
79
|
+
}
|
|
80
|
+
const scope = params.scope || "repo";
|
|
81
|
+
const effectiveLimit = Math.min(params.limit ?? DEFAULT_SEARCH_LIMIT, MAX_SEARCH_LIMIT);
|
|
82
|
+
try {
|
|
83
|
+
const client = getSovantClient();
|
|
84
|
+
const repoInfo = getRepoInfo();
|
|
85
|
+
// Build search parameters based on scope
|
|
86
|
+
const searchParams = {
|
|
87
|
+
query,
|
|
88
|
+
limit: effectiveLimit,
|
|
89
|
+
};
|
|
90
|
+
// Parse user-provided tags
|
|
91
|
+
const userTags = params.tags
|
|
92
|
+
? params.tags
|
|
93
|
+
.split(",")
|
|
94
|
+
.map((t) => t.trim())
|
|
95
|
+
.filter(Boolean)
|
|
96
|
+
: [];
|
|
97
|
+
if (scope === "repo") {
|
|
98
|
+
// Safe-by-default: scope to current repo
|
|
99
|
+
const threadId = await getThreadId();
|
|
100
|
+
searchParams.thread_id = threadId;
|
|
101
|
+
if (repoInfo.repo) {
|
|
102
|
+
userTags.push(`repo:${repoInfo.repo}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// scope="global": no thread_id, no repo tag — intentionally wide
|
|
106
|
+
if (userTags.length > 0) {
|
|
107
|
+
searchParams.tags = userTags;
|
|
108
|
+
}
|
|
109
|
+
if (params.type) {
|
|
110
|
+
searchParams.type = params.type;
|
|
111
|
+
}
|
|
112
|
+
const result = await client.memory.search(searchParams);
|
|
113
|
+
const results = result?.results || result?.memories || [];
|
|
114
|
+
// Build scope header
|
|
115
|
+
const scopeHeader = scope === "repo"
|
|
116
|
+
? `Scope: REPO (${repoInfo.repo})`
|
|
117
|
+
: `Scope: GLOBAL (all projects)`;
|
|
118
|
+
return formatSearchResults(results, query, scopeHeader, scope === "global");
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return `Search failed: ${formatSovantError(error)}`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.js","sourceRoot":"","sources":["../../src/commands/recall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,oBAAo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MAAc,EAAE,OAAO,IAAK,MAAc,EAAE,QAAQ,IAAI,EAAE,CAAC;QAE5E,qBAAqB;QACrB,MAAM,WAAW,GACf,KAAK,KAAK,MAAM;YACd,CAAC,CAAC,gBAAgB,QAAQ,CAAC,IAAI,GAAG;YAClC,CAAC,CAAC,8BAA8B,CAAC;QAErC,OAAO,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC;IAC9E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,kBAAkB,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remember command handlers
|
|
3
|
+
*
|
|
4
|
+
* /remember <text> - Save as journal entry
|
|
5
|
+
* /remember-pref <text> - Save as preference
|
|
6
|
+
* /remember-decision <text> - Save as decision/insight
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Handle /remember command - saves as journal entry
|
|
10
|
+
*/
|
|
11
|
+
export declare function handleRemember(text: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Handle /remember-pref command - saves as preference
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleRememberPref(text: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Handle /remember-decision command - saves as decision/insight
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleRememberDecision(text: string): Promise<string>;
|
|
20
|
+
//# sourceMappingURL=remember.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remember.d.ts","sourceRoot":"","sources":["../../src/commands/remember.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsFH;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOlE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOtE;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAO1E"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remember command handlers
|
|
3
|
+
*
|
|
4
|
+
* /remember <text> - Save as journal entry
|
|
5
|
+
* /remember-pref <text> - Save as preference
|
|
6
|
+
* /remember-decision <text> - Save as decision/insight
|
|
7
|
+
*/
|
|
8
|
+
import { getSovantClient, formatSovantError } from "../sovant.js";
|
|
9
|
+
import { getThreadId, buildMemoryTags } from "./shared.js";
|
|
10
|
+
import { getRepoInfo } from "../repo.js";
|
|
11
|
+
import { shortId } from "../format.js";
|
|
12
|
+
/**
|
|
13
|
+
* Create a memory with the appropriate type and tags
|
|
14
|
+
*/
|
|
15
|
+
async function createMemory(content, variant) {
|
|
16
|
+
try {
|
|
17
|
+
const client = getSovantClient();
|
|
18
|
+
const threadId = await getThreadId();
|
|
19
|
+
const repoInfo = getRepoInfo();
|
|
20
|
+
// Determine type and build tags using shared helper
|
|
21
|
+
let type;
|
|
22
|
+
const tags = buildMemoryTags(repoInfo);
|
|
23
|
+
tags.push("user-saved"); // All explicit saves are user-saved
|
|
24
|
+
switch (variant) {
|
|
25
|
+
case "journal":
|
|
26
|
+
type = "journal";
|
|
27
|
+
break;
|
|
28
|
+
case "preference":
|
|
29
|
+
type = "preference";
|
|
30
|
+
tags.push("preference");
|
|
31
|
+
break;
|
|
32
|
+
case "decision":
|
|
33
|
+
type = "insight";
|
|
34
|
+
tags.push("decision");
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
// Build metadata
|
|
38
|
+
const metadata = {
|
|
39
|
+
source: "claude-code",
|
|
40
|
+
repo: repoInfo.repo,
|
|
41
|
+
branch: repoInfo.branch,
|
|
42
|
+
user_confirmed: true,
|
|
43
|
+
confidence: 1.0,
|
|
44
|
+
};
|
|
45
|
+
// Create the memory
|
|
46
|
+
const result = await client.memory.create({
|
|
47
|
+
data: content,
|
|
48
|
+
type,
|
|
49
|
+
tags,
|
|
50
|
+
metadata,
|
|
51
|
+
thread_id: threadId,
|
|
52
|
+
});
|
|
53
|
+
const id = result?.id;
|
|
54
|
+
if (!id) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
message: "Memory created but no ID returned",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
message: `Saved memory ${shortId(id)}`,
|
|
63
|
+
memoryId: id,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
message: formatSovantError(error),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Handle /remember command - saves as journal entry
|
|
75
|
+
*/
|
|
76
|
+
export async function handleRemember(text) {
|
|
77
|
+
if (!text.trim()) {
|
|
78
|
+
return "Please provide text to remember. Usage: /remember <text>";
|
|
79
|
+
}
|
|
80
|
+
const result = await createMemory(text.trim(), "journal");
|
|
81
|
+
return result.message;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Handle /remember-pref command - saves as preference
|
|
85
|
+
*/
|
|
86
|
+
export async function handleRememberPref(text) {
|
|
87
|
+
if (!text.trim()) {
|
|
88
|
+
return "Please provide a preference to remember. Usage: /remember-pref <preference>";
|
|
89
|
+
}
|
|
90
|
+
const result = await createMemory(text.trim(), "preference");
|
|
91
|
+
return result.message;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Handle /remember-decision command - saves as decision/insight
|
|
95
|
+
*/
|
|
96
|
+
export async function handleRememberDecision(text) {
|
|
97
|
+
if (!text.trim()) {
|
|
98
|
+
return "Please provide a decision to remember. Usage: /remember-decision <decision>";
|
|
99
|
+
}
|
|
100
|
+
const result = await createMemory(text.trim(), "decision");
|
|
101
|
+
return result.message;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=remember.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remember.js","sourceRoot":"","sources":["../../src/commands/remember.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAWvC;;GAEG;AACH,KAAK,UAAU,YAAY,CACzB,OAAe,EACf,OAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAE/B,oDAAoD;QACpD,IAAI,IAA0C,CAAC;QAC/C,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,oCAAoC;QAE7D,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,SAAS;gBACZ,IAAI,GAAG,SAAS,CAAC;gBACjB,MAAM;YACR,KAAK,YAAY;gBACf,IAAI,GAAG,YAAY,CAAC;gBACpB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBACxB,MAAM;YACR,KAAK,UAAU;gBACb,IAAI,GAAG,SAAS,CAAC;gBACjB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;QACV,CAAC;QAED,iBAAiB;QACjB,MAAM,QAAQ,GAAG;YACf,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACn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