vde-layout 0.0.9 → 0.1.1

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/README.md CHANGED
@@ -20,7 +20,7 @@ bun add -g vde-layout
20
20
  ```
21
21
 
22
22
  ## Quick Start
23
- 1. Create a YAML file at `~/.config/vde/layout.yml` (or any supported location; see Configuration Search Order).
23
+ 1. Create a YAML file at `~/.config/vde/layout.yml` (or any supported location; see "Configuration Search Order").
24
24
  2. Paste a preset definition:
25
25
  ```yaml
26
26
  presets:
@@ -56,24 +56,24 @@ bun add -g vde-layout
56
56
  ```
57
57
 
58
58
  ## CLI Commands
59
- - `vde-layout [preset]` Apply the named preset. When omitted, vde-layout uses the `default` preset; if none exists it lists available presets and exits.
60
- - `vde-layout list` Show available presets with descriptions.
61
- - `vde-layout dev --dry-run` Display the tmux steps without executing them.
62
- - `vde-layout dev --verbose` Print informational logs, including resolved presets and plan details.
63
- - `vde-layout dev --backend wezterm` Use the WezTerm backend (defaults to `tmux` when omitted).
64
- - `vde-layout dev --current-window` Reuse the current tmux window (or active WezTerm tab) after confirming that other panes can be closed.
65
- - `vde-layout dev --new-window` Force creation of a new tmux window or WezTerm tab even when presets or defaults request reuse.
66
- - `vde-layout --config /path/to/layout.yml` Load presets from a specific file.
67
- - `vde-layout --help` Show usage.
68
- - `vde-layout --version` / `vde-layout -v` Print package version (`-V` is kept for compatibility).
59
+ - `vde-layout [preset]` - Apply the named preset. When omitted, vde-layout uses the `default` preset; if none exists it lists available presets and exits.
60
+ - `vde-layout list` - Show available presets with descriptions.
61
+ - `vde-layout dev --dry-run` - Display the tmux steps without executing them.
62
+ - `vde-layout dev --verbose` - Print informational logs, including resolved presets and plan details.
63
+ - `vde-layout dev --backend wezterm` - Use the WezTerm backend (defaults to `tmux` when omitted).
64
+ - `vde-layout dev --current-window` - Reuse the current tmux window (or active WezTerm tab) after confirming that other panes can be closed.
65
+ - `vde-layout dev --new-window` - Force creation of a new tmux window or WezTerm tab even when presets or defaults request reuse.
66
+ - `vde-layout --config /path/to/layout.yml` - Load presets from a specific file.
67
+ - `vde-layout --help` - Show usage.
68
+ - `vde-layout --version` / `vde-layout -v` - Print package version.
69
69
 
70
70
  > **Note:** Applying a preset (without `--dry-run`) must be done inside an active tmux session when using the tmux backend. For the WezTerm backend, ensure a WezTerm window is running and focused so the CLI can discover it.
71
71
 
72
72
  ## Terminal Backends
73
73
  vde-layout resolves backends in the following order: CLI flag (`--backend`), preset configuration, then defaults to `tmux`.
74
74
 
75
- - **tmux (default)** Requires an active tmux session for non-dry runs. `--current-window` closes other panes in the selected window after confirmation; `--new-window` always creates a new tmux window.
76
- - **WezTerm** Requires the `wezterm` CLI to be available (nightly channel recommended). Start WezTerm beforehand so at least one window exists.
75
+ - **tmux (default)** - Requires an active tmux session for non-dry runs. `--current-window` closes other panes in the selected window after confirmation; `--new-window` always creates a new tmux window.
76
+ - **WezTerm** - Requires the `wezterm` CLI to be available (nightly channel recommended). Start WezTerm beforehand so at least one window exists.
77
77
  - `--current-window` targets the active tab and confirms before closing other panes.
78
78
  - `--new-window` spawns a new tab in the active window when one is available, otherwise creates a fresh window.
79
79
 
@@ -112,6 +112,8 @@ layout:
112
112
  focus: true # optional; only one pane should be true
113
113
  delay: 500 # optional; wait (ms) before running command
114
114
  title: "Server" # optional; tmux pane title
115
+ ephemeral: true # optional; close pane after command completes
116
+ closeOnError: false # optional; if ephemeral, close on error (default: false)
115
117
  - type: vertical # nested split
116
118
  ratio: [1, 1]
117
119
  panes:
@@ -119,11 +121,76 @@ layout:
119
121
  - name: "shell"
120
122
  ```
121
123
 
124
+ ### Template Tokens
125
+ You can reference dynamically-assigned pane IDs within pane commands using template tokens. These tokens are resolved after the layout finishes splitting panes but before commands execute:
126
+
127
+ - **`{{this_pane}}`** - References the current pane receiving the command
128
+ - **`{{focus_pane}}`** - References the pane that will receive focus
129
+ - **`{{pane_id:<name>}}`** - References a specific pane by its name
130
+
131
+ Example:
132
+ ```yaml
133
+ presets:
134
+ cross-pane-demo:
135
+ name: Cross Pane Coordination
136
+ layout:
137
+ type: vertical
138
+ ratio: [2, 1]
139
+ panes:
140
+ - name: editor
141
+ command: 'echo "Editor pane ID: {{this_pane}}"'
142
+ focus: true
143
+ - name: terminal
144
+ command: 'echo "I can reference the editor pane: {{pane_id:editor}}"'
145
+ ```
146
+
147
+ **Common use cases:**
148
+ - Send commands to other panes: `tmux send-keys -t {{pane_id:editor}} "npm test" Enter`
149
+ - Display pane information for debugging: `echo "Current: {{this_pane}}, Focus: {{focus_pane}}"`
150
+ - Coordinate tasks across multiple panes within your preset configuration
151
+
152
+ ### Ephemeral Panes
153
+ Ephemeral panes automatically close after their command completes. This is useful for one-time tasks like builds, tests, or initialization scripts.
154
+
155
+ ```yaml
156
+ panes:
157
+ - name: build
158
+ command: npm run build
159
+ ephemeral: true # Pane closes when command finishes
160
+ ```
161
+
162
+ **Error handling:**
163
+ - By default, ephemeral panes remain open if the command fails, allowing you to inspect errors
164
+ - Set `closeOnError: true` to close the pane regardless of success or failure
165
+
166
+ ```yaml
167
+ panes:
168
+ - name: quick-test
169
+ command: npm test
170
+ ephemeral: true
171
+ closeOnError: false # Default: stays open on error
172
+
173
+ - name: build-and-exit
174
+ command: npm run build
175
+ ephemeral: true
176
+ closeOnError: true # Closes even if build fails
177
+ ```
178
+
179
+ **Combining with template tokens:**
180
+ ```yaml
181
+ panes:
182
+ - name: editor
183
+ command: nvim
184
+ - name: test-runner
185
+ command: 'tmux send-keys -t {{pane_id:editor}} ":!npm test" Enter'
186
+ ephemeral: true # Run once and close
187
+ ```
188
+
122
189
  ### Ratio Normalization
123
190
  Ratios can be any set of positive integers. vde-layout normalizes them to percentages:
124
- - `[1, 1]` `[50, 50]`
125
- - `[2, 3]` `[40, 60]`
126
- - `[1, 2, 1]` `[25, 50, 25]`
191
+ - `[1, 1]` -> `[50, 50]`
192
+ - `[2, 3]` -> `[40, 60]`
193
+ - `[1, 2, 1]` -> `[25, 50, 25]`
127
194
 
128
195
  ### Single Command Presets
129
196
  If you omit `layout`, the preset runs a single command in one pane (or opens the default shell when `command` is omitted):
@@ -149,11 +216,11 @@ presets:
149
216
  - If an error occurs (for example, a tmux command fails or the configuration is invalid), vde-layout returns a structured error with the failing step and guidance.
150
217
 
151
218
  ## Environment Variables
152
- - `VDE_CONFIG_PATH` Override the base directory for configuration files.
153
- - `XDG_CONFIG_HOME` XDG base directory root; defaults to `~/.config` when unset.
154
- - `VDE_DEBUG=true` Enable debug-level logs (includes stack traces).
155
- - `VDE_VERBOSE=true` Enable info-level logs without full debug output.
156
- - `TMUX` Automatically set by tmux. vde-layout checks this to ensure execution happens inside a session.
219
+ - `VDE_CONFIG_PATH` - Override the base directory for configuration files.
220
+ - `XDG_CONFIG_HOME` - XDG base directory root; defaults to `~/.config` when unset.
221
+ - `VDE_DEBUG=true` - Enable debug-level logs (includes stack traces).
222
+ - `VDE_VERBOSE=true` - Enable info-level logs without full debug output.
223
+ - `TMUX` - Automatically set by tmux. vde-layout checks this to ensure execution happens inside a session.
157
224
 
158
225
  ## Requirements
159
226
  - Node.js 22 or higher