Skip to content

bug(add): -p flag installs to .opencode/ instead of flattened profile path #82

@kdcokenny

Description

@kdcokenny

Description

When using ocx add <component> -p <profile>, component files are incorrectly installed to .opencode/plugin/ instead of the flattened plugin/ path that profiles should use.

Expected Behavior

Profile installations should use flattened paths:

  • ~/.config/opencode/profiles/<name>/plugin/component.ts
  • ~/.config/opencode/profiles/<name>/opencode.jsonc

Actual Behavior

Files are installed with .opencode/ prefix:

  • ~/.config/opencode/profiles/<name>/.opencode/plugin/component.ts
  • ~/.config/opencode/profiles/<name>/.opencode/opencode.jsonc

Root Cause

In packages/cli/src/utils/update-opencode-config.ts, the updateOpencodeJsonConfig() function at line ~248 hardcodes the .opencode/ prefix via LOCAL_CONFIG_DIR, ignoring the isFlattened flag.

The handleNpmPlugins() function likely has the same issue.

Suggested Fix

  1. Add isFlattened parameter to findOpencodeConfig() and updateOpencodeJsonConfig()
  2. When isFlattened is true, don't prepend .opencode/ to paths
  3. Ensure all profile-mode code paths pass isFlattened: true

Reproduction

# Create a profile
ocx profile add test-profile

# Add a component with -p flag
ocx add kdco/worktree -p test-profile

# Check where files were installed
ls -la ~/.config/opencode/profiles/test-profile/
ls -la ~/.config/opencode/profiles/test-profile/.opencode/  # Should not exist

Related

Found while testing #80 (OCX-aware worktree feature).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions