@millstone/synapse-context-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/README.md +217 -0
- package/dist/bundled/code-structure.js +12427 -0
- package/dist/bundled/file-search.js +40278 -0
- package/dist/bundled/semantic-search.js +40245 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-bash.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-c.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-c_sharp.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-cpp.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-css.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-dart.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-elisp.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-elixir.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-elm.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-embedded_template.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-go.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-html.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-java.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-javascript.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-json.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-kotlin.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-lua.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-objc.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-ocaml.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-php.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-python.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-ql.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-rescript.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-ruby.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-rust.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-scala.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-solidity.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-swift.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-systemrdl.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-tlaplus.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-toml.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-tsx.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-typescript.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-vue.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-yaml.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter-zig.wasm +0 -0
- package/dist/bundled/tree-sitter-wasms/tree-sitter.wasm +0 -0
- package/dist/bundled/tree-sitter.wasm +0 -0
- package/dist/continue/ContinueIDE.d.ts +70 -0
- package/dist/continue/ContinueIDE.d.ts.map +1 -0
- package/dist/continue/ContinueIDE.js +251 -0
- package/dist/continue/ContinueIDE.js.map +1 -0
- package/dist/embeddings/embeddings-provider.d.ts +53 -0
- package/dist/embeddings/embeddings-provider.d.ts.map +1 -0
- package/dist/embeddings/embeddings-provider.js +138 -0
- package/dist/embeddings/embeddings-provider.js.map +1 -0
- package/dist/embeddings/index.d.ts +10 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +10 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/vector-index.d.ts +43 -0
- package/dist/embeddings/vector-index.d.ts.map +1 -0
- package/dist/embeddings/vector-index.js +174 -0
- package/dist/embeddings/vector-index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/selection/SelectionManager.d.ts +90 -0
- package/dist/selection/SelectionManager.d.ts.map +1 -0
- package/dist/selection/SelectionManager.js +167 -0
- package/dist/selection/SelectionManager.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +480 -0
- package/dist/server.js.map +1 -0
- package/dist/shims/continue-worker-paths.d.ts +47 -0
- package/dist/shims/continue-worker-paths.d.ts.map +1 -0
- package/dist/shims/continue-worker-paths.js +94 -0
- package/dist/shims/continue-worker-paths.js.map +1 -0
- package/dist/shims/workerpool-shim.d.ts +43 -0
- package/dist/shims/workerpool-shim.d.ts.map +1 -0
- package/dist/shims/workerpool-shim.js +37 -0
- package/dist/shims/workerpool-shim.js.map +1 -0
- package/dist/tools/code-structure.d.ts +36 -0
- package/dist/tools/code-structure.d.ts.map +1 -0
- package/dist/tools/code-structure.js +131 -0
- package/dist/tools/code-structure.js.map +1 -0
- package/dist/tools/file-search.d.ts +35 -0
- package/dist/tools/file-search.d.ts.map +1 -0
- package/dist/tools/file-search.js +286 -0
- package/dist/tools/file-search.js.map +1 -0
- package/dist/tools/file-tree.d.ts +18 -0
- package/dist/tools/file-tree.d.ts.map +1 -0
- package/dist/tools/file-tree.js +45 -0
- package/dist/tools/file-tree.js.map +1 -0
- package/dist/tools/manage-selection.d.ts +28 -0
- package/dist/tools/manage-selection.d.ts.map +1 -0
- package/dist/tools/manage-selection.js +98 -0
- package/dist/tools/manage-selection.js.map +1 -0
- package/dist/tools/read-file.d.ts +19 -0
- package/dist/tools/read-file.d.ts.map +1 -0
- package/dist/tools/read-file.js +35 -0
- package/dist/tools/read-file.js.map +1 -0
- package/dist/tools/semantic-search.d.ts +50 -0
- package/dist/tools/semantic-search.d.ts.map +1 -0
- package/dist/tools/semantic-search.js +243 -0
- package/dist/tools/semantic-search.js.map +1 -0
- package/dist/tools/workspace-context.d.ts +20 -0
- package/dist/tools/workspace-context.d.ts.map +1 -0
- package/dist/tools/workspace-context.js +36 -0
- package/dist/tools/workspace-context.js.map +1 -0
- package/dist/tree-sitter/code-snippet-queries/bash.scm +7 -0
- package/dist/tree-sitter/code-snippet-queries/c.scm +34 -0
- package/dist/tree-sitter/code-snippet-queries/c_sharp.scm +42 -0
- package/dist/tree-sitter/code-snippet-queries/cpp.scm +34 -0
- package/dist/tree-sitter/code-snippet-queries/dart.scm +33 -0
- package/dist/tree-sitter/code-snippet-queries/elisp.scm +21 -0
- package/dist/tree-sitter/code-snippet-queries/elixir.scm +32 -0
- package/dist/tree-sitter/code-snippet-queries/elm.scm +17 -0
- package/dist/tree-sitter/code-snippet-queries/go.scm +28 -0
- package/dist/tree-sitter/code-snippet-queries/java.scm +34 -0
- package/dist/tree-sitter/code-snippet-queries/javascript.scm +22 -0
- package/dist/tree-sitter/code-snippet-queries/kotlin.scm +32 -0
- package/dist/tree-sitter/code-snippet-queries/lua.scm +34 -0
- package/dist/tree-sitter/code-snippet-queries/ocaml.scm +27 -0
- package/dist/tree-sitter/code-snippet-queries/php.scm +43 -0
- package/dist/tree-sitter/code-snippet-queries/python.scm +17 -0
- package/dist/tree-sitter/code-snippet-queries/rescript.scm +23 -0
- package/dist/tree-sitter/code-snippet-queries/ruby.scm +33 -0
- package/dist/tree-sitter/code-snippet-queries/rust.scm +42 -0
- package/dist/tree-sitter/code-snippet-queries/scala.scm +32 -0
- package/dist/tree-sitter/code-snippet-queries/solidity.scm +33 -0
- package/dist/tree-sitter/code-snippet-queries/swift.scm +40 -0
- package/dist/tree-sitter/code-snippet-queries/tsx.scm +54 -0
- package/dist/tree-sitter/code-snippet-queries/typescript.scm +28 -0
- package/dist/tree-sitter/code-snippet-queries/zig.scm +16 -0
- package/dist/utils/file-walker.d.ts +19 -0
- package/dist/utils/file-walker.d.ts.map +1 -0
- package/dist/utils/file-walker.js +82 -0
- package/dist/utils/file-walker.js.map +1 -0
- package/dist/utils/token-counter.d.ts +16 -0
- package/dist/utils/token-counter.d.ts.map +1 -0
- package/dist/utils/token-counter.js +30 -0
- package/dist/utils/token-counter.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workerpool Shim for Continue Integration
|
|
3
|
+
*
|
|
4
|
+
* This shim wraps workerpool to intercept pool() calls and resolve worker paths
|
|
5
|
+
* to their actual locations in node_modules/@continuedev/core.
|
|
6
|
+
*
|
|
7
|
+
* When @continuedev/core is bundled, its __dirname points to the bundle output
|
|
8
|
+
* directory, but worker files remain in node_modules. This shim bridges that gap.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: This file should be used as an alias for 'workerpool' ONLY for
|
|
11
|
+
* imports originating from @continuedev/core. Other imports should use the
|
|
12
|
+
* real workerpool directly.
|
|
13
|
+
*
|
|
14
|
+
* @see docs/BUNDLING_SOLUTION.md for architecture details
|
|
15
|
+
*/
|
|
16
|
+
export type Pool = any;
|
|
17
|
+
export type PoolOptions = any;
|
|
18
|
+
/**
|
|
19
|
+
* Create a worker pool with path resolution for Continue workers.
|
|
20
|
+
*
|
|
21
|
+
* If the worker path doesn't exist (common when bundled), we resolve it
|
|
22
|
+
* to the actual location in node_modules/@continuedev/core.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pool(script?: string, options?: PoolOptions): Pool;
|
|
25
|
+
/**
|
|
26
|
+
* Create a worker that can be managed by the pool.
|
|
27
|
+
* Passed through to real workerpool without modification.
|
|
28
|
+
*/
|
|
29
|
+
export declare function worker(methods?: Record<string, (...args: unknown[]) => unknown>, options?: {
|
|
30
|
+
onTerminate?: () => void;
|
|
31
|
+
}): void;
|
|
32
|
+
export declare const cpus: number;
|
|
33
|
+
export declare const isMainThread: boolean;
|
|
34
|
+
export declare const platform: "node" | "browser";
|
|
35
|
+
declare const _default: {
|
|
36
|
+
pool: typeof pool;
|
|
37
|
+
worker: typeof worker;
|
|
38
|
+
cpus: number;
|
|
39
|
+
isMainThread: boolean;
|
|
40
|
+
platform: "node" | "browser";
|
|
41
|
+
};
|
|
42
|
+
export default _default;
|
|
43
|
+
//# sourceMappingURL=workerpool-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerpool-shim.d.ts","sourceRoot":"","sources":["../../src/shims/workerpool-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,MAAM,MAAM,IAAI,GAAG,GAAG,CAAC;AAEvB,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC;AAY9B;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CASjE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EACzD,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,GACrC,IAAI,CAEN;AAGD,eAAO,MAAM,IAAI,QAAsB,CAAC;AACxC,eAAO,MAAM,YAAY,SAA8B,CAAC;AACxD,eAAO,MAAM,QAAQ,oBAA0B,CAAC;;;;;;;;AAGhD,wBAME"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { resolveWorkerPathSync, prewarmManifest } from "./continue-worker-paths.js";
|
|
4
|
+
const require2 = createRequire(import.meta.url);
|
|
5
|
+
const realWorkerpool = require2("workerpool");
|
|
6
|
+
prewarmManifest().catch((err) => {
|
|
7
|
+
console.error("[workerpool-shim] Failed to prewarm manifest:", err);
|
|
8
|
+
});
|
|
9
|
+
function pool(script, options) {
|
|
10
|
+
let resolvedScript = script;
|
|
11
|
+
if (typeof script === "string" && !fs.existsSync(script)) {
|
|
12
|
+
resolvedScript = resolveWorkerPathSync(script);
|
|
13
|
+
console.error(`[workerpool-shim] Resolved worker path: ${script} -> ${resolvedScript}`);
|
|
14
|
+
}
|
|
15
|
+
return realWorkerpool.pool(resolvedScript, options);
|
|
16
|
+
}
|
|
17
|
+
function worker(methods, options) {
|
|
18
|
+
return realWorkerpool.worker(methods, options);
|
|
19
|
+
}
|
|
20
|
+
const cpus = realWorkerpool.cpus;
|
|
21
|
+
const isMainThread = realWorkerpool.isMainThread;
|
|
22
|
+
const platform = realWorkerpool.platform;
|
|
23
|
+
var workerpool_shim_default = {
|
|
24
|
+
pool,
|
|
25
|
+
worker,
|
|
26
|
+
cpus,
|
|
27
|
+
isMainThread,
|
|
28
|
+
platform
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
cpus,
|
|
32
|
+
workerpool_shim_default as default,
|
|
33
|
+
isMainThread,
|
|
34
|
+
platform,
|
|
35
|
+
pool,
|
|
36
|
+
worker
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerpool-shim.js","sourceRoot":"","sources":["../../src/shims/workerpool-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAQpF,gDAAgD;AAChD,+EAA+E;AAC/E,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,cAAc,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAC;AAE5E,gEAAgE;AAChE,eAAe,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAC,MAAe,EAAE,OAAqB;IACzD,IAAI,cAAc,GAAG,MAAM,CAAC;IAE5B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzD,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,CAAC,KAAK,CAAC,2CAA2C,MAAM,OAAO,cAAc,EAAE,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,cAAc,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CACpB,OAAyD,EACzD,OAAsC;IAEtC,OAAO,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC;AACxD,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC;AAEhD,oDAAoD;AACpD,eAAe;IACb,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,YAAY;IACZ,QAAQ;CACT,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface CodeStructureArgs {
|
|
2
|
+
paths: string[];
|
|
3
|
+
scope?: 'paths' | 'selected';
|
|
4
|
+
}
|
|
5
|
+
export interface CodeStructureResult {
|
|
6
|
+
scope: string;
|
|
7
|
+
structures: Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
signatures: string[];
|
|
10
|
+
count: number;
|
|
11
|
+
}>;
|
|
12
|
+
performance?: {
|
|
13
|
+
extractionTime: number;
|
|
14
|
+
filesProcessed: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface IndexCodeArgs {
|
|
18
|
+
paths: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface IndexCodeResult {
|
|
21
|
+
indexed: number;
|
|
22
|
+
failed: number;
|
|
23
|
+
totalSnippets: number;
|
|
24
|
+
performance: {
|
|
25
|
+
indexingTime: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract code structure using Continue's tree-sitter parser
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCodeStructureTool(args: CodeStructureArgs, selectedPaths?: string[]): Promise<CodeStructureResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Index code files into the database for structure extraction
|
|
34
|
+
*/
|
|
35
|
+
export declare function indexCodeTool(args: IndexCodeArgs): Promise<IndexCodeResult>;
|
|
36
|
+
//# sourceMappingURL=code-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-structure.d.ts","sourceRoot":"","sources":["../../src/tools/code-structure.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,WAAW,CAAC,EAAE;QACZ,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE;QACX,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,mBAAmB,CAAC,CA+D9B;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CA0EjF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { CodeSnippetsCodebaseIndex } from '@continuedev/core/dist/indexing/CodeSnippetsIndex.js';
|
|
2
|
+
import { SqliteDb } from '@continuedev/core/dist/indexing/refreshIndex.js';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
/**
|
|
5
|
+
* Extract code structure using Continue's tree-sitter parser
|
|
6
|
+
*/
|
|
7
|
+
export async function getCodeStructureTool(args, selectedPaths) {
|
|
8
|
+
const startTime = Date.now();
|
|
9
|
+
// Determine which paths to analyze
|
|
10
|
+
const paths = args.scope === 'selected'
|
|
11
|
+
? (selectedPaths || [])
|
|
12
|
+
: args.paths;
|
|
13
|
+
if (paths.length === 0) {
|
|
14
|
+
return {
|
|
15
|
+
scope: args.scope || 'paths',
|
|
16
|
+
structures: [],
|
|
17
|
+
performance: {
|
|
18
|
+
extractionTime: 0,
|
|
19
|
+
filesProcessed: 0,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
// Use Continue's CodeSnippetsIndex to extract signatures
|
|
25
|
+
const { groupedByUri } = await CodeSnippetsCodebaseIndex.getPathsAndSignatures(paths, 0, // uriOffset
|
|
26
|
+
paths.length, // uriBatchSize - process all paths
|
|
27
|
+
0, // snippetOffset
|
|
28
|
+
1000 // snippetBatchSize - max snippets per file
|
|
29
|
+
);
|
|
30
|
+
// Format results
|
|
31
|
+
const structures = Object.entries(groupedByUri).map(([path, signatures]) => ({
|
|
32
|
+
path,
|
|
33
|
+
signatures: signatures,
|
|
34
|
+
count: signatures.length,
|
|
35
|
+
}));
|
|
36
|
+
const extractionTime = Date.now() - startTime;
|
|
37
|
+
return {
|
|
38
|
+
scope: args.scope || 'paths',
|
|
39
|
+
structures,
|
|
40
|
+
performance: {
|
|
41
|
+
extractionTime,
|
|
42
|
+
filesProcessed: paths.length,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error('Code structure extraction error:', error);
|
|
48
|
+
// Return placeholder results on error
|
|
49
|
+
return {
|
|
50
|
+
scope: args.scope || 'paths',
|
|
51
|
+
structures: paths.map(path => ({
|
|
52
|
+
path,
|
|
53
|
+
signatures: [],
|
|
54
|
+
count: 0,
|
|
55
|
+
})),
|
|
56
|
+
performance: {
|
|
57
|
+
extractionTime: Date.now() - startTime,
|
|
58
|
+
filesProcessed: 0,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Index code files into the database for structure extraction
|
|
65
|
+
*/
|
|
66
|
+
export async function indexCodeTool(args) {
|
|
67
|
+
const startTime = Date.now();
|
|
68
|
+
let indexed = 0;
|
|
69
|
+
let failed = 0;
|
|
70
|
+
let totalSnippets = 0;
|
|
71
|
+
try {
|
|
72
|
+
const db = await SqliteDb.get();
|
|
73
|
+
// Create tables if they don't exist
|
|
74
|
+
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
|
|
75
|
+
id INTEGER PRIMARY KEY,
|
|
76
|
+
path TEXT NOT NULL,
|
|
77
|
+
cacheKey TEXT NOT NULL,
|
|
78
|
+
content TEXT NOT NULL,
|
|
79
|
+
title TEXT NOT NULL,
|
|
80
|
+
signature TEXT,
|
|
81
|
+
startLine INTEGER NOT NULL,
|
|
82
|
+
endLine INTEGER NOT NULL
|
|
83
|
+
)`);
|
|
84
|
+
// Create a minimal IDE interface
|
|
85
|
+
const fakeIde = {
|
|
86
|
+
readFile: async (filepath) => {
|
|
87
|
+
return fs.readFileSync(filepath, 'utf-8');
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const indexer = new CodeSnippetsCodebaseIndex(fakeIde);
|
|
91
|
+
// Process each file
|
|
92
|
+
for (const filepath of args.paths) {
|
|
93
|
+
try {
|
|
94
|
+
const contents = fs.readFileSync(filepath, 'utf-8');
|
|
95
|
+
const snippets = await indexer.getSnippetsInFile(filepath, contents);
|
|
96
|
+
// Store snippets in database
|
|
97
|
+
for (const snippet of snippets) {
|
|
98
|
+
await db.run('INSERT OR REPLACE INTO code_snippets (path, cacheKey, content, title, signature, startLine, endLine) VALUES (?, ?, ?, ?, ?, ?, ?)', [
|
|
99
|
+
filepath,
|
|
100
|
+
'default', // Simple cache key
|
|
101
|
+
snippet.content,
|
|
102
|
+
snippet.title,
|
|
103
|
+
snippet.signature,
|
|
104
|
+
snippet.startLine,
|
|
105
|
+
snippet.endLine
|
|
106
|
+
]);
|
|
107
|
+
totalSnippets++;
|
|
108
|
+
}
|
|
109
|
+
indexed++;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.error(`Failed to index ${filepath}:`, error);
|
|
113
|
+
failed++;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const indexingTime = Date.now() - startTime;
|
|
117
|
+
return {
|
|
118
|
+
indexed,
|
|
119
|
+
failed,
|
|
120
|
+
totalSnippets,
|
|
121
|
+
performance: {
|
|
122
|
+
indexingTime
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error('Indexing error:', error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=code-structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-structure.js","sourceRo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.js';
|
|
2
|
+
export interface FileSearchArgs {
|
|
3
|
+
pattern: string;
|
|
4
|
+
mode?: 'auto' | 'path' | 'content' | 'both';
|
|
5
|
+
regex?: boolean;
|
|
6
|
+
filter?: {
|
|
7
|
+
extensions?: string[];
|
|
8
|
+
exclude?: string[];
|
|
9
|
+
};
|
|
10
|
+
max_results?: number;
|
|
11
|
+
context_lines?: number;
|
|
12
|
+
include_content?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface FileSearchResult {
|
|
15
|
+
pattern: string;
|
|
16
|
+
mode: string;
|
|
17
|
+
results: Array<{
|
|
18
|
+
type: 'path' | 'content';
|
|
19
|
+
path: string;
|
|
20
|
+
line_range?: [number, number];
|
|
21
|
+
content?: string;
|
|
22
|
+
score?: number;
|
|
23
|
+
}>;
|
|
24
|
+
count: number;
|
|
25
|
+
performance?: {
|
|
26
|
+
searchTime: number;
|
|
27
|
+
method: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Search files using Continue's FTS5 index with BM25 ranking
|
|
32
|
+
* Supports multiple workspace directories for cross-repository search
|
|
33
|
+
*/
|
|
34
|
+
export declare function fileSearchTool(args: FileSearchArgs, workspaceDirs: string | string[], ide: ContinueIDE): Promise<FileSearchResult>;
|
|
35
|
+
//# sourceMappingURL=file-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-search.d.ts","sourceRoot":"","sources":["../../src/tools/file-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAwC9D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAgMD;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,cAAc,EACpB,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,EAChC,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,gBAAgB,CAAC,CAiI3B"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { FileWalker } from '../utils/file-walker.js';
|
|
2
|
+
import { FullTextSearchCodebaseIndex } from '@continuedev/core/dist/indexing/FullTextSearchCodebaseIndex.js';
|
|
3
|
+
import { getComputeDeleteAddRemove, SqliteDb } from '@continuedev/core/dist/indexing/refreshIndex.js';
|
|
4
|
+
import { ChunkCodebaseIndex } from '@continuedev/core/dist/indexing/chunk/ChunkCodebaseIndex.js';
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
/**
|
|
7
|
+
* Build tag string in Continue's format: "directory::branch::artifactId"
|
|
8
|
+
*/
|
|
9
|
+
function tagToString(tag) {
|
|
10
|
+
return `${tag.directory}::${tag.branch}::${tag.artifactId}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check if a tag already has indexed chunks in the database.
|
|
14
|
+
* This handles the case where a previous indexing run was interrupted:
|
|
15
|
+
* - chunk_tags has entries (INSERT succeeded)
|
|
16
|
+
* - tag_catalog wasn't updated (markComplete didn't run)
|
|
17
|
+
* - Next run would try to re-insert → UNIQUE constraint violation
|
|
18
|
+
*/
|
|
19
|
+
async function isTagAlreadyIndexed(tag) {
|
|
20
|
+
try {
|
|
21
|
+
const db = await SqliteDb.get();
|
|
22
|
+
const tagString = tagToString(tag);
|
|
23
|
+
console.error(`[DEBUG] isTagAlreadyIndexed: checking for tag="${tagString}"`);
|
|
24
|
+
const result = await db.get('SELECT COUNT(*) as count FROM chunk_tags WHERE tag = ?', [tagString]);
|
|
25
|
+
const count = result?.count ?? 0;
|
|
26
|
+
console.error(`[DEBUG] isTagAlreadyIndexed: found ${count} entries`);
|
|
27
|
+
return count > 0;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// Table might not exist yet on first run
|
|
31
|
+
console.error(`[DEBUG] isTagAlreadyIndexed: error`, error);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Track which directories have been indexed (rebuilds on server restart)
|
|
36
|
+
const indexedDirs = new Set();
|
|
37
|
+
/**
|
|
38
|
+
* Sanitize query text for FTS5 phrase search.
|
|
39
|
+
*
|
|
40
|
+
* FTS5 interprets special characters as operators:
|
|
41
|
+
* - `-` as NOT (e.g., "crossplane-plan" becomes "crossplane NOT plan")
|
|
42
|
+
* - `+` as required term
|
|
43
|
+
* - `*` as prefix wildcard
|
|
44
|
+
* - `OR`, `AND`, `NOT` as boolean operators
|
|
45
|
+
* - `"` for phrase search
|
|
46
|
+
*
|
|
47
|
+
* Continue's upstream code only strips `?` characters, leaving this bug.
|
|
48
|
+
* We fix it by wrapping the entire query in double quotes for phrase search.
|
|
49
|
+
* This matches exact character sequences, which is typically what users want
|
|
50
|
+
* for code identifiers like `context-mcp` or `getUserById`.
|
|
51
|
+
*/
|
|
52
|
+
function sanitizeFTS5Query(text) {
|
|
53
|
+
// Escape any existing double quotes by doubling them
|
|
54
|
+
const escaped = text.replace(/"/g, '""');
|
|
55
|
+
// Wrap in double quotes for phrase search
|
|
56
|
+
return `"${escaped}"`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build FTS5 index for a single workspace directory
|
|
60
|
+
* This populates the chunks table and FTS5 index tables
|
|
61
|
+
*/
|
|
62
|
+
async function buildFTSIndexForDir(workspaceDir, ide) {
|
|
63
|
+
// 1. Create IndexTag - each directory gets its own tag
|
|
64
|
+
const tag = {
|
|
65
|
+
branch: 'main', // TODO: Detect from git
|
|
66
|
+
directory: workspaceDir,
|
|
67
|
+
artifactId: 'chunks', // ChunkCodebaseIndex.artifactId
|
|
68
|
+
};
|
|
69
|
+
// Check if already indexed in chunk_tags (handles interrupted previous runs)
|
|
70
|
+
if (await isTagAlreadyIndexed(tag)) {
|
|
71
|
+
console.error(`FTS5 index already exists for: ${workspaceDir} (skipping)`);
|
|
72
|
+
indexedDirs.add(workspaceDir);
|
|
73
|
+
return tag;
|
|
74
|
+
}
|
|
75
|
+
console.error(`Building FTS5 index for: ${workspaceDir}`);
|
|
76
|
+
// 2. Get all files to index
|
|
77
|
+
const walker = new FileWalker(workspaceDir);
|
|
78
|
+
const allFiles = await walker.walk();
|
|
79
|
+
// Create FileStatsMap
|
|
80
|
+
const fileStats = {};
|
|
81
|
+
for (const file of allFiles) {
|
|
82
|
+
try {
|
|
83
|
+
const stats = await fs.stat(file);
|
|
84
|
+
fileStats[file] = {
|
|
85
|
+
size: stats.size,
|
|
86
|
+
lastModified: stats.mtimeMs,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Skip files we can't stat
|
|
91
|
+
console.error(`Error stating file ${file}:`, error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// 3. Use Continue's helper to compute what to index
|
|
95
|
+
const [results, _pathsAndCacheKeys, markComplete] = await getComputeDeleteAddRemove(tag, fileStats, async (path) => await fs.readFile(path, 'utf-8'), undefined // repoName
|
|
96
|
+
);
|
|
97
|
+
console.error(` Indexing ${results.compute.length} files, removing ${results.del.length} files...`);
|
|
98
|
+
// 4. Build Chunks index (populates chunks table)
|
|
99
|
+
try {
|
|
100
|
+
// ChunkCodebaseIndex needs (readFile, continueServerClient, maxChunkSize)
|
|
101
|
+
// We don't have a continueServerClient, so pass a mock with connected: false
|
|
102
|
+
const mockServerClient = {
|
|
103
|
+
connected: false,
|
|
104
|
+
url: undefined,
|
|
105
|
+
getUserToken: () => undefined,
|
|
106
|
+
getConfig: async () => ({ configJson: '{}' }),
|
|
107
|
+
getFromIndexCache: async () => ({ files: {} }),
|
|
108
|
+
};
|
|
109
|
+
const maxChunkSize = 512; // Default chunk size
|
|
110
|
+
const chunkIndex = new ChunkCodebaseIndex(ide.readFile.bind(ide), mockServerClient, maxChunkSize);
|
|
111
|
+
for await (const progress of chunkIndex.update(tag, results, markComplete, undefined)) {
|
|
112
|
+
// Log progress
|
|
113
|
+
if (progress.progress % 20 === 0 || progress.progress === 100) {
|
|
114
|
+
console.error(` Chunks indexing progress: ${progress.progress}%`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
console.error(` ✅ Chunks table populated for ${workspaceDir}`);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error(` ❌ Error building chunks index for ${workspaceDir}:`, error);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
// 5. Build FTS index (indexes the chunks)
|
|
124
|
+
try {
|
|
125
|
+
const ftsIndex = new FullTextSearchCodebaseIndex();
|
|
126
|
+
for await (const progress of ftsIndex.update(tag, results, markComplete, undefined)) {
|
|
127
|
+
// Log progress
|
|
128
|
+
if (progress.progress % 20 === 0 || progress.progress === 100) {
|
|
129
|
+
console.error(` FTS indexing progress: ${progress.progress}%`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
console.error(` ✅ FTS index populated for ${workspaceDir}`);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error(` ❌ Error building FTS index for ${workspaceDir}:`, error);
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
indexedDirs.add(workspaceDir);
|
|
139
|
+
return tag;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Build FTS5 index for all workspace directories
|
|
143
|
+
* Returns array of IndexTags for querying
|
|
144
|
+
*/
|
|
145
|
+
async function buildFTSIndex(workspaceDirs, ide) {
|
|
146
|
+
const tags = [];
|
|
147
|
+
// Check which directories need indexing
|
|
148
|
+
const dirsToIndex = workspaceDirs.filter(dir => !indexedDirs.has(dir));
|
|
149
|
+
if (dirsToIndex.length === 0) {
|
|
150
|
+
console.error('FTS5 index already built for all directories, skipping...');
|
|
151
|
+
// Return tags for all indexed directories
|
|
152
|
+
return workspaceDirs.map(dir => ({
|
|
153
|
+
branch: 'main',
|
|
154
|
+
directory: dir,
|
|
155
|
+
artifactId: 'chunks',
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
console.error(`Building FTS5 index for ${dirsToIndex.length} directory(ies)...`);
|
|
159
|
+
// Index each directory sequentially
|
|
160
|
+
for (const dir of dirsToIndex) {
|
|
161
|
+
const tag = await buildFTSIndexForDir(dir, ide);
|
|
162
|
+
tags.push(tag);
|
|
163
|
+
}
|
|
164
|
+
// Add tags for already-indexed directories
|
|
165
|
+
for (const dir of workspaceDirs) {
|
|
166
|
+
if (!dirsToIndex.includes(dir)) {
|
|
167
|
+
tags.push({
|
|
168
|
+
branch: 'main',
|
|
169
|
+
directory: dir,
|
|
170
|
+
artifactId: 'chunks',
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
console.error(`✅ FTS5 index built for ${workspaceDirs.length} directory(ies)`);
|
|
175
|
+
return tags;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Search files using Continue's FTS5 index with BM25 ranking
|
|
179
|
+
* Supports multiple workspace directories for cross-repository search
|
|
180
|
+
*/
|
|
181
|
+
export async function fileSearchTool(args, workspaceDirs, ide) {
|
|
182
|
+
// Normalize to array and remove trailing slashes for consistent tag matching
|
|
183
|
+
const dirs = (Array.isArray(workspaceDirs) ? workspaceDirs : [workspaceDirs])
|
|
184
|
+
.map(dir => dir.replace(/\/+$/, ''));
|
|
185
|
+
const mode = args.mode || 'auto';
|
|
186
|
+
const maxResults = args.max_results || 50;
|
|
187
|
+
const includeContent = args.include_content ?? false; // Default to false to save tokens
|
|
188
|
+
const results = [];
|
|
189
|
+
const startTime = Date.now();
|
|
190
|
+
// Path search across all directories (still uses V1 walker - fast enough)
|
|
191
|
+
if (mode === 'path' || mode === 'both' || mode === 'auto') {
|
|
192
|
+
try {
|
|
193
|
+
let allPathMatches = [];
|
|
194
|
+
// Search each directory
|
|
195
|
+
for (const dir of dirs) {
|
|
196
|
+
const walker = new FileWalker(dir);
|
|
197
|
+
const pathMatches = await walker.find(args.pattern, args.regex);
|
|
198
|
+
allPathMatches.push(...pathMatches);
|
|
199
|
+
}
|
|
200
|
+
// Apply filters
|
|
201
|
+
if (args.filter?.extensions && args.filter.extensions.length > 0) {
|
|
202
|
+
allPathMatches = allPathMatches.filter(path => {
|
|
203
|
+
const ext = path.split('.').pop();
|
|
204
|
+
return ext && args.filter.extensions.includes(ext);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (args.filter?.exclude && args.filter.exclude.length > 0) {
|
|
208
|
+
allPathMatches = allPathMatches.filter(path => {
|
|
209
|
+
return !args.filter.exclude.some(exclude => path.includes(exclude));
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
results.push(...allPathMatches.slice(0, maxResults).map(path => ({
|
|
213
|
+
type: 'path',
|
|
214
|
+
path,
|
|
215
|
+
})));
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error('Path search error:', error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Content search using FTS5
|
|
222
|
+
let searchMethod = 'File System';
|
|
223
|
+
if (mode === 'content' ||
|
|
224
|
+
mode === 'both' ||
|
|
225
|
+
(mode === 'auto' && results.length === 0)) {
|
|
226
|
+
try {
|
|
227
|
+
// 1. Build FTS index for all directories if not already built
|
|
228
|
+
const tags = await buildFTSIndex(dirs, ide);
|
|
229
|
+
// 2. Search using FTS5 across all indexed directories
|
|
230
|
+
const ftsIndex = new FullTextSearchCodebaseIndex();
|
|
231
|
+
const chunks = await ftsIndex.retrieve({
|
|
232
|
+
n: maxResults,
|
|
233
|
+
text: sanitizeFTS5Query(args.pattern),
|
|
234
|
+
tags: tags, // Search across all indexed directories
|
|
235
|
+
bm25Threshold: -2.5, // Ranks are negative; filter keeps rank <= threshold
|
|
236
|
+
});
|
|
237
|
+
// 3. Convert chunks to results
|
|
238
|
+
for (const chunk of chunks) {
|
|
239
|
+
// Apply extension filter if specified
|
|
240
|
+
if (args.filter?.extensions && args.filter.extensions.length > 0) {
|
|
241
|
+
const ext = chunk.filepath.split('.').pop();
|
|
242
|
+
if (!ext || !args.filter.extensions.includes(ext)) {
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
// Apply exclude filter if specified
|
|
247
|
+
if (args.filter?.exclude && args.filter.exclude.length > 0) {
|
|
248
|
+
const shouldExclude = args.filter.exclude.some(exclude => chunk.filepath.includes(exclude));
|
|
249
|
+
if (shouldExclude) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
// Build result with line range and optional content
|
|
254
|
+
const result = {
|
|
255
|
+
type: 'content',
|
|
256
|
+
path: chunk.filepath,
|
|
257
|
+
line_range: [chunk.startLine, chunk.endLine],
|
|
258
|
+
};
|
|
259
|
+
// Only include content if requested (saves tokens)
|
|
260
|
+
if (includeContent) {
|
|
261
|
+
result.content = chunk.content.trim();
|
|
262
|
+
}
|
|
263
|
+
results.push(result);
|
|
264
|
+
}
|
|
265
|
+
searchMethod = `FTS5 (BM25, ${dirs.length} dir${dirs.length > 1 ? 's' : ''})`;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
console.error('FTS5 search error:', error);
|
|
269
|
+
throw error; // No fallback - FTS5 failures are hard errors
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const searchTime = Date.now() - startTime;
|
|
273
|
+
// Deduplicate by path
|
|
274
|
+
const uniqueResults = Array.from(new Map(results.map(r => [r.path, r])).values()).slice(0, maxResults);
|
|
275
|
+
return {
|
|
276
|
+
pattern: args.pattern,
|
|
277
|
+
mode,
|
|
278
|
+
results: uniqueResults,
|
|
279
|
+
count: uniqueResults.length,
|
|
280
|
+
performance: {
|
|
281
|
+
searchTime,
|
|
282
|
+
method: searchMethod,
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
//# sourceMappingURL=file-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-search.js","sourceRoot":"","sources":["../../src/tools/file-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gEAAgE,CAAC;AAC7G,OAAO,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,iDAAiD,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AAEjG,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAEpC;;GAEG;AACH,SAAS,WAAW,CAAC,GAAa;IAChC,OAAO,GAAG,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,mB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AAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAChD,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAEvB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,IAAI;QACJ,OAAO,EAAE,aAAa;QACtB,KAAK,EAAE,aAAa,CAAC,MAAM;QAC3B,WAAW,EAAE;YACX,UAAU;YACV,MAAM,EAAE,YAAY;SACrB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FileTreeArgs {
|
|
2
|
+
type: 'files' | 'roots';
|
|
3
|
+
mode?: 'auto' | 'full' | 'folders';
|
|
4
|
+
path?: string;
|
|
5
|
+
max_depth?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FileTreeResult {
|
|
8
|
+
type: string;
|
|
9
|
+
mode?: string;
|
|
10
|
+
roots?: string[];
|
|
11
|
+
files?: string[];
|
|
12
|
+
count?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get workspace file tree
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFileTreeTool(args: FileTreeArgs, workspaceDir: string): Promise<FileTreeResult>;
|
|
18
|
+
//# sourceMappingURL=file-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../src/tools/file-tree.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,YAAY,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,CAAC,CAwCzB"}
|