CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tildify

Convert an absolute path to a tilde path by replacing the user's home directory with ~

93

1.09x

Evaluation93%

1.09x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-6/

Path Display Filter

A CLI tool needs to display file system paths in a user-friendly way by converting paths that start with the user's home directory to tilde notation, but it must leave all other paths unchanged regardless of whether they contain the home directory string elsewhere.

Capabilities

Prefix-based path shortening

  • Given an absolute path that starts with the user's home directory (e.g., /Users/john/documents/file.txt), returns the path with the home directory replaced by ~ (e.g., ~/documents/file.txt) @test
  • Given a path that equals the user's home directory exactly, returns ~ @test

Non-prefix path preservation

  • Given a path where the home directory path appears in a non-prefix position (e.g., /var/backup/Users/john/archive), returns the path unchanged @test

External path handling

  • Given a system path outside the home directory (e.g., /usr/local/bin), returns the path unchanged @test

Implementation

@generates

API

/**
 * Transforms a file system path by replacing the home directory prefix with tilde notation.
 * Paths where the home directory does not appear at the start are returned unchanged.
 *
 * @param {string} absolutePath - The absolute file system path to transform
 * @returns {string} The transformed path with tilde notation or the original path
 */
function filterPath(absolutePath) {
  // Implementation here
}

module.exports = { filterPath };

Dependencies { .dependencies }

tildify { .dependency }

Provides path transformation from absolute paths to tilde notation.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tildify

tile.json