xindex 1.0.12 → 1.0.13
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/.mcp.json +4 -0
- package/apps/indexApp.ts +4 -4
- package/apps/mcpApp.ts +7 -7
- package/apps/run.index.ts +5 -5
- package/apps/run.mcp.ts +9 -9
- package/apps/run.reset.ts +3 -3
- package/apps/run.search.ts +3 -3
- package/apps/run.watch.ts +9 -9
- package/apps/watchApp.ts +7 -7
- package/apps/watchFileEventsApp.ts +6 -6
- package/{componets → components}/llm/embed.ts +4 -9
- package/components/llm/queryLLM.ts +31 -0
- package/features/indexContent.ts +5 -5
- package/features/removeContent.ts +1 -1
- package/features/resetIndex.ts +1 -1
- package/features/searchIndex.ts +4 -4
- package/package.json +1 -1
- package/componets/llm/queryLLM.ts +0 -20
- /package/{componets → components}/IType.ts +0 -0
- /package/{componets → components}/appId.ts +0 -0
- /package/{componets → components}/buildComponents.ts +0 -0
- /package/{componets → components}/config/DEFAULT_LOCATE_BATCH_SIZE.ts +0 -0
- /package/{componets → components}/config/INDEXING_BATCH_SIZE.ts +0 -0
- /package/{componets → components}/config/INDEXING_COALESCE_MAX_ITEMS.ts +0 -0
- /package/{componets → components}/config/INDEXING_COALESCE_MS.ts +0 -0
- /package/{componets → components}/config/WATCH_COALESCE_MS.ts +0 -0
- /package/{componets → components}/config/WATCH_FLUSH_MS.ts +0 -0
- /package/{componets → components}/config/loadConfig.ts +0 -0
- /package/{componets → components}/config/xindexConfig.ts +0 -0
- /package/{componets → components}/ignore/loadIgnoreChain.ts +0 -0
- /package/{componets → components}/index/coalesceIndexApi.ts +0 -0
- /package/{componets → components}/index/contentIndexDriver.ts +0 -0
- /package/{componets → components}/index/documentContentIndexDriver.ts +0 -0
- /package/{componets → components}/index/documentIndex.ts +0 -0
- /package/{componets → components}/index/formatSearchResults.ts +0 -0
- /package/{componets → components}/index/getIndexStats.ts +0 -0
- /package/{componets → components}/index/handleFileEvent.ts +0 -0
- /package/{componets → components}/index/indexApi.ts +0 -0
- /package/{componets → components}/index/vectraIndex.ts +0 -0
- /package/{componets → components}/index/watcherLock.ts +0 -0
- /package/{componets → components}/io/safeIndexBatch.ts +0 -0
- /package/{componets → components}/io/safeReadFile.ts +0 -0
- /package/{componets → components}/keywords/cleanUpKeywords.ts +0 -0
- /package/{componets → components}/keywords/extractKeywords.ts +0 -0
- /package/{componets → components}/keywords/refineKeywords.ts +0 -0
- /package/{componets → components}/locate/bm25.ts +0 -0
- /package/{componets → components}/locate/inMemoryIndex.ts +0 -0
- /package/{componets → components}/locate/locateInFile.ts +0 -0
- /package/{componets → components}/locate/windowsOf.ts +0 -0
- /package/{componets → components}/logger.ts +0 -0
- /package/{componets → components}/walkFiles.ts +0 -0
- /package/{componets → components}/watchFiles.ts +0 -0
package/.mcp.json
CHANGED
package/apps/indexApp.ts
CHANGED
|
@@ -3,11 +3,11 @@ import {batch} from "../packages/streamx/src/batch.js";
|
|
|
3
3
|
import {map} from "../packages/streamx/src/map.js";
|
|
4
4
|
import {tap} from "../packages/streamx/src/tap.js";
|
|
5
5
|
import {run} from "../packages/streamx/src/index.js";
|
|
6
|
-
import {IWalkFiles} from "../
|
|
6
|
+
import {IWalkFiles} from "../components/walkFiles.js";
|
|
7
7
|
import {IIndexContent} from "../features/indexContent.js";
|
|
8
|
-
import {ILogger} from "../
|
|
9
|
-
import {INDEXING_BATCH_SIZE} from "../
|
|
10
|
-
import {SafeIndexBatch} from "../
|
|
8
|
+
import {ILogger} from "../components/logger.js";
|
|
9
|
+
import {INDEXING_BATCH_SIZE} from "../components/config/INDEXING_BATCH_SIZE";
|
|
10
|
+
import {SafeIndexBatch} from "../components/io/safeIndexBatch.js";
|
|
11
11
|
|
|
12
12
|
export type IIndexApp = (inputs: string[]) => Promise<void>;
|
|
13
13
|
|
package/apps/mcpApp.ts
CHANGED
|
@@ -2,15 +2,15 @@ import {McpServer} from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import {StdioServerTransport} from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import {z} from "zod";
|
|
4
4
|
import {IIndexApp} from "./indexApp.js";
|
|
5
|
-
import {IGetIndexStats} from "../
|
|
5
|
+
import {IGetIndexStats} from "../components/index/getIndexStats.js";
|
|
6
6
|
import {IResetIndex} from "../features/resetIndex.js";
|
|
7
|
-
import {IWatchFiles} from "../
|
|
8
|
-
import {IHandleFileEvents} from "../
|
|
9
|
-
import {ILogger} from "../
|
|
7
|
+
import {IWatchFiles} from "../components/watchFiles.js";
|
|
8
|
+
import {IHandleFileEvents} from "../components/index/handleFileEvent.js";
|
|
9
|
+
import {ILogger} from "../components/logger.js";
|
|
10
10
|
import {WatchFileEventsApp} from "./watchFileEventsApp.js";
|
|
11
|
-
import {IWatcherLock} from "../
|
|
12
|
-
import {IXindexConfig} from "../
|
|
13
|
-
import {FormatSearchResults} from "../
|
|
11
|
+
import {IWatcherLock} from "../components/index/watcherLock.js";
|
|
12
|
+
import {IXindexConfig} from "../components/config/xindexConfig.js";
|
|
13
|
+
import {FormatSearchResults} from "../components/index/formatSearchResults.js";
|
|
14
14
|
import {ISearchApp} from "./searchApp.js";
|
|
15
15
|
|
|
16
16
|
export type IMcpApp = () => Promise<void>;
|
package/apps/run.index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {BuildComponents} from "../
|
|
2
|
-
import {BufferedLoggerToStdOut} from "../
|
|
3
|
-
import {WalkFiles} from "../
|
|
1
|
+
import {BuildComponents} from "../components/buildComponents.js";
|
|
2
|
+
import {BufferedLoggerToStdOut} from "../components/logger.js";
|
|
3
|
+
import {WalkFiles} from "../components/walkFiles.js";
|
|
4
4
|
import {IndexApp} from "./indexApp.js";
|
|
5
|
-
import {AppId} from "../
|
|
6
|
-
import {INDEXING_COALESCE_MS} from "../
|
|
5
|
+
import {AppId} from "../components/appId.js";
|
|
6
|
+
import {INDEXING_COALESCE_MS} from "../components/config/INDEXING_COALESCE_MS.js";
|
|
7
7
|
|
|
8
8
|
const appId = AppId();
|
|
9
9
|
const cwd = process.cwd();
|
package/apps/run.mcp.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {BuildComponents} from "../
|
|
2
|
-
import {HandleFileEvents} from "../
|
|
3
|
-
import {BufferedLoggerToStdErr} from "../
|
|
4
|
-
import {WalkFiles} from "../
|
|
5
|
-
import {WatchFiles} from "../
|
|
6
|
-
import {WatcherLock} from "../
|
|
1
|
+
import {BuildComponents} from "../components/buildComponents.js";
|
|
2
|
+
import {HandleFileEvents} from "../components/index/handleFileEvent.js";
|
|
3
|
+
import {BufferedLoggerToStdErr} from "../components/logger.js";
|
|
4
|
+
import {WalkFiles} from "../components/walkFiles.js";
|
|
5
|
+
import {WatchFiles} from "../components/watchFiles.js";
|
|
6
|
+
import {WatcherLock} from "../components/index/watcherLock.js";
|
|
7
7
|
import {IndexApp} from "./indexApp.js";
|
|
8
8
|
import {McpApp} from "./mcpApp.js";
|
|
9
9
|
import {SearchApp} from "./searchApp.js";
|
|
10
10
|
import {join} from "path";
|
|
11
|
-
import {AppId} from "../
|
|
12
|
-
import {INDEXING_COALESCE_MS} from "../
|
|
13
|
-
import {WATCH_COALESCE_MS} from "../
|
|
11
|
+
import {AppId} from "../components/appId.js";
|
|
12
|
+
import {INDEXING_COALESCE_MS} from "../components/config/INDEXING_COALESCE_MS.js";
|
|
13
|
+
import {WATCH_COALESCE_MS} from "../components/config/WATCH_COALESCE_MS.js";
|
|
14
14
|
|
|
15
15
|
const args = process.argv.slice(2);
|
|
16
16
|
const watchDirArg = args.find(a => a.startsWith("--watch-dir="));
|
package/apps/run.reset.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {BuildComponents} from "../
|
|
2
|
-
import {BufferedLoggerToStdOut} from "../
|
|
3
|
-
import {AppId} from "../
|
|
1
|
+
import {BuildComponents} from "../components/buildComponents.js";
|
|
2
|
+
import {BufferedLoggerToStdOut} from "../components/logger.js";
|
|
3
|
+
import {AppId} from "../components/appId.js";
|
|
4
4
|
|
|
5
5
|
const appId = AppId();
|
|
6
6
|
const log = BufferedLoggerToStdOut();
|
package/apps/run.search.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {BuildComponents} from "../
|
|
2
|
-
import {BufferedLoggerToStdOut} from "../
|
|
1
|
+
import {BuildComponents} from "../components/buildComponents.js";
|
|
2
|
+
import {BufferedLoggerToStdOut} from "../components/logger.js";
|
|
3
3
|
import {SearchApp} from "./searchApp.js";
|
|
4
|
-
import {FormatSearchResults} from "../
|
|
4
|
+
import {FormatSearchResults} from "../components/index/formatSearchResults.js";
|
|
5
5
|
|
|
6
6
|
const log = BufferedLoggerToStdOut();
|
|
7
7
|
const {searchContentIndex} = await BuildComponents({log});
|
package/apps/run.watch.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {BuildComponents} from "../
|
|
2
|
-
import {HandleFileEvents} from "../
|
|
3
|
-
import {BufferedLoggerToStdOut} from "../
|
|
4
|
-
import {WalkFiles} from "../
|
|
5
|
-
import {WatchFiles} from "../
|
|
6
|
-
import {WatcherLock} from "../
|
|
1
|
+
import {BuildComponents} from "../components/buildComponents.js";
|
|
2
|
+
import {HandleFileEvents} from "../components/index/handleFileEvent.js";
|
|
3
|
+
import {BufferedLoggerToStdOut} from "../components/logger.js";
|
|
4
|
+
import {WalkFiles} from "../components/walkFiles.js";
|
|
5
|
+
import {WatchFiles} from "../components/watchFiles.js";
|
|
6
|
+
import {WatcherLock} from "../components/index/watcherLock.js";
|
|
7
7
|
import {WatchApp} from "./watchApp.js";
|
|
8
|
-
import {AppId} from "../
|
|
8
|
+
import {AppId} from "../components/appId.js";
|
|
9
9
|
import {join} from "path";
|
|
10
|
-
import {WATCH_COALESCE_MS} from "../
|
|
11
|
-
import {INDEXING_COALESCE_MS} from "../
|
|
10
|
+
import {WATCH_COALESCE_MS} from "../components/config/WATCH_COALESCE_MS.js";
|
|
11
|
+
import {INDEXING_COALESCE_MS} from "../components/config/INDEXING_COALESCE_MS.js";
|
|
12
12
|
|
|
13
13
|
const cwd = process.cwd();
|
|
14
14
|
const log = BufferedLoggerToStdOut();
|
package/apps/watchApp.ts
CHANGED
|
@@ -3,15 +3,15 @@ import {batch} from "../packages/streamx/src/batch.js";
|
|
|
3
3
|
import {map} from "../packages/streamx/src/map.js";
|
|
4
4
|
import {tap} from "../packages/streamx/src/tap.js";
|
|
5
5
|
import {run} from "../packages/streamx/src/index.js";
|
|
6
|
-
import {IWalkFiles} from "../
|
|
7
|
-
import {IWatchFiles} from "../
|
|
8
|
-
import {IHandleFileEvents} from "../
|
|
9
|
-
import {ILogger} from "../
|
|
10
|
-
import {IWatcherLock} from "../
|
|
6
|
+
import {IWalkFiles} from "../components/walkFiles.js";
|
|
7
|
+
import {IWatchFiles} from "../components/watchFiles.js";
|
|
8
|
+
import {IHandleFileEvents} from "../components/index/handleFileEvent.js";
|
|
9
|
+
import {ILogger} from "../components/logger.js";
|
|
10
|
+
import {IWatcherLock} from "../components/index/watcherLock.js";
|
|
11
11
|
import {WatchFileEventsApp} from "./watchFileEventsApp.js";
|
|
12
12
|
import {IIndexContent} from "../features/indexContent.js";
|
|
13
|
-
import {INDEXING_BATCH_SIZE} from "../
|
|
14
|
-
import {SafeIndexBatch} from "../
|
|
13
|
+
import {INDEXING_BATCH_SIZE} from "../components/config/INDEXING_BATCH_SIZE";
|
|
14
|
+
import {SafeIndexBatch} from "../components/io/safeIndexBatch.js";
|
|
15
15
|
|
|
16
16
|
export type IWatchApp = {
|
|
17
17
|
run: (inputs: string[]) => Promise<void>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {IWatchFiles} from "../
|
|
2
|
-
import {IHandleFileEvents} from "../
|
|
3
|
-
import {ILogger} from "../
|
|
4
|
-
import {IWatcherLock} from "../
|
|
1
|
+
import {IWatchFiles} from "../components/watchFiles.js";
|
|
2
|
+
import {IHandleFileEvents} from "../components/index/handleFileEvent.js";
|
|
3
|
+
import {ILogger} from "../components/logger.js";
|
|
4
|
+
import {IWatcherLock} from "../components/index/watcherLock.js";
|
|
5
5
|
import {from} from "../packages/streamx/src/from.js";
|
|
6
6
|
import {batchTimed} from "../packages/streamx/src/batchTimed.js";
|
|
7
7
|
import {map} from "../packages/streamx/src/map.js";
|
|
8
8
|
import {run} from "../packages/streamx/src/index.js";
|
|
9
|
-
import {INDEXING_BATCH_SIZE} from "../
|
|
10
|
-
import {WATCH_FLUSH_MS} from "../
|
|
9
|
+
import {INDEXING_BATCH_SIZE} from "../components/config/INDEXING_BATCH_SIZE.js";
|
|
10
|
+
import {WATCH_FLUSH_MS} from "../components/config/WATCH_FLUSH_MS.js";
|
|
11
11
|
|
|
12
12
|
export type IWatchFileEventsApp = () => void;
|
|
13
13
|
|
|
@@ -7,17 +7,12 @@ export type IEmbed = (text: string) => Promise<number[]>;
|
|
|
7
7
|
type Pooling = "none" | "mean" | "cls" | "first_token" | "eos" | "last_token";
|
|
8
8
|
|
|
9
9
|
export function Embed({pooling, normalize}: {pooling: Pooling, normalize: boolean}): IEmbed {
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
function getEmbedder() {
|
|
13
|
-
if (!embedderPromise) {
|
|
14
|
-
embedderPromise = pipeline("feature-extraction", MODEL);
|
|
15
|
-
}
|
|
16
|
-
return embedderPromise;
|
|
17
|
-
}
|
|
10
|
+
let embedder: any = undefined
|
|
18
11
|
|
|
19
12
|
return async function embed(text) {
|
|
20
|
-
|
|
13
|
+
if (!embedder) {
|
|
14
|
+
embedder = await pipeline("feature-extraction", MODEL);
|
|
15
|
+
}
|
|
21
16
|
const result = await embedder(text, {pooling, normalize});
|
|
22
17
|
return Array.from(result.data as Float32Array);
|
|
23
18
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {pipeline} from "@huggingface/transformers";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export type IQueryLLM = (prompt: string, input: string, maxTokens?: number) => Promise<string>;
|
|
5
|
+
|
|
6
|
+
const MODEL = "HuggingFaceTB/SmolLM2-135M-Instruct";
|
|
7
|
+
|
|
8
|
+
export function QueryLLM({maxTokens, model = MODEL}: {
|
|
9
|
+
maxTokens: number,
|
|
10
|
+
model?: string
|
|
11
|
+
}): IQueryLLM {
|
|
12
|
+
let generator: any = undefined;
|
|
13
|
+
|
|
14
|
+
return async function queryLLM(prompt, input, limit = maxTokens) {
|
|
15
|
+
if (!generator) {
|
|
16
|
+
generator = await pipeline(
|
|
17
|
+
"text-generation",
|
|
18
|
+
model
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const messages = [
|
|
23
|
+
{role: "system", content: prompt},
|
|
24
|
+
{role: "user", content: input},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const output = await generator(messages, {max_new_tokens: limit ?? maxTokens});
|
|
28
|
+
return (output[0].generated_text.at(-1)?.content as string) ?? "";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
package/features/indexContent.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {IndexCommandType, IIndexApi} from "../
|
|
2
|
-
import {IExtractKeywords} from "../
|
|
3
|
-
import {ICleanUpKeywords} from "../
|
|
4
|
-
import {IEmbed} from "../
|
|
5
|
-
import {ILogger} from "../
|
|
1
|
+
import {IndexCommandType, IIndexApi} from "../components/index/indexApi.js";
|
|
2
|
+
import {IExtractKeywords} from "../components/keywords/extractKeywords.js";
|
|
3
|
+
import {ICleanUpKeywords} from "../components/keywords/cleanUpKeywords.js";
|
|
4
|
+
import {IEmbed} from "../components/llm/embed.js";
|
|
5
|
+
import {ILogger} from "../components/logger.js";
|
|
6
6
|
|
|
7
7
|
export type IIndexContent = (items: Array<{id: string, content: string}>) => Promise<void>;
|
|
8
8
|
|
package/features/resetIndex.ts
CHANGED
package/features/searchIndex.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {LocalIndex} from "vectra";
|
|
2
|
-
import {IEmbed} from "../
|
|
3
|
-
import {IExtractKeywords} from "../
|
|
4
|
-
import {ICleanUpKeywords} from "../
|
|
5
|
-
import {ILocateInFile} from "../
|
|
2
|
+
import {IEmbed} from "../components/llm/embed.js";
|
|
3
|
+
import {IExtractKeywords} from "../components/keywords/extractKeywords.js";
|
|
4
|
+
import {ICleanUpKeywords} from "../components/keywords/cleanUpKeywords.js";
|
|
5
|
+
import {ILocateInFile} from "../components/locate/locateInFile.js";
|
|
6
6
|
|
|
7
7
|
export type IIndexRecord = {
|
|
8
8
|
score: number;
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {pipeline} from "@huggingface/transformers";
|
|
2
|
-
|
|
3
|
-
const generator = await pipeline(
|
|
4
|
-
"text-generation",
|
|
5
|
-
"HuggingFaceTB/SmolLM2-135M-Instruct"
|
|
6
|
-
);
|
|
7
|
-
|
|
8
|
-
export type IQueryLLM = (prompt: string, input: string, maxTokens?: number) => Promise<string>;
|
|
9
|
-
|
|
10
|
-
export function QueryLLM({maxTokens}: { maxTokens: number }): IQueryLLM {
|
|
11
|
-
return async function queryLLM(prompt, input, overrideMaxTokens?) {
|
|
12
|
-
const messages = [
|
|
13
|
-
{role: "system", content: prompt},
|
|
14
|
-
{role: "user", content: input},
|
|
15
|
-
];
|
|
16
|
-
const output = await generator(messages, {max_new_tokens: overrideMaxTokens ?? maxTokens});
|
|
17
|
-
return (output[0].generated_text.at(-1)?.content as string) ?? "";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|