@opengeni/jev 0.1.0-canary.36199476632001
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/LICENSE +190 -0
- package/README.md +140 -0
- package/dist/circuit-breaker.d.ts +58 -0
- package/dist/client.d.ts +173 -0
- package/dist/code-search/config.d.ts +142 -0
- package/dist/code-search/judge.d.ts +169 -0
- package/dist/code-search/leads.d.ts +96 -0
- package/dist/code-search/pack.d.ts +106 -0
- package/dist/code-search/recall.d.ts +155 -0
- package/dist/code-search/search.d.ts +93 -0
- package/dist/code-search/session.d.ts +33 -0
- package/dist/code-search/text.d.ts +35 -0
- package/dist/code-search/tool.d.ts +34 -0
- package/dist/code-search/windows.d.ts +85 -0
- package/dist/code-search/workspace.d.ts +51 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3110 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
- package/src/circuit-breaker.ts +135 -0
- package/src/client.ts +577 -0
- package/src/code-search/config.ts +282 -0
- package/src/code-search/judge.ts +413 -0
- package/src/code-search/leads.ts +442 -0
- package/src/code-search/pack.ts +354 -0
- package/src/code-search/recall.ts +648 -0
- package/src/code-search/search.ts +773 -0
- package/src/code-search/session.ts +89 -0
- package/src/code-search/text.ts +159 -0
- package/src/code-search/tool.ts +209 -0
- package/src/code-search/windows.ts +617 -0
- package/src/code-search/workspace.ts +55 -0
- package/src/index.ts +71 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* search.ts - the code_search pipeline (scout-0.3.1 with the Jev judge):
|
|
3
|
+
*
|
|
4
|
+
* 1. recall (ripgrep) -> top maxCandidates files by distinct-keyword IDF
|
|
5
|
+
* 2. wave 1 (file triage, 1 Noul per file) -> up to maxFiles files (+ lexical guard)
|
|
6
|
+
* 3. wave 2 (passage verification) -> relevance + per-sub-question coverage per passage
|
|
7
|
+
* 4. wave 3 (leads, exactly one round) -> <= maxLeadsFollowed definitions, verified like wave 2
|
|
8
|
+
* 5. pack (bounded, verbatim, line-numbered) + status (1 request over the packed evidence)
|
|
9
|
+
*
|
|
10
|
+
* Every file and process access goes through the injected CodeSearchWorkspace. A Jev failure fails the
|
|
11
|
+
* search (JevUnavailableError / JevRequestError propagate); only a failed final status check keeps the
|
|
12
|
+
* fully Jev-scored pack and reports the status as unknown.
|
|
13
|
+
*/
|
|
14
|
+
import { JevRequestError, JevUnavailableError, type JevClient } from "../client.js";
|
|
15
|
+
import { type CodeSearchConfig } from "./config.js";
|
|
16
|
+
import { type FileCandidate, type KeywordInfo, type RecallResult } from "./recall.js";
|
|
17
|
+
import type { CodeSearchWorkspace } from "./workspace.js";
|
|
18
|
+
/** The validated research version this engine ports (ranking, thresholds and defaults are unchanged). */
|
|
19
|
+
export declare const CODE_SEARCH_ENGINE_VERSION = "scout-0.3.1";
|
|
20
|
+
export declare const CODE_SEARCH_DEFAULT_BUDGET_TOKENS = 12000;
|
|
21
|
+
export interface CodeSearchInput {
|
|
22
|
+
question: string;
|
|
23
|
+
keywords: string[];
|
|
24
|
+
subQuestions?: string[] | undefined;
|
|
25
|
+
/** Workspace-relative path prefixes to search; default the whole workspace. */
|
|
26
|
+
paths?: string[] | undefined;
|
|
27
|
+
workspace: CodeSearchWorkspace;
|
|
28
|
+
jev: JevClient;
|
|
29
|
+
signal?: AbortSignal | undefined;
|
|
30
|
+
/** Max pack size in tokens (default 12000). */
|
|
31
|
+
budgetTokens?: number | undefined;
|
|
32
|
+
/** Tuning and tests only; defaults to DEFAULT_CODE_SEARCH_CONFIG. */
|
|
33
|
+
config?: CodeSearchConfig | undefined;
|
|
34
|
+
/** In-memory stage trace (recall, wave1, wave2, leads, pack, summary, and one "jev" event per Jev request). */
|
|
35
|
+
onStage?: ((stage: string, data: Record<string, unknown>) => void) | undefined;
|
|
36
|
+
}
|
|
37
|
+
export interface CodeSearchStatus {
|
|
38
|
+
label: "sufficient" | "partial" | "insufficient" | "unknown";
|
|
39
|
+
overall: number | null;
|
|
40
|
+
subs: Array<number | null>;
|
|
41
|
+
/** Set when the final Jev sufficiency check failed (the pack itself is fully Jev-scored). */
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CodeSearchStats {
|
|
45
|
+
wallMs: number;
|
|
46
|
+
stageMs: Record<string, number>;
|
|
47
|
+
candidates: number;
|
|
48
|
+
filesSelected: number;
|
|
49
|
+
passagesVerified: number;
|
|
50
|
+
passagesIncluded: number;
|
|
51
|
+
packChars: number;
|
|
52
|
+
packTokensEst: number;
|
|
53
|
+
workspaceCalls: number;
|
|
54
|
+
/** A ripgrep call returned partial output (byte cap or time limit); the pack header says so. */
|
|
55
|
+
ripgrepTruncated: boolean;
|
|
56
|
+
jev: {
|
|
57
|
+
requests: number;
|
|
58
|
+
inputTokens: number;
|
|
59
|
+
costUsd: number;
|
|
60
|
+
model: string | null;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface CodeSearchResult {
|
|
64
|
+
version: string;
|
|
65
|
+
/** The rendered pack: a status header line, verbatim line-numbered passages, then the footer. */
|
|
66
|
+
text: string;
|
|
67
|
+
status: CodeSearchStatus;
|
|
68
|
+
stats: CodeSearchStats;
|
|
69
|
+
/** The error of a failed final status check, for a circuit breaker (the search itself succeeded). */
|
|
70
|
+
statusCheckError?: JevUnavailableError | JevRequestError;
|
|
71
|
+
}
|
|
72
|
+
/** Lexical passage relevance in [0,1]: keyword IDF mass present, question-term overlap, file prior. */
|
|
73
|
+
export declare function lexicalPassageScore(text: string, kwPresent: number[], keywords: KeywordInfo[], qTerms: string[], fileNorm: number): number;
|
|
74
|
+
export declare function selectFiles(cands: FileCandidate[], scores: Map<string, number>, ids: string[], T1: number, cfg: CodeSearchConfig): {
|
|
75
|
+
selected: number[];
|
|
76
|
+
ranked: number[];
|
|
77
|
+
};
|
|
78
|
+
/** Round-robin across files (priority order), each file's windows by score, up to max. */
|
|
79
|
+
export declare function capPassages<T extends {
|
|
80
|
+
score: number;
|
|
81
|
+
}>(perFile: T[][], max: number): T[][];
|
|
82
|
+
/** Evidence text for the status check: included passages, best first, up to maxChars (whole blocks only). */
|
|
83
|
+
export declare function statusEvidence(included: Array<{
|
|
84
|
+
block: string;
|
|
85
|
+
rel: number;
|
|
86
|
+
}>, maxChars: number): string;
|
|
87
|
+
export declare function statusLabel(s: {
|
|
88
|
+
overall: number;
|
|
89
|
+
subs: number[];
|
|
90
|
+
} | null, cfg: CodeSearchConfig): CodeSearchStatus;
|
|
91
|
+
/** Footer note about paths that were missing, or a search that had to widen to the whole workspace. */
|
|
92
|
+
export declare function prefixNote(rec: Pick<RecallResult, "missingPrefixes" | "widened" | "validPrefixes">): string | undefined;
|
|
93
|
+
export declare function runCodeSearch(input: CodeSearchInput): Promise<CodeSearchResult>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session.ts - one search's view of the workspace: counts calls, records partial ripgrep output and
|
|
3
|
+
* makes every call honour the search's AbortSignal.
|
|
4
|
+
*/
|
|
5
|
+
import { type CodeSearchWorkspace } from "./workspace.js";
|
|
6
|
+
/** Parallel reads per search. */
|
|
7
|
+
export declare const READ_CONCURRENCY = 8;
|
|
8
|
+
/** Parallel ripgrep calls for one pattern split under CODE_SEARCH_MAX_PATTERN_CHARS. */
|
|
9
|
+
export declare const RIPGREP_SPLIT_CONCURRENCY = 4;
|
|
10
|
+
export declare class WorkspaceSession {
|
|
11
|
+
private readonly workspace;
|
|
12
|
+
readonly signal: AbortSignal;
|
|
13
|
+
private readonly ripgrepTimeoutMs;
|
|
14
|
+
calls: number;
|
|
15
|
+
/** A ripgrep call returned output cut at the adapter's byte cap. */
|
|
16
|
+
truncated: boolean;
|
|
17
|
+
/** A ripgrep call hit its time limit (its output is partial). */
|
|
18
|
+
timedOut: boolean;
|
|
19
|
+
constructor(workspace: CodeSearchWorkspace, signal: AbortSignal, ripgrepTimeoutMs: number);
|
|
20
|
+
get partial(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* ripgrep stdout. Exit code 2 (error) with some output keeps the output (for example unreadable files);
|
|
23
|
+
* with no output it throws unless `allowFailure`, which then yields "".
|
|
24
|
+
*/
|
|
25
|
+
ripgrep(args: readonly string[], options?: {
|
|
26
|
+
allowFailure?: boolean;
|
|
27
|
+
}): Promise<string>;
|
|
28
|
+
/** File text, or null when missing or binary (NUL bytes). */
|
|
29
|
+
readText(path: string, maxBytes: number): Promise<string | null>;
|
|
30
|
+
pathKinds(paths: readonly string[]): Promise<Record<string, "file" | "directory" | "missing">>;
|
|
31
|
+
}
|
|
32
|
+
/** Map with at most `limit` calls in flight; results keep the input order. */
|
|
33
|
+
export declare function mapLimit<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* text.ts - keyword variants, word splitting, stopwords and small text helpers.
|
|
3
|
+
*/
|
|
4
|
+
/** Split an identifier or phrase into lowercase words: fooBarBAZ_qux-v2 -> [foo, bar, baz, qux, v2]. */
|
|
5
|
+
export declare function splitWords(s: string): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Identifier variants of a keyword. The search is case-insensitive, so only the
|
|
8
|
+
* separator forms matter: concatenated (camel/Pascal/flat), snake/SCREAMING, kebab, spaced phrase.
|
|
9
|
+
* Returned in display casing (camel, snake, kebab, spaced) for the trace; deduped case-insensitively.
|
|
10
|
+
*/
|
|
11
|
+
export declare function keywordVariants(kw: string): string[];
|
|
12
|
+
/** Contiguous 2-word fragments of a compound with >= 3 words (fallback when the full name has no hits). */
|
|
13
|
+
export declare function compoundFragments(kw: string): string[];
|
|
14
|
+
/** A single plain word (no case change, no separator) short enough to need a word boundary. */
|
|
15
|
+
export declare function isShortPlainWord(kw: string, maxLen: number): boolean;
|
|
16
|
+
/** Escape for Rust regex (ripgrep). */
|
|
17
|
+
export declare function escapeRegex(s: string): string;
|
|
18
|
+
export declare const STOPWORDS: Set<string>;
|
|
19
|
+
/** Crude stemmer: good enough for overlap scoring (not for display). */
|
|
20
|
+
export declare function stem(w: string): string;
|
|
21
|
+
/** Content terms of a text (identifiers split into words, stopwords dropped, stemmed, deduped). */
|
|
22
|
+
export declare function contentTerms(text: string, minLen?: number): string[];
|
|
23
|
+
/** Fraction of `terms` present in `textTerms`. */
|
|
24
|
+
export declare function overlap(terms: string[], textTerms: Set<string>): number;
|
|
25
|
+
export declare function isTestPath(p: string): boolean;
|
|
26
|
+
/** Release notes: CHANGELOG*, HISTORY*, RELEASE_NOTES*, .changeset/ entries (describe past changes, not current code). */
|
|
27
|
+
export declare function isChangelogPath(p: string): boolean;
|
|
28
|
+
/** Is the question about history / releases (then release notes are not down-weighted)? */
|
|
29
|
+
export declare function questionMentionsHistory(q: string): boolean;
|
|
30
|
+
export declare function isDocPath(p: string): boolean;
|
|
31
|
+
export declare function questionMentionsTests(q: string): boolean;
|
|
32
|
+
/** Trim a line to maxChars around the first occurrence of any needle (case-insensitive). */
|
|
33
|
+
export declare function trimAround(line: string, needles: string[], maxChars: number): string;
|
|
34
|
+
export declare function estTokens(chars: number, charsPerToken: number): number;
|
|
35
|
+
export declare function fmtK(n: number): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const CODE_SEARCH_TOOL_NAME = "code_search";
|
|
2
|
+
export declare const CODE_SEARCH_TOOL_DESCRIPTION: string;
|
|
3
|
+
export declare const CODE_SEARCH_LIMITS: {
|
|
4
|
+
readonly questionMinChars: 3;
|
|
5
|
+
readonly questionMaxChars: 2000;
|
|
6
|
+
readonly keywordsMax: 20;
|
|
7
|
+
readonly keywordMaxChars: 120;
|
|
8
|
+
readonly subQuestionsMax: 3;
|
|
9
|
+
readonly subQuestionMaxChars: 1000;
|
|
10
|
+
readonly pathsMax: 8;
|
|
11
|
+
readonly pathMaxChars: 1000;
|
|
12
|
+
};
|
|
13
|
+
/** Plain JSON (mutable arrays), so it fits any JSON-schema slot of a tool definition. */
|
|
14
|
+
export type CodeSearchJsonValue = string | number | boolean | null | CodeSearchJsonValue[] | {
|
|
15
|
+
[key: string]: CodeSearchJsonValue;
|
|
16
|
+
};
|
|
17
|
+
/** JSON schema of the tool input; parseCodeSearchArguments enforces the same rules. */
|
|
18
|
+
export declare const codeSearchInputSchema: {
|
|
19
|
+
[key: string]: CodeSearchJsonValue;
|
|
20
|
+
};
|
|
21
|
+
export interface CodeSearchArguments {
|
|
22
|
+
question: string;
|
|
23
|
+
keywords: string[];
|
|
24
|
+
subQuestions: string[];
|
|
25
|
+
paths: string[];
|
|
26
|
+
}
|
|
27
|
+
/** Invalid tool arguments; the message is written for the model. */
|
|
28
|
+
export declare class CodeSearchArgumentError extends Error {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/** Validate and normalize tool arguments (trim, drop empty entries, dedupe, workspace-relative paths). */
|
|
32
|
+
export declare function parseCodeSearchArguments(args: Record<string, unknown>): CodeSearchArguments;
|
|
33
|
+
/** Short model-facing text for a failed code_search call. */
|
|
34
|
+
export declare function renderCodeSearchError(error: unknown): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* windows.ts - turn hit lines into readable passages.
|
|
3
|
+
*
|
|
4
|
+
* For each hit: walk up (<= maxUp lines) to the nearest declaration line at lower-or-equal indentation
|
|
5
|
+
* whose block encloses the hit (function/class/const/export/interface/type/enum/describe/route handler,
|
|
6
|
+
* markdown heading, SQL statement, python def/class), then walk down to where that block closes
|
|
7
|
+
* (<= maxDown lines below the hit). No enclosing declaration -> fixed context around the hit, labelled
|
|
8
|
+
* with the nearest enclosing declaration further up. Overlapping windows merge; windows longer than
|
|
9
|
+
* maxWindowLines split around hit clusters; each file keeps its best windowsPerFile windows.
|
|
10
|
+
* All line numbers in this module's public API are 1-based. A line past the end of the file as read (it
|
|
11
|
+
* changed after ripgrep saw it, or could not be read) is skipped by the callers and treated as blank here.
|
|
12
|
+
*/
|
|
13
|
+
import type { CodeSearchConfig } from "./config.js";
|
|
14
|
+
import type { HitLine, KeywordInfo } from "./recall.js";
|
|
15
|
+
export type Lang = "brace" | "indent" | "markdown" | "sql" | "other";
|
|
16
|
+
export interface Window {
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
/** Hit lines inside the window (1-based). */
|
|
20
|
+
hits: number[];
|
|
21
|
+
/** Enclosing declaration when it is above the window start (or the window starts at it). */
|
|
22
|
+
label?: {
|
|
23
|
+
line: number;
|
|
24
|
+
text: string;
|
|
25
|
+
} | undefined;
|
|
26
|
+
kind: "hit" | "header" | "def";
|
|
27
|
+
score: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function langOf(path: string): Lang;
|
|
30
|
+
export declare function indentOf(line: string): number;
|
|
31
|
+
export declare function isDeclLine(line: string, lang: Lang): boolean;
|
|
32
|
+
/** Remove string literals and comments so bracket counting is roughly right. */
|
|
33
|
+
export declare function stripForBrackets(line: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* 0-based index of the last line of the block starting at 0-based line d, or null if unknown
|
|
36
|
+
* (no structure, or longer than maxScan lines).
|
|
37
|
+
*/
|
|
38
|
+
export declare function blockEnd(lines: string[], d: number, lang: Lang, maxScan?: number): number | null;
|
|
39
|
+
/** Nearest declaration above (0-based idx) with indentation below the given one; cheap, for labels only. */
|
|
40
|
+
export declare function nearestEnclosingLabel(lines: string[], idx: number, lang: Lang, maxScan?: number): {
|
|
41
|
+
line: number;
|
|
42
|
+
text: string;
|
|
43
|
+
} | undefined;
|
|
44
|
+
/** The window around one hit line (1-based in, 1-based out). */
|
|
45
|
+
export declare function enclosingWindow(lines: string[], hitLine: number, lang: Lang, cfg: CodeSearchConfig): Window;
|
|
46
|
+
/** Grow windows shorter than minWindowLines with surrounding context (1/3 above, 2/3 below). */
|
|
47
|
+
export declare function padWindow(win: Window, nLines: number, cfg: CodeSearchConfig): Window;
|
|
48
|
+
/** Merge overlapping windows or windows separated by <= gap lines. Input any order; output by start. */
|
|
49
|
+
export declare function mergeWindows(ws: Window[], gap: number): Window[];
|
|
50
|
+
/** Split a window longer than maxLines into chunks around its hit clusters (chunks without hits are dropped). */
|
|
51
|
+
export declare function splitWindow(w: Window, maxLines: number, before?: number): Window[];
|
|
52
|
+
export declare function keywordRegex(k: KeywordInfo): RegExp | null;
|
|
53
|
+
export declare function textHasKeyword(text: string, k: KeywordInfo): boolean;
|
|
54
|
+
export declare function keywordsInRange(lines: string[], start: number, end: number, keywords: KeywordInfo[]): number[];
|
|
55
|
+
export declare function scoreWindow(lines: string[], w: Window, keywords: KeywordInfo[], hitWeight?: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Windows for one file: window the strongest hit lines (skipping hits already covered), merge,
|
|
58
|
+
* split long ones, score, keep the best windowsPerFile, return in line order.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildFileWindows(lines: string[], hitLines: HitLine[], keywords: KeywordInfo[], lang: Lang, cfg: CodeSearchConfig, render?: RenderOpts): Window[];
|
|
61
|
+
/** Window for a definition found at 1-based defLine (lead following). */
|
|
62
|
+
export declare function definitionWindow(lines: string[], defLine: number, lang: Lang, cfg: CodeSearchConfig, render?: RenderOpts): Window;
|
|
63
|
+
export interface RenderOpts {
|
|
64
|
+
/** Lines longer than this are cut (with an explicit marker). */
|
|
65
|
+
maxLineChars: number;
|
|
66
|
+
/** When a cut line has a match beyond the head, the cut keeps the region around the first match. */
|
|
67
|
+
needles?: RegExp[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Cut one over-long line to about maxChars, marked explicitly. If a needle matches beyond the first ~60% of
|
|
71
|
+
* the budget, keep a short head plus the region around the match (prose docs such as AGENTS.md have
|
|
72
|
+
* single-line paragraphs of 1-6k chars whose key sentence is often far from the start).
|
|
73
|
+
*/
|
|
74
|
+
export declare function cutLine(t: string, maxChars: number, needles?: RegExp[]): string;
|
|
75
|
+
/** Render lines[start..end] (1-based inclusive) as `N| text`, cutting very long lines with an explicit marker. */
|
|
76
|
+
export declare function renderLines(lines: string[], start: number, end: number, opts: number | RenderOpts): string;
|
|
77
|
+
/** Rendered length of one line (as renderLines would produce it, plus the newline). */
|
|
78
|
+
export declare function renderedLineLength(lines: string[], i: number, o: RenderOpts): number;
|
|
79
|
+
/**
|
|
80
|
+
* Split a window whose rendered text exceeds maxChars into whole-line sub-windows around its hits:
|
|
81
|
+
* each sub-window starts a few lines above the first uncovered hit (up to a quarter of the budget) and
|
|
82
|
+
* extends down until the budget is used. Windows without hits (headers, definitions) keep their top.
|
|
83
|
+
*/
|
|
84
|
+
export declare function splitByChars(lines: string[], w: Window, maxChars: number, o: RenderOpts, ctxUp?: number): Window[];
|
|
85
|
+
export declare function splitLines(text: string): string[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The only way the code_search engine touches files and processes. The sandbox side implements it.
|
|
3
|
+
*
|
|
4
|
+
* The engine passes ripgrep only these flags, so an adapter may enforce an allowlist:
|
|
5
|
+
* --files, --null, --line-number, --with-filename, --no-heading, --color never, -i, -w, --no-require-git,
|
|
6
|
+
* --hidden, -m N, --max-columns N, --max-filesize N, -g GLOB, -e PATTERN, then `--` followed by
|
|
7
|
+
* workspace-relative paths ("." or paths without a leading "-", no absolute paths, no "..").
|
|
8
|
+
* A PATTERN is never longer than CODE_SEARCH_MAX_PATTERN_CHARS: the engine splits a longer alternation
|
|
9
|
+
* into several ripgrep calls and merges their output.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Longest `-e` pattern the engine passes to ripgrep, so an adapter may cap pattern length (the sandbox
|
|
13
|
+
* adapter rejects patterns over 16,384 characters).
|
|
14
|
+
*/
|
|
15
|
+
export declare const CODE_SEARCH_MAX_PATTERN_CHARS = 16000;
|
|
16
|
+
export type CodeSearchRipgrepResult = {
|
|
17
|
+
stdout: string;
|
|
18
|
+
exitCode: number | null;
|
|
19
|
+
truncated: boolean;
|
|
20
|
+
timedOut: boolean;
|
|
21
|
+
};
|
|
22
|
+
export interface CodeSearchWorkspace {
|
|
23
|
+
/** Run ripgrep in the workspace root. `args` excludes the binary. stdout is exactly what rg prints (up to the adapter's byte cap; `truncated` reports a cut). exitCode follows rg: 0 matches, 1 none, 2 error. Throws CodeSearchWorkspaceError when ripgrep is missing or the workspace is unreachable. */
|
|
24
|
+
ripgrep(args: readonly string[], options: {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
timeoutMs: number;
|
|
27
|
+
}): Promise<CodeSearchRipgrepResult>;
|
|
28
|
+
/** Read a workspace-relative file as UTF-8. Null when missing. */
|
|
29
|
+
readText(path: string, options: {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
maxBytes: number;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
text: string;
|
|
34
|
+
truncated: boolean;
|
|
35
|
+
binary: boolean;
|
|
36
|
+
} | null>;
|
|
37
|
+
/** Classify workspace-relative paths. */
|
|
38
|
+
pathKinds(paths: readonly string[], options: {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<Record<string, "file" | "directory" | "missing">>;
|
|
41
|
+
}
|
|
42
|
+
export declare class CodeSearchWorkspaceError extends Error {
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Thrown by an adapter when the ripgrep binary is not installed, so the tool can tell the model to use
|
|
46
|
+
* other search commands. A plain CodeSearchWorkspaceError whose message says ripgrep is missing is
|
|
47
|
+
* recognised too.
|
|
48
|
+
*/
|
|
49
|
+
export declare class CodeSearchRipgrepMissingError extends CodeSearchWorkspaceError {
|
|
50
|
+
constructor(message?: string);
|
|
51
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { JEV_CHARS_PER_TOKEN, JEV_DEFAULT_BASE_URL, JEV_DEFAULT_LIMITS, JEV_DEFAULT_MODEL, JEV_PRICE_PER_MILLION_INPUT_TOKENS_USD, JevClient, JevError, JevLimiter, JevRequestError, JevUnavailableError, estimateJevTokens, jevCostUsd, noul, planChunks, type JevAnswer, type JevAnswerFor, type JevAskOptions, type JevAskResult, type JevChoiceAnswer, type JevChoiceQuestion, type JevClientOptions, type JevFetch, type JevInstructions, type JevLimits, type JevNoulAnswer, type JevNoulQuestion, type JevQuestion, type JevScoreAnswer, type JevScoreQuestion, } from "./client.js";
|
|
2
|
+
export { JevCircuitBreaker, type JevCircuitBreakerOptions, type JevCircuitLease, type JevCircuitState, type JevCircuitStatus, } from "./circuit-breaker.js";
|
|
3
|
+
export { CODE_SEARCH_DEFAULT_BUDGET_TOKENS, CODE_SEARCH_ENGINE_VERSION, runCodeSearch, type CodeSearchInput, type CodeSearchResult, type CodeSearchStats, type CodeSearchStatus, } from "./code-search/search.js";
|
|
4
|
+
export { CODE_SEARCH_MAX_PATTERN_CHARS, CodeSearchRipgrepMissingError, CodeSearchWorkspaceError, type CodeSearchRipgrepResult, type CodeSearchWorkspace, } from "./code-search/workspace.js";
|
|
5
|
+
export { DEFAULT_CODE_SEARCH_CONFIG, codeSearchConfig, type CodeSearchConfig, type CodeSearchConfigOverride, } from "./code-search/config.js";
|
|
6
|
+
export { CODE_SEARCH_LIMITS, CODE_SEARCH_TOOL_DESCRIPTION, CODE_SEARCH_TOOL_NAME, CodeSearchArgumentError, codeSearchInputSchema, parseCodeSearchArguments, renderCodeSearchError, type CodeSearchArguments, type CodeSearchJsonValue, } from "./code-search/tool.js";
|