MCPcopy Create free account
hub / github.com/anus-dev/ANUS / createTempFilesForModify

Function createTempFilesForModify

packages/core/src/tools/modifiable-tool.ts:53–81  ·  view source on GitHub ↗
(
  currentContent: string,
  proposedContent: string,
  file_path: string,
)

Source from the content-addressed store, hash-verified

51}
52
53function createTempFilesForModify(
54 currentContent: string,
55 proposedContent: string,
56 file_path: string,
57): { oldPath: string; newPath: string } {
58 const tempDir = os.tmpdir();
59 const diffDir = path.join(tempDir, 'anus-cli-tool-modify-diffs');
60
61 if (!fs.existsSync(diffDir)) {
62 fs.mkdirSync(diffDir, { recursive: true });
63 }
64
65 const ext = path.extname(file_path);
66 const fileName = path.basename(file_path, ext);
67 const timestamp = Date.now();
68 const tempOldPath = path.join(
69 diffDir,
70 `anus-cli-modify-${fileName}-old-${timestamp}${ext}`,
71 );
72 const tempNewPath = path.join(
73 diffDir,
74 `anus-cli-modify-${fileName}-new-${timestamp}${ext}`,
75 );
76
77 fs.writeFileSync(tempOldPath, currentContent, 'utf8');
78 fs.writeFileSync(tempNewPath, proposedContent, 'utf8');
79
80 return { oldPath: tempOldPath, newPath: tempNewPath };
81}
82
83function getUpdatedParams<ToolParams>(
84 tmpOldPath: string,

Callers 1

modifyWithEditorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected