{"id":50483306,"url":"https://github.com/whtsky/ocgc","last_synced_at":"2026-06-01T19:30:58.715Z","repository":{"id":351561217,"uuid":"1211513476","full_name":"whtsky/ocgc","owner":"whtsky","description":"OpenCode Garbage Collector. Analyze and reclaim storage used by OpenCode sessions, diffs, and snapshots","archived":false,"fork":false,"pushed_at":"2026-04-15T13:42:00.000Z","size":389,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-15T15:34:16.918Z","etag":null,"topics":["cleanup","cli","disk-space","garbage-collector","opencode","python","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whtsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-15T13:19:26.000Z","updated_at":"2026-04-15T14:20:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/whtsky/ocgc","commit_stats":null,"previous_names":["whtsky/ocgc"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/whtsky/ocgc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Focgc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Focgc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Focgc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Focgc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whtsky","download_url":"https://codeload.github.com/whtsky/ocgc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whtsky%2Focgc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33790692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cleanup","cli","disk-space","garbage-collector","opencode","python","sqlite"],"created_at":"2026-06-01T19:30:57.111Z","updated_at":"2026-06-01T19:30:58.710Z","avatar_url":"https://github.com/whtsky.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ocgc: OpenCode Garbage Collector\n\nAnalyze and reclaim storage used by [OpenCode](https://github.com/anomalyco/opencode) sessions, diffs, and snapshots.\n\nOpenCode stores sessions in a SQLite file that grows without limit and has [no built-in cleanup](https://github.com/anomalyco/opencode/issues/4980). It also writes session diffs and git snapshots to disk. `ocgc` shows where the space goes and reclaims it.\n\n## Screenshots\n\n`ocgc status`\n\n![status](screenshots/status.png)\n\n`ocgc analyze`\n\n![analyze](screenshots/analyze.png)\n\n`ocgc purge --clean-orphans --clean-snapshots --older-than 14d --dry-run`\n\n![purge](screenshots/purge.png)\n\n## Quick start\n\nCopy this to your AI agent:\n\n```\nRead https://raw.githubusercontent.com/whtsky/ocgc/refs/heads/main/README.md and help me garbage collect OpenCode storage.\n```\n\n## Install\n\n```bash\nuv tool install ocgc\n```\n\nOr with pip:\n\n```bash\npip install ocgc\n```\n\n## Usage\n\n```bash\n# Dashboard: DB size, session breakdown, storage by part type\nocgc status\n\n# List sessions sorted by size\nocgc sessions --sort size --limit 20\n\n# Deep analysis: top sessions, growth rate, root vs subagent\nocgc analyze\n\n# Preview what a purge would do\nocgc purge --older-than 14d --dry-run\n\n# Delete subagent sessions older than a week\nocgc purge --subagents --older-than 7d\n\n# Strip reasoning tokens only (biggest space win, ~77% of storage)\nocgc purge --strip-reasoning\n\n# Other purge options\nocgc purge --larger-than 50M\nocgc purge --keep-latest 50\nocgc purge --session ses_abc123\n\n# Clean up orphan session diff files (no matching session in DB)\nocgc purge --clean-orphans\n\n# Delete all snapshot directories\nocgc purge --clean-snapshots\n\n# Reclaim disk space after purging\nocgc vacuum\n```\n\nMultiple purge flags combine with AND. `--strip-reasoning` changes the action from deleting sessions to removing reasoning parts (from matching sessions, or all sessions if no other filters are given). `--clean-orphans` and `--clean-snapshots` run independently before any session purge. `--dry-run` previews without touching anything. `--force` skips the confirmation prompt.\n\n## Filesystem storage\n\nBeyond the SQLite database, OpenCode stores data on the filesystem:\n\n- Session diffs (`~/.local/share/opencode/storage/session_diff/`): one JSON file per session containing full file contents. Cleaned automatically when sessions are purged.\n- Snapshots (`~/.local/share/opencode/snapshot/`): git object packs for each project. Use `--clean-snapshots` to delete.\n- Tool output (`~/.local/share/opencode/tool-output/`): small files from tool invocations. Shown in stats but no cleanup needed.\n\n`ocgc status` and `ocgc analyze` show sizes for all three directories. `analyze` also reports orphan session diff files (files with no matching session in the DB).\n\n## Safety\n\n`status`, `sessions`, and `analyze` are read-only. `purge` asks for confirmation before deleting. `ocgc` warns if OpenCode is running.\n\n## Custom database path\n\n```bash\nexport OCGC_DB_PATH=/path/to/opencode.db\nocgc status\n```\n\nDefault: `~/.local/share/opencode/opencode.db`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhtsky%2Focgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhtsky%2Focgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhtsky%2Focgc/lists"}