@crowley/rag-mcp 1.0.4 → 1.0.6
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/dist/annotations.d.ts +16 -0
- package/dist/annotations.js +158 -0
- package/dist/context-enrichment.d.ts +2 -2
- package/dist/context-enrichment.js +37 -14
- package/dist/formatters.d.ts +2 -0
- package/dist/formatters.js +12 -0
- package/dist/index.js +64 -47
- package/dist/schemas.d.ts +97 -0
- package/dist/schemas.js +128 -0
- package/dist/tool-middleware.d.ts +40 -0
- package/dist/tool-middleware.js +216 -0
- package/dist/tool-registry.js +2 -1
- package/dist/tools/advanced.d.ts +2 -2
- package/dist/tools/advanced.js +200 -275
- package/dist/tools/agents.d.ts +2 -2
- package/dist/tools/agents.js +59 -78
- package/dist/tools/analytics.d.ts +2 -2
- package/dist/tools/analytics.js +170 -210
- package/dist/tools/architecture.d.ts +2 -2
- package/dist/tools/architecture.js +506 -661
- package/dist/tools/ask.d.ts +2 -2
- package/dist/tools/ask.js +164 -219
- package/dist/tools/cache.d.ts +2 -2
- package/dist/tools/cache.js +63 -82
- package/dist/tools/clustering.d.ts +2 -2
- package/dist/tools/clustering.js +154 -215
- package/dist/tools/confluence.d.ts +2 -2
- package/dist/tools/confluence.js +80 -116
- package/dist/tools/database.d.ts +2 -2
- package/dist/tools/database.js +303 -380
- package/dist/tools/feedback.d.ts +2 -2
- package/dist/tools/feedback.js +143 -184
- package/dist/tools/guidelines.d.ts +2 -2
- package/dist/tools/guidelines.js +123 -135
- package/dist/tools/indexing.d.ts +2 -2
- package/dist/tools/indexing.js +104 -100
- package/dist/tools/memory.d.ts +2 -2
- package/dist/tools/memory.js +299 -485
- package/dist/tools/pm.d.ts +2 -2
- package/dist/tools/pm.js +367 -615
- package/dist/tools/review.d.ts +2 -2
- package/dist/tools/review.js +142 -189
- package/dist/tools/search.d.ts +2 -2
- package/dist/tools/search.js +230 -305
- package/dist/tools/session.d.ts +2 -2
- package/dist/tools/session.js +288 -345
- package/dist/tools/suggestions.d.ts +2 -2
- package/dist/tools/suggestions.js +444 -255
- package/dist/types.d.ts +19 -2
- package/package.json +4 -2
package/dist/tools/indexing.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* them to the RAG API in batches via POST /api/index/upload. This allows
|
|
7
7
|
* remote MCP clients to index codebases that aren't on the server filesystem.
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
9
|
+
import type { ToolSpec } from "../types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Create the indexing tools module with project-specific descriptions.
|
|
12
12
|
*/
|
|
13
|
-
export declare function createIndexingTools(projectName: string):
|
|
13
|
+
export declare function createIndexingTools(projectName: string): ToolSpec[];
|
package/dist/tools/indexing.js
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import * as fs from "fs";
|
|
10
10
|
import * as path from "path";
|
|
11
11
|
import { glob } from "glob";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { TOOL_ANNOTATIONS } from "../annotations.js";
|
|
12
14
|
const DEFAULT_PATTERNS = [
|
|
13
15
|
"**/*.ts",
|
|
14
16
|
"**/*.tsx",
|
|
@@ -100,128 +102,130 @@ async function uploadFiles(ctx, projectPath, opts) {
|
|
|
100
102
|
duration: totalDuration,
|
|
101
103
|
};
|
|
102
104
|
}
|
|
105
|
+
// In-memory cache for get_index_status (30 min TTL)
|
|
106
|
+
let _statusCache = null;
|
|
107
|
+
const STATUS_CACHE_TTL = 30 * 60 * 1000; // 30 minutes
|
|
103
108
|
/**
|
|
104
109
|
* Create the indexing tools module with project-specific descriptions.
|
|
105
110
|
*/
|
|
106
111
|
export function createIndexingTools(projectName) {
|
|
107
|
-
|
|
112
|
+
return [
|
|
108
113
|
{
|
|
109
114
|
name: "index_codebase",
|
|
110
115
|
description: `Index or re-index the ${projectName} codebase for RAG search.`,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
116
|
+
schema: z.object({
|
|
117
|
+
path: z.string().optional().describe("Path to index (default: entire project)"),
|
|
118
|
+
force: z.boolean().optional().describe("Force re-index even if already indexed"),
|
|
119
|
+
}),
|
|
120
|
+
annotations: TOOL_ANNOTATIONS["index_codebase"],
|
|
121
|
+
handler: async (args, ctx) => {
|
|
122
|
+
const { path: indexPath, force = false } = args;
|
|
123
|
+
const projectPath = indexPath || ctx.projectPath;
|
|
124
|
+
const stats = await uploadFiles(ctx, projectPath, { force });
|
|
125
|
+
_statusCache = null; // Invalidate status cache after indexing
|
|
126
|
+
let result = `## Indexing ${projectName}\n\n`;
|
|
127
|
+
result += `- **Total files found:** ${stats.totalFiles}\n`;
|
|
128
|
+
result += `- **Files indexed:** ${stats.indexedFiles}\n`;
|
|
129
|
+
result += `- **Chunks created:** ${stats.totalChunks}\n`;
|
|
130
|
+
result += `- **Errors:** ${stats.errors}\n`;
|
|
131
|
+
result += `- **Duration:** ${stats.duration}ms\n`;
|
|
132
|
+
return result;
|
|
124
133
|
},
|
|
125
134
|
},
|
|
126
135
|
{
|
|
127
136
|
name: "get_index_status",
|
|
128
|
-
description: `Get the indexing status for ${projectName} codebase.`,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
description: `Get the indexing status for ${projectName} codebase. Results cached for 30 minutes.`,
|
|
138
|
+
schema: z.object({}),
|
|
139
|
+
outputSchema: z.object({
|
|
140
|
+
status: z.string(),
|
|
141
|
+
totalFiles: z.number().optional(),
|
|
142
|
+
indexedFiles: z.number().optional(),
|
|
143
|
+
lastUpdated: z.string().optional(),
|
|
144
|
+
vectorCount: z.number().optional(),
|
|
145
|
+
cached: z.boolean(),
|
|
146
|
+
}),
|
|
147
|
+
annotations: TOOL_ANNOTATIONS["get_index_status"],
|
|
148
|
+
handler: async (_args, ctx) => {
|
|
149
|
+
// Return cached result if still valid
|
|
150
|
+
if (_statusCache && Date.now() < _statusCache.expiresAt) {
|
|
151
|
+
const remainingMin = Math.round((_statusCache.expiresAt - Date.now()) / 60000);
|
|
152
|
+
return {
|
|
153
|
+
text: _statusCache.data + `\n_Cached (expires in ${remainingMin}min)_`,
|
|
154
|
+
structured: { ..._statusCache.structured, cached: true },
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const response = await ctx.api.get(`/api/index/status/${ctx.collectionPrefix}codebase`);
|
|
158
|
+
const data = response.data;
|
|
159
|
+
let text = `## Index Status: ${projectName}\n\n`;
|
|
160
|
+
text += `- **Status:** ${data.status || "unknown"}\n`;
|
|
161
|
+
text += `- **Total Files:** ${data.totalFiles ?? "N/A"}\n`;
|
|
162
|
+
text += `- **Indexed Files:** ${data.indexedFiles ?? "N/A"}\n`;
|
|
163
|
+
text += `- **Last Updated:** ${data.lastUpdated ? new Date(data.lastUpdated).toLocaleString() : "Never"}\n`;
|
|
164
|
+
text += `- **Vector Count:** ${data.vectorCount ?? "N/A"}\n`;
|
|
165
|
+
const structured = {
|
|
166
|
+
status: data.status || "unknown",
|
|
167
|
+
totalFiles: data.totalFiles,
|
|
168
|
+
indexedFiles: data.indexedFiles,
|
|
169
|
+
lastUpdated: data.lastUpdated,
|
|
170
|
+
vectorCount: data.vectorCount,
|
|
171
|
+
cached: false,
|
|
172
|
+
};
|
|
173
|
+
// Cache for 30 minutes
|
|
174
|
+
_statusCache = { data: text, expiresAt: Date.now() + STATUS_CACHE_TTL, structured };
|
|
175
|
+
return { text, structured };
|
|
132
176
|
},
|
|
133
177
|
},
|
|
134
178
|
{
|
|
135
179
|
name: "reindex_zero_downtime",
|
|
136
180
|
description: `Reindex ${projectName} codebase with zero downtime using alias swap.`,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
181
|
+
schema: z.object({
|
|
182
|
+
path: z.string().optional().describe("Path to index (default: entire project)"),
|
|
183
|
+
patterns: z.array(z.string()).optional().describe("File patterns to include (e.g., ['**/*.ts', '**/*.py'])"),
|
|
184
|
+
excludePatterns: z.array(z.string()).optional().describe("File patterns to exclude (e.g., ['node_modules/**'])"),
|
|
185
|
+
}),
|
|
186
|
+
annotations: TOOL_ANNOTATIONS["reindex_zero_downtime"],
|
|
187
|
+
handler: async (args, ctx) => {
|
|
188
|
+
const { path: indexPath, patterns, excludePatterns } = args;
|
|
189
|
+
const projectPath = indexPath || ctx.projectPath;
|
|
190
|
+
const stats = await uploadFiles(ctx, projectPath, {
|
|
191
|
+
patterns,
|
|
192
|
+
excludePatterns,
|
|
193
|
+
force: true,
|
|
194
|
+
});
|
|
195
|
+
_statusCache = null; // Invalidate status cache after reindex
|
|
196
|
+
let result = `## Reindex: ${projectName}\n\n`;
|
|
197
|
+
result += `- **Total files found:** ${stats.totalFiles}\n`;
|
|
198
|
+
result += `- **Files indexed:** ${stats.indexedFiles}\n`;
|
|
199
|
+
result += `- **Chunks created:** ${stats.totalChunks}\n`;
|
|
200
|
+
result += `- **Errors:** ${stats.errors}\n`;
|
|
201
|
+
result += `- **Duration:** ${stats.duration}ms\n`;
|
|
202
|
+
return result;
|
|
155
203
|
},
|
|
156
204
|
},
|
|
157
205
|
{
|
|
158
206
|
name: "list_aliases",
|
|
159
207
|
description: "List all collection aliases and their mappings.",
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
index_codebase: async (args, ctx) => {
|
|
168
|
-
const { path: indexPath, force = false } = args;
|
|
169
|
-
const projectPath = indexPath || ctx.projectPath;
|
|
170
|
-
const stats = await uploadFiles(ctx, projectPath, { force });
|
|
171
|
-
let result = `## Indexing ${projectName}\n\n`;
|
|
172
|
-
result += `- **Total files found:** ${stats.totalFiles}\n`;
|
|
173
|
-
result += `- **Files indexed:** ${stats.indexedFiles}\n`;
|
|
174
|
-
result += `- **Chunks created:** ${stats.totalChunks}\n`;
|
|
175
|
-
result += `- **Errors:** ${stats.errors}\n`;
|
|
176
|
-
result += `- **Duration:** ${stats.duration}ms\n`;
|
|
177
|
-
return result;
|
|
178
|
-
},
|
|
179
|
-
get_index_status: async (_args, ctx) => {
|
|
180
|
-
const response = await ctx.api.get(`/api/index/status/${ctx.collectionPrefix}codebase`);
|
|
181
|
-
const data = response.data;
|
|
182
|
-
let result = `## Index Status: ${projectName}\n\n`;
|
|
183
|
-
result += `- **Status:** ${data.status || "unknown"}\n`;
|
|
184
|
-
result += `- **Total Files:** ${data.totalFiles ?? "N/A"}\n`;
|
|
185
|
-
result += `- **Indexed Files:** ${data.indexedFiles ?? "N/A"}\n`;
|
|
186
|
-
result += `- **Last Updated:** ${data.lastUpdated ? new Date(data.lastUpdated).toLocaleString() : "Never"}\n`;
|
|
187
|
-
result += `- **Vector Count:** ${data.vectorCount ?? "N/A"}\n`;
|
|
188
|
-
return result;
|
|
189
|
-
},
|
|
190
|
-
reindex_zero_downtime: async (args, ctx) => {
|
|
191
|
-
const { path: indexPath, patterns, excludePatterns } = args;
|
|
192
|
-
const projectPath = indexPath || ctx.projectPath;
|
|
193
|
-
const stats = await uploadFiles(ctx, projectPath, {
|
|
194
|
-
patterns,
|
|
195
|
-
excludePatterns,
|
|
196
|
-
force: true,
|
|
197
|
-
});
|
|
198
|
-
let result = `## Reindex: ${projectName}\n\n`;
|
|
199
|
-
result += `- **Total files found:** ${stats.totalFiles}\n`;
|
|
200
|
-
result += `- **Files indexed:** ${stats.indexedFiles}\n`;
|
|
201
|
-
result += `- **Chunks created:** ${stats.totalChunks}\n`;
|
|
202
|
-
result += `- **Errors:** ${stats.errors}\n`;
|
|
203
|
-
result += `- **Duration:** ${stats.duration}ms\n`;
|
|
204
|
-
return result;
|
|
205
|
-
},
|
|
206
|
-
list_aliases: async (_args, ctx) => {
|
|
207
|
-
const response = await ctx.api.get("/api/aliases");
|
|
208
|
-
const aliases = response.data.aliases || response.data;
|
|
209
|
-
if (!aliases || (Array.isArray(aliases) && aliases.length === 0)) {
|
|
210
|
-
return "No aliases configured.";
|
|
211
|
-
}
|
|
212
|
-
let result = `## Collection Aliases\n\n`;
|
|
213
|
-
if (Array.isArray(aliases)) {
|
|
214
|
-
for (const a of aliases) {
|
|
215
|
-
result += `- **${a.alias}** -> ${a.collection}\n`;
|
|
208
|
+
schema: z.object({}),
|
|
209
|
+
annotations: TOOL_ANNOTATIONS["list_aliases"],
|
|
210
|
+
handler: async (_args, ctx) => {
|
|
211
|
+
const response = await ctx.api.get("/api/aliases");
|
|
212
|
+
const aliases = response.data.aliases || response.data;
|
|
213
|
+
if (!aliases || (Array.isArray(aliases) && aliases.length === 0)) {
|
|
214
|
+
return "No aliases configured.";
|
|
216
215
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
let result = `## Collection Aliases\n\n`;
|
|
217
|
+
if (Array.isArray(aliases)) {
|
|
218
|
+
for (const a of aliases) {
|
|
219
|
+
result += `- **${a.alias}** -> ${a.collection}\n`;
|
|
220
|
+
}
|
|
221
221
|
}
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
else {
|
|
223
|
+
for (const [alias, collection] of Object.entries(aliases)) {
|
|
224
|
+
result += `- **${alias}** -> ${collection}\n`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
},
|
|
224
229
|
},
|
|
225
|
-
|
|
226
|
-
return { tools, handlers };
|
|
230
|
+
];
|
|
227
231
|
}
|
package/dist/tools/memory.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* batch_remember, validate_memory, review_memories,
|
|
6
6
|
* promote_memory, run_quality_gates, memory_maintenance
|
|
7
7
|
*/
|
|
8
|
-
import type {
|
|
9
|
-
export declare function createMemoryTools(projectName: string):
|
|
8
|
+
import type { ToolSpec } from "../types.js";
|
|
9
|
+
export declare function createMemoryTools(projectName: string): ToolSpec[];
|