workon 3.6.0 → 3.7.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
@@ -288,6 +288,131 @@ eval "$(workon myproject --shell)"
288
288
  workon myproject --shell
289
289
  ```
290
290
 
291
+ ## For AI Agents
292
+
293
+ All worktree commands support a `-y, --yes` flag that skips interactive prompts, making them safe to call from AI agents, scripts, and CI pipelines.
294
+
295
+ ### Non-Interactive Worktree Lifecycle
296
+
297
+ ```bash
298
+ # Create a worktree (auto-defaults base branch to current)
299
+ workon worktrees add feat-x -b main -y
300
+
301
+ # Create and immediately open a session
302
+ workon worktrees add feat-x -b main -y -o
303
+
304
+ # Open an existing worktree session
305
+ workon worktrees open feat-x -y
306
+
307
+ # Create a branch from a worktree and push it
308
+ workon worktrees branch feat-x my-branch -y -p
309
+
310
+ # Merge, remove worktree, and delete the branch
311
+ workon worktrees merge feat-x -i main -y --delete-branch
312
+
313
+ # Force-remove a worktree with uncommitted changes
314
+ workon worktrees remove feat-x -y -f
315
+ ```
316
+
317
+ ### Colon Syntax with Worktrees
318
+
319
+ Run specific events in a worktree using the extended colon syntax:
320
+
321
+ ```bash
322
+ # project:events:worktree-name
323
+ workon myproject:cwd:feat-x # cd into worktree
324
+ workon myproject:claude:feat-x # open Claude in worktree
325
+ workon myproject:cwd,claude:feat-x # specific events in worktree
326
+ workon myproject::feat-x # all events in worktree
327
+ ```
328
+
329
+ ### Non-Interactive Flags Reference
330
+
331
+ > **`worktrees` (plural)** = manage worktrees from the **main repo**.
332
+ > **`worktree` (singular)** = operate on the worktree **you're currently inside**.
333
+
334
+ **`workon worktrees` (from main repo)**
335
+
336
+ | Command | Flag | Effect when set |
337
+ |---------|------|-----------------|
338
+ | `worktrees add` | `-y, --yes` | Skips registration prompt, auto-defaults base branch, skips "open session?" prompt |
339
+ | `worktrees add` | `-b, --base <branch>` | Sets base branch (avoids branch selection prompt) |
340
+ | `worktrees add` | `-o, --open` | Opens session after creation (avoids prompt) |
341
+ | `worktrees add` | `--no-hook` | Skips post-setup hook |
342
+ | `worktrees open` | `-y, --yes` | Skips registration prompt |
343
+ | `worktrees branch` | `-y, --yes` | Skips "push to origin?" prompt (use `-p` to push) |
344
+ | `worktrees branch` | `-p, --push` | Pushes branch (avoids prompt) |
345
+ | `worktrees remove` | `-y, --yes` | Skips confirmation prompt |
346
+ | `worktrees remove` | `-f, --force` | Force-removes with uncommitted changes |
347
+ | `worktrees remove` | `--no-hook` | Skips pre-teardown hook |
348
+ | `worktrees merge` | `-y, --yes` | Skips all prompts, auto-selects target branch (main/master/develop/dev) |
349
+ | `worktrees merge` | `-i, --into <branch>` | Sets target branch explicitly |
350
+ | `worktrees merge` | `-s, --squash` | Uses squash merge (default: regular merge) |
351
+ | `worktrees merge` | `-k, --keep` | Keeps worktree after merge |
352
+ | `worktrees merge` | `--delete-branch` | Deletes merged branch (avoids prompt) |
353
+
354
+ **`workon worktree` (from inside a worktree)**
355
+
356
+ | Command | Flag | Effect when set |
357
+ |---------|------|-----------------|
358
+ | `worktree merge` | `-y, --yes` | Skips all prompts, auto-selects target branch (main/master/develop/dev) |
359
+ | `worktree merge` | `-i, --into <branch>` | Sets target branch explicitly |
360
+ | `worktree merge` | `-s, --squash` | Uses squash merge (default: regular merge) |
361
+ | `worktree merge` | `--delete-branch` | Deletes merged branch (avoids prompt) |
362
+ | `worktree remove` | `-y, --yes` | Skips confirmation prompt |
363
+ | `worktree remove` | `-f, --force` | Force-removes with uncommitted changes |
364
+
365
+ ### Commands That Are Already Non-Interactive
366
+
367
+ These commands produce output only and never prompt:
368
+
369
+ - `workon worktrees list` / `workon worktrees list -a`
370
+ - `workon worktree` / `workon worktree status`
371
+
372
+ ### Example: Automating a Feature Branch Workflow
373
+
374
+ This is a typical developer workflow that can be fully automated by an AI agent using the non-interactive flags. Here's the manual version compared to the automated version:
375
+
376
+ **Manual workflow (interactive):**
377
+
378
+ ```bash
379
+ # 1. cd into the project
380
+ workon my-project:cwd
381
+
382
+ # 2. Create a worktree (prompts for base branch, open session, etc.)
383
+ workon worktrees add my-feature
384
+
385
+ # 3. Do your work...
386
+
387
+ # 4. Push, create a PR, get it reviewed and merged
388
+
389
+ # 5. Tear down the worktree
390
+ workon worktrees remove my-feature
391
+ ```
392
+
393
+ **Automated workflow (non-interactive, agent-friendly):**
394
+
395
+ ```bash
396
+ # 1. cd into the project
397
+ workon my-project:cwd
398
+
399
+ # 2. Create a worktree and open a session — no prompts
400
+ workon worktrees add my-feature -b main -y -o
401
+
402
+ # 3. Agent does the work in the worktree...
403
+ # (or use colon syntax to target it directly)
404
+ # workon my-project:claude:my-feature
405
+
406
+ # 4. Push, create a PR, get it reviewed and merged
407
+ workon worktrees branch my-feature pr-branch -y -p
408
+ # ... PR merged via gh/API ...
409
+
410
+ # 5. Tear down: remove worktree and delete the branch
411
+ workon worktrees remove my-feature -y
412
+ ```
413
+
414
+ The key difference is that every step in the automated version completes without waiting for user input, making it safe to chain together in scripts or have an AI agent drive the entire flow.
415
+
291
416
  ## Advanced Usage
292
417
 
293
418
  ### Environment Detection