# tmax Development Roadmap

This document outlines the development roadmap for tmax, an extensible terminal-based text editor with T-Lisp scripting capabilities.

## 🎯 Primary Goal: Emacs with Evil-Mode Parity

The immediate priority is achieving **basic Emacs with Evil-mode** functionality. This means:

1. **T-Lisp Core**: All functionality implemented as T-Lisp functions
2. **Evil-Mode Editing**: Vim-style modal editing in normal mode
3. **Emacs Integration**: Key Emacs features (kill ring, minibuffer, help) accessible via M-x
4. **Hybrid Model**: Vim motions where they overlap, Emacs features where they're unique

**What "Basic Emacs with Evil-mode Parity" means:**

### Evil-Mode Features (Normal Mode)
- ✅ Modal editing (normal, insert, visual, command, mx modes) - **COMPLETE**
- ✅ File operations (open, save, create) - **COMPLETE**
- ✅ Multiple buffers - **COMPLETE**
- ✅ **Core operators** (delete, yank, change, put) - **COMPLETE**
- ✅ **Navigation** (word, line, paragraph) - **COMPLETE**
- ✅ **Counts** (3j, 5dd) - **COMPLETE**
- ✅ **Search** (/, ?, n, N) - **COMPLETE**
- ✅ **Jumps** (gg, G) - **COMPLETE**
- ✅ **Undo** (u, C-r) - **COMPLETE**

### Emacs Features (All Modes via M-x)
- ✅ T-Lisp interpreter (like Emacs Lisp) - **COMPLETE**
- ✅ M-x command system - **COMPLETE**
- ✅ **Kill Ring** (clipboard history) - **COMPLETE**
- ✅ **Minibuffer** (completion, history) - **COMPLETE**
- ✅ **Help System** (describe-key, apropos) - **COMPLETE**
- ❌ **Emacs Window Commands** (C-x 2, C-x 3) - **PHASE 1.12**

### Architecture Principle
**All implemented in T-Lisp, callable via M-x, keybindings are just shortcuts.**

Example:
```lisp
;; User presses 'd' in normal mode
→ T-Lisp keymap lookup
→ Execute (evil-delete-operator)
→ Function is also callable via M-x evil-delete-operator

;; User presses 'SPC f' (leader key sequence)
→ T-Lisp keymap lookup for SPC
→ T-Lisp keymap lookup for f in *leader-keymap*
→ Execute (find-file)
→ Function is also callable via M-x find-file
```

**Leader Key System (Spacemacs/Doom-style):**
- `SPC` is the primary leader key (configurable)
- Hierarchical keybinding organization (SPC f, SPC b, SPC w, etc.)
- Which-key shows available bindings after each prefix
- All leader key bindings are just T-Lisp keymap entries
- Users can define their own hierarchical keymaps in T-Lisp

**Estimated timeline to basic parity**: 5-6 weeks (Phase 1.1 - 1.13)

### Emacs Features NOT Included

To avoid confusion, here are Emacs features we're **not** implementing:

| Feature | Reason | Alternative |
|---------|--------|-------------|
| **Emacs Navigation** (C-n, C-p, C-f, C-b, C-a, C-e) | Use Vim motions instead | `j`, `k`, `l`, `h`, `0`, `$` |
| **Emacs Word Navigation** (M-f, M-b) | Use Vim motions | `w`, `b` |
| **Mark/Region** (C-SPC, C-x C-x) | Evil visual mode covers this | `v`, `V` |
| **Emacs Buffer Menu** (C-x C-b) | Use command-mode or M-x | `:ls`, `M-x buffer-list` |
| **Recursive Editing** (C-r in minibuffer) | Complexity vs benefit | Use separate minibuffer sessions |
| **Narrowing/Widening** | Can be added later as plugin | User-extensible via T-Lisp |
| **Abbrev Mode** | Can be added later as plugin | User-extensible via T-Lisp |
| **Fill/Paragraph Fill** | Can be added later as plugin | User-extensible via T-Lisp |

**Philosophy**: Keep core minimal, advanced features as T-Lisp plugins/extensions.

### Phase 1 Overview: Evil + Emacs Integration

| Phase | Feature | Type | Priority |
|-------|---------|------|----------|
| 1.1 | Enhanced Navigation (w, b, e, 0, $) | Evil | CRITICAL |
| 1.2 | Basic Operators (dd, dw, yy, p, u) | Evil | CRITICAL |
| 1.3 | Counts (3j, 5dd) | Evil | HIGH |
| 1.4 | Change Operator (cw, cc) | Evil | HIGH |
| 1.5 | Search (/, ?, n, N) | Evil | HIGH |
| 1.6 | Jump Commands (gg, G) | Evil | HIGH |
| 1.7 | Visual Selection | Evil | MEDIUM |
| 1.8 | Basic Text Objects (iw, aw) | Evil | MEDIUM |
| 1.9 | Kill Ring System | Emacs | HIGH |
| 1.10 | Minibuffer + Which-key + Fuzzy Match | Emacs | HIGH |
| 1.11 | Help System | Emacs | MEDIUM |
| 1.12 | Emacs Window Commands | Emacs | LOW |
| 1.13 | Fuzzy Search Commands | Navigation | MEDIUM |

**All implemented as T-Lisp functions, all callable via M-x.**

## Current Status: v0.2.0 - Core Editing Complete, Editor Primitives In Progress

**Status**: Phase 0.8 (Daemon/Client) and Phase 1 (Core Editing) are COMPLETE. Phase 1.5 (Editor Prerequisites) is the blocking next step — TypeScript-level primitives must be closed before programming modes can grow.

### Completed Features
- ✅ **Core Editor**: A T-Lisp-based terminal editor with vim-style key bindings (hjkl navigation)
- ✅ **T-Lisp Extensibility**: A complete T-Lisp interpreter with tail-call optimization and macro system
- ✅ **Modal Editing**: Five editing modes: normal, insert, visual, command, and M-x
- ✅ **File Operations**: Open, save, and create files through a command interface
- ✅ **Multiple Buffers**: Efficient buffer management with gap buffer implementation
- ✅ **Zero External Dependencies**: A self-contained application for security and simplicity
- ✅ **Key Bindings**: Configurable key bindings through T-Lisp API
- ✅ **Configuration**: `~/.config/tmax/init.tlisp` file support for user customization
- ✅ **Testing**: Comprehensive test suite with tmux UI harness
- ✅ **Bun Runtime**: Running on Bun for improved performance
- ✅ **Daemon/Client**: Emacs-style daemon with Frame-based multi-client support
- ✅ **Messages Buffer**: `*Messages*` buffer for editor event observability
- ✅ **Enhanced Navigation**: Word, line, paragraph navigation with jump commands
- ✅ **Core Operators**: Delete, yank, change, put operations with count prefix
- ✅ **Search**: Forward/backward search with word-under-cursor search
- ✅ **Visual Mode**: Characterwise selection with text object support
- ✅ **Kill Ring**: Emacs-style clipboard history with yank-pop cycling
- ✅ **Minibuffer**: Lisp-owned M-x and buffer completion with Orderless matching, Vertico display, Marginalia annotations, and histories
- ✅ **Which-key**: Popup showing available bindings after prefix keys
- ✅ **Help System**: describe-key, describe-function, apropos-command
- ✅ **Macro Recording**: Record, playback, and persist macros
- ✅ **Plugin System**: Plugin loading with directory structure and repository
- ✅ **Interchangeable Frontends**: TUI (ANSI), Ink (React), Steep

### Mode System Status

| Mode | Type | Registration | Keymap | Commands | Electric | Indent |
|------|------|-------------|--------|----------|----------|--------|
| fundamental | Major | ✅ | — | — | — | — |
| typescript | Major | ✅ `.ts/.tsx/.js/.jsx/.mjs` | ❌ | ❌ | ❌ | regex-only |
| python | Major | ✅ `.py/.pyi` | ❌ | ❌ | ❌ | regex-only |
| lisp | Major | ✅ `.tlisp/.lisp/.el/.clj` | ❌ | ❌ | ❌ | regex-only |
| go | Major | ✅ `.go` | ❌ | ❌ | ❌ | regex-only |
| markdown | Major | ✅ `.md/.markdown/.mdx` | ✅ 30 bindings | ✅ ~750 lines | ✅ list continue | N/A |
| line-numbers | Minor | ✅ global | — | ✅ toggle | — | — |
| relative-line-numbers | Minor | ✅ buffer-local | — | ✅ toggle | — | — |
| auto-fill | Minor | ✅ global | — | ✅ toggle | — | — |

**Blocking gaps** (Phase 1.5): auto-indent on Enter, electric-pair-mode, show-paren-mode, comment-dwim, indent engine improvements, syntax highlight pipeline wiring.

### Test Coverage
- Unit tests: tokenizer, parser, evaluator, editor API
- Integration tests: file operations, buffer management
- UI tests: tmux-based test harness (15 assertions, 93.3% pass rate)

---

## Immediate Priority: Editor Prerequisites (Phase 1.5) — BLOCKING

**Why Phase 1.5 comes first**: All programming modes are scaffolding because TypeScript primitives are missing. Auto-indent on Enter, electric pairs, show-paren, and comment commands must exist before any programming mode can provide meaningful behavior. Phase 2 (extensibility) and Phase 3 (advanced features) depend on these primitives.

**See Phase 1.5 below for the full breakdown.**

---

## Phase 2 Preview: Extensibility & Plugin Ecosystem

### Phase 0.4: T-Lisp-Centric Key Binding System ✅ COMPLETE

**Objective**: Complete migration from TypeScript-centric to T-Lisp-centric key binding system.

#### 0.4.1 - Implement T-Lisp Keymaps [0/2]
- [ ] Add `hash-map` or `association-list` data type to T-Lisp standard library
- [ ] Define keymap variables for each mode (`*normal-mode-keymap*`, `*insert-mode-keymap*`, etc.)
- [ ] Implement keymap lookup and manipulation functions

#### 0.4.2 - Create Core Bindings File [1/2]
- [x] Default bindings using T-Lisp syntax
- [ ] Create `src/tlisp/core-bindings.tlisp` file
- [ ] Remove `initializeDefaultKeyMappings()` from editor.ts
- [ ] Load core-bindings.tlisp at editor startup

#### 0.4.3 - Refactor TypeScript Key Handler [1/3]
- [x] TypeScript executes T-Lisp commands
- [ ] Remove TypeScript `keyMappings` Map from editor.ts
- [ ] Update `handleKey()` to query T-Lisp environment for command lookup
- [ ] Implement graceful fallback for unbound keys

#### 0.4.4 - Re-implement (key-bind) in T-Lisp [0/2]
- [ ] Remove built-in `(key-bind)` function from TypeScript API
- [ ] Implement `(key-bind)` as pure T-Lisp function in stdlib
- [ ] Add helper functions: `(get-binding)`, `(remove-binding)`, `(list-bindings)`
- [ ] Update tests for T-Lisp key-bind implementation

**Testing Requirements**:
- Unit tests for hash-map/association-list operations
- Integration tests for key binding lookup and execution
- End-to-end tests for complete key binding workflow
- Tests for core-bindings.tlisp loading and error handling

### Phase 0.5: Testing Infrastructure Enhancement (TRT Framework)

**Status:** 📋 PLANNED
**Priority:** HIGH (enables quality for Phase 1)
**Timeline:** 1-2 weeks (MVP: 8 days)

**Objective:** Implement TRT (Tmax Regression Testing) - a self-hosted T-Lisp testing framework inspired by Emacs ERT, enabling comprehensive testing of T-Lisp code and editor features.

**Feature Prioritization:**

**🚨 MUST HAVE (MVP - 8 days)**
- Essential features for any functional test framework
- Delivers working test framework with basic functionality

**⭐ SHOULD HAVE (Phase 0.6 - +10 days)**
- Important features for real-world development workflows
- Delivers professional-grade testing infrastructure

**💡 NICE TO HAVE (Phase 0.7+ - +15-20 days)**
- Advanced features and polish
- Delivers enterprise-grade testing framework

See [RFC-001: TRT Framework](../rfcs/RFC-001-trt-framework.md) for complete specification and prioritization details.

---

#### MVP Breakdown (Phase 0.5 - 8 days)

##### Phase 0.5.1: Core Framework MVP [CRITICAL] (4 days)
- [ ] `deftest` macro - Define tests
- [ ] `should-equal` assertion - Basic equality check
- [ ] Test runner CLI - `tmax --test` entry point
- [ ] Test discovery - Find `*.test.tlisp` files automatically
- [ ] Basic CLI output - Pass/fail results with test names
- [ ] Exit codes - CI/CD integration (0=success, 1=failure)

##### Phase 0.5.2: Essential Assertions [CRITICAL] (2 days)
- [ ] Core assertions (4 total)
  - [ ] `should-equal` - Compare values
  - [ ] `should-be-truthy` - Truthy check
  - [ ] `should-be-falsy` - Falsy check
  - [ ] `should-throw` - Error thrown check
- [ ] Error message formatting - Clear failure messages

##### Phase 0.5.3: Basic Isolation [CRITICAL] (2 days)
- [ ] Environment reset between tests
- [ ] Global state cleanup (clear buffers, reset variables)
- [ ] Simple before/after hooks - Setup and teardown

**MVP Deliverables:**
- ✅ Can define and run tests
- ✅ Test discovery works automatically
- ✅ Basic assertions pass/fail
- ✅ Tests isolated (no state leakage)
- ✅ CI/CD integration ready

---

#### Should Have Breakdown (Phase 0.6 - +10 days)

##### Phase 0.6.1: Rich Assertions [IMPORTANT] (3 days)
- [ ] String assertions (5+ assertions)
  - [ ] `should-contain` - Substring check
  - [ ] `should-match` - Regex match
  - [ ] `should-be-empty-string` - Empty check
- [ ] Collection assertions (4+ assertions)
  - [ ] `should-have-length` - Length check
  - [ ] `should-contain` - Element in collection
  - [ ] `should-be-empty` - Empty collection
- [ ] Numeric assertions (4+ assertions)
  - [ ] `should-be-greater-than`
  - [ ] `should-be-less-than`
  - [ ] `should-be-close-to` - Approximate equality
- [ ] Custom assertion API - `defassertion`

##### Phase 0.6.2: Fixtures System [IMPORTANT] (3 days)
- [ ] `deffixture` macro - Define reusable fixtures
- [ ] `with-fixture` macro - Use fixture in test
- [ ] Fixture scopes - `:function`, `:suite`
- [ ] Auto-cleanup - Even if test fails
- [ ] Fixture dependencies - Fixtures using other fixtures

##### Phase 0.6.3: Test Suites [IMPORTANT] (2 days)
- [ ] `describe-suite` macro - Group related tests
- [ ] Nested test organization - Hierarchical structure
- [ ] Suite-level hooks - `:before-all`, `:after-all`
- [ ] Per-suite filtering - Run specific suites

##### Phase 0.6.4: Async Testing [IMPORTANT] (4 days)
- [ ] `deftest-async` macro - Async test support
- [ ] Async assertions (2 assertions)
  - [ ] `should-await-equal` - Await and compare
  - [ ] `should-await-throw` - Await error check
- [ ] Timeout protection - Fail if too slow
- [ ] Async error handling - Proper rejection detection

##### Phase 0.6.5: Better CLI Output [IMPORTANT] (2 days)
- [ ] Progress indicators - Show test progress
- [ ] ANSI colored output - Visual clarity
- [ ] Test summary statistics - Count and percentage
- [ ] Per-file results - Organized output
- [ ] Verbose mode toggle - Detailed output option

##### Phase 0.6.6: Basic Coverage [IMPORTANT] (4 days)
- [ ] Line coverage tracking - Which lines executed
- [ ] Coverage summary - Overall percentage
- [ ] Per-file coverage - File-by-file breakdown
- [ ] Text format output - Human-readable
- [ ] Coverage thresholds - Fail if below target

**Phase 0.6 Deliverables:**
- ✅ Rich assertion library (20+ assertions)
- ✅ Reusable test fixtures
- ✅ Test suite organization
- ✅ Async operation testing
- ✅ Professional CLI output
- ✅ Code coverage measurement

---

#### Nice to Have Breakdown (Phase 0.7+ - +15-20 days)

Can be implemented incrementally as needed:

##### Advanced Test Isolation
- Four-layer isolation strategy (environment, buffer, global, module)
- Buffer auto-cleanup with `with-test-buffer` macro
- Flaky test detection with retry logic
- Strict mode (fail if state leaks detected)

##### Parametrized Tests
- `deftest-parametrized` macro
- Table-driven test syntax
- Per-case setup/teardown hooks

##### Snapshot Testing
- `should-match-snapshot` assertion
- External `.snap` files
- Interactive update workflow
- Diff visualization (side-by-side, unified)

##### Test Explorer UI
- Buffer-based Test Explorer
- Hierarchical tree view
- Interactive keybindings
- Jump to test definition

##### Examples as Tests
- Test docstring examples automatically
- Example coverage tracking
- Triple purpose (docs/tests/demos)

##### Watch Mode & TDD
- File watcher implementation
- Smart test selection (affected tests)
- TDD workflow (Red-Green-Refactor)
- Interactive watch menu

##### Advanced Coverage
- Branch coverage tracking
- Function coverage tracking
- HTML report generation
- Lcov format for CI/CD
- Threshold enforcement and trending

##### Mocking & Spying
- `spy-on` function
- `mock-fn` creation
- Call verification APIs
- Module mocking with runtime evaluation

##### Benchmarking
- `deftest-bench` macro
- Performance measurement (ops/sec, variance)
- Baseline tracking and comparison
- Regression detection

**Phase 0.7+ Deliverables:**
- ✅ Enterprise features (all nice-to-have items)
- ✅ Advanced isolation and reliability
- ✅ Developer experience enhancements
- ✅ Performance optimization tools

**Success Criteria:**
- ✅ Can run TRT tests with `bun run test:trt` (implemented in SPEC-049; runs the self-hosted trt framework via `bin/trt` → `tmax --test`)
- ✅ All existing T-Lisp features have TRT test coverage (80%+) (in progress; core framework self-tests + pilot migrations landed)
- ✅ TRT tests pass in CI/CD pipeline (exit codes 0/1/2)
- ✅ Users can write and run their own TRT tests in `test/tlisp/` (`.test.tlisp` files, auto-discovered)
- ✅ Test results formatted clearly with pass/fail/error indicators (human report + `--json`)
- ✅ Watch mode enables rapid TDD workflow (watch/TDD is a TS-level file-watcher enhancement; framework is T-Lisp)

**Dependencies:**
- Must complete after Phase 0.4 (key binding refactor) - TRT will test key bindings
- Must complete before Phase 1.2 (basic operators) - enables TDD for complex features
- Enables safer development of all Phase 1 features

**Benefits:**
- Self-hosted testing in T-Lisp (like Emacs ERT)
- Users can test their configurations and plugins
- Executable documentation through tests
- Safer refactoring with regression tests
- Better code quality for T-Lisp features

---

### Phase 0.8: Server/Client Architecture

**Status:** ✅ COMPLETE
**Priority:** HIGH (enables AI agent control and instant file operations)

**Objective:** Implement server/client architecture inspired by Emacs' `emacsclient` system, enabling instant file opening, T-Lisp evaluation from command line, and AI agent control of the editor.

**Key Innovation:** This transforms tmax into an **AI-native editor**, the first terminal editor designed from the ground up for AI agent control.

**Feature Prioritization:**

**🚨 MUST HAVE (MVP - Phase 0.8.1, 1 week)**
- Server mode (`tmax --daemon`)
- Client CLI (`tmaxclient`)
- File opening with wait/no-wait modes
- T-Lisp evaluation from command line
- Basic JSON-RPC protocol over Unix socket

**⭐ SHOULD HAVE (Phase 0.8.2, +1 week)**
- Advanced client commands (list, kill, insert buffers)
- Custom socket paths and multiple server instances
- Extended wait modes (terminal, background, new frame)
- Integration examples (git, file managers, shells)

**💡 NICE TO HAVE (Phase 0.8.3, +1 week)**
- TCP sockets for remote access
- Auto-start server on first client request
- T-Lisp server API (hooks, client info, broadcast)
- AI agent protocol extensions (full state query, help system)

**AI Agent Capabilities (Unique to tmax):**

Full editor control via JSON-RPC protocol:
- ✅ **State Query** - Get full editor state (buffers, vars, cursor, selections)
- ✅ **Code Execution** - Evaluate T-Lisp and get results
- ✅ **Help System** - Query functions (`describe-function`, `describe-variable`, `apropos`)
- ✅ **Source Navigation** - Find function sources, cross-references
- ✅ **Real-Time Feedback** - 10x faster than file-based workflows (62ms vs 605ms)

**See [RFC-002: Server/Client Architecture](../rfcs/RFC-002-server-client-architecture.md) for complete specification.**

---

#### Phase 0.8.1: Basic Server/Client [CRITICAL] (1 week)

**Server Implementation:**
- [ ] `tmax --daemon` command
- [ ] Unix socket listener (`/tmp/tmax-$UID/server`)
- [ ] JSON-RPC protocol handler
- [ ] Connection management (accept, close, cleanup)
- [ ] T-Lisp execution engine integration
- [ ] Graceful shutdown (SIGTERM, SIGINT)

**Client Implementation:**
- [ ] `tmaxclient` CLI tool
- [ ] File opening: `tmaxclient file.txt`
- [ ] T-Lisp eval: `tmaxclient --eval '(code)'`
- [ ] Wait mode (block until buffer closed)
- [ ] No-wait mode (`-n` flag)
- [ ] Error handling (server not running, connection refused)

**AI Agent Protocol (Core):**
- [ ] Query method: `{"method": "query", "params": {"query": "full-state"}}`
- [ ] Eval method: `{"method": "eval", "params": {"code": "(buffer-list)"}}
- [ ] Command method: `{"method": "command", "params": {"command": "save-buffer"}}`

**Testing:**
- [ ] Unit tests for server socket handling
- [ ] Unit tests for client connection logic
- [ ] Integration tests (server + client)
- [ ] Manual testing with real workflows (git, file managers)

---

#### Phase 0.8.2: Advanced Client Features [IMPORTANT] (1 week)

**Client Commands:**
- [ ] `tmaxclient --list-buffers` - List all buffers
- [ ] `tmaxclient --kill-buffer name` - Kill specific buffer
- [ ] `tmaxclient --insert text` - Insert text at cursor
- [ ] `tmaxclient --insert-stdin` - Insert from stdin pipe
- [ ] `tmaxclient --script file.tlisp` - Execute T-Lisp file
- [ ] `tmaxclient --server-info` - Get server status
- [ ] `tmaxclient --ping` - Check if server running

**Socket Management:**
- [ ] Custom socket paths: `-s /path/to/socket`
- [ ] Environment variable: `$TMAX_SOCKET`
- [ ] Multiple server instances support
- [ ] Socket conflict detection
- [ ] Socket cleanup on shutdown

**Wait Modes:**
- [ ] `-c` flag (new frame/buffer mode)
- [ ] `-nw` flag (terminal mode for $EDITOR)
- [ ] Exit codes based on buffer state (saved/discarded)

**Integration Examples:**
- [ ] Git integration (`$GIT_EDITOR='tmaxclient -nw'`)
- [ ] File manager examples (ranger, lf, nnn, fzf)
- [ ] Shell function examples (tf, tb, tl, te)
- [ ] Script examples (Python, shell)

---

#### Phase 0.8.3: AI Agent Enhancement [MEDIUM] (3-5 days)

**Extended Query Methods:**
- [ ] `describe-function` - Get function documentation, signature, source location
- [ ] `describe-variable` - Get variable value, documentation, customization info
- [ ] `apropos-command` - Search functions by pattern
- [ ] `find-function-source` - Locate function definition
- [ ] `find-usages` - Find all calls/references to function
- [ ] `xref` - Cross-reference analysis (callers, callees)

**Help System Integration:**
- [ ] Query help system via JSON-RPC
- [ ] Return structured documentation (signature, docs, examples, related)
- [ ] Support for `describe-key`, `describe-variable`, `apropos`
- [ ] Source location with file:line references

**TCP Sockets:**
- [ ] `tmax --daemon=tcp:host:port`
- [ ] `tmaxclient -s host:port file.txt`
- [ ] Remote connection support
- [ ] SSH tunnel examples
- [ ] Security considerations (localhost only by default)

**Auto-Start:**
- [ ] `--autostart` flag for client
- [ ] Config option: `(setq server-autostart t)`
- [ ] Server detection logic
- [ ] Automatic server startup on first request

**T-Lisp Server API:**
- [ ] `(server-running-p)` - Check server status
- [ ] `(server-socket-path)` - Get socket path
- [ ] `(server-clients)` - List connected clients
- [ ] `(server-broadcast message)` - Send to all clients
- [ ] `(server-current-client)` - Get current client info
- [ ] Server hooks: `server-client-connect-hook`, `server-client-disconnect-hook`
- [ ] Server hooks: `server-start-hook`, `server-shutdown-hook`

**Documentation:**
- [ ] User guide for server/client usage
- [ ] AI agent integration guide (Python, TypeScript examples)
- [ ] T-Lisp API reference for server functions
- [ ] Troubleshooting guide (socket permissions, etc.)

**Phase 0.8 Deliverables:**
- ✅ Server/client infrastructure (Unix socket + TCP)
- ✅ AI agent protocol with full state query and help system
- ✅ Integration examples (git, file managers, shells)
- ✅ AI agent client libraries (Python, TypeScript)
- ✅ Comprehensive documentation for REPL-driven development with AI

**Success Criteria:**
- ✅ Can start server and connect from client
- ✅ Instant file opening (<100ms vs 2-5s startup)
- ✅ AI agents can query full editor state
- ✅ AI agents can execute T-Lisp and get results
- ✅ Help system accessible via JSON-RPC
- ✅ Integration with git, file managers, shells working

**Dependencies:**
- Can be developed in parallel with Phase 0.4-0.7
- Must complete before Phase 2 (extensibility) for plugin development
- Enables AI-assisted development for all future features

**Benefits:**
- Instant file operations without startup overhead
- AI agent control for automated development
- REPL-driven development from external tools
- Integration with Unix philosophy (pipelines, scripts)
- Competitive advantage: First AI-native terminal editor

---

## Phase 1: Core Editing (v0.2.0)

**Focus**: Implement fundamental editing commands to reach basic "Emacs with Evil-mode" parity.

**Approach**: Hybrid model - Evil-mode in normal mode, Emacs-style bindings in insert/command modes.

### 1.1 - Enhanced Navigation ✅ COMPLETE
Priority: CRITICAL | Impact: Non-negotiable for daily use

- [x] Word navigation: `w` (forward), `b` (backward), `e` (end of word)
- [x] Line navigation: `0` (start), `$` (end), `^` (first non-blank)
- [x] Paragraph navigation: `{` (previous), `}` (next)
- [x] Screen navigation: `H` (top), `M` (middle), `L` (bottom)
- [x] Tests for all navigation commands

**Rationale**: Without word and line navigation, you can't efficiently edit code or text.

### 1.2 - Basic Operators ✅ COMPLETE
Priority: CRITICAL | Impact: Core editing capability

- [x] Delete operator: `dd` (line), `dw` (word), `x` (character), `D` (to end of line)
- [x] Yank (copy) operator: `yy` (line), `yw` (word)
- [x] Put (paste): `p` (after cursor), `P` (before cursor)
- [x] Undo: `u` (undo), `C-r` (redo)
- [x] Operator framework: Parse `operator + count + motion` sequences
- [x] Tests for operator combinations

**Rationale**: These are the absolute minimum for text manipulation. Without these, tmax is just a viewer, not an editor.

### 1.3 - Counts & Multipliers ✅ COMPLETE
Priority: HIGH | Impact: Vim's compositional power

- [x] Parse count prefix: `3j`, `5dd`, `2w`
- [x] Apply count to motions: `10j` (down 10 lines)
- [x] Apply count to operators: `3dd` (delete 3 lines), `5x` (delete 5 chars)
- [x] Default count of 1 when omitted
- [x] Tests for count combinations

**Rationale**: Counts are what makes Vim efficient. Without them, every operation is tedious.

### 1.4 - Change Operator ✅ COMPLETE
Priority: HIGH | Impact: Distinguish delete vs change workflow

- [x] Change operator: `cw` (change word), `cc` (change line), `C` (to end of line)
- [x] Change deletes and enters insert mode
- [x] Change with text objects: `ci"`, `ca{`
- [x] Tests for change operations

**Rationale**: The distinction between delete (d) and change (c) is core to Vim workflow.

### 1.5 - Search Functionality ✅ COMPLETE
Priority: HIGH | Impact: Essential for code navigation

- [x] `/pattern` - Forward search
- [x] `?pattern` - Backward search
- [x] `n` - Next search result
- [x] `N` - Previous search result
- [x] `*` - Search word under cursor (forward)
- [x] `#` - Search word under cursor (backward)
- [x] Highlight search matches
- [x] Incremental search with real-time feedback
- [x] Search history navigation
- [x] Tests for search operations

**Rationale**: Can't efficiently navigate codebases without search.

### 1.6 - Jump Commands ✅ COMPLETE
Priority: HIGH | Impact: Quick file navigation

- [x] `gg` - Jump to first line of buffer
- [x] `G` - Jump to last line of buffer
- [x] `:line_number` - Jump to specific line
- [x] `C-u` + `j/k` - Jump by screen lines
- [x] Line number display in gutter (optional)
- [x] Tests for jump command accuracy

**Rationale**: Essential for quickly moving through files.

### 1.7 - Visual Selection Operations ✅ COMPLETE
Priority: MEDIUM | Impact: Improved text manipulation

- [x] Characterwise visual mode (v) + operations (d, y, c)
- [x] Linewise visual mode (V) + operations (d, y, c)
- [x] Blockwise visual mode (C-v) + operations
- [x] Visual selection indicators
- [x] Visual text operations (delete, yank, change, indent)
- [x] Tests for visual mode operations

**Rationale**: Visual mode is important but you can work around it with operators + motions.

### 1.8 - Basic Text Objects ✅ COMPLETE
Priority: MEDIUM | Impact: Faster editing workflows

- [x] Inner word: `iw` (inside word)
- [x] Outer word: `aw` (including space)
- [x] Inner sentence: `is`
- [x] Outer sentence: `as`
- [x] Tests for basic text objects

**Rationale**: Text objects are powerful but advanced. Can start with basic ones.

### 1.9 - Kill Ring System (Emacs Integration) ✅ COMPLETE
Priority: HIGH | Impact: Enhanced clipboard with history

- [x] Kill ring data structure in T-Lisp (stack with max size)
- [x] `(kill-ring-add text)` - Add text to kill ring
- [x] `(kill-ring-latest)` - Get most recent kill
- [x] `(kill-ring-previous)` - Get previous kill (for yank-pop)
- [x] `(kill-region start end)` - Cut region to kill ring
- [x] `(copy-region-as-kill start end)` - Copy region to kill ring
- [x] `(yank)` - Insert latest kill at cursor
- [x] `(yank-pop)` - Replace last yank with previous kill
- [x] Integration: Evil's delete/yank operations also use kill ring
- [x] Kill ring persistence across sessions
- [x] Keybindings: `C-w`, `M-w`, `C-y`, `M-y`
- [x] Tests for kill ring operations

**Rationale**: Kill ring is Emacs' signature feature. More sophisticated than simple clipboard - provides history and cycling. Complements Evil-mode perfectly.

**Implementation Note**: All implemented as T-Lisp functions, callable via M-x, keybindings are just shortcuts to these functions.

### 1.10 - Lisp-Owned Minibuffer Completion and Which-key ✅ COMPLETE
Priority: HIGH | Impact: Enhanced command experience (Spacemacs/Doom-style)

#### Core Minibuffer
- [x] Generic minibuffer UI and vertical completion view
- [x] `(read-from-minibuffer ...)` - Raw input sessions
- [x] `(completing-read ...)` - Named completion tables and accept actions
- [x] T-Lisp-owned keyed histories
- [x] `C-g` and Escape - Abort/minibuffer cancel mechanisms
- [x] Integration: M-x and `C-x b` use the reusable completion framework
- [ ] File completion and command-mode migration

#### Orderless, Vertico, and Marginalia Behavior
- [x] Stable all-components-in-any-order matching for M-x and buffers
- [x] Smart case and `=`, `^`, `~`, `,`, `!`, and `&` affix styles
- [x] Vertical candidates, selection, scrolling, counts, and Tab insertion
- [x] Category-aware command and buffer annotations
- [x] `C-x b` switches to existing buffers or creates raw input
- [x] Frame-local serializable minibuffer sessions

#### Which-key System
- [x] `(which-key-show prefix-key)` - Show available bindings after prefix
- [x] Popup menu displays after 0.5s delay (configurable)
- [x] Hierarchical menu display:
  ```
  SPC → Shows:
    ;  M-x execute-extended-command
    f  File operations
    b  Buffer operations
    w  Window operations
    h  Help
  ```
- [x] Nested which-key for submenus:
  ```
  SPC f → Shows:
    f  find-file
    s  save-file
    R  recent-files
  ```
- [x] Integration with all keymaps (normal, insert, global, etc.)
- [x] Keybinding hints in status line
- [x] Tests for which-key system

#### Command Documentation Preview
- [x] Show function docstring in minibuffer completion
- [x] Display keybinding next to command name:
  ```
  M-x kill-region
    Kill region between point and mark
    Binding: C-w
  ```
- [x] Preview first line of docstring in which-key
- [x] Full doc available via `C-h f` (describe-function)

#### Enhanced M-x Experience
- [x] `(execute-extended-command)` - Read and execute command
- [x] M-x binding: `SPC ;` (simple, single binding)
- [x] Annotated command candidates and stable Orderless filtering
- [x] Hide commands without documentation or bindings
- [ ] Context-aware suggestions and custom command groups

#### Hierarchical Keybinding System (Leader Key)
- [x] Define leader key hierarchy in T-Lisp:
  ```lisp
  ;; Leader key definition
  (define-key *global-keymap* "SPC" *leader-keymap*)

  ;; M-x is the primary entry point
  (define-key *leader-keymap* ";" 'execute-extended-command)

  ;; File operations submenu
  (define-key *leader-keymap* "f" *file-keymap*)
  (define-key *file-keymap* "f" 'find-file)
  (define-key *file-keymap* "s" 'save-file)

  ;; Buffer operations submenu
  (define-key *leader-keymap* "b" *buffer-keymap*)
  (define-key *buffer-keymap* "b" 'switch-to-buffer)
  (define-key *buffer-keymap* "k" 'kill-buffer)
  ```
- [x] Leader key for each mode (normal mode uses SPC, others can differ)
- [x] Customizable leader key (user can change from SPC in config)
- [x] Nested keymaps support (arbitrary depth)
- [x] Keymap conflict detection and resolution

#### Tests
- [x] Minibuffer input/output tests
- [x] Orderless matching tests (components, affixes, spans, stability)
- [x] Which-key popup tests (timing, display)
- [x] Command history tests
- [x] Integration tests for M-x and buffer completion

**Rationale**: Which-key provides discoverability while the reusable Lisp-owned completion stack provides Emacs-style narrowing and selection without score-based auto-selection.

**Implementation Note**: Completion tables, matching, annotations, selection, scrolling, histories, and key semantics are implemented in T-Lisp. TypeScript transports and renders the published view.

### 1.11 - Help System ✅ COMPLETE
Priority: MEDIUM | Impact: Discoverability for T-Lisp extensibility

- [x] Function documentation storage in T-Lisp (docstrings)
- [x] `(describe-key key)` - Show function bound to key
- [x] `(describe-function name)` - Show function documentation
- [x] `(describe-variable name)` - Show variable documentation
- [x] `(apropos-command pattern)` - Search commands by regex
- [x] `(apropos-function pattern)` - Search all functions
- [x] Help buffer display system
- [x] Keybindings: `C-h k`, `C-h f`, `C-h v`, `C-h a`
- [x] Integration: Show docstrings in M-x completion
- [x] Tests for help system

**Rationale**: Help system is crucial for discoverability in an extensible editor. Makes T-Lisp API accessible to users.

**Implementation Note**: All help functions are T-Lisp, documentation stored in function definitions.

### 1.12 - Emacs Window Commands
Priority: LOW | Impact: Alternative keybindings to window features

- [ ] `(split-window-below)` - Split window horizontally (create new pane below)
- [ ] `(split-window-right)` - Split window vertically (create new pane right)
- [ ] `(delete-window)` - Close current window
- [ ] `(delete-other-windows)` - Close all other windows (make current fullscreen)
- [ ] `(other-window n)` - Switch focus to next window (n=1 for next, n=-1 for prev)
- [ ] Keybindings: `C-x 2`, `C-x 3`, `C-x 0`, `C-x 1`, `C-x o`
- [ ] Share infrastructure with Vim split commands (`:split`, `:vsplit`)
- [ ] Tests for Emacs window commands

**Rationale**: Provides Emacs-style keybindings for window management. Same underlying feature as Vim splits, just different interface.

**Implementation Note**: These are T-Lisp wrapper functions that call the same window-management primitives as Vim splits.

### 1.13 - Fuzzy Search Commands (Document Navigation)
Priority: MEDIUM | Impact: Efficient document navigation

- [ ] `(fuzzy-search-line pattern)` - Fuzzy search lines in current buffer
- [ ] `(fuzzy-switch-buffer)` - Fuzzy search and switch buffers
- [ ] `(fuzzy-find-file)` - Fuzzy search for files
- [ ] `(fuzzy-goto-line)` - Jump to line with preview
- [ ] All commands use same fuzzy matching engine from minibuffer
- [ ] Integration with which-key (show available actions on match)
- [ ] Integration with minibuffer history
- [ ] Preview: show line/context before selecting
- [ ] Keybindings:
  - `SPC l` - Search lines in buffer
  - `SPC b b` - Switch buffer (fuzzy version of :b)
  - `SPC f f` - Find file (fuzzy version)
  - `SPC j` - Jump to line
- [ ] Tests for fuzzy search operations

**Rationale**: Fuzzy search makes large documents and projects navigable. Instead of exact matches, type fragments and see all matching lines/buffers/files. This is how modern editors (VS Code, Spacemacs) handle navigation.

**Example usage:**
```
SPC l (fuzzy-search-line)
Type: "init"
↓
Shows all lines matching "init":
  (defun init ()              10:23  Buffer: main.ts
  (setq init-var)            15:4   Buffer: main.ts
  (init-config)              42:10  Buffer: config.tlisp

Select → jumps to that line (with preview)
```

**Implementation Note**: All implemented in T-Lisp using the fuzzy matching engine from Phase 1.10. These are T-Lisp functions callable via M-x.

---

## Future Enhancements (Post-Phase 1)

The following features enhance the editing experience but are not required for basic "Emacs with Evil-mode" parity. These can be implemented as user needs emerge or as the T-Lisp ecosystem matures.

### Context Actions (Embark-style)
Priority: LOW | Impact: Power user feature

Allow actions on completion candidates based on their type.

- [ ] `(embark-act)` - Show actions for selected candidate
- [ ] Context-aware actions based on candidate type:
  - Files: open, delete, rename, copy, chmod
  - Buffers: switch, kill, save, rename
  - Functions: describe, execute, view source
  - Variables: describe, set, customize
- [ ] Works from: minibuffer completion, buffers, file lists
- [ ] Action menu via which-key
- [ ] Custom action definitions in T-Lisp
- [ ] Keybinding: `C-h e` or `SPC e` after selection
- [ ] Tests

**Example:**
```
SPC b (fuzzy-switch-buffer)
Select: main.ts
Press: SPC e (embark-act)
Shows actions:
  s  Switch to buffer
  k  Kill buffer
  w  Save buffer
  r  Rename buffer
```

**Rationale**: Embark provides context-aware actions everywhere. Powerful but advanced. Can be added after core editing is solid.

**Implementation Note**: Pure T-Lisp system. Type-based action dispatch. Users can define custom actions in their config.

### In-Buffer Completion (Corfu-style)
Priority: LOW | Impact: LSP prerequisite

Auto-completion popup while typing (similar to VS Code/IntelliJ).

- [ ] Completion-at-point (CAP) framework
- [ ] `(completion-start)` - Start completion manually
- [ ] Auto-trigger after delay (configurable)
- [ ] Completion popup UI component
- [ ] Completion sources:
  - Buffer words (dabbrev-style)
  - File names
  - Buffer names
  - T-Lisp functions
- [ ] Cycle through candidates with Tab/Shift-Tab
- [ ] Preview documentation in popup
- [ ] Keybinding: `C-SPC` or `Tab` (configurable)
- [ ] Tests

**Rationale**: In-buffer completion is essential for LSP integration (Phase 3). Can implement basic version now, extend for LSP later.

**Implementation Note**: T-Lisp completion sources. UI component in TypeScript. Hooks for LSP completion in Phase 3.

### Advanced Navigation
Priority: LOW | Impact: Power user features

- [ ] `imenu` - Jump to function/section definitions
- [ ] `tags` - Navigate using ctags/etags
- [ ] `bookmark` - Persistent file positions
- [ ] `registers` - Save positions, text, window configs
- [ ] `mark-ring` - Jump between saved positions
- [ ] `global-mark` - Marks across files

### Search Enhancement
Priority: LOW | Impact: Multi-file search

- [ ] `ripgrep integration` - Fast text search with ripgrep
- [ ] `grep-find` - Traditional grep/find
- [ ] `project-search` - Search across project files
- [ ] `replace-in-files` - Multi-file search/replace
- [ ] `search-results-buffer` - Navigate search results

### Text Objects Library
Priority: LOW | Impact: More editing power

- [ ] Advanced text objects:
  - `ai`, `ii` - around/inside indentation
  - `a<`, `i<` - around/inside angle brackets
  - `at`, `it` - around/inside HTML tags
  - `af`, `if` - around/inside function
- [ ] Custom text object definitions in T-Lisp
- [ ] Text object composition (combine objects)

### Editing Enhancements
Priority: LOW | Impact: Convenience features

- [ ] `multiple-cursors` - Edit multiple locations simultaneously
- [ ] `sort-lines` - Sort selected lines
- [ ] `delete-duplicate-lines` - Remove duplicates
- [ ] `reverse-region` - Reverse selected lines
- [ ] `indent-rigidly` - Change indentation of region
- [ ] `format-code` - Format buffer/region

### Project Integration
Priority: LOW | Impact: Project-aware editing

- [ ] `project-find` - Find files in project
- [ ] `project-search` - Search in project files
- [ ] `project-switch` - Switch between projects
- [ ] `.project` file` - Project configuration
- [ ] `project-root` detection (git, mercurial, etc.)

### UI/UX Enhancements
Priority: LOW | Impact: Visual polish

- [ ] `mode-line` enhancements - Git branch, LSP status, time
- [ ] `tab-bar` - Visual tab bar for buffers
- [ ] `breadcrumb` - Show current location in header
- [ ] `line-numbers` - Toggleable line number display
- [ ] `color-themes` - Multiple color schemes
- [ ] `cursor-indicators` - Show multiple cursors visually

### Performance Optimizations
Priority: LOW | Impact: Large file handling

- [ ] `lazy-rendering` - Only render visible viewport
- [ ] `incremental-highlighting` - Syntax highlight on scroll
- [ ] `buffer-lazy-loading` - Load large files on demand
- [ ] `operation-coalescing` - Batch edits for performance

### Extensibility Features
Priority: LOW | Impact: Plugin ecosystem

- [ ] `package-manager` - Install/manage T-Lisp packages (Loom — see [RFC-010](../rfcs/RFC-010-loom-package-manager.md))
- [ ] `lazy-loading` - Load packages on demand (`use-package` macro)
- [ ] `package-hooks` - Load/save/activate hooks
- [ ] `package-config` - Per-package configuration
- [ ] `package-documentation` - Generate docs from packages

---

## Phase 1.5: Editor Prerequisites (v0.2.1) — BLOCKING

**Focus**: Close TypeScript-level foundation gaps that prevent all programming modes from growing beyond registration-only scaffolding. These primitives must exist before any mode can provide keymaps, electric features, or meaningful indentation.

**Why this is blocking**: All four programming modes (TypeScript, Python, Go, Lisp) are stuck at "register + syntax highlight + regex indent" because the TypeScript primitives they need don't exist yet. Every new mode hits the same wall. Markdown mode is the only rich mode because it doesn't depend on these primitives.

### 1.15 - Auto-Indent on Enter
Priority: CRITICAL | Impact: Foundational — every programming mode needs this

- [ ] Wire `indent-current-line` into the Enter key handler in insert mode
- [ ] Fix `indent-apply-region` no-op in `indent-ops.ts` (loop body never applies)
- [ ] Tests for auto-indent across all programming modes

### 1.16 - Electric Pair Mode
Priority: HIGH | Impact: Auto-close brackets, quotes, parens

- [ ] `(electric-pair-mode)` minor mode — auto-insert closing delimiter
- [ ] Supported pairs: `()`, `[]`, `{}`, `""`, `''`, `` ` ` ``
- [ ] Skip-over when typing closing delimiter that already exists
- [ ] Backspace deletes paired delimiter
- [ ] Configurable per major mode via `electric-pair-pairs`
- [ ] Tests

### 1.17 - Show Paren Mode
Priority: HIGH | Impact: Visual delimiter matching

- [ ] `(show-paren-mode)` minor mode — highlight matching delimiter
- [ ] Highlight matching open/close when cursor is adjacent to a delimiter
- [ ] Highlight mismatched delimiters differently (error color)
- [ ] Works across lines for multi-line expressions
- [ ] Tests

### 1.18 - Comment Commands
Priority: HIGH | Impact: Every programming mode needs comment toggling

- [ ] `(comment-dwim)` — toggle comment on current line or region
- [ ] `(comment-region start end)` — comment region
- [ ] `(uncomment-region start end)` — uncomment region
- [ ] Comment syntax per major mode (`//`, `#`, `;`, `--`, etc.)
- [ ] Keybinding: `gcc` (toggle line), `gc` (operator + motion), visual mode `gc`
- [ ] Tests

### 1.19 - Indent Engine Improvements
Priority: HIGH | Impact: Regex-only indent is a rough heuristic

- [ ] Continuation-line handling (multi-line function calls, expressions)
- [ ] Context-aware indent depth (not just previous-line regex matching)
- [ ] `indent-apply-region` must actually apply (currently a no-op)
- [ ] Python-specific: offside rule, hanging indent, dedent tracking
- [ ] Lisp-specific: s-expression nesting depth, special-form indentation
- [ ] Tests per language

### 1.20 - Syntax Highlighting Pipeline
Priority: MEDIUM | Impact: Highlights computed but never rendered

- [ ] Wire `syntax-apply-highlights` to the render pipeline (currently returns nil)
- [ ] Highlight spans reach the Steep/Ink renderers
- [ ] Performance: only re-tokenize changed lines
- [ ] Tests for rendered output with highlights

### 1.21 - Improved Buffer Management
Priority: MEDIUM | Impact: Better multi-file workflows

- [ ] Buffer list command (`:ls`)
- [ ] Buffer switching by number (`:b<number>`)
- [ ] Buffer deletion (`:bd`)
- [ ] Modified buffer indicators
- [ ] Auto-save functionality
- [ ] Buffer persistence across sessions

---

## Phase 1.6: Programming Mode Deepening (v0.2.1)

**Focus**: Once TypeScript primitives exist (Phase 1.5), build out programming modes with keymaps, electric features, and language-specific commands.

### 1.22 - Mode-Specific Keymaps
Priority: HIGH | Impact: Every programming mode has zero keybindings

- [ ] TypeScript mode keymap: format, organize imports, go to definition
- [ ] Python mode keymap: run script, send to REPL
- [ ] Lisp mode keymap: eval-defun, eval-buffer, macroexpand
- [ ] Go mode keymap: gofmt, goimports, test
- [ ] All mode keymaps integrate with which-key

### 1.23 - Advanced Text Objects
Priority: MEDIUM | Impact: Power user features

- [ ] Paragraph objects: `cip`, `dip`, `yip`
- [ ] Block objects: `ci"`, `da'`, `ya{`, `ci(`
- [ ] Tag objects for XML/HTML: `cit`, `dat`, `yat`
- [ ] Indent objects: `ai`, `ii` (around/inside indentation)
- [ ] Tests for all text objects

### 1.24 - Visual Selection Enhancements
Priority: MEDIUM | Impact: Improved visual mode

- [ ] Visual text objects: `vi"`, `va'`, `vap`
- [ ] Visual indent operations
- [ ] Visual block append/g-insert

### 1.25 - Additional Major Modes
Priority: MEDIUM | Impact: Broader language support

- [ ] `json-mode` — `.json` files, auto-format, folding
- [ ] `yaml-mode` — `.yaml`/`.yml` files, indentation-sensitive
- [ ] `css-mode` — `.css`/`.scss` files
- [ ] `html-mode` — `.html`/`.htm` files, tag matching
- [ ] `shell-mode` — `.sh`/`.bash`/`.zsh` files
- [ ] `rust-mode` — `.rs` files
- [ ] `c-mode` — `.c`/`.h` files

### 1.26 - Special Buffer Modes
Priority: MEDIUM | Impact: Proper display for editor UI buffers

- [ ] `help-mode` — read-only help buffers with forward/back navigation
- [ ] `completion-list-mode` — completion candidate display
- [ ] `special-mode` — read-only base mode for `*Messages*`, `*scratch*`, etc.
- [ ] `dired-mode` — directory editor (commands exist, mode does not)

### 1.27 - Additional Minor Modes
Priority: LOW | Impact: Editor quality-of-life

- [ ] `hl-line-mode` — highlight current line
- [ ] `whitespace-mode` — visualize tabs, trailing spaces, hard newlines
- [ ] `visual-line-mode` — soft word wrap with word boundaries
- [ ] `subword-mode` — treat CamelCase segments as words
- [ ] `rainbow-delimiters-mode` — color-coded nesting depth
- [ ] `outline-mode` — fold sections by heading level

---

## Phase 2: Extensibility & Customization (v0.3.0)

**Focus**: Enhance T-Lisp capabilities and plugin ecosystem.

### 2.1 - Plugin System
Priority: HIGH | Impact: Unlimited extensibility
Status: Foundation complete (`src/editor/api/plugin-ops.ts`)

- [x] Plugin directory structure (`~/.config/tmax/tlpa/`)
- [x] Plugin loading from `plugin.tlisp`
- [ ] Plugin dependency management
- [ ] Plugin isolation and sandboxing
- [x] Plugin lifecycle hooks (load/unload)
- [ ] Plugin enable/disable hooks
- [ ] Plugin API documentation

### 2.2 - Advanced T-Lisp Features
Priority: MEDIUM | Impact: More powerful customization
Status: Module system exists

- [x] Module system for T-Lisp (`defmodule`, `require-module`, `export`)
- [ ] Namespace support
- [x] Advanced string manipulation functions
- [x] Regular expression integration
- [x] File system operations
- [ ] Process spawning capabilities
- [ ] HTTP request support (for plugin ecosystem)

### 2.3 - Key Binding System Completion
Priority: HIGH | Impact: Core extensibility feature
Status: Core system complete, refinements remain

- [x] Phase 0.4 refactor — keymaps in T-Lisp
- [ ] Key binding validation and conflict detection
- [ ] Key binding documentation and examples
- [ ] Mode-specific key binding override system
- [ ] Centralized key resolution for minor/major mode precedence

### 2.4 - Macro Recording & Playback
Priority: MEDIUM | Impact: Productivity enhancement
Status: COMPLETE

- [x] `q{register}` - Start recording macro
- [x] `q` - Stop recording macro
- [x] `@{register}` - Play back macro
- [x] `@@` - Repeat last macro
- [x] Macro editing capabilities
- [x] Macro persistence across sessions

### 2.5 - Configuration System
Priority: MEDIUM | Impact: Better user experience

- [ ] Configuration file validation
- [ ] Configuration error reporting with line numbers
- [ ] Configuration profiles (work, personal, etc.)
- [ ] Configuration file hot-reloading
- [ ] Example configurations for popular workflows

### 2.6 - Performance Optimizations
Priority: LOW | Impact: Better responsiveness

- [ ] Lazy rendering for large files
- [ ] Incremental syntax highlighting
- [ ] Optimized buffer operations
- [ ] Memory usage profiling and optimization

---

## Phase 3: Advanced Features (v0.4.0)

**Focus**: Professional-grade features for power users.

### 3.1 - LSP Integration
Priority: HIGH | Impact: Modern development experience

- [ ] LSP client architecture
- [ ] Language server initialization and management
- [ ] Diagnostics display (errors, warnings, hints)
- [ ] Code completion (autocomplete)
- [ ] Go to definition
- [ ] Find references
- [ ] Symbol search
- [ ] Code actions (quick fixes)
- [ ] Signature help
- [ ] Document symbols outline

### 3.2 - Multiple Windows/Panes
Priority: HIGH | Impact: Advanced multi-file editing

- [ ] Window splitting (horizontal, vertical)
- [ ] Window navigation and management
- [ ] Window resizing
- [ ] Multiple buffers per window
- [ ] Window layout persistence
- [ ] Tmux-like pane management

### 3.3 - File Tree Explorer
Priority: MEDIUM | Impact: Project navigation

- [ ] File tree sidebar
- [ ] File and directory operations
- [ ] File filtering and search
- [ ] Git integration indicators
- [ ] Toggleable file tree panel
- [ ] Project root detection

### 3.4 - Undo/Redo System
Priority: MEDIUM | Impact: Essential safety feature

- [ ] Undo tree implementation
- [ ] Persistent undo history
- [ ] Branching undo/redo
- [ ] Undo timeline visualization
- [ ] Undo persistence across sessions
- [ ] Configuration for undo limits

### 3.5 - Terminal Integration
Priority: LOW | Impact: Convenient workflow

- [ ] Built-in terminal panel
- [ ] Terminal pane management
- [ ] Terminal command execution from editor
- [ ] Quick terminal toggle

---

## Phase 4: Community & Ecosystem (v0.5.0)

**Focus**: Build sustainable community and plugin ecosystem.

### 4.1 - Community Infrastructure
Priority: MEDIUM | Impact: Growth and adoption

- [ ] Plugin repository and registry
- [ ] Plugin submission and review process
- [ ] Community contribution guidelines
- [ ] Plugin showcase and examples

### 4.1a - Loom — T-Lisp Package Manager

**Name:** Loom (weaving packages together)
**CLI:** `loom` — `loom install`, `loom publish`, `loom search`, `loom update`
**Registry:** `loom.tmux.mekaelturner.com` (v2)

**Goal:** An Emacs/MELPA-style package manager where browsing, installing, and updating packages happens inside the editor via T-Lisp commands. CLI is a secondary interface.

**Architecture principle:** The package manager is a T-Lisp package itself. Since T-Lisp owns commands, modes, and buffers, the entire UX (package browser, install/update/remove, search) is written in T-Lisp. TypeScript only provides the filesystem and network primitives. This follows the same split as the rest of tmax — T-Lisp owns behavior, TypeScript owns transport.

**Primary interface — in-editor (like `M-x list-packages`):**
- `M-x list-packages` — opens a `*Packages*` buffer showing available and installed packages (name, version, description, status)
- `M-x package-install RET name` — fetches and installs a package
- `M-x package-refresh-contents` — updates the package index from the registry
- `M-x package-delete RET name` — removes an installed package
- Packages auto-load on startup via `(require-module "author/package")` in `init.tlisp`
- `use-package`-style macro for declarative package configuration with lazy loading

**Secondary interface — CLI:**
- `loom install github.com/user/tmax-plugin-name` — clones to `~/.config/tmax/packages/`
- `loom list` / `loom update` / `loom remove` — package management from terminal
- Convenience wrappers around the same T-Lisp functions the editor uses

**v1 — Git-based packages (zero infrastructure):**
- Packages are git repos containing a `plugin.tlisp` with `(defmodule ...)` and `(export ...)`
- `loom install` clones to `~/.config/tmax/packages/`
- `require-module` resolves from local package cache via existing `TLISP_PATH`
- The module system (`defmodule`/`require-module`/`(export ...)`) already exists
- Package index is a curated JSON file in the tmax repo (like MELPA's recipe format)

**v2 — Hosted registry (post-adoption):**
- `loom publish` pushes to a registry at `loom.tmux.mekaelturner.com` (or GitHub-based)
- Registry indexes packages by exported symbols, docstrings, and metadata
- `loom search query` / `M-x package-search` searches across all published packages
- Website `/packages/[name]` auto-generates API docs from exports and docstrings
- Community submissions via pull request to a package recipe repo (like MELPA)

**Why defer v2:** Hosted infrastructure has ongoing cost. Git-based packages work immediately with the existing module system and need zero backend. A registry only adds value once there's enough adoption to justify the infrastructure.

**See [RFC-010: Loom Package Manager](../rfcs/RFC-010-loom-package-manager.md) for complete specification.**

### 4.2 - Documentation Portal
Priority: HIGH | Impact: Accessibility and onboarding

- [ ] Dedicated documentation website
- [ ] API reference for T-Lisp functions
- [ ] Plugin development tutorials
- [ ] Video tutorials and walkthroughs
- [ ] Interactive examples
- [ ] Community-contributed guides

### 4.3 - Testing & Quality Assurance
Priority: MEDIUM | Impact: Stability and reliability

- [ ] Increase test coverage to 90%+
- [ ] Automated UI testing across platforms
- [ ] Performance benchmarking suite
- [ ] Continuous integration improvements
- [ ] Automated release testing

### 4.4 - Distribution & Packaging
Priority: LOW | Impact: Accessibility

- [ ] Homebrew formula
- [ ] Arch Linux AUR package
- [ ] Debian/Ubuntu packages
- [ ] RPM packages for Fedora
- [ ] Windows installer
- [ ] Installation scripts

---

## Future Considerations

### Potential Features (Beyond v0.5.0)
- Collaborative editing (multi-user)
- Remote file editing (SSH, SFTP)
- Cloud synchronization
- AI integration (code completion, refactoring)
- Advanced vim script compatibility layer
- Emacs keybinding emulation mode
- GUI version (optional)
- Mobile version (experimental)

### Technical Debt & Maintenance
- Ongoing dependency updates
- Security audits and fixes
- Code quality improvements
- Documentation maintenance
- Community issue triage and support

---

## Development Philosophy

tmax follows the principle of **"powerful core, extensible surface"**:

1. **TypeScript Core**: Provides efficient, low-level operations (terminal I/O, file system, buffer management)
2. **T-Lisp Engine**: Handles all high-level functionality and customization
3. **Community-First**: Plugins and configurations shared as T-Lisp scripts
4. **Stability-First**: Comprehensive testing before feature releases
5. **Documentation-Driven**: Clear docs alongside code development

### Feature Selection Criteria

Features are prioritized based on:
- **User Impact**: How much does this improve daily editing workflows?
- **Extensibility**: Does this enable new possibilities through T-Lisp?
- **Maintainability**: Can we support this long-term without excessive complexity?
- **Test Coverage**: Can we adequately test this feature?
- **Community Demand**: Is there significant user interest or requests?

---

## Contributing

We welcome contributions! See the main README.md for contribution guidelines.

### How to Get Involved

1. **Pick a task**: Choose an item from this roadmap
2. **Open an issue**: Discuss the implementation approach
3. **Write tests**: Follow TDD workflow
4. **Submit PR**: Include tests and documentation
5. **Join discussion**: Engage with the community

### Areas Seeking Contributors

- T-Lisp standard library extensions
- Language syntax definitions
- Plugin development
- Documentation improvements
- Test coverage expansion
- Performance optimization
- Platform-specific packaging

---

## Release Schedule

**Note**: Dates are approximate and subject to change based on development progress.

- **v0.1.0** ✅ - Released (Current) - Core editor with T-Lisp engine
- **v0.2.0** - Q1 2025 (Core Editing) - Basic Evil-mode parity: operators, navigation, search, jumps
  - **v0.2.0-alpha** - Core operators and navigation (1.1, 1.2, 1.3)
  - **v0.2.0-beta** - Change operator, search, jumps (1.4, 1.5, 1.6)
  - **v0.2.0** - Visual mode and basic text objects (1.7, 1.8)
- **v0.2.1** - Q1 2025 (Enhanced Editing) - Advanced text objects, visual features
- **v0.3.0** - Q2 2025 (Extensibility) - Plugin system, advanced T-Lisp, macros
- **v0.4.0** - Q3 2025 (Advanced Features) - LSP integration, multiple windows
- **v0.5.0** - Q4 2025 (Community & Ecosystem) - Documentation, packaging, community

### Versioning Policy

tmax follows semantic versioning (SemVer):
- **Major version**: Incompatible API changes
- **Minor version**: New features, backward compatible
- **Patch version**: Bug fixes, backward compatible

Until v1.0.0, minor versions may include breaking changes as we refine the API.

---

## Development Infrastructure (2026)

### adw Pipeline ✅ COMPLETE

The adw (Agent-Driven Workflow) pipeline automates the full development cycle: **plan → spec-review → build → patch-review**, with a build↔patch retry loop. See [ADR-0094](adrs/ADR-0094-adw-pipeline-architecture.md).

- ✅ Individual dispatchers: `adw-plan.ts`, `adw-spec-review.ts`, `adw-build.ts`, `adw-patch-review.ts`
- ✅ 3-stage orchestrator (`adw-plan-reviewspec-build.ts`) with resume + spec-anchored discovery
- ✅ 4-stage pipeline (`adw-plan-review-build-patch.ts`) with build↔patch retry loop (max 3)
- ✅ tmux launcher (`adw-launch.ts`) — runs pipelines in detached windows
- ✅ e2e test runner (`adw-run-e2e.ts`) with YAML playbooks

### TRT (tmax Runtime Testing) ✅ COMPLETE

T-Lisp-native test framework replacing the old TS test framework. See [ADR-0097](adrs/ADR-0097-trt-tlisp-native-test-framework.md).

- ✅ 12 T-Lisp modules: assertions, async, bench, coverage, doctest, fixtures, mock, parametrize, snapshots, suites, cli, trt
- ✅ Minimal TS bootstrap (`src/tlisp/trt/bootstrap.ts`)
- ✅ Run via `bin/trt` or `bun run test:trt`

### Unified Observability ✅ COMPLETE

`*daemon*` event buffer + log-store for daemon lifecycle events. See [ADR-0096](adrs/ADR-0096-unified-observability-daemon-buffer.md).

- ✅ `src/editor/log-store.ts` — ring buffer with persistence
- ✅ `*daemon*` virtual buffer + `*Messages*` readonly
- ✅ T-Lisp query commands (`src/tlisp/core/commands/observability.tlisp`)

### Browse-URL ✅ COMPLETE

URL detection + browser dispatch (`gX`). See [ADR-0095](adrs/ADR-0095-browse-url-detection-dispatch.md).

- ✅ Bare/markdown/angle-bracket/GitHub-issue URL detection
- ✅ Scheme allowlist + `$BROWSER` parsing + injection-safe `Bun.spawn`

### FP Foundations ✅ COMPLETE

T-Lisp functional programming primitives. See [ADR-0098](adrs/ADR-0098-tlisp-fp-foundations.md).

- ✅ `src/utils/adt.ts` (discriminated unions), `writer.ts` (WriterT monad)
- ✅ `src/tlisp/core/monads.tlisp` (maybe, either, pipe)
- ✅ Evaluator/stdlib refactored around cleaner dispatch

---

## References

- **Main README**: `/README.md`
- **TODO List**: `/TODO.org`
- **Functional Patterns**: `/functional-patterns-guidelines.md`
- **Specs**: `/specs/` directory
- **Test Documentation**: `/test/README.md`

---

**Last Updated**: 2026-06-10

For the latest updates and discussions, visit the project repository.
