@ohzw/worktree-command-tui 0.1.1 → 0.1.3

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.
Files changed (46) hide show
  1. package/README.md +91 -26
  2. package/dist/app.d.ts +1 -1
  3. package/dist/app.js +242 -114
  4. package/dist/components/ActionPanel.d.ts +4 -2
  5. package/dist/components/ActionPanel.js +87 -135
  6. package/dist/components/ContextBar.d.ts +4 -1
  7. package/dist/components/ContextBar.js +29 -3
  8. package/dist/components/Header.js +5 -1
  9. package/dist/components/HelpWindow.d.ts +7 -0
  10. package/dist/components/HelpWindow.js +29 -0
  11. package/dist/components/LogPanel.d.ts +10 -3
  12. package/dist/components/LogPanel.js +240 -33
  13. package/dist/components/WorktreeList.js +20 -40
  14. package/dist/core/command-runner.d.ts +11 -0
  15. package/dist/core/command-runner.js +59 -7
  16. package/dist/core/config-lifecycle.d.ts +25 -0
  17. package/dist/core/config-lifecycle.js +160 -0
  18. package/dist/core/config.d.ts +2 -3
  19. package/dist/core/config.js +0 -48
  20. package/dist/core/git-metadata.d.ts +25 -0
  21. package/dist/core/git-metadata.js +84 -0
  22. package/dist/core/git-worktrees.d.ts +2 -1
  23. package/dist/core/git-worktrees.js +30 -11
  24. package/dist/core/github-metadata.d.ts +21 -0
  25. package/dist/core/github-metadata.js +153 -0
  26. package/dist/core/init.d.ts +3 -2
  27. package/dist/core/init.js +9 -57
  28. package/dist/core/log-reader.d.ts +7 -0
  29. package/dist/core/log-reader.js +59 -0
  30. package/dist/core/posix-process.d.ts +2 -2
  31. package/dist/core/posix-process.js +19 -4
  32. package/dist/core/process-control.d.ts +2 -2
  33. package/dist/core/process-control.js +5 -2
  34. package/dist/core/runtime-state.d.ts +42 -0
  35. package/dist/core/runtime-state.js +125 -0
  36. package/dist/core/runtime.d.ts +19 -39
  37. package/dist/core/runtime.js +112 -216
  38. package/dist/core/session-store.js +22 -7
  39. package/dist/core/tui-interaction.d.ts +31 -0
  40. package/dist/core/tui-interaction.js +59 -0
  41. package/dist/core/worktree-projection.d.ts +76 -0
  42. package/dist/core/worktree-projection.js +132 -0
  43. package/dist/main.js +6 -5
  44. package/dist/terminal/viewport.d.ts +15 -0
  45. package/dist/terminal/viewport.js +49 -0
  46. package/package.json +1 -1
package/README.md CHANGED
@@ -1,20 +1,27 @@
1
1
  # worktree-command-tui
2
2
 
3
- `worktree-command-tui` is a terminal UI (TUI) tool for operating multiple Git worktrees from one repository.
4
- It helps you inspect, start, and stop per-worktree processes with quick keyboard-driven workflows.
3
+ `worktree-command-tui` is a terminal UI for managing Git worktrees from inside a repository.
4
+ It keeps one active runtime session per namespace, lets you switch worktrees with the keyboard, and keeps logs/process cleanup tied to the repo's shared Git state.
5
5
 
6
6
  ## Features
7
7
 
8
- - List and monitor worktrees for the current repository
9
- - Start/stop worktree-specific commands
10
- - Keep process handling centralized for each session
11
- - Persist namespace-aware runtime state
12
- - Support JSONC config (with comments and trailing commas)
8
+ - Discover worktrees from the current repository even when launched from a subdirectory
9
+ - Start or switch the active worktree session with `Enter`
10
+ - Stop the active session and clean up recorded orphan processes with `s`
11
+ - Run an optional per-worktree setup command with `i`
12
+ - Open the selected worktree in your editor with `e`
13
+ - Open the selected branch's pull request in a browser with `o`
14
+ - Delete a non-root worktree from the TUI with `d`, then confirm
15
+ - Inspect branch, upstream, working tree, and pull request metadata in the detail pane
16
+ - Tail ANSI-colored logs inline or in a full-screen log view
17
+ - Generate and load JSONC config with comments and trailing commas
13
18
 
14
19
  ## Requirements
15
20
 
16
21
  - Node.js `>=20`
17
- - A Git repository in the target working directory
22
+ - Git
23
+ - A Git repository (additional linked worktrees optional)
24
+ - Optional: GitHub CLI (`gh`) and a GitHub origin remote for pull request metadata and `o` / Open PR
18
25
 
19
26
  ## Installation
20
27
 
@@ -22,19 +29,24 @@ It helps you inspect, start, and stop per-worktree processes with quick keyboard
22
29
  npm install -g @ohzw/worktree-command-tui
23
30
  ```
24
31
 
25
- ## Usage
32
+ Installed binaries:
26
33
 
27
- ### 1) Initialize configuration
34
+ - `wctui`
35
+ - `worktree-command-tui` (compatibility alias)
28
36
 
29
- Run this once in a repository root (or any subdirectory of the repository):
37
+ ## Quick start
38
+
39
+ ### 1) Initialize config
40
+
41
+ Run this from the repo root or any subdirectory inside the repo:
30
42
 
31
43
  ```bash
32
44
  wctui init
33
45
  ```
34
46
 
35
- This creates `.worktree-command-tui.jsonc` with a sensible default configuration.
47
+ This writes `.worktree-command-tui.jsonc` at the repository root.
36
48
 
37
- To regenerate an existing configuration:
49
+ To overwrite an existing config:
38
50
 
39
51
  ```bash
40
52
  wctui init --force
@@ -46,41 +58,94 @@ wctui init --force
46
58
  wctui
47
59
  ```
48
60
 
49
- `worktree-command-tui` is still available as a compatibility alias.
61
+ If config is missing, the CLI exits with a message telling you to run `wctui init`.
62
+
63
+ ## Keyboard shortcuts
64
+
65
+ Primary shortcuts in the footer:
66
+
67
+ - `↑↓` / `j` `k` — move selection
68
+ - `Enter` — start or switch to selected worktree
69
+ - `i` — run `setupCommand` when configured
70
+ - `e` — open the selected worktree in the configured editor when `editorCommand` is configured
71
+ - `o` — open the selected worktree's pull request when GitHub metadata is available
72
+ - `d` — arm worktree deletion
73
+ - `L` — open full-screen logs
74
+ - `s` — stop active session
75
+ - `r` — refresh worktree metadata
76
+ - `?` — show help
77
+ - `q` — quit
78
+
79
+ Additional shortcuts from the help window:
80
+
81
+ - `g` / `G` — jump to first / last worktree
82
+ - `[` / `]` — scroll logs
83
+ - `PageUp` / `PageDn` — page the selection list
84
+ - Mouse wheel — scroll the pane under the cursor
85
+ - `d` / `y` — confirm delete after arming it
86
+ - `Esc` / `n` / `q` — cancel delete confirmation
87
+
88
+ ## Security and network behavior
89
+
90
+ `wctui` executes the argv commands stored in `.worktree-command-tui.jsonc` when you press the matching keys. Treat repository config as trusted code:
91
+
92
+ - `Enter` starts `command` in the selected worktree.
93
+ - `i` runs `setupCommand`; package-manager install commands may run dependency lifecycle scripts.
94
+ - `e` runs `editorCommand` with the selected worktree path appended.
50
95
 
51
- If no configuration file is found, the CLI will prompt you to run `wctui init`.
96
+ Review config before using those actions in an untrusted repository or worktree.
97
+
98
+ The TUI also reads pull request metadata with the GitHub CLI when `remote.origin.url` points at `github.com`. This uses `gh api`, your existing `gh` authentication, and a short timeout. Non-GitHub remote hosts are ignored by default.
52
99
 
53
100
  ## Configuration
54
101
 
55
- The tool reads these files in this order:
102
+ The tool looks for config in this order:
56
103
 
57
104
  1. `.worktree-command-tui.jsonc`
58
105
  2. `.worktree-command-tui.json`
59
106
 
60
- A minimal example of the generated config:
107
+ Example config:
61
108
 
62
109
  ```jsonc
63
110
  {
64
- // Session namespace used for logs/state
111
+ // Session namespace used for git-common-dir state files and logs.
65
112
  "namespace": "worktree-command-tui",
66
- // Command executed in each selected worktree
67
- "command": ["npm", "run", "start"],
68
- // Port used for cleanup/monitoring
113
+
114
+ // Command launched in the selected worktree.
115
+ "command": ["npm", "run", "dev"],
116
+
117
+ // Optional command run manually with the setup key in the selected worktree.
118
+ "setupCommand": ["npm", "install"],
119
+
120
+ // Optional command that opens the selected worktree path in an editor.
121
+ // The selected worktree path is appended as the final argv entry.
122
+ "editorCommand": ["code"],
123
+
124
+ // TCP port owned by the command, used when stopping stale/orphaned processes.
69
125
  "port": 3000,
70
- // Required files that must exist in a worktree
126
+
127
+ // Files that must exist in a worktree before the command can be started there.
71
128
  "requiredFiles": ["package.json"],
72
- // Optional command substrings considered orphaned processes
129
+
130
+ // Extra process command-line substrings treated as orphans for cleanup.
73
131
  "orphanMatchers": []
74
132
  }
75
133
  ```
76
134
 
135
+ Notes:
136
+
137
+ - `setupCommand` is optional and never runs automatically; `i` only appears when it is configured
138
+ - `editorCommand` is optional; when set, the selected worktree path is appended to the argv and `e` becomes available
139
+ - The generated default config auto-detects package manager hints from `packageManager` or common lockfiles and chooses a default script such as `dev`, `start`, or `serve`
140
+ - Session records and logs are stored under the repository's Git common dir, so they are shared across worktrees in the same repo
141
+
77
142
  ## Development
78
143
 
79
144
  ```bash
80
145
  npm install
81
- npm run test # Run test suite
82
- npm run typecheck # Run TypeScript type-check
83
- npm run build # Build distributable output to dist/
146
+ npm test
147
+ npm run typecheck
148
+ npm run build
84
149
  ```
85
150
 
86
151
  ## License
package/dist/app.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare function getMouseWheelDelta(input: string): number;
14
14
  export declare function getShellDimensions(columns: number, rows: number): ShellDimensions;
15
15
  export declare function shouldUseCompactLayout(_columns: number, _rows: number, _worktreeCount?: number): boolean;
16
16
  export declare function shouldUseMinimalLayout(columns: number, rows: number): boolean;
17
- export declare function shouldStackPanes(columns: number, rows: number, worktreeCount?: number): boolean;
17
+ export declare function shouldStackPanes(columns: number, rows: number, _worktreeCount?: number): boolean;
18
18
  export declare function App({ initialModel, actions, windowSizeOverride, }: {
19
19
  initialModel: AppModel;
20
20
  actions: AppActions;