This plan turns the collected code-review and user-review feedback into a test-first path toward a public opencode-profiles release.
- Keep the implementation zsh-only for now.
- Add or update Bats tests before changing behavior.
- Prefer clear CLI behavior over preserving pre-release command shapes.
- Treat installer safety as part of the public API.
- Keep each milestone releasable on its own.
Goal: remove known footguns before adding new CLI features.
Tests first:
ocpexits with status1.ocpprints usage.ocpdoes not print an internal zshshifterror.
Implementation:
- Check
(( $# == 0 ))before assigningprofileand callingshift. - Keep
ocp -handocp --helpbehavior unchanged.
Verification:
npx --yes bats testTests first:
ocp ../outsideis rejected.ocp-new ../outsideis rejected.ocp-copy work ../outsideis rejected.ocp .andocp ..are rejected.ocp <profile> --set-defaultrejects invalid profile names.
Implementation:
- Add
_ocp_valid_profile_name. - Reject empty names,
.,.., and names containing/. - Use the validation in every command that accepts a profile name.
Verification:
zsh -n src/ocp.zsh
npx --yes bats testTests first:
ocp-copydoes not print success whencp -Rfails.ocp-newreturns non-zero if profile directories or config files cannot be created.
Implementation:
- Add
|| return 1tocp -R. - Check
mkdir,opencode.jsonc, andtui.jsoncwrites inocp-new. - Keep error messages stable enough to assert in tests.
Verification:
zsh -n src/ocp.zsh
npx --yes bats testGoal: make it clear which flags belong to ocp and which are passed to OpenCode.
Tests first:
ocp work -- --helppasses--helpto OpenCode.ocp work -- "hello world"preserves the spaced argument.- Shell-sensitive arguments are passed through unchanged where feasible.
Implementation:
- Support an optional
--separator after the profile name. - Avoid test helpers that hide quoting bugs through shell string evaluation.
Verification:
npx --yes bats test/ocp.batsTests first:
ocp --helpincludes pass-through syntax.ocp --helpmentions default-profile behavior.
Implementation:
- Change help to a clearer block:
usage:
ocp <profile> [-- <opencode args...>]
ocp <profile> --set-default
ocp --reset-default
ocp --help
- Add examples for
ocp work -- --help,ocp work --set-default, andocp --reset-default.
Verification:
npx --yes bats test/ocp.batsGoal: make the CLI self-explanatory after installation.
Tests first:
- Lists valid profile names.
- Does not list
.default-profile. - Handles an empty profile directory with a useful message or empty output.
Implementation:
- Reuse
_ocp_profile_names, but filter internal files. - Decide whether to show only valid profiles or all directories. Prefer valid profiles for user-facing output.
Verification:
npx --yes bats test/ocp.batsTests first:
- Prints the default profile when one is configured and valid.
- Clearly says no default profile is set when absent.
- Returns non-zero or warns when the default profile file points to an invalid profile.
Implementation:
- Read
.default-profilethrough existing helpers. - Validate the profile before printing it as active.
Verification:
npx --yes bats test/ocp.batsTests first:
- Reports missing config file.
- Reports missing config directory.
- Reports detected config and TUI files for a valid profile.
- Uses the current default profile when no profile is provided, if available.
Implementation:
- Keep diagnostics plain text and stable.
- Reuse existing config discovery helpers.
Verification:
npx --yes bats test/ocp.batsGoal: settle command names before the first public release.
Current management commands:
ocp-new work
ocp-copy work personalCandidate public shape:
ocp new work
ocp copy work personalRecommended decision:
- Prefer
ocp newandocp copyfor the public CLI. - Keep
ocp-newandocp-copyas aliases only if we want compatibility with the local prototype. - Since there is no public release yet, it is acceptable to remove the standalone commands before
v0.1.0if we want a cleaner API.
Tests first:
ocp new workcreates a profile.ocp copy work personalcopies a profile.- If aliases are kept,
ocp-newandocp-copycontinue to work.
Implementation:
- Extract profile creation and copying into internal helpers.
- Route
ocp newandocp copythrough those helpers.
Verification:
npx --yes bats test/ocp.batsGoal: make installation unsurprising for public users.
Tests first:
- Installer works when
OCP_INSTALL_DIRcontains spaces. .zshrccontains a quoted and sourceable path.
Implementation:
- Generate
source ".../src/ocp.zsh". - Escape embedded backslashes and double quotes.
Verification:
sh -n install.sh
npx --yes bats test/installer.batsTests first:
- Default installer copies files and prints the source line without editing
.zshrc. ./install.sh --write-zshrcedits.zshrconce.- Running
--write-zshrctwice does not duplicate the source line. - A backup is created before modifying an existing
.zshrc.
Implementation:
- Add
--write-zshrc. - Keep
--dry-run. - Update README installation instructions.
Verification:
sh -n install.sh
npx --yes bats test/installer.batsGoal: make the README accurate for a first-time public user.
Updates:
- Replace the placeholder GitHub URL once the owner is known.
- Explain that installation sources a zsh file, not a standalone binary.
- Explain that
opencodebecomes a shell function wrapper after sourcing. - Add examples for where to put agents, commands, plugins, and TUI config.
- Document
ocp list,ocp current, andocp doctoronce implemented. - Clarify default-profile behavior with examples.
- Document pass-through args with
--. - Document uninstall steps for both installed files and
.zshrcsource lines.
Verification:
npx --yes prettier --write README.md CHANGELOG.md CONTRIBUTING.md CODE_REVIEW_FEEDBACK.md .github/workflows/test.yml
npx --yes bats testGoal: prepare v0.1.0 for a public repository.
Checklist:
- All Bats tests pass locally and in CI.
- Shell syntax checks pass in CI.
- README uses the real repository URL.
CODE_REVIEW_FEEDBACK.mdfindings are either fixed or explicitly deferred.- Installer behavior is safe by default.
- No local shell config or secrets exist in repository history.
- The GitHub token found in the original local zshrc has been rotated before publication.
Verification:
zsh -n src/ocp.zsh
sh -n install.sh
npx --yes prettier --write README.md CHANGELOG.md CONTRIBUTING.md CODE_REVIEW_FEEDBACK.md .github/workflows/test.yml
npx --yes bats test- Fix correctness and safety issues.
- Improve argument handling and help.
- Add
ocp listandocp current. - Decide the
ocp newandocp copycommand shape. - Add
ocp doctor. - Harden the installer.
- Update docs and release metadata.