Migration guide for v2.x users
PAI-OpenCode v3.0 introduces significant architectural improvements:
- Plugin Event Bus — replaces hooks with event-driven architecture
- Hierarchical Skills — Category/Skill structure (replaces flat)
- Agent-based routing — each agent has exactly one model configured in
opencode.json - Security Layer — prompt injection protection
- Installer — CLI-only installation flow
- DB Archiving — automated session management
# Automatic backup created by migration script
bun Tools/migration-v2-to-v3.ts --dry-run
# Or manual backup
cp -r ~/.opencode ~/.opencode-backup-$(date +%Y%m%d)Exit all OpenCode sessions before migrating.
cd /path/to/pai-opencode
bun Tools/migration-v2-to-v3.tsThis will:
- Detect your current version (v2.x vs v3.x)
- Create timestamped backup
- Update skill structure (flat → hierarchical)
- Update MINIMAL_BOOTSTRAP.md paths
Options:
--dry-run # Preview only, no changes
--force # Skip version check
--backup-dir=/path # Custom backup locationbun run skills:validateExpected output: ✅ Validation passed! (0 errors)
v3.0 uses dual-file configuration:
| File | Purpose |
|---|---|
~/.opencode/opencode.json |
OpenCode settings (agent models, MCP) |
~/.opencode/settings.json |
PAI settings (identity, paths) |
The migration script preserves your settings. Verify:
# Confirm no legacy model_tiers / model_tier keys remain (should return nothing)
grep -E 'model_tiers|model_tier' ~/.opencode/opencode.json
cat ~/.opencode/settings.json | grep daidentityopencodeCheck that:
/db-archivecommand works- Plugin events fire (see DB-MAINTENANCE.md)
- Skills load correctly
| v2.x | v3.0 |
|---|---|
| Hooks (hook files) | Event bus (plugin handlers) |
hook.execute |
bus.on('tool.execute.before') |
Impact: If you had custom hooks, port them to plugin handlers:
// v2.x style (hook)
export default {
before: async (context) => { /* ... */ }
}
// v3.0 style (plugin handler)
import { bus } from '../lib/bus';
bus.on('tool.execute.before', async (event) => { /* ... */ });| v2.x | v3.0 |
|---|---|
Flat: skills/SkillName/ |
Hierarchical: skills/Category/SkillName/ |
Impact: Skills are now organized by category. The migration script handles this automatically.
Manual fix if needed:
# Example: move flat skill to category
mkdir -p ~/.opencode/skills/CustomCategory/
mv ~/.opencode/skills/MySkill ~/.opencode/skills/CustomCategory/| v2.x | v3.0 |
|---|---|
CLAUDE.md |
AGENTS.md |
| Single config file | Dual: opencode.json + settings.json |
~/.claude/ |
~/.opencode/ |
Impact: All paths updated automatically.
-
bun run skills:validatepasses -
opencodestarts without errors -
/db-archiveshows DB stats - Plugin events logged (check
~/.opencode/logs/) - Custom skills still work
- No
.claude/references in error messages
# Check for nested directories
ls ~/.opencode/skills/Telos/
# Should see: DashboardTemplate, ReportTemplate, SKILL.md
# Should NOT see: Telos/ (nested)
# Fix nested skills
mv ~/.opencode/skills/Telos/Telos/* ~/.opencode/skills/Telos/
rmdir ~/.opencode/skills/Telos/Telos/# 1. Stop all OpenCode processes
# 2. Retry migration
bun Tools/migration-v2-to-v3.ts --forceCheck skill structure:
# v3.0 requires frontmatter in SKILL.md
head -5 ~/.opencode/skills/CustomCategory/MySkill/SKILL.md
# Should show: --- name: ... description: ... ---If migration fails:
# Restore from backup
cp -r ~/.opencode-backup-YYYYMMDD/* ~/.opencode/
# Or use git (if you track ~/.opencode/)
cd ~/.opencode && git checkout v2.x-branch| Feature | Benefit |
|---|---|
| Plugin Event Bus | Cleaner code, better testability |
| Agent-based routing | Cost optimization via appropriate agent selection |
| Prompt Injection Guard | Security against adversarial attacks |
| Installer (CLI-only) | Deterministic install flow (no GUI path) |
| DB Archiving | Automated session cleanup |
| Hierarchical Skills | Better organization, lazy loading |
See CHANGELOG.md for complete list.
- Issues: GitHub Issues
- Documentation: docs/
- DB Maintenance: docs/DB-MAINTENANCE.md
Migration complete? Run opencode and enjoy v3.0! 🎉