How trailhq/trail-code works
Trail-code is a local coding-agent context product: it builds a code-and-call graph, retrieves relevant files and impact context, and carries team and personal learnings between sessions. The principal workflow runs from repository initialization through graph construction and agent integration to retrieval and saved learnings. It also supports learning checks, branch-overlap warnings, onboarding from prior sessions and reviews, graph visualization, and optional team/cloud features. Sampled source and README evidence support the main links; unsampled subsystems are represented only where documented capabilities justify them.
Main entry points: cli.ts CLI and init · ask.ts Context retrieval · engine.ts Context engine · notes.ts Learning notes
Components 20
Code map
- Context engine
src/engine.ts - Symbol extraction
src/graph/extract.ts - Graph build
src/graph/build.ts - Context build
src/context/build.ts - Local graph
src/graph/write.ts - Context retrieval
src/ask/ask.ts
Learnings
- Learning notes
src/notes/notes.ts - Learning checks
src/check/local-check.ts - Cold-start learning
src/notes/cold-start.ts - PR review learning
src/notes/pr-reviews.ts
Agent access
- CLI and init
src/cli.ts - Agent hooks
src/claude/hooks.ts - Host setup
src/hosts/init.ts - MCP tools
src/mcp/server.ts
Team features
- Team sync
src/cloud/workspace-sync.ts - Review service
src/app/server.ts
Inspection and upkeep
- Change impact
src/blast/blast.ts - Graph visualization
src/viz/assemble.ts - Usage telemetry
src/telemetry/track.ts
Other components
- Developer or agent
Connections 23
- Developer or agent → CLI and init: initializes repository
README.md - CLI and init → Context engine: starts build
- Context engine → Context build: builds context
src/engine.ts - Context engine → Graph build: builds graph
src/engine.ts - Graph build → Symbol extraction: extracts symbols
- Context build → Local graph: writes nodes
src/context/build.ts - Context engine → Context retrieval: answers queries
src/engine.ts - Context retrieval → Local graph: reads graph
src/ask/ask.ts - CLI and init → Host setup: wires agents
README.md - Host setup → Agent hooks: configures hooks
- Agent hooks → Context retrieval: provides context
README.md - Developer or agent → MCP tools: requests agent tools
- MCP tools → Context retrieval: exposes graph tools
- Developer or agent → Learning notes: saves discoveries
README.md - Learning notes → Learning checks: supplies decisions
src/check/local-check.ts - Learning notes → Context retrieval: adds prior context
src/ask/ask.ts - CLI and init → Cold-start learning: seeds learnings
README.md - CLI and init → PR review learning: imports review insights
README.md - Developer or agent → Change impact: checks change impact
README.md - Local graph → Graph visualization: renders map
- Learning notes → Team sync: syncs team knowledge
README.md - Developer or agent → Review service: submits review event
- Developer or agent → Usage telemetry: emits usage signals