@sourcegraph/amp 0.0.1748865683-g71e54e → 0.0.1748880131-g73e573

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 (46) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/{client-BWw-YoAm.js → client-Byn34k3j.js} +2 -2
  3. package/dist/{client-BWw-YoAm.js.map → client-Byn34k3j.js.map} +1 -1
  4. package/dist/{console-CTjwGR94.js → console-DU9kM8bt.js} +7700 -7964
  5. package/dist/console-DU9kM8bt.js.map +1 -0
  6. package/dist/{create_file.node-vNn4fbhz.js → create_file.node-ClSLp2zA.js} +2 -2
  7. package/dist/{create_file.node-vNn4fbhz.js.map → create_file.node-ClSLp2zA.js.map} +1 -1
  8. package/dist/{edit_file.node-CT1vyl1i.js → edit_file.node-sQFRZtsD.js} +3 -3
  9. package/dist/{edit_file.node-CT1vyl1i.js.map → edit_file.node-sQFRZtsD.js.map} +1 -1
  10. package/dist/{executable-BrAdMU71.js → executable-2OB-i_QC.js} +2 -2
  11. package/dist/{executable-BrAdMU71.js.map → executable-2OB-i_QC.js.map} +1 -1
  12. package/dist/{files-BOfdJygp.js → files-BhysNTQv.js} +2 -2
  13. package/dist/{files-BOfdJygp.js.map → files-BhysNTQv.js.map} +1 -1
  14. package/dist/{glob.node-4tOopzOM.js → glob.node-cVUTfljn.js} +4 -4
  15. package/dist/{glob.node-4tOopzOM.js.map → glob.node-cVUTfljn.js.map} +1 -1
  16. package/dist/{index-NLHysr2h.js → index-Cb59cjjj.js} +2 -2
  17. package/dist/{index-NLHysr2h.js.map → index-Cb59cjjj.js.map} +1 -1
  18. package/dist/{list_directory.node-updCUrTG.js → list_directory.node-B8Oj3ncW.js} +2 -2
  19. package/dist/{list_directory.node-updCUrTG.js.map → list_directory.node-B8Oj3ncW.js.map} +1 -1
  20. package/dist/{load-profile-DZZRFAc9.js → load-profile-CV3b6-Nj.js} +2 -2
  21. package/dist/{load-profile-DZZRFAc9.js.map → load-profile-CV3b6-Nj.js.map} +1 -1
  22. package/dist/{main-BJVONhWT.js → main-CZ7RS9Yt.js} +8534 -8317
  23. package/dist/main-CZ7RS9Yt.js.map +1 -0
  24. package/dist/{node-BtSehPh_.js → node-B45lZe2M.js} +3 -3
  25. package/dist/{node-BtSehPh_.js.map → node-B45lZe2M.js.map} +1 -1
  26. package/dist/{node-DGpCXn3p.js → node-B4WUHHZd.js} +2 -2
  27. package/dist/{node-DGpCXn3p.js.map → node-B4WUHHZd.js.map} +1 -1
  28. package/dist/{node-S3C83o8k.js → node-BPXlKmtc.js} +2 -2
  29. package/dist/{node-S3C83o8k.js.map → node-BPXlKmtc.js.map} +1 -1
  30. package/dist/{node-DIQSaLGP.js → node-B_G-Clj6.js} +3 -3
  31. package/dist/{node-DIQSaLGP.js.map → node-B_G-Clj6.js.map} +1 -1
  32. package/dist/{node-BkgN80SA.js → node-DujrrqQo.js} +4 -4
  33. package/dist/{node-BkgN80SA.js.map → node-DujrrqQo.js.map} +1 -1
  34. package/dist/{node-iqSbLvK6.js → node-UKopbCpJ.js} +1094 -837
  35. package/dist/node-UKopbCpJ.js.map +1 -0
  36. package/dist/{read_file.node-B7tSIDli.js → read_file.node-gXffR6jB.js} +2 -2
  37. package/dist/{read_file.node-B7tSIDli.js.map → read_file.node-gXffR6jB.js.map} +1 -1
  38. package/dist/{stdio-nUAEiLxy.js → stdio-B7u3y1kB.js} +3 -3
  39. package/dist/{stdio-nUAEiLxy.js.map → stdio-B7u3y1kB.js.map} +1 -1
  40. package/dist/storybook.js +1 -1
  41. package/dist/{undo_edit.node-BYhKjjZF.js → undo_edit.node-BQSDe2Ll.js} +2 -2
  42. package/dist/{undo_edit.node-BYhKjjZF.js.map → undo_edit.node-BQSDe2Ll.js.map} +1 -1
  43. package/package.json +1 -1
  44. package/dist/console-CTjwGR94.js.map +0 -1
  45. package/dist/main-BJVONhWT.js.map +0 -1
  46. package/dist/node-iqSbLvK6.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { f as a } from "./client-BWw-YoAm.js";
3
- import { p as u, aP as c } from "./console-CTjwGR94.js";
2
+ import { f as a } from "./client-Byn34k3j.js";
3
+ import { p as u, aP as c } from "./console-DU9kM8bt.js";
4
4
  const l = ({ args: o }, { threadID: t }) => u(async (s) => {
5
5
  try {
6
6
  const r = `/api/web-search?query=${encodeURIComponent(o.query)}&numResults=${o.num_results || 5}`, e = await a(r, {
@@ -23,4 +23,4 @@ const l = ({ args: o }, { threadID: t }) => u(async (s) => {
23
23
  export {
24
24
  l as nodeWebSearchTool
25
25
  };
26
- //# sourceMappingURL=node-BtSehPh_.js.map
26
+ //# sourceMappingURL=node-B45lZe2M.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-BtSehPh_.js","sources":["../../core/src/tools/builtin/web_search/node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { fetchFromAmpServer } from '../../../server-api/client'\nimport { HEADER_KEY_THREAD_ID } from '../../../server-api/headers'\nimport type { webSearchToolReg } from './common'\n\nexport const nodeWebSearchTool: NonNullable<(typeof webSearchToolReg)['fn']> = (\n\t{ args },\n\t{ threadID },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\ttry {\n\t\t\t// Call the server endpoint using the fetchFromAmpServer helper\n\t\t\tconst url = `/api/web-search?query=${encodeURIComponent(args.query)}&numResults=${args.num_results || 5}`\n\t\t\tconst response = await fetchFromAmpServer(url, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tsignal,\n\t\t\t\theaders: threadID ? { [HEADER_KEY_THREAD_ID]: threadID } : undefined,\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text()\n\t\t\t\tthrow new Error(`Server returned ${response.status}: ${errorText}`)\n\t\t\t}\n\n\t\t\tconst results = await response.json()\n\t\t\treturn {\n\t\t\t\tstatus: 'done' as const,\n\t\t\t\tresult: results,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to perform web search: ${(error as Error).message}`)\n\t\t}\n\t})\n}\n"],"names":["nodeWebSearchTool","args","threadID","promiseFactoryToObservable","signal","url","response","fetchFromAmpServer","HEADER_KEY_THREAD_ID","errorText","error"],"mappings":";;;AAKO,MAAMA,IAAkE,CAC9E,EAAE,MAAAC,KACF,EAAE,UAAAC,QAEKC,EAA2B,OAAOC,MAAW;AAC/C,MAAA;AAEG,UAAAC,IAAM,yBAAyB,mBAAmBJ,EAAK,KAAK,CAAC,eAAeA,EAAK,eAAe,CAAC,IACjGK,IAAW,MAAMC,EAAmBF,GAAK;AAAA,MAC9C,QAAQ;AAAA,MACR,QAAAD;AAAA,MACA,SAASF,IAAW,EAAE,CAACM,CAAoB,GAAGN,EAAa,IAAA;AAAA,IAAA,CAC3D;AAEG,QAAA,CAACI,EAAS,IAAI;AACX,YAAAG,IAAY,MAAMH,EAAS,KAAK;AACtC,YAAM,IAAI,MAAM,mBAAmBA,EAAS,MAAM,KAAKG,CAAS,EAAE;AAAA,IAAA;AAI5D,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,QAHe,MAAMH,EAAS,KAAK;AAAA,IAIpC;AAAA,WACQI,GAAO;AACf,UAAM,IAAI,MAAM,iCAAkCA,EAAgB,OAAO,EAAE;AAAA,EAAA;AAC5E,CACA;"}
1
+ {"version":3,"file":"node-B45lZe2M.js","sources":["../../core/src/tools/builtin/web_search/node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport { fetchFromAmpServer } from '../../../server-api/client'\nimport { HEADER_KEY_THREAD_ID } from '../../../server-api/headers'\nimport type { webSearchToolReg } from './common'\n\nexport const nodeWebSearchTool: NonNullable<(typeof webSearchToolReg)['fn']> = (\n\t{ args },\n\t{ threadID },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\ttry {\n\t\t\t// Call the server endpoint using the fetchFromAmpServer helper\n\t\t\tconst url = `/api/web-search?query=${encodeURIComponent(args.query)}&numResults=${args.num_results || 5}`\n\t\t\tconst response = await fetchFromAmpServer(url, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tsignal,\n\t\t\t\theaders: threadID ? { [HEADER_KEY_THREAD_ID]: threadID } : undefined,\n\t\t\t})\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text()\n\t\t\t\tthrow new Error(`Server returned ${response.status}: ${errorText}`)\n\t\t\t}\n\n\t\t\tconst results = await response.json()\n\t\t\treturn {\n\t\t\t\tstatus: 'done' as const,\n\t\t\t\tresult: results,\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to perform web search: ${(error as Error).message}`)\n\t\t}\n\t})\n}\n"],"names":["nodeWebSearchTool","args","threadID","promiseFactoryToObservable","signal","url","response","fetchFromAmpServer","HEADER_KEY_THREAD_ID","errorText","error"],"mappings":";;;AAKO,MAAMA,IAAkE,CAC9E,EAAE,MAAAC,KACF,EAAE,UAAAC,QAEKC,EAA2B,OAAOC,MAAW;AAC/C,MAAA;AAEG,UAAAC,IAAM,yBAAyB,mBAAmBJ,EAAK,KAAK,CAAC,eAAeA,EAAK,eAAe,CAAC,IACjGK,IAAW,MAAMC,EAAmBF,GAAK;AAAA,MAC9C,QAAQ;AAAA,MACR,QAAAD;AAAA,MACA,SAASF,IAAW,EAAE,CAACM,CAAoB,GAAGN,EAAa,IAAA;AAAA,IAAA,CAC3D;AAEG,QAAA,CAACI,EAAS,IAAI;AACX,YAAAG,IAAY,MAAMH,EAAS,KAAK;AACtC,YAAM,IAAI,MAAM,mBAAmBA,EAAS,MAAM,KAAKG,CAAS,EAAE;AAAA,IAAA;AAI5D,WAAA;AAAA,MACN,QAAQ;AAAA,MACR,QAHe,MAAMH,EAAS,KAAK;AAAA,IAIpC;AAAA,WACQI,GAAO;AACf,UAAM,IAAI,MAAM,iCAAkCA,EAAgB,OAAO,EAAE;AAAA,EAAA;AAC5E,CACA;"}
@@ -4,7 +4,7 @@ import * as i from "node:fs";
4
4
  import * as o from "node:path";
5
5
  import { join as f } from "node:path";
6
6
  import { promisify as p } from "node:util";
7
- import { C as l, aH as n } from "./console-CTjwGR94.js";
7
+ import { C as l, aH as n } from "./console-DU9kM8bt.js";
8
8
  import { homedir as w } from "node:os";
9
9
  const d = f(w(), ".amp", "file-changes"), u = p(m);
10
10
  function b(a) {
@@ -110,4 +110,4 @@ export {
110
110
  y as listFilesGit,
111
111
  b as nodeFileSystem
112
112
  };
113
- //# sourceMappingURL=node-DGpCXn3p.js.map
113
+ //# sourceMappingURL=node-B4WUHHZd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-DGpCXn3p.js","sources":["../../core/src/platform/fs/backups.node.ts","../../core/src/platform/fs/node.ts"],"sourcesContent":["import { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport const BACKUP_DIR_NODE = join(homedir(), '.amp', 'file-changes')\n","import { execFile } from 'node:child_process'\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { promisify } from 'node:util'\nimport logger from '../../common/logger'\nimport { type FileChangeRecord } from '../../threads/file-tracking/common'\nimport type { ThreadID } from '../../threads/thread'\nimport { BACKUP_DIR_NODE } from './backups.node'\nimport { FileNotExistError, type FileSystem } from './fs'\n\nconst execFileAsync = promisify(execFile)\n\nexport function nodeFileSystem(threadID: ThreadID): FileSystem {\n\tconst backupDir = path.join(BACKUP_DIR_NODE, threadID)\n\treturn {\n\t\trelativePath: (a: string, b: string) => path.relative(a, b),\n\t\tjoinPath: (...paths: string[]) => path.join(...paths),\n\n\t\treadFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\treturn await fs.promises.readFile(path, { encoding: 'utf8', signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\treadBinaryFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Read as Buffer without encoding\n\t\t\t\treturn await fs.promises.readFile(path, { signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tgetMtime: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Node.js stat doesn't support AbortSignal directly\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn stats.mtimeMs\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tstat: async (path: string) => {\n\t\t\ttry {\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn {\n\t\t\t\t\tsize: stats.size,\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\twriteFile: async (path, content, signal) => {\n\t\t\tawait fs.promises.writeFile(path, content, { encoding: 'utf-8', signal })\n\t\t},\n\t\tdeleteFile: async (path, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\tawait fs.promises.unlink(path)\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tmkdirp: async (path) => {\n\t\t\tawait fs.promises.mkdir(path, { recursive: true })\n\t\t},\n\t\tstoreFileChange: async (backupFileName: string, fileChange: FileChangeRecord) => {\n\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\tawait fs.promises.writeFile(backupPath, JSON.stringify(fileChange, null, 2), 'utf8')\n\t\t},\n\t\tlistBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\t// Ensure backup directory exists\n\t\t\t\tif (\n\t\t\t\t\t!(await fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false))\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.mkdir(backupDir, { recursive: true })\n\t\t\t\t\treturn []\n\t\t\t\t}\n\t\t\t\treturn await fs.promises.readdir(backupDir)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Error listing backup files:', error)\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t\tloadFileChange: async (backupFileName: string) => {\n\t\t\ttry {\n\t\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\t\tconst content = await fs.promises.readFile(backupPath, 'utf8')\n\t\t\t\treturn JSON.parse(content) as FileChangeRecord\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error loading backup file ${backupFileName}:`, error)\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\t\tcleanupBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\tawait fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false)\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.rm(backupDir, { recursive: true, force: true })\n\t\t\t\t\tlogger.debug(`Cleaned up backup directory: ${backupDir}`)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error cleaning up backup files in ${backupDir}:`, error)\n\t\t\t}\n\t\t},\n\t\tlistFiles: async (dir: string) => listFilesGit(dir),\n\t\texclusiveWriter: false,\n\t}\n}\n\nfunction isNodeFSNotExistError(error: unknown): boolean {\n\treturn (\n\t\terror !== null &&\n\t\ttypeof error === 'object' &&\n\t\t'code' in error &&\n\t\t(error as { code: string }).code === 'ENOENT'\n\t)\n}\n\n/**\n * Lists files in a directory using git ls-files.\n * Exported for reuse by other filesystem implementations.\n */\nexport async function listFilesGit(dir: string): Promise<string[]> {\n\ttry {\n\t\tconst { stdout: trackedFiles } = await execFileAsync('git', ['ls-files'], {\n\t\t\tcwd: dir,\n\t\t})\n\n\t\tconst { stdout: untrackedFiles } = await execFileAsync(\n\t\t\t'git',\n\t\t\t['ls-files', '--others', '--exclude-standard'],\n\t\t\t{\n\t\t\t\tcwd: dir,\n\t\t\t},\n\t\t)\n\n\t\treturn [...trackedFiles.split('\\n'), ...untrackedFiles.split('\\n')].filter(Boolean)\n\t} catch {\n\t\treturn []\n\t}\n}\n"],"names":["BACKUP_DIR_NODE","join","homedir","execFileAsync","promisify","execFile","nodeFileSystem","threadID","backupDir","path","a","b","paths","signal","fs","error","isNodeFSNotExistError","FileNotExistError","content","backupFileName","fileChange","backupPath","s","logger","dir","listFilesGit","trackedFiles","untrackedFiles"],"mappings":";;;;;;;;AAGO,MAAMA,IAAkBC,EAAKC,KAAW,QAAQ,cAAc,GCO/DC,IAAgBC,EAAUC,CAAQ;AAEjC,SAASC,EAAeC,GAAgC;AAC9D,QAAMC,IAAYC,EAAK,KAAKT,GAAiBO,CAAQ;AAC9C,SAAA;AAAA,IACN,cAAc,CAACG,GAAWC,MAAcF,EAAK,SAASC,GAAGC,CAAC;AAAA,IAC1D,UAAU,IAAIC,MAAoBH,EAAK,KAAK,GAAGG,CAAK;AAAA,IAEpD,UAAU,OAAOH,GAAcI,MAAyB;AACnD,UAAA;AACI,eAAA,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,UAAU,QAAQ,QAAAI,GAAQ;AAAA,eAC5DE,GAAO;AACX,cAAAC,EAAsBD,CAAK,IACxB,IAAIE,EAAkBR,CAAI,IAE3BM;AAAA,MAAA;AAAA,IAER;AAAA,IACA,gBAAgB,OAAON,GAAcI,MAAyB;AACzD,UAAA;AAEH,eAAO,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,QAAAI,GAAQ;AAA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IAAA,CACL,GAEK,EAAE,QAAQG,EAAe,IAAI,MAAMxB;AAAA,MACxC;AAAA,MACA,CAAC,YAAY,YAAY,oBAAoB;AAAA,MAC7C;AAAA,QACC,KAAKqB;AAAA,MAAA;AAAA,IAEP;AAEA,WAAO,CAAC,GAAGE,EAAa,MAAM;AAAA,CAAI,GAAG,GAAGC,EAAe,MAAM;AAAA,CAAI,CAAC,EAAE,OAAO,OAAO;AAAA,EAAA,QAC3E;AACP,WAAO,CAAC;AAAA,EAAA;AAEV;"}
1
+ {"version":3,"file":"node-B4WUHHZd.js","sources":["../../core/src/platform/fs/backups.node.ts","../../core/src/platform/fs/node.ts"],"sourcesContent":["import { homedir } from 'node:os'\nimport { join } from 'node:path'\n\nexport const BACKUP_DIR_NODE = join(homedir(), '.amp', 'file-changes')\n","import { execFile } from 'node:child_process'\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { promisify } from 'node:util'\nimport logger from '../../common/logger'\nimport { type FileChangeRecord } from '../../threads/file-tracking/common'\nimport type { ThreadID } from '../../threads/thread'\nimport { BACKUP_DIR_NODE } from './backups.node'\nimport { FileNotExistError, type FileSystem } from './fs'\n\nconst execFileAsync = promisify(execFile)\n\nexport function nodeFileSystem(threadID: ThreadID): FileSystem {\n\tconst backupDir = path.join(BACKUP_DIR_NODE, threadID)\n\treturn {\n\t\trelativePath: (a: string, b: string) => path.relative(a, b),\n\t\tjoinPath: (...paths: string[]) => path.join(...paths),\n\n\t\treadFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\treturn await fs.promises.readFile(path, { encoding: 'utf8', signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\treadBinaryFile: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Read as Buffer without encoding\n\t\t\t\treturn await fs.promises.readFile(path, { signal })\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tgetMtime: async (path: string, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\t// Node.js stat doesn't support AbortSignal directly\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn stats.mtimeMs\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tstat: async (path: string) => {\n\t\t\ttry {\n\t\t\t\tconst stats = await fs.promises.stat(path)\n\t\t\t\treturn {\n\t\t\t\t\tsize: stats.size,\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\twriteFile: async (path, content, signal) => {\n\t\t\tawait fs.promises.writeFile(path, content, { encoding: 'utf-8', signal })\n\t\t},\n\t\tdeleteFile: async (path, signal?: AbortSignal) => {\n\t\t\ttry {\n\t\t\t\tawait fs.promises.unlink(path)\n\t\t\t} catch (error) {\n\t\t\t\tif (isNodeFSNotExistError(error)) {\n\t\t\t\t\tthrow new FileNotExistError(path)\n\t\t\t\t}\n\t\t\t\tthrow error\n\t\t\t}\n\t\t},\n\t\tmkdirp: async (path) => {\n\t\t\tawait fs.promises.mkdir(path, { recursive: true })\n\t\t},\n\t\tstoreFileChange: async (backupFileName: string, fileChange: FileChangeRecord) => {\n\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\tawait fs.promises.writeFile(backupPath, JSON.stringify(fileChange, null, 2), 'utf8')\n\t\t},\n\t\tlistBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\t// Ensure backup directory exists\n\t\t\t\tif (\n\t\t\t\t\t!(await fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false))\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.mkdir(backupDir, { recursive: true })\n\t\t\t\t\treturn []\n\t\t\t\t}\n\t\t\t\treturn await fs.promises.readdir(backupDir)\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error('Error listing backup files:', error)\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t\tloadFileChange: async (backupFileName: string) => {\n\t\t\ttry {\n\t\t\t\tconst backupPath = path.join(backupDir, backupFileName)\n\t\t\t\tconst content = await fs.promises.readFile(backupPath, 'utf8')\n\t\t\t\treturn JSON.parse(content) as FileChangeRecord\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error loading backup file ${backupFileName}:`, error)\n\t\t\t\treturn null\n\t\t\t}\n\t\t},\n\t\tcleanupBackupFiles: async () => {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\tawait fs.promises\n\t\t\t\t\t\t.stat(backupDir)\n\t\t\t\t\t\t.then((s) => s.isDirectory())\n\t\t\t\t\t\t.catch(() => false)\n\t\t\t\t) {\n\t\t\t\t\tawait fs.promises.rm(backupDir, { recursive: true, force: true })\n\t\t\t\t\tlogger.debug(`Cleaned up backup directory: ${backupDir}`)\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(`Error cleaning up backup files in ${backupDir}:`, error)\n\t\t\t}\n\t\t},\n\t\tlistFiles: async (dir: string) => listFilesGit(dir),\n\t\texclusiveWriter: false,\n\t}\n}\n\nfunction isNodeFSNotExistError(error: unknown): boolean {\n\treturn (\n\t\terror !== null &&\n\t\ttypeof error === 'object' &&\n\t\t'code' in error &&\n\t\t(error as { code: string }).code === 'ENOENT'\n\t)\n}\n\n/**\n * Lists files in a directory using git ls-files.\n * Exported for reuse by other filesystem implementations.\n */\nexport async function listFilesGit(dir: string): Promise<string[]> {\n\ttry {\n\t\tconst { stdout: trackedFiles } = await execFileAsync('git', ['ls-files'], {\n\t\t\tcwd: dir,\n\t\t})\n\n\t\tconst { stdout: untrackedFiles } = await execFileAsync(\n\t\t\t'git',\n\t\t\t['ls-files', '--others', '--exclude-standard'],\n\t\t\t{\n\t\t\t\tcwd: dir,\n\t\t\t},\n\t\t)\n\n\t\treturn [...trackedFiles.split('\\n'), ...untrackedFiles.split('\\n')].filter(Boolean)\n\t} catch {\n\t\treturn []\n\t}\n}\n"],"names":["BACKUP_DIR_NODE","join","homedir","execFileAsync","promisify","execFile","nodeFileSystem","threadID","backupDir","path","a","b","paths","signal","fs","error","isNodeFSNotExistError","FileNotExistError","content","backupFileName","fileChange","backupPath","s","logger","dir","listFilesGit","trackedFiles","untrackedFiles"],"mappings":";;;;;;;;AAGO,MAAMA,IAAkBC,EAAKC,KAAW,QAAQ,cAAc,GCO/DC,IAAgBC,EAAUC,CAAQ;AAEjC,SAASC,EAAeC,GAAgC;AAC9D,QAAMC,IAAYC,EAAK,KAAKT,GAAiBO,CAAQ;AAC9C,SAAA;AAAA,IACN,cAAc,CAACG,GAAWC,MAAcF,EAAK,SAASC,GAAGC,CAAC;AAAA,IAC1D,UAAU,IAAIC,MAAoBH,EAAK,KAAK,GAAGG,CAAK;AAAA,IAEpD,UAAU,OAAOH,GAAcI,MAAyB;AACnD,UAAA;AACI,eAAA,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,UAAU,QAAQ,QAAAI,GAAQ;AAAA,eAC5DE,GAAO;AACX,cAAAC,EAAsBD,CAAK,IACxB,IAAIE,EAAkBR,CAAI,IAE3BM;AAAA,MAAA;AAAA,IAER;AAAA,IACA,gBAAgB,OAAON,GAAcI,MAAyB;AACzD,UAAA;AAEH,eAAO,MAAMC,EAAG,SAAS,SAASL,GAAM,EAAE,QAAAI,GAAQ;AAAA,eAC1CE,GAAO;AACX,cAAAC,EAAsBD,CAAK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MAAMxB;AAAA,MACxC;AAAA,MACA,CAAC,YAAY,YAAY,oBAAoB;AAAA,MAC7C;AAAA,QACC,KAAKqB;AAAA,MAAA;AAAA,IAEP;AAEA,WAAO,CAAC,GAAGE,EAAa,MAAM;AAAA,CAAI,GAAG,GAAGC,EAAe,MAAM;AAAA,CAAI,CAAC,EAAE,OAAO,OAAO;AAAA,EAAA,QAC3E;AACP,WAAO,CAAC;AAAA,EAAA;AAEV;"}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a9 as Pe, a8 as st, p as lt } from "./console-CTjwGR94.js";
2
+ import { a9 as Pe, a8 as st, p as lt } from "./console-DU9kM8bt.js";
3
3
  var pe = {}, Pu = {}, be = {}, Me;
4
4
  function ne() {
5
5
  return Me || (Me = 1, function(u) {
@@ -4850,4 +4850,4 @@ ${a}`
4850
4850
  export {
4851
4851
  ea as nodeReadWebPageTool
4852
4852
  };
4853
- //# sourceMappingURL=node-S3C83o8k.js.map
4853
+ //# sourceMappingURL=node-BPXlKmtc.js.map