Repository navigation
OpenShell SDK Migration [Spec + Impl] - #7
Conversation
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
Assisted-By: 🤖 Claude Code
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (24)
📝 WalkthroughWalkthroughReplaces the cc-deck OpenShell CLI wrapper with the ChangesOpenShell SDK Migration
Zellij Sort Update
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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 |
Applied fixes from bot review comments: - Comment #3496496758: check ExecResult.ExitCode in credential injection - Comment #3496496766: update plan.md PushBytes to match temp-file implementation - Comment #3496496768: update spec.md PushBytes assumption to match implementation Assisted-By: 🤖 Claude Code
There was a problem hiding this comment.
Pull request overview
Migrates cc-deck’s OpenShell integration from a CLI wrapper (os/exec + output parsing) to the OpenShell Go SDK (github.com/rhuss/openshell-sdk-go), updating workspace lifecycle, file transfer, credential injection, and tests to use the SDK’s typed clients and fake client. This also adds a full spec/plan/task set for the migration and tweaks zellij sidebar sorting to prioritize recency within tiers.
Changes:
- Replace OpenShell CLI subprocess wrapper with SDK-backed
v1.ClientInterfaceusage across workspace lifecycle + data channel operations. - Update credential injection + unit tests to use SDK Exec/Files clients (and fake client where possible).
- Add migration spec artifacts and update README/CLAUDE.md references; adjust zellij plugin sorting behavior.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| specs/075-openshell-sdk-migration/tasks.md | Task breakdown for the SDK migration work. |
| specs/075-openshell-sdk-migration/spec.md | Feature spec, acceptance scenarios, requirements, and success criteria. |
| specs/075-openshell-sdk-migration/review-findings.md | Captures review findings and resolutions for the migration. |
| specs/075-openshell-sdk-migration/REVIEW-CODE.md | Automated review/compliance report for the migration. |
| specs/075-openshell-sdk-migration/research.md | Research notes on mapping types/APIs and testing constraints. |
| specs/075-openshell-sdk-migration/plan.md | Implementation plan and structure/risk notes. |
| specs/075-openshell-sdk-migration/data-model.md | Type mapping between prior wrapper types and SDK types. |
| specs/075-openshell-sdk-migration/checklists/requirements.md | Spec-quality checklist for the migration spec. |
| README.md | Documents SDK usage and (currently) local dev setup guidance. |
| cc-zellij-plugin/src/controller/actions.rs | Changes session sorting to order by activity tier then recency. |
| cc-deck/internal/ws/openshell.go | Workspace lifecycle migrated to SDK (sandboxes/providers/exec) + WaitReady usage. |
| cc-deck/internal/ws/openshell_test.go | Workspace tests updated to use SDK fake client and phase override wrapper. |
| cc-deck/internal/ws/channel_openshell.go | Data channel migrated to SDK Files client; PushBytes now uses temp-file + upload. |
| cc-deck/internal/openshell/iface.go | Replaces old custom Client interface with NewSDKClient factory. |
| cc-deck/internal/openshell/credentials.go | Credential env-var/file injection updated to SDK Exec/Files clients. |
| cc-deck/internal/openshell/credentials_test.go | Updates credential tests to use SDK client interfaces/mocks. |
| cc-deck/internal/openshell/client.go | Removes CLI wrapper implementation; keeps GatewayConfig and adds SDK config mapping. |
| cc-deck/internal/openshell/client_test.go | Tests updated for NewSDKClient and GatewayConfig.ToSDKConfig(). |
| cc-deck/internal/credential/transport.go | Credential transport interface and implementation updated for SDK-style operations. |
| cc-deck/internal/credential/transport_test.go | Updates mocks/tests for new credential transport interface. |
| cc-deck/go.mod | Adds SDK dependency and grpc/genproto indirects; includes a local-path replace directive. |
| cc-deck/go.sum | Adds checksums for new transitive dependencies. |
| cc-deck/CLAUDE.md | Updates referenced plan document path to the new spec/plan. |
| brainstorm/27-openshell-sdk-migration.md | Brainstorm doc for the SDK migration approach and rationale. |
| brainstorm/00-overview.md | Updates brainstorm index/overview with the new thread. |
Comments suppressed due to low confidence (1)
cc-deck/internal/openshell/credentials.go:318
InjectEnvVarsbuildsexportlines using%q, which wraps values in double quotes. Double-quoted values still allow command substitution (e.g.$(...)/ backticks), so a value containing those characters would execute code when the shell sources.bashrc/.zshrc. Also, the function currently always returnsnileven if every injection attempt fails, so callers can't detect a complete failure.
func InjectEnvVars(ctx context.Context, client v1.ClientInterface, sandboxID string, vars map[string]string) error {
for k, v := range vars {
exportLine := fmt.Sprintf("export %s=%q", k, v)
for _, rcFile := range []string{".bashrc", ".zshrc"} {
cmd := []string{"bash", "-c", fmt.Sprintf("echo %q >> /sandbox/%s", exportLine, rcFile)}
result, err := client.Exec().Run(ctx, sandboxID, cmd)
if err != nil {
log.Printf("WARNING: failed to set %s in %s: %v", k, rcFile, err)
} else if result != nil && result.ExitCode != 0 {
log.Printf("WARNING: failed to set %s in %s: exit code %d", k, rcFile, result.ExitCode)
}
}
}
return nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sigs.k8s.io/yaml v1.6.0 // indirect | ||
| ) | ||
|
|
||
| replace github.com/rhuss/openshell-sdk-go => ../../openshell-sdk-go |
| For local development, `cc-deck/go.mod` contains a `replace` directive pointing to the local SDK checkout: | ||
|
|
||
| ``` | ||
| replace github.com/rhuss/openshell-sdk-go => ../../openshell-sdk-go | ||
| ``` |
Applied fixes from bot review comments: - Comment #3496585380: add remotePath validation to PushBytes Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3496656187: propagate stream errors and exit codes from Exec() Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3496716156: route stderr chunks to os.Stderr in streaming exec Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3496998666: use errors.Is(streamErr, io.EOF) instead of string comparison Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3498025432: fail sandbox creation if policy loading fails - Comment #3498019275: split sandbox command string for args support - Comment #3498025450: pass cancellable context to Interactive() - Comment #3498019319: set w.attach to nil after normal detach - Comment #3498025422: fix markdown heading levels in idea-inbox Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3498088741: fix misplaced doc comment on resolveSandboxCommand Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3498148823: map L7 allow rules in policy conversion Assisted-By: 🤖 Claude Code
Replace cc-deck's OpenShell CLI wrapper (os/exec + output parsing) with the OpenShell Go SDK (github.com/rhuss/openshell-sdk-go v0.2.2). All sandbox lifecycle operations now use gRPC via the SDK directly. Key changes: - Remove cliClient, execCLI, parseSandboxName, parseSandboxState, stripANSI - Use SDK sub-clients: Sandboxes(), Providers(), Exec(), Files() - Implement attach I/O forwarding via InteractiveSession with terminal raw mode, SIGWINCH handling, and bidirectional io.Copy - Pass initial security policy as structured SandboxPolicy type - Map L7 allow rules in policy conversion - Populate FromExisting provider credentials from detected env vars - Use plaintext gRPC (TLS.Insecure) for non-TLS gateway connections - Route stderr chunks to os.Stderr in streaming exec - Propagate stream errors and exit codes The git channel (ext::openshell transport) still requires the CLI binary. Assisted-By: 🤖 Claude Code
ed89e9c to
134eee7
Compare
| if extractErr != nil { | ||
| return cfg, fmt.Errorf("extracting policy from image %s: %w\n\nTo provide the policy file manually, use the --policy flag", cfg.Image, extractErr) | ||
| log.Printf("WARNING: could not extract policy from image %s: %v", cfg.Image, extractErr) | ||
| return cfg, nil |
There was a problem hiding this comment.
🚩 OCI extraction failure downgraded from hard error to warning
At cc-deck/internal/ws/openshell.go:136-138, when OCI policy extraction fails, the old code returned a hard error with a suggestion to use --policy. The new code logs a WARNING and returns (cfg, nil) — meaning sandbox creation proceeds without a policy. This is a significant behavioral change: previously, if you had an image but no explicit policy and the image couldn't be reached, creation would fail loudly. Now it silently proceeds without a policy, which could result in a sandbox with no security policy applied. The test at cc-deck/internal/ws/openshell_test.go:514-518 confirms this is intentional. Whether this is correct depends on whether the SDK/gateway has a default policy — if the gateway rejects sandbox creation without a policy, this will fail later with a less helpful error.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Implementation of OpenShell SDK Migration.
Replace cc-deck's OpenShell CLI wrapper (
os/exec+ output parsing) with the OpenShell Go SDK (github.com/rhuss/openshell-sdk-go). All sandbox lifecycle operations (create, attach, delete, exec, upload, download, provider management) now use gRPC via the SDK directly, eliminating theopenshellCLI binary as a runtime dependency.The git channel (
ext::openshelltransport) still requires the CLI binary forgit push/fetchoperations.Artifacts
specs/075-openshell-sdk-migration/spec.mdspecs/075-openshell-sdk-migration/plan.mdspecs/075-openshell-sdk-migration/tasks.mdAssisted-By: 🤖 Claude Code
Summary by CodeRabbit