Adding Tracks Support
How to implement Agent Tracks support in your AI client.
Overview
Adding tracks support to your client involves three phases:
- Discovery: Load track metadata at startup
- Activation: Load full instructions when relevant
- Execution: Follow instructions and optionally run scripts
Phase 1: Discovery
At startup, scan for TRACK.md files in:
.haijun/tracks/in the project root- User-level tracks directory (~/.config/haijun/tracks/)
- Any directories configured by the user
Parse only the YAML frontmatter to extract name and description. Store these in memory for quick lookup.
Phase 2: Activation
When a user sends a message, compare the task against available track descriptions. Use semantic similarity or keyword matching to determine relevance. When a track matches:
- Read the full
TRACK.mdcontent - Add it to the agent's context
- Optionally load referenced files
Phase 3: Execution
Follow the instructions in the track. If the track references scripts:
- Resolve the script path relative to the track directory
- Check that the script is executable
- Execute with appropriate sandboxing
- Capture and return output
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
tracks.enabled | boolean | true | Enable/disable tracks support |
tracks.paths | array | [".haijun/tracks"] | Directories to scan for tracks |
tracks.maxActive | number | 5 | Maximum tracks to activate per task |
tracks.allowScripts | boolean | true | Allow executing bundled scripts |
Agent