@sourcegraph/amp 0.0.1748419293-g63ac77 → 0.0.1748427377-geeb377
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/amp.js +2 -3
- package/dist/amp.js.map +1 -1
- package/dist/{color-Cj45sRkS.js → color-DGLUYaqf.js} +5462 -5641
- package/dist/color-DGLUYaqf.js.map +1 -0
- package/dist/{create_file.node-0vS2hejR.js → create_file.node-BJ9db1t8.js} +2 -2
- package/dist/{create_file.node-0vS2hejR.js.map → create_file.node-BJ9db1t8.js.map} +1 -1
- package/dist/{edit_file.node-it4wJ5TR.js → edit_file.node-BMxxYIGr.js} +9 -9
- package/dist/{edit_file.node-it4wJ5TR.js.map → edit_file.node-BMxxYIGr.js.map} +1 -1
- package/dist/{executable-9B5WLKFI.js → executable-D-KMMXSM.js} +2 -2
- package/dist/{executable-9B5WLKFI.js.map → executable-D-KMMXSM.js.map} +1 -1
- package/dist/{files-B2BG6wGh.js → files-CfkeQImL.js} +2 -2
- package/dist/{files-B2BG6wGh.js.map → files-CfkeQImL.js.map} +1 -1
- package/dist/{glob.node-CSXwSKG2.js → glob.node-B0mTFFtz.js} +60 -60
- package/dist/{glob.node-CSXwSKG2.js.map → glob.node-B0mTFFtz.js.map} +1 -1
- package/dist/{list_directory.node-BFm1qTEf.js → list_directory.node-DHsYGwWf.js} +2 -2
- package/dist/{list_directory.node-BFm1qTEf.js.map → list_directory.node-DHsYGwWf.js.map} +1 -1
- package/dist/{load-profile-Cj-UxFl1.js → load-profile-OVWYid8R.js} +2 -2
- package/dist/load-profile-OVWYid8R.js.map +1 -0
- package/dist/{main-B3QXAnGP.js → main-C0CMTAuI.js} +10650 -10266
- package/dist/main-C0CMTAuI.js.map +1 -0
- package/dist/{node-goKryvqE.js → node-BXVTFEWU.js} +19 -19
- package/dist/{node-goKryvqE.js.map → node-BXVTFEWU.js.map} +1 -1
- package/dist/{node--F98eUbP.js → node-BZRHbCOQ.js} +2 -2
- package/dist/{node--F98eUbP.js.map → node-BZRHbCOQ.js.map} +1 -1
- package/dist/{node-3f9fJ7aL.js → node-C_IajzJJ.js} +2 -2
- package/dist/{node-3f9fJ7aL.js.map → node-C_IajzJJ.js.map} +1 -1
- package/dist/{node-z_wuLuYG.js → node-DOR8bmJd.js} +5 -5
- package/dist/{node-z_wuLuYG.js.map → node-DOR8bmJd.js.map} +1 -1
- package/dist/{node-COM1O9lA.js → node-KD2UfqlA.js} +8 -8
- package/dist/node-KD2UfqlA.js.map +1 -0
- package/dist/{node-CPx25-dA.js → node-fuc2ayQf.js} +3 -3
- package/dist/{node-CPx25-dA.js.map → node-fuc2ayQf.js.map} +1 -1
- package/dist/{read_file.node-BPyNHNAZ.js → read_file.node-Bju6vvoS.js} +2 -2
- package/dist/{read_file.node-BPyNHNAZ.js.map → read_file.node-Bju6vvoS.js.map} +1 -1
- package/dist/{stdio-BHqN64gs.js → stdio-Cz3SGMSm.js} +3 -3
- package/dist/{stdio-BHqN64gs.js.map → stdio-Cz3SGMSm.js.map} +1 -1
- package/dist/storybook.js +4 -4
- package/dist/{undo_edit.node-BdqjDOxO.js → undo_edit.node-DlNuubCp.js} +4 -4
- package/dist/{undo_edit.node-BdqjDOxO.js.map → undo_edit.node-DlNuubCp.js.map} +1 -1
- package/package.json +1 -1
- package/dist/client-BG3r9aH9.js +0 -35
- package/dist/client-BG3r9aH9.js.map +0 -1
- package/dist/color-Cj45sRkS.js.map +0 -1
- package/dist/load-profile-Cj-UxFl1.js.map +0 -1
- package/dist/main-B3QXAnGP.js.map +0 -1
- package/dist/node-COM1O9lA.js.map +0 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import d from "node:path";
|
3
|
-
import { p as f,
|
3
|
+
import { p as f, aT as l, a9 as u } from "./color-DGLUYaqf.js";
|
4
4
|
const w = ({ args: t }, { dir: a, dirs: i, trackFileChange: c, filesystem: r }) => f(async (e) => {
|
5
5
|
if (l(a), typeof t.content != "string")
|
6
6
|
throw new Error("create_file: content must be specified");
|
@@ -21,4 +21,4 @@ const w = ({ args: t }, { dir: a, dirs: i, trackFileChange: c, filesystem: r })
|
|
21
21
|
export {
|
22
22
|
w as nodeCreateFileTool
|
23
23
|
};
|
24
|
-
//# sourceMappingURL=create_file.node-
|
24
|
+
//# sourceMappingURL=create_file.node-BJ9db1t8.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create_file.node-
|
1
|
+
{"version":3,"file":"create_file.node-BJ9db1t8.js","sources":["../../core/src/tools/builtin/filesystem/create_file.node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport path from 'path'\nimport { checkDirURIIsFile } from '../node-helpers'\nimport type { createFileToolReg } from './create_file.common'\nimport { resolveArgumentPath } from './read_file.util'\n\nexport const nodeCreateFileTool: NonNullable<typeof createFileToolReg.fn> = (\n\t{ args },\n\t{ dir, dirs, trackFileChange, filesystem },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\tcheckDirURIIsFile(dir)\n\t\tif (typeof args.content !== 'string') {\n\t\t\tthrow new Error('create_file: content must be specified')\n\t\t}\n\n\t\tsignal.throwIfAborted()\n\n\t\tconst fullPath = await resolveArgumentPath(filesystem, dirs, args.path, signal)\n\t\tconst dirname = path.dirname(fullPath)\n\t\tawait filesystem.mkdirp(dirname, signal)\n\n\t\tlet content = args.content\n\t\t// HACK: the Anthropic tool calling API appears to trim whitespace from around all tool args.\n\t\t// When we create files, we _almost always_ want to create them with a trailing newline.\n\t\t// More info here: https://sourcegraph.slack.com/archives/C04D0GRD1GB/p1747064252012509\n\t\tif (!content.endsWith('\\n')) {\n\t\t\tcontent += '\\n'\n\t\t}\n\t\tawait trackFileChange(fullPath, async (path) => {\n\t\t\tawait filesystem.writeFile(path, content, signal)\n\t\t})\n\t\treturn {\n\t\t\tstatus: 'done',\n\t\t\tresult: `Successfully created file ${args.path}`,\n\t\t\tfiles: [args.path],\n\t\t}\n\t})\n}\n"],"names":["nodeCreateFileTool","args","dir","dirs","trackFileChange","filesystem","promiseFactoryToObservable","signal","checkDirURIIsFile","fullPath","resolveArgumentPath","dirname","path","content"],"mappings":";;;AAMa,MAAAA,IAA+D,CAC3E,EAAE,MAAAC,KACF,EAAE,KAAAC,GAAK,MAAAC,GAAM,iBAAAC,GAAiB,YAAAC,QAEvBC,EAA2B,OAAOC,MAAW;AAE/C,MADJC,EAAkBN,CAAG,GACjB,OAAOD,EAAK,WAAY;AACrB,UAAA,IAAI,MAAM,wCAAwC;AAGzD,EAAAM,EAAO,eAAe;AAEtB,QAAME,IAAW,MAAMC,EAAoBL,GAAYF,GAAMF,EAAK,MAAMM,CAAM,GACxEI,IAAUC,EAAK,QAAQH,CAAQ;AAC/B,QAAAJ,EAAW,OAAOM,GAASJ,CAAM;AAEvC,MAAIM,IAAUZ,EAAK;AAInB,SAAKY,EAAQ,SAAS;AAAA,CAAI,MACdA,KAAA;AAAA,IAEN,MAAAT,EAAgBK,GAAU,OAAOG,MAAS;AAC/C,UAAMP,EAAW,UAAUO,GAAMC,GAASN,CAAM;AAAA,EAAA,CAChD,GACM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ,6BAA6BN,EAAK,IAAI;AAAA,IAC9C,OAAO,CAACA,EAAK,IAAI;AAAA,EAClB;AAAA,CACA;"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import { p,
|
3
|
-
import { recordEdit as x } from "./undo_edit.node-
|
4
|
-
class
|
2
|
+
import { p, aT as m, a9 as F, aX as v, aY as _, aZ as b } from "./color-DGLUYaqf.js";
|
3
|
+
import { recordEdit as x } from "./undo_edit.node-DlNuubCp.js";
|
4
|
+
class T {
|
5
5
|
#e = !1;
|
6
6
|
#t = [];
|
7
7
|
/**
|
@@ -21,13 +21,13 @@ class y {
|
|
21
21
|
this.#t.length > 0 ? this.#t.shift()?.() : this.#e = !1;
|
22
22
|
}
|
23
23
|
}
|
24
|
-
const l = new
|
24
|
+
const l = new T(), k = ({ args: e }, { dir: t, dirs: d, threadID: u, trackFileChange: h, filesystem: i }) => p(async (a) => {
|
25
25
|
await l.acquire();
|
26
26
|
try {
|
27
|
-
|
27
|
+
y(e), m(t);
|
28
28
|
const r = await F(i, d, e.path, a);
|
29
29
|
if (!i.exclusiveWriter) {
|
30
|
-
const s =
|
30
|
+
const s = v(r, u), c = await i.getMtime(r);
|
31
31
|
if (s && c && s !== c)
|
32
32
|
return {
|
33
33
|
status: "error",
|
@@ -37,7 +37,7 @@ const l = new y(), k = ({ args: e }, { dir: t, dirs: d, threadID: u, trackFileCh
|
|
37
37
|
}
|
38
38
|
};
|
39
39
|
}
|
40
|
-
const n = await i.readFile(r, a), { modifiedContent: o, formattedDiff: f, lineRange: w } = await
|
40
|
+
const n = await i.readFile(r, a), { modifiedContent: o, formattedDiff: f, lineRange: w } = await _(
|
41
41
|
e.path,
|
42
42
|
n,
|
43
43
|
e.old_str,
|
@@ -58,11 +58,11 @@ const l = new y(), k = ({ args: e }, { dir: t, dirs: d, threadID: u, trackFileCh
|
|
58
58
|
l.release();
|
59
59
|
}
|
60
60
|
});
|
61
|
-
function
|
61
|
+
function y(e) {
|
62
62
|
if (e = b.parse(e), e.old_str === e.new_str)
|
63
63
|
throw new Error("old_str and new_str must be different from each other.");
|
64
64
|
}
|
65
65
|
export {
|
66
66
|
k as nodeEditFileTool
|
67
67
|
};
|
68
|
-
//# sourceMappingURL=edit_file.node-
|
68
|
+
//# sourceMappingURL=edit_file.node-BMxxYIGr.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"edit_file.node-
|
1
|
+
{"version":3,"file":"edit_file.node-BMxxYIGr.js","sources":["../../core/src/utils/async_mutex.ts","../../core/src/tools/builtin/filesystem/edit_file.node.ts"],"sourcesContent":["export class AsyncMutex {\n\t#locked = false\n\t#queue: (() => void)[] = []\n\n\t/**\n\t * Acquires the lock. If the lock is already held, waits until it is released.\n\t * @returns A promise that resolves when the lock is acquired.\n\t */\n\tasync acquire(): Promise<void> {\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tif (!this.#locked) {\n\t\t\t\t// Lock is free, acquire it immediately\n\t\t\t\tthis.#locked = true\n\t\t\t\tresolve()\n\t\t\t} else {\n\t\t\t\t// Lock is held, add the resolver to the queue\n\t\t\t\tthis.#queue.push(resolve)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Releases the lock. If there are waiters in the queue, the next one acquires the lock.\n\t * Otherwise, the lock becomes free.\n\t */\n\trelease(): void {\n\t\tif (this.#queue.length > 0) {\n\t\t\t// Pass the lock to the next waiter without setting #locked to false\n\t\t\tconst nextResolve = this.#queue.shift()\n\t\t\t// The next waiter's promise resolves, and *they* now hold the lock.\n\t\t\t// #locked remains true.\n\t\t\tnextResolve?.()\n\t\t} else {\n\t\t\t// No waiters, release the lock\n\t\t\tthis.#locked = false\n\t\t}\n\t}\n}\n","import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { getFileModTime } from '../../../threads/file-tracking/common'\nimport { AsyncMutex } from '../../../utils/async_mutex'\nimport { checkDirURIIsFile } from '../node-helpers'\nimport type { EditFileToolDef, editFileToolReg } from './edit_file.common'\nimport { applyFileEdits, editFileArgsSchema } from './edit_file.common'\nimport { resolveArgumentPath } from './read_file.util'\nimport { recordEdit } from './undo_edit.node'\n\nconst runningMutex = new AsyncMutex()\n\nexport const nodeEditFileTool: NonNullable<(typeof editFileToolReg)['fn']> = (\n\t{ args },\n\t{ dir, dirs, threadID, trackFileChange, filesystem },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\tawait runningMutex.acquire()\n\t\ttry {\n\t\t\tcheckEditArgs(args)\n\n\t\t\tcheckDirURIIsFile(dir)\n\n\t\t\tconst filePath = await resolveArgumentPath(filesystem, dirs, args.path, signal)\n\n\t\t\tif (!filesystem.exclusiveWriter) {\n\t\t\t\tconst lastReadTime = getFileModTime(filePath, threadID)\n\t\t\t\tconst currentMtime = await filesystem.getMtime(filePath)\n\t\t\t\tif (lastReadTime && currentMtime && lastReadTime !== currentMtime) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'error' as const,\n\t\t\t\t\t\tprogress: {},\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tmessage: `The file '${args.path}' has been modified since you last read it. Please use read_file to view the current version before making edits.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst content = await filesystem.readFile(filePath, signal)\n\t\t\tconst { modifiedContent, formattedDiff, lineRange } = await applyFileEdits(\n\t\t\t\targs.path,\n\t\t\t\tcontent,\n\t\t\t\targs.old_str,\n\t\t\t\targs.new_str,\n\t\t\t)\n\n\t\t\tawait recordEdit(args.path, content, modifiedContent)\n\n\t\t\tawait trackFileChange(filePath, async (path) => {\n\t\t\t\tawait filesystem.writeFile(path, modifiedContent, signal)\n\t\t\t})\n\n\t\t\tconst result = {\n\t\t\t\tdiff: formattedDiff,\n\t\t\t\tlineRange,\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tstatus: 'done',\n\t\t\t\tprogress: {},\n\t\t\t\tresult,\n\t\t\t\tfiles: [args.path],\n\t\t\t}\n\t\t} finally {\n\t\t\trunningMutex.release()\n\t\t}\n\t})\n}\n\nfunction checkEditArgs(args: EditFileToolDef['args']): asserts args is EditFileToolDef['args'] {\n\targs = editFileArgsSchema.parse(args)\n\tif (args.old_str === args.new_str) {\n\t\tthrow new Error('old_str and new_str must be different from each other.')\n\t}\n}\n"],"names":["AsyncMutex","#locked","#queue","resolve","runningMutex","nodeEditFileTool","args","dir","dirs","threadID","trackFileChange","filesystem","promiseFactoryToObservable","signal","checkEditArgs","checkDirURIIsFile","filePath","resolveArgumentPath","lastReadTime","getFileModTime","currentMtime","content","modifiedContent","formattedDiff","lineRange","applyFileEdits","recordEdit","path","editFileArgsSchema"],"mappings":";;;AAAO,MAAMA,EAAW;AAAA,EACvBC,KAAU;AAAA,EACVC,KAAyB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAM1B,MAAM,UAAyB;AACvB,WAAA,IAAI,QAAc,CAACC,MAAY;AACjC,MAAC,KAAKF,KAMJ,KAAAC,GAAO,KAAKC,CAAO,KAJxB,KAAKF,KAAU,IACPE,EAAA;AAAA,IAIT,CACA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOF,UAAgB;AACX,IAAA,KAAKD,GAAO,SAAS,IAEJ,KAAKA,GAAO,MAAM,IAGxB,IAGd,KAAKD,KAAU;AAAA,EAChB;AAEF;AC5BA,MAAMG,IAAe,IAAIJ,EAAW,GAEvBK,IAAgE,CAC5E,EAAE,MAAAC,EAAK,GACP,EAAE,KAAAC,GAAK,MAAAC,GAAM,UAAAC,GAAU,iBAAAC,GAAiB,YAAAC,QAEjCC,EAA2B,OAAOC,MAAW;AACnD,QAAMT,EAAa,QAAQ;AACvB,MAAA;AACH,IAAAU,EAAcR,CAAI,GAElBS,EAAkBR,CAAG;AAErB,UAAMS,IAAW,MAAMC,EAAoBN,GAAYH,GAAMF,EAAK,MAAMO,CAAM;AAE1E,QAAA,CAACF,EAAW,iBAAiB;AAC1B,YAAAO,IAAeC,EAAeH,GAAUP,CAAQ,GAChDW,IAAe,MAAMT,EAAW,SAASK,CAAQ;AACnD,UAAAE,KAAgBE,KAAgBF,MAAiBE;AAC7C,eAAA;AAAA,UACN,QAAQ;AAAA,UACR,UAAU,CAAC;AAAA,UACX,OAAO;AAAA,YACN,SAAS,aAAad,EAAK,IAAI;AAAA,UAAA;AAAA,QAEjC;AAAA,IACD;AAGD,UAAMe,IAAU,MAAMV,EAAW,SAASK,GAAUH,CAAM,GACpD,EAAE,iBAAAS,GAAiB,eAAAC,GAAe,WAAAC,EAAA,IAAc,MAAMC;AAAA,MAC3DnB,EAAK;AAAA,MACLe;AAAA,MACAf,EAAK;AAAA,MACLA,EAAK;AAAA,IACN;AAEA,iBAAMoB,EAAWpB,EAAK,MAAMe,GAASC,CAAe,GAE9C,MAAAZ,EAAgBM,GAAU,OAAOW,MAAS;AAC/C,YAAMhB,EAAW,UAAUgB,GAAML,GAAiBT,CAAM;AAAA,IAAA,CACxD,GAOM;AAAA,MACN,QAAQ;AAAA,MACR,UAAU,CAAC;AAAA,MACX,QARc;AAAA,QACd,MAAMU;AAAA,QACN,WAAAC;AAAA,MACD;AAAA,MAMC,OAAO,CAAClB,EAAK,IAAI;AAAA,IAClB;AAAA,EAAA,UACC;AACD,IAAAF,EAAa,QAAQ;AAAA,EAAA;AACtB,CACA;AAGF,SAASU,EAAcR,GAAwE;AAE1F,MADGA,IAAAsB,EAAmB,MAAMtB,CAAI,GAChCA,EAAK,YAAYA,EAAK;AACnB,UAAA,IAAI,MAAM,wDAAwD;AAE1E;"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { existsSync as o } from "node:fs";
|
3
3
|
import { createRequire as t } from "node:module";
|
4
|
-
import { n as i } from "./color-
|
4
|
+
import { n as i } from "./color-DGLUYaqf.js";
|
5
5
|
function g() {
|
6
6
|
try {
|
7
7
|
const r = t(import.meta.url)("@vscode/ripgrep")?.rgPath;
|
@@ -15,4 +15,4 @@ function g() {
|
|
15
15
|
export {
|
16
16
|
g as r
|
17
17
|
};
|
18
|
-
//# sourceMappingURL=executable-
|
18
|
+
//# sourceMappingURL=executable-D-KMMXSM.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"executable-
|
1
|
+
{"version":3,"file":"executable-D-KMMXSM.js","sources":["../../core/src/tools/builtin/grep/executable.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport logger from '../../../common/logger'\n\nexport function ripgrepExecutable(): string {\n\tif (import.meta.env.VITE_PLATFORM === 'vscode') {\n\t\tconst possiblePaths = getVSCodeRipgrepPaths()\n\n\t\tfor (const path of possiblePaths) {\n\t\t\tif (existsSync(path)) {\n\t\t\t\treturn path\n\t\t\t}\n\t\t}\n\t} else if (import.meta.env.VITE_PLATFORM === 'node') {\n\t\ttry {\n\t\t\t// Create a require function that can be used in ESM context\n\t\t\tconst require = createRequire(import.meta.url)\n\n\t\t\t// Use the created require function to load @vscode/ripgrep\n\t\t\tconst ripgrepModule = require('@vscode/ripgrep') as { rgPath: string }\n\t\t\tconst rgPath = ripgrepModule?.rgPath\n\n\t\t\tif (rgPath && existsSync(rgPath)) {\n\t\t\t\treturn rgPath\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tlogger.error('Error with ripgrep:', error)\n\t\t}\n\t}\n\n\treturn 'rg'\n}\n\nfunction getVSCodeRipgrepPaths(): string[] {\n\tconst platform = process.platform\n\tconst paths: string[] = []\n\n\ttry {\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst vscode = require('vscode') as typeof import('vscode')\n\t\tconst binaryName = platform === 'win32' ? 'rg.exe' : 'rg'\n\t\tpaths.push(\n\t\t\tjoin(vscode.env.appRoot, 'node_modules', '@vscode', 'ripgrep', 'bin', binaryName),\n\t\t)\n\t} catch {\n\t\t// ignore\n\t}\n\n\t// This if statement should no longer be needed since vscode.env.appRoot\n\t// already handles it. However, keeping it here as a fallback just to be\n\t// sure we don't regress anything after adding appRoot support.\n\tif (platform === 'darwin') {\n\t\tpaths.push(\n\t\t\t'/Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/@vscode/ripgrep/bin/rg',\n\t\t)\n\t} else if (platform === 'linux') {\n\t\tpaths.push(\n\t\t\t'/usr/share/code/resources/app/node_modules/@vscode/ripgrep/bin/rg',\n\t\t\tjoin(homedir(), '.vscode/extensions/ms-vscode.vscode-ripgrep-*/bin/rg'),\n\t\t)\n\t}\n\n\treturn paths\n}\n"],"names":["ripgrepExecutable","rgPath","createRequire","existsSync","error","logger"],"mappings":";;;;AAMO,SAASA,IAA4B;AAUtC,MAAA;AAMH,UAAMC,IAJUC,EAAc,YAAY,GAAG,EAGf,iBAAiB,GACjB;AAE1B,QAAAD,KAAUE,EAAWF,CAAM;AACvB,aAAAA;AAAA,WAEAG,GAAO;AACR,IAAAC,EAAA,MAAM,uBAAuBD,CAAK;AAAA,EAAA;AAIpC,SAAA;AACR;"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import y from "node:path";
|
3
|
-
import {
|
3
|
+
import { b4 as I, b5 as T, n as z, b6 as B, b7 as P } from "./color-DGLUYaqf.js";
|
4
4
|
async function L(p, h, t) {
|
5
5
|
const b = await t.listFiles(h), i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), f = [], M = /\b([\w/_-]+(?:\\.|[\w/_-])*(?:\.[\w-]+)+)\b/g, F = /(\/(?:[\w-]+\/|[\w-]+\\[.\s\S])+[\w.-]+(?:\\.|[\w.-])*(?:\.[\w-]+)+)\b/g, x = /\b([A-Za-z]:[\\\\][^\s"'<>|]*(?:\.[\w-]+)+)\b/g;
|
6
6
|
await l(M, !1), await l(F, !0), await l(x, !0);
|
@@ -67,4 +67,4 @@ async function L(p, h, t) {
|
|
67
67
|
export {
|
68
68
|
L as getFileMentions
|
69
69
|
};
|
70
|
-
//# sourceMappingURL=files-
|
70
|
+
//# sourceMappingURL=files-CfkeQImL.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"files-
|
1
|
+
{"version":3,"file":"files-CfkeQImL.js","sources":["../../core/src/threads/files.ts"],"sourcesContent":["import path from 'node:path'\nimport logger from '../common/logger'\nimport type { FileSystem } from '../platform/fs/fs'\nimport { getImageFileMetadata } from '../tools/builtin/filesystem/file-type'\nimport { checkFileSizeLimit } from '../tools/builtin/filesystem/read_file.util'\nimport type { FileMention } from './file-mentions'\nimport { FileMentions } from './file-mentions'\nimport { isSupportedImageMIMEType } from './image-attachments'\n\nexport async function getFileMentions(\n\tcontent: string,\n\tworkspaceRoot: string,\n\tfilesystem: Pick<FileSystem, 'stat' | 'readFile' | 'readBinaryFile' | 'listFiles'>,\n): Promise<FileMentions> {\n\tconst files = await filesystem.listFiles(workspaceRoot)\n\tconst fileContents = new Map<string, string>()\n\tconst imageFiles = new Map<string, { mimeType: string; size: number }>() // Track image files separately\n\tconst mentions: FileMention[] = []\n\n\t// Regex patterns for file paths\n\t// Match relative paths with extension within workspace\n\tconst relativePathRegex = /\\b([\\w/_-]+(?:\\\\.|[\\w/_-])*(?:\\.[\\w-]+)+)\\b/g\n\t// Match absolute paths with extension (Unix/Linux/Mac)\n\tconst unixAbsolutePathRegex =\n\t\t/(\\/(?:[\\w-]+\\/|[\\w-]+\\\\[.\\s\\S])+[\\w.-]+(?:\\\\.|[\\w.-])*(?:\\.[\\w-]+)+)\\b/g\n\t// Match absolute paths with extension (Windows) - using a more permissive approach\n\tconst windowsAbsolutePathRegex = /\\b([A-Za-z]:[\\\\\\\\][^\\s\"'<>|]*(?:\\.[\\w-]+)+)\\b/g\n\n\t// Process matches for each regex pattern\n\tawait processMatches(relativePathRegex, false)\n\tawait processMatches(unixAbsolutePathRegex, true)\n\n\tawait processMatches(windowsAbsolutePathRegex, true)\n\n\t// Process matches from a regex pattern\n\tasync function processMatches(regex: RegExp, isAbsolutePath: boolean) {\n\t\t// Reset regex before execution to ensure we don't miss any matches\n\t\tregex.lastIndex = 0\n\n\t\tlet match\n\t\twhile ((match = regex.exec(content)) !== null) {\n\t\t\tconst [word] = match\n\t\t\t// Unescape special characters in the path\n\t\t\t// Unescape characters in file paths\n\t\t\tlet unescapedWord\n\t\t\t// Check if this is a Windows path with drive letter\n\t\t\tconst isWindowsPath = word.match(/^[A-Za-z]:[\\\\]/) !== null\n\t\t\tif (isWindowsPath) {\n\t\t\t\t// For Windows paths, preserve the backslashes as path separators but handle escaped characters\n\t\t\t\tunescapedWord = word\n\t\t\t} else {\n\t\t\t\t// For other paths, unescape everything\n\t\t\t\tunescapedWord = word.replace(/\\\\(.)/g, '$1')\n\t\t\t}\n\n\t\t\tconst isCached = fileContents.has(unescapedWord) || imageFiles.has(unescapedWord)\n\n\t\t\t// Skip if we've already processed this file path\n\t\t\tif (isCached) {\n\t\t\t\taddMention(unescapedWord, match.index)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Determine file path\n\t\t\tconst filePath = isAbsolutePath\n\t\t\t\t? unescapedWord\n\t\t\t\t: path.join(workspaceRoot, unescapedWord)\n\n\t\t\t// For relative paths, check if file exists in the workspace\n\t\t\tif (!isAbsolutePath && !files.includes(unescapedWord)) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// For absolute paths, check if file exists on disk\n\t\t\tif (isAbsolutePath) {\n\t\t\t\ttry {\n\t\t\t\t\t// Just try to stat the file to see if it exists\n\t\t\t\t\tawait filesystem.stat(filePath)\n\t\t\t\t} catch (err) {\n\t\t\t\t\t// File doesn't exist or can't be accessed\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Process the file\n\t\t\ttry {\n\t\t\t\t// Check if this is an image file\n\t\t\t\tconst imageInfo = await getImageFileMetadata(filesystem, filePath)\n\n\t\t\t\tif (imageInfo && isSupportedImageMIMEType(imageInfo.mimeType)) {\n\t\t\t\t\t// This is an image file, treat it as an attachment\n\t\t\t\t\timageFiles.set(unescapedWord, imageInfo)\n\t\t\t\t\t// Read the image file as binary and convert to base64\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst imageBuffer = await filesystem.readBinaryFile(filePath)\n\t\t\t\t\t\tconst base64Data = imageBuffer.toString('base64')\n\t\t\t\t\t\t// Store the base64 data\n\t\t\t\t\t\tfileContents.set(unescapedWord, base64Data)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\t'Failed to read image as binary',\n\t\t\t\t\t\t\t{ path: unescapedWord },\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t// Set a placeholder in case of error\n\t\t\t\t\t\tfileContents.set(\n\t\t\t\t\t\t\tunescapedWord,\n\t\t\t\t\t\t\t`[Image file: ${unescapedWord} (${imageInfo.mimeType}, ${Math.round(imageInfo.size / 1024)} KB)]`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\taddMention(unescapedWord, match.index)\n\t\t\t\t} else {\n\t\t\t\t\t// Not an image file, handle normally\n\t\t\t\t\tconst isTooLarge = await checkFileSizeLimit(filesystem, filePath)\n\t\t\t\t\tif (isTooLarge) {\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tconst data = await filesystem.readFile(filePath)\n\t\t\t\t\tfileContents.set(unescapedWord, data)\n\t\t\t\t\taddMention(unescapedWord, match.index)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Skip file if there's any error reading it\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\n\t// Helper function to add a mention\n\tfunction addMention(path: string, startIndex: number) {\n\t\tmentions.push({\n\t\t\tpath,\n\t\t\trange: {\n\t\t\t\tstart: startIndex,\n\t\t\t\tend: startIndex + path.length - 1,\n\t\t\t},\n\t\t})\n\t}\n\n\t// Create a FileMentions instance with both text and image file contents\n\tconst fileMentions = new FileMentions(fileContents, mentions)\n\n\t// Add image file metadata to the FileMentions instance\n\tfileMentions.imageFiles = imageFiles\n\n\treturn fileMentions\n}\n"],"names":["getFileMentions","content","workspaceRoot","filesystem","files","fileContents","imageFiles","mentions","relativePathRegex","unixAbsolutePathRegex","windowsAbsolutePathRegex","processMatches","regex","isAbsolutePath","match","word","unescapedWord","addMention","filePath","path","imageInfo","getImageFileMetadata","isSupportedImageMIMEType","base64Data","error","logger","checkFileSizeLimit","data","startIndex","fileMentions","FileMentions"],"mappings":";;;AASsB,eAAAA,EACrBC,GACAC,GACAC,GACwB;AACxB,QAAMC,IAAQ,MAAMD,EAAW,UAAUD,CAAa,GAChDG,wBAAmB,IAAoB,GACvCC,wBAAiB,IAAgD,GACjEC,IAA0B,CAAC,GAI3BC,IAAoB,gDAEpBC,IACL,2EAEKC,IAA2B;AAG3B,QAAAC,EAAeH,GAAmB,EAAK,GACvC,MAAAG,EAAeF,GAAuB,EAAI,GAE1C,MAAAE,EAAeD,GAA0B,EAAI;AAGpC,iBAAAC,EAAeC,GAAeC,GAAyB;AAErE,IAAAD,EAAM,YAAY;AAEd,QAAAE;AACJ,YAAQA,IAAQF,EAAM,KAAKX,CAAO,OAAO,QAAM;AACxC,YAAA,CAACc,CAAI,IAAID;AAGX,UAAAE;AAcJ,UAZsBD,EAAK,MAAM,gBAAgB,MAAM,OAGtCC,IAAAD,IAGAC,IAAAD,EAAK,QAAQ,UAAU,IAAI,GAG3BV,EAAa,IAAIW,CAAa,KAAKV,EAAW,IAAIU,CAAa,GAGlE;AACF,QAAAC,EAAAD,GAAeF,EAAM,KAAK;AACrC;AAAA,MAAA;AAID,YAAMI,IAAWL,IACdG,IACAG,EAAK,KAAKjB,GAAec,CAAa;AAGzC,UAAI,GAACH,KAAkB,CAACT,EAAM,SAASY,CAAa,IAKpD;AAAA,YAAIH;AACC,cAAA;AAEG,kBAAAV,EAAW,KAAKe,CAAQ;AAAA,kBACjB;AAEb;AAAA,UAAA;AAKE,YAAA;AAEH,gBAAME,IAAY,MAAMC,EAAqBlB,GAAYe,CAAQ;AAEjE,cAAIE,KAAaE,EAAyBF,EAAU,QAAQ,GAAG;AAEnD,YAAAd,EAAA,IAAIU,GAAeI,CAAS;AAEnC,gBAAA;AAEG,oBAAAG,KADc,MAAMpB,EAAW,eAAee,CAAQ,GAC7B,SAAS,QAAQ;AAEnC,cAAAb,EAAA,IAAIW,GAAeO,CAAU;AAAA,qBAClCC,GAAO;AACR,cAAAC,EAAA;AAAA,gBACN;AAAA,gBACA,EAAE,MAAMT,EAAc;AAAA,gBACtBQ;AAAA,cACD,GAEanB,EAAA;AAAA,gBACZW;AAAA,gBACA,gBAAgBA,CAAa,KAAKI,EAAU,QAAQ,KAAK,KAAK,MAAMA,EAAU,OAAO,IAAI,CAAC;AAAA,cAC3F;AAAA,YAAA;AAEU,YAAAH,EAAAD,GAAeF,EAAM,KAAK;AAAA,UAAA,OAC/B;AAGN,gBADmB,MAAMY,EAAmBvB,GAAYe,CAAQ;AAE/D;AAGD,kBAAMS,IAAO,MAAMxB,EAAW,SAASe,CAAQ;AAClC,YAAAb,EAAA,IAAIW,GAAeW,CAAI,GACzBV,EAAAD,GAAeF,EAAM,KAAK;AAAA,UAAA;AAAA,gBAEvB;AAEf;AAAA,QAAA;AAAA;AAAA,IACD;AAAA,EACD;AAIQ,WAAAG,EAAWE,GAAcS,GAAoB;AACrD,IAAArB,EAAS,KAAK;AAAA,MACb,MAAAY;AAAAA,MACA,OAAO;AAAA,QACN,OAAOS;AAAA,QACP,KAAKA,IAAaT,EAAK,SAAS;AAAA,MAAA;AAAA,IACjC,CACA;AAAA,EAAA;AAIF,QAAMU,IAAe,IAAIC,EAAazB,GAAcE,CAAQ;AAG5D,SAAAsB,EAAa,aAAavB,GAEnBuB;AACR;"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { spawn as yt } from "node:child_process";
|
3
|
-
import { k as Ht, O as $t, g as mt, m as
|
4
|
-
import { r as Ot } from "./executable-
|
3
|
+
import { k as Ht, O as $t, g as mt, m as Tt, aT as Lt, n as vt } from "./color-DGLUYaqf.js";
|
4
|
+
import { r as Ot } from "./executable-D-KMMXSM.js";
|
5
5
|
var pt = {}, ft, Et;
|
6
6
|
function it() {
|
7
7
|
if (Et) return ft;
|
@@ -23,7 +23,7 @@ function it() {
|
|
23
23
|
STAR: S,
|
24
24
|
START_ANCHOR: x,
|
25
25
|
SEP: "/"
|
26
|
-
},
|
26
|
+
}, L = {
|
27
27
|
...F,
|
28
28
|
SLASH_LITERAL: `[${p}]`,
|
29
29
|
QMARK: A,
|
@@ -174,7 +174,7 @@ function it() {
|
|
174
174
|
* Create GLOB_CHARS
|
175
175
|
*/
|
176
176
|
globChars(b) {
|
177
|
-
return b === !0 ?
|
177
|
+
return b === !0 ? L : F;
|
178
178
|
}
|
179
179
|
}, ft;
|
180
180
|
}
|
@@ -244,13 +244,13 @@ function wt() {
|
|
244
244
|
/* ) */
|
245
245
|
CHAR_RIGHT_SQUARE_BRACKET: y
|
246
246
|
/* ] */
|
247
|
-
} = /* @__PURE__ */ it(), S = (
|
248
|
-
|
247
|
+
} = /* @__PURE__ */ it(), S = (L) => L === a || L === d, I = (L) => {
|
248
|
+
L.isPrefix !== !0 && (L.depth = L.isGlobstar ? 1 / 0 : 1);
|
249
249
|
};
|
250
|
-
return ht = (
|
251
|
-
const b = G || {}, Y =
|
252
|
-
let M =
|
253
|
-
const
|
250
|
+
return ht = (L, G) => {
|
251
|
+
const b = G || {}, Y = L.length - 1, B = b.parts === !0 || b.scanToEnd === !0, W = [], w = [], st = [];
|
252
|
+
let M = L, H = -1, N = 0, tt = 0, rt = !1, j = !1, v = !1, et = !1, X = !1, s = !1, k = !1, z = !1, ut = !1, t = !1, e = 0, nt, l, C = { value: "", depth: 0, isGlob: !1 };
|
253
|
+
const V = () => H >= Y, J = () => M.charCodeAt(H + 1), U = () => (nt = l, M.charCodeAt(++H));
|
254
254
|
for (; H < Y; ) {
|
255
255
|
l = U();
|
256
256
|
let q;
|
@@ -259,7 +259,7 @@ function wt() {
|
|
259
259
|
continue;
|
260
260
|
}
|
261
261
|
if (s === !0 || l === f) {
|
262
|
-
for (e++;
|
262
|
+
for (e++; V() !== !0 && (l = U()); ) {
|
263
263
|
if (l === d) {
|
264
264
|
k = C.backslashes = !0, U();
|
265
265
|
continue;
|
@@ -298,7 +298,7 @@ function wt() {
|
|
298
298
|
}
|
299
299
|
if (b.noext !== !0 && (l === E || l === R || l === A || l === r || l === u) === !0 && J() === x) {
|
300
300
|
if (v = C.isGlob = !0, et = C.isExtglob = !0, t = !0, l === u && H === N && (ut = !0), B === !0) {
|
301
|
-
for (;
|
301
|
+
for (; V() !== !0 && (l = U()); ) {
|
302
302
|
if (l === d) {
|
303
303
|
k = C.backslashes = !0, l = U();
|
304
304
|
continue;
|
@@ -323,7 +323,7 @@ function wt() {
|
|
323
323
|
break;
|
324
324
|
}
|
325
325
|
if (l === c) {
|
326
|
-
for (;
|
326
|
+
for (; V() !== !0 && (q = U()); ) {
|
327
327
|
if (q === d) {
|
328
328
|
k = C.backslashes = !0, U();
|
329
329
|
continue;
|
@@ -343,7 +343,7 @@ function wt() {
|
|
343
343
|
}
|
344
344
|
if (b.noparen !== !0 && l === x) {
|
345
345
|
if (v = C.isGlob = !0, B === !0) {
|
346
|
-
for (;
|
346
|
+
for (; V() !== !0 && (l = U()); ) {
|
347
347
|
if (l === x) {
|
348
348
|
k = C.backslashes = !0, l = U();
|
349
349
|
continue;
|
@@ -364,14 +364,14 @@ function wt() {
|
|
364
364
|
}
|
365
365
|
}
|
366
366
|
b.noext === !0 && (et = !1, v = !1);
|
367
|
-
let D = M, ot = "",
|
368
|
-
N > 0 && (ot = M.slice(0, N), M = M.slice(N), tt -= N), D && v === !0 && tt > 0 ? (D = M.slice(0, tt),
|
367
|
+
let D = M, ot = "", Z = "";
|
368
|
+
N > 0 && (ot = M.slice(0, N), M = M.slice(N), tt -= N), D && v === !0 && tt > 0 ? (D = M.slice(0, tt), Z = M.slice(tt)) : v === !0 ? (D = "", Z = M) : D = M, D && D !== "" && D !== "/" && D !== M && S(D.charCodeAt(D.length - 1)) && (D = D.slice(0, -1)), b.unescape === !0 && (Z && (Z = p.removeBackslashes(Z)), D && k === !0 && (D = p.removeBackslashes(D)));
|
369
369
|
const h = {
|
370
370
|
prefix: ot,
|
371
|
-
input:
|
371
|
+
input: L,
|
372
372
|
start: N,
|
373
373
|
base: D,
|
374
|
-
glob:
|
374
|
+
glob: Z,
|
375
375
|
isBrace: rt,
|
376
376
|
isBracket: j,
|
377
377
|
isGlob: v,
|
@@ -383,11 +383,11 @@ function wt() {
|
|
383
383
|
if (b.tokens === !0 && (h.maxDepth = 0, S(l) || w.push(C), h.tokens = w), b.parts === !0 || b.tokens === !0) {
|
384
384
|
let q;
|
385
385
|
for (let K = 0; K < W.length; K++) {
|
386
|
-
const i = q ? q + 1 : N,
|
387
|
-
b.tokens && (K === 0 && N !== 0 ? (w[K].isPrefix = !0, w[K].value = ot) : w[K].value = n, I(w[K]), h.maxDepth += w[K].depth), (K !== 0 || n !== "") && st.push(n), q =
|
386
|
+
const i = q ? q + 1 : N, T = W[K], n = L.slice(i, T);
|
387
|
+
b.tokens && (K === 0 && N !== 0 ? (w[K].isPrefix = !0, w[K].value = ot) : w[K].value = n, I(w[K]), h.maxDepth += w[K].depth), (K !== 0 || n !== "") && st.push(n), q = T;
|
388
388
|
}
|
389
|
-
if (q && q + 1 <
|
390
|
-
const K =
|
389
|
+
if (q && q + 1 < L.length) {
|
390
|
+
const K = L.slice(q + 1);
|
391
391
|
st.push(K), b.tokens && (w[w.length - 1].value = K, I(w[w.length - 1]), h.maxDepth += w[w.length - 1].depth);
|
392
392
|
}
|
393
393
|
h.slashes = W, h.parts = st;
|
@@ -424,7 +424,7 @@ function Nt() {
|
|
424
424
|
let m = c.length;
|
425
425
|
if (m > $)
|
426
426
|
throw new SyntaxError(`Input length: ${m}, exceeds maximum allowed length: ${$}`);
|
427
|
-
const y = { type: "bos", value: "", output: r.prepend || "" }, S = [y], I = r.capture ? "" : "?:", F = p.globChars(r.windows),
|
427
|
+
const y = { type: "bos", value: "", output: r.prepend || "" }, S = [y], I = r.capture ? "" : "?:", F = p.globChars(r.windows), L = p.extglobChars(F), {
|
428
428
|
DOT_LITERAL: G,
|
429
429
|
PLUS_LITERAL: b,
|
430
430
|
SLASH_LITERAL: Y,
|
@@ -460,8 +460,8 @@ function Nt() {
|
|
460
460
|
c = A.removePrefix(c, s), m = c.length;
|
461
461
|
const k = [], z = [], ut = [];
|
462
462
|
let t = y, e;
|
463
|
-
const nt = () => s.index === m - 1, l = s.peek = (i = 1) => c[s.index + i], C = s.advance = () => c[++s.index] || "",
|
464
|
-
s.consumed += i, s.index +=
|
463
|
+
const nt = () => s.index === m - 1, l = s.peek = (i = 1) => c[s.index + i], C = s.advance = () => c[++s.index] || "", V = () => c.slice(s.index + 1), J = (i = "", T = 0) => {
|
464
|
+
s.consumed += i, s.index += T;
|
465
465
|
}, U = (i) => {
|
466
466
|
s.output += i.output != null ? i.output : i.value, J(i.value);
|
467
467
|
}, D = () => {
|
@@ -471,38 +471,38 @@ function Nt() {
|
|
471
471
|
return i % 2 === 0 ? !1 : (s.negated = !0, s.start++, !0);
|
472
472
|
}, ot = (i) => {
|
473
473
|
s[i]++, ut.push(i);
|
474
|
-
},
|
474
|
+
}, Z = (i) => {
|
475
475
|
s[i]--, ut.pop();
|
476
476
|
}, h = (i) => {
|
477
477
|
if (t.type === "globstar") {
|
478
|
-
const
|
479
|
-
i.type !== "slash" && i.type !== "paren" && !
|
478
|
+
const T = s.braces > 0 && (i.type === "comma" || i.type === "brace"), n = i.extglob === !0 || k.length && (i.type === "pipe" || i.type === "paren");
|
479
|
+
i.type !== "slash" && i.type !== "paren" && !T && !n && (s.output = s.output.slice(0, -t.output.length), t.type = "star", t.value = "*", t.output = X, s.output += t.output);
|
480
480
|
}
|
481
481
|
if (k.length && i.type !== "paren" && (k[k.length - 1].inner += i.value), (i.value || i.output) && U(i), t && t.type === "text" && i.type === "text") {
|
482
482
|
t.output = (t.output || t.value) + i.value, t.value += i.value;
|
483
483
|
return;
|
484
484
|
}
|
485
485
|
i.prev = t, S.push(i), t = i;
|
486
|
-
}, q = (i,
|
487
|
-
const n = { ...T
|
486
|
+
}, q = (i, T) => {
|
487
|
+
const n = { ...L[T], conditions: 1, inner: "" };
|
488
488
|
n.prev = t, n.parens = s.parens, n.output = s.output;
|
489
489
|
const _ = (r.capture ? "(" : "") + n.open;
|
490
|
-
ot("parens"), h({ type: i, value:
|
490
|
+
ot("parens"), h({ type: i, value: T, output: s.output ? "" : B }), h({ type: "paren", extglob: !0, value: C(), output: _ }), k.push(n);
|
491
491
|
}, K = (i) => {
|
492
|
-
let
|
492
|
+
let T = i.close + (r.capture ? ")" : ""), n;
|
493
493
|
if (i.type === "negate") {
|
494
494
|
let _ = X;
|
495
|
-
if (i.inner && i.inner.length > 1 && i.inner.includes("/") && (_ = j(r)), (_ !== X || nt() || /^\)+$/.test(
|
495
|
+
if (i.inner && i.inner.length > 1 && i.inner.includes("/") && (_ = j(r)), (_ !== X || nt() || /^\)+$/.test(V())) && (T = i.close = `)$))${_}`), i.inner.includes("*") && (n = V()) && /^\.[^\\/.]+$/.test(n)) {
|
496
496
|
const O = x(n, { ...E, fastpaths: !1 }).output;
|
497
|
-
|
497
|
+
T = i.close = `)${O})${_})`;
|
498
498
|
}
|
499
499
|
i.prev.type === "bos" && (s.negatedExtglob = !0);
|
500
500
|
}
|
501
|
-
h({ type: "paren", extglob: !0, value: e, output:
|
501
|
+
h({ type: "paren", extglob: !0, value: e, output: T }), Z("parens");
|
502
502
|
};
|
503
503
|
if (r.fastpaths !== !1 && !/(^[*!]|[/()[\]{}"])/.test(c)) {
|
504
|
-
let i = !1,
|
505
|
-
return i === !0 && (r.unescape === !0 ?
|
504
|
+
let i = !1, T = c.replace(o, (n, _, O, Q, P, lt) => Q === "\\" ? (i = !0, n) : Q === "?" ? _ ? _ + Q + (P ? H.repeat(P.length) : "") : lt === 0 ? et + (P ? H.repeat(P.length) : "") : H.repeat(O.length) : Q === "." ? G.repeat(O.length) : Q === "*" ? _ ? _ + Q + (P ? X : "") : X : _ ? n : `\\${n}`);
|
505
|
+
return i === !0 && (r.unescape === !0 ? T = T.replace(/\\/g, "") : T = T.replace(/\\+/g, (n) => n.length % 2 === 0 ? "\\\\" : n ? "\\" : "")), T === c && r.contains === !0 ? (s.output = c, s) : (s.output = A.wrapOutput(T, s, E), s);
|
506
506
|
}
|
507
507
|
for (; !nt(); ) {
|
508
508
|
if (e = C(), e === "\0")
|
@@ -515,7 +515,7 @@ function Nt() {
|
|
515
515
|
e += "\\", h({ type: "text", value: e });
|
516
516
|
continue;
|
517
517
|
}
|
518
|
-
const _ = /^\\+/.exec(
|
518
|
+
const _ = /^\\+/.exec(V());
|
519
519
|
let O = 0;
|
520
520
|
if (_ && _[0].length > 2 && (O = _[0].length, s.index += O, O % 2 !== 0 && (e += "\\")), r.unescape === !0 ? e = C() : e += C(), s.brackets === 0) {
|
521
521
|
h({ type: "text", value: e });
|
@@ -556,11 +556,11 @@ function Nt() {
|
|
556
556
|
K(k.pop());
|
557
557
|
continue;
|
558
558
|
}
|
559
|
-
h({ type: "paren", value: e, output: s.parens ? ")" : "\\)" }),
|
559
|
+
h({ type: "paren", value: e, output: s.parens ? ")" : "\\)" }), Z("parens");
|
560
560
|
continue;
|
561
561
|
}
|
562
562
|
if (e === "[") {
|
563
|
-
if (r.nobracket === !0 || !
|
563
|
+
if (r.nobracket === !0 || !V().includes("]")) {
|
564
564
|
if (r.nobracket !== !0 && r.strictBrackets === !0)
|
565
565
|
throw new SyntaxError(f("closing", "]"));
|
566
566
|
e = `\\${e}`;
|
@@ -580,7 +580,7 @@ function Nt() {
|
|
580
580
|
h({ type: "text", value: e, output: `\\${e}` });
|
581
581
|
continue;
|
582
582
|
}
|
583
|
-
|
583
|
+
Z("brackets");
|
584
584
|
const n = t.value.slice(1);
|
585
585
|
if (t.posix !== !0 && n[0] === "^" && !n.includes("/") && (e = `/${e}`), t.value += e, U({ value: e }), r.literalBrackets === !1 || A.hasRegexChars(n))
|
586
586
|
continue;
|
@@ -623,7 +623,7 @@ function Nt() {
|
|
623
623
|
for (const P of Q)
|
624
624
|
s.output += P.output || P.value;
|
625
625
|
}
|
626
|
-
h({ type: "brace", value: e, output: _ }),
|
626
|
+
h({ type: "brace", value: e, output: _ }), Z("braces"), z.pop();
|
627
627
|
continue;
|
628
628
|
}
|
629
629
|
if (e === "|") {
|
@@ -666,7 +666,7 @@ function Nt() {
|
|
666
666
|
if (t && t.type === "paren") {
|
667
667
|
const _ = l();
|
668
668
|
let O = e;
|
669
|
-
(t.value === "(" && !/[!=<:]/.test(_) || _ === "<" && !/<([!=]|\w+>)/.test(
|
669
|
+
(t.value === "(" && !/[!=<:]/.test(_) || _ === "<" && !/<([!=]|\w+>)/.test(V())) && (O = `\\${e}`), h({ type: "text", value: e, output: O });
|
670
670
|
continue;
|
671
671
|
}
|
672
672
|
if (r.dot !== !0 && (t.type === "slash" || t.type === "bos")) {
|
@@ -712,7 +712,7 @@ function Nt() {
|
|
712
712
|
}
|
713
713
|
if (e !== "*") {
|
714
714
|
(e === "$" || e === "^") && (e = `\\${e}`);
|
715
|
-
const n = g.exec(
|
715
|
+
const n = g.exec(V());
|
716
716
|
n && (e += n[0], s.index += n[0].length), h({ type: "text", value: e });
|
717
717
|
continue;
|
718
718
|
}
|
@@ -720,7 +720,7 @@ function Nt() {
|
|
720
720
|
t.type = "star", t.star = !0, t.value += e, t.output = X, s.backtrack = !0, s.globstar = !0, J(e);
|
721
721
|
continue;
|
722
722
|
}
|
723
|
-
let i =
|
723
|
+
let i = V();
|
724
724
|
if (r.noextglob !== !0 && /^\([^?]/.test(i)) {
|
725
725
|
q("star", e);
|
726
726
|
continue;
|
@@ -766,28 +766,28 @@ function Nt() {
|
|
766
766
|
s.output = s.output.slice(0, -t.output.length), t.type = "globstar", t.output = j(r), t.value += e, s.output += t.output, s.globstar = !0, J(e);
|
767
767
|
continue;
|
768
768
|
}
|
769
|
-
const
|
769
|
+
const T = { type: "star", value: e, output: X };
|
770
770
|
if (r.bash === !0) {
|
771
|
-
|
771
|
+
T.output = ".*?", (t.type === "bos" || t.type === "slash") && (T.output = v + T.output), h(T);
|
772
772
|
continue;
|
773
773
|
}
|
774
774
|
if (t && (t.type === "bracket" || t.type === "paren") && r.regex === !0) {
|
775
|
-
|
775
|
+
T.output = e, h(T);
|
776
776
|
continue;
|
777
777
|
}
|
778
|
-
(s.index === s.start || t.type === "slash" || t.type === "dot") && (t.type === "dot" ? (s.output += st, t.output += st) : r.dot === !0 ? (s.output += M, t.output += M) : (s.output += v, t.output += v), l() !== "*" && (s.output += B, t.output += B)), h(
|
778
|
+
(s.index === s.start || t.type === "slash" || t.type === "dot") && (t.type === "dot" ? (s.output += st, t.output += st) : r.dot === !0 ? (s.output += M, t.output += M) : (s.output += v, t.output += v), l() !== "*" && (s.output += B, t.output += B)), h(T);
|
779
779
|
}
|
780
780
|
for (; s.brackets > 0; ) {
|
781
781
|
if (r.strictBrackets === !0) throw new SyntaxError(f("closing", "]"));
|
782
|
-
s.output = A.escapeLast(s.output, "["),
|
782
|
+
s.output = A.escapeLast(s.output, "["), Z("brackets");
|
783
783
|
}
|
784
784
|
for (; s.parens > 0; ) {
|
785
785
|
if (r.strictBrackets === !0) throw new SyntaxError(f("closing", ")"));
|
786
|
-
s.output = A.escapeLast(s.output, "("),
|
786
|
+
s.output = A.escapeLast(s.output, "("), Z("parens");
|
787
787
|
}
|
788
788
|
for (; s.braces > 0; ) {
|
789
789
|
if (r.strictBrackets === !0) throw new SyntaxError(f("closing", "}"));
|
790
|
-
s.output = A.escapeLast(s.output, "{"),
|
790
|
+
s.output = A.escapeLast(s.output, "{"), Z("braces");
|
791
791
|
}
|
792
792
|
if (r.strictSlashes !== !0 && (t.type === "star" || t.type === "bracket") && h({ type: "maybe_slash", value: "", output: `${Y}?` }), s.backtrack === !0) {
|
793
793
|
s.output = "";
|
@@ -806,12 +806,12 @@ function Nt() {
|
|
806
806
|
SLASH_LITERAL: S,
|
807
807
|
ONE_CHAR: I,
|
808
808
|
DOTS_SLASH: F,
|
809
|
-
NO_DOT:
|
809
|
+
NO_DOT: L,
|
810
810
|
NO_DOTS: G,
|
811
811
|
NO_DOTS_SLASH: b,
|
812
812
|
STAR: Y,
|
813
813
|
START_ANCHOR: B
|
814
|
-
} = p.globChars(r.windows), W = r.dot ? G :
|
814
|
+
} = p.globChars(r.windows), W = r.dot ? G : L, w = r.dot ? b : L, st = r.capture ? "" : "?:", M = { negated: !1, prefix: "" };
|
815
815
|
let H = r.bash === !0 ? ".*?" : Y;
|
816
816
|
r.capture && (H = `(${H})`);
|
817
817
|
const N = (v) => v.noglobstar === !0 ? H : `(${st}(?:(?!${B}${v.dot ? F : y}).)*?)`, tt = (v) => {
|
@@ -852,8 +852,8 @@ function It() {
|
|
852
852
|
if (Array.isArray(u)) {
|
853
853
|
const S = u.map((F) => o(F, a, f));
|
854
854
|
return (F) => {
|
855
|
-
for (const
|
856
|
-
const G =
|
855
|
+
for (const L of S) {
|
856
|
+
const G = L(F);
|
857
857
|
if (G) return G;
|
858
858
|
}
|
859
859
|
return !1;
|
@@ -870,7 +870,7 @@ function It() {
|
|
870
870
|
m = o(c.ignore, S, f);
|
871
871
|
}
|
872
872
|
const y = (S, I = !1) => {
|
873
|
-
const { isMatch: F, match:
|
873
|
+
const { isMatch: F, match: L, output: G } = o.test(S, r, a, { glob: u, posix: E }), b = { glob: u, state: $, regex: r, posix: E, input: S, output: G, match: L, isMatch: F };
|
874
874
|
return typeof c.onResult == "function" && c.onResult(b), F === !1 ? (b.isMatch = !1, I ? b : !1) : m(S) ? (typeof c.onIgnore == "function" && c.onIgnore(b), b.isMatch = !1, I ? b : !1) : (typeof c.onMatch == "function" && c.onMatch(b), I ? b : !0);
|
875
875
|
};
|
876
876
|
return f && (y.state = $), y;
|
@@ -932,7 +932,7 @@ function Gt(p, A, R) {
|
|
932
932
|
return mt(
|
933
933
|
...p.map((d) => Bt(d, A, R))
|
934
934
|
).pipe(
|
935
|
-
|
935
|
+
Tt((d) => {
|
936
936
|
const g = [];
|
937
937
|
for (const a of d)
|
938
938
|
a.status === "in-progress" ? g.push(...a?.progress ?? []) : a.status === "done" ? g.push(...a.result) : a.status === "error" ? g.push(...a.progress ?? []) : a.status === "cancelled" && g.push(...a.progress ?? []);
|
@@ -953,7 +953,7 @@ function Gt(p, A, R) {
|
|
953
953
|
);
|
954
954
|
}
|
955
955
|
function Bt(p, A, R) {
|
956
|
-
return
|
956
|
+
return Lt(p), new $t((d) => {
|
957
957
|
d.next({
|
958
958
|
status: "in-progress",
|
959
959
|
progress: []
|
@@ -1048,4 +1048,4 @@ export {
|
|
1048
1048
|
Xt as nodeGlobTool,
|
1049
1049
|
Mt as ripgrepFiles
|
1050
1050
|
};
|
1051
|
-
//# sourceMappingURL=glob.node-
|
1051
|
+
//# sourceMappingURL=glob.node-B0mTFFtz.js.map
|