@crowley/rag-mcp 1.0.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.
Files changed (49) hide show
  1. package/dist/api-client.d.ts +4 -0
  2. package/dist/api-client.js +19 -0
  3. package/dist/context-enrichment.d.ts +44 -0
  4. package/dist/context-enrichment.js +190 -0
  5. package/dist/formatters.d.ts +33 -0
  6. package/dist/formatters.js +70 -0
  7. package/dist/index.d.ts +13 -0
  8. package/dist/index.js +109 -0
  9. package/dist/tool-registry.d.ts +20 -0
  10. package/dist/tool-registry.js +123 -0
  11. package/dist/tools/advanced.d.ts +9 -0
  12. package/dist/tools/advanced.js +315 -0
  13. package/dist/tools/agents.d.ts +8 -0
  14. package/dist/tools/agents.js +97 -0
  15. package/dist/tools/analytics.d.ts +9 -0
  16. package/dist/tools/analytics.js +261 -0
  17. package/dist/tools/architecture.d.ts +5 -0
  18. package/dist/tools/architecture.js +720 -0
  19. package/dist/tools/ask.d.ts +9 -0
  20. package/dist/tools/ask.js +256 -0
  21. package/dist/tools/cache.d.ts +5 -0
  22. package/dist/tools/cache.js +98 -0
  23. package/dist/tools/clustering.d.ts +9 -0
  24. package/dist/tools/clustering.js +251 -0
  25. package/dist/tools/confluence.d.ts +9 -0
  26. package/dist/tools/confluence.js +147 -0
  27. package/dist/tools/database.d.ts +5 -0
  28. package/dist/tools/database.js +429 -0
  29. package/dist/tools/feedback.d.ts +9 -0
  30. package/dist/tools/feedback.js +220 -0
  31. package/dist/tools/guidelines.d.ts +5 -0
  32. package/dist/tools/guidelines.js +146 -0
  33. package/dist/tools/indexing.d.ts +9 -0
  34. package/dist/tools/indexing.js +129 -0
  35. package/dist/tools/memory.d.ts +9 -0
  36. package/dist/tools/memory.js +565 -0
  37. package/dist/tools/pm.d.ts +9 -0
  38. package/dist/tools/pm.js +680 -0
  39. package/dist/tools/review.d.ts +8 -0
  40. package/dist/tools/review.js +213 -0
  41. package/dist/tools/search.d.ts +9 -0
  42. package/dist/tools/search.js +377 -0
  43. package/dist/tools/session.d.ts +10 -0
  44. package/dist/tools/session.js +386 -0
  45. package/dist/tools/suggestions.d.ts +9 -0
  46. package/dist/tools/suggestions.js +301 -0
  47. package/dist/types.d.ts +32 -0
  48. package/dist/types.js +4 -0
  49. package/package.json +40 -0
@@ -0,0 +1,386 @@
1
+ /**
2
+ * Session tools module - context summarization, session lifecycle management,
3
+ * change tracking, and usage pattern analysis.
4
+ */
5
+ import { truncate } from "../formatters.js";
6
+ /**
7
+ * Create the session tools module with project-specific descriptions.
8
+ * Accepts a mutable ctx reference to update activeSessionId on start/end.
9
+ */
10
+ export function createSessionTools(projectName, sharedCtx) {
11
+ const tools = [
12
+ {
13
+ name: "summarize_context",
14
+ description: `Summarize the current working context for ${projectName}. Shows recently used tools, active features, recent queries, and suggested next steps.`,
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ sessionId: {
19
+ type: "string",
20
+ description: "Session ID to get context for. If omitted, returns the latest context.",
21
+ },
22
+ },
23
+ },
24
+ },
25
+ {
26
+ name: "summarize_changes",
27
+ description: `Summarize changes made during a session for ${projectName}. Shows what was modified, tools used, and key actions taken.`,
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ sessionId: {
32
+ type: "string",
33
+ description: "Session ID to summarize changes for.",
34
+ },
35
+ includeCode: {
36
+ type: "boolean",
37
+ description: "Whether to include code snippets in the summary (default: false).",
38
+ default: false,
39
+ },
40
+ },
41
+ required: ["sessionId"],
42
+ },
43
+ },
44
+ {
45
+ name: "analyze_usage_patterns",
46
+ description: `Analyze tool usage patterns for ${projectName}. Shows common workflows, detected patterns, and recommendations for improving productivity.`,
47
+ inputSchema: {
48
+ type: "object",
49
+ properties: {
50
+ days: {
51
+ type: "number",
52
+ description: "Number of days to analyze (default: 7).",
53
+ default: 7,
54
+ },
55
+ },
56
+ },
57
+ },
58
+ {
59
+ name: "get_developer_profile",
60
+ description: `Get accumulated developer profile for ${projectName}: frequent files, preferred tools, peak hours, common patterns.`,
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {},
64
+ },
65
+ },
66
+ {
67
+ name: "start_session",
68
+ description: `Start a new working session for ${projectName}. Tracks tool usage, file changes, and learnings throughout the session.`,
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {
72
+ sessionId: {
73
+ type: "string",
74
+ description: "Custom session ID. If omitted, one will be generated.",
75
+ },
76
+ initialContext: {
77
+ type: "string",
78
+ description: "Description of what this session is about (e.g., 'fixing auth bug', 'adding new API endpoint').",
79
+ },
80
+ resumeFrom: {
81
+ type: "string",
82
+ description: "Session ID to resume from. Carries over context from the previous session.",
83
+ },
84
+ },
85
+ },
86
+ },
87
+ {
88
+ name: "get_session_context",
89
+ description: `Get the current context for an active session in ${projectName}. Shows files being worked on, tools used, and pending learnings.`,
90
+ inputSchema: {
91
+ type: "object",
92
+ properties: {
93
+ sessionId: {
94
+ type: "string",
95
+ description: "Session ID to get context for.",
96
+ },
97
+ },
98
+ required: ["sessionId"],
99
+ },
100
+ },
101
+ {
102
+ name: "end_session",
103
+ description: `End a working session for ${projectName}. Saves a summary and optionally extracts learnings for future sessions.`,
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {
107
+ sessionId: {
108
+ type: "string",
109
+ description: "Session ID to end.",
110
+ },
111
+ summary: {
112
+ type: "string",
113
+ description: "Summary of what was accomplished during the session.",
114
+ },
115
+ autoSaveLearnings: {
116
+ type: "boolean",
117
+ description: "Automatically save detected learnings to memory (default: true).",
118
+ default: true,
119
+ },
120
+ feedback: {
121
+ type: "string",
122
+ description: "Optional feedback about the session (e.g., 'productive', 'too many context switches').",
123
+ },
124
+ },
125
+ required: ["sessionId"],
126
+ },
127
+ },
128
+ ];
129
+ const handlers = {
130
+ summarize_context: async (args, ctx) => {
131
+ const { sessionId } = args;
132
+ const params = sessionId ? `?sessionId=${sessionId}` : "";
133
+ const response = await ctx.api.get(`/api/context/${ctx.projectName}${params}`);
134
+ const data = response.data;
135
+ let result = `**Context Summary for ${ctx.projectName}**\n\n`;
136
+ if (data.recentTools && data.recentTools.length > 0) {
137
+ result += `**Recently Used Tools:**\n`;
138
+ result += data.recentTools
139
+ .map((t) => `- ${t}`)
140
+ .join("\n");
141
+ result += "\n\n";
142
+ }
143
+ if (data.activeFeatures && data.activeFeatures.length > 0) {
144
+ result += `**Active Features:**\n`;
145
+ result += data.activeFeatures
146
+ .map((f) => `- ${f}`)
147
+ .join("\n");
148
+ result += "\n\n";
149
+ }
150
+ if (data.recentQueries && data.recentQueries.length > 0) {
151
+ const queries = data.recentQueries.slice(0, 5);
152
+ result += `**Recent Queries:**\n`;
153
+ result += queries
154
+ .map((q) => `- ${truncate(q, 80)}`)
155
+ .join("\n");
156
+ result += "\n\n";
157
+ }
158
+ if (data.suggestedNextSteps && data.suggestedNextSteps.length > 0) {
159
+ result += `**Suggested Next Steps:**\n`;
160
+ result += data.suggestedNextSteps
161
+ .map((s, i) => `${i + 1}. ${s}`)
162
+ .join("\n");
163
+ result += "\n";
164
+ }
165
+ return result;
166
+ },
167
+ summarize_changes: async (args, ctx) => {
168
+ const { sessionId, includeCode } = args;
169
+ const params = includeCode ? "?includeCode=true" : "";
170
+ const response = await ctx.api.get(`/api/changes/${ctx.projectName}/${sessionId}${params}`);
171
+ const data = response.data;
172
+ let result = `**Changes Summary for Session ${sessionId}**\n\n`;
173
+ if (data.summary) {
174
+ result += `${data.summary}\n\n`;
175
+ }
176
+ if (data.duration !== undefined) {
177
+ result += `**Duration:** ${data.duration} minutes\n`;
178
+ }
179
+ if (data.toolsUsed && data.toolsUsed.length > 0) {
180
+ result += `**Tools Used:** ${data.toolsUsed.join(", ")}\n`;
181
+ }
182
+ if (data.filesAffected && data.filesAffected.length > 0) {
183
+ const files = data.filesAffected.slice(0, 10);
184
+ result += `\n**Files Affected:**\n`;
185
+ result += files.map((f) => `- ${f}`).join("\n");
186
+ if (data.filesAffected.length > 10) {
187
+ result += `\n- ... and ${data.filesAffected.length - 10} more`;
188
+ }
189
+ result += "\n";
190
+ }
191
+ if (data.keyActions && data.keyActions.length > 0) {
192
+ result += `\n**Key Actions:**\n`;
193
+ result += data.keyActions
194
+ .map((a, i) => `${i + 1}. ${a}`)
195
+ .join("\n");
196
+ result += "\n";
197
+ }
198
+ return result;
199
+ },
200
+ get_developer_profile: async (_args, ctx) => {
201
+ const response = await ctx.api.get(`/api/developer-profile`, { headers: { "X-Project-Name": ctx.projectName } });
202
+ const p = response.data;
203
+ if (!p.totalToolCalls) {
204
+ return "No usage data yet. Use tools to build your developer profile.";
205
+ }
206
+ let result = `**Developer Profile** (${p.totalSessions} sessions, ${p.totalToolCalls} tool calls)\n\n`;
207
+ if (p.frequentFiles.length > 0) {
208
+ result += "**Frequent Files:**\n";
209
+ result += p.frequentFiles.slice(0, 10).map((f) => `- ${f.file} (${f.count}x)`).join("\n");
210
+ result += "\n\n";
211
+ }
212
+ if (p.preferredTools.length > 0) {
213
+ result += "**Preferred Tools:**\n";
214
+ result += p.preferredTools.slice(0, 8).map((t) => `- ${t.tool}: ${t.count}x (avg ${Math.round(t.avgDurationMs)}ms)`).join("\n");
215
+ result += "\n\n";
216
+ }
217
+ if (p.peakHours.length > 0) {
218
+ result += "**Peak Hours:** ";
219
+ result += p.peakHours.map((h) => `${h.hour}:00 (${h.count})`).join(", ");
220
+ result += "\n\n";
221
+ }
222
+ if (p.commonPatterns.length > 0) {
223
+ result += "**Common Patterns:**\n";
224
+ result += p.commonPatterns.slice(0, 5).map((q) => `- "${truncate(q, 60)}"`).join("\n");
225
+ result += "\n";
226
+ }
227
+ return result;
228
+ },
229
+ analyze_usage_patterns: async (args, ctx) => {
230
+ const { days = 7 } = args;
231
+ const response = await ctx.api.get(`/api/patterns/${ctx.projectName}?days=${days}`);
232
+ const data = response.data;
233
+ let result = `**Usage Patterns for ${ctx.projectName}** (last ${days} days)\n\n`;
234
+ if (data.insights && data.insights.length > 0) {
235
+ result += `**Insights:**\n`;
236
+ result += data.insights
237
+ .map((insight) => `- ${insight}`)
238
+ .join("\n");
239
+ result += "\n\n";
240
+ }
241
+ if (data.commonWorkflows && data.commonWorkflows.length > 0) {
242
+ result += `**Common Workflows:**\n`;
243
+ result += data.commonWorkflows
244
+ .map((w) => `- ${w.tools.join(" -> ")} (${w.count}x, ${(w.successRate * 100).toFixed(0)}% success)`)
245
+ .join("\n");
246
+ result += "\n\n";
247
+ }
248
+ if (data.detectedPatterns && data.detectedPatterns.length > 0) {
249
+ result += `**Detected Patterns:**\n`;
250
+ result += data.detectedPatterns
251
+ .map((p) => `- **${p.name}:** ${p.description}\n *Suggestion:* ${p.suggestion}`)
252
+ .join("\n");
253
+ result += "\n\n";
254
+ }
255
+ if (data.recommendations && data.recommendations.length > 0) {
256
+ result += `**Recommendations:**\n`;
257
+ result += data.recommendations
258
+ .map((r, i) => `${i + 1}. ${r}`)
259
+ .join("\n");
260
+ result += "\n";
261
+ }
262
+ return result;
263
+ },
264
+ start_session: async (args, ctx) => {
265
+ const { sessionId, initialContext, resumeFrom } = args;
266
+ const response = await ctx.api.post("/api/session/start", {
267
+ projectName: ctx.projectName,
268
+ sessionId,
269
+ initialContext,
270
+ resumeFrom,
271
+ });
272
+ const data = response.data;
273
+ // Update shared context with active session ID
274
+ if (sharedCtx && data.sessionId) {
275
+ sharedCtx.activeSessionId = data.sessionId;
276
+ }
277
+ let result = `**Session Started**\n\n`;
278
+ result += `- **Session ID:** ${data.sessionId}\n`;
279
+ result += `- **Started:** ${data.started}\n`;
280
+ if (data.resumedFrom) {
281
+ result += `- **Resumed From:** ${data.resumedFrom}\n`;
282
+ }
283
+ if (data.initialFiles && data.initialFiles.length > 0) {
284
+ result += `\n**Initial Files:**\n`;
285
+ result += data.initialFiles
286
+ .map((f) => `- ${f}`)
287
+ .join("\n");
288
+ result += "\n";
289
+ }
290
+ // Include prefetch stats if available
291
+ if (data.session?.metadata?.prefetchStats) {
292
+ const pf = data.session.metadata.prefetchStats;
293
+ result += `\n**Predictive Prefetch:** ${pf.prefetchedCount ?? 0} resources prefetched\n`;
294
+ }
295
+ // Include briefing if available (Sprint E)
296
+ if (data.briefing) {
297
+ result += `\n**Session Briefing:**\n${data.briefing}\n`;
298
+ }
299
+ return result;
300
+ },
301
+ get_session_context: async (args, ctx) => {
302
+ const { sessionId } = args;
303
+ const response = await ctx.api.get(`/api/session/${sessionId}`);
304
+ const data = response.data;
305
+ let result = `**Session Context**\n\n`;
306
+ result += `- **Session ID:** ${data.sessionId}\n`;
307
+ result += `- **Status:** ${data.status}\n`;
308
+ result += `- **Started At:** ${data.startedAt}\n`;
309
+ result += `- **Last Activity:** ${data.lastActivity}\n`;
310
+ if (data.currentFiles && data.currentFiles.length > 0) {
311
+ const files = data.currentFiles.slice(0, 10);
312
+ result += `\n**Current Files:**\n`;
313
+ result += files.map((f) => `- ${f}`).join("\n");
314
+ if (data.currentFiles.length > 10) {
315
+ result += `\n- ... and ${data.currentFiles.length - 10} more`;
316
+ }
317
+ result += "\n";
318
+ }
319
+ if (data.toolsUsed && data.toolsUsed.length > 0) {
320
+ result += `\n**Tools Used:** ${data.toolsUsed.join(", ")}\n`;
321
+ }
322
+ if (data.activeFeatures && data.activeFeatures.length > 0) {
323
+ result += `\n**Active Features:**\n`;
324
+ result += data.activeFeatures
325
+ .map((f) => `- ${f}`)
326
+ .join("\n");
327
+ result += "\n";
328
+ }
329
+ if (data.pendingLearnings && data.pendingLearnings.length > 0) {
330
+ const learnings = data.pendingLearnings.slice(0, 5);
331
+ result += `\n**Pending Learnings:**\n`;
332
+ result += learnings
333
+ .map((l) => `- ${truncate(l, 80)}`)
334
+ .join("\n");
335
+ if (data.pendingLearnings.length > 5) {
336
+ result += `\n- ... and ${data.pendingLearnings.length - 5} more`;
337
+ }
338
+ result += "\n";
339
+ }
340
+ return result;
341
+ },
342
+ end_session: async (args, ctx) => {
343
+ const { sessionId, summary, autoSaveLearnings, feedback } = args;
344
+ const response = await ctx.api.post(`/api/session/${sessionId}/end`, {
345
+ summary,
346
+ autoSaveLearnings: autoSaveLearnings !== undefined ? autoSaveLearnings : true,
347
+ feedback,
348
+ });
349
+ const data = response.data;
350
+ // Clear active session ID
351
+ if (sharedCtx) {
352
+ sharedCtx.activeSessionId = undefined;
353
+ }
354
+ let result = `**Session Ended**\n\n`;
355
+ if (data.summary) {
356
+ result += `**Summary:** ${data.summary}\n\n`;
357
+ }
358
+ if (data.duration !== undefined) {
359
+ result += `- **Duration:** ${data.duration} minutes\n`;
360
+ }
361
+ if (data.toolsUsedCount !== undefined) {
362
+ result += `- **Tools Used:** ${data.toolsUsedCount}\n`;
363
+ }
364
+ if (data.filesAffectedCount !== undefined) {
365
+ result += `- **Files Affected:** ${data.filesAffectedCount}\n`;
366
+ }
367
+ if (data.queriesCount !== undefined) {
368
+ result += `- **Queries:** ${data.queriesCount}\n`;
369
+ }
370
+ if (data.learningsSaved !== undefined) {
371
+ result += `- **Learnings Saved:** ${data.learningsSaved}\n`;
372
+ }
373
+ if (data.filesAffected && data.filesAffected.length > 0) {
374
+ const files = data.filesAffected.slice(0, 10);
375
+ result += `\n**Files Affected:**\n`;
376
+ result += files.map((f) => `- ${f}`).join("\n");
377
+ if (data.filesAffected.length > 10) {
378
+ result += `\n- ... and ${data.filesAffected.length - 10} more`;
379
+ }
380
+ result += "\n";
381
+ }
382
+ return result;
383
+ },
384
+ };
385
+ return { tools, handlers };
386
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Suggestions tools module - contextual suggestions, related code,
3
+ * implementation suggestions, test suggestions, and code context.
4
+ */
5
+ import type { ToolModule } from "../types.js";
6
+ /**
7
+ * Create the suggestions tools module with project-specific descriptions.
8
+ */
9
+ export declare function createSuggestionTools(projectName: string): ToolModule;