# AGENTS.md ## System Intent & Context This repository is a high-performance, rule-based **block markdown editor** built with Vue 3, TypeScript, and the Lezer parsing framework. Documents are structured as distinct, interactive **Blocks** rather than a single flat string. A 3-stage parsing pipeline bridges UI state down to ASTs, enabling real-time extraction of pages, references, task state, callouts, and inline decorations. --- ## Monorepo Structure ``` apps/dev/ Development and testing sandbox (Vue 3 + Vite + TypeScript) packages/editor/ Core headless engine — parsers, rule registries, composables, tests ``` **Component flow:** ``` apps/dev/src/pages/EditorView.vue └── apps/dev/src/components/Editor.vue └── packages/editor/src/components/Block.vue ├── packages/editor/src/composables/useMarkdownDecorations.ts │ └── packages/editor/src/lib/markdown-parser.ts │ └── packages/editor/src/lib/markdown-rules/engine.ts │ ├── block-classifier.ts │ ├── inline-rules.ts │ └── block-rules.ts ├── packages/editor/src/composables/useBlockKeyboardHandlers.ts └── packages/editor/src/composables/usePatternPlugin.ts └── Lezer Parser Engine ``` --- ## Parsing Pipeline All syntax features flow through a 3-stage pipeline in `packages/editor/src/lib/markdown-rules/engine.ts`: ``` [Raw Block Content String] │ ├── Phase 1: Block Classification → regex classifyBlock() on first line ├── Phase 1a: Priority Detection → separate from task state ├── Phase 2: Lezer AST Visitor → Inline Rules (Bold, Links, PageRef, Tags, Highlights) └── Phase 3: Property Extraction → Suffix Matcher (Key::Value) │ ▼ [ParsedDecorations — unified output struct] ``` ### Unified Output Contract ```typescript export interface DecorationRange { type: "hidden" | "content" from: number to: number className?: string } export interface ParsedDecorations { content: (TokenDecoration | PageRefDecoration | BlockRefDecoration | TagDecoration | HighlightDecoration)[] properties: PropertyInfo[] blocks: BlockDecoration[] } ``` Do not change this interface without updating both unit tests and block render cycles. --- ## Supported Syntax ### Task States and Priorities ``` TODO Fix the critical focus bug [#A] └──┘ └──┘ status priority ``` - **Valid states:** `TODO`, `DOING`, `DONE`, `LATER`, `NOW`, `WAITING`, `CANCELLED` - **State progression:** `TODO → DOING → DONE` (linear). `LATER`, `NOW`, `WAITING`, `CANCELLED` are orthogonal. - **Valid priorities:** `[#A]`, `[#B]`, `[#C]` — independent of task state. ### Obsidian-Style Elements | Syntax | Example | |---|---| | Page reference | `[[Page Name]]` or `[[Real Page\|Display Name]]` | | Block reference | `((block-id-1234))` | | Callout | `> [!NOTE] Description text` | | Property | `author:: John Doe` | **Valid callout types:** `NOTE`, `WARNING`, `TIP`, `DANGER`, `INFO` --- ## Technology Stack | Layer | Technology | Rule | |---|---|---| | Framework | Vue 3 (Composition API, `