@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: code-viewer-query
3
+ description: Use when investigating database contents, checking schema, running SQL queries, or answering questions about data in SQLite/MySQL/PostgreSQL databases visible to code-viewer. Triggers on "query", "SQL", "database", "テーブル", "データベース", "クエリ", "スキーマ", "DB".
4
+ ---
5
+
6
+ # code-viewer query
7
+
8
+ Execute read-only SQL queries against databases discovered by code-viewer.
9
+ Results are saved to query history and appear in the browser's Database
10
+ view, so the human can review what you queried.
11
+
12
+ ## When to use
13
+
14
+ - Answering "what does this data look like?"
15
+ - Checking schema, row counts, sample data
16
+ - Investigating data quality or anomalies
17
+ - Exploring table relationships
18
+
19
+ ## Requirements
20
+
21
+ - A code-viewer server must already be running for the repository
22
+ (the human starts it with: `code-viewer`). The CLI never starts one.
23
+ - Run from inside the repository, or pass `--cwd <repo>`.
24
+ - If `code-viewer` is not on PATH, prefix every command with
25
+ `npx -y @youtyan/code-viewer`.
26
+
27
+ ## Workflow
28
+
29
+ 1. List available databases:
30
+
31
+ ```sh
32
+ code-viewer query list
33
+ ```
34
+
35
+ 2. Execute a query:
36
+
37
+ ```sh
38
+ code-viewer query exec --db data.db --sql "SELECT * FROM users LIMIT 10" \
39
+ --title "Sample user data" --body "Checking what user records look like."
40
+ ```
41
+
42
+ 3. The human sees results in the browser's Database > Query History panel.
43
+
44
+ ## Guidelines
45
+
46
+ - Always use LIMIT. The server caps rows but be explicit.
47
+ - Write --title for the human, not for yourself.
48
+ - Use --body to explain why the query matters.
49
+ - Do not query broad PII or secrets unless explicitly asked.
50
+ - Use --no-save for exploratory queries that should not remain in history.
51
+ - Prefer specific columns over SELECT *.
52
+
53
+ ## Full reference
54
+
55
+ Before composing queries, read the complete agent guide:
56
+
57
+ ```sh
58
+ code-viewer query agent-help
59
+ ```
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: code-viewer-snapshot
3
+ description: Use when taking database snapshots before/after an operation to verify what changed, diffing two points in time, or confirming a migration/test/feature modified the expected tables and rows. Triggers on "snapshot", "diff", "スナップショット", "差分", "before/after", "DBの変更を確認", "マイグレーション検証", "テスト前後の比較".
4
+ ---
5
+
6
+ # code-viewer snapshot
7
+
8
+ Take point-in-time snapshots of database tables and diff them to see
9
+ exactly what changed — inserted, updated, and deleted rows with full
10
+ before/after values. Use it to verify migrations, test runs, or any
11
+ operation that should modify the database in a predictable way.
12
+
13
+ ## When to use
14
+
15
+ - Verifying a migration added/removed the expected rows
16
+ - Confirming a test correctly modifies the database
17
+ - Debugging "what did that operation actually change?"
18
+ - Auditing data changes before and after a deploy or script
19
+
20
+ ## Requirements
21
+
22
+ - A code-viewer server must already be running for the repository
23
+ (the human starts it with: `code-viewer`). The CLI never starts one.
24
+ - Run from inside the repository, or pass `--cwd <repo>`.
25
+ - If `code-viewer` is not on PATH, prefix every command with
26
+ `npx -y @youtyan/code-viewer`.
27
+
28
+ ## Workflow
29
+
30
+ ### 1. Take a "before" snapshot
31
+
32
+ Specify which database and tables to capture. Always use `--tables` to
33
+ avoid scanning unnecessary tables.
34
+
35
+ ```sh
36
+ code-viewer query snapshot create --db app.db \
37
+ --tables users,orders \
38
+ --note "Before running user registration test"
39
+ ```
40
+
41
+ ### 2. Perform the operation
42
+
43
+ The human (or a test runner, migration script, etc.) modifies the database.
44
+
45
+ ### 3. Take an "after" snapshot
46
+
47
+ ```sh
48
+ code-viewer query snapshot create --db app.db \
49
+ --tables users,orders \
50
+ --note "After running user registration test"
51
+ ```
52
+
53
+ ### 4. Get snapshot IDs
54
+
55
+ ```sh
56
+ code-viewer query snapshot list --db app.db
57
+ ```
58
+
59
+ ### 5. View the diff
60
+
61
+ Compare table-level summary (which tables changed and how many rows):
62
+
63
+ ```sh
64
+ code-viewer query diff tables --before snap-abc123 --after snap-def456
65
+ ```
66
+
67
+ Drill into row-level changes for a specific table:
68
+
69
+ ```sh
70
+ code-viewer query diff rows --before snap-abc123 --after snap-def456 \
71
+ --table users
72
+ ```
73
+
74
+ The human can also view all snapshots and diffs in the browser's
75
+ Database > Snapshot tab.
76
+
77
+ ## Managing snapshots
78
+
79
+ ```sh
80
+ # Update a snapshot's note
81
+ code-viewer query snapshot note --id snap-abc123 --note "Updated note"
82
+
83
+ # Delete a snapshot
84
+ code-viewer query snapshot delete --id snap-abc123
85
+ ```
86
+
87
+ ## Guidelines
88
+
89
+ - Always specify `--tables` — snapshotting every table wastes time.
90
+ - Write meaningful `--note` values — the human uses them to tell
91
+ snapshots apart.
92
+ - Take both snapshots against the same `--db` and `--tables`.
93
+ - For large tables, the snapshot captures all rows — be mindful of
94
+ database size.
95
+ - The diff is computed on demand, not stored — you can diff any two
96
+ snapshots of the same database.
97
+
98
+ ## Full reference
99
+
100
+ ```sh
101
+ code-viewer query agent-help
102
+ ```