src — tracks

Module: src-tracks Cohesion: 0.80 Members: 0

src — tracks

The src/tracks module implements a Track System designed to facilitate context-driven development. Inspired by the "spec → plan → implement" workflow, it provides a structured way to manage development tasks, features, and bug fixes as discrete "tracks." This system aims to ensure that work is well-defined, planned, and executed in alignment with project context and guidelines.

1. Core Concepts

The Track System revolves around a few central concepts:

All track data and project context are persisted as Markdown and JSON files within a .codebuddy/ directory in the project's root.

2. Architecture Overview

The src/tracks module is composed of two main classes: TrackManager and TrackCommands, along with a types.ts file defining the data structures.

The interaction flow is generally:

graph TD
    A[User Command <br> (e.g., /track new)] --> B{TrackCommands.execute}
    B -- Calls --> C[TrackManager]
    C -- Reads/Writes --> D[File System <br> (.codebuddy/)]
    B -- Generates <br> AI Prompts --> E[AI Agent]
    E -- (AI Agent acts based on prompt) --> A

3. Key Components

3.1. src/tracks/track-manager.ts - The Persistence & Logic Layer

The TrackManager class is responsible for the underlying data management and file system interactions for tracks and project context.

Key Responsibilities:

File Structure Managed by TrackManager:

.codebuddy/
├── context/
│   ├── product.md
│   ├── tech-stack.md
│   ├── guidelines.md
│   └── workflow.md
├── tracks.md             <-- Index of all tracks
└── tracks/
    ├── <track_id_1>/
    │   ├── metadata.json
    │   ├── spec.md
    │   └── plan.md
    └── <track_id_2>/
        ├── metadata.json
        ├── spec.md
        └── plan.md

3.2. src/tracks/track-commands.ts - The Command Interface

The TrackCommands class provides a command-line interface (CLI) for interacting with the Track System. It parses user commands (e.g., /track new) and delegates the actual work to the TrackManager. A key feature is its ability to generate specific prompts for an AI agent, guiding it through the various stages of track development.

Key Responsibilities:

3.3. src/tracks/types.ts - Data Models

This file defines all the TypeScript interfaces and type aliases used across the Track System, ensuring strong typing and clarity for track metadata, specification, plan, tasks, and project context.

4. Development Workflow

The Track System supports a structured development workflow, often guided by an AI agent:

  1. Setup: A developer (or AI) runs /track setup. TrackManager.initialize() creates the .codebuddy/ directory and default context files. TrackCommands then prompts the AI to customize these context files (product.md, tech-stack.md, guidelines.md, workflow.md).
  2. New Track: A developer (or AI) initiates a new track with /track new .

  1. Implementation: When ready to work, a developer (or AI) runs /track implement.

  1. Completion: Once all tasks in a track are complete, TrackCommands provides a getTrackCompletePrompt to the AI, guiding it through final review, documentation updates, and marking the track as completed using /track complete .

5. Data Persistence

All track and context data is stored directly on the file system, making it transparent, version-controllable (e.g., with Git), and easily editable by humans or tools.

6. Integration Points

The src/tracks module integrates with the rest of the codebase primarily through:

7. Contributing to the Module

When contributing to the src/tracks module, consider the following: