@peaske7/readit 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/.claude/CLAUDE.md +118 -76
  2. package/.claude/commands/review.md +1 -1
  3. package/.claude/roadmap.md +32 -9
  4. package/.claude/user-stories.md +100 -15
  5. package/AGENTS.md +30 -26
  6. package/Makefile +32 -0
  7. package/README.md +90 -2
  8. package/biome.json +18 -8
  9. package/bun.lock +426 -568
  10. package/bunfig.toml +2 -0
  11. package/docs/perf-baseline.md +56 -1
  12. package/docs/superpowers/specs/2026-03-27-go-server-rewrite-design.md +284 -0
  13. package/e2e/comments.spec.ts +14 -58
  14. package/e2e/document-load.spec.ts +1 -23
  15. package/e2e/export.spec.ts +4 -4
  16. package/e2e/perf/add-comment.spec.ts +9 -11
  17. package/e2e/perf/fixtures/generate.ts +1 -5
  18. package/e2e/perf/screenshot-final.png +0 -0
  19. package/e2e/perf/utils/metrics.ts +73 -9
  20. package/e2e/persistence-file.spec.ts +41 -26
  21. package/e2e/utils/selection.ts +17 -73
  22. package/go/cmd/readit/main.go +416 -0
  23. package/go/go.mod +20 -0
  24. package/go/go.sum +41 -0
  25. package/go/internal/server/anchor.go +302 -0
  26. package/go/internal/server/anchor_test.go +111 -0
  27. package/go/internal/server/comments.go +390 -0
  28. package/go/internal/server/documents.go +113 -0
  29. package/go/internal/server/embed.go +17 -0
  30. package/go/internal/server/headings.go +33 -0
  31. package/go/internal/server/headings_test.go +75 -0
  32. package/go/internal/server/htmltext.go +123 -0
  33. package/go/internal/server/markdown.go +157 -0
  34. package/go/internal/server/markdown_bench_test.go +42 -0
  35. package/go/internal/server/markdown_test.go +79 -0
  36. package/go/internal/server/server.go +453 -0
  37. package/go/internal/server/server_bench_test.go +122 -0
  38. package/go/internal/server/settings.go +110 -0
  39. package/go/internal/server/sse.go +140 -0
  40. package/go/internal/server/storage.go +275 -0
  41. package/go/internal/server/storage_test.go +118 -0
  42. package/go/internal/server/template.go +66 -0
  43. package/go/internal/server/types.go +101 -0
  44. package/go/internal/server/watcher.go +74 -0
  45. package/index.html +4 -14
  46. package/nvim-readit/lua/readit/health.lua +64 -0
  47. package/nvim-readit/lua/readit/init.lua +463 -0
  48. package/nvim-readit/plugin/readit.lua +19 -0
  49. package/package.json +20 -28
  50. package/shell/_readit +158 -0
  51. package/shell/readit.zsh +87 -0
  52. package/src/App.svelte +881 -0
  53. package/src/cli.ts +183 -21
  54. package/src/components/ActionsMenu.svelte +95 -0
  55. package/src/components/CommentBadge.svelte +67 -0
  56. package/src/components/CommentErrorBanner.svelte +33 -0
  57. package/src/components/CommentInput.svelte +75 -0
  58. package/src/components/CommentListItem.svelte +95 -0
  59. package/src/components/CommentManager.svelte +129 -0
  60. package/src/components/CommentNav.svelte +109 -0
  61. package/src/components/DocumentViewer.svelte +218 -0
  62. package/src/components/FloatingComment.svelte +107 -0
  63. package/src/components/Header.svelte +76 -0
  64. package/src/components/InlineEditor.svelte +72 -0
  65. package/src/components/MarginNote.svelte +167 -0
  66. package/src/components/MarginNotesContainer.svelte +33 -0
  67. package/src/components/RawModal.svelte +126 -0
  68. package/src/components/ReanchorConfirm.svelte +30 -0
  69. package/src/components/SettingsModal.svelte +220 -0
  70. package/src/components/ShortcutCapture.svelte +82 -0
  71. package/src/components/ShortcutList.svelte +145 -0
  72. package/src/components/TabBar.svelte +52 -0
  73. package/src/components/TableOfContents.svelte +125 -0
  74. package/src/components/ui/ActionLink.svelte +40 -0
  75. package/src/components/ui/{Button.tsx → Button.svelte} +19 -20
  76. package/src/components/ui/Dialog.svelte +97 -0
  77. package/src/components/ui/DropdownMenu.svelte +85 -0
  78. package/src/components/ui/DropdownMenuItem.svelte +38 -0
  79. package/src/components/ui/DropdownMenuSeparator.svelte +11 -0
  80. package/src/components/ui/{Text.tsx → Text.svelte} +18 -23
  81. package/src/env.d.ts +6 -0
  82. package/src/index.css +36 -166
  83. package/src/lib/__fixtures__/bench-data.ts +0 -13
  84. package/src/lib/anchor.bench.ts +1 -12
  85. package/src/lib/anchor.test.ts +0 -8
  86. package/src/lib/anchor.ts +0 -4
  87. package/src/lib/comment-storage.bench.ts +49 -0
  88. package/src/lib/comment-storage.test.ts +41 -33
  89. package/src/lib/comment-storage.ts +21 -18
  90. package/src/lib/export.bench.ts +21 -0
  91. package/src/lib/export.ts +0 -1
  92. package/src/{hooks/useHeadings.test.ts → lib/headings.test.ts} +10 -24
  93. package/src/{hooks/useHeadings.ts → lib/headings.ts} +11 -13
  94. package/src/lib/highlight/core.test.ts +0 -5
  95. package/src/lib/highlight/dom.ts +52 -216
  96. package/src/lib/highlight/highlight-registry.ts +221 -0
  97. package/src/lib/highlight/highlight.bench.ts +92 -0
  98. package/src/lib/highlight/highlighter.ts +112 -132
  99. package/src/lib/highlight/resolver.ts +5 -79
  100. package/src/lib/highlight/types.ts +0 -5
  101. package/src/lib/html-text.test.ts +162 -0
  102. package/src/lib/html-text.ts +161 -0
  103. package/src/lib/i18n/en.ts +26 -0
  104. package/src/lib/i18n/ja.ts +26 -0
  105. package/src/lib/i18n/types.ts +25 -0
  106. package/src/lib/margin-layout.bench.ts +61 -0
  107. package/src/lib/margin-layout.ts +0 -7
  108. package/src/lib/markdown-renderer.test.ts +154 -0
  109. package/src/lib/markdown-renderer.ts +177 -0
  110. package/src/lib/mermaid-config.ts +38 -0
  111. package/src/lib/mermaid-renderer.ts +162 -0
  112. package/src/lib/mermaid-worker.ts +60 -0
  113. package/src/lib/positions.ts +31 -24
  114. package/src/lib/shortcut-registry.ts +244 -0
  115. package/src/lib/utils.ts +0 -29
  116. package/src/main.ts +16 -0
  117. package/src/schema.ts +16 -5
  118. package/src/server.ts +355 -91
  119. package/src/stores/app.svelte.ts +231 -0
  120. package/src/stores/locale.svelte.ts +46 -0
  121. package/src/stores/settings.svelte.ts +90 -0
  122. package/src/stores/shortcuts.svelte.ts +104 -0
  123. package/src/stores/ui.svelte.ts +12 -0
  124. package/src/template.ts +104 -0
  125. package/src/test-setup.ts +47 -0
  126. package/svelte.config.js +5 -0
  127. package/tsconfig.json +2 -2
  128. package/vite.config.ts +23 -3
  129. package/vscode-readit/.mcp.json +7 -0
  130. package/vscode-readit/.vscodeignore +7 -0
  131. package/vscode-readit/bun.lock +78 -0
  132. package/vscode-readit/icon.svg +10 -0
  133. package/vscode-readit/package.json +110 -0
  134. package/vscode-readit/src/extension.ts +117 -0
  135. package/vscode-readit/src/server-manager.ts +272 -0
  136. package/vscode-readit/src/webview-provider.ts +204 -0
  137. package/vscode-readit/tsconfig.json +20 -0
  138. package/e2e/fixtures/sample.html +0 -13
  139. package/src/App.tsx +0 -368
  140. package/src/components/ActionsMenu.tsx +0 -91
  141. package/src/components/DocumentViewer/CodeBlock.tsx +0 -160
  142. package/src/components/DocumentViewer/DocumentViewer.tsx +0 -230
  143. package/src/components/DocumentViewer/MermaidDiagram.tsx +0 -136
  144. package/src/components/Header.tsx +0 -54
  145. package/src/components/InlineEditor.tsx +0 -74
  146. package/src/components/MarginNote.tsx +0 -185
  147. package/src/components/MarginNotes.tsx +0 -23
  148. package/src/components/RawModal.tsx +0 -144
  149. package/src/components/ReanchorConfirm.tsx +0 -36
  150. package/src/components/SettingsModal.tsx +0 -232
  151. package/src/components/TabBar.tsx +0 -60
  152. package/src/components/TableOfContents.tsx +0 -108
  153. package/src/components/comments/CommentBadge.tsx +0 -49
  154. package/src/components/comments/CommentInput.tsx +0 -86
  155. package/src/components/comments/CommentListItem.tsx +0 -90
  156. package/src/components/comments/CommentManager.tsx +0 -129
  157. package/src/components/comments/CommentNav.tsx +0 -109
  158. package/src/components/ui/ActionLink.tsx +0 -28
  159. package/src/components/ui/Dialog.tsx +0 -116
  160. package/src/components/ui/DropdownMenu.tsx +0 -158
  161. package/src/contexts/CommentContext.tsx +0 -198
  162. package/src/contexts/LocaleContext.tsx +0 -76
  163. package/src/contexts/PositionsContext.tsx +0 -16
  164. package/src/contexts/SettingsContext.tsx +0 -133
  165. package/src/hooks/useClickOutside.ts +0 -31
  166. package/src/hooks/useCommentNavigation.ts +0 -107
  167. package/src/hooks/useComments.ts +0 -311
  168. package/src/hooks/useDocument.ts +0 -157
  169. package/src/hooks/useScrollSpy.ts +0 -77
  170. package/src/hooks/useTextSelection.ts +0 -86
  171. package/src/lib/highlight/worker.ts +0 -45
  172. package/src/main.tsx +0 -13
  173. package/src/store.ts +0 -222
package/.claude/CLAUDE.md CHANGED
@@ -11,14 +11,24 @@ Inspired by [difit](https://github.com/yoshiko-pg/difit) - a local code review t
11
11
  ```bash
12
12
  # Development
13
13
  bun install # Install dependencies
14
- bun dev # Start dev server (Vite + CLI)
15
- bun run build # Build for production
16
- bun run test # Run tests
14
+ bun dev # Start dev server (CLI with --watch)
15
+ bun run dev:client # Start Vite dev server only
16
+ bun run build # Build for production (Vite + CLI)
17
+ bun run test # Run unit tests (Vitest)
18
+ bun run test:e2e # Run e2e tests (Playwright)
19
+ bun run test:perf # Run performance tests
20
+ bun run bench # Run benchmarks
17
21
  bun run typecheck # Run TypeScript checks
18
22
  bun run check # Run Biome (lint + format check)
19
23
  bun run check:fix # Fix lint + format issues
20
24
  bun run format # Format with Biome
21
25
 
26
+ # Go server (production binary)
27
+ make dev # Go server + Vite HMR
28
+ make build # Build single binary (dist/readit)
29
+ make test # Run Go tests
30
+ make clean # Clean build artifacts
31
+
22
32
  # Usage
23
33
  bunx readit <file.md> # Review Markdown file
24
34
  bunx readit <file.html> # Review HTML file
@@ -29,6 +39,8 @@ bunx readit <file.md> --clean # Clear existing comments
29
39
 
30
40
  bunx readit list # List all files with comments
31
41
  bunx readit show <file.md> # Show comments for a file
42
+ bunx readit open <files...> # Add files to running server
43
+ bunx readit completion zsh # Output shell integration script
32
44
  ```
33
45
 
34
46
  ## Architecture
@@ -36,97 +48,126 @@ bunx readit show <file.md> # Show comments for a file
36
48
  ```
37
49
  readit/
38
50
  ├── src/
39
- │ ├── cli/
40
- │ └── index.ts # CLI entry point (Commander.js)
41
- │ ├── server/
42
- │ └── index.ts # Bun.serve() server + API routes
51
+ │ ├── cli.ts # CLI entry point (Commander.js)
52
+ ├── server.ts # Bun.serve() server + API routes
53
+ │ ├── App.svelte # Main Svelte component
54
+ ├── main.ts # Svelte entry point
55
+ │ ├── schema.ts # TypeScript types
56
+ │ ├── template.ts # HTML template rendering
57
+ │ ├── index.css # Tailwind styles + CSS custom properties
43
58
  │ ├── components/
44
- │ │ ├── Header.tsx
45
- │ │ ├── DocumentViewer.tsx # Renders MD (react-markdown) or HTML (IframeContainer)
46
- │ │ ├── IframeContainer.tsx # Isolated HTML rendering with comment support
47
- │ │ ├── CodeBlock.tsx # Syntax-highlighted code blocks
48
- │ │ ├── CommentInputArea.tsx
49
- │ │ ├── CommentListItem.tsx # Comment item in manager dropdown
50
- │ │ ├── CommentManagerDropdown.tsx # Dropdown menu for managing comments
51
- │ │ ├── CommentMinimap.tsx # Visual minimap of comment positions
52
- │ │ ├── CommentNavigator.tsx # Navigate between comments
53
- │ │ ├── FloatingTOC.tsx # Floating TOC button (fullscreen mode)
54
- │ │ ├── MarginNote.tsx # Individual margin note
55
- │ │ ├── MarginNotesContainer.tsx
56
- │ │ ├── MermaidDiagram.tsx # Mermaid diagram rendering
57
- │ │ ├── RawCommentsModal.tsx # View raw .comments.md file
58
- │ │ ├── SettingsModal.tsx # Settings modal (font preferences)
59
- │ │ ├── TableOfContents.tsx # Document headings navigation
60
- │ │ └── index.ts
61
- │ ├── hooks/
62
- │ │ ├── useComments.ts # Comment state management
63
- │ │ ├── useCommentNavigation.ts # Navigate between comments
64
- │ │ ├── useDocument.ts # Document fetching and state
65
- │ │ ├── useFontPreference.ts # Font preference with server persistence
66
- │ │ ├── useHeadings.ts # Extract headings from document
67
- │ │ ├── useLayoutMode.ts # Layout mode toggle (centered/fullscreen)
68
- │ │ ├── useReanchorMode.ts # Re-anchor mode for unresolved comments
69
- │ │ ├── useScrollMetrics.ts # Scroll position tracking
70
- ├── useScrollSpy.ts # Track scroll position for TOC
71
- │ │ ├── useTextSelection.ts # Text selection handling
72
- │ │ └── index.ts
73
- │ ├── lib/
74
- │ │ ├── anchor.ts # Anchor-based comment resolution
75
- │ │ ├── comment-storage.ts # File-based comment storage
76
- │ ├── context.ts # LLM context extraction
77
- ├── export.ts # Export utilities (JSON, prompt format)
78
- ├── layout-constants.ts # Layout dimensions and breakpoints
79
- ├── margin-layout.ts # Margin note position resolution
80
- ├── scroll.ts # Scroll calculation utilities
81
- ├── utils.ts # Common utilities (cn, etc.)
82
- │ └── highlight/ # Text highlighting system
83
- ├── index.ts
84
- ├── highlighter.ts # Unified highlighter factory
85
- ├── core.ts # Core highlight logic
86
- ├── dom.ts # DOM manipulation
87
- ├── colors.ts # Comment color palette
88
- ├── types.ts # Type definitions
89
- └── script-builder.ts
90
- ├── types/
91
- └── index.ts # Shared types
92
- │ ├── App.tsx # Main React component
93
- │ ├── main.tsx # React entry point
94
- └── index.css # Tailwind styles
59
+ │ │ ├── Header.svelte
60
+ │ │ ├── DocumentViewer.svelte # Renders document HTML
61
+ │ │ ├── CommentInput.svelte # Comment input area
62
+ │ │ ├── CommentNav.svelte # Navigate between comments
63
+ │ │ ├── CommentListItem.svelte # Comment item in manager
64
+ │ │ ├── CommentManager.svelte # Comment management panel
65
+ │ │ ├── CommentBadge.svelte # Comment count badge
66
+ │ │ ├── MarginNote.svelte # Individual margin note
67
+ │ │ ├── MarginNotesContainer.svelte
68
+ │ │ ├── ActionsMenu.svelte # Actions dropdown menu
69
+ │ │ ├── InlineEditor.svelte # Inline text editing
70
+ │ │ ├── RawModal.svelte # View raw .comments.md file
71
+ │ │ ├── ReanchorConfirm.svelte # Re-anchor confirmation dialog
72
+ │ │ ├── SettingsModal.svelte # Settings modal
73
+ │ │ ├── ShortcutCapture.svelte # Keyboard shortcut capture
74
+ │ │ ├── ShortcutList.svelte # Keyboard shortcuts list
75
+ │ │ ├── TabBar.svelte # Multi-file tab bar
76
+ ├── TableOfContents.svelte # Document headings navigation
77
+ │ │ └── ui/ # Primitive UI components
78
+ │ │ ├── ActionLink.svelte
79
+ │ │ ├── Button.svelte
80
+ │ │ ├── Dialog.svelte
81
+ │ │ ├── DropdownMenu.svelte
82
+ │ │ ├── DropdownMenuItem.svelte
83
+ │ │ ├── DropdownMenuSeparator.svelte
84
+ │ │ └── Text.svelte
85
+ │ ├── stores/ # Svelte 5 reactive stores
86
+ │ │ ├── app.svelte.ts # Application state
87
+ │ │ ├── settings.svelte.ts # User settings
88
+ ├── shortcuts.svelte.ts # Keyboard shortcuts
89
+ │ │ ├── locale.svelte.ts # i18n state
90
+ │ │ └── ui.svelte.ts # UI state
91
+ └── lib/
92
+ ├── anchor.ts # Anchor-based comment resolution
93
+ ├── comment-storage.ts # File-based comment storage
94
+ ├── export.ts # Export utilities (JSON, prompt format)
95
+ ├── headings.ts # Heading extraction
96
+ ├── html-text.ts # HTML text extraction
97
+ ├── margin-layout.ts # Margin note position resolution
98
+ │ ├── markdown-renderer.ts # Server-side markdown rendering
99
+ │ ├── mermaid-renderer.ts # Mermaid diagram rendering
100
+ │ ├── mermaid-config.ts # Mermaid configuration
101
+ │ ├── mermaid-worker.ts # Mermaid worker thread
102
+ │ ├── positions.ts # Position calculations
103
+ │ ├── shortcut-registry.ts # Keyboard shortcut registry
104
+ ├── utils.ts # Common utilities (cn, etc.)
105
+ ├── highlight/ # Text highlighting system
106
+ ├── highlighter.ts # Highlight manager
107
+ ├── highlight-registry.ts # Highlight registry
108
+ ├── resolver.ts # Highlight resolution
109
+ ├── dom.ts # DOM manipulation
110
+ │ │ └── types.ts # Type definitions
111
+ │ └── i18n/ # Internationalization
112
+ │ ├── index.ts
113
+ │ ├── translations.ts
114
+ │ ├── types.ts
115
+ │ ├── en.ts # English translations
116
+ │ └── ja.ts # Japanese translations
117
+ ├── go/ # Go server (production binary)
118
+ │ ├── cmd/readit/main.go # Go CLI entry point
119
+ │ └── internal/server/ # HTTP server, markdown, comments, SSE
120
+ ├── shell/ # Shell integration
121
+ │ ├── readit.zsh # Zsh plugin (@ file picker + completions)
122
+ │ └── _readit # Zsh compdef completion function
123
+ ├── nvim-readit/ # Neovim plugin
124
+ │ ├── lua/readit/init.lua # Core plugin (server mgmt, commands, keymaps)
125
+ │ ├── lua/readit/health.lua # :checkhealth support
126
+ │ └── plugin/readit.lua # Auto-loader
127
+ ├── vscode-readit/ # VS Code extension
128
+ │ └── src/ # Extension source (TypeScript)
129
+ ├── e2e/ # Playwright e2e tests
130
+ ├── docs/ # Design docs and specs
95
131
  ├── dist/ # Built output
96
132
  ├── .claude/ # AI agent docs
97
133
  │ ├── user-stories.md
98
134
  │ ├── roadmap.md
99
135
  │ └── settings.json
136
+ ├── Makefile # Go build targets (make dev, make build)
100
137
  ├── CLAUDE.md # This file
101
- ├── AGENTS.md # AI agent instructions
102
- └── CHANGELOG.md # Version changelog
138
+ └── AGENTS.md # AI agent instructions
103
139
  ```
104
140
 
105
141
  ## Key Design Decisions
106
142
 
107
- 1. **react-markdown for Markdown**: Client-side rendering, no external dependencies
108
- 2. **unified/rehype for HTML**: Safe HTML rendering with XSS protection via html-processor
109
- 3. **IframeContainer for HTML isolation**: Renders HTML in sandboxed iframe to prevent style/script leakage
110
- 4. **Margin notes UX**: Comments appear as margin notes next to highlighted text (Google Docs style)
111
- 5. **File-based comments**: Human-readable `.comments.md` files stored in `~/.readit/comments/`
112
- 6. **difit-style UX**: CLI local server browser, familiar pattern
113
- 7. **Hooks for state**: Custom hooks for comment management
143
+ 1. **markdown-it for Markdown**: Server-side rendering with shiki for syntax highlighting
144
+ 2. **Mermaid for diagrams**: Server-side Mermaid diagram rendering
145
+ 3. **Margin notes UX**: Comments appear as margin notes next to highlighted text (Google Docs style)
146
+ 4. **File-based comments**: Human-readable `.comments.md` files stored in `~/.readit/comments/`
147
+ 5. **difit-style UX**: CLI local server browser, familiar pattern
148
+ 6. **Svelte 5 stores for state**: Reactive stores (`.svelte.ts`) for state management
149
+ 7. **i18n support**: English and Japanese translations
150
+ 8. **Live reload**: fs.watch() on documents + SSE push to browser; handles rename-style saves (Vim/Neovim/Emacs)
151
+ 9. **Editor integrations**: Neovim plugin (Lua), VS Code extension, shell completions with `@` fzf file picker
114
152
 
115
153
  ## Tech Stack
116
154
 
117
155
  - **Runtime**: Bun
118
156
  - **CLI**: Commander.js for argument parsing
119
- - **Server**: Bun.serve() for API and static files
120
- - **Markdown Rendering**: react-markdown
121
- - **HTML Rendering**: unified + rehype-parse + rehype-react (with XSS sanitization)
122
- - **Frontend**: React 19 + TypeScript + Vite
157
+ - **Server**: Bun.serve() for API, SSE, and static files
158
+ - **Markdown Rendering**: markdown-it (server-side) + shiki (syntax highlighting)
159
+ - **Frontend**: Svelte 5 + TypeScript + Vite
123
160
  - **Styling**: Tailwind CSS v4
124
- - **Testing**: Vitest
161
+ - **Icons**: lucide-svelte
162
+ - **Testing**: Vitest (unit) + Playwright (e2e)
163
+ - **Production Binary**: Go (embeds frontend via go:embed)
125
164
  - **Quality**: Biome (lint + format), lefthook
165
+ - **Shell Integration**: Zsh/Bash/Fish completions, fzf-powered `@` file picker
166
+ - **Editor Plugins**: Neovim (Lua), VS Code (TypeScript)
126
167
 
127
168
  ## Current Limitations
128
169
 
129
- - Comments use text offset, may break if document changes significantly
170
+ - Comments use anchor-based text matching, may break if document changes significantly
130
171
  - No comment status tracking yet (resolved/unresolved planned for v0.3.0)
131
172
 
132
173
  ## User Stories
@@ -136,7 +177,8 @@ See `.claude/user-stories.md` for detailed user stories and acceptance criteria.
136
177
  ## Code Style
137
178
 
138
179
  - TypeScript strict mode
139
- - Functional React components with hooks
140
- - Tailwind for styling (no CSS-in-JS)
180
+ - Svelte 5 components with reactive stores
181
+ - Tailwind for styling
141
182
  - ESM modules throughout
142
- - Co-located test files (`*.test.ts`)
183
+ - Co-located test files (`*.test.ts`, `*.bench.ts`)
184
+ - E2E tests in `e2e/`
@@ -78,7 +78,7 @@ Reference `.claude/rules/style-guide.md` for detailed examples.
78
78
  **For surface issues:**
79
79
 
80
80
  1. Fix silently after addressing fundamental issues
81
- 2. Run `pnpm turbo run fix` to format
81
+ 2. Run `bun run check:fix` to format
82
82
 
83
83
  ## Anti-patterns to Flag
84
84
 
@@ -3,17 +3,17 @@
3
3
  ## v0.1.0 - MVP ✅
4
4
 
5
5
  - [x] CLI with Commander.js
6
- - [x] react-markdown for Markdown rendering
7
- - [x] HTML file support with unified/rehype (XSS protection)
8
- - [x] Express server serving static files
9
- - [x] React 19 frontend with Tailwind CSS v4
6
+ - [x] markdown-it for Markdown rendering (server-side with shiki syntax highlighting)
7
+ - [x] HTML file support
8
+ - [x] Bun.serve() server serving API + static files
9
+ - [x] Svelte 5 frontend with Tailwind CSS v4
10
10
  - [x] Text selection → comment input
11
11
  - [x] Margin notes UI (Google Docs style)
12
12
  - [x] Highlight commented text with yellow background
13
13
  - [x] Copy All / Export JSON
14
14
  - [x] File-based comment persistence (`.comments.md` files)
15
15
  - [x] Copy for LLM feature (⌘⇧C) - copy selection/comment with surrounding context
16
- - [x] CLI subcommands: `list`, `show`
16
+ - [x] CLI subcommands: `list`, `show`, `open`
17
17
 
18
18
  ## v0.2.0 - File-Based Comment Storage ✅
19
19
 
@@ -65,7 +65,7 @@ Review documents, add comments, then resolve one-by-one with LLM assistance.
65
65
  ## v0.4.0 - Visual Enhancements ✅
66
66
 
67
67
  - [x] Highlight commented text in document (moved to v0.1.0)
68
- - [x] Syntax highlighting for code blocks (react-syntax-highlighter)
68
+ - [x] Syntax highlighting for code blocks (shiki, server-side)
69
69
  - [x] Click highlight → scroll to margin note
70
70
  - [x] Click margin note → scroll to highlighted text
71
71
  - [x] Mermaid diagram rendering
@@ -82,13 +82,36 @@ Review documents, add comments, then resolve one-by-one with LLM assistance.
82
82
  - [ ] Filter by category
83
83
  - [ ] Category in export format
84
84
 
85
- ## v0.6.0 - Multi-file Support
85
+ ## v0.6.0 - Multi-file Support (Partial ✅)
86
86
 
87
87
  - [ ] Glob pattern support (`readit docs/*.md`)
88
- - [ ] File navigation sidebar
89
- - [ ] Per-file comment storage
88
+ - [x] Multiple file arguments (`readit file1.md file2.md`)
89
+ - [x] Directory scanning (`readit <dir>`)
90
+ - [x] `readit open <files...>` to add files to running server
91
+ - [x] File tab navigation (TabBar.svelte)
92
+ - [x] Per-file comment storage
90
93
  - [ ] Bulk export across files
91
94
 
95
+ ## v0.7.0 - Shell Integration & Editor Plugins ✅
96
+
97
+ - [x] Zsh integration with `@` file autocomplete (fzf-powered, Forge Code-style)
98
+ - [x] `@<TAB>` launches fzf picker for markdown files
99
+ - [x] `@partial<TAB>` pre-filters fzf query
100
+ - [x] Syntax highlighting for `@*.md` patterns in command line
101
+ - [x] Standard compdef completion for subcommands and options
102
+ - [x] Bash and Fish completion scripts via `readit completion`
103
+ - [x] Neovim plugin (`nvim-readit/`)
104
+ - [x] Server lifecycle management (start/stop/discover)
105
+ - [x] `:ReaditOpen`, `:ReaditStop`, `:ReaditStatus`, `:ReaditReload`, `:ReaditList` commands
106
+ - [x] Configurable keymaps (`<leader>r` prefix by default)
107
+ - [x] `:checkhealth readit` support
108
+ - [x] Auto-cleanup on VimLeavePre
109
+ - [x] Enhanced live reload on file changes
110
+ - [x] Handle `rename` events (Vim/Neovim write-to-temp-then-rename saves)
111
+ - [x] Auto re-establish watcher after rename with retry logic
112
+ - [x] SSE auto-reconnect with exponential backoff
113
+ - [x] Parallel document + comments fetch on reload
114
+
92
115
  ## Future Considerations
93
116
 
94
117
  - Sticky notes (ペタペタ) - add notes not tied to text selection
@@ -11,7 +11,7 @@
11
11
  **Acceptance Criteria:**
12
12
 
13
13
  - Run `readit document.md` or `readit document.html` and browser opens with rendered content
14
- - react-markdown for Markdown, unified/rehype for HTML (client-side rendering)
14
+ - markdown-it for Markdown (server-side rendering with shiki syntax highlighting)
15
15
  - Clean light theme with good typography for reading
16
16
 
17
17
  ---
@@ -153,20 +153,20 @@
153
153
 
154
154
  ---
155
155
 
156
- ### US-010: Review Multiple Files
156
+ ### US-010: Review Multiple Files
157
157
 
158
- **As a** reviewer
159
- **I want to** review multiple Markdown files in one session
160
- **So that** I can review an entire document set
158
+ **As a** reviewer
159
+ **I want to** review multiple Markdown files in one session
160
+ **So that** I can review an entire document set
161
161
 
162
162
  **Acceptance Criteria:**
163
163
 
164
- - `readit docs/*.md` opens multi-file view
165
- - File tabs or sidebar navigation
164
+ - ~~`readit docs/*.md` opens multi-file view~~ `readit file1.md file2.md` or `readit <dir>` opens multi-file view
165
+ - File tabs or sidebar navigation (TabBar.svelte)
166
166
  - Comments stored per file
167
167
  - Bulk export across all files
168
168
 
169
- **Status:** Not implemented
169
+ **Status:** Implemented (multi-file args, directory scanning, `open` command, tab bar UI). Glob patterns not yet supported.
170
170
 
171
171
  ---
172
172
 
@@ -205,6 +205,61 @@
205
205
 
206
206
  ---
207
207
 
208
+ ### US-013: Shell Integration with File Autocomplete ✅
209
+
210
+ **As a** CLI user
211
+ **I want to** autocomplete markdown file paths with `@<TAB>` in my shell
212
+ **So that** I can quickly find and open documents without typing full paths
213
+
214
+ **Acceptance Criteria:**
215
+
216
+ - `readit @<TAB>` launches fzf picker for markdown files in cwd
217
+ - `readit @partial<TAB>` pre-filters the picker with "partial" as query
218
+ - Standard Tab completion works for subcommands and options
219
+ - `readit completion zsh|bash|fish` outputs shell-specific setup scripts
220
+ - `eval "$(readit completion zsh)"` installs everything in one line
221
+
222
+ **Status:** Implemented (v0.7.0)
223
+
224
+ ---
225
+
226
+ ### US-014: Neovim Plugin ✅
227
+
228
+ **As a** Neovim user
229
+ **I want to** render and review markdown documents directly from my editor
230
+ **So that** I can stay in my editing workflow while reviewing
231
+
232
+ **Acceptance Criteria:**
233
+
234
+ - `:ReaditOpen` starts server and opens current buffer in browser
235
+ - `:ReaditStop` stops the server
236
+ - `:ReaditReload` saves buffer and triggers browser refresh
237
+ - `:ReaditStatus` shows server info
238
+ - Configurable keymaps (default `<leader>r` prefix)
239
+ - Server auto-cleanup on VimLeavePre
240
+ - `:checkhealth readit` verifies dependencies
241
+
242
+ **Status:** Implemented (v0.7.0)
243
+
244
+ ---
245
+
246
+ ### US-015: Live Reload on File Changes ✅
247
+
248
+ **As a** reviewer
249
+ **I want to** see the browser update automatically when I edit the source document
250
+ **So that** I can see my changes reflected in real time
251
+
252
+ **Acceptance Criteria:**
253
+
254
+ - Browser updates within ~200ms of file save
255
+ - Works with Vim/Neovim saves (write-to-temp-then-rename pattern)
256
+ - SSE connection auto-reconnects if server restarts (exponential backoff)
257
+ - Document HTML and comments fetched in parallel for fast reload
258
+
259
+ **Status:** Implemented (enhanced in v0.7.0, base SSE existed since v0.1.0)
260
+
261
+ ---
262
+
208
263
  ## Technical Stories
209
264
 
210
265
  ### TS-001: CLI Argument Parsing
@@ -217,18 +272,22 @@
217
272
 
218
273
  ### TS-002: Server Architecture
219
274
 
220
- - Express server serves API + static files
221
- - `/api/document` returns `{ content, type, filePath, fileName, clean }`
222
- - `/api/heartbeat` SSE for browser disconnect detection
223
- - Development mode proxies to Vite
275
+ - Bun.serve() serves API + static files
276
+ - `/api/documents` list and add documents
277
+ - `/api/document` fetch individual document HTML and headings
278
+ - `/api/comments` CRUD operations for comments
279
+ - `/api/settings` get/update user settings
280
+ - `/api/heartbeat` SSE for browser connection tracking
281
+ - `/api/document/stream` SSE for document updates (live reload)
282
+ - Development mode proxies to Vite dev server
224
283
  - Production mode serves built assets from dist/
225
284
 
226
285
  ### TS-003: Build System
227
286
 
228
287
  - Vite for frontend bundling
229
- - tsup for CLI bundling
230
- - Single `npm run build` produces complete distributable
231
- - `npx readit` works without global install
288
+ - `bun build` for CLI bundling (target bun, ESM)
289
+ - Single `bun run build` produces complete distributable
290
+ - `bunx readit` works without global install
232
291
 
233
292
  ### TS-004: File-Based Comment Storage
234
293
 
@@ -246,3 +305,29 @@
246
305
 
247
306
  - API endpoints: `GET/POST/PUT/DELETE /api/comments` for CRUD operations
248
307
  - Watch file for external changes (optional)
308
+
309
+ ### TS-005: Shell Integration Architecture
310
+
311
+ - `shell/_readit` - Standard zsh compdef for subcommands, options, file args
312
+ - `shell/readit.zsh` - Rich widget: `@` prefix triggers fzf markdown file picker
313
+ - Uses `fd` for fast file listing, falls back to `find`
314
+ - fzf with bat/head preview, initial query from text after `@`
315
+ - `readit completion zsh|bash|fish` CLI subcommand outputs setup scripts
316
+ - Bash completion via `complete -F`, Fish via `complete -c`
317
+
318
+ ### TS-006: Neovim Plugin Architecture
319
+
320
+ - `nvim-readit/lua/readit/init.lua` - Core: setup, server management, commands, keymaps
321
+ - `nvim-readit/plugin/readit.lua` - Auto-loader on markdown FileType
322
+ - `nvim-readit/lua/readit/health.lua` - `:checkhealth` module
323
+ - Discovers existing servers via `~/.readit/server.json`
324
+ - Starts server with `jobstart()`, attaches files via `POST /api/documents`
325
+ - Communicates with server via curl (non-blocking `jobstart`)
326
+
327
+ ### TS-007: File Watcher Resilience
328
+
329
+ - `fs.watch()` with both `"change"` and `"rename"` event handling
330
+ - On rename: retry loop (10 attempts, 200ms apart) to re-establish watcher
331
+ - Debounced re-render (200ms) to avoid thrashing on rapid saves
332
+ - SSE auto-reconnect with exponential backoff (1s -> 30s max)
333
+ - Parallel fetch of document HTML + comments on reload
package/AGENTS.md CHANGED
@@ -4,57 +4,61 @@ Instructions for AI coding agents working on this project.
4
4
 
5
5
  ## Project Context
6
6
 
7
- readit is a CLI tool for reviewing Markdown documents with inline comments. The workflow is:
7
+ readit is a CLI tool for reviewing Markdown and HTML documents with inline comments. The workflow is:
8
8
 
9
9
  1. User runs `readit document.md`
10
- 2. CLI converts Markdown to HTML using Pandoc
11
- 3. Express server starts and opens browser
10
+ 2. Server renders Markdown to HTML (markdown-it + shiki for syntax highlighting)
11
+ 3. Bun.serve() starts and opens browser with Svelte 5 frontend
12
12
  4. User selects text and adds comments
13
- 5. Comments are saved to localStorage
13
+ 5. Comments are saved as `.comments.md` files in `~/.readit/comments/`
14
14
  6. User can export comments for AI or apply back to Markdown
15
15
 
16
16
  ## Development Commands
17
17
 
18
18
  ```bash
19
- pnpm install # Install dependencies
20
- pnpm dev # Start development (Vite + CLI hot reload)
21
- pnpm build # Build for production
22
- pnpm test # Run tests
23
- pnpm typecheck # TypeScript check
24
- pnpm check # Biome lint + format check
25
- pnpm check:fix # Fix issues
26
- pnpm format # Format code
19
+ bun install # Install dependencies
20
+ bun dev # Start development (CLI with --watch)
21
+ bun run dev:client # Start Vite dev server only
22
+ bun run build # Build for production (Vite + CLI)
23
+ bun run test # Run unit tests (Vitest)
24
+ bun run test:e2e # Run e2e tests (Playwright)
25
+ bun run typecheck # TypeScript check
26
+ bun run check # Biome lint + format check
27
+ bun run check:fix # Fix lint + format issues
28
+ bun run format # Format code with Biome
27
29
  ```
28
30
 
29
31
  ## Code Organization
30
32
 
31
- - `src/cli/` - CLI entry point, argument parsing
32
- - `src/server/` - Express server, Pandoc integration
33
- - `src/components/` - React UI components
34
- - `src/hooks/` - Custom React hooks
35
- - `src/lib/` - Utility functions
36
- - `src/types/` - TypeScript types
33
+ - `src/cli.ts` - CLI entry point (Commander.js)
34
+ - `src/server.ts` - Bun.serve() server + API routes
35
+ - `src/components/` - Svelte 5 UI components
36
+ - `src/stores/` - Svelte 5 reactive stores (`.svelte.ts`)
37
+ - `src/lib/` - Utility functions, rendering, i18n
38
+ - `src/schema.ts` - TypeScript types
39
+ - `shell/` - Zsh/Bash/Fish completions and `@` file picker widget
40
+ - `nvim-readit/` - Neovim plugin (Lua)
41
+ - `vscode-readit/` - VS Code extension
37
42
 
38
43
  ## Testing
39
44
 
40
- - Tests are co-located with source files (`*.test.ts`)
41
- - Use Vitest for testing
42
- - Run `pnpm test` before committing
45
+ - Unit tests are co-located with source files (`*.test.ts`)
46
+ - E2E tests live in `e2e/` (Playwright)
47
+ - Run `bun run test` before committing
43
48
 
44
49
  ## Commit Guidelines
45
50
 
46
51
  - Use conventional commits (feat:, fix:, docs:, etc.)
47
52
  - Keep commits focused and atomic
48
- - Run `pnpm typecheck && pnpm check` before committing
53
+ - Run `bun run typecheck && bun run check` before committing
49
54
 
50
55
  ## Adding Features
51
56
 
52
57
  1. Check `.claude/user-stories.md` for planned features
53
- 2. Update types in `src/types/` first
54
- 3. Create/update hooks if needed
55
- 4. Create/update components
58
+ 2. Update types in `src/schema.ts` first
59
+ 3. Create/update stores if needed (`src/stores/`)
60
+ 4. Create/update Svelte components (`src/components/`)
56
61
  5. Add tests
57
- 6. Update CHANGELOG.md
58
62
 
59
63
  ## Key Files to Review
60
64
 
package/Makefile ADDED
@@ -0,0 +1,32 @@
1
+ .PHONY: dev build build-client build-server test test-client test-e2e clean
2
+
3
+ # Development: Go server manages Vite child process
4
+ dev:
5
+ cd go && go run ./cmd/readit -- --dev $(ARGS)
6
+
7
+ # Production build: frontend first, then Go embeds it
8
+ build: build-client build-server
9
+
10
+ build-client:
11
+ bunx vite build
12
+
13
+ build-server: build-client
14
+ rm -rf go/internal/server/dist
15
+ mkdir -p go/internal/server/dist
16
+ cp -r dist/. go/internal/server/dist/
17
+ cd go && go build -o ../dist/readit ./cmd/readit
18
+
19
+ # Tests
20
+ test:
21
+ cd go && go test ./...
22
+
23
+ test-client:
24
+ bun run test
25
+
26
+ test-e2e:
27
+ bun run test:e2e
28
+
29
+ clean:
30
+ rm -rf dist go/internal/server/dist
31
+ mkdir -p go/internal/server/dist
32
+ touch go/internal/server/dist/.gitkeep