Skip to content

Commit cee9c3c

Browse files
committed
chore: bump min. node version to 20 (lts)
1 parent d001a91 commit cee9c3c

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"agentic-knowledge": "packages/cli/dist/index.js"
99
},
1010
"engines": {
11-
"node": ">=18.0.0",
11+
"node": ">=20.0.0",
1212
"pnpm": ">=9.0.0"
1313
},
1414
"packageManager": "pnpm@10.29.3",

packages/core/src/search/searcher.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ async function tryLoadMiniSearch(): Promise<
7272
/** Opaque handle returned by {@link buildFileIndex}. */
7373
export interface DocsetIndex {
7474
/** MiniSearch instance (null when MiniSearch could not be loaded) */
75-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7675
_ms: {
7776
search(
78-
query: string,
79-
opts?: Record<string, unknown>,
77+
_query: string,
78+
_opts?: Record<string, unknown>,
8079
): Array<{ id: unknown; score: number }>;
8180
} | null;
8281
/** Absolute path to the docset root used to build this index */
@@ -98,8 +97,13 @@ export async function buildFileIndex(rootPath: string): Promise<DocsetIndex> {
9897
return { _ms: null, rootPath, _idToPath: new Map() };
9998
}
10099

101-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
102-
const ms = new (MiniSearch as any)({
100+
type MiniSearchInstance = DocsetIndex["_ms"] & {
101+
addAllAsync(_docs: Array<{ id: number; content: string }>): Promise<void>;
102+
};
103+
type MiniSearchCtor = new (
104+
_opts: Record<string, unknown>,
105+
) => MiniSearchInstance;
106+
const ms = new (MiniSearch as unknown as MiniSearchCtor)({
103107
fields: ["content"],
104108
storeFields: [],
105109
});
@@ -416,13 +420,16 @@ function escapeRegex(s: string): string {
416420
* Only used for the `include` file-filter option; not a full glob engine.
417421
*/
418422
function matchGlob(filePath: string, pattern: string): boolean {
419-
// Convert simple glob to regex
423+
// Convert simple glob to regex.
424+
// Use a rare Unicode placeholder (U+FFFE) to temporarily represent **
425+
// so that the single-* replacement doesn't clobber it.
426+
const DOUBLE_STAR = "\uFFFE";
420427
const regexStr = pattern
421428
.replace(/[.+^${}()|[\]\\]/g, "\\$&") // escape regex chars (not * and ?)
422-
.replace(/\*\*/g, "\x00") // placeholder for **
429+
.replace(/\*\*/g, DOUBLE_STAR) // placeholder for **
423430
.replace(/\*/g, "[^/]*") // * → any chars except /
424431
.replace(/\?/g, "[^/]") // ? → single char except /
425-
.replace(/\x00/g, ".*"); // ** → any chars including /
432+
.replace(new RegExp(DOUBLE_STAR, "g"), ".*"); // ** → any chars including /
426433

427434
return new RegExp(regexStr + "$", "i").test(filePath);
428435
}

0 commit comments

Comments
 (0)