or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-8/

Commit Message Cache System

Build a simple commit message caching system that stores commit messages per repository and allows retrieval of the last cached message.

Requirements

Implement a caching system with repository-specific storage:

  1. Write to cache: Store a commit message and options for a given repository path
  2. Read from cache: Retrieve the cached message and options for a repository path
  3. Handle missing cache: Throw an error when attempting to read a cache entry that doesn't exist

Cache File Format

Store data in a JSON file where each repository path is a key:

{
  "/home/user/project1": {
    "message": "feat: add new feature",
    "options": { "amend": false }
  },
  "/home/user/project2": {
    "message": "fix: resolve bug",
    "options": {}
  }
}

Test Cases

  • Writing a message to cache creates a valid JSON file with the correct structure @test
  • Reading a cached message returns the stored message and options @test
  • Reading from cache when no entry exists throws an error @test
  • Multiple repositories can store separate cached messages @test

Implementation

@generates

API

/**
 * Writes commit data to the cache file for a specific repository.
 * Creates or updates the cache entry for the repository.
 *
 * @param {string} cachePath - Path to the cache JSON file
 * @param {string} repoPath - Repository path (used as cache key)
 * @param {object} data - Data to cache
 * @param {string} data.message - The commit message
 * @param {object} data.options - Commit options
 */
function writeCache(cachePath, repoPath, data) {
  // Implementation
}

/**
 * Reads cached commit data for a specific repository.
 *
 * @param {string} cachePath - Path to the cache JSON file
 * @param {string} repoPath - Repository path (used as cache key)
 * @returns {object} Cached data with message and options properties
 * @throws {Error} When cache file doesn't exist or repository entry not found
 */
function readCache(cachePath, repoPath) {
  // Implementation
}

module.exports = { writeCache, readCache };

Dependencies { .dependencies }

czg { .dependency }

A CLI tool for generating standardized commit messages with built-in caching and retry capabilities.

@satisfied-by