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

Function modifyWithEditor

packages/core/src/tools/modifiable-tool.ts:141–171  ·  view source on GitHub ↗
(
  originalParams: ToolParams,
  modifyContext: ModifyContext<ToolParams>,
  editorType: EditorType,
  _abortSignal: AbortSignal,
  onEditorClose: () => void,
)

Source from the content-addressed store, hash-verified

139 * and returns the updated tool parameters and the diff after the user has modified the proposed content.
140 */
141export async function modifyWithEditor<ToolParams>(
142 originalParams: ToolParams,
143 modifyContext: ModifyContext<ToolParams>,
144 editorType: EditorType,
145 _abortSignal: AbortSignal,
146 onEditorClose: () => void,
147): Promise<ModifyResult<ToolParams>> {
148 const currentContent = await modifyContext.getCurrentContent(originalParams);
149 const proposedContent =
150 await modifyContext.getProposedContent(originalParams);
151
152 const { oldPath, newPath } = createTempFilesForModify(
153 currentContent,
154 proposedContent,
155 modifyContext.getFilePath(originalParams),
156 );
157
158 try {
159 await openDiff(oldPath, newPath, editorType, onEditorClose);
160 const result = getUpdatedParams(
161 oldPath,
162 newPath,
163 originalParams,
164 modifyContext,
165 );
166
167 return result;
168 } finally {
169 deleteTempFiles(oldPath, newPath);
170 }
171}

Callers 1

Calls 4

createTempFilesForModifyFunction · 0.85
openDiffFunction · 0.85
getUpdatedParamsFunction · 0.85
deleteTempFilesFunction · 0.85

Tested by

no test coverage detected