claude-code-plus-plus 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/index.js +5 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/start.js +4 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/index.js +18 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/parser.js +8 -3
- package/dist/cli/parser.js.map +1 -1
- package/dist/cli/validators.js +30 -20
- package/dist/cli/validators.js.map +1 -1
- package/dist/config/defaults.js +10 -5
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.js +24 -4
- package/dist/config/index.js.map +1 -1
- package/dist/config/loader.js +29 -20
- package/dist/config/loader.js.map +1 -1
- package/dist/config/paths.js +30 -21
- package/dist/config/paths.js.map +1 -1
- package/dist/config/schema.js +6 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/git/index.js +6 -1
- package/dist/git/index.js.map +1 -1
- package/dist/git/worktree.js +18 -13
- package/dist/git/worktree.js.map +1 -1
- package/dist/index.js +41 -6
- package/dist/index.js.map +1 -1
- package/dist/launcher/index.d.ts.map +1 -1
- package/dist/launcher/index.js +60 -26
- package/dist/launcher/index.js.map +1 -1
- package/dist/platform/clipboard.js +22 -15
- package/dist/platform/clipboard.js.map +1 -1
- package/dist/platform/detector.js +37 -22
- package/dist/platform/detector.js.map +1 -1
- package/dist/platform/index.js +42 -4
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/paths.js +61 -48
- package/dist/platform/paths.js.map +1 -1
- package/dist/platform/shell.js +35 -27
- package/dist/platform/shell.js.map +1 -1
- package/dist/sidebar/app.d.ts.map +1 -1
- package/dist/sidebar/app.js +73 -39
- package/dist/sidebar/app.js.map +1 -1
- package/dist/sidebar/index.js +4 -2
- package/dist/sidebar/index.js.map +1 -1
- package/dist/sidebar/input.js +12 -5
- package/dist/sidebar/input.js.map +1 -1
- package/dist/sidebar/render.js +102 -90
- package/dist/sidebar/render.js.map +1 -1
- package/dist/terminal/bar-handler.js +9 -7
- package/dist/terminal/bar-handler.js.map +1 -1
- package/dist/terminal/bar-render.js +6 -2
- package/dist/terminal/bar-render.js.map +1 -1
- package/dist/terminal/index.js +6 -1
- package/dist/terminal/index.js.map +1 -1
- package/dist/tmux/commands.js +18 -11
- package/dist/tmux/commands.js.map +1 -1
- package/dist/tmux/index.js +33 -7
- package/dist/tmux/index.js.map +1 -1
- package/dist/tmux/pane.js +76 -51
- package/dist/tmux/pane.js.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/async.js +16 -7
- package/dist/utils/async.js.map +1 -1
- package/dist/utils/errors.js +31 -14
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/id.js +19 -10
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/index.js +65 -6
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +17 -10
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/string.js +22 -10
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/validation.js +28 -13
- package/dist/utils/validation.js.map +1 -1
- package/package.json +4 -4
- package/dist/app.d.ts +0 -52
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -318
- package/dist/app.js.map +0 -1
- package/dist/core/index.d.ts +0 -14
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -14
- package/dist/core/index.js.map +0 -1
- package/dist/core/session/index.d.ts +0 -7
- package/dist/core/session/index.d.ts.map +0 -1
- package/dist/core/session/index.js +0 -6
- package/dist/core/session/index.js.map +0 -1
- package/dist/core/session/session-manager.d.ts +0 -46
- package/dist/core/session/session-manager.d.ts.map +0 -1
- package/dist/core/session/session-manager.js +0 -245
- package/dist/core/session/session-manager.js.map +0 -1
- package/dist/core/session/session.d.ts +0 -44
- package/dist/core/session/session.d.ts.map +0 -1
- package/dist/core/session/session.js +0 -78
- package/dist/core/session/session.js.map +0 -1
- package/dist/core/terminal/index.d.ts +0 -7
- package/dist/core/terminal/index.d.ts.map +0 -1
- package/dist/core/terminal/index.js +0 -6
- package/dist/core/terminal/index.js.map +0 -1
- package/dist/core/terminal/terminal-manager.d.ts +0 -36
- package/dist/core/terminal/terminal-manager.d.ts.map +0 -1
- package/dist/core/terminal/terminal-manager.js +0 -182
- package/dist/core/terminal/terminal-manager.js.map +0 -1
- package/dist/core/terminal/terminal.d.ts +0 -27
- package/dist/core/terminal/terminal.d.ts.map +0 -1
- package/dist/core/terminal/terminal.js +0 -38
- package/dist/core/terminal/terminal.js.map +0 -1
- package/dist/core/workspace/index.d.ts +0 -7
- package/dist/core/workspace/index.d.ts.map +0 -1
- package/dist/core/workspace/index.js +0 -6
- package/dist/core/workspace/index.js.map +0 -1
- package/dist/core/workspace/workspace-manager.d.ts +0 -59
- package/dist/core/workspace/workspace-manager.d.ts.map +0 -1
- package/dist/core/workspace/workspace-manager.js +0 -224
- package/dist/core/workspace/workspace-manager.js.map +0 -1
- package/dist/core/workspace/workspace.d.ts +0 -56
- package/dist/core/workspace/workspace.d.ts.map +0 -1
- package/dist/core/workspace/workspace.js +0 -96
- package/dist/core/workspace/workspace.js.map +0 -1
- package/dist/core/worktree/index.d.ts +0 -7
- package/dist/core/worktree/index.d.ts.map +0 -1
- package/dist/core/worktree/index.js +0 -6
- package/dist/core/worktree/index.js.map +0 -1
- package/dist/core/worktree/worktree-manager.d.ts +0 -47
- package/dist/core/worktree/worktree-manager.d.ts.map +0 -1
- package/dist/core/worktree/worktree-manager.js +0 -170
- package/dist/core/worktree/worktree-manager.js.map +0 -1
- package/dist/core/worktree/worktree.d.ts +0 -35
- package/dist/core/worktree/worktree.d.ts.map +0 -1
- package/dist/core/worktree/worktree.js +0 -50
- package/dist/core/worktree/worktree.js.map +0 -1
- package/dist/core/worktree-manager.d.ts +0 -26
- package/dist/core/worktree-manager.d.ts.map +0 -1
- package/dist/core/worktree-manager.js +0 -177
- package/dist/core/worktree-manager.js.map +0 -1
- package/dist/events/bus.d.ts +0 -76
- package/dist/events/bus.d.ts.map +0 -1
- package/dist/events/bus.js +0 -223
- package/dist/events/bus.js.map +0 -1
- package/dist/events/handlers/index.d.ts +0 -28
- package/dist/events/handlers/index.d.ts.map +0 -1
- package/dist/events/handlers/index.js +0 -44
- package/dist/events/handlers/index.js.map +0 -1
- package/dist/events/handlers/session-events.d.ts +0 -12
- package/dist/events/handlers/session-events.d.ts.map +0 -1
- package/dist/events/handlers/session-events.js +0 -38
- package/dist/events/handlers/session-events.js.map +0 -1
- package/dist/events/handlers/terminal-events.d.ts +0 -12
- package/dist/events/handlers/terminal-events.d.ts.map +0 -1
- package/dist/events/handlers/terminal-events.js +0 -37
- package/dist/events/handlers/terminal-events.js.map +0 -1
- package/dist/events/handlers/ui-events.d.ts +0 -11
- package/dist/events/handlers/ui-events.d.ts.map +0 -1
- package/dist/events/handlers/ui-events.js +0 -202
- package/dist/events/handlers/ui-events.js.map +0 -1
- package/dist/events/index.d.ts +0 -9
- package/dist/events/index.d.ts.map +0 -1
- package/dist/events/index.js +0 -10
- package/dist/events/index.js.map +0 -1
- package/dist/multiplexer/base.d.ts +0 -73
- package/dist/multiplexer/base.d.ts.map +0 -1
- package/dist/multiplexer/base.js +0 -68
- package/dist/multiplexer/base.js.map +0 -1
- package/dist/multiplexer/factory.d.ts +0 -28
- package/dist/multiplexer/factory.d.ts.map +0 -1
- package/dist/multiplexer/factory.js +0 -72
- package/dist/multiplexer/factory.js.map +0 -1
- package/dist/multiplexer/index.d.ts +0 -14
- package/dist/multiplexer/index.d.ts.map +0 -1
- package/dist/multiplexer/index.js +0 -15
- package/dist/multiplexer/index.js.map +0 -1
- package/dist/multiplexer/tmux/index.d.ts +0 -9
- package/dist/multiplexer/tmux/index.d.ts.map +0 -1
- package/dist/multiplexer/tmux/index.js +0 -7
- package/dist/multiplexer/tmux/index.js.map +0 -1
- package/dist/multiplexer/tmux/tmux-commands.d.ts +0 -96
- package/dist/multiplexer/tmux/tmux-commands.d.ts.map +0 -1
- package/dist/multiplexer/tmux/tmux-commands.js +0 -282
- package/dist/multiplexer/tmux/tmux-commands.js.map +0 -1
- package/dist/multiplexer/tmux/tmux-config.d.ts +0 -57
- package/dist/multiplexer/tmux/tmux-config.d.ts.map +0 -1
- package/dist/multiplexer/tmux/tmux-config.js +0 -103
- package/dist/multiplexer/tmux/tmux-config.js.map +0 -1
- package/dist/multiplexer/tmux/tmux-multiplexer.d.ts +0 -94
- package/dist/multiplexer/tmux/tmux-multiplexer.d.ts.map +0 -1
- package/dist/multiplexer/tmux/tmux-multiplexer.js +0 -302
- package/dist/multiplexer/tmux/tmux-multiplexer.js.map +0 -1
- package/dist/multiplexer/windows/index.d.ts +0 -5
- package/dist/multiplexer/windows/index.d.ts.map +0 -1
- package/dist/multiplexer/windows/index.js +0 -5
- package/dist/multiplexer/windows/index.js.map +0 -1
- package/dist/multiplexer/windows/windows-multiplexer.d.ts +0 -61
- package/dist/multiplexer/windows/windows-multiplexer.d.ts.map +0 -1
- package/dist/multiplexer/windows/windows-multiplexer.js +0 -151
- package/dist/multiplexer/windows/windows-multiplexer.js.map +0 -1
- package/dist/services/claude/claude-detector.d.ts +0 -37
- package/dist/services/claude/claude-detector.d.ts.map +0 -1
- package/dist/services/claude/claude-detector.js +0 -83
- package/dist/services/claude/claude-detector.js.map +0 -1
- package/dist/services/claude/claude-service.d.ts +0 -57
- package/dist/services/claude/claude-service.d.ts.map +0 -1
- package/dist/services/claude/claude-service.js +0 -108
- package/dist/services/claude/claude-service.js.map +0 -1
- package/dist/services/claude/index.d.ts +0 -7
- package/dist/services/claude/index.d.ts.map +0 -1
- package/dist/services/claude/index.js +0 -6
- package/dist/services/claude/index.js.map +0 -1
- package/dist/services/git/branch-service.d.ts +0 -64
- package/dist/services/git/branch-service.d.ts.map +0 -1
- package/dist/services/git/branch-service.js +0 -217
- package/dist/services/git/branch-service.js.map +0 -1
- package/dist/services/git/git-service.d.ts +0 -44
- package/dist/services/git/git-service.d.ts.map +0 -1
- package/dist/services/git/git-service.js +0 -145
- package/dist/services/git/git-service.js.map +0 -1
- package/dist/services/git/index.d.ts +0 -8
- package/dist/services/git/index.d.ts.map +0 -1
- package/dist/services/git/index.js +0 -7
- package/dist/services/git/index.js.map +0 -1
- package/dist/services/git/worktree-service.d.ts +0 -61
- package/dist/services/git/worktree-service.d.ts.map +0 -1
- package/dist/services/git/worktree-service.js +0 -243
- package/dist/services/git/worktree-service.js.map +0 -1
- package/dist/services/index.d.ts +0 -12
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js +0 -12
- package/dist/services/index.js.map +0 -1
- package/dist/services/process/index.d.ts +0 -8
- package/dist/services/process/index.d.ts.map +0 -1
- package/dist/services/process/index.js +0 -6
- package/dist/services/process/index.js.map +0 -1
- package/dist/services/process/process-monitor.d.ts +0 -98
- package/dist/services/process/process-monitor.d.ts.map +0 -1
- package/dist/services/process/process-monitor.js +0 -173
- package/dist/services/process/process-monitor.js.map +0 -1
- package/dist/services/process/process-spawner.d.ts +0 -55
- package/dist/services/process/process-spawner.d.ts.map +0 -1
- package/dist/services/process/process-spawner.js +0 -93
- package/dist/services/process/process-spawner.js.map +0 -1
- package/dist/sidebar.d.ts +0 -13
- package/dist/sidebar.d.ts.map +0 -1
- package/dist/sidebar.js +0 -1535
- package/dist/sidebar.js.map +0 -1
- package/dist/state/actions.d.ts +0 -49
- package/dist/state/actions.d.ts.map +0 -1
- package/dist/state/actions.js +0 -512
- package/dist/state/actions.js.map +0 -1
- package/dist/state/index.d.ts +0 -16
- package/dist/state/index.d.ts.map +0 -1
- package/dist/state/index.js +0 -28
- package/dist/state/index.js.map +0 -1
- package/dist/state/middleware/index.d.ts +0 -7
- package/dist/state/middleware/index.d.ts.map +0 -1
- package/dist/state/middleware/index.js +0 -6
- package/dist/state/middleware/index.js.map +0 -1
- package/dist/state/middleware/logger.d.ts +0 -22
- package/dist/state/middleware/logger.d.ts.map +0 -1
- package/dist/state/middleware/logger.js +0 -45
- package/dist/state/middleware/logger.js.map +0 -1
- package/dist/state/middleware/persistence.d.ts +0 -29
- package/dist/state/middleware/persistence.d.ts.map +0 -1
- package/dist/state/middleware/persistence.js +0 -71
- package/dist/state/middleware/persistence.js.map +0 -1
- package/dist/state/persistence/file-adapter.d.ts +0 -48
- package/dist/state/persistence/file-adapter.d.ts.map +0 -1
- package/dist/state/persistence/file-adapter.js +0 -96
- package/dist/state/persistence/file-adapter.js.map +0 -1
- package/dist/state/persistence/index.d.ts +0 -8
- package/dist/state/persistence/index.d.ts.map +0 -1
- package/dist/state/persistence/index.js +0 -6
- package/dist/state/persistence/index.js.map +0 -1
- package/dist/state/persistence/serializer.d.ts +0 -41
- package/dist/state/persistence/serializer.d.ts.map +0 -1
- package/dist/state/persistence/serializer.js +0 -114
- package/dist/state/persistence/serializer.js.map +0 -1
- package/dist/state/selectors.d.ts +0 -67
- package/dist/state/selectors.d.ts.map +0 -1
- package/dist/state/selectors.js +0 -177
- package/dist/state/selectors.js.map +0 -1
- package/dist/state/store.d.ts +0 -86
- package/dist/state/store.d.ts.map +0 -1
- package/dist/state/store.js +0 -161
- package/dist/state/store.js.map +0 -1
- package/dist/state/types.d.ts +0 -269
- package/dist/state/types.d.ts.map +0 -1
- package/dist/state/types.js +0 -7
- package/dist/state/types.js.map +0 -1
- package/dist/state.d.ts +0 -53
- package/dist/state.d.ts.map +0 -1
- package/dist/state.js +0 -101
- package/dist/state.js.map +0 -1
- package/dist/terminal-manager.d.ts +0 -16
- package/dist/terminal-manager.d.ts.map +0 -1
- package/dist/terminal-manager.js +0 -364
- package/dist/terminal-manager.js.map +0 -1
- package/dist/tmux.d.ts +0 -163
- package/dist/tmux.d.ts.map +0 -1
- package/dist/tmux.js +0 -360
- package/dist/tmux.js.map +0 -1
- package/dist/types/config.d.ts +0 -103
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -7
- package/dist/types/config.js.map +0 -1
- package/dist/types/entities.d.ts +0 -88
- package/dist/types/entities.d.ts.map +0 -1
- package/dist/types/entities.js +0 -8
- package/dist/types/entities.js.map +0 -1
- package/dist/types/events.d.ts +0 -156
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/events.js +0 -8
- package/dist/types/events.js.map +0 -1
- package/dist/types/index.d.ts +0 -11
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/multiplexer.d.ts +0 -238
- package/dist/types/multiplexer.d.ts.map +0 -1
- package/dist/types/multiplexer.js +0 -8
- package/dist/types/multiplexer.js.map +0 -1
- package/dist/ui/components/base.d.ts +0 -155
- package/dist/ui/components/base.d.ts.map +0 -1
- package/dist/ui/components/base.js +0 -269
- package/dist/ui/components/base.js.map +0 -1
- package/dist/ui/components/index.d.ts +0 -10
- package/dist/ui/components/index.d.ts.map +0 -1
- package/dist/ui/components/index.js +0 -10
- package/dist/ui/components/index.js.map +0 -1
- package/dist/ui/components/input-field.d.ts +0 -98
- package/dist/ui/components/input-field.d.ts.map +0 -1
- package/dist/ui/components/input-field.js +0 -274
- package/dist/ui/components/input-field.js.map +0 -1
- package/dist/ui/components/list.d.ts +0 -94
- package/dist/ui/components/list.d.ts.map +0 -1
- package/dist/ui/components/list.js +0 -294
- package/dist/ui/components/list.js.map +0 -1
- package/dist/ui/components/modal.d.ts +0 -83
- package/dist/ui/components/modal.d.ts.map +0 -1
- package/dist/ui/components/modal.js +0 -249
- package/dist/ui/components/modal.js.map +0 -1
- package/dist/ui/components/tabs.d.ts +0 -97
- package/dist/ui/components/tabs.d.ts.map +0 -1
- package/dist/ui/components/tabs.js +0 -252
- package/dist/ui/components/tabs.js.map +0 -1
- package/dist/ui/components/text.d.ts +0 -60
- package/dist/ui/components/text.d.ts.map +0 -1
- package/dist/ui/components/text.js +0 -224
- package/dist/ui/components/text.js.map +0 -1
- package/dist/ui/index.d.ts +0 -12
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -18
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/input/index.d.ts +0 -8
- package/dist/ui/input/index.d.ts.map +0 -1
- package/dist/ui/input/index.js +0 -8
- package/dist/ui/input/index.js.map +0 -1
- package/dist/ui/input/input-manager.d.ts +0 -83
- package/dist/ui/input/input-manager.d.ts.map +0 -1
- package/dist/ui/input/input-manager.js +0 -200
- package/dist/ui/input/input-manager.js.map +0 -1
- package/dist/ui/input/keybindings.d.ts +0 -47
- package/dist/ui/input/keybindings.d.ts.map +0 -1
- package/dist/ui/input/keybindings.js +0 -168
- package/dist/ui/input/keybindings.js.map +0 -1
- package/dist/ui/input/keyboard.d.ts +0 -24
- package/dist/ui/input/keyboard.d.ts.map +0 -1
- package/dist/ui/input/keyboard.js +0 -230
- package/dist/ui/input/keyboard.js.map +0 -1
- package/dist/ui/input/mouse.d.ts +0 -44
- package/dist/ui/input/mouse.d.ts.map +0 -1
- package/dist/ui/input/mouse.js +0 -161
- package/dist/ui/input/mouse.js.map +0 -1
- package/dist/ui/layout/box.d.ts +0 -63
- package/dist/ui/layout/box.d.ts.map +0 -1
- package/dist/ui/layout/box.js +0 -160
- package/dist/ui/layout/box.js.map +0 -1
- package/dist/ui/layout/constraints.d.ts +0 -77
- package/dist/ui/layout/constraints.d.ts.map +0 -1
- package/dist/ui/layout/constraints.js +0 -154
- package/dist/ui/layout/constraints.js.map +0 -1
- package/dist/ui/layout/flex.d.ts +0 -59
- package/dist/ui/layout/flex.d.ts.map +0 -1
- package/dist/ui/layout/flex.js +0 -163
- package/dist/ui/layout/flex.js.map +0 -1
- package/dist/ui/layout/index.d.ts +0 -7
- package/dist/ui/layout/index.d.ts.map +0 -1
- package/dist/ui/layout/index.js +0 -7
- package/dist/ui/layout/index.js.map +0 -1
- package/dist/ui/modals/delete-modal.d.ts +0 -27
- package/dist/ui/modals/delete-modal.d.ts.map +0 -1
- package/dist/ui/modals/delete-modal.js +0 -59
- package/dist/ui/modals/delete-modal.js.map +0 -1
- package/dist/ui/modals/index.d.ts +0 -7
- package/dist/ui/modals/index.d.ts.map +0 -1
- package/dist/ui/modals/index.js +0 -7
- package/dist/ui/modals/index.js.map +0 -1
- package/dist/ui/modals/input-modal.d.ts +0 -66
- package/dist/ui/modals/input-modal.d.ts.map +0 -1
- package/dist/ui/modals/input-modal.js +0 -185
- package/dist/ui/modals/input-modal.js.map +0 -1
- package/dist/ui/modals/quit-modal.d.ts +0 -30
- package/dist/ui/modals/quit-modal.d.ts.map +0 -1
- package/dist/ui/modals/quit-modal.js +0 -65
- package/dist/ui/modals/quit-modal.js.map +0 -1
- package/dist/ui/renderer/ansi.d.ts +0 -206
- package/dist/ui/renderer/ansi.d.ts.map +0 -1
- package/dist/ui/renderer/ansi.js +0 -318
- package/dist/ui/renderer/ansi.js.map +0 -1
- package/dist/ui/renderer/canvas.d.ts +0 -126
- package/dist/ui/renderer/canvas.d.ts.map +0 -1
- package/dist/ui/renderer/canvas.js +0 -346
- package/dist/ui/renderer/canvas.js.map +0 -1
- package/dist/ui/renderer/colors.d.ts +0 -65
- package/dist/ui/renderer/colors.d.ts.map +0 -1
- package/dist/ui/renderer/colors.js +0 -260
- package/dist/ui/renderer/colors.js.map +0 -1
- package/dist/ui/renderer/index.d.ts +0 -8
- package/dist/ui/renderer/index.d.ts.map +0 -1
- package/dist/ui/renderer/index.js +0 -8
- package/dist/ui/renderer/index.js.map +0 -1
- package/dist/ui/renderer/symbols.d.ts +0 -176
- package/dist/ui/renderer/symbols.d.ts.map +0 -1
- package/dist/ui/renderer/symbols.js +0 -246
- package/dist/ui/renderer/symbols.js.map +0 -1
- package/dist/ui/views/index.d.ts +0 -7
- package/dist/ui/views/index.d.ts.map +0 -1
- package/dist/ui/views/index.js +0 -7
- package/dist/ui/views/index.js.map +0 -1
- package/dist/ui/views/sidebar-view.d.ts +0 -89
- package/dist/ui/views/sidebar-view.d.ts.map +0 -1
- package/dist/ui/views/sidebar-view.js +0 -259
- package/dist/ui/views/sidebar-view.js.map +0 -1
- package/dist/ui/views/terminal-bar-view.d.ts +0 -67
- package/dist/ui/views/terminal-bar-view.d.ts.map +0 -1
- package/dist/ui/views/terminal-bar-view.js +0 -172
- package/dist/ui/views/terminal-bar-view.js.map +0 -1
- package/dist/ui/views/welcome-view.d.ts +0 -34
- package/dist/ui/views/welcome-view.d.ts.map +0 -1
- package/dist/ui/views/welcome-view.js +0 -116
- package/dist/ui/views/welcome-view.js.map +0 -1
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workspace Entity
|
|
3
|
-
*
|
|
4
|
-
* Factory functions for creating Workspace objects.
|
|
5
|
-
* A workspace represents the entire application state for a repository.
|
|
6
|
-
*/
|
|
7
|
-
import { generateId } from '../../utils';
|
|
8
|
-
/**
|
|
9
|
-
* Create a new workspace
|
|
10
|
-
*/
|
|
11
|
-
export function createWorkspace(options) {
|
|
12
|
-
const { projectPath, projectName, multiplexerSessionId } = options;
|
|
13
|
-
return {
|
|
14
|
-
id: generateId(12),
|
|
15
|
-
projectPath,
|
|
16
|
-
projectName: projectName ?? extractProjectName(projectPath),
|
|
17
|
-
multiplexerSessionId: multiplexerSessionId ?? '',
|
|
18
|
-
worktrees: [],
|
|
19
|
-
activeSessionId: null,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Extract project name from path
|
|
24
|
-
*/
|
|
25
|
-
function extractProjectName(projectPath) {
|
|
26
|
-
const parts = projectPath.split('/');
|
|
27
|
-
return parts[parts.length - 1] || 'workspace';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Add a worktree to workspace
|
|
31
|
-
*/
|
|
32
|
-
export function addWorktreeToWorkspace(workspace, worktree) {
|
|
33
|
-
return {
|
|
34
|
-
...workspace,
|
|
35
|
-
worktrees: [...workspace.worktrees, worktree],
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Remove a worktree from workspace
|
|
40
|
-
*/
|
|
41
|
-
export function removeWorktreeFromWorkspace(workspace, worktreeId) {
|
|
42
|
-
return {
|
|
43
|
-
...workspace,
|
|
44
|
-
worktrees: workspace.worktrees.filter((w) => w.id !== worktreeId),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the active session from workspace
|
|
49
|
-
*/
|
|
50
|
-
export function getActiveSession(workspace) {
|
|
51
|
-
if (!workspace.activeSessionId)
|
|
52
|
-
return undefined;
|
|
53
|
-
for (const wt of workspace.worktrees) {
|
|
54
|
-
const session = wt.sessions.find((s) => s.id === workspace.activeSessionId);
|
|
55
|
-
if (session)
|
|
56
|
-
return session;
|
|
57
|
-
}
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get the main worktree from workspace
|
|
62
|
-
*/
|
|
63
|
-
export function getMainWorktree(workspace) {
|
|
64
|
-
return workspace.worktrees.find((w) => w.isMain);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get all sessions across all worktrees
|
|
68
|
-
*/
|
|
69
|
-
export function getAllSessions(workspace) {
|
|
70
|
-
return workspace.worktrees.flatMap((w) => w.sessions);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Get total session count
|
|
74
|
-
*/
|
|
75
|
-
export function getTotalSessionCount(workspace) {
|
|
76
|
-
return workspace.worktrees.reduce((sum, w) => sum + w.sessions.length, 0);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Find worktree containing a session
|
|
80
|
-
*/
|
|
81
|
-
export function findWorktreeBySessionId(workspace, sessionId) {
|
|
82
|
-
return workspace.worktrees.find((w) => w.sessions.some((s) => s.id === sessionId));
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Find worktree by branch name
|
|
86
|
-
*/
|
|
87
|
-
export function findWorktreeByBranch(workspace, branch) {
|
|
88
|
-
return workspace.worktrees.find((w) => w.branch === branch);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Find worktree by ID
|
|
92
|
-
*/
|
|
93
|
-
export function findWorktreeById(workspace, worktreeId) {
|
|
94
|
-
return workspace.worktrees.find((w) => w.id === worktreeId);
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=workspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/core/workspace/workspace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,OAA+B;IAC7D,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC;IAEnE,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC;QAClB,WAAW;QACX,WAAW,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW,CAAC;QAC3D,oBAAoB,EAAE,oBAAoB,IAAI,EAAE;QAChD,SAAS,EAAE,EAAE;QACb,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,WAAW,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAoB,EACpB,QAAkB;IAElB,OAAO;QACL,GAAG,SAAS;QACZ,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,SAAoB,EACpB,UAAkB;IAElB,OAAO;QACL,GAAG,SAAS;QACZ,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAC3C,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAAoB,EACpB,MAAc;IAEd,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAoB,EACpB,UAAkB;IAElB,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree Module
|
|
3
|
-
*/
|
|
4
|
-
export { createWorktree, worktreeFromInfo, worktreesFromInfoList, hasSessions, getSessionCount, } from './worktree';
|
|
5
|
-
export type { CreateWorktreeOptions } from './worktree';
|
|
6
|
-
export { WorktreeManager, createWorktreeManager } from './worktree-manager';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/worktree/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/worktree/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages the lifecycle of git worktrees.
|
|
5
|
-
*/
|
|
6
|
-
import type { Worktree } from '../../types';
|
|
7
|
-
/**
|
|
8
|
-
* Worktree manager class
|
|
9
|
-
*/
|
|
10
|
-
export declare class WorktreeManager {
|
|
11
|
-
private repoPath;
|
|
12
|
-
private worktreesBasePath;
|
|
13
|
-
constructor(repoPath: string, worktreesBasePath: string);
|
|
14
|
-
/**
|
|
15
|
-
* Load all worktrees from git
|
|
16
|
-
*/
|
|
17
|
-
loadWorktrees(): Worktree[];
|
|
18
|
-
/**
|
|
19
|
-
* Create a new worktree
|
|
20
|
-
*/
|
|
21
|
-
create(branch: string): Promise<Worktree>;
|
|
22
|
-
/**
|
|
23
|
-
* Delete a worktree
|
|
24
|
-
*/
|
|
25
|
-
delete(worktreeId: string): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Rename a worktree (renames branch and moves directory)
|
|
28
|
-
*/
|
|
29
|
-
rename(worktreeId: string, newBranch: string): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Get a worktree by ID
|
|
32
|
-
*/
|
|
33
|
-
get(worktreeId: string): Worktree | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Get all worktrees
|
|
36
|
-
*/
|
|
37
|
-
getAll(): Worktree[];
|
|
38
|
-
/**
|
|
39
|
-
* Check if a branch name is available
|
|
40
|
-
*/
|
|
41
|
-
isBranchAvailable(branch: string): boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Create a worktree manager
|
|
45
|
-
*/
|
|
46
|
-
export declare function createWorktreeManager(repoPath: string, worktreesBasePath: string): WorktreeManager;
|
|
47
|
-
//# sourceMappingURL=worktree-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-manager.d.ts","sourceRoot":"","sources":["../../../src/core/worktree/worktree-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,aAAa,CAAC;AAU1D;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM;IAKvD;;OAEG;IACH,aAAa,IAAI,QAAQ,EAAE;IAM3B;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAkD/C;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC/C;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDlE;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAK7C;;OAEG;IACH,MAAM,IAAI,QAAQ,EAAE;IAKpB;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAY3C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,GACxB,eAAe,CAEjB"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree Manager
|
|
3
|
-
*
|
|
4
|
-
* Manages the lifecycle of git worktrees.
|
|
5
|
-
*/
|
|
6
|
-
import { getLogger, WorktreeError } from '../../utils';
|
|
7
|
-
import { getEventBus } from '../../events';
|
|
8
|
-
import { getStore, actions, selectWorktreeById } from '../../state';
|
|
9
|
-
import { getWorktreeService, getBranchService, getGitService } from '../../services';
|
|
10
|
-
import { getNewWorktreePath } from '../../config';
|
|
11
|
-
import { createWorktree, worktreesFromInfoList } from './worktree';
|
|
12
|
-
const logger = getLogger().child('worktree-manager');
|
|
13
|
-
/**
|
|
14
|
-
* Worktree manager class
|
|
15
|
-
*/
|
|
16
|
-
export class WorktreeManager {
|
|
17
|
-
repoPath;
|
|
18
|
-
worktreesBasePath;
|
|
19
|
-
constructor(repoPath, worktreesBasePath) {
|
|
20
|
-
this.repoPath = repoPath;
|
|
21
|
-
this.worktreesBasePath = worktreesBasePath;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Load all worktrees from git
|
|
25
|
-
*/
|
|
26
|
-
loadWorktrees() {
|
|
27
|
-
const worktreeService = getWorktreeService();
|
|
28
|
-
const infos = worktreeService.list(this.repoPath);
|
|
29
|
-
return worktreesFromInfoList(infos);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Create a new worktree
|
|
33
|
-
*/
|
|
34
|
-
async create(branch) {
|
|
35
|
-
const eventBus = getEventBus();
|
|
36
|
-
const store = getStore();
|
|
37
|
-
const worktreeService = getWorktreeService();
|
|
38
|
-
const branchService = getBranchService();
|
|
39
|
-
const gitService = getGitService();
|
|
40
|
-
logger.debug('Creating worktree', { branch });
|
|
41
|
-
// Check if branch already exists
|
|
42
|
-
if (branchService.exists(this.repoPath, branch)) {
|
|
43
|
-
// Check if it already has a worktree
|
|
44
|
-
if (worktreeService.hasBranchWorktree(this.repoPath, branch)) {
|
|
45
|
-
throw new WorktreeError(`Branch ${branch} already has a worktree`, {
|
|
46
|
-
branch,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Determine worktree path
|
|
51
|
-
const repoName = gitService.getRepositoryName(this.repoPath);
|
|
52
|
-
const worktreePath = getNewWorktreePath(this.worktreesBasePath, repoName, branch);
|
|
53
|
-
// Create the worktree
|
|
54
|
-
worktreeService.create(this.repoPath, worktreePath, branch, {
|
|
55
|
-
createBranch: true,
|
|
56
|
-
});
|
|
57
|
-
// Create worktree entity
|
|
58
|
-
const worktree = createWorktree({
|
|
59
|
-
path: worktreePath,
|
|
60
|
-
branch,
|
|
61
|
-
isMain: false,
|
|
62
|
-
});
|
|
63
|
-
// Update state
|
|
64
|
-
store.dispatch(actions.createWorktree(worktree));
|
|
65
|
-
// Emit event
|
|
66
|
-
eventBus.emit('worktree:created', { worktree });
|
|
67
|
-
logger.debug('Worktree created', { worktreeId: worktree.id, branch });
|
|
68
|
-
return worktree;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Delete a worktree
|
|
72
|
-
*/
|
|
73
|
-
async delete(worktreeId) {
|
|
74
|
-
const eventBus = getEventBus();
|
|
75
|
-
const store = getStore();
|
|
76
|
-
const state = store.getState();
|
|
77
|
-
const worktreeService = getWorktreeService();
|
|
78
|
-
const worktree = selectWorktreeById(state, worktreeId);
|
|
79
|
-
if (!worktree) {
|
|
80
|
-
throw new WorktreeError('Worktree not found', { worktreePath: worktreeId });
|
|
81
|
-
}
|
|
82
|
-
if (worktree.isMain) {
|
|
83
|
-
throw new WorktreeError('Cannot delete main worktree');
|
|
84
|
-
}
|
|
85
|
-
logger.debug('Deleting worktree', { worktreeId, path: worktree.path });
|
|
86
|
-
// Delete the worktree from git
|
|
87
|
-
worktreeService.remove(worktree.path, true);
|
|
88
|
-
// Update state
|
|
89
|
-
store.dispatch(actions.deleteWorktree(worktreeId));
|
|
90
|
-
// Emit event
|
|
91
|
-
eventBus.emit('worktree:deleted', {
|
|
92
|
-
worktreeId,
|
|
93
|
-
path: worktree.path,
|
|
94
|
-
});
|
|
95
|
-
logger.debug('Worktree deleted', { worktreeId });
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Rename a worktree (renames branch and moves directory)
|
|
99
|
-
*/
|
|
100
|
-
async rename(worktreeId, newBranch) {
|
|
101
|
-
const eventBus = getEventBus();
|
|
102
|
-
const store = getStore();
|
|
103
|
-
const state = store.getState();
|
|
104
|
-
const worktreeService = getWorktreeService();
|
|
105
|
-
const branchService = getBranchService();
|
|
106
|
-
const gitService = getGitService();
|
|
107
|
-
const worktree = selectWorktreeById(state, worktreeId);
|
|
108
|
-
if (!worktree) {
|
|
109
|
-
throw new WorktreeError('Worktree not found');
|
|
110
|
-
}
|
|
111
|
-
if (worktree.isMain) {
|
|
112
|
-
throw new WorktreeError('Cannot rename main worktree');
|
|
113
|
-
}
|
|
114
|
-
const oldBranch = worktree.branch;
|
|
115
|
-
const oldPath = worktree.path;
|
|
116
|
-
logger.debug('Renaming worktree', { worktreeId, oldBranch, newBranch });
|
|
117
|
-
// Rename the branch
|
|
118
|
-
branchService.rename(worktree.path, oldBranch, newBranch);
|
|
119
|
-
// Calculate new path
|
|
120
|
-
const repoName = gitService.getRepositoryName(this.repoPath);
|
|
121
|
-
const newPath = getNewWorktreePath(this.worktreesBasePath, repoName, newBranch);
|
|
122
|
-
// Move the worktree
|
|
123
|
-
if (newPath !== oldPath) {
|
|
124
|
-
worktreeService.move(oldPath, newPath);
|
|
125
|
-
}
|
|
126
|
-
// Update state
|
|
127
|
-
store.dispatch(actions.renameWorktree(worktreeId, newBranch, newPath));
|
|
128
|
-
// Emit event
|
|
129
|
-
eventBus.emit('worktree:renamed', {
|
|
130
|
-
worktreeId,
|
|
131
|
-
oldBranch,
|
|
132
|
-
newBranch,
|
|
133
|
-
});
|
|
134
|
-
logger.debug('Worktree renamed', { worktreeId, newBranch });
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get a worktree by ID
|
|
138
|
-
*/
|
|
139
|
-
get(worktreeId) {
|
|
140
|
-
const state = getStore().getState();
|
|
141
|
-
return selectWorktreeById(state, worktreeId);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get all worktrees
|
|
145
|
-
*/
|
|
146
|
-
getAll() {
|
|
147
|
-
const state = getStore().getState();
|
|
148
|
-
return state.workspace?.worktrees ?? [];
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Check if a branch name is available
|
|
152
|
-
*/
|
|
153
|
-
isBranchAvailable(branch) {
|
|
154
|
-
const branchService = getBranchService();
|
|
155
|
-
const worktreeService = getWorktreeService();
|
|
156
|
-
// Check if branch exists
|
|
157
|
-
if (!branchService.exists(this.repoPath, branch)) {
|
|
158
|
-
return true; // Branch doesn't exist, so it's available for creation
|
|
159
|
-
}
|
|
160
|
-
// Branch exists, check if it has a worktree
|
|
161
|
-
return !worktreeService.hasBranchWorktree(this.repoPath, branch);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Create a worktree manager
|
|
166
|
-
*/
|
|
167
|
-
export function createWorktreeManager(repoPath, worktreesBasePath) {
|
|
168
|
-
return new WorktreeManager(repoPath, worktreesBasePath);
|
|
169
|
-
}
|
|
170
|
-
//# sourceMappingURL=worktree-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-manager.js","sourceRoot":"","sources":["../../../src/core/worktree/worktree-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,eAAe;IAClB,QAAQ,CAAS;IACjB,iBAAiB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QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC,CAAC,uDAAuD;QACtE,CAAC;QAED,4CAA4C;QAC5C,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,iBAAyB;IAEzB,OAAO,IAAI,eAAe,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree Entity
|
|
3
|
-
*
|
|
4
|
-
* Factory functions for creating Worktree objects.
|
|
5
|
-
*/
|
|
6
|
-
import type { Worktree, WorktreeInfo } from '../../types';
|
|
7
|
-
/**
|
|
8
|
-
* Options for creating a new worktree
|
|
9
|
-
*/
|
|
10
|
-
export interface CreateWorktreeOptions {
|
|
11
|
-
path: string;
|
|
12
|
-
branch: string;
|
|
13
|
-
isMain?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Create a new worktree entity from options
|
|
17
|
-
*/
|
|
18
|
-
export declare function createWorktree(options: CreateWorktreeOptions): Worktree;
|
|
19
|
-
/**
|
|
20
|
-
* Create a worktree entity from git WorktreeInfo
|
|
21
|
-
*/
|
|
22
|
-
export declare function worktreeFromInfo(info: WorktreeInfo): Worktree;
|
|
23
|
-
/**
|
|
24
|
-
* Convert multiple WorktreeInfo to Worktree entities
|
|
25
|
-
*/
|
|
26
|
-
export declare function worktreesFromInfoList(infos: WorktreeInfo[]): Worktree[];
|
|
27
|
-
/**
|
|
28
|
-
* Check if a worktree has any sessions
|
|
29
|
-
*/
|
|
30
|
-
export declare function hasSessions(worktree: Worktree): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Get the session count for a worktree
|
|
33
|
-
*/
|
|
34
|
-
export declare function getSessionCount(worktree: Worktree): number;
|
|
35
|
-
//# sourceMappingURL=worktree.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.d.ts","sourceRoot":"","sources":["../../../src/core/worktree/worktree.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG1D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,QAAQ,CAUvE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,CAQ7D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,CAEvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE1D"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worktree Entity
|
|
3
|
-
*
|
|
4
|
-
* Factory functions for creating Worktree objects.
|
|
5
|
-
*/
|
|
6
|
-
import { generateId } from '../../utils';
|
|
7
|
-
/**
|
|
8
|
-
* Create a new worktree entity from options
|
|
9
|
-
*/
|
|
10
|
-
export function createWorktree(options) {
|
|
11
|
-
const { path, branch, isMain = false } = options;
|
|
12
|
-
return {
|
|
13
|
-
id: isMain ? 'main' : generateId(8),
|
|
14
|
-
path,
|
|
15
|
-
branch,
|
|
16
|
-
isMain,
|
|
17
|
-
sessions: [],
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create a worktree entity from git WorktreeInfo
|
|
22
|
-
*/
|
|
23
|
-
export function worktreeFromInfo(info) {
|
|
24
|
-
return {
|
|
25
|
-
id: info.isMain ? 'main' : generateId(8),
|
|
26
|
-
path: info.path,
|
|
27
|
-
branch: info.branch,
|
|
28
|
-
isMain: info.isMain,
|
|
29
|
-
sessions: [],
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Convert multiple WorktreeInfo to Worktree entities
|
|
34
|
-
*/
|
|
35
|
-
export function worktreesFromInfoList(infos) {
|
|
36
|
-
return infos.map(worktreeFromInfo);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if a worktree has any sessions
|
|
40
|
-
*/
|
|
41
|
-
export function hasSessions(worktree) {
|
|
42
|
-
return worktree.sessions.length > 0;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get the session count for a worktree
|
|
46
|
-
*/
|
|
47
|
-
export function getSessionCount(worktree) {
|
|
48
|
-
return worktree.sessions.length;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=worktree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../../src/core/worktree/worktree.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACnC,IAAI;QACJ,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAkB;IACjD,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QACxC,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAqB;IACzD,OAAO,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC5C,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAkB;IAChD,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;AAClC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Worktree } from '../types.js';
|
|
2
|
-
export declare class WorktreeManager {
|
|
3
|
-
private basePath;
|
|
4
|
-
private repoPath;
|
|
5
|
-
private git;
|
|
6
|
-
constructor(repoPath: string, basePath?: string);
|
|
7
|
-
private generateId;
|
|
8
|
-
private ensureBaseDir;
|
|
9
|
-
list(): Promise<Worktree[]>;
|
|
10
|
-
create(branch: string, newBranch?: boolean): Promise<Worktree>;
|
|
11
|
-
remove(path: string, force?: boolean): Promise<void>;
|
|
12
|
-
prune(): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Rename a worktree's branch and move its directory atomically.
|
|
15
|
-
* If either operation fails, rollback any changes.
|
|
16
|
-
*/
|
|
17
|
-
rename(worktreePath: string, oldBranch: string, newBranch: string): Promise<string>;
|
|
18
|
-
/**
|
|
19
|
-
* Get the path of a worktree by branch name
|
|
20
|
-
*/
|
|
21
|
-
getWorktreePath(branch: string): Promise<string | null>;
|
|
22
|
-
getBranches(): Promise<string[]>;
|
|
23
|
-
getRepoPath(): string;
|
|
24
|
-
getBasePath(): string;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=worktree-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worktree-manager.d.ts","sourceRoot":"","sources":["../../src/core/worktree-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAO5C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAY;gBAEX,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAA8B;IAMtE,OAAO,CAAC,UAAU;YAIJ,aAAa;IAQrB,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IA4C3B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyBrE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;OAGG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4BzF;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAMvD,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAStC,WAAW,IAAI,MAAM;IAIrB,WAAW,IAAI,MAAM;CAGtB"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { simpleGit } from 'simple-git';
|
|
2
|
-
import { homedir } from 'os';
|
|
3
|
-
import { join, basename } from 'path';
|
|
4
|
-
import { mkdir, rm, access } from 'fs/promises';
|
|
5
|
-
import { appendFileSync } from 'fs';
|
|
6
|
-
function debugLog(...args) {
|
|
7
|
-
const msg = `[${new Date().toISOString()}] [WorktreeManager] ${args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' ')}\n`;
|
|
8
|
-
appendFileSync('/tmp/claude-pp-debug.log', msg);
|
|
9
|
-
}
|
|
10
|
-
export class WorktreeManager {
|
|
11
|
-
basePath;
|
|
12
|
-
repoPath;
|
|
13
|
-
git;
|
|
14
|
-
constructor(repoPath, basePath = '~/.claude-worktrees') {
|
|
15
|
-
this.repoPath = repoPath;
|
|
16
|
-
this.basePath = basePath.replace('~', homedir());
|
|
17
|
-
this.git = simpleGit(repoPath);
|
|
18
|
-
}
|
|
19
|
-
generateId() {
|
|
20
|
-
return Math.random().toString(36).substring(2, 10);
|
|
21
|
-
}
|
|
22
|
-
async ensureBaseDir() {
|
|
23
|
-
try {
|
|
24
|
-
await access(this.basePath);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
await mkdir(this.basePath, { recursive: true });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async list() {
|
|
31
|
-
try {
|
|
32
|
-
const result = await this.git.raw(['worktree', 'list', '--porcelain']);
|
|
33
|
-
const worktrees = [];
|
|
34
|
-
const blocks = result.trim().split('\n\n');
|
|
35
|
-
for (const block of blocks) {
|
|
36
|
-
if (!block.trim())
|
|
37
|
-
continue;
|
|
38
|
-
const lines = block.split('\n');
|
|
39
|
-
let path = '';
|
|
40
|
-
let branch = '';
|
|
41
|
-
for (const line of lines) {
|
|
42
|
-
if (line.startsWith('worktree ')) {
|
|
43
|
-
path = line.substring(9);
|
|
44
|
-
}
|
|
45
|
-
else if (line.startsWith('branch ')) {
|
|
46
|
-
branch = line.substring(7).replace('refs/heads/', '');
|
|
47
|
-
}
|
|
48
|
-
else if (line === 'detached') {
|
|
49
|
-
branch = '(detached)';
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (path) {
|
|
53
|
-
const isMain = path === this.repoPath;
|
|
54
|
-
worktrees.push({
|
|
55
|
-
id: isMain ? 'main' : this.generateId(),
|
|
56
|
-
path,
|
|
57
|
-
branch: branch || basename(path),
|
|
58
|
-
isMain,
|
|
59
|
-
sessions: [],
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return worktrees;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
// If not a git repo or worktree command fails, return empty
|
|
67
|
-
console.error('Failed to list worktrees:', error);
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async create(branch, newBranch = false) {
|
|
72
|
-
await this.ensureBaseDir();
|
|
73
|
-
const sanitizedBranch = branch.replace(/[^a-zA-Z0-9-_]/g, '-');
|
|
74
|
-
const worktreePath = join(this.basePath, `${basename(this.repoPath)}-${sanitizedBranch}`);
|
|
75
|
-
try {
|
|
76
|
-
if (newBranch) {
|
|
77
|
-
await this.git.raw(['worktree', 'add', '-b', branch, worktreePath]);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
await this.git.raw(['worktree', 'add', worktreePath, branch]);
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
id: this.generateId(),
|
|
84
|
-
path: worktreePath,
|
|
85
|
-
branch,
|
|
86
|
-
isMain: false,
|
|
87
|
-
sessions: [],
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
throw new Error(`Failed to create worktree for branch '${branch}': ${error}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
async remove(path, force = false) {
|
|
95
|
-
debugLog('remove called with path:', path, 'force:', force);
|
|
96
|
-
try {
|
|
97
|
-
const args = ['worktree', 'remove'];
|
|
98
|
-
if (force)
|
|
99
|
-
args.push('--force');
|
|
100
|
-
args.push(path);
|
|
101
|
-
debugLog('Running git', args.join(' '));
|
|
102
|
-
await this.git.raw(args);
|
|
103
|
-
debugLog('git worktree remove succeeded');
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
debugLog('git worktree remove failed:', error);
|
|
107
|
-
// Try to clean up manually if git worktree remove fails
|
|
108
|
-
if (force) {
|
|
109
|
-
debugLog('Attempting manual cleanup');
|
|
110
|
-
await rm(path, { recursive: true, force: true });
|
|
111
|
-
await this.git.raw(['worktree', 'prune']);
|
|
112
|
-
debugLog('Manual cleanup succeeded');
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
throw new Error(`Failed to remove worktree at '${path}': ${error}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async prune() {
|
|
120
|
-
await this.git.raw(['worktree', 'prune']);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Rename a worktree's branch and move its directory atomically.
|
|
124
|
-
* If either operation fails, rollback any changes.
|
|
125
|
-
*/
|
|
126
|
-
async rename(worktreePath, oldBranch, newBranch) {
|
|
127
|
-
const sanitizedNewBranch = newBranch.replace(/[^a-zA-Z0-9-_]/g, '-');
|
|
128
|
-
const newWorktreePath = join(this.basePath, `${basename(this.repoPath)}-${sanitizedNewBranch}`);
|
|
129
|
-
// Step 1: Rename the branch
|
|
130
|
-
try {
|
|
131
|
-
await this.git.raw(['branch', '-m', oldBranch, newBranch]);
|
|
132
|
-
}
|
|
133
|
-
catch (error) {
|
|
134
|
-
throw new Error(`Failed to rename branch '${oldBranch}' to '${newBranch}': ${error}`);
|
|
135
|
-
}
|
|
136
|
-
// Step 2: Move the worktree directory
|
|
137
|
-
try {
|
|
138
|
-
await this.git.raw(['worktree', 'move', worktreePath, newWorktreePath]);
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
// Rollback: rename branch back
|
|
142
|
-
try {
|
|
143
|
-
await this.git.raw(['branch', '-m', newBranch, oldBranch]);
|
|
144
|
-
}
|
|
145
|
-
catch (rollbackError) {
|
|
146
|
-
// Rollback failed - we're in an inconsistent state
|
|
147
|
-
throw new Error(`Failed to move worktree and rollback failed. Manual intervention required. Original error: ${error}`);
|
|
148
|
-
}
|
|
149
|
-
throw new Error(`Failed to move worktree from '${worktreePath}' to '${newWorktreePath}': ${error}`);
|
|
150
|
-
}
|
|
151
|
-
return newWorktreePath;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get the path of a worktree by branch name
|
|
155
|
-
*/
|
|
156
|
-
async getWorktreePath(branch) {
|
|
157
|
-
const worktrees = await this.list();
|
|
158
|
-
const wt = worktrees.find(w => w.branch === branch);
|
|
159
|
-
return wt?.path || null;
|
|
160
|
-
}
|
|
161
|
-
async getBranches() {
|
|
162
|
-
try {
|
|
163
|
-
const result = await this.git.branch(['-a']);
|
|
164
|
-
return result.all;
|
|
165
|
-
}
|
|
166
|
-
catch {
|
|
167
|
-
return [];
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
getRepoPath() {
|
|
171
|
-
return this.repoPath;
|
|
172
|
-
}
|
|
173
|
-
getBasePath() {
|
|
174
|
-
return this.basePath;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=worktree-manager.js.map
|