@youtyan/code-viewer 0.1.32 → 0.1.34

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.
package/README.md CHANGED
@@ -103,6 +103,47 @@ Use `scope.omitDirs` for directories that should stay visible as skipped, and
103
103
  `scope.excludeNames` for file or directory names that should be hidden entirely.
104
104
  `.DS_Store` is hidden by default.
105
105
 
106
+ ## AI Code Annotations
107
+
108
+ AI coding agents (Claude Code, Codex, and similar CLI agents) can walk you
109
+ through a codebase inside the viewer. An agent posts explanations for
110
+ specific code locations with the `annotate` subcommand, and every open
111
+ browser tab jumps to that location live — in the diff view when the file has
112
+ changes in the current range, or in the source view otherwise:
113
+
114
+ ```sh
115
+ code-viewer annotate start --title "How the SSE update flow works"
116
+ code-viewer annotate add --file web-src/server/preview.ts --line 2330-2360 \
117
+ --body "Each browser tab keeps one SSE stream open against this endpoint."
118
+ code-viewer annotate add --file web-src/app.ts --line 9650 \
119
+ --from HEAD~1 --to worktree \
120
+ --body "After the fix, reloads preserve the scroll position here."
121
+ ```
122
+
123
+ The body is Markdown. Long bodies can be passed with `--body-file <path>` or
124
+ piped through stdin. `code-viewer annotate --help` shows all commands,
125
+ including `list`, `delete <id>`, and `clear`.
126
+
127
+ Annotations are grouped into sessions and persisted in
128
+ `.code-viewer/annotations.json` at the repository root, so the walkthrough
129
+ survives reloads and server restarts. The `.code-viewer` directory is
130
+ tool-internal: it never shows up in the file tree, searches, or diffs. Add it
131
+ to `.gitignore` if you do not want to share annotations through git.
132
+
133
+ In the browser, the 💬 button in the header opens the annotation side panel.
134
+ The current explanation is rendered at the top of the panel while the code
135
+ stays visible next to it, with the annotated lines highlighted. The history
136
+ below groups annotations by session; clicking an entry jumps back to its
137
+ location, and entries and sessions can be deleted there too. The "follow"
138
+ checkbox controls whether the tab jumps automatically when an agent adds a
139
+ new annotation.
140
+
141
+ The `annotate` subcommand reuses the running server for the repository when
142
+ one exists (discovered via `~/.cache/code-viewer/servers/`) and starts one
143
+ automatically otherwise, printing its URL to stderr. Pass `--cwd <repo>` when
144
+ annotating a repository other than the current directory, or `--server <url>`
145
+ to target a specific server.
146
+
106
147
  ## Development
107
148
 
108
149
  ```sh