diff --git a/docs/shell/scripts.md b/docs/shell/scripts.md index df375f0..56dcf77 100644 --- a/docs/shell/scripts.md +++ b/docs/shell/scripts.md @@ -481,6 +481,7 @@ pj-palette's background task sessions (`@pj_task`) are left out. Sessions are ta ```sh workmux-palette workmux-palette --add BRANCH +workmux-palette --prompt workmux-palette --popup DIR CMD… workmux-palette --do DIR CMD… ``` @@ -493,7 +494,7 @@ With no arguments it prints palette items as JSON, grouped by category: | --- | --- | --- | | Agents | Every agent `workmux status --all --json` tracks in this tmux server: waiting (yellow), done (green), working (blue), then idle, most recent first. Title `/`, description status, time since the change, and the pane title | `switch-client` to the agent's pane | | Worktrees: `` | The active pane's repo's worktrees (`workmux list --json`, main checkout left out): branch, open/closed, dirty, path. Open ones are green | `workmux open` (starts the session if closed) | -| New | **New worktree from a prompt**, when the pane is in a repo | `workmux add -A -e` in a popup: `$EDITOR` for the prompt, omp names the branch | +| New | **New worktree from a prompt**, when the pane is in a repo | `--prompt` in a popup: `gum write` for the task, then `workmux add -A -p TASK` (omp names the branch, see [workmux](../tools/workmux.md#branch-names)) | | Workmux | **Dashboard** (90% popup), **Sidebar** (toggle), **Last done** (`workmux last-done`) | | | Close | One per open worktree | `workmux close`: ends the session, keeps worktree and branch | | Merge | One per worktree | `workmux merge` in a popup | @@ -501,9 +502,11 @@ With no arguments it prints palette items as JSON, grouped by category: **`--add BRANCH`** is the palette's `query` item: the typed text, listed after the matches, becomes `workmux add BRANCH` in the active pane's directory, so a branch name that matches nothing creates its worktree and session and switches to it. +**`--prompt`** is the New item's popup body. `gum write` takes the task: enter submits, ctrl+j inserts a newline, ctrl+e opens `$EDITOR`, esc cancels (the popup closes, nothing is created). An empty task does nothing. + **`--popup DIR CMD…`** runs CMD in DIR in an 80% × 60% popup (argv form, so nothing is re-parsed by a shell or by tmux formats). The popup closes when CMD succeeds; on failure it shows `[exit N]` and waits for a key. **`--do DIR CMD…`** runs CMD in place and shows the last output line as a tmux message when it fails. -**Needs:** tmux, `jq`, `git`, `workmux`. +**Needs:** tmux, `jq`, `git`, `gum`, `workmux`. ## yazi-nvim-open diff --git a/docs/tools/workmux.md b/docs/tools/workmux.md index 611913c..04dca12 100644 --- a/docs/tools/workmux.md +++ b/docs/tools/workmux.md @@ -21,6 +21,7 @@ workmux global config: one git worktree and one tmux session per agent, driven f | `worktree_dir` | `~/Work/{project}` | Worktrees land in `~/Work//`, next to worktrunk's `~/Work/-`. | | `base_branch` | `auto` | New branches start from the repo's main branch, not the branch the pane is on. | | `agent` | `omp` | `` runs omp; it receives `-p`/`-P`/`-e` prompts and names branches for `add -A`. | +| `auto_name.system_prompt` | rules below | Keeps `add -A` branch names short (see [Branch names](#branch-names)). | | `windows` | omp (focused), nvim | Two unnamed windows, so `automatic-rename-format` labels them like every other tab. | | `status_format` | `false` | workmux leaves `window-status-format` alone; `tmux.conf` renders `#{@workmux_status}` itself (see [Window tabs](../terminal/tmux.md#window-tabs)). | @@ -29,3 +30,7 @@ A `.workmux.yaml` in a repo overrides any of these. ## Agent status The omp extension reports `working`, `waiting`, and `done`. workmux stores the icon in the window option `@workmux_status`, which the tab formats print after the label. The palette's Agents group reads `workmux status --all --json`. + +## Branch names + +`workmux add -A` (the palette's New item) pipes the task to `omp --no-session -p` with `auto_name.system_prompt`. The name becomes the worktree directory, the tab label (cut at 27 characters), and the session `/` in the session pill (`status-left-length 30`), so the prompt asks for kebab-case, 1–2 words (3 if needed), at most 16 characters, the subject rather than the method, filler words dropped, common short forms (`auth`, `config`, `nav`, `anim`, …), and no `feat/`-style prefixes. Checked with `--dry-run`: a menu-bar tap/expand animation task → `menubar-expand`, a macOS codesigning CI failure → `codesign-fix`, plugin API docs → `plugin-api-docs`. The model can still overshoot; the prompt is guidance, not a hard cap. diff --git a/dot_config/workmux/config.yaml b/dot_config/workmux/config.yaml index 5df7830..7b578aa 100644 --- a/dot_config/workmux/config.yaml +++ b/dot_config/workmux/config.yaml @@ -20,6 +20,34 @@ base_branch: auto # omp gets the prompt (-p/-P/-e) and names branches for `add -A`. agent: omp +# `add -A` (the palette's New item) asks omp for the branch name. The name is +# the worktree dir, the session / in the 30-column status-left +# pill, and the tab label (cut at 27), so keep it to ~16 characters. +auto_name: + system_prompt: | + Generate a git branch name for the task below. It is shown in narrow + terminal tabs that cut it off after about 16 characters, so it must be + short and readable at a glance. + + Rules: + - kebab-case: lowercase letters, digits and hyphens only + - 1-2 words, 3 only when needed; 16 characters at most + - name the thing being changed, not how: drop filler words such as + add, implement, make, update, support, feature, the, with + - use common short forms when clear: auth, config, nav, anim, perf, + deps, docs, ui, api, db + - no type prefixes such as feat/ or fix/; use "fix" as a word only + when the task is a bug fix + + Examples: + - "Make the cards tappable and expandable with an animation" -> card-expand + - "Fix the search results not showing" -> search-fix + - "Add a dark mode toggle to settings" -> dark-mode + - "Refactor the authentication module" -> auth-refactor + - "Add CSV export to the reports page" -> csv-export + + Output only the branch name, nothing else. + # Windows stay unnamed so tmux.conf's automatic-rename-format labels them # (omp icon + repo, nvim icon + file) like every other tab. windows: diff --git a/dot_local/bin/executable_workmux-palette b/dot_local/bin/executable_workmux-palette index 55aa391..485ca55 100755 --- a/dot_local/bin/executable_workmux-palette +++ b/dot_local/bin/executable_workmux-palette @@ -10,6 +10,9 @@ # sidebar and last-done tools # workmux-palette --add BRANCH the palette's query item (what was typed): # `workmux add BRANCH` in the active pane's repo +# workmux-palette --prompt the New item's popup body: `gum write` the +# task (enter submits, ctrl+j newline, esc +# cancels), then `workmux add -A -p TASK` # workmux-palette --popup DIR CMD… # run CMD… in DIR in a popup that closes when it # succeeds and waits for a key when it fails @@ -38,7 +41,8 @@ case ${1-} in dir=$2 shift 2 # argv form: tmux runs it without a shell and expands no formats in it. - exec tmux display-popup -E -w 80% -h 60% -d "$dir" -T " ${*//#/##} " "$self" --exec "$@" + title=${*/#"$self"/${self##*/}} + exec tmux display-popup -E -w 80% -h 60% -d "$dir" -T " ${title//#/##} " "$self" --exec "$@" ;; --do) cd "$2" || exit 1 @@ -53,6 +57,15 @@ case ${1-} in cwd=$(tmux display -p '#{pane_current_path}') exec "$self" --popup "$cwd" workmux add "$2" ;; +--prompt) + # The branch name comes from omp under auto_name in workmux's config.yaml. + task=$(gum write --width 0 --height 8 \ + --header "New worktree in ${PWD##*/}: describe the task (enter submits, ctrl+j newline, esc cancels)" \ + --placeholder "What should the agent do?") || exit 0 + [ -n "${task//[[:space:]]/}" ] || exit 0 + printf '→ naming the branch…\n' + exec workmux add -A -p "$task" + ;; esac cwd=$(tmux display -p '#{pane_current_path}' 2>/dev/null) || cwd=$PWD @@ -91,8 +104,8 @@ workmux status --all --json 2>/dev/null | jq --arg self "$self" --arg home "$HOM + (if .is_open then {iconColor: "#5eff6c"} else {} end)), (if $root == "" then empty else {category: "New", icon: "\uf067", title: "New worktree from a prompt", - description: "write the prompt in $EDITOR; omp names the branch · \($repo)", - aliases: ["add", "prompt"], action: run("--popup"; ["workmux", "add", "-A", "-e"])} + description: "type the task (gum write); omp names the branch · \($repo)", + aliases: ["add", "prompt"], action: run("--popup"; [$self, "--prompt"])} end), {category: "Workmux", icon: "\uf0e4", title: "Dashboard", description: "agents and worktrees TUI in a popup", aliases: ["dash"], action: {tmux: "display-popup -E -w 90% -h 90% workmux dashboard"}},