# PROJECT KNOWLEDGE BASE

**Generated:** 2026-03-04

## OVERVIEW
Project: **dm-context**
Stack: Node.js, TypeScript (ES2022 / Node16), `@mariozechner/dm` API, `@sinclair/typebox`.

Description: A Git-like context management extension for the `pi` coding agent. It allows AI agents to proactively structure, monitor, and compress their context (history) using tools modeled after Git (`tag`, `log`, `checkout`).

## STRUCTURE
*   `src/`: TypeScript source code for the extension.
    *   `index.ts`: Tool and command registrations (`acm`, `context_tag`, `context_log`, `context_checkout`).
    *   `context.ts`: CLI command registrations (e.g., `/context` for TUI visualization).
    *   `utils.ts`: Shared utility functions and type definitions.
*   `skills/`: DM skills documentation, containing `context-management/SKILL.md` which instructs the LLM on how to use the context tools.
*   `test/`: Markdown test scenarios.
*   `dist/`: Output directory for compiled code (generated by `tsc`).

## COMMANDS
| Action | Command |
|--------|---------|
| Install| `npm install` |
| Build  | `npx tsc` |
| Test   | See `test/test.md` |
| Run    | The extension is loaded natively by `pi`. In a `pi` environment, run `pi -e ./src/index.ts -e ./src/context.ts --skill ./skills` to test locally. |

## CODING STANDARDS
*   **Language**: TypeScript with ESM (`"type": "module"`).
*   **Style**: Standard TypeScript. Interfaces and functions are exported as ES modules. Types are defined using `@sinclair/typebox` for tool parameter schemas.
*   **Rules**: Strict mode is enabled (`"strict": true`). Missing types from the main SDK entry point are defined locally (e.g., `SessionTreeNode` in `utils.ts`).

## WHERE TO LOOK
*   **Source**: `src/`
*   **Tests**: `test/`
*   **Skill Docs**: `skills/context-management/SKILL.md` (Crucial for understanding the agent workflow, tagging strategies, and the "Build, Perceive, Navigate" philosophy).

## NOTES
*   **Architecture**: `dm-context` hooks directly into the `SessionManager` from the `dm` SDK, leveraging its underlying tree structure to implement lossless time travel (squashing noise without deleting the nodes from disk).
*   **Missing Entry File**: The `package.json` defines `"main": "dist/index.js"`. The extension relies on `pi.extensions` config (`src/index.ts`, `src/context.ts`).
*   **Test Script Issues**: `test/test.md` outlines the testing steps.