Skip to content

refactor(server): extract worktree archive command#891

Closed
boudra wants to merge 1 commit into
refactor-agent-lifecycle-commandsfrom
refactor-worktree-commands
Closed

refactor(server): extract worktree archive command#891
boudra wants to merge 1 commit into
refactor-agent-lifecycle-commandsfrom
refactor-worktree-commands

Conversation

@boudra

@boudra boudra commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extract shared archivePaseoWorktreeCommand for common worktree archive target resolution, ownership checks, and archive service invocation.
  • Make Session and MCP archive handlers entrypoint adapters: Session emits WS response shapes; MCP returns structured content and keeps MCP argument errors local.
  • Add MCP coverage for archiving a worktree by slug.

Risk and Coverage Notes

  • Low risk: archive teardown/delete side effects stay in archivePaseoWorktree, covered by worktree-session.test.ts archive cases for agent close, terminal teardown, archiving state updates, failure cleanup, orphaned git metadata, and snapshot refresh.
  • Low risk: MCP archive side effects remain covered by mcp-server.test.ts for snapshot refresh and workspace archiving callbacks.
  • Newly covered: MCP archive_worktree with worktreeSlug, proving the shared command preserves slug-to-Paseo-worktree-path behavior and deletes the worktree.
  • Intentional transport difference: Session maps NOT_ALLOWED to paseo_worktree_archive_response; MCP throws the tool error. Both cross the same command result.

Verification

  • npx vitest run packages/server/src/server/worktree-session.test.ts packages/server/src/server/agent/mcp-server.test.ts --bail=1
  • npm run format
  • npm run typecheck
  • npm run lint
  • pre-commit hook: lint, format:check:files, typecheck

Refactor Candidate

Chosen: shared archive worktree command.

The deleted duplication was target resolution plus Paseo ownership policy in Session and MCP. Deleting the new command would make worktree-session.ts regain branch lookup and ownership checks, and mcp-server.ts regain slug/path construction plus archive service assembly.

Next likely slice: standalone create/list worktree commands, if a deletion test shows enough remaining drift beyond the existing createPaseoWorktreeWorkflow.

@boudra

boudra commented May 10, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of the single integration PR #893, which contains the full Session/MCP command-boundary stack and is being held until after the stable release.

@boudra boudra closed this May 10, 2026
@boudra boudra deleted the refactor-worktree-commands branch May 10, 2026 10:42
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