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-8/

Editor Lifecycle Manager

Provide a thin wrapper around a system text editor so callers can run synchronous or asynchronous editing sessions, read the edited content, observe the editor's exit status, and clean up the temporary file explicitly when needed.

Capabilities

Synchronous session with status

  • Launches the editor synchronously, returns the edited text plus the editor's exit status, and ensures the temporary file is removed after reading. @test

Callback-based asynchronous session

  • Launches the editor asynchronously, delivers either an error or the edited text and exit status through the provided callback, and cleans up the temporary file after the callback resolves. @test

Manual cleanup hook

  • Exposes a cleanup operation that callers can trigger without running the editor (for example after cancelling) and surfaces a failure if the temporary file cannot be removed. @test

Custom temporary file options

  • Accepts temporary file options (prefix, postfix, template, dir, mode) that are applied when creating the editable file for both sync and async launches. @test

Implementation

@generates

API

export interface TempFileOptions {
  prefix?: string;
  postfix?: string;
  template?: string;
  dir?: string;
  mode?: number;
}

export interface SessionResult {
  content: string;
  exitStatus: number;
  path: string;
}

export class EditorLifecycle {
  constructor(initialText?: string, fileOptions?: TempFileOptions);

  /**
   * Launch the editor synchronously and return edited content with exit status.
   */
  launchSync(): SessionResult;

  /**
   * Launch the editor asynchronously and invoke the callback with content and exit status.
   */
  launchAsync(callback: (err: Error | null, result?: SessionResult) => void): void;

  /**
   * Remove the temporary file even if no launch occurred.
   */
  discard(): void;
}

Dependencies { .dependencies }

external-editor { .dependency }

Uses an external editor library to manage launching, reading, exit status reporting, and cleanup for the temporary file.

@satisfied-by

Version

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