@youtyan/code-viewer 0.1.51 → 0.1.53

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
@@ -14,6 +14,7 @@ Requires Node.js 20 or newer when installed from npm. Development uses
14
14
  - Preview Markdown with a table of contents, task lists, Mermaid diagrams, and Shiki code highlighting.
15
15
  - Preview browser-safe media and show metadata for binary files that cannot be rendered.
16
16
  - Switch the viewer UI between English and Japanese from Viewer Settings.
17
+ - Browse SQLite, PostgreSQL, and MySQL databases with a built-in database viewer.
17
18
  - Read the built-in Help page for repository browsing, diffs, annotations, agent skills, and shortcuts.
18
19
  - Open repository folders in the OS file manager from localhost-only actions.
19
20
  - Upload files into worktree folders when upload is explicitly enabled.
@@ -111,6 +112,75 @@ Use `scope.omitDirs` for directories that should stay visible as skipped, and
111
112
  `scope.excludeNames` for file or directory names that should be hidden entirely.
112
113
  `.DS_Store` is hidden by default.
113
114
 
115
+ ## Database Viewer
116
+
117
+ code-viewer auto-discovers databases in your repository and provides a
118
+ browser-based viewer for exploring their contents.
119
+
120
+ **SQLite** files (`.db`, `.sqlite`, `.sqlite3`, `.s3db`) are detected
121
+ automatically by scanning the repository tree. **PostgreSQL** and **MySQL**
122
+ databases are detected from `docker-compose.yml` and connected through
123
+ Docker.
124
+
125
+ ### Browser UI
126
+
127
+ Open the database icon in the sidebar to access:
128
+
129
+ - **Table browser** — paginated data grid with column sorting, text
130
+ filtering, and CSV/JSON export.
131
+ - **Query editor** — execute read-only SQL with syntax highlighting.
132
+ Results and history are saved and shared across tabs.
133
+ - **ER diagram** — auto-generated entity-relationship diagram showing
134
+ foreign key relationships between tables.
135
+ - **Global search** — full-text search across all tables and text columns.
136
+ - **Snapshots & diffs** — take point-in-time snapshots of selected tables
137
+ and compare any two snapshots to see inserted, updated, and deleted rows
138
+ with full before/after values.
139
+
140
+ ### CLI
141
+
142
+ AI agents can query databases and manage snapshots from the command line:
143
+
144
+ ```sh
145
+ code-viewer query exec --db data.db --sql "SELECT * FROM users LIMIT 10" \
146
+ --title "Sample users" --body "Checking user data shape."
147
+
148
+ code-viewer query search --db app.db --term "john@example.com"
149
+
150
+ code-viewer query snapshot create --db app.db --tables users,orders \
151
+ --note "Before migration"
152
+ ```
153
+
154
+ `code-viewer query --help` shows all commands. `code-viewer query agent-help`
155
+ prints a detailed guide for AI agents covering queries, search, snapshots,
156
+ and diffs.
157
+
158
+ ### Snapshot & Diff Workflow
159
+
160
+ Snapshots capture the state of selected tables at a point in time. Diff any
161
+ two snapshots to verify that a migration, test, or operation changed exactly
162
+ what you expected:
163
+
164
+ ```sh
165
+ # 1. Snapshot before the operation
166
+ code-viewer query snapshot create --db app.db --tables users --note "Before"
167
+
168
+ # 2. (run the migration / test / script)
169
+
170
+ # 3. Snapshot after
171
+ code-viewer query snapshot create --db app.db --tables users --note "After"
172
+
173
+ # 4. List snapshots to get IDs
174
+ code-viewer query snapshot list --db app.db
175
+
176
+ # 5. Compare
177
+ code-viewer query diff tables --before snap-abc123 --after snap-def456
178
+ code-viewer query diff rows --before snap-abc123 --after snap-def456 --table users
179
+ ```
180
+
181
+ Diffs are computed on demand — no pre-computation needed. The browser's
182
+ Snapshot tab provides a visual interface for the same workflow.
183
+
114
184
  ## AI Code Annotations
115
185
 
116
186
  AI coding agents (Claude Code, Codex, and similar CLI agents) can walk you
@@ -163,9 +233,9 @@ write concise Markdown explanations, and how to install the bundled agent skill.
163
233
 
164
234
  ### Agent Skill
165
235
 
166
- The package bundles an [Agent Skill](https://agentskills.io) (the SKILL.md
167
- open standard) that teaches AI coding agents when and how to use
168
- `annotate`. Install it into the current project:
236
+ The package bundles [Agent Skills](https://agentskills.io) (the SKILL.md
237
+ open standard) that teach AI coding agents when and how to use
238
+ `annotate`, `query`, and `snapshot`. Install them into the current project:
169
239
 
170
240
  ```sh
171
241
  npx -y @youtyan/code-viewer skill install # Claude Code (.claude/skills/)