tessl install tessl/npm-external-editor@3.1.0Edit a string with the users preferred text editor using $VISUAL or $ENVIRONMENT
Agent Success
Agent success rate when using this tile
79%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.05x
Baseline
Agent success rate without this tile
75%
A module that edits text by running a temporary file through a caller-specified editor command, returning the edited contents and the command's exit status.
initialText of "draft" and a command { bin: "node", args: ["-e", "const fs=require('fs'); const p=process.argv[2]; const s=fs.readFileSync(p,'utf8'); fs.writeFileSync(p, s.toUpperCase());"] }, the function resolves with text equal to "DRAFT" and exitCode equal to 0. @test{ bin: "node", args: ["-e", "const fs=require('fs'); const p=process.argv[2]; fs.writeFileSync(p, 'kept'); process.exit(13);"] }, the function resolves with text equal to "kept" and exitCode equal to 13. @testinitialText of "seed" and a command { bin: "bash", args: ["-c", "echo added >> \"$1\"", "--"] }, the function passes the temporary file path as the final argument so the script can write to it, resulting in text that ends with a newline followed by "added" and commandUsed whose last element is that temp file path. @test@generates
export interface ScriptedEditorOptions {
initialText?: string;
command: { bin: string; args: string[] };
}
export interface ScriptedEditorResult {
text: string;
exitCode: number;
commandUsed: string[];
}
/**
* Writes the initial text to a temporary file, runs the provided command against that file, and returns the edited contents plus the exit status.
*/
export function runScriptedEdit(options: ScriptedEditorOptions): Promise<ScriptedEditorResult>;Used to create a temporary file, launch the chosen editor command, and read back the edited contents.
@satisfied-by