Overview
Therehash command rebuilds .opencode/agents/.manifest-lock.json by scanning all installed agent files and recomputing their SHA-256 hashes. This trusts the current disk state as the new baseline.
Use this to:
- Accept manual edits as the new baseline
- Recover from lock file corruption
- Rebuild lock file after git pull/merge
- Create lock file from pre-existing agents
How It Works
- Scan disk — Finds all
.mdfiles in.opencode/agents/ - Compute hashes — Calculates SHA-256 for each file
- Match manifest — Links files to agent entries in
manifest.json - Write lock — Overwrites
.manifest-lock.jsonwith new hashes - Report — Shows count of rehashed agents
Example Usage
Basic rehash
After manual edits
You editedtypescript-pro.md to customize behavior:
After git pull
Team member committed agent updates to git:Recover from lock file corruption
If.manifest-lock.json was deleted or corrupted:
Security Implications
When to Use
After manual customization
After manual customization
You edited agent files to customize behavior for your project. Run
rehash to make verify stop reporting mismatches.After git operations
After git operations
After
git pull, git merge, or git checkout that modifies agent files, run rehash to sync lock file with new state.Recovering from lock file loss
Recovering from lock file loss
If
.manifest-lock.json was deleted (e.g., not committed to git), run rehash to rebuild it from installed agents.Permission changes
Permission changes
After manually editing an agent’s
permission: block, run rehash to avoid false positives from verify.What Gets Rehashed
Rehash scans all.md files in .opencode/agents/:
manifest.json are ignored — rehash only processes agents that exist in the upstream registry.
Exit Codes
| Code | Meaning |
|---|---|
0 | Lock file rebuilt successfully |
Alternatives
Instead ofrehash, you can:
-
Reinstall with —force — Downloads fresh copies and updates lock:
-
Use update — Reinstalls only agents with hash mismatches:
rehash when you want to keep current modifications. Use install --force or update when you want to restore upstream versions.
Related Commands
- verify — Check lock file integrity
- update — Reinstall agents with hash mismatches
- install — Install/reinstall agents
Lock File Format
After rehash,.manifest-lock.json contains:
sha256 field is what verify checks against.
See Also
- Lock System — Deep dive into lock file architecture
- Permissions — How permission modifications affect hashes