@youtyan/code-viewer 0.1.33 → 0.1.35

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,52 @@ 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`. For AI agents,
126
+ `code-viewer annotate agent-help` prints a skill-style guide covering the
127
+ workflow, conventions, and pitfalls for writing good walkthroughs.
128
+
129
+ Annotations are grouped into sessions and persisted in
130
+ `.code-viewer/annotations.json` at the repository root, so the walkthrough
131
+ survives reloads and server restarts. The `.code-viewer` directory is
132
+ tool-internal: it never shows up in the file tree, searches, or diffs. Add it
133
+ to `.gitignore` if you do not want to share annotations through git.
134
+
135
+ In the browser, the 💬 button in the header opens the annotation side panel.
136
+ The current explanation is rendered at the top of the panel while the code
137
+ stays visible next to it, with the annotated lines highlighted. The history
138
+ below groups annotations by session; clicking an entry jumps back to its
139
+ location, and entries and sessions can be deleted there too. The "follow"
140
+ checkbox controls whether the tab jumps automatically when an agent adds a
141
+ new annotation.
142
+
143
+ The `annotate` subcommand talks to the running server for the repository
144
+ (discovered via `~/.cache/code-viewer/servers/`); start one with
145
+ `code-viewer` first. Pass `--cwd <repo>` when annotating a repository other
146
+ than the current directory, or `--server <url>` to target a specific server.
147
+
148
+ `add` appends to the most recent session (creating one when none exists);
149
+ run `annotate start` again to begin a new session, or pass `--session <id>`
150
+ to target a specific one.
151
+
106
152
  ## Development
107
153
 
108
154
  ```sh