@sourcegraph/amp 0.0.1748592090-g82886f → 0.0.1748606491-gd5f622

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.
Files changed (40) hide show
  1. package/dist/amp.js +2 -2
  2. package/dist/{color-KZLHE9lz.js → color-DWbYEM4a.js} +136 -122
  3. package/dist/color-DWbYEM4a.js.map +1 -0
  4. package/dist/{create_file.node-CeO77-N9.js → create_file.node-bNP_q1DK.js} +2 -2
  5. package/dist/{create_file.node-CeO77-N9.js.map → create_file.node-bNP_q1DK.js.map} +1 -1
  6. package/dist/{edit_file.node-BRayGlMY.js → edit_file.node-XfOTJyMK.js} +10 -10
  7. package/dist/{edit_file.node-BRayGlMY.js.map → edit_file.node-XfOTJyMK.js.map} +1 -1
  8. package/dist/{executable-rYoa-LRU.js → executable-BQwwBwPM.js} +2 -2
  9. package/dist/{executable-rYoa-LRU.js.map → executable-BQwwBwPM.js.map} +1 -1
  10. package/dist/{files-DRNnhOmo.js → files-CNpc3qfn.js} +2 -2
  11. package/dist/{files-DRNnhOmo.js.map → files-CNpc3qfn.js.map} +1 -1
  12. package/dist/{glob.node-agGBjrBg.js → glob.node-Be6IkRaA.js} +40 -40
  13. package/dist/{glob.node-agGBjrBg.js.map → glob.node-Be6IkRaA.js.map} +1 -1
  14. package/dist/{list_directory.node-TYM6mPMl.js → list_directory.node-DgNuSnuF.js} +2 -2
  15. package/dist/{list_directory.node-TYM6mPMl.js.map → list_directory.node-DgNuSnuF.js.map} +1 -1
  16. package/dist/{load-profile-DfzWNpRA.js → load-profile-Nd8bHROp.js} +2 -2
  17. package/dist/{load-profile-DfzWNpRA.js.map → load-profile-Nd8bHROp.js.map} +1 -1
  18. package/dist/{main-d0nDM7GJ.js → main-BwXeL2d_.js} +4603 -4594
  19. package/dist/{main-d0nDM7GJ.js.map → main-BwXeL2d_.js.map} +1 -1
  20. package/dist/{node-CDZC4DW9.js → node-Bk40W4Y0.js} +3 -3
  21. package/dist/{node-CDZC4DW9.js.map → node-Bk40W4Y0.js.map} +1 -1
  22. package/dist/{node-XQHPbSSO.js → node-CvPxW0zu.js} +3 -3
  23. package/dist/{node-XQHPbSSO.js.map → node-CvPxW0zu.js.map} +1 -1
  24. package/dist/{node-COuJYHx_.js → node-DTPo1BPg.js} +2 -2
  25. package/dist/{node-COuJYHx_.js.map → node-DTPo1BPg.js.map} +1 -1
  26. package/dist/{node-DWXaFMNz.js → node-D_wBXMvd.js} +2 -2
  27. package/dist/{node-DWXaFMNz.js.map → node-D_wBXMvd.js.map} +1 -1
  28. package/dist/{node-HdWhJMp3.js → node-QAVfVAJ0.js} +7 -7
  29. package/dist/{node-HdWhJMp3.js.map → node-QAVfVAJ0.js.map} +1 -1
  30. package/dist/{node-DkV0OdKk.js → node-_PrF9PME.js} +16 -16
  31. package/dist/{node-DkV0OdKk.js.map → node-_PrF9PME.js.map} +1 -1
  32. package/dist/{read_file.node-2KNKpy--.js → read_file.node-D4T78vUr.js} +2 -2
  33. package/dist/{read_file.node-2KNKpy--.js.map → read_file.node-D4T78vUr.js.map} +1 -1
  34. package/dist/{stdio-GkdttQu7.js → stdio-BFbLdCh7.js} +3 -3
  35. package/dist/{stdio-GkdttQu7.js.map → stdio-BFbLdCh7.js.map} +1 -1
  36. package/dist/storybook.js +1 -1
  37. package/dist/{undo_edit.node-C8Hv1wkP.js → undo_edit.node-Dgk-4gRe.js} +6 -6
  38. package/dist/{undo_edit.node-C8Hv1wkP.js.map → undo_edit.node-Dgk-4gRe.js.map} +1 -1
  39. package/package.json +1 -1
  40. package/dist/color-KZLHE9lz.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, aT as l, a9 as u } from "./color-KZLHE9lz.js";
3
+ import { p as f, aU as l, ab as u } from "./color-DWbYEM4a.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-CeO77-N9.js.map
24
+ //# sourceMappingURL=create_file.node-bNP_q1DK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create_file.node-CeO77-N9.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
+ {"version":3,"file":"create_file.node-bNP_q1DK.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, aT as m, a9 as F, aX as v, aY as _, aZ as b } from "./color-KZLHE9lz.js";
3
- import { recordEdit as x } from "./undo_edit.node-C8Hv1wkP.js";
4
- class T {
2
+ import { p, aU as m, ab as F, aY as _, aZ as b, a_ as v } from "./color-DWbYEM4a.js";
3
+ import { recordEdit as x } from "./undo_edit.node-Dgk-4gRe.js";
4
+ class y {
5
5
  #e = !1;
6
6
  #t = [];
7
7
  /**
@@ -21,13 +21,13 @@ class T {
21
21
  this.#t.length > 0 ? this.#t.shift()?.() : this.#e = !1;
22
22
  }
23
23
  }
24
- const l = new T(), k = ({ args: e }, { dir: t, dirs: d, threadID: u, trackFileChange: h, filesystem: i }) => p(async (a) => {
24
+ const l = new y(), 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
- y(e), m(t);
27
+ E(e), m(t);
28
28
  const r = await F(i, d, e.path, a);
29
29
  if (!i.exclusiveWriter) {
30
- const s = v(r, u), c = await i.getMtime(r);
30
+ const s = _(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 T(), 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 b(
41
41
  e.path,
42
42
  n,
43
43
  e.old_str,
@@ -58,11 +58,11 @@ const l = new T(), k = ({ args: e }, { dir: t, dirs: d, threadID: u, trackFileCh
58
58
  l.release();
59
59
  }
60
60
  });
61
- function y(e) {
62
- if (e = b.parse(e), e.old_str === e.new_str)
61
+ function E(e) {
62
+ if (e = v.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-BRayGlMY.js.map
68
+ //# sourceMappingURL=edit_file.node-XfOTJyMK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"edit_file.node-BRayGlMY.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
+ {"version":3,"file":"edit_file.node-XfOTJyMK.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-KZLHE9lz.js";
4
+ import { n as i } from "./color-DWbYEM4a.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-rYoa-LRU.js.map
18
+ //# sourceMappingURL=executable-BQwwBwPM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"executable-rYoa-LRU.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
+ {"version":3,"file":"executable-BQwwBwPM.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 { b4 as I, b5 as T, n as z, b6 as B, b7 as P } from "./color-KZLHE9lz.js";
3
+ import { b5 as I, b6 as T, n as z, b7 as B, b8 as P } from "./color-DWbYEM4a.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-DRNnhOmo.js.map
70
+ //# sourceMappingURL=files-CNpc3qfn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"files-DRNnhOmo.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
+ {"version":3,"file":"files-CNpc3qfn.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 Tt, aT as Lt, n as vt } from "./color-KZLHE9lz.js";
4
- import { r as Ot } from "./executable-rYoa-LRU.js";
3
+ import { k as Ht, O as $t, g as mt, m as Lt, aU as Tt, n as vt } from "./color-DWbYEM4a.js";
4
+ import { r as Ot } from "./executable-BQwwBwPM.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
- }, L = {
26
+ }, T = {
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 ? L : F;
177
+ return b === !0 ? T : F;
178
178
  }
179
179
  }, ft;
180
180
  }
@@ -244,12 +244,12 @@ function wt() {
244
244
  /* ) */
245
245
  CHAR_RIGHT_SQUARE_BRACKET: y
246
246
  /* ] */
247
- } = /* @__PURE__ */ it(), S = (L) => L === a || L === d, I = (L) => {
248
- L.isPrefix !== !0 && (L.depth = L.isGlobstar ? 1 / 0 : 1);
247
+ } = /* @__PURE__ */ it(), S = (T) => T === a || T === d, I = (T) => {
248
+ T.isPrefix !== !0 && (T.depth = T.isGlobstar ? 1 / 0 : 1);
249
249
  };
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 };
250
+ return ht = (T, G) => {
251
+ const b = G || {}, Y = T.length - 1, B = b.parts === !0 || b.scanToEnd === !0, W = [], w = [], st = [];
252
+ let M = T, 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
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();
@@ -368,7 +368,7 @@ function wt() {
368
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: L,
371
+ input: T,
372
372
  start: N,
373
373
  base: D,
374
374
  glob: Z,
@@ -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, 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;
386
+ const i = q ? q + 1 : N, L = W[K], n = T.slice(i, L);
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 = L;
388
388
  }
389
- if (q && q + 1 < L.length) {
390
- const K = L.slice(q + 1);
389
+ if (q && q + 1 < T.length) {
390
+ const K = T.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), L = p.extglobChars(F), {
427
+ const y = { type: "bos", value: "", output: r.prepend || "" }, S = [y], I = r.capture ? "" : "?:", F = p.globChars(r.windows), T = 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] || "", V = () => c.slice(s.index + 1), J = (i = "", T = 0) => {
464
- s.consumed += i, s.index += T;
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 = "", L = 0) => {
464
+ s.consumed += i, s.index += L;
465
465
  }, U = (i) => {
466
466
  s.output += i.output != null ? i.output : i.value, J(i.value);
467
467
  }, D = () => {
@@ -475,34 +475,34 @@ function Nt() {
475
475
  s[i]--, ut.pop();
476
476
  }, h = (i) => {
477
477
  if (t.type === "globstar") {
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);
478
+ const L = 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" && !L && !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, T) => {
487
- const n = { ...L[T], conditions: 1, inner: "" };
486
+ }, q = (i, L) => {
487
+ const n = { ...T[L], 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: T, output: s.output ? "" : B }), h({ type: "paren", extglob: !0, value: C(), output: _ }), k.push(n);
490
+ ot("parens"), h({ type: i, value: L, output: s.output ? "" : B }), h({ type: "paren", extglob: !0, value: C(), output: _ }), k.push(n);
491
491
  }, K = (i) => {
492
- let T = i.close + (r.capture ? ")" : ""), n;
492
+ let L = 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(V())) && (T = i.close = `)$))${_}`), i.inner.includes("*") && (n = V()) && /^\.[^\\/.]+$/.test(n)) {
495
+ if (i.inner && i.inner.length > 1 && i.inner.includes("/") && (_ = j(r)), (_ !== X || nt() || /^\)+$/.test(V())) && (L = i.close = `)$))${_}`), i.inner.includes("*") && (n = V()) && /^\.[^\\/.]+$/.test(n)) {
496
496
  const O = x(n, { ...E, fastpaths: !1 }).output;
497
- T = i.close = `)${O})${_})`;
497
+ L = 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: T }), Z("parens");
501
+ h({ type: "paren", extglob: !0, value: e, output: L }), Z("parens");
502
502
  };
503
503
  if (r.fastpaths !== !1 && !/(^[*!]|[/()[\]{}"])/.test(c)) {
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);
504
+ let i = !1, L = 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 ? L = L.replace(/\\/g, "") : L = L.replace(/\\+/g, (n) => n.length % 2 === 0 ? "\\\\" : n ? "\\" : "")), L === c && r.contains === !0 ? (s.output = c, s) : (s.output = A.wrapOutput(L, s, E), s);
506
506
  }
507
507
  for (; !nt(); ) {
508
508
  if (e = C(), e === "\0")
@@ -766,16 +766,16 @@ 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 T = { type: "star", value: e, output: X };
769
+ const L = { type: "star", value: e, output: X };
770
770
  if (r.bash === !0) {
771
- T.output = ".*?", (t.type === "bos" || t.type === "slash") && (T.output = v + T.output), h(T);
771
+ L.output = ".*?", (t.type === "bos" || t.type === "slash") && (L.output = v + L.output), h(L);
772
772
  continue;
773
773
  }
774
774
  if (t && (t.type === "bracket" || t.type === "paren") && r.regex === !0) {
775
- T.output = e, h(T);
775
+ L.output = e, h(L);
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(T);
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(L);
779
779
  }
780
780
  for (; s.brackets > 0; ) {
781
781
  if (r.strictBrackets === !0) throw new SyntaxError(f("closing", "]"));
@@ -806,12 +806,12 @@ function Nt() {
806
806
  SLASH_LITERAL: S,
807
807
  ONE_CHAR: I,
808
808
  DOTS_SLASH: F,
809
- NO_DOT: L,
809
+ NO_DOT: T,
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 : L, w = r.dot ? b : L, st = r.capture ? "" : "?:", M = { negated: !1, prefix: "" };
814
+ } = p.globChars(r.windows), W = r.dot ? G : T, w = r.dot ? b : T, 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 L of S) {
856
- const G = L(F);
855
+ for (const T of S) {
856
+ const G = T(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: 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 };
873
+ const { isMatch: F, match: T, output: G } = o.test(S, r, a, { glob: u, posix: E }), b = { glob: u, state: $, regex: r, posix: E, input: S, output: G, match: T, 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
- Tt((d) => {
935
+ Lt((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 Lt(p), new $t((d) => {
956
+ return Tt(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-agGBjrBg.js.map
1051
+ //# sourceMappingURL=glob.node-Be6IkRaA.js.map