@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/README.md CHANGED
@@ -27,12 +27,100 @@ readit <file> --host 0.0.0.0 # Custom host (default: 127.0.0.1)
27
27
  readit <file> --no-open # Don't auto-open browser
28
28
  readit <file> --clean # Clear existing comments
29
29
 
30
- readit list # List all files with comments
31
- readit show <file> # Show comments for a file
30
+ readit list # List all files with comments
31
+ readit show <file> # Show comments for a file
32
+ readit open <files...> # Add files to running server
33
+ readit completion zsh # Output shell integration script
32
34
  ```
33
35
 
34
36
  Select text to add comments. Comments appear as margin notes. Copy all comments formatted for AI with a single click.
35
37
 
38
+ ## Shell Integration
39
+
40
+ readit provides rich shell completions and an `@` file picker for zsh, bash, and fish.
41
+
42
+ ### Zsh (recommended)
43
+
44
+ Add to your `~/.zshrc`:
45
+
46
+ ```bash
47
+ eval "$(readit completion zsh)"
48
+ ```
49
+
50
+ This gives you:
51
+
52
+ - **`@` file picker** -- type `readit @` and press Tab to open an fzf-powered markdown file picker with preview. Type `readit @test` + Tab to pre-filter to files matching "test".
53
+ - **Standard completion** -- Tab-complete subcommands (`open`, `list`, `show`, `completion`), options (`--port`, `--clean`), and markdown file paths.
54
+ - **Syntax highlighting** -- `@file.md` tokens are highlighted in cyan (requires [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)).
55
+ - **`ri` alias** -- shorthand for `readit`.
56
+
57
+ Optional dependencies for the best experience: [fzf](https://github.com/junegunn/fzf), [fd](https://github.com/sharkdp/fd), [bat](https://github.com/sharkdp/bat).
58
+
59
+ ### Bash
60
+
61
+ ```bash
62
+ eval "$(readit completion bash)"
63
+ ```
64
+
65
+ ### Fish
66
+
67
+ ```fish
68
+ readit completion fish | source
69
+ ```
70
+
71
+ ## Neovim Plugin
72
+
73
+ The `nvim-readit` plugin lets you open markdown files in readit directly from Neovim. Edits in Neovim are reflected in the browser automatically via live reload.
74
+
75
+ ### Installation (lazy.nvim)
76
+
77
+ ```lua
78
+ {
79
+ dir = "path/to/readit/nvim-readit", -- or install from repo
80
+ ft = "markdown",
81
+ opts = {},
82
+ }
83
+ ```
84
+
85
+ ### Commands
86
+
87
+ | Command | Keymap | Description |
88
+ |---|---|---|
89
+ | `:ReaditOpen` | `<leader>ro` | Open current buffer in readit |
90
+ | `:ReaditReload` | `<leader>rr` | Save and reload in browser |
91
+ | `:ReaditStop` | `<leader>rq` | Stop the readit server |
92
+ | `:ReaditStatus` | `<leader>ri` | Show server status |
93
+ | `:ReaditList` | `<leader>rl` | Pick from files with comments |
94
+ | `:ReaditOpenFile <path>` | -- | Open a specific file |
95
+
96
+ ### Configuration
97
+
98
+ ```lua
99
+ require("readit").setup({
100
+ bun_path = "bun", -- Path to bun executable
101
+ port = 0, -- 0 = auto-select free port
102
+ host = "127.0.0.1",
103
+ auto_open = true, -- Open browser on :ReaditOpen
104
+ keymap_prefix = "<leader>r", -- Change keymap prefix
105
+ })
106
+ ```
107
+
108
+ Run `:checkhealth readit` to verify your setup.
109
+
110
+ ## Live Reload
111
+
112
+ readit watches open documents for changes and automatically refreshes the browser. This works with any editor:
113
+
114
+ - **Standard saves** -- detected via `fs.watch()` change events.
115
+ - **Vim/Neovim/Emacs saves** -- these editors write to a temp file then rename. readit detects rename events and re-establishes the file watcher automatically.
116
+ - **SSE auto-reconnect** -- if the browser loses its connection to the server, it reconnects with exponential backoff.
117
+
118
+ No configuration needed. Open a file with `readit`, edit it in any editor, and the browser updates within ~200ms.
119
+
120
+ ## VS Code Extension
121
+
122
+ The `vscode-readit` extension provides a side-by-side preview panel inside VS Code. See [vscode-readit/](vscode-readit/) for details.
123
+
36
124
  ## Development
37
125
 
38
126
  ```bash
package/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
3
3
  "vcs": {
4
4
  "enabled": true,
5
5
  "clientKind": "git",
@@ -19,9 +19,7 @@
19
19
  "style": {
20
20
  "noNonNullAssertion": "off"
21
21
  },
22
- "correctness": {
23
- "useExhaustiveDependencies": "warn"
24
- },
22
+ "correctness": {},
25
23
  "complexity": {
26
24
  "noForEach": "off",
27
25
  "noImportantStyles": "off"
@@ -37,9 +35,7 @@
37
35
  "useSemanticElements": "warn",
38
36
  "useFocusableInteractive": "warn"
39
37
  },
40
- "security": {
41
- "noDangerouslySetInnerHtml": "warn"
42
- }
38
+ "security": {}
43
39
  }
44
40
  },
45
41
  "css": {
@@ -65,5 +61,19 @@
65
61
  "!!**/test-results"
66
62
  ],
67
63
  "ignoreUnknown": true
68
- }
64
+ },
65
+ "overrides": [
66
+ {
67
+ "includes": ["**/*.svelte"],
68
+ "linter": {
69
+ "rules": {
70
+ "correctness": {
71
+ "noUnusedImports": "off",
72
+ "noUnusedVariables": "off",
73
+ "noUnusedFunctionParameters": "off"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ]
69
79
  }