Repository navigation
feat(cli): expose worktree import via CLI and MCP (#6051) - #6052
github-actions[bot] wants to merge 1 commit into
Conversation
Adds `superset workspaces import` and the `workspaces_import` MCP tool, both backed by the existing host-service `workspaceCreation.adopt` mutation, so automation can hand Superset a worktree it already created. Refs #6051
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit 3ce8356 on Jul 29, 2026 2:46pm UTC. |
|
Closing: no longer applicable. This adds files under It also builds on #6051 stays open (tracked as SUPER-1691). The smaller fix is a |
What this is
Not a bug — #6051 is a feature request, so there is no failing behaviour to reproduce. I verified the reported gap, found the capability already exists server-side, and wired it up to the two automatable surfaces. Opened as a draft since it adds public CLI/MCP surface area that deserves a human call on naming.
The gap (verified)
The desktop app can import an existing worktree (
openExternalWorktree/importAllWorktrees,apps/desktop/src/lib/trpc/routers/workspaces/procedures/create.ts:912), but neitherpackages/clinor the MCP servers exposed anything equivalent —superset workspaces createandworkspaces_createonly ever materialize a new worktree.What the issue doesn't mention: the v2 host service already has the whole import path implemented as
workspaceCreation.adopt(packages/host-service/src/trpc/router/workspace-creation/procedures/adopt.ts), including the optional explicitworktreePaththe desktop import needs, the stale-row hygiene inadoptExistingWorktree, and cross-project path rejection. Its doc comment says the only caller is the v1→v2 migration. So this needed no new host-service logic at all — only client wiring.What was added
superset workspaces import --project <id> --path <worktree-path> --branch <branch> [--name] [--base-branch] (--local | --host <id>), callingworkspaceCreation.adopt.--namedefaults to the worktree directory name.workspaces_importinpackages/mcp-v2, same inputs plushostId, hitting the same procedure.<Command>block in the CLI reference and a row in the MCP tool table.Two deliberate choices, both tested:
--pathmust be absolute. It is interpreted on the target host, which may not be the machine running the CLI, so resolving a relative path against the local cwd would silently point at the wrong directory.adoptintentionally reads the branch actually checked out at the path and ignores the caller'sbranch(so a stale name can't make the migration miss a valid worktree). Rather than change that shared behaviour, the CLI compares the result and returnsbranchMismatchplus a message naming the real branch.I chose mcp-v2 for the MCP side: it is host-service-backed like the CLI, so it reuses
adoptdirectly. Adding this to v1packages/mcpwould instead require a new desktop renderer command-watcher handler and a newToolContextmutation — happy to add that too if v1 still needs parity.Tests
packages/cli/src/commands/workspaces/import/command.test.ts(6 tests) — started as the reproduction: it failed withCannot find module './command', which is the reported gap. Now covers forwarding toadopt, name defaulting,--base-branch, relative-path rejection, and branch-mismatch reporting.packages/mcp-v2/src/tools/workspaces/import.test.ts(5 tests) — asserts the tool is registered asworkspaces_import, targetsworkspaceCreation.adopt, derives the name, and rejects a relative path without calling the host.bun test packages/cli/src/commands/workspaces packages/mcp-v2→ 22 pass. Lint exits 0; both packages typecheck.Unrelated pre-existing failure worth flagging: running the whole
packages/clisuite in one process failsagents/create/command.test.tswithExport named 'execFileSync' not found—src/lib/host/spawn.test.ts:40mocksnode:child_processand the mock leaks across files. It fails identically on this branch with my changes stashed, and each file passes in isolation. Left alone as out of scope.Refs #6051
Summary by cubic
Adds
superset workspaces importand theworkspaces_importMCP tool to register an existing git worktree as a workspace, reusingworkspaceCreation.adopt. This lets automation hand off pre-created worktrees without creating new ones.superset workspaces import --project <id> --path <abs> --branch <branch> [--name] [--base-branch] (--local | --host <id>).workspaces_importinpackages/mcp-v2, callingworkspaceCreation.adopt.--pathmust be absolute (interpreted on the target host);--namedefaults to the worktree directory; forwards--base-branch.--branch, the result setsbranchMismatchand returns the real branch.Written for commit 3ce8356. Summary will update on new commits.