flowseeker 0.1.7

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 (82) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/COMPATIBILITY.md +281 -0
  3. package/LICENSE +21 -0
  4. package/README.md +375 -0
  5. package/dist/adapters/frameworkEdges.js +586 -0
  6. package/dist/agent/approvalPolicy.js +81 -0
  7. package/dist/agent/commandRunner.js +166 -0
  8. package/dist/agent/flowCommandRunner.js +124 -0
  9. package/dist/agent/mcpToolRunner.js +167 -0
  10. package/dist/auth/githubAuth.js +71 -0
  11. package/dist/auth/modelList.js +127 -0
  12. package/dist/auth/oauthHandler.js +377 -0
  13. package/dist/chat/nativeChatParticipant.js +616 -0
  14. package/dist/cli/mcpServer.js +383 -0
  15. package/dist/cli/runEvaluation.js +789 -0
  16. package/dist/cli/runReplay.js +481 -0
  17. package/dist/commands/checkHostCompatibility.js +149 -0
  18. package/dist/commands/copyAgentPrompt.js +52 -0
  19. package/dist/commands/copyContext.js +54 -0
  20. package/dist/commands/explainSelectionRelevance.js +57 -0
  21. package/dist/commands/findRelevantContext.js +127 -0
  22. package/dist/commands/openEvidence.js +49 -0
  23. package/dist/commands/openMcpConfig.js +81 -0
  24. package/dist/commands/openRelatedTests.js +54 -0
  25. package/dist/commands/rebuildIndex.js +45 -0
  26. package/dist/commands/runEvaluationSuite.js +323 -0
  27. package/dist/commands/runReplaySuite.js +228 -0
  28. package/dist/config/defaultConfig.js +72 -0
  29. package/dist/config/loadConfig.js +84 -0
  30. package/dist/config/loadConfigFromPath.js +60 -0
  31. package/dist/extension.js +513 -0
  32. package/dist/gateway/agentPrompts.js +176 -0
  33. package/dist/gateway/aiGateway.js +1255 -0
  34. package/dist/gateway/aiProviders.js +901 -0
  35. package/dist/gateway/contextExpansion.js +331 -0
  36. package/dist/gateway/editProposalStore.js +238 -0
  37. package/dist/gateway/planProposalStore.js +28 -0
  38. package/dist/index/cacheStore.js +51 -0
  39. package/dist/index/chunker.js +45 -0
  40. package/dist/index/dependencyExtractor.js +107 -0
  41. package/dist/index/fileDiscovery.js +177 -0
  42. package/dist/index/structuredExtractor.js +256 -0
  43. package/dist/index/workspaceIndex.js +518 -0
  44. package/dist/mcp/mcpConfig.js +154 -0
  45. package/dist/mcp/mcpProvider.js +109 -0
  46. package/dist/mcp/mcpTools.js +215 -0
  47. package/dist/pipeline/agentPrompt.js +79 -0
  48. package/dist/pipeline/agentPromptHeadless.js +85 -0
  49. package/dist/pipeline/contextBlueprint.js +346 -0
  50. package/dist/pipeline/contextPack.js +80 -0
  51. package/dist/pipeline/diffPreview.js +79 -0
  52. package/dist/pipeline/evaluationMetrics.js +154 -0
  53. package/dist/pipeline/evidenceGraph.js +389 -0
  54. package/dist/pipeline/feedback.js +215 -0
  55. package/dist/pipeline/fileGroups.js +84 -0
  56. package/dist/pipeline/fileScanner.js +866 -0
  57. package/dist/pipeline/nodeScan.js +219 -0
  58. package/dist/pipeline/ranker.js +563 -0
  59. package/dist/pipeline/responseLanguage.js +39 -0
  60. package/dist/pipeline/retrievalPlan.js +163 -0
  61. package/dist/pipeline/runHeadless.js +54 -0
  62. package/dist/pipeline/runPipeline.js +114 -0
  63. package/dist/pipeline/solvePacket.js +382 -0
  64. package/dist/pipeline/subsystem.js +257 -0
  65. package/dist/pipeline/taskUnderstanding.js +453 -0
  66. package/dist/pipeline/tokenSavings.js +146 -0
  67. package/dist/pipeline/universalScan.js +216 -0
  68. package/dist/pipeline/verifyAfterApply.js +233 -0
  69. package/dist/runtime/capabilities.js +71 -0
  70. package/dist/runtime/hostDetect.js +98 -0
  71. package/dist/runtime/hostTier.js +68 -0
  72. package/dist/runtime/statusBar.js +80 -0
  73. package/dist/skills/skillRegistry.js +208 -0
  74. package/dist/types.js +3 -0
  75. package/dist/ui/chatViewProvider.js +3899 -0
  76. package/dist/ui/resultTreeProvider.js +174 -0
  77. package/dist/usage/quotaTracker.js +358 -0
  78. package/dist/utils/async.js +30 -0
  79. package/dist/utils/logger.js +64 -0
  80. package/dist/utils/text.js +364 -0
  81. package/dist/utils/updateChecker.js +140 -0
  82. package/package.json +561 -0
@@ -0,0 +1,383 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * FlowSeeker Standalone MCP Server (stdio transport).
5
+ *
6
+ * Run with:
7
+ * node dist/cli/mcpServer.js [--workspace /path/to/repo]
8
+ *
9
+ * Or via npx (after publishing): package name is `flowseeker`, bin is `flowseeker-mcp`:
10
+ * npx -p flowseeker flowseeker-mcp --workspace /path/to/repo
11
+ *
12
+ * This server implements the Model Context Protocol (MCP) over stdio,
13
+ * exposing FlowSeeker's retrieval pipeline as tools that any MCP-compliant
14
+ * client can invoke (Cursor, Antigravity, Windsurf, Claude Desktop, etc.).
15
+ *
16
+ * Protocol: JSON-RPC 2.0 over stdin/stdout, one JSON object per line.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || (function () {
35
+ var ownKeys = function(o) {
36
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37
+ var ar = [];
38
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
39
+ return ar;
40
+ };
41
+ return ownKeys(o);
42
+ };
43
+ return function (mod) {
44
+ if (mod && mod.__esModule) return mod;
45
+ var result = {};
46
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47
+ __setModuleDefault(result, mod);
48
+ return result;
49
+ };
50
+ })();
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ const readline = __importStar(require("readline"));
53
+ const mcpTools_1 = require("../mcp/mcpTools");
54
+ const updateChecker_1 = require("../utils/updateChecker");
55
+ const SERVER_NAME = "flowseeker-mcp";
56
+ const SERVER_VERSION = "0.1.7";
57
+ const PROTOCOL_VERSION = "2024-11-05";
58
+ function parseCliArgs(argv) {
59
+ let workspace = process.cwd();
60
+ let mode = "server";
61
+ for (let i = 0; i < argv.length; i++) {
62
+ if ((argv[i] === "--workspace" || argv[i] === "-w") && argv[i + 1]) {
63
+ workspace = argv[i + 1];
64
+ i++;
65
+ continue;
66
+ }
67
+ if (argv[i] === "--version" || argv[i] === "-v") {
68
+ mode = "version";
69
+ continue;
70
+ }
71
+ if (argv[i] === "--check-updates") {
72
+ mode = "check-updates";
73
+ continue;
74
+ }
75
+ if (argv[i] === "--help" || argv[i] === "-h") {
76
+ printHelp();
77
+ process.exit(0);
78
+ }
79
+ }
80
+ return { workspace, mode };
81
+ }
82
+ function printHelp() {
83
+ const help = [
84
+ "FlowSeeker MCP Server — expose codebase retrieval as MCP tools.",
85
+ "",
86
+ "Usage (installed via npm):",
87
+ " npx -p flowseeker flowseeker-mcp [options]",
88
+ "",
89
+ "Usage (local dev build):",
90
+ " node dist/cli/mcpServer.js [options]",
91
+ "",
92
+ "Options:",
93
+ " --workspace, -w <path> Workspace root path (default: cwd)",
94
+ " --version, -v Print version and exit",
95
+ " --check-updates Check npm for a newer FlowSeeker version and exit",
96
+ " --help, -h Show this help",
97
+ "",
98
+ "This server communicates via JSON-RPC 2.0 over stdin/stdout.",
99
+ "Configure it as an MCP server in your IDE or AI client.",
100
+ "",
101
+ "Cursor/Antigravity/Windsurf/Claude Desktop config (npx):",
102
+ ' {',
103
+ ' "mcpServers": {',
104
+ ' "flowseeker": {',
105
+ ' "command": "npx",',
106
+ ' "args": ["-p", "flowseeker", "flowseeker-mcp", "--workspace", "."]',
107
+ ' }',
108
+ ' }',
109
+ ' }',
110
+ "",
111
+ "VS Code / Copilot .vscode/mcp.json config:",
112
+ ' {',
113
+ ' "servers": {',
114
+ ' "flowseeker": {',
115
+ ' "command": "npx",',
116
+ ' "args": ["-p", "flowseeker", "flowseeker-mcp", "--workspace", "."]',
117
+ ' }',
118
+ ' }',
119
+ ' }',
120
+ "",
121
+ "Native Chat autocomplete is controlled by the IDE host; FlowSeeker exposes tools and prompts via MCP.",
122
+ "",
123
+ "Dev / local build alternative:",
124
+ ' {',
125
+ ' "mcpServers": {',
126
+ ' "flowseeker": {',
127
+ ' "command": "node",',
128
+ ' "args": ["path/to/dist/cli/mcpServer.js", "--workspace", "."]',
129
+ ' }',
130
+ ' }',
131
+ ' }',
132
+ "",
133
+ "For per-IDE setup instructions visit:",
134
+ " https://www.npmjs.com/package/flowseeker",
135
+ ""
136
+ ];
137
+ console.error(help.join("\n"));
138
+ }
139
+ // ── MCP Protocol Handlers ─────────────────────────────────────────────
140
+ function handleInitialize(_params) {
141
+ return {
142
+ protocolVersion: PROTOCOL_VERSION,
143
+ capabilities: {
144
+ tools: { listChanged: true },
145
+ prompts: { listChanged: true }
146
+ },
147
+ serverInfo: {
148
+ name: SERVER_NAME,
149
+ version: SERVER_VERSION
150
+ }
151
+ };
152
+ }
153
+ function handleToolsList() {
154
+ return {
155
+ tools: mcpTools_1.TOOL_DEFINITIONS.map((tool) => ({
156
+ name: tool.name,
157
+ description: tool.description,
158
+ inputSchema: tool.inputSchema
159
+ }))
160
+ };
161
+ }
162
+ function handlePromptsList() {
163
+ return {
164
+ prompts: mcpTools_1.MCP_PROMPT_DEFINITIONS.map((prompt) => ({
165
+ name: prompt.name,
166
+ description: prompt.description,
167
+ arguments: prompt.arguments
168
+ }))
169
+ };
170
+ }
171
+ function handlePromptsGet(params) {
172
+ const name = params.name;
173
+ const prompt = mcpTools_1.MCP_PROMPT_DEFINITIONS.find((candidate) => candidate.name === name);
174
+ if (!prompt) {
175
+ throw new Error(`Unknown prompt: ${name}`);
176
+ }
177
+ const args = (params.arguments ?? {});
178
+ const task = typeof args.task === "string" && args.task.trim() ? args.task.trim() : "<describe your task>";
179
+ const workspace = typeof args.workspace === "string" && args.workspace.trim()
180
+ ? ` Workspace: ${args.workspace.trim()}.`
181
+ : "";
182
+ return {
183
+ description: prompt.description,
184
+ messages: [
185
+ {
186
+ role: "user",
187
+ content: {
188
+ type: "text",
189
+ text: `Use the ${prompt.toolName} MCP tool to ${prompt.toolPurpose}. Task: ${task}.${workspace}`
190
+ }
191
+ }
192
+ ]
193
+ };
194
+ }
195
+ async function handleToolsCall(params, defaultWorkspace) {
196
+ const name = params.name;
197
+ const args = (params.arguments ?? {});
198
+ if (!name) {
199
+ return {
200
+ content: [{ type: "text", text: "Missing tool name." }],
201
+ isError: true
202
+ };
203
+ }
204
+ return (0, mcpTools_1.handleToolCall)(name, args, defaultWorkspace);
205
+ }
206
+ // ── Main Server Loop ──────────────────────────────────────────────────
207
+ let pendingCalls = 0;
208
+ let initialized = false;
209
+ async function processRequest(request, workspace) {
210
+ const { id, method, params } = request;
211
+ // Notifications (no id) — just acknowledge
212
+ if (id === undefined || id === null) {
213
+ if (method === "notifications/initialized") {
214
+ logStderr("Client initialized.");
215
+ initialized = true;
216
+ }
217
+ return null; // Notifications don't get responses
218
+ }
219
+ try {
220
+ let result;
221
+ switch (method) {
222
+ case "initialize":
223
+ result = handleInitialize(params ?? {});
224
+ break;
225
+ case "tools/list":
226
+ result = handleToolsList();
227
+ break;
228
+ case "tools/call":
229
+ pendingCalls++;
230
+ try {
231
+ result = await handleToolsCall(params ?? {}, workspace);
232
+ }
233
+ finally {
234
+ pendingCalls--;
235
+ }
236
+ break;
237
+ case "prompts/list":
238
+ result = handlePromptsList();
239
+ break;
240
+ case "prompts/get":
241
+ result = handlePromptsGet(params ?? {});
242
+ break;
243
+ case "ping":
244
+ result = {};
245
+ break;
246
+ default:
247
+ return {
248
+ jsonrpc: "2.0",
249
+ id,
250
+ error: {
251
+ code: -32601,
252
+ message: `Method not found: ${method}`
253
+ }
254
+ };
255
+ }
256
+ return { jsonrpc: "2.0", id, result };
257
+ }
258
+ catch (error) {
259
+ pendingCalls--;
260
+ const message = error instanceof Error ? error.message : String(error);
261
+ logStderr(`Error handling ${method}: ${message}`);
262
+ return {
263
+ jsonrpc: "2.0",
264
+ id,
265
+ error: {
266
+ code: -32603,
267
+ message: `Internal error: ${message}`
268
+ }
269
+ };
270
+ }
271
+ }
272
+ function logStderr(message) {
273
+ process.stderr.write(`[${SERVER_NAME}] ${message}\n`);
274
+ }
275
+ function sendResponse(response) {
276
+ process.stdout.write(JSON.stringify(response) + "\n");
277
+ }
278
+ async function main() {
279
+ const { workspace, mode } = parseCliArgs(process.argv.slice(2));
280
+ if (mode === "version") {
281
+ process.stdout.write(`${SERVER_VERSION}\n`);
282
+ return;
283
+ }
284
+ if (mode === "check-updates") {
285
+ const result = await (0, updateChecker_1.checkForPackageUpdate)(SERVER_VERSION);
286
+ if (result.error) {
287
+ process.stdout.write(`Unable to check for updates: ${result.error}\n`);
288
+ }
289
+ else if (result.hasUpdate && result.latestVersion) {
290
+ process.stdout.write(`FlowSeeker ${result.latestVersion} is available. Current version: ${result.currentVersion}.\n`);
291
+ }
292
+ else {
293
+ process.stdout.write(`FlowSeeker ${result.currentVersion} is up to date.\n`);
294
+ }
295
+ return;
296
+ }
297
+ logStderr(`FlowSeeker MCP Server v${SERVER_VERSION}`);
298
+ logStderr(`Workspace: ${workspace}`);
299
+ logStderr(`Protocol: ${PROTOCOL_VERSION}`);
300
+ logStderr("Listening for JSON-RPC requests on stdin...");
301
+ const rl = readline.createInterface({
302
+ input: process.stdin,
303
+ terminal: false
304
+ });
305
+ let buffer = "";
306
+ rl.on("line", async (line) => {
307
+ buffer += line;
308
+ // Try to parse complete JSON objects
309
+ try {
310
+ const request = JSON.parse(buffer);
311
+ buffer = "";
312
+ if (request.jsonrpc !== "2.0") {
313
+ logStderr(`Invalid JSON-RPC version: ${request.jsonrpc}`);
314
+ if (request.id !== undefined && request.id !== null) {
315
+ sendResponse({
316
+ jsonrpc: "2.0",
317
+ id: request.id,
318
+ error: { code: -32600, message: "Invalid Request: expected jsonrpc 2.0" }
319
+ });
320
+ }
321
+ return;
322
+ }
323
+ logStderr(`← ${request.method}${request.id !== undefined ? ` (id: ${request.id})` : ""}`);
324
+ const response = await processRequest(request, workspace);
325
+ if (response) {
326
+ logStderr(`→ ${request.method} response sent`);
327
+ sendResponse(response);
328
+ // After initialize, send the required initialized notification
329
+ if (request.method === "initialize") {
330
+ process.stdout.write(JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" }) + "\n");
331
+ logStderr("→ notifications/initialized sent");
332
+ }
333
+ }
334
+ }
335
+ catch (parseError) {
336
+ // If it's a JSON parse error, the buffer might need more data
337
+ // But since we read line by line and MCP sends one object per line,
338
+ // a parse error here means invalid input
339
+ if (buffer.trim()) {
340
+ logStderr(`Parse error, resetting buffer. Input: ${buffer.slice(0, 200)}`);
341
+ buffer = "";
342
+ }
343
+ }
344
+ });
345
+ rl.on("close", () => {
346
+ logStderr("stdin closed. Waiting for in-flight calls to complete...");
347
+ const shutdown = () => {
348
+ logStderr("Shutting down.");
349
+ process.exit(0);
350
+ };
351
+ if (pendingCalls === 0) {
352
+ shutdown();
353
+ return;
354
+ }
355
+ // Wait up to 30s for pending calls, then force-exit
356
+ const timer = setTimeout(() => {
357
+ logStderr(`Force shutdown after timeout (${pendingCalls} call(s) still pending).`);
358
+ process.exit(0);
359
+ }, 30000);
360
+ const poll = setInterval(() => {
361
+ if (pendingCalls === 0) {
362
+ clearInterval(poll);
363
+ clearTimeout(timer);
364
+ shutdown();
365
+ }
366
+ }, 200);
367
+ });
368
+ // Handle graceful shutdown
369
+ process.on("SIGINT", () => {
370
+ logStderr("SIGINT received. Shutting down.");
371
+ process.exit(0);
372
+ });
373
+ process.on("SIGTERM", () => {
374
+ logStderr("SIGTERM received. Shutting down.");
375
+ process.exit(0);
376
+ });
377
+ }
378
+ void main().catch((error) => {
379
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
380
+ process.stderr.write(`[${SERVER_NAME}] Fatal: ${message}\n`);
381
+ process.exit(1);
382
+ });
383
+ //# sourceMappingURL=mcpServer.js.map