@oscharko-dev/keiko-workspace 0.2.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/dist/.tsbuildinfo +1 -0
- package/dist/binaryDetect.d.ts +6 -0
- package/dist/binaryDetect.d.ts.map +1 -0
- package/dist/binaryDetect.js +20 -0
- package/dist/contextPack.d.ts +24 -0
- package/dist/contextPack.d.ts.map +1 -0
- package/dist/contextPack.js +118 -0
- package/dist/detect.d.ts +5 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +144 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +199 -0
- package/dist/document-extraction.d.ts +44 -0
- package/dist/document-extraction.d.ts.map +1 -0
- package/dist/document-extraction.js +372 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/fs.d.ts +25 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +69 -0
- package/dist/gitHistory.d.ts +3 -0
- package/dist/gitHistory.d.ts.map +1 -0
- package/dist/gitHistory.js +317 -0
- package/dist/ignore.d.ts +15 -0
- package/dist/ignore.d.ts.map +1 -0
- package/dist/ignore.js +248 -0
- package/dist/importGraph.d.ts +3 -0
- package/dist/importGraph.d.ts.map +1 -0
- package/dist/importGraph.js +131 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +38 -0
- package/dist/realpath.d.ts +9 -0
- package/dist/realpath.d.ts.map +1 -0
- package/dist/realpath.js +72 -0
- package/dist/repoSearch.d.ts +46 -0
- package/dist/repoSearch.d.ts.map +1 -0
- package/dist/repoSearch.js +350 -0
- package/dist/repoSearchEntries.d.ts +15 -0
- package/dist/repoSearchEntries.d.ts.map +1 -0
- package/dist/repoSearchEntries.js +106 -0
- package/dist/repoSearchLineSelection.d.ts +18 -0
- package/dist/repoSearchLineSelection.d.ts.map +1 -0
- package/dist/repoSearchLineSelection.js +43 -0
- package/dist/repoSearchMatchers.d.ts +8 -0
- package/dist/repoSearchMatchers.d.ts.map +1 -0
- package/dist/repoSearchMatchers.js +414 -0
- package/dist/repoSearchPolicy.d.ts +34 -0
- package/dist/repoSearchPolicy.d.ts.map +1 -0
- package/dist/repoSearchPolicy.js +342 -0
- package/dist/repoSearchRegexSafety.d.ts +2 -0
- package/dist/repoSearchRegexSafety.d.ts.map +1 -0
- package/dist/repoSearchRegexSafety.js +15 -0
- package/dist/repoSearchScan.d.ts +62 -0
- package/dist/repoSearchScan.d.ts.map +1 -0
- package/dist/repoSearchScan.js +292 -0
- package/dist/retrieval.d.ts +10 -0
- package/dist/retrieval.d.ts.map +1 -0
- package/dist/retrieval.js +74 -0
- package/dist/stableId.d.ts +4 -0
- package/dist/stableId.d.ts.map +1 -0
- package/dist/stableId.js +49 -0
- package/dist/structuralAdapters.d.ts +27 -0
- package/dist/structuralAdapters.d.ts.map +1 -0
- package/dist/structuralAdapters.js +87 -0
- package/dist/summary.d.ts +4 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/summary.js +54 -0
- package/dist/testSourcePairing.d.ts +3 -0
- package/dist/testSourcePairing.d.ts.map +1 -0
- package/dist/testSourcePairing.js +179 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/package.json +35 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
const METADATA_FILENAMES = new Set([
|
|
2
|
+
"package.json",
|
|
3
|
+
"tsconfig.json",
|
|
4
|
+
"tsconfig.base.json",
|
|
5
|
+
"tsconfig.build.json",
|
|
6
|
+
"vite.config.ts",
|
|
7
|
+
"vite.config.js",
|
|
8
|
+
"vitest.config.ts",
|
|
9
|
+
"vitest.config.js",
|
|
10
|
+
"jest.config.ts",
|
|
11
|
+
"jest.config.js",
|
|
12
|
+
"playwright.config.ts",
|
|
13
|
+
"playwright.config.js",
|
|
14
|
+
"next.config.ts",
|
|
15
|
+
"next.config.js",
|
|
16
|
+
"eslint.config.ts",
|
|
17
|
+
"eslint.config.js",
|
|
18
|
+
]);
|
|
19
|
+
const OVERVIEW_FILENAMES = new Set([
|
|
20
|
+
"readme.md",
|
|
21
|
+
"agents.md",
|
|
22
|
+
"contributing.md",
|
|
23
|
+
"architecture.md",
|
|
24
|
+
"docs/architecture.md",
|
|
25
|
+
"docs/overview.md",
|
|
26
|
+
"docs/readme.md",
|
|
27
|
+
]);
|
|
28
|
+
const LOCKFILE_FILENAMES = new Set([
|
|
29
|
+
"bun.lock",
|
|
30
|
+
"bun.lockb",
|
|
31
|
+
"cargo.lock",
|
|
32
|
+
"composer.lock",
|
|
33
|
+
"gemfile.lock",
|
|
34
|
+
"package-lock.json",
|
|
35
|
+
"pnpm-lock.yaml",
|
|
36
|
+
"yarn.lock",
|
|
37
|
+
]);
|
|
38
|
+
const LOW_VALUE_SEGMENTS = new Set([
|
|
39
|
+
".parcel-cache",
|
|
40
|
+
".svelte-kit",
|
|
41
|
+
".vercel",
|
|
42
|
+
"coverage",
|
|
43
|
+
"dist",
|
|
44
|
+
"generated",
|
|
45
|
+
"storybook-static",
|
|
46
|
+
"tmp",
|
|
47
|
+
]);
|
|
48
|
+
const LOW_VALUE_IGNORE_LINES = Object.freeze([
|
|
49
|
+
".parcel-cache/",
|
|
50
|
+
".svelte-kit/",
|
|
51
|
+
".vercel/",
|
|
52
|
+
"coverage/",
|
|
53
|
+
"dist/",
|
|
54
|
+
"generated/",
|
|
55
|
+
"storybook-static/",
|
|
56
|
+
"tmp/",
|
|
57
|
+
"bun.lock",
|
|
58
|
+
"bun.lockb",
|
|
59
|
+
"cargo.lock",
|
|
60
|
+
"composer.lock",
|
|
61
|
+
"Gemfile.lock",
|
|
62
|
+
"package-lock.json",
|
|
63
|
+
"pnpm-lock.yaml",
|
|
64
|
+
"yarn.lock",
|
|
65
|
+
]);
|
|
66
|
+
const SOURCE_EXTENSIONS = new Set([
|
|
67
|
+
"cjs",
|
|
68
|
+
"cts",
|
|
69
|
+
"go",
|
|
70
|
+
"java",
|
|
71
|
+
"js",
|
|
72
|
+
"jsx",
|
|
73
|
+
"mjs",
|
|
74
|
+
"mts",
|
|
75
|
+
"py",
|
|
76
|
+
"rs",
|
|
77
|
+
"ts",
|
|
78
|
+
"tsx",
|
|
79
|
+
"vue",
|
|
80
|
+
]);
|
|
81
|
+
const DOC_EXTENSIONS = new Set(["adoc", "md", "mdx", "rst", "txt"]);
|
|
82
|
+
const TEST_FILE_RE = /(?:^|[./_-])(?:test|spec|fixture|mock)s?(?:[./_-]|$)/iu;
|
|
83
|
+
// Identifier tokens with a SINGLE greedy quantifier — no two overlapping `[A-Za-z0-9_$]*` runs
|
|
84
|
+
// around `[A-Z]`, which is a polynomial-ReDoS shape on uncontrolled query text (CodeQL). The
|
|
85
|
+
// camelCase test (an uppercase at position >= 1) is applied separately as a constant-width probe.
|
|
86
|
+
const IDENTIFIER_TOKEN_RE = /\b[A-Za-z_$][A-Za-z0-9_$]*\b/gu;
|
|
87
|
+
const HAS_INNER_UPPERCASE_RE = /[A-Za-z0-9_$][A-Z]/u;
|
|
88
|
+
const TOKEN_RE = /[A-Za-z0-9_.-]{3,}/gu;
|
|
89
|
+
function emptyBucketCounts() {
|
|
90
|
+
return {
|
|
91
|
+
"canonical-metadata": 0,
|
|
92
|
+
"overview-doc": 0,
|
|
93
|
+
"exact-path": 0,
|
|
94
|
+
"symbol-source": 0,
|
|
95
|
+
source: 0,
|
|
96
|
+
test: 0,
|
|
97
|
+
docs: 0,
|
|
98
|
+
lockfile: 0,
|
|
99
|
+
"low-value": 0,
|
|
100
|
+
other: 0,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function basename(scopePath) {
|
|
104
|
+
const index = scopePath.lastIndexOf("/");
|
|
105
|
+
return index >= 0 ? scopePath.slice(index + 1) : scopePath;
|
|
106
|
+
}
|
|
107
|
+
function extension(scopePath) {
|
|
108
|
+
const name = basename(scopePath).toLowerCase();
|
|
109
|
+
const dot = name.lastIndexOf(".");
|
|
110
|
+
return dot < 0 ? "" : name.slice(dot + 1);
|
|
111
|
+
}
|
|
112
|
+
function normalizedPath(scopePath) {
|
|
113
|
+
return scopePath.split("\\").join("/").toLowerCase();
|
|
114
|
+
}
|
|
115
|
+
function pathSegments(scopePath) {
|
|
116
|
+
return normalizedPath(scopePath)
|
|
117
|
+
.split("/")
|
|
118
|
+
.filter((segment) => segment.length > 0);
|
|
119
|
+
}
|
|
120
|
+
function isLockfile(scopePath) {
|
|
121
|
+
return LOCKFILE_FILENAMES.has(basename(scopePath).toLowerCase());
|
|
122
|
+
}
|
|
123
|
+
function hasLowValueSegment(scopePath) {
|
|
124
|
+
return pathSegments(scopePath).some((segment) => LOW_VALUE_SEGMENTS.has(segment));
|
|
125
|
+
}
|
|
126
|
+
function normalizedQueryTerms(query) {
|
|
127
|
+
const terms = new Set();
|
|
128
|
+
for (const match of query.text.matchAll(TOKEN_RE)) {
|
|
129
|
+
terms.add(match[0].toLowerCase());
|
|
130
|
+
}
|
|
131
|
+
for (const match of query.text.matchAll(IDENTIFIER_TOKEN_RE)) {
|
|
132
|
+
if (HAS_INNER_UPPERCASE_RE.test(match[0])) {
|
|
133
|
+
terms.add(match[0].toLowerCase());
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return [...terms];
|
|
137
|
+
}
|
|
138
|
+
function bucketByPath(scopePath) {
|
|
139
|
+
const path = normalizedPath(scopePath);
|
|
140
|
+
const name = basename(path);
|
|
141
|
+
const ext = extension(path);
|
|
142
|
+
if (METADATA_FILENAMES.has(name)) {
|
|
143
|
+
return "canonical-metadata";
|
|
144
|
+
}
|
|
145
|
+
if (OVERVIEW_FILENAMES.has(path) || OVERVIEW_FILENAMES.has(name)) {
|
|
146
|
+
return "overview-doc";
|
|
147
|
+
}
|
|
148
|
+
if (isLockfile(path)) {
|
|
149
|
+
return "lockfile";
|
|
150
|
+
}
|
|
151
|
+
if (hasLowValueSegment(path)) {
|
|
152
|
+
return "low-value";
|
|
153
|
+
}
|
|
154
|
+
if (TEST_FILE_RE.test(path)) {
|
|
155
|
+
return "test";
|
|
156
|
+
}
|
|
157
|
+
if (SOURCE_EXTENSIONS.has(ext)) {
|
|
158
|
+
return "source";
|
|
159
|
+
}
|
|
160
|
+
if (DOC_EXTENSIONS.has(ext)) {
|
|
161
|
+
return "docs";
|
|
162
|
+
}
|
|
163
|
+
return "other";
|
|
164
|
+
}
|
|
165
|
+
function bucketScore(bucket, intent) {
|
|
166
|
+
if (intent === "project-metadata") {
|
|
167
|
+
return metadataBucketScore(bucket);
|
|
168
|
+
}
|
|
169
|
+
if (intent === "repository-overview") {
|
|
170
|
+
return overviewBucketScore(bucket);
|
|
171
|
+
}
|
|
172
|
+
if (intent === "targeted-code-search" || intent === "diagnostic-search") {
|
|
173
|
+
return targetedBucketScore(bucket);
|
|
174
|
+
}
|
|
175
|
+
return genericBucketScore(bucket);
|
|
176
|
+
}
|
|
177
|
+
function metadataBucketScore(bucket) {
|
|
178
|
+
const scores = {
|
|
179
|
+
"canonical-metadata": 100,
|
|
180
|
+
"overview-doc": 70,
|
|
181
|
+
"exact-path": 95,
|
|
182
|
+
"symbol-source": 80,
|
|
183
|
+
source: 45,
|
|
184
|
+
test: 40,
|
|
185
|
+
docs: 55,
|
|
186
|
+
lockfile: 15,
|
|
187
|
+
"low-value": 5,
|
|
188
|
+
other: 20,
|
|
189
|
+
};
|
|
190
|
+
return scores[bucket];
|
|
191
|
+
}
|
|
192
|
+
function overviewBucketScore(bucket) {
|
|
193
|
+
const scores = {
|
|
194
|
+
"canonical-metadata": 75,
|
|
195
|
+
"overview-doc": 100,
|
|
196
|
+
"exact-path": 95,
|
|
197
|
+
"symbol-source": 80,
|
|
198
|
+
source: 50,
|
|
199
|
+
test: 35,
|
|
200
|
+
docs: 70,
|
|
201
|
+
lockfile: 5,
|
|
202
|
+
"low-value": 5,
|
|
203
|
+
other: 20,
|
|
204
|
+
};
|
|
205
|
+
return scores[bucket];
|
|
206
|
+
}
|
|
207
|
+
function targetedBucketScore(bucket) {
|
|
208
|
+
const scores = {
|
|
209
|
+
"canonical-metadata": 65,
|
|
210
|
+
"overview-doc": 35,
|
|
211
|
+
"exact-path": 100,
|
|
212
|
+
"symbol-source": 95,
|
|
213
|
+
source: 80,
|
|
214
|
+
test: 55,
|
|
215
|
+
docs: 25,
|
|
216
|
+
lockfile: 5,
|
|
217
|
+
"low-value": 5,
|
|
218
|
+
other: 20,
|
|
219
|
+
};
|
|
220
|
+
return scores[bucket];
|
|
221
|
+
}
|
|
222
|
+
function genericBucketScore(bucket) {
|
|
223
|
+
const scores = {
|
|
224
|
+
"canonical-metadata": 80,
|
|
225
|
+
"overview-doc": 65,
|
|
226
|
+
"exact-path": 90,
|
|
227
|
+
"symbol-source": 85,
|
|
228
|
+
source: 60,
|
|
229
|
+
test: 45,
|
|
230
|
+
docs: 50,
|
|
231
|
+
lockfile: 5,
|
|
232
|
+
"low-value": 5,
|
|
233
|
+
other: 20,
|
|
234
|
+
};
|
|
235
|
+
return scores[bucket];
|
|
236
|
+
}
|
|
237
|
+
function pathTermBonus(scopePath, terms) {
|
|
238
|
+
const path = normalizedPath(scopePath);
|
|
239
|
+
const name = basename(path);
|
|
240
|
+
let score = 0;
|
|
241
|
+
for (const term of terms) {
|
|
242
|
+
if (name === term || name.startsWith(`${term}.`)) {
|
|
243
|
+
score = Math.max(score, 25);
|
|
244
|
+
}
|
|
245
|
+
else if (path.includes(term)) {
|
|
246
|
+
score = Math.max(score, 12);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return score;
|
|
250
|
+
}
|
|
251
|
+
function depthPenalty(scopePath) {
|
|
252
|
+
return Math.min(pathSegments(scopePath).length, 12);
|
|
253
|
+
}
|
|
254
|
+
function priorityForFile(file, terms, policy) {
|
|
255
|
+
return (bucketScore(bucketByPath(file.relativePath), policy.intent) +
|
|
256
|
+
pathTermBonus(file.relativePath, terms) -
|
|
257
|
+
depthPenalty(file.relativePath));
|
|
258
|
+
}
|
|
259
|
+
function bucketCounts(files) {
|
|
260
|
+
const counts = emptyBucketCounts();
|
|
261
|
+
for (const file of files) {
|
|
262
|
+
counts[bucketByPath(file.relativePath)] += 1;
|
|
263
|
+
}
|
|
264
|
+
return counts;
|
|
265
|
+
}
|
|
266
|
+
function sortFiles(files, query, policy) {
|
|
267
|
+
// Score each file ONCE (query tokenization + path bucketing are O(path) and were previously
|
|
268
|
+
// recomputed twice per comparison — O(n log n) blocking work on the 2000-file candidate cap).
|
|
269
|
+
// Tie-break on raw code-point order, not localeCompare, so evidence ordering is reproducible
|
|
270
|
+
// across locales/ICU builds (regulated-delivery determinism).
|
|
271
|
+
const terms = normalizedQueryTerms(query);
|
|
272
|
+
const scored = files.map((file) => ({ file, score: priorityForFile(file, terms, policy) }));
|
|
273
|
+
scored.sort((a, b) => {
|
|
274
|
+
if (a.score !== b.score)
|
|
275
|
+
return b.score - a.score;
|
|
276
|
+
if (a.file.relativePath < b.file.relativePath)
|
|
277
|
+
return -1;
|
|
278
|
+
return a.file.relativePath > b.file.relativePath ? 1 : 0;
|
|
279
|
+
});
|
|
280
|
+
return scored.map((entry) => entry.file);
|
|
281
|
+
}
|
|
282
|
+
export function resolveSearchPolicy(hasExplicitRelativePaths, hints) {
|
|
283
|
+
const mode = hasExplicitRelativePaths ? "explicit-scope" : "workspace-root-default";
|
|
284
|
+
const intent = hints?.retrievalIntent ?? "generic";
|
|
285
|
+
return {
|
|
286
|
+
mode,
|
|
287
|
+
intent,
|
|
288
|
+
applyGitignore: mode === "workspace-root-default",
|
|
289
|
+
omitLowValueWorkspaceFiles: mode === "workspace-root-default",
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
// The legacy `gatherCandidates(scope, limits, fs)` overload predates the search-policy work and is
|
|
293
|
+
// still used by importGraph / testSourcePairing, which expect FULL-tree discovery (no .gitignore
|
|
294
|
+
// subset, no low-value omission) — that was the hardcoded `applyGitignore: false` behavior before
|
|
295
|
+
// this change. Resolving the default workspace-root policy for them would silently start dropping
|
|
296
|
+
// gitignored / low-value files from those callers, so they get this neutral policy instead.
|
|
297
|
+
export function legacyDiscoveryPolicy(hasExplicitRelativePaths) {
|
|
298
|
+
return {
|
|
299
|
+
mode: hasExplicitRelativePaths ? "explicit-scope" : "workspace-root-default",
|
|
300
|
+
intent: "generic",
|
|
301
|
+
applyGitignore: false,
|
|
302
|
+
omitLowValueWorkspaceFiles: false,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
export function policyOmissionReason(scopePath, policy) {
|
|
306
|
+
if (!policy.omitLowValueWorkspaceFiles) {
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
if (isLockfile(scopePath) && policy.intent !== "project-metadata") {
|
|
310
|
+
return "generated";
|
|
311
|
+
}
|
|
312
|
+
return hasLowValueSegment(scopePath) ? "generated" : undefined;
|
|
313
|
+
}
|
|
314
|
+
export function extraIgnoreLinesForSearch(policy) {
|
|
315
|
+
return policy.omitLowValueWorkspaceFiles ? LOW_VALUE_IGNORE_LINES : [];
|
|
316
|
+
}
|
|
317
|
+
export function orderCandidatesForSearch(files, query, policy, ignoredByDiscovery, deniedByDiscovery) {
|
|
318
|
+
const ordered = sortFiles(files, query, policy);
|
|
319
|
+
return {
|
|
320
|
+
files: ordered,
|
|
321
|
+
diagnostics: {
|
|
322
|
+
policyMode: policy.mode,
|
|
323
|
+
intent: policy.intent,
|
|
324
|
+
filesDiscovered: files.length,
|
|
325
|
+
filesAfterPolicy: ordered.length,
|
|
326
|
+
ignoredByDiscovery,
|
|
327
|
+
deniedByDiscovery,
|
|
328
|
+
candidateBuckets: bucketCounts(ordered),
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
export function shouldScoreContent(query, text, policy) {
|
|
333
|
+
if (query.kind !== "natural-language" && query.kind !== "exact-symbol") {
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
if (policy.intent === "repository-overview" || policy.intent === "project-metadata") {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
const haystack = query.caseSensitive ? text : text.toLowerCase();
|
|
340
|
+
const terms = normalizedQueryTerms(query).filter((term) => term.length >= 4);
|
|
341
|
+
return terms.length === 0 || terms.some((term) => haystack.includes(term));
|
|
342
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoSearchRegexSafety.d.ts","sourceRoot":"","sources":["../src/repoSearchRegexSafety.ts"],"names":[],"mappings":"AAKA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const MAX_REGEX_LENGTH = 200;
|
|
2
|
+
const DANGEROUS_GROUP_OR_CLASS_REPETITION = /\([^)]*\)[+*{]|\[[^\]]*\][+*{]/;
|
|
3
|
+
const ADJACENT_QUANTIFIED_ATOMS = /(?:\\.|[^\\()[\]{}+*?|])(?:[+*]|\{\d+(?:,\d*)?\})(?:\\.|[^\\()[\]{}+*?|])(?:[+*]|\{\d+(?:,\d*)?\})/;
|
|
4
|
+
export function regexSafetyIssue(source) {
|
|
5
|
+
if (source.length > MAX_REGEX_LENGTH) {
|
|
6
|
+
return `regex too long: ${String(source.length)} > ${String(MAX_REGEX_LENGTH)}`;
|
|
7
|
+
}
|
|
8
|
+
if (DANGEROUS_GROUP_OR_CLASS_REPETITION.test(source)) {
|
|
9
|
+
return "regex contains repetition over a group or character class (potential catastrophic backtracking)";
|
|
10
|
+
}
|
|
11
|
+
if (ADJACENT_QUANTIFIED_ATOMS.test(source)) {
|
|
12
|
+
return "regex contains adjacent quantified atoms (potential catastrophic backtracking)";
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { CandidateFile, CandidateOmissionReason, EvidenceAtom, EvidenceAtomProvenanceKind, RetrievalQuery } from "@oscharko-dev/keiko-contracts/connected-context";
|
|
2
|
+
import type { WorkspaceFs } from "./fs.js";
|
|
3
|
+
import type { LineMatcher } from "./repoSearchMatchers.js";
|
|
4
|
+
import { type SearchDiagnostics, type SearchPolicy } from "./repoSearchPolicy.js";
|
|
5
|
+
import type { DiscoveredFile, WorkspaceInfo } from "./types.js";
|
|
6
|
+
export declare function isImageScopePath(scopePath: string): boolean;
|
|
7
|
+
export interface ScopeShape {
|
|
8
|
+
readonly workspace: WorkspaceInfo;
|
|
9
|
+
readonly scopeId: string;
|
|
10
|
+
readonly relativePaths: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface LimitsShape {
|
|
13
|
+
readonly maxFilesScanned: number;
|
|
14
|
+
readonly maxMatchesReturned: number;
|
|
15
|
+
readonly maxBytesPerFileScanned: number;
|
|
16
|
+
readonly elapsedMsMax: number;
|
|
17
|
+
}
|
|
18
|
+
export interface AtomShape {
|
|
19
|
+
readonly scopeId: string;
|
|
20
|
+
readonly scopePath: string;
|
|
21
|
+
readonly lineRange: {
|
|
22
|
+
readonly startLine: number;
|
|
23
|
+
readonly endLine: number;
|
|
24
|
+
} | undefined;
|
|
25
|
+
readonly provenanceKind: EvidenceAtomProvenanceKind;
|
|
26
|
+
readonly tool: string;
|
|
27
|
+
readonly queryFingerprint: string;
|
|
28
|
+
readonly score: number;
|
|
29
|
+
readonly emittedAtMs: number;
|
|
30
|
+
}
|
|
31
|
+
export declare function buildAtom(shape: AtomShape): EvidenceAtom;
|
|
32
|
+
export declare function buildCandidate(scopePath: string, omitted: CandidateOmissionReason | undefined): CandidateFile;
|
|
33
|
+
export interface CandidateSet {
|
|
34
|
+
readonly files: readonly DiscoveredFile[];
|
|
35
|
+
readonly truncated: boolean;
|
|
36
|
+
readonly diagnostics: SearchDiagnostics;
|
|
37
|
+
}
|
|
38
|
+
export declare function gatherCandidates(scope: ScopeShape, limits: LimitsShape, fs: WorkspaceFs): CandidateSet;
|
|
39
|
+
export declare function gatherCandidates(scope: ScopeShape, query: RetrievalQuery, limits: LimitsShape, fs: WorkspaceFs, policy: SearchPolicy): CandidateSet;
|
|
40
|
+
export declare function probeBinary(fs: WorkspaceFs, abs: string, size: number): Promise<boolean>;
|
|
41
|
+
export interface SearchTextRunner {
|
|
42
|
+
readonly scope: ScopeShape;
|
|
43
|
+
readonly limits: LimitsShape;
|
|
44
|
+
readonly fs: WorkspaceFs;
|
|
45
|
+
readonly nowMs: () => number;
|
|
46
|
+
readonly startMs: number;
|
|
47
|
+
readonly signal?: AbortSignal | undefined;
|
|
48
|
+
readonly matcher: LineMatcher;
|
|
49
|
+
readonly fingerprint: string;
|
|
50
|
+
readonly policy: SearchPolicy;
|
|
51
|
+
readonly query: RetrievalQuery;
|
|
52
|
+
}
|
|
53
|
+
export interface RunState {
|
|
54
|
+
filesScanned: number;
|
|
55
|
+
matchesReturned: number;
|
|
56
|
+
truncated: boolean;
|
|
57
|
+
}
|
|
58
|
+
export declare function elapsed(runner: SearchTextRunner): number;
|
|
59
|
+
export declare function hitLimit(runner: SearchTextRunner, state: RunState): boolean;
|
|
60
|
+
export declare function isIoError(err: unknown): boolean;
|
|
61
|
+
export declare function scanFile(runner: SearchTextRunner, file: DiscoveredFile, state: RunState, atoms: EvidenceAtom[], candidates: CandidateFile[]): Promise<void>;
|
|
62
|
+
//# sourceMappingURL=repoSearchScan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoSearchScan.d.ts","sourceRoot":"","sources":["../src/repoSearchScan.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,uBAAuB,EACvB,YAAY,EACZ,0BAA0B,EAC1B,cAAc,EACf,MAAM,iDAAiD,CAAC;AAOzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,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