@sourcegraph/amp 0.0.1748894490-ge9fff4 → 0.0.1748917891-gc53039

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 (44) hide show
  1. package/dist/amp.js +3 -3
  2. package/dist/{client-BdpLPYaH.js → client-CJDF5IOf.js} +2 -2
  3. package/dist/{client-BdpLPYaH.js.map → client-CJDF5IOf.js.map} +1 -1
  4. package/dist/{console-CqG_XvSY.js → console-EFuuJ6Do.js} +80 -79
  5. package/dist/{console-CqG_XvSY.js.map → console-EFuuJ6Do.js.map} +1 -1
  6. package/dist/{create_file.node-ADITw5B2.js → create_file.node-znCV9y1u.js} +2 -2
  7. package/dist/{create_file.node-ADITw5B2.js.map → create_file.node-znCV9y1u.js.map} +1 -1
  8. package/dist/{edit_file.node-DXreHiOg.js → edit_file.node-Ox45wer9.js} +5 -5
  9. package/dist/{edit_file.node-DXreHiOg.js.map → edit_file.node-Ox45wer9.js.map} +1 -1
  10. package/dist/{executable-CNRwugd8.js → executable-Dny7Sqei.js} +2 -2
  11. package/dist/{executable-CNRwugd8.js.map → executable-Dny7Sqei.js.map} +1 -1
  12. package/dist/{files-BmtGFG0Q.js → files-XMouM7Xy.js} +2 -2
  13. package/dist/{files-BmtGFG0Q.js.map → files-XMouM7Xy.js.map} +1 -1
  14. package/dist/{glob.node-CVEV9zgB.js → glob.node-CQYWJD-w.js} +6 -6
  15. package/dist/{glob.node-CVEV9zgB.js.map → glob.node-CQYWJD-w.js.map} +1 -1
  16. package/dist/{index-BqIcA2B7.js → index-tUVCK-3e.js} +2 -2
  17. package/dist/{index-BqIcA2B7.js.map → index-tUVCK-3e.js.map} +1 -1
  18. package/dist/{list_directory.node-BemKxEzJ.js → list_directory.node-CBATT0WM.js} +2 -2
  19. package/dist/{list_directory.node-BemKxEzJ.js.map → list_directory.node-CBATT0WM.js.map} +1 -1
  20. package/dist/{load-profile-DrobQ5m2.js → load-profile-C07m9AR8.js} +2 -2
  21. package/dist/{load-profile-DrobQ5m2.js.map → load-profile-C07m9AR8.js.map} +1 -1
  22. package/dist/{main-CG54iRKx.js → main-BqEui1IZ.js} +7875 -7094
  23. package/dist/main-BqEui1IZ.js.map +1 -0
  24. package/dist/{node-CY_sNxT5.js → node-B514W51x.js} +7 -7
  25. package/dist/{node-CY_sNxT5.js.map → node-B514W51x.js.map} +1 -1
  26. package/dist/{node-D3-y_ogB.js → node-BTp0pR0E.js} +2 -2
  27. package/dist/{node-D3-y_ogB.js.map → node-BTp0pR0E.js.map} +1 -1
  28. package/dist/{node-CWIBdJry.js → node-CC00cSMA.js} +3 -3
  29. package/dist/{node-CWIBdJry.js.map → node-CC00cSMA.js.map} +1 -1
  30. package/dist/{node-BySrtniU.js → node-DBTLyS3b.js} +14 -14
  31. package/dist/{node-BySrtniU.js.map → node-DBTLyS3b.js.map} +1 -1
  32. package/dist/{node-CIdEg4qU.js → node-DXJQ7rm8.js} +3 -3
  33. package/dist/{node-CIdEg4qU.js.map → node-DXJQ7rm8.js.map} +1 -1
  34. package/dist/{node-oyrvsiXU.js → node-O3hoyYss.js} +2 -2
  35. package/dist/{node-oyrvsiXU.js.map → node-O3hoyYss.js.map} +1 -1
  36. package/dist/{read_file.node-6hnIOwx2.js → read_file.node-Cr1TQq-u.js} +2 -2
  37. package/dist/{read_file.node-6hnIOwx2.js.map → read_file.node-Cr1TQq-u.js.map} +1 -1
  38. package/dist/{stdio-CrHlir-C.js → stdio-Ba8PP3i9.js} +3 -3
  39. package/dist/{stdio-CrHlir-C.js.map → stdio-Ba8PP3i9.js.map} +1 -1
  40. package/dist/storybook.js +1 -1
  41. package/dist/{undo_edit.node-PvuGXz4H.js → undo_edit.node-BOccAnc1.js} +6 -6
  42. package/dist/{undo_edit.node-PvuGXz4H.js.map → undo_edit.node-BOccAnc1.js.map} +1 -1
  43. package/package.json +1 -1
  44. package/dist/main-CG54iRKx.js.map +0 -1
package/dist/storybook.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { at as r, ay as a, al as c, az as d, ar as f, as as x, ah as b, aq as I } from "./console-CqG_XvSY.js";
2
+ import { au as r, az as a, am as c, aA as d, as as f, at as x, ai as b, ar as I } from "./console-EFuuJ6Do.js";
3
3
  import { stdout as s } from "node:process";
4
4
  import { parseArgs as w } from "node:util";
5
5
  function D() {
@@ -3,9 +3,9 @@ import F from "node:crypto";
3
3
  import s, { writeFile as D } from "node:fs/promises";
4
4
  import g from "node:os";
5
5
  import c from "node:path";
6
- import { p as b, aA as C, aJ as E, aK as v, C as m } from "./console-CqG_XvSY.js";
6
+ import { p as b, aB as C, aK as E, aL as v, C as m } from "./console-EFuuJ6Do.js";
7
7
  const x = 50, o = [];
8
- async function N(t, i, d) {
8
+ async function J(t, i, d) {
9
9
  try {
10
10
  const e = y(t), r = await w(), a = c.join(r, e), n = { filePath: t, oldContent: i, newContent: d };
11
11
  await s.writeFile(a, JSON.stringify(n), "utf-8");
@@ -38,7 +38,7 @@ async function O(t) {
38
38
  return;
39
39
  }
40
40
  }
41
- const A = ({ args: t }, { dir: i, threadID: d, trackFileChange: e }) => b(async (r) => {
41
+ const U = ({ args: t }, { dir: i, threadID: d, trackFileChange: e }) => b(async (r) => {
42
42
  C(i), _(t);
43
43
  const a = c.resolve(i.fsPath, t.path), n = await O(t.path);
44
44
  if (!n)
@@ -76,7 +76,7 @@ function y(t) {
76
76
  }
77
77
  export {
78
78
  O as getLastEdit,
79
- A as nodeUndoEditTool,
80
- N as recordEdit
79
+ U as nodeUndoEditTool,
80
+ J as recordEdit
81
81
  };
82
- //# sourceMappingURL=undo_edit.node-PvuGXz4H.js.map
82
+ //# sourceMappingURL=undo_edit.node-BOccAnc1.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"undo_edit.node-PvuGXz4H.js","sources":["../../core/src/tools/builtin/filesystem/undo_edit.node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport crypto from 'node:crypto'\nimport fs, { writeFile } from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'path'\nimport logger from '../../../common/logger'\nimport { checkDirURIIsFile } from '../node-helpers'\nimport { createUnifiedDiff, formatDiffAsMarkdown } from './edit_file.common'\nimport type { UndoEditToolDef, undoEditToolReg } from './undo_edit.common'\n\nconst MAX_FILES = 50\nconst editQueue: string[] = []\n\nexport async function recordEdit(\n\tfilePath: string,\n\toldContent: string,\n\tnewContent: string,\n): Promise<void> {\n\ttry {\n\t\tconst hashedFilename = getHashedFilename(filePath)\n\t\tconst tempDir = await getTempDir()\n\t\tconst editFile = path.join(tempDir, hashedFilename)\n\n\t\tconst editData = { filePath, oldContent, newContent }\n\t\tawait fs.writeFile(editFile, JSON.stringify(editData), 'utf-8')\n\n\t\t// Update the FIFO queue\n\t\t// Remove if already in queue (to add it to the end)\n\t\tconst existingIndex = editQueue.indexOf(hashedFilename)\n\t\tif (existingIndex >= 0) {\n\t\t\teditQueue.splice(existingIndex, 1)\n\t\t}\n\n\t\t// Add to end of queue (most recent)\n\t\teditQueue.push(hashedFilename)\n\n\t\t// If we exceed the limit, remove the oldest edit\n\t\tif (editQueue.length > MAX_FILES) {\n\t\t\tconst oldestFile = editQueue.shift()\n\t\t\tif (oldestFile) {\n\t\t\t\tconst oldestPath = path.join(tempDir, oldestFile)\n\t\t\t\tawait fs.unlink(oldestPath).catch(() => {})\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlogger.error('Failed to record edit:', error)\n\t}\n}\n\n// Function to get and remove the most recent edit for a file\nexport async function getLastEdit(\n\tfilePath: string,\n): Promise<{ oldContent: string; newContent: string } | undefined> {\n\ttry {\n\t\tconst hashedFilename = getHashedFilename(filePath)\n\t\tconst tempDir = await getTempDir()\n\t\tconst editFile = path.join(tempDir, hashedFilename)\n\n\t\ttry {\n\t\t\tawait fs.access(editFile)\n\t\t} catch {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst editDataStr = await fs.readFile(editFile, 'utf-8')\n\t\tconst editData = JSON.parse(editDataStr) as {\n\t\t\tfilePath: string\n\t\t\toldContent: string\n\t\t\tnewContent: string\n\t\t}\n\n\t\t// Remove from queue and delete file\n\t\tconst queueIndex = editQueue.indexOf(hashedFilename)\n\t\tif (queueIndex >= 0) {\n\t\t\teditQueue.splice(queueIndex, 1)\n\t\t}\n\t\tawait fs.unlink(editFile).catch(() => {})\n\n\t\treturn { oldContent: editData.oldContent, newContent: editData.newContent }\n\t} catch (error) {\n\t\tlogger.error('Failed to get last edit:', error)\n\t\treturn undefined\n\t}\n}\n\nexport const nodeUndoEditTool: NonNullable<(typeof undoEditToolReg)['fn']> = (\n\t{ args },\n\t{ dir, threadID, trackFileChange },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\tcheckDirURIIsFile(dir)\n\t\tcheckUndoEditArgs(args)\n\n\t\tconst filePath = path.resolve(dir.fsPath, args.path)\n\n\t\t// Get the last edit from history (now async)\n\t\tconst lastEdit = await getLastEdit(args.path)\n\t\tif (!lastEdit) {\n\t\t\treturn {\n\t\t\t\tstatus: 'error' as const,\n\t\t\t\tprogress: {},\n\t\t\t\terror: {\n\t\t\t\t\tmessage: `No edit history found for file '${args.path}'.`,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tconst diff = createUnifiedDiff(lastEdit.newContent, lastEdit.oldContent, args.path)\n\t\tconst formattedDiff = formatDiffAsMarkdown(diff)\n\n\t\tawait trackFileChange(filePath, async (path) => {\n\t\t\tawait writeFile(path, lastEdit.oldContent, {\n\t\t\t\tencoding: 'utf-8',\n\t\t\t\tsignal,\n\t\t\t})\n\t\t})\n\n\t\treturn { status: 'done', progress: {}, result: formattedDiff }\n\t})\n}\n\nfunction checkUndoEditArgs(args: UndoEditToolDef['args']): asserts args is UndoEditToolDef['args'] {\n\tif (typeof args !== 'object' || args === null) {\n\t\tthrow new Error('args must be an object. received instead: `' + JSON.stringify(args) + '`')\n\t}\n\tif (typeof args.path !== 'string') {\n\t\tthrow new Error(\n\t\t\t'path must be a string. received instead: `' + JSON.stringify(args.path) + '`',\n\t\t)\n\t}\n}\n\nlet tempDir = ''\nlet tempDirPromise: Promise<string> | null = null\n\nasync function getTempDir(): Promise<string> {\n\tif (tempDir) return tempDir\n\tif (!tempDirPromise) {\n\t\ttempDirPromise = fs\n\t\t\t.mkdtemp(path.join(os.tmpdir(), 'amp-edits-'))\n\t\t\t.then((dir) => {\n\t\t\t\ttempDir = dir\n\t\t\t\treturn dir\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tlogger.error('Failed to create edit history directory:', error)\n\t\t\t\tthrow error\n\t\t\t})\n\t}\n\treturn tempDirPromise\n}\n\nfunction getHashedFilename(filePath: string): string {\n\tconst hash = crypto.createHash('sha256').update(filePath).digest('hex').slice(0, 16)\n\treturn `${hash}-${path.basename(filePath)}`\n}\n"],"names":["MAX_FILES","editQueue","recordEdit","filePath","oldContent","newContent","hashedFilename","getHashedFilename","tempDir","getTempDir","editFile","path","editData","fs","existingIndex","oldestFile","oldestPath","error","logger","getLastEdit","editDataStr","queueIndex","nodeUndoEditTool","args","dir","threadID","trackFileChange","promiseFactoryToObservable","signal","checkDirURIIsFile","checkUndoEditArgs","lastEdit","diff","createUnifiedDiff","formattedDiff","formatDiffAsMarkdown","writeFile","tempDirPromise","os","crypto"],"mappings":";;;;;;AAUA,MAAMA,IAAY,IACZC,IAAsB,CAAC;AAEP,eAAAC,EACrBC,GACAC,GACAC,GACgB;AACZ,MAAA;AACG,UAAAC,IAAiBC,EAAkBJ,CAAQ,GAC3CK,IAAU,MAAMC,EAAW,GAC3BC,IAAWC,EAAK,KAAKH,GAASF,CAAc,GAE5CM,IAAW,EAAE,UAAAT,GAAU,YAAAC,GAAY,YAAAC,EAAW;AACpD,UAAMQ,EAAG,UAAUH,GAAU,KAAK,UAAUE,CAAQ,GAAG,OAAO;AAIxD,UAAAE,IAAgBb,EAAU,QAAQK,CAAc;AASlD,QARAQ,KAAiB,KACVb,EAAA,OAAOa,GAAe,CAAC,GAIl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filesystem/undo_edit.node.ts"],"sourcesContent":["import { promiseFactoryToObservable } from '@sourcegraph/observable'\nimport crypto from 'node:crypto'\nimport fs, { writeFile } from 'node:fs/promises'\nimport os from 'node:os'\nimport path from 'path'\nimport logger from '../../../common/logger'\nimport { checkDirURIIsFile } from '../node-helpers'\nimport { createUnifiedDiff, formatDiffAsMarkdown } from './edit_file.common'\nimport type { UndoEditToolDef, undoEditToolReg } from './undo_edit.common'\n\nconst MAX_FILES = 50\nconst editQueue: string[] = []\n\nexport async function recordEdit(\n\tfilePath: string,\n\toldContent: string,\n\tnewContent: string,\n): Promise<void> {\n\ttry {\n\t\tconst hashedFilename = getHashedFilename(filePath)\n\t\tconst tempDir = await getTempDir()\n\t\tconst editFile = path.join(tempDir, hashedFilename)\n\n\t\tconst editData = { filePath, oldContent, newContent }\n\t\tawait fs.writeFile(editFile, JSON.stringify(editData), 'utf-8')\n\n\t\t// Update the FIFO queue\n\t\t// Remove if already in queue (to add it to the end)\n\t\tconst existingIndex = editQueue.indexOf(hashedFilename)\n\t\tif (existingIndex >= 0) {\n\t\t\teditQueue.splice(existingIndex, 1)\n\t\t}\n\n\t\t// Add to end of queue (most recent)\n\t\teditQueue.push(hashedFilename)\n\n\t\t// If we exceed the limit, remove the oldest edit\n\t\tif (editQueue.length > MAX_FILES) {\n\t\t\tconst oldestFile = editQueue.shift()\n\t\t\tif (oldestFile) {\n\t\t\t\tconst oldestPath = path.join(tempDir, oldestFile)\n\t\t\t\tawait fs.unlink(oldestPath).catch(() => {})\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tlogger.error('Failed to record edit:', error)\n\t}\n}\n\n// Function to get and remove the most recent edit for a file\nexport async function getLastEdit(\n\tfilePath: string,\n): Promise<{ oldContent: string; newContent: string } | undefined> {\n\ttry {\n\t\tconst hashedFilename = getHashedFilename(filePath)\n\t\tconst tempDir = await getTempDir()\n\t\tconst editFile = path.join(tempDir, hashedFilename)\n\n\t\ttry {\n\t\t\tawait fs.access(editFile)\n\t\t} catch {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst editDataStr = await fs.readFile(editFile, 'utf-8')\n\t\tconst editData = JSON.parse(editDataStr) as {\n\t\t\tfilePath: string\n\t\t\toldContent: string\n\t\t\tnewContent: string\n\t\t}\n\n\t\t// Remove from queue and delete file\n\t\tconst queueIndex = editQueue.indexOf(hashedFilename)\n\t\tif (queueIndex >= 0) {\n\t\t\teditQueue.splice(queueIndex, 1)\n\t\t}\n\t\tawait fs.unlink(editFile).catch(() => {})\n\n\t\treturn { oldContent: editData.oldContent, newContent: editData.newContent }\n\t} catch (error) {\n\t\tlogger.error('Failed to get last edit:', error)\n\t\treturn undefined\n\t}\n}\n\nexport const nodeUndoEditTool: NonNullable<(typeof undoEditToolReg)['fn']> = (\n\t{ args },\n\t{ dir, threadID, trackFileChange },\n) => {\n\treturn promiseFactoryToObservable(async (signal) => {\n\t\tcheckDirURIIsFile(dir)\n\t\tcheckUndoEditArgs(args)\n\n\t\tconst filePath = path.resolve(dir.fsPath, args.path)\n\n\t\t// Get the last edit from history (now async)\n\t\tconst lastEdit = await getLastEdit(args.path)\n\t\tif (!lastEdit) {\n\t\t\treturn {\n\t\t\t\tstatus: 'error' as const,\n\t\t\t\tprogress: {},\n\t\t\t\terror: {\n\t\t\t\t\tmessage: `No edit history found for file '${args.path}'.`,\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tconst diff = createUnifiedDiff(lastEdit.newContent, lastEdit.oldContent, args.path)\n\t\tconst formattedDiff = formatDiffAsMarkdown(diff)\n\n\t\tawait trackFileChange(filePath, async (path) => {\n\t\t\tawait writeFile(path, lastEdit.oldContent, {\n\t\t\t\tencoding: 'utf-8',\n\t\t\t\tsignal,\n\t\t\t})\n\t\t})\n\n\t\treturn { status: 'done', progress: {}, result: formattedDiff }\n\t})\n}\n\nfunction checkUndoEditArgs(args: UndoEditToolDef['args']): asserts args is UndoEditToolDef['args'] {\n\tif (typeof args !== 'object' || args === null) {\n\t\tthrow new Error('args must be an object. received instead: `' + JSON.stringify(args) + '`')\n\t}\n\tif (typeof args.path !== 'string') {\n\t\tthrow new Error(\n\t\t\t'path must be a string. received instead: `' + JSON.stringify(args.path) + '`',\n\t\t)\n\t}\n}\n\nlet tempDir = ''\nlet tempDirPromise: Promise<string> | null = null\n\nasync function getTempDir(): Promise<string> {\n\tif (tempDir) return tempDir\n\tif (!tempDirPromise) {\n\t\ttempDirPromise = fs\n\t\t\t.mkdtemp(path.join(os.tmpdir(), 'amp-edits-'))\n\t\t\t.then((dir) => {\n\t\t\t\ttempDir = dir\n\t\t\t\treturn dir\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tlogger.error('Failed to create edit history directory:', error)\n\t\t\t\tthrow error\n\t\t\t})\n\t}\n\treturn tempDirPromise\n}\n\nfunction getHashedFilename(filePath: string): string {\n\tconst hash = crypto.createHash('sha256').update(filePath).digest('hex').slice(0, 16)\n\treturn `${hash}-${path.basename(filePath)}`\n}\n"],"names":["MAX_FILES","editQueue","recordEdit","filePath","oldContent","newContent","hashedFilename","getHashedFilename","tempDir","getTempDir","editFile","path","editData","fs","existingIndex","oldestFile","oldestPath","error","logger","getLastEdit","editDataStr","queueIndex","nodeUndoEditTool","args","dir","threadID","trackFileChange","promiseFactoryToObservable","signal","checkDirURIIsFile","checkUndoEditArgs","lastEdit","diff","createUnifiedDiff","formattedDiff","formatDiffAsMarkdown","writeFile","tempDirPromise","os","crypto"],"mappings":";;;;;;AAUA,MAAMA,IAAY,IACZC,IAAsB,CAAC;AAEP,eAAAC,EACrBC,GACAC,GACAC,GACgB;AACZ,MAAA;AACG,UAAAC,IAAiBC,EAAkBJ,CAAQ,GAC3CK,IAAU,MAAMC,EAAW,GAC3BC,IAAWC,EAAK,KAAKH,GAASF,CAAc,GAE5CM,IAAW,EAAE,UAAAT,GAAU,YAAAC,GAAY,YAAAC,EAAW;AACpD,UAAMQ,EAAG,UAAUH,GAAU,KAAK,UAAUE,CAAQ,GAAG,OAAO;AA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,EAAK,SAASR,CAAQ,CAAC;AAC1C;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1748894490-ge9fff4",
3
+ "version": "0.0.1748917891-gc53039",
4
4
  "description": "CLI for Amp, an agentic coding tool in research preview from Sourcegraph.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {