CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-external-editor

tessl install tessl/npm-external-editor@3.1.0

Edit 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%

task.mdevals/scenario-9/

Scripted Editor Command

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.

Capabilities

Scripted transformation

  • Given 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

Exit status capture

  • With a command { 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. @test

Argument passthrough

  • Given initialText 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

Implementation

@generates

API

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>;

Dependencies { .dependencies }

external-editor { .dependency }

Used to create a temporary file, launch the chosen editor command, and read back the edited contents.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/external-editor@3.1.x
tile.json