Conversation
WalkthroughA new bash installer script is introduced that syncs content from three source directories (agents, commands, skills) into an OpenCode config directory using a four-phase flow: planning, conflict resolution, summary presentation, and file execution with checksum-based change detection. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Script as install-opencode.sh
participant FS as File System
User->>Script: Execute script
Note over Script: Phase 1: Scan & Plan
Script->>FS: Read source directories
Script->>FS: Calculate SHA-256 checksums
Script->>Script: Build action plan (new/skip/prompt)
Note over Script: Phase 2: Resolve Conflicts
loop For changed files
Script->>User: Prompt: overwrite or skip?
User-->>Script: User decision
Script->>Script: Record final action
end
Note over Script: Phase 3: Present Summary
Script->>User: Display planned changes<br/>(new, overwrite, skip)
Script->>User: Note about opencode.json
Note over Script: Phase 4: Execute
Script->>FS: Create target directories
loop For each file
alt File action
Script->>FS: Copy file
Script->>User: Report (copied/overwritten/skipped)
else Error
Script->>User: Report error
end
end
Script->>User: Installation complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
install-opencode.sh (1)
107-108: Separate variable declaration from assignment (SC2155 best practice).Shellcheck recommends declaring and assigning variables separately to avoid masking return values. While this specific case is low-risk, adopting the pattern improves consistency:
- local source_checksum=$(calculate_checksum "$source_file") - local target_checksum=$(calculate_checksum "$target_file") + local source_checksum + source_checksum=$(calculate_checksum "$source_file") + local target_checksum + target_checksum=$(calculate_checksum "$target_file")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
install-opencode.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
install-opencode.sh
[warning] 79-79: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 107-107: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 108-108: Declare and assign separately to avoid masking return values.
(SC2155)
[warning] 138-138: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 138-138: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 203-203: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 203-203: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 203-203: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 203-203: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
🔇 Additional comments (7)
install-opencode.sh (7)
96-119: Excellent file handling with null-byte delimiters.The use of
find ... -print0withIFS= read -r -d ''correctly handles filenames with spaces, newlines, and special characters. This is a best practice implementation.
44-67: Well-structured user interaction with proper directory handling.The prompts correctly use
-n 1 -rflags for single-character input, handle tilde expansion, and include confirmation before creating directories. The directory creation logic properly checks existence, prompts for confirmation, and handles creation errors.
285-317: Solid Phase 4 execution logic with comprehensive error handling.The file copy operations properly:
- Skip marked files (line 287-289)
- Create required directories with error recovery (lines 292-299)
- Copy files with inline error handling (line 305)
- Track successes and errors separately (lines 306-316)
The implementation correctly continues processing remaining files after errors, which is appropriate for an installer script.
73-129: Phase 1 scanning implementation is correct and handles missing directories gracefully.The scanning logic properly detects changes via SHA-256 checksum comparison and categorizes actions appropriately. Skipping non-existent source directories with warnings is reasonable behavior for an installer.
131-186: Phase 2 conflict resolution handles user input robustly with proper loop validation.The implementation correctly:
- Prompts only for changed files (line 141)
- Validates user input in a loop (lines 151-170)
- Updates decisions to a new temp file (line 175)
- Replaces the original with the updated decisions (line 179)
- Tracks and reports conflict count (lines 142, 181-185)
188-264: Phase 3 summary display is informative with appropriate user guidance.The phase correctly:
- Categorizes and sorts all planned changes (lines 205-223)
- Displays each category with clear formatting (lines 226-250)
- Checks for OpenCode configuration files (lines 252-264)
- Provides helpful next-steps guidance
338-348: Next steps section provides clear post-installation guidance.The final instructions correctly guide users to enable the opencode-skills plugin and restart OpenCode. The optional AGENTS.md creation step is helpful.
|
|
||
| # Create temp file to store file metadata | ||
| TEMP_FILE=$(mktemp) | ||
| trap "rm -f $TEMP_FILE" EXIT |
There was a problem hiding this comment.
Fix cumulative trap statements and use single quotes to delay variable expansion.
The trap statement at line 79 is replaced (not cumulative) at line 138, causing $TEMP_FILE cleanup to be lost. Additionally, Shellcheck warns (SC2064) that variables should be quoted to prevent expansion at definition time rather than exit time.
Each trap statement should use single quotes and include all cleanup files:
- trap "rm -f $TEMP_FILE" EXIT
+ trap 'rm -f "$TEMP_FILE"' EXITThen at line 138, replace (not supplement) with all files:
- trap "rm -f $TEMP_FILE $TEMP_ACTIONS" EXIT
+ trap 'rm -f "$TEMP_FILE" "$TEMP_ACTIONS"' EXITAnd at line 203:
- trap "rm -f $TEMP_FILE $TEMP_NEW $TEMP_OVERWRITE $TEMP_SKIP" EXIT
+ trap 'rm -f "$TEMP_FILE" "$TEMP_NEW" "$TEMP_OVERWRITE" "$TEMP_SKIP"' EXITAlso applies to: 138-138, 203-203
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 79-79: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
| NEW_COUNT=0 | ||
| OVERWRITE_COUNT=0 | ||
| SKIP_COUNT=0 |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Initialize SKIP_COUNT variable with other count variables.
SKIP_COUNT is only assigned during the Phase 3 loop, while NEW_COUNT and OVERWRITE_COUNT are properly initialized beforehand. With set -u enabled (line 2), uninitialized variables cause errors. For consistency and safety, initialize SKIP_COUNT with the others:
# Count actions
NEW_COUNT=0
OVERWRITE_COUNT=0
+ SKIP_COUNT=0And remove the implicit initialization at line 219:
- SKIP_COUNT=$((SKIP_COUNT + 1))
+ SKIP_COUNT=$((SKIP_COUNT + 1)) # Now explicitly initialized aboveAlso applies to: 219-219
🤖 Prompt for AI Agents
In install-opencode.sh around lines 195 to 197, SKIP_COUNT is not initialized
alongside NEW_COUNT and OVERWRITE_COUNT which causes failures under set -u; add
SKIP_COUNT=0 to that block to initialize it, and remove the later implicit
initialization at line 219 so the variable is only set once at the top.
|
Thank you! Great to see opencode support being added. It would help to update README.md with instructions for getting started with the script. |
|
Haha i did the same thing. I'll test yours and see if there's anything I did different which you might be able to |
|
So I tried this, and it seems to break because Opencode is stricter with YAML formatting for the agents. This is how Claude put it after I fixed it:
Maybe your script should auto parse any agents which exist Edit: Tested using Opencode 1.0.80 Edit 2: Moreover, the code reviewer Edit 3: I see you already noticed this in #115. But the model problem still remains |
the hacky thing to do would be to strip the model setting, or map them to opencode model names. however, for this "dumb" installer it would be better if this was abstracted upstream before the installers for claude/codex/opencode see it. this is a bigger change that we'd need @obra to weigh in on. |
|
Thanks so much for this PR. Have any of the folks here looked at what it'd take to do it as a 'proper' opencode plugin using their install and extension mechanisms? I worry a little bit about a copy-to-install kind of workflow. The skill suite does need to be slightly better abstracted to support non-claude-code models and harnesses. For Codex, specifically with the GPT5 series models, we can get away with a custom bootstrap with a mapping table, but the right thing is probably to make all the skills cleaner and have a mapping table for each platform. I think the code-reviewer subagent should probably be retired in favor of 'generic subagent with prompting' The other opencode PR that reuses most of the codex bootstrap looked generally pretty good to me, but also I've only been playing with opencode for the past couple of days. |
|
I just landed a full opencode implementation (as a plugin, with tools). Install instructions are in the README. I'd love to know how it works for folks. (I'm closing out this PR for now) |
This installer script copies the skills, agents and commands into opencode's expected dir structure.
When used with https://github.com/malhashemi/opencode-skills the result is a superpowers-capable opencode.
It is meant to be run once, and then whenever the superpowers repo is updated with a
git pull. The installer will copy new skills if they are found and prompt to overwrite or ignore skills which have changed.Motivation and Context
I wanted to use superpowers in opencode.
How Has This Been Tested?
Tested with both a fresh opencode install and an existing install.
Breaking Changes
They will need to use the opencode-skills plugin which is mentioned by the installer.
Types of changes
Checklist
Summary by CodeRabbit