feat(registry): Add OCX profile preservation for worktrees#80
Open
feat(registry): Add OCX profile preservation for worktrees#80
Conversation
When OpenCode is launched via `ocx opencode -p <profile>`, the worktree plugin now automatically preserves the profile context when spawning new worktrees. Changes: - Add OCX_CONTEXT, OCX_BIN, OCX_PROFILE env vars to ocx opencode command - Add parseOcxContext() and buildWorktreeCommand() helpers to worktree plugin - Proper shell escaping with quoted values for safety - Fail loud if OCX context detected but binary missing This ensures profile settings, instructions, and configuration follow users into worktrees when using OCX.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
ocx | a6b7c7e | Jan 22 2026, 06:11 PM |
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="workers/kdco-registry/files/plugin/worktree.ts">
<violation number="1" location="workers/kdco-registry/files/plugin/worktree.ts:84">
P2: Double-escaping issue: values are pre-escaped with `escapeBash()` and quoted here, but `terminal.ts` will escape the entire command string again. When the result is placed in a bash script in an unquoted context, the escaped quotes (`\"`) don't prevent word splitting on spaces. Paths or profile names with spaces will break.
Consider removing the escaping here and letting the terminal code handle it, or using single quotes which survive the transformation:</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #80 +/- ##
=======================================
Coverage 53.60% 53.60%
=======================================
Files 36 36
Lines 2722 2722
=======================================
Hits 1459 1459
Misses 1263 1263 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Change from command string to argv array for spawn commands - Add argvToBashCommand() and argvToBatchCommand() with platform-specific escaping - Fix Windows batch escaping: reject newlines, escape embedded quotes - Add null byte validation for bash arguments - Trim OCX_PROFILE for consistency - Remove local .opencode/plugin/worktree.ts (registry is source of truth)
There was a problem hiding this comment.
1 issue found across 3 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="workers/kdco-registry/files/plugin/worktree/terminal.ts">
<violation number="1" location="workers/kdco-registry/files/plugin/worktree/terminal.ts:65">
P2: Incorrect escaping for quoted batch arguments. `escapeBatch()` is designed for unquoted contexts (adds `^&`, `^<`, etc.), but here it's applied inside double quotes where metacharacters don't need caret escaping. Only `%` needs escaping as `%%` inside quotes. This will cause arguments containing `&`, `<`, `>`, `|`, or `^` to include incorrect literal caret characters.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
escapeBatch() is for unquoted contexts and adds caret escapes. Inside double quotes, only % and " need escaping - metacharacters like &, <, >, |, ^ are already protected by the quotes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When OpenCode is launched via
ocx opencode -p <profile>, the worktree plugin now automatically preserves the profile context when spawning new worktrees.Changes
OCX CLI (
packages/cli/src/commands/opencode.ts)resolveOcxBin()helper to find OCX binary pathOCX_CONTEXT=1- Marker that OCX launched this sessionOCX_BIN=<path>- Absolute path to OCX binaryOCX_PROFILE=<name>- Resolved effective profileWorktree Plugin (
workers/kdco-registry/files/plugin/worktree.ts,.opencode/plugin/worktree.ts)parseOcxContext()to detect OCX context from env varsbuildWorktreeCommand()to generate correct spawn commandDocumentation
AGENTS.mdwith new env vars and "Worktree Profile Preservation" sectionfacades/opencode-worktree/README.mdwith "OCX Profile Support" sectionBehavior
opencodeopencode --session <id>ocx opencodeocx opencode --session <id>ocx opencode -p workocx opencode -p work --session <id>Multiple simultaneous sessions with different profiles work independently (env vars are process-scoped).
Testing
Summary by cubic
Preserves OCX profile context when spawning new worktrees. If you launched OpenCode via ocx opencode -p , worktrees now start with the same profile using the OCX binary.
Written for commit a6b7c7e. Summary will update on new commits.