|
| 1 | +# QMD Extension |
| 2 | + |
| 3 | +Repo-local QMD infrastructure for Pi. |
| 4 | + |
| 5 | +## What it does |
| 6 | + |
| 7 | +- Detects whether the current repo is indexed by QMD |
| 8 | +- Tracks repo freshness via `.pi/qmd.json` |
| 9 | +- Adds a quiet footer for indexed repos only |
| 10 | +- Injects short guidance so the agent knows when to use `qmd query/search/get` via `bash` |
| 11 | +- Provides an interactive split-pane TUI panel (`/qmd`, `/qp`, `Ctrl+Alt+Q`) with: |
| 12 | + - Persistent collection sidebar (left) — always visible, navigate with `j/k`, filter with `/` |
| 13 | + - Context-sensitive main pane (right) — overview, files, or search view |
| 14 | + - Interactive search with debounced lex results and hybrid mode (`ctrl+t`) |
| 15 | + - File browser with NERDTree-style tree and index toggle |
| 16 | + - In-panel update (`u`, bound only) and init (`i`) actions |
| 17 | + - `tab` switches focus between sidebar and main pane |
| 18 | +- Provides subcommands: `/qmd status`, `/qmd update`, `/qmd init` |
| 19 | + |
| 20 | +## What it does not do |
| 21 | + |
| 22 | +- It does **not** expose an always-on search tool |
| 23 | +- It does **not** intercept or rewrite search queries automatically |
| 24 | +- It does **not** mirror QMD config into repo files |
| 25 | + |
| 26 | +The extension owns infra and workflow. The agent still uses the QMD CLI directly for retrieval. |
| 27 | + |
| 28 | +## Source of truth |
| 29 | + |
| 30 | +- **QMD store** — collections and path contexts |
| 31 | +- **`.pi/qmd.json`** — repo binding and freshness marker only |
| 32 | + |
| 33 | +## Commands |
| 34 | + |
| 35 | +### `/qmd` (no args) · `/qp` · `Ctrl+Alt+Q` |
| 36 | + |
| 37 | +Opens the QMD index dashboard as a split-pane panel. Left pane shows all collections; right pane shows overview, files, or search for the selected collection. Use `tab` to switch focus, `s` to search, `f` for files. See `docs/panel.md` for full keyboard shortcuts and layout. |
| 38 | + |
| 39 | +When `hasUI` is false, prints a plain-text summary instead. |
| 40 | + |
| 41 | +### `/qmd status` |
| 42 | + |
| 43 | +Shows current repo state only: |
| 44 | + |
| 45 | +- indexed / not indexed / unavailable |
| 46 | +- repo root |
| 47 | +- collection key |
| 48 | +- freshness state |
| 49 | +- repair notes when marker/store drift is detected |
| 50 | + |
| 51 | +### `/qmd update` |
| 52 | + |
| 53 | +Updates the **current repo collection only**. |
| 54 | +It never reindexes all collections by default. |
| 55 | + |
| 56 | +### `/qmd init` |
| 57 | + |
| 58 | +Starts a deterministic onboarding flow: |
| 59 | + |
| 60 | +1. scan repo |
| 61 | +2. build draft proposal |
| 62 | +3. let the agent refine it with the user |
| 63 | +4. execute `qmd_init` only after explicit confirmation |
| 64 | + |
| 65 | +## Setup |
| 66 | + |
| 67 | +This repo currently expects the local QMD fork to be linked via Bun: |
| 68 | + |
| 69 | +- package: `@tobilu/qmd` |
| 70 | +- local fork: `~/git/qmd-fork` |
| 71 | +- link style: `bun link` |
| 72 | + |
| 73 | +## File layout |
| 74 | + |
| 75 | +``` |
| 76 | +extensions/qmd/ |
| 77 | +├── index.ts # Extension entry point |
| 78 | +├── core/ |
| 79 | +│ ├── errors.ts # Agent-legible typed errors |
| 80 | +│ ├── qmd-store.ts # SDK wrapper with lazy lifecycle |
| 81 | +│ └── types.ts # Zod schemas + TypeBox tool params |
| 82 | +├── domain/ |
| 83 | +│ ├── freshness.ts # Git-based markdown freshness |
| 84 | +│ ├── onboarding.ts # Deterministic init pipeline |
| 85 | +│ └── repo-binding.ts # Repo root, collection key, marker I/O |
| 86 | +├── extension/ |
| 87 | +│ ├── command.ts # Slash commands, alias, shortcut, panel lifecycle |
| 88 | +│ ├── runtime.ts # Session hooks, footer, prompt injection |
| 89 | +│ └── tool.ts # Workflow-scoped qmd_init tool |
| 90 | +├── ui/ |
| 91 | +│ ├── constants.ts # Panel constants (width, shortcuts, icon) |
| 92 | +│ ├── data.ts # Snapshot builder, file tree, helpers |
| 93 | +│ ├── panel.ts # Split-pane TUI panel (sidebar + main: overview/files/search) |
| 94 | +│ └── plain-text.ts # Non-TUI fallback summary |
| 95 | +├── diy/ |
| 96 | +│ ├── README.md # How to copy/paste this blueprint into another repo |
| 97 | +│ ├── qmd-extension-snapshot-spec.md |
| 98 | +│ ├── qmd-extension-diy-execution-plan.md |
| 99 | +│ ├── agent-prompt-template.md |
| 100 | +│ └── references.md |
| 101 | +├── docs/ |
| 102 | +│ ├── architecture.md # Layer diagram and responsibilities |
| 103 | +│ ├── freshness.md # Freshness model and footer behavior |
| 104 | +│ ├── onboarding.md # Init flow steps and caveats |
| 105 | +│ └── panel.md # Panel states, keyboard shortcuts, data flow |
| 106 | +└── __tests__/ |
| 107 | + ├── core/ |
| 108 | + │ ├── qmd-store.test.ts |
| 109 | + │ └── types.test.ts |
| 110 | + ├── domain/ |
| 111 | + │ ├── freshness.test.ts |
| 112 | + │ ├── onboarding.test.ts |
| 113 | + │ └── repo-binding.test.ts |
| 114 | + ├── extension/ |
| 115 | + │ └── runtime.test.ts |
| 116 | + └── ui/ |
| 117 | + └── data.test.ts |
| 118 | +``` |
| 119 | + |
| 120 | +## DIY blueprint |
| 121 | + |
| 122 | +If you want to recreate this extension in another repo without installing this package, use: |
| 123 | + |
| 124 | +- `diy/README.md` — copy/paste usage instructions |
| 125 | +- `diy/qmd-extension-snapshot-spec.md` — current behavior blueprint |
| 126 | +- `diy/qmd-extension-diy-execution-plan.md` — implementation milestones |
| 127 | +- `diy/references.md` — internal docs + agent-memory raw links |
| 128 | +- `diy/agent-prompt-template.md` — copy/paste prompt for rebuilding elsewhere |
| 129 | + |
| 130 | +## Docs |
| 131 | + |
| 132 | +- `docs/architecture.md` — layers, dependency direction, file responsibilities |
| 133 | +- `docs/onboarding.md` — init flow steps and caveats |
| 134 | +- `docs/freshness.md` — freshness model and footer behavior |
| 135 | +- `docs/panel.md` — panel states, keyboard shortcuts, data flow |
0 commit comments