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

Path Display Utility

A utility for displaying file paths in a user-friendly format in terminal applications.

Capabilities

Convert absolute paths to user-friendly format

  • Converts absolute paths within the user's home directory to use tilde notation @test
  • Returns the home directory itself as a tilde when given the exact home directory path @test
  • Preserves paths outside the user's home directory unchanged @test

Implementation

@generates

API

/**
 * Converts an absolute file path to a user-friendly display format.
 * Paths within the user's home directory are converted to tilde notation.
 *
 * @param {string} absolutePath - An absolute file system path
 * @returns {string} The formatted path suitable for display
 */
function formatPathForDisplay(absolutePath) {
  // IMPLEMENTATION HERE
}

module.exports = { formatPathForDisplay };

Dependencies { .dependencies }

tildify { .dependency }

Provides path formatting support.

Test Cases

The following test cases should be implemented in test/path-display.test.js:

Test 1: Convert home subdirectory path

  • Given an absolute path within the user's home directory (e.g., /Users/username/documents/project)
  • When formatPathForDisplay is called with this path
  • Then it should return the path with tilde notation (e.g., ~/documents/project)

Test 2: Convert exact home directory

  • Given an absolute path that is exactly the user's home directory (e.g., /Users/username)
  • When formatPathForDisplay is called with this path
  • Then it should return just the tilde: ~

Test 3: Preserve non-home paths

  • Given an absolute path outside the user's home directory (e.g., /var/log/system.log)
  • When formatPathForDisplay is called with this path
  • Then it should return the path unchanged: /var/log/system.log

Install with Tessl CLI

npx tessl i tessl/npm-tildify

tile.json