Skip to content

Hide workspace parent flag from worktree create CLI - #5743

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/enable-child-worktrees
Jun 19, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/enable-child-worktrees

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep orca worktree create on the public --parent-worktree path and remove --parent-workspace from the CLI contract entirely.
  • Route --parent-worktree folder:<id>, worktree:<id>, id:folder:<id>, and id:worktree:<id> through the existing internal parentWorkspace lineage path.
  • Preserve --parent-worktree active/current from top-level folder workspaces by resolving those folder pseudo-worktree ids back onto the internal parentWorkspace path.
  • Keep traditional worktree selectors on parentWorktree, preserve inferred ORCA_WORKSPACE_ID / ORCA_WORKTREE_ID parent behavior, and scrub public hidden-flag guidance from create/help/runtime errors.
  • Update the repo-owned skills/orca-cli/SKILL.md source so installed agent-facing guidance matches the new public worktree-create flow and does not advertise stale worktree/workspace wording for lineage.

Brennan YOLO Lite Evidence

  • Design doc: .tmp/brennan-yolo-lite/cli-worktree-parent-selector-design.md (scratch only, not included in the PR).
  • Design review: Fermat completed auto-design-review-fix; final design had no P0/P1 issues.
  • Implementation: Schrodinger implemented the reviewed design; no intentional deviations beyond extracting create parent selector logic to keep worktree.ts under max-lines.
  • Completeness verification: Helmholtz initially caught public help wording leaks; after fixes, rechecked and marked complete.
  • Code review loop:
    • Round 1: Avicenna reported unrelated branch drift outside this CLI cleanup; Wegener found two actionable leaks: bare hidden-alias errors and runtime parent-workspace wording.
    • Fixes applied: runtime/user-facing lineage messages now use parent selector/context/worktree wording; later follow-up removed the hidden alias entirely so --parent-workspace is unknown.
    • Round 2: McClintock and Hooke returned clean.
    • Post-refactor staged round: Dewey and Halley found the extracted module was untracked; after staging it, Anscombe and Peirce reviewed git diff --cached and both returned clean.
    • Skill follow-up: Pasteur reviewed skills/orca-cli/SKILL.md and returned clean.
    • Alias-removal follow-up: Goodall returned clean; Kuhn found the --parent-worktree active/current folder-workspace edge. The edge is now fixed and covered by regression tests; Godel, Dalton, and Socrates returned clean on the updated branch.
  • brennan-test-changes: Euler verdict was land; validation covered CLI help, parent selector routing, runtime/schema wording, and the extracted selector module.

Tests

  • pnpm run typecheck
  • pnpm run typecheck:cli
  • pnpm run build:cli
  • git diff --check
  • git diff --cached --check
  • node config/scripts/verify-cli-bin.mjs --run-help
  • node out/cli/index.js worktree create --help confirmed create exposes --parent-worktree with folder/worktree context keys and no --parent-workspace
  • node out/cli/index.js worktree set --help confirmed set keeps ordinary worktree selectors and does not advertise folder/worktree context keys
  • node out/cli/index.js worktree create --repo id:repo-1 --name child --parent-workspace folder:folder-1 --json rejects --parent-workspace as an unknown flag before runtime dispatch
  • Live compiled CLI explicit-parent smoke against running Orca runtime: node out/cli/index.js worktree create --repo id:de1c307b-d4b8-4b2d-aaa2-98f801372829 --name cli-parent-validation-1781829749 --parent-worktree active --setup skip --comment "manual compiled CLI validation; safe to remove" --json
  • Explicit-parent smoke result confirmed parentWorktreeId and workspaceLineage.parentWorkspaceKey pointed at the current stargazer worktree; worktree show on the parent listed the child before cleanup
  • Live compiled CLI inferred-parent smoke against running Orca runtime: node out/cli/index.js worktree create --repo id:de1c307b-d4b8-4b2d-aaa2-98f801372829 --name cli-inferred-parent-validation-1781830062 --setup skip --comment "manual inferred-parent CLI validation; safe to remove" --json
  • Inferred-parent smoke result confirmed the default no-parent-flag path set parentWorktreeId, lineage.capture.source: cwd-context, lineage.capture.confidence: inferred, and workspaceLineage.parentWorkspaceKey to the current stargazer worktree; worktree show on the parent listed the child before cleanup
  • Live smoke cleanup: removed both validation worktrees with node out/cli/index.js worktree rm ... --force --json; parent child list empty afterward; validation directories and branches absent
  • rg -n "parent-workspace|worktree/workspace|checkout/workspace|current workspace|child workspace|spawn codex/claude in a workspace|Orca worktree/workspace" skills/orca-cli/SKILL.md returned no matches
  • rg -n "hiddenFlags|--parent-workspace|parent-workspace|compatibility alias" src skills docs config tests --glob '!node_modules' returns only negative CLI tests for the removed flag
  • pnpm exec oxlint src/cli/args.ts src/cli/format.test.ts src/cli/handlers/worktree-create-parent-selector.ts src/cli/handlers/worktree-lineage-summary.ts src/cli/handlers/worktree.ts src/cli/help.ts src/cli/index.test.ts src/cli/specs/core.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/orca-runtime.ts src/main/runtime/rpc/errors.test.ts src/main/runtime/rpc/methods/worktree-schemas.ts src/main/runtime/rpc/methods/worktree.test.ts skills/orca-cli/SKILL.md
  • pnpm exec vitest run --config config/vitest.config.ts src/cli/index.test.ts -t "parent-worktree" (1 file, 6 matching tests)
  • pnpm exec vitest run --config config/vitest.config.ts src/cli/index.test.ts src/cli/format.test.ts src/main/runtime/rpc/errors.test.ts src/main/runtime/rpc/methods/worktree.test.ts src/main/runtime/orca-runtime.test.ts (5 files, 579 tests)

Accepted Gaps / Notes

  • pnpm run lint gets past touched files, but fails on pre-existing unrelated localization catalog keys in src/renderer/src/components/sidebar/sidebar-workspace-option-items.ts and src/renderer/src/components/sidebar/worktree-card-display-property-options.ts; those files have no working-tree diff in this PR.
  • No live folder-workspace parent smoke was possible from current Orca state because worktree list --limit 10000 --json returned no folder pseudo-worktrees. The folder active/current edge is covered by focused CLI regression tests and manual code tracing, while the live compiled CLI smokes covered real worktree creation, linkage visibility, and cleanup for explicit and inferred normal worktree parents.
  • No live SSH runtime pass was run. brennan-test-changes accepted this for the CLI/runtime argument-routing scope because parser/help/error behavior and runtime routing are covered directly by focused tests and CLI probes.

Open in Stage

@ghost

ghost commented Jun 18, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 6 individual chapters for you:

Title
1 Update runtime lineage terminology and error messages
2 Extract parent selector resolution logic
3 Remove parent-workspace flag from CLI handlers
4 Clean up CLI help and specifications
5 Verify CLI changes with integration tests
6 Update agent skill documentation
Open in Stage

Chapters generated by Stage for commit e016920 on Jun 19, 2026 12:25am UTC.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR replaces --parent-workspace with --parent-worktree as the public CLI flag for specifying a worktree parent during worktree create and worktree set. A new worktree-create-parent-selector module centralizes parent resolution, routing workspace-key-style values (e.g., folder:<id>, worktree:<id>, id:<...>) to parentWorkspace and other selector forms to parentWorktree via getOptionalWorktreeSelector. The --parent-workspace flag is removed from allowedFlags entirely. Runtime lineage error messages are updated throughout to use "worktree," "parent selector," and "parent context" terminology instead of "workspace." Help text, CLI specs, tests, and skill documentation are updated accordingly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing the workspace parent flag from the worktree create CLI, which is the central objective of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed PR description is comprehensive and well-structured, covering summary, implementation details, design review evidence, testing approach, and accepted gaps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3c0443e3-892e-4bc2-82c9-28d14ff03f83

📥 Commits

Reviewing files that changed from the base of the PR and between afde3a3 and c7b544b.

📒 Files selected for processing (13)
  • src/cli/args.ts
  • src/cli/format.test.ts
  • src/cli/handlers/worktree-create-parent-selector.ts
  • src/cli/handlers/worktree-lineage-summary.ts
  • src/cli/handlers/worktree.ts
  • src/cli/help.ts
  • src/cli/index.test.ts
  • src/cli/specs/core.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/errors.test.ts
  • src/main/runtime/rpc/methods/worktree-schemas.ts
  • src/main/runtime/rpc/methods/worktree.test.ts

Comment thread src/cli/index.test.ts
Comment on lines +229 to 264
await main(['--help'], '/tmp/repo')

const rootHelp = String(logSpy.mock.calls[0][0])
expect(rootHelp).not.toContain('--parent-workspace')
expect(rootHelp).toContain('[--parent-worktree <selector>] [--no-parent]')

logSpy.mockClear()
await main(['worktree', 'create', '--help'], '/tmp/repo')

const createHelp = String(logSpy.mock.calls[0][0])
expect(createHelp).not.toContain('--parent-workspace')
expect(createHelp).not.toContain('checkout/workspace')
expect(createHelp).not.toContain('caller workspace')
expect(createHelp).not.toContain('current workspace')
expect(createHelp).not.toContain('active Orca workspace')
expect(createHelp).not.toContain('folderWorkspaceId')
expect(createHelp).toContain('folder:<id>')
expect(createHelp).toContain('folder:<folderId>')
expect(createHelp).toContain('worktree:<id>')

logSpy.mockClear()
await main(['worktree', 'set', '--help'], '/tmp/repo')

const setHelp = String(logSpy.mock.calls[0][0])
expect(setHelp).not.toContain('--parent-workspace')
expect(setHelp).not.toContain('folder:<id>')
expect(setHelp).not.toContain('worktree:<id>')
expect(callMock).not.toHaveBeenCalled()
})

it('distinguishes new worktrees from fresh agent terminals in command help', async () => {
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
logSpy.mockClear()

await main(['worktree', 'create', '--help'], '/tmp/repo')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace hardcoded POSIX test paths with path utilities.

Several updated tests use literal /tmp/... paths, which is not cross-platform and can break on Windows runners. Use path.join/path.resolve (or a shared test-path helper) for these cases.

As per coding guidelines, "Use path.join or Electron/Node path utilities for file paths — never assume / or \ for cross-platform compatibility".

Also applies to: 1316-1383, 1609-1724

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant