Skip to content

Commit dbc4b59

Browse files
author
SIN CI
committed
chore: final sync before local cleanup
1 parent e868ec5 commit dbc4b59

8 files changed

Lines changed: 330 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to the SIN-Code unified binary will be documented in this fi
66

77
### Features
88
- **SIN-Browser-Tools MCP Full Integration (v3.29.0)**: 106 Playwright-based browser automation tools now fully integrated in sin-code and opencode. Per-tool permission defaults (35 read-only `allow`, 71 mutating `ask`). Catalog entry updated with full tool inventory. opencode.json `sin-browser-tools` MCP server registered. `sin-code mcp-install browser` updated to install SIN-Browser-Tools (pip) instead of deprecated `@anthropic/browser-tools-mcp` (npm). Tools include: navigation, click/type/fill, screenshots, PDF, tab/session management, cookie/storage, diagnostics, Shadow DOM, OOPIF, SPA wait, network mocking, macOS Spaces, screen recording.
9+
- **skill-process-disk-clean (v3.29.0)**: New bundled skill that safely reclaims disk space on a developer Mac. Surveys large directories, classifies them by risk (safe / ask / locked), deletes regenerable caches (Yarn, bun, npm, go-build, trivy, claude transcripts/plugins, chrome_pipeline, webauto), and VACUUMs the bloated `~/.local/share/opencode/opencode.db` (WAL freelist → 60 GB shrinks to ~6 GB with zero session loss). Sync-compatible with Infra-SIN-OpenCode-Stack. Local symlink `~/.config/opencode/skills/clean-disk-opencode` provided.
910

1011
### Features
1112
- **Context Meter (#484)**: `ContextMeter` struct in `agentloop/` — thread-safe token tracker with visual progress bar. Warns at 80%, compacts at 90%. `sin-code context` CLI command.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 OpenSIN-Code
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
name: skill-process-disk-clean
3+
description: Use when user says 'clean disk', 'free up space', 'disk full', 'opencode.db is huge', 'clean caches', 'vacuum opencode db'. Safely reclaim disk space by cleaning developer caches and VACUUMing the bloated opencode.db (WAL freelist) with zero session loss.
4+
license: MIT
5+
compatibility:
6+
- sin-code
7+
- opencode
8+
- claude-code
9+
- codex
10+
metadata:
11+
author: SIN-Code
12+
version: 3.29.0
13+
sources:
14+
- Infra-SIN-OpenCode-Stack
15+
required_tools: []
16+
lifecycle: native
17+
---
18+
19+
# skill-process-disk-clean
20+
21+
## Overview
22+
23+
Safely reclaim disk space on a developer Mac by cleaning opencode-related and
24+
general developer caches, logs, and the bloated `opencode.db` SQLite database.
25+
26+
The skill detects large directories, classifies them by risk (safe / ask /
27+
locked), and runs a deterministic cleanup. The single biggest win is usually
28+
`~/.local/share/opencode/opencode.db`: in WAL mode it grows to tens of GB while
29+
~90% of the file is freelist pages. A `VACUUM` after stopping opencode shrinks
30+
it back to a few GB with **zero session loss**.
31+
32+
## When to Use
33+
34+
- "clean disk", "free up space", "disk full", "mac has no space"
35+
- "opencode.db is huge", "why is opencode 60gb"
36+
- "clean caches", "clean yarn/npm/bun/go cache"
37+
- Disk capacity is above ~80% and the user wants headroom.
38+
39+
## When NOT to Use
40+
41+
- A one-off `rm` of a single known file (just do it).
42+
- Cleaning a production server or someone else's machine without confirmation.
43+
- The user explicitly wants to keep old sessions/logs for audit.
44+
45+
## Core Process
46+
47+
```
48+
CHECK DISK → SURVEY DIRS → CLASSIFY RISK → CLEAN SAFE → HANDLE DB → REPORT
49+
```
50+
51+
1. Report current `df -h /` capacity.
52+
2. Survey candidate directories with `du -sh`.
53+
3. Classify each as `safe` (cache, regenerable), `ask` (auth/state, old
54+
backups), or `locked` (opencode.db while opencode runs).
55+
4. Delete `safe` targets immediately.
56+
5. For `opencode.db`: stop all opencode processes, then `VACUUM`.
57+
6. Print before/after `df -h /`.
58+
59+
## Risk Classes
60+
61+
| Class | Examples | Action |
62+
|-------|----------|--------|
63+
| safe | `~/Library/Caches/*`, `~/.npm/_cacache`, `~/.bun/install/cache`, `~/.claude/transcripts`, `~/.claude/plugins/cache`, `chrome_pipeline_*`, `webauto-*` | delete without asking |
64+
| ask | `~/.config/sin-solver/authd/state-backups`, old opencode `sessions/` you want kept | ask user first |
65+
| locked | `~/.local/share/opencode/opencode.db` | stop opencode, then `VACUUM` |
66+
67+
## opencode.db Growth Explained
68+
69+
- WAL mode + no `VACUUM` → deleted rows go to the freelist, never returned to OS.
70+
- Hundreds of sessions × thousands of tool-output parts (10–100 KB each) bloat
71+
the live data to ~6 GB; the file reaches 60 GB because the freelist holds
72+
~53 GB.
73+
- `VACUUM` rewrites the file and releases the freelist: 60 GB → ~6 GB.
74+
- **No sessions are lost** — `VACUUM` only reclaims empty pages.
75+
76+
## Critical Rules
77+
78+
- Never delete `~/.local/share/opencode/opencode.db` itself.
79+
- Never `VACUUM` while opencode processes hold the lock — it hangs. Stop them
80+
first (`pkill -9 -f opencode`).
81+
- Never delete `.git`, project source, or `~/.ssh`.
82+
- Always print before/after free space.
83+
84+
## Verification
85+
86+
- [ ] `df -h /` before and after shows reclaimed space.
87+
- [ ] `opencode.db` size reduced after VACUUM (if run).
88+
- [ ] No project source or git history deleted.
89+
- [ ] User confirmed any `ask`-class deletion.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Trigger Phrases — skill-process-disk-clean
2+
3+
## Primary Triggers (always activate)
4+
5+
- "clean disk"
6+
- "free up space"
7+
- "disk full"
8+
- "mac has no space"
9+
- "no space left"
10+
- "storage full"
11+
- "reclaim disk"
12+
- "clean up my mac"
13+
- "why is my disk 97% full"
14+
- "opencode.db is huge"
15+
- "why is opencode 60gb"
16+
- "clean caches"
17+
- "clean yarn cache"
18+
- "clean npm cache"
19+
- "clean bun cache"
20+
- "clean go build cache"
21+
- "vacuum opencode db"
22+
23+
## Context Triggers
24+
25+
- `df -h /` shows capacity > 80%
26+
- `du -sh ~/.local/share/opencode/` reports > 10 GB
27+
- `ls -lh ~/.local/share/opencode/opencode.db` reports > 5 GB
28+
- User complains about build/test failures due to "no space left on device"
29+
30+
## Anti-Triggers (do NOT activate)
31+
32+
- "delete this one file" — single known target, just do it
33+
- "clean production server" — different risk profile, confirm first
34+
- "wipe my whole disk" — never
35+
- "delete node_modules in my project" — that affects source builds, ask first
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Standards — skill-process-disk-clean
2+
3+
## 1. Always measure before and after
4+
5+
Print `df -h /` at the start and end. Report capacity % and GB freed. Never
6+
claim space was reclaimed without proof.
7+
8+
## 2. Classify every target before deleting
9+
10+
| Class | Definition | Action |
11+
|-------|------------|--------|
12+
| safe | Regenerable cache, no user state | delete immediately |
13+
| ask | Auth tokens, state backups, old sessions the user may want | ask first |
14+
| locked | `opencode.db` while opencode holds a write lock | stop processes, then VACUUM |
15+
16+
## 3. Never touch source or secrets
17+
18+
Forbidden under all circumstances:
19+
20+
- `~/.git`, any project `.git`
21+
- `~/.ssh`
22+
- Project source trees
23+
- `~/.local/share/opencode/opencode.db` (the file itself — only VACUUM it)
24+
25+
## 4. opencode.db VACUUM protocol
26+
27+
The DB uses WAL mode. Deleted rows accumulate in the freelist and are never
28+
returned to the OS until `VACUUM`. A 60 GB file may hold only ~6 GB of real
29+
data.
30+
31+
Steps:
32+
33+
1. Stop ALL opencode processes — `VACUUM` hangs while a lock is held:
34+
```bash
35+
pkill -9 -f opencode
36+
sleep 3
37+
```
38+
2. Confirm no opencode process remains: `ps aux | grep opencode | grep -v grep`
39+
3. Run: `sqlite3 ~/.local/share/opencode/opencode.db "VACUUM;"`
40+
4. Takes 2–3 minutes for a 60 GB file. Verify size dropped.
41+
42+
`VACUUM` does **not** delete sessions — it only releases empty freelist pages.
43+
44+
## 5. Safe targets (regenerable, delete without asking)
45+
46+
- `~/Library/Caches/Yarn/`
47+
- `~/Library/Caches/go-build/`
48+
- `~/.npm/_cacache/`
49+
- `~/.bun/install/cache/`
50+
- `~/Library/Caches/trivy/`
51+
- `~/.claude/transcripts/`
52+
- `~/.claude/plugins/cache/`
53+
- `~/.config/chrome_pipeline_*/`
54+
- `~/.config/webauto-oci-debug/`
55+
- `~/.local/share/webauto-nodriver-mcp/`
56+
- `~/.local/share/opencode/log/`
57+
- `~/.local/share/opencode/sessions/` (only if user does not need old session files)
58+
59+
## 6. Ask-class targets (confirm with user)
60+
61+
- `~/.config/sin-solver/authd/state-backups/` — 3-month-old auth state backups
62+
- `~/Library/Containers/` — app data, may contain user documents
63+
64+
## 7. Ensure free space before VACUUM
65+
66+
`VACUUM` rewrites the whole DB. Ensure at least the size of the *real* data
67+
(~6 GB) is free before starting. If not, clean safe caches first.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Workflows — skill-process-disk-clean
2+
3+
## Workflow 1: Full safe cleanup (no opencode restart)
4+
5+
Use when the user wants space now and opencode must keep running.
6+
7+
```
8+
1. df -h /
9+
2. Survey safe targets:
10+
du -sh ~/Library/Caches/Yarn/ ~/.bun/install/cache/ ~/.npm/_cacache/ \
11+
~/Library/Caches/go-build/ ~/Library/Caches/trivy/ \
12+
~/.claude/transcripts/ ~/.claude/plugins/cache/ \
13+
~/.config/chrome_pipeline_*/ ~/.config/webauto-oci-debug/ \
14+
~/.local/share/webauto-nodriver-mcp/ ~/.local/share/opencode/log/
15+
3. rm -rf each safe target
16+
4. df -h / (report GB freed)
17+
```
18+
19+
Note: caches may regenerate while opencode runs (Yarn can regrow to 8 GB).
20+
Re-run as needed; never delete `opencode.db`.
21+
22+
## Workflow 2: opencode.db VACUUM (max reclamation)
23+
24+
Use when capacity is critical and opencode can be stopped.
25+
26+
```
27+
1. df -h /
28+
2. pkill -9 -f opencode
29+
3. sleep 3
30+
4. ps aux | grep opencode | grep -v grep # must be empty
31+
5. sqlite3 ~/.local/share/opencode/opencode.db "VACUUM;"
32+
6. ls -lh ~/.local/share/opencode/opencode.db
33+
7. df -h / (report GB freed — typically 50+ GB)
34+
```
35+
36+
## Workflow 3: Ask-class cleanup
37+
38+
```
39+
1. du -sh ~/.config/sin-solver/authd/state-backups/
40+
2. Present size + age to user
41+
3. On confirmation: rm -rf <target>
42+
4. df -h /
43+
```
44+
45+
## Workflow 4: Diagnostic (no deletion)
46+
47+
When the user just wants to know what is using space:
48+
49+
```
50+
df -h /
51+
du -sh ~/Library/* ~/.local/* ~/.config/* 2>/dev/null | sort -rh | head -25
52+
du -sh ~/.local/share/opencode/opencode.db
53+
sqlite3 ~/.local/share/opencode/opencode.db \
54+
"PRAGMA page_count; PRAGMA page_size; PRAGMA freelist_count;" \
55+
# if freelist_count >> page_count, VACUUM will reclaim most of it
56+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Output Template — skill-process-disk-clean
2+
3+
```markdown
4+
## Disk Cleanup Report
5+
6+
**Before:** <capacity>% used, <free> GB free
7+
**After:** <capacity>% used, <free> GB free
8+
**Reclaimed:** <n> GB
9+
10+
### Deleted (safe)
11+
| Target | Size |
12+
|--------|------|
13+
| ~/Library/Caches/Yarn/ | <n> GB |
14+
| ... | ... |
15+
16+
### opencode.db
17+
- Before: <n> GB
18+
- After: <n> GB (VACUUM)
19+
- Sessions lost: none
20+
21+
### Skipped (ask-class, not confirmed)
22+
| Target | Size | Reason |
23+
|--------|------|--------|
24+
| ~/.config/sin-solver/authd/state-backups/ | <n> MB | awaiting confirmation |
25+
26+
### Next step
27+
Run `VACUUM` after stopping opencode to reclaim the remaining <n> GB.
28+
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Prompt Templates — skill-process-disk-clean
2+
3+
## Template A: Full cleanup
4+
5+
```
6+
Clean my Mac disk. First report current capacity with df -h /.
7+
Then delete all safe caches (Yarn, bun, npm, go-build, trivy,
8+
claude transcripts, claude plugin cache, chrome_pipeline, webauto).
9+
Report GB freed. Do NOT stop opencode.
10+
```
11+
12+
## Template B: Max reclamation (VACUUM)
13+
14+
```
15+
My disk is almost full. Stop all opencode processes, then VACUUM
16+
~/.local/share/opencode/opencode.db to reclaim freelist space.
17+
Report before/after size and free GB. No sessions should be lost.
18+
```
19+
20+
## Template C: Diagnostic only
21+
22+
```
23+
Why is my disk 97% full? Survey ~/Library, ~/.local, ~/.config and
24+
report the top 25 directories by size. Also check opencode.db page
25+
and freelist counts to see if VACUUM would help. Do not delete anything.
26+
```
27+
28+
## Template D: Ask-class
29+
30+
```
31+
Check ~/.config/sin-solver/authd/state-backups/ — report size and
32+
age of each backup. Ask me before deleting anything there.
33+
```

0 commit comments

Comments
 (0)