@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/dist/index.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Sovant MCP Server for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* Provides persistent project memory through Sovant's governed memory layer.
|
|
6
|
+
* Creates/loads a thread per git repository and exposes tools for:
|
|
7
|
+
* - Saving memories (/remember, /remember-pref, /remember-decision)
|
|
8
|
+
* - Recalling memories (/recall)
|
|
9
|
+
* - Managing memories (/memory list, /memory delete)
|
|
10
|
+
*
|
|
11
|
+
* On session start, runs a recall to load project context.
|
|
12
|
+
*/
|
|
13
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
14
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
16
|
+
import { hasApiKey } from "./sovant.js";
|
|
17
|
+
import { initializeThread, isSessionInitialized, getThreadInfo, } from "./commands/shared.js";
|
|
18
|
+
import { handleRemember, handleRememberPref, handleRememberDecision, } from "./commands/remember.js";
|
|
19
|
+
import { handleRecall, handleSearch } from "./commands/recall.js";
|
|
20
|
+
import { handleMemory, handleMemoryUpdate } from "./commands/memory.js";
|
|
21
|
+
// Tool definitions
|
|
22
|
+
const TOOLS = [
|
|
23
|
+
{
|
|
24
|
+
name: "sovant_remember",
|
|
25
|
+
description: "Save a note, fact, or context to project memory. Use for general notes about the project.",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
text: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "The text to remember",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
required: ["text"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "sovant_remember_pref",
|
|
39
|
+
description: "Save a user preference to project memory. Use for coding style preferences, tool choices, etc.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: "object",
|
|
42
|
+
properties: {
|
|
43
|
+
text: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "The preference to remember",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["text"],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "sovant_remember_decision",
|
|
53
|
+
description: "Save an important decision to project memory. Use for architectural decisions, tech choices, tradeoffs.",
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
text: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "The decision to remember",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ["text"],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "sovant_recall",
|
|
67
|
+
description: "Search project memories for relevant context, scoped to the current repository's thread. Use to find past decisions, preferences, or notes.",
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: "object",
|
|
70
|
+
properties: {
|
|
71
|
+
query: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "The search query or question",
|
|
74
|
+
},
|
|
75
|
+
limit: {
|
|
76
|
+
type: "number",
|
|
77
|
+
description: "Max results to return (default: 10, max: 25)",
|
|
78
|
+
},
|
|
79
|
+
scope: {
|
|
80
|
+
type: "string",
|
|
81
|
+
enum: ["thread", "global"],
|
|
82
|
+
description: "Search scope: 'thread' (default, current repo) or 'global' (all projects)",
|
|
83
|
+
},
|
|
84
|
+
mode: {
|
|
85
|
+
type: "string",
|
|
86
|
+
enum: ["smart", "exact"],
|
|
87
|
+
description: "Recall mode: 'smart' (default, hybrid AI recall) or 'exact' (deterministic keyword match)",
|
|
88
|
+
},
|
|
89
|
+
debug: {
|
|
90
|
+
type: "boolean",
|
|
91
|
+
description: "Include debug info (counts, token estimates, sources)",
|
|
92
|
+
},
|
|
93
|
+
include_workspace: {
|
|
94
|
+
type: "boolean",
|
|
95
|
+
description: "Include non-dev memories (dashboard, CRM, smart capture). Default: false (dev memories only)",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
required: ["query"],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "sovant_memory_list",
|
|
103
|
+
description: "List recent project memories with short IDs needed for show/update/delete.",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
type: "object",
|
|
106
|
+
properties: {
|
|
107
|
+
count: {
|
|
108
|
+
type: "number",
|
|
109
|
+
description: "Number of memories to list (default: 20, max: 100)",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "sovant_memory_delete",
|
|
116
|
+
description: "Delete a memory by its ID. Use the short ID from /memory list.",
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
memory_id: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "The memory ID to delete (full or short ID)",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
required: ["memory_id"],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "sovant_memory_update",
|
|
130
|
+
description: "Update an existing memory's content. Use the short ID from /memory list.",
|
|
131
|
+
inputSchema: {
|
|
132
|
+
type: "object",
|
|
133
|
+
properties: {
|
|
134
|
+
memory_id: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "The memory ID to update (full or short ID)",
|
|
137
|
+
},
|
|
138
|
+
text: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "The new content for the memory",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
required: ["memory_id", "text"],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "sovant_memory_show",
|
|
148
|
+
description: "Show full details of a specific memory, including tags, metadata, and creation date.",
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: "object",
|
|
151
|
+
properties: {
|
|
152
|
+
memory_id: {
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "The memory ID to show (full or short ID)",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
required: ["memory_id"],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "sovant_search",
|
|
162
|
+
description: "Search memories with explicit scoping. Defaults to current repo (safe). Use scope='global' to search across all projects.",
|
|
163
|
+
inputSchema: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
query: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "The search query",
|
|
169
|
+
},
|
|
170
|
+
scope: {
|
|
171
|
+
type: "string",
|
|
172
|
+
enum: ["repo", "global"],
|
|
173
|
+
description: "Search scope: 'repo' (default, current project only) or 'global' (all projects)",
|
|
174
|
+
},
|
|
175
|
+
tags: {
|
|
176
|
+
type: "string",
|
|
177
|
+
description: "Comma-separated tags to filter by",
|
|
178
|
+
},
|
|
179
|
+
type: {
|
|
180
|
+
type: "string",
|
|
181
|
+
description: "Memory type filter (e.g. 'decision', 'preference')",
|
|
182
|
+
},
|
|
183
|
+
limit: {
|
|
184
|
+
type: "number",
|
|
185
|
+
description: "Max results to return (default: 10, max: 20)",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
required: ["query"],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "sovant_thread_info",
|
|
193
|
+
description: "Get info about the current project's memory thread, including thread title, memory count, and creation date.",
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
// Create server
|
|
201
|
+
const server = new Server({
|
|
202
|
+
name: "sovant-claude-code",
|
|
203
|
+
version: "0.3.0",
|
|
204
|
+
}, {
|
|
205
|
+
capabilities: {
|
|
206
|
+
tools: {},
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
// Handle tool listing
|
|
210
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
211
|
+
return { tools: TOOLS };
|
|
212
|
+
});
|
|
213
|
+
// Handle tool calls
|
|
214
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
215
|
+
const { name, arguments: args } = request.params;
|
|
216
|
+
// Check for API key first
|
|
217
|
+
if (!hasApiKey()) {
|
|
218
|
+
return {
|
|
219
|
+
content: [
|
|
220
|
+
{
|
|
221
|
+
type: "text",
|
|
222
|
+
text: "SOVANT_API_KEY environment variable is not set.\n" +
|
|
223
|
+
"Please set it in your shell or Claude Code configuration:\n" +
|
|
224
|
+
" export SOVANT_API_KEY=sk_live_your_key_here\n" +
|
|
225
|
+
"Get your API key at https://sovant.ai/dashboard/settings/api-keys",
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
isError: true,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// Initialize thread on first tool call if not already done
|
|
232
|
+
if (!isSessionInitialized()) {
|
|
233
|
+
try {
|
|
234
|
+
const { summary, isNew } = await initializeThread();
|
|
235
|
+
// Log the session summary (will be visible in Claude Code)
|
|
236
|
+
console.error(`[sovant] ${isNew ? "Created new thread" : "Loaded thread"}`);
|
|
237
|
+
console.error(`[sovant] ${summary}`);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.error("[sovant] Failed to initialize thread:", error);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
let result;
|
|
245
|
+
switch (name) {
|
|
246
|
+
case "sovant_remember":
|
|
247
|
+
result = await handleRemember(args?.text || "");
|
|
248
|
+
break;
|
|
249
|
+
case "sovant_remember_pref":
|
|
250
|
+
result = await handleRememberPref(args?.text || "");
|
|
251
|
+
break;
|
|
252
|
+
case "sovant_remember_decision":
|
|
253
|
+
result = await handleRememberDecision(args?.text || "");
|
|
254
|
+
break;
|
|
255
|
+
case "sovant_recall":
|
|
256
|
+
result = await handleRecall(args?.query || "", args?.limit, args?.scope, args?.mode, args?.debug, args?.include_workspace);
|
|
257
|
+
break;
|
|
258
|
+
case "sovant_search":
|
|
259
|
+
result = await handleSearch({
|
|
260
|
+
query: args?.query || "",
|
|
261
|
+
scope: args?.scope,
|
|
262
|
+
tags: args?.tags,
|
|
263
|
+
type: args?.type,
|
|
264
|
+
limit: args?.limit,
|
|
265
|
+
});
|
|
266
|
+
break;
|
|
267
|
+
case "sovant_memory_list":
|
|
268
|
+
result = await handleMemory(`list ${args?.count || ""}`);
|
|
269
|
+
break;
|
|
270
|
+
case "sovant_memory_delete":
|
|
271
|
+
result = await handleMemory(`delete ${args?.memory_id || ""}`);
|
|
272
|
+
break;
|
|
273
|
+
case "sovant_memory_update":
|
|
274
|
+
result = await handleMemoryUpdate(args?.memory_id || "", args?.text || "");
|
|
275
|
+
break;
|
|
276
|
+
case "sovant_memory_show":
|
|
277
|
+
result = await handleMemory(`show ${args?.memory_id || ""}`);
|
|
278
|
+
break;
|
|
279
|
+
case "sovant_thread_info": {
|
|
280
|
+
const info = await getThreadInfo();
|
|
281
|
+
result = [
|
|
282
|
+
`**Project Thread Info** (${info.data_source})`,
|
|
283
|
+
`Repo: ${info.repo}`,
|
|
284
|
+
`Thread ID: ${info.thread_id}`,
|
|
285
|
+
`Thread Title: ${info.thread_title}`,
|
|
286
|
+
info.memory_count !== undefined
|
|
287
|
+
? `Memories: ${info.memory_count}`
|
|
288
|
+
: null,
|
|
289
|
+
info.created_at ? `Created: ${info.created_at}` : null,
|
|
290
|
+
info.branch ? `Branch: ${info.branch}` : null,
|
|
291
|
+
`Config File: ${info.config_path}`,
|
|
292
|
+
]
|
|
293
|
+
.filter(Boolean)
|
|
294
|
+
.join("\n");
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
default:
|
|
298
|
+
result = `Unknown tool: ${name}`;
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
content: [
|
|
302
|
+
{
|
|
303
|
+
type: "text",
|
|
304
|
+
text: result,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
const message = error instanceof Error ? error.message : "Unknown error occurred";
|
|
311
|
+
return {
|
|
312
|
+
content: [
|
|
313
|
+
{
|
|
314
|
+
type: "text",
|
|
315
|
+
text: `Error: ${message}`,
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
isError: true,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
// Start server
|
|
323
|
+
async function main() {
|
|
324
|
+
const transport = new StdioServerTransport();
|
|
325
|
+
await server.connect(transport);
|
|
326
|
+
console.error("[sovant] MCP server started");
|
|
327
|
+
}
|
|
328
|
+
main().catch((error) => {
|
|
329
|
+
console.error("[sovant] Fatal error:", error);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
});
|
|
332
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAExE,mBAAmB;AACnB,MAAM,KAAK,GAAW;IACpB;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,2FAA2F;QAC7F,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAA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-0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local storage for Sovant thread configuration
|
|
3
|
+
*
|
|
4
|
+
* Persists the thread ID mapping in .sovant/thread.json so that
|
|
5
|
+
* memories are associated with the correct repo across sessions.
|
|
6
|
+
*/
|
|
7
|
+
export interface ThreadConfig {
|
|
8
|
+
/** Sovant thread UUID */
|
|
9
|
+
thread_id: string;
|
|
10
|
+
/** Repository identifier (owner/repo or folder name) */
|
|
11
|
+
repo: string;
|
|
12
|
+
/** When the thread was first created */
|
|
13
|
+
created_at: string;
|
|
14
|
+
/** Last time this config was accessed */
|
|
15
|
+
last_seen: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the path to the thread config file
|
|
19
|
+
*/
|
|
20
|
+
export declare function getConfigPath(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Load thread configuration from .sovant/thread.json
|
|
23
|
+
* @returns ThreadConfig or null if not found
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadThreadConfig(): ThreadConfig | null;
|
|
26
|
+
/**
|
|
27
|
+
* Save thread configuration to .sovant/thread.json
|
|
28
|
+
* @returns true if saved successfully, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
export declare function saveThreadConfig(config: ThreadConfig): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Update the last_seen timestamp in the config
|
|
33
|
+
*/
|
|
34
|
+
export declare function updateLastSeen(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the .sovant directory is writable
|
|
37
|
+
*/
|
|
38
|
+
export declare function canWriteConfig(): boolean;
|
|
39
|
+
//# sourceMappingURL=localStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStore.d.ts","sourceRoot":"","sources":["../src/localStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,YAAY;IAC3B,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,GAAG,IAAI,CAsBtD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAkB9D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAoBxC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local storage for Sovant thread configuration
|
|
3
|
+
*
|
|
4
|
+
* Persists the thread ID mapping in .sovant/thread.json so that
|
|
5
|
+
* memories are associated with the correct repo across sessions.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
8
|
+
import { join, dirname } from "path";
|
|
9
|
+
const SOVANT_DIR = ".sovant";
|
|
10
|
+
const THREAD_FILE = "thread.json";
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the thread config file
|
|
13
|
+
*/
|
|
14
|
+
export function getConfigPath() {
|
|
15
|
+
return join(process.cwd(), SOVANT_DIR, THREAD_FILE);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load thread configuration from .sovant/thread.json
|
|
19
|
+
* @returns ThreadConfig or null if not found
|
|
20
|
+
*/
|
|
21
|
+
export function loadThreadConfig() {
|
|
22
|
+
const configPath = getConfigPath();
|
|
23
|
+
if (!existsSync(configPath)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const content = readFileSync(configPath, "utf-8");
|
|
28
|
+
const config = JSON.parse(content);
|
|
29
|
+
// Validate required fields
|
|
30
|
+
if (!config.thread_id || !config.repo) {
|
|
31
|
+
console.error("[sovant] Invalid thread config, missing required fields");
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error("[sovant] Failed to load thread config:", error);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Save thread configuration to .sovant/thread.json
|
|
43
|
+
* @returns true if saved successfully, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
export function saveThreadConfig(config) {
|
|
46
|
+
const configPath = getConfigPath();
|
|
47
|
+
const configDir = dirname(configPath);
|
|
48
|
+
try {
|
|
49
|
+
// Create .sovant directory if it doesn't exist
|
|
50
|
+
if (!existsSync(configDir)) {
|
|
51
|
+
mkdirSync(configDir, { recursive: true });
|
|
52
|
+
}
|
|
53
|
+
// Write config with pretty formatting
|
|
54
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error("[sovant] Failed to save thread config:", error);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Update the last_seen timestamp in the config
|
|
64
|
+
*/
|
|
65
|
+
export function updateLastSeen() {
|
|
66
|
+
const config = loadThreadConfig();
|
|
67
|
+
if (config) {
|
|
68
|
+
config.last_seen = new Date().toISOString();
|
|
69
|
+
saveThreadConfig(config);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if the .sovant directory is writable
|
|
74
|
+
*/
|
|
75
|
+
export function canWriteConfig() {
|
|
76
|
+
const configDir = join(process.cwd(), SOVANT_DIR);
|
|
77
|
+
try {
|
|
78
|
+
if (!existsSync(configDir)) {
|
|
79
|
+
mkdirSync(configDir, { recursive: true });
|
|
80
|
+
}
|
|
81
|
+
// Try to write a test file
|
|
82
|
+
const testPath = join(configDir, ".write-test");
|
|
83
|
+
writeFileSync(testPath, "test", "utf-8");
|
|
84
|
+
// Clean up
|
|
85
|
+
const { unlinkSync } = require("fs");
|
|
86
|
+
unlinkSync(testPath);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=localStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStore.js","sourceRoot":"","sources":["../src/localStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAarC,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;QAEnD,2BAA2B;QAC3B,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACtC,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;YACzE,OAAO,IAAI,CAAC;QACd,CAAC;QAED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AAE,CAAC;YAC3B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QAED,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QAChD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEzC,WAAW;QACX,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/repo.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git repository detection helpers
|
|
3
|
+
*
|
|
4
|
+
* Detects the current git repository and extracts identifying information
|
|
5
|
+
* like owner/repo name and current branch.
|
|
6
|
+
*/
|
|
7
|
+
export interface RepoInfo {
|
|
8
|
+
/** Repository identifier (owner/repo or folder name) */
|
|
9
|
+
repo: string;
|
|
10
|
+
/** Current git branch (if available) */
|
|
11
|
+
branch?: string;
|
|
12
|
+
/** Whether this is a git repository */
|
|
13
|
+
isGitRepo: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get repository information for the current working directory
|
|
17
|
+
*/
|
|
18
|
+
export declare function getRepoInfo(): RepoInfo;
|
|
19
|
+
/**
|
|
20
|
+
* Get a short identifier for the repo (last component)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRepoShortName(repo: string): string;
|
|
23
|
+
//# sourceMappingURL=repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../src/repo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CA+CtC;AAgCD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD"}
|
package/dist/repo.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git repository detection helpers
|
|
3
|
+
*
|
|
4
|
+
* Detects the current git repository and extracts identifying information
|
|
5
|
+
* like owner/repo name and current branch.
|
|
6
|
+
*/
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
import { basename } from "path";
|
|
9
|
+
/**
|
|
10
|
+
* Get repository information for the current working directory
|
|
11
|
+
*/
|
|
12
|
+
export function getRepoInfo() {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
// Try to detect git repo
|
|
15
|
+
try {
|
|
16
|
+
// Check if we're in a git repo
|
|
17
|
+
execSync("git rev-parse --git-dir", { cwd, stdio: "pipe" });
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Not a git repo, use folder name
|
|
21
|
+
return {
|
|
22
|
+
repo: basename(cwd),
|
|
23
|
+
isGitRepo: false,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Get remote URL and extract owner/repo
|
|
27
|
+
let repo;
|
|
28
|
+
try {
|
|
29
|
+
const remoteUrl = execSync("git remote get-url origin", {
|
|
30
|
+
cwd,
|
|
31
|
+
encoding: "utf-8",
|
|
32
|
+
stdio: "pipe",
|
|
33
|
+
}).trim();
|
|
34
|
+
repo = normalizeRemoteUrl(remoteUrl);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// No remote, use folder name
|
|
38
|
+
repo = basename(cwd);
|
|
39
|
+
}
|
|
40
|
+
// Get current branch
|
|
41
|
+
let branch;
|
|
42
|
+
try {
|
|
43
|
+
branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
44
|
+
cwd,
|
|
45
|
+
encoding: "utf-8",
|
|
46
|
+
stdio: "pipe",
|
|
47
|
+
}).trim();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Ignore branch detection errors
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
repo,
|
|
54
|
+
branch,
|
|
55
|
+
isGitRepo: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Normalize a git remote URL to owner/repo format
|
|
60
|
+
*
|
|
61
|
+
* Handles:
|
|
62
|
+
* - https://github.com/owner/repo.git
|
|
63
|
+
* - git@github.com:owner/repo.git
|
|
64
|
+
* - https://gitlab.com/owner/repo
|
|
65
|
+
* - etc.
|
|
66
|
+
*/
|
|
67
|
+
function normalizeRemoteUrl(url) {
|
|
68
|
+
// Remove .git suffix
|
|
69
|
+
url = url.replace(/\.git$/, "");
|
|
70
|
+
// Handle SSH URLs (git@github.com:owner/repo)
|
|
71
|
+
const sshMatch = url.match(/^git@[^:]+:(.+)$/);
|
|
72
|
+
if (sshMatch) {
|
|
73
|
+
return sshMatch[1];
|
|
74
|
+
}
|
|
75
|
+
// Handle HTTPS URLs (https://github.com/owner/repo)
|
|
76
|
+
try {
|
|
77
|
+
const parsed = new URL(url);
|
|
78
|
+
// Remove leading slash and return path
|
|
79
|
+
return parsed.pathname.replace(/^\//, "");
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// If URL parsing fails, return as-is
|
|
83
|
+
return url;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get a short identifier for the repo (last component)
|
|
88
|
+
*/
|
|
89
|
+
export function getRepoShortName(repo) {
|
|
90
|
+
const parts = repo.split("/");
|
|
91
|
+
return parts[parts.length - 1];
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=repo.js.map
|
package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;QACJ,MAAM;QACN,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,GAAW;IACrC,qBAAqB;IACrB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEhC,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC/C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,oDAAoD;IACpD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,uCAAuC;QACvC,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;QACrC,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/sovant.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sovant client wrapper for Claude Code MCP plugin
|
|
3
|
+
*
|
|
4
|
+
* Initializes and provides access to the Sovant SDK client.
|
|
5
|
+
* Handles API key validation and error handling.
|
|
6
|
+
*/
|
|
7
|
+
import { Sovant, SovantError } from "@sovant/sdk";
|
|
8
|
+
/**
|
|
9
|
+
* Get or initialize the Sovant client
|
|
10
|
+
* @throws Error if SOVANT_API_KEY is not set
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSovantClient(): Sovant;
|
|
13
|
+
/**
|
|
14
|
+
* Check if API key is configured
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasApiKey(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Format Sovant errors for user display
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatSovantError(error: unknown): string;
|
|
21
|
+
export { SovantError };
|
|
22
|
+
//# sourceMappingURL=sovant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sovant.d.ts","sourceRoot":"","sources":["../src/sovant.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIlD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAmBxC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAmBxD;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|