diff --git a/.claude/docs/cli.md b/.claude/docs/cli.md index 62911b8..32e7416 100644 --- a/.claude/docs/cli.md +++ b/.claude/docs/cli.md @@ -19,9 +19,9 @@ | `--initial-index` | int | Initial cursor position | | `--initial-filter` | string | Initial filter name | | `--prompt` | string | Prompt string | -| `--layout` | string | Layout type: top-down, bottom-up | +| `--layout` | string | Layout type: top-down, bottom-up, top-down-query-bottom | | `--select-1` | bool | Auto-select if single match | -| `--exit-zero` | bool | Exit 0 even on cancel | +| `--exit-zero` | bool | Exit immediately with status 1 if input is empty | | `--select-all` | bool | Select all lines initially | | `--on-cancel` | string | Cancel behavior: success/error | | `--selection-prefix` | string | Prefix for selected lines | @@ -33,7 +33,7 @@ ## Exit Codes - 0 — success (lines selected) -- 0 — cancel with `--on-cancel success` or `--exit-zero` +- 0 — cancel with `--on-cancel success` - 1 — cancel (default) - Custom — from `--exec` command exit status diff --git a/.claude/docs/dependencies.md b/.claude/docs/dependencies.md index 9ee49ac..1cc62cc 100644 --- a/.claude/docs/dependencies.md +++ b/.claude/docs/dependencies.md @@ -4,7 +4,7 @@ ``` cmd/peco → peco (root), internal/util -cmd/filterbench → filter +cmd/filterbench → peco (root), filter, line, pipeline peco (root) → config, filter, hub, line, pipeline, query, selection, sig → internal/ansi, internal/keyseq, internal/util, internal/buffer diff --git a/.claude/docs/internals.md b/.claude/docs/internals.md index 22c7def..a19f0ca 100644 --- a/.claude/docs/internals.md +++ b/.claude/docs/internals.md @@ -56,7 +56,7 @@ Hub supports **batch mode** — multiple sends within `Batch()` callback are pro - `Screen` interface wraps terminal operations - `TcellScreen` — production impl using tcell/v2 - `InlineScreen` — wraps TcellScreen for height-limited display -- `DummyScreen` — test mock with event injection +- `SimScreen` — test mock with event injection ## Layout System diff --git a/.claude/docs/packages.md b/.claude/docs/packages.md index 709cce2..42bacca 100644 --- a/.claude/docs/packages.md +++ b/.claude/docs/packages.md @@ -16,10 +16,10 @@ Interactive filtering tool core. Holds global state, goroutine loops, UI compone - **(*Peco).ExecQuery(ctx, func()) → bool** — execute filter with debounce - Key types: `Peco`, `Buffer`, `FilteredBuffer`, `MemoryBuffer`, `Source`, `Screen`, `Layout`, `Action`, `Keymap`, `Event`, `CLIOptions`, `Location`, `PageCrop` - Key interfaces: `MessageHub`, `Screen`, `Layout`, `Action`, `ActionMap`, `Buffer`, `Keyseq`, `ConfigReader` -- Screen impls: `TcellScreen` (production), `InlineScreen` (height-limited), `DummyScreen` (tests) +- Screen impls: `TcellScreen` (production), `InlineScreen` (height-limited), `SimScreen` (tests) - Layout impls: `BasicLayout` with builders: `DefaultLayout`, `BottomUpLayout`, `TopDownQueryBottomLayout` -- Files: `peco.go`, `action.go`, `buffer.go`, `caret.go`, `event.go`, `filter.go`, `input.go`, `keymap.go`, `layout.go`, `layout_any.go`, `layout_windows.go`, `options.go`, `page.go`, `screen.go`, `screen_inline.go`, `source.go`, `state.go`, `view.go`, `vertical_anchor_gen.go` -- Imports: config, filter, hub, line, pipeline, query, selection, sig, internal/ansi, internal/keyseq, internal/util +- Files: `peco.go`, `action.go`, `buffer.go`, `event.go`, `filter.go`, `input.go`, `keymap.go`, `layout.go`, `layout_any.go`, `layout_windows.go`, `options.go`, `page.go`, `screen.go`, `screen_inline.go`, `source.go`, `state.go`, `view.go`, `vertical_anchor_gen.go` +- Imports: config, filter, hub, line, pipeline, query, selection, sig, internal/ansi, internal/buffer, internal/keyseq, internal/util ## cmd/peco @@ -34,7 +34,7 @@ CLI entry point. Benchmark tool for filter performance. - Files: `main.go` -- Imports: filter +- Imports: peco (root), filter, line, pipeline ## config/ diff --git a/CLAUDE.md b/CLAUDE.md index 414c59c..d671205 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -19,9 +19,9 @@ Read the linked doc BEFORE working in that area. No exceptions. ## Build & Test Commands ```bash -make # Download deps and build (default target) -make build # Build binary to releases/peco__/peco -make test # Run all tests: go test -v ./... +make # Build binary via goreleaser (default target) +make build # Build binary to dist/peco__/peco +make test # Run all tests: go test -v -race ./... make deps # Download Go module dependencies make clean # Remove build artifacts ``` @@ -40,7 +40,7 @@ The entry point is `cmd/peco/peco.go`. peco runs three main goroutines coordinated via context cancellation: -- **Input loop** (`input.go`) — reads termbox key events, resolves key sequences via Keymap, dispatches actions +- **Input loop** (`input.go`) — reads tcell key events, resolves key sequences via Keymap, dispatches actions - **View loop** (`view.go`) — renders screen in response to draw/paging/status messages - **Filter loop** (`filter.go`) — executes queries against the line buffer when query text changes @@ -54,14 +54,14 @@ These goroutines communicate through the **Hub** (`hub/`), a central message bus 4. **Filter** applies the active filter algorithm to produce matched lines 5. Results flow through the **Pipeline** (`pipeline/`) as `Source → Acceptor → Destination` 6. **View** receives draw messages and delegates to **Layout** (`layout.go`) which composes `UserPrompt`, `ListArea`, and `StatusBar` -7. **Screen** (`screen.go`) wraps termbox-go for terminal cell rendering +7. **Screen** (`screen.go`) wraps tcell/v2 for terminal cell rendering ### Key Interfaces - **`Buffer`** — line storage (`LineAt`, `Size`); implemented by `MemoryBuffer`, `FilteredBuffer`, `Source` - **`Filter`** (in `filter/`) — `Apply(ctx, []line.Line, ChanOutput)` for each filter algorithm (IgnoreCase, CaseSensitive, SmartCase, Regexp, IRegexp, Fuzzy, ExternalCmd) - **`Line`** (`line/`) — represents a single line with `ID`, `Buffer`, `DisplayString`, `Output` -- **`Screen`** — terminal abstraction (`Init`, `SetCell`, `Flush`, `PollEvent`); `DummyScreen` used in tests +- **`Screen`** — terminal abstraction (`Init`, `SetCell`, `Flush`, `PollEvent`); `SimScreen` used in tests - **`Layout`** — screen composition (`DrawScreen`, `DrawPrompt`, `MovePage`) - **`Action`** — user actions bound to keys (`action.go`); ~40 built-in actions, supports combined action sequences @@ -83,8 +83,8 @@ Uses `go:generate` with `stringer` for enum string representations. ## Testing Patterns -- `newPeco()` helper creates a test instance with `DummyScreen` (mock terminal) -- `NewDummyScreen()` supports event injection for simulating user input +- `newPeco()` helper creates a test instance with `SimScreen` (mock terminal) +- `NewDummyScreen()` returns a `SimScreen` that supports event injection for simulating user input - Table-driven tests with `t.Run()` subtests are the common pattern - Regression tests for specific GitHub issues in `issues_test.go`