Commit f5b5a73
feat: add yolo mode to auto-approve permission prompts (#240)
* feat: add `--yolo` mode to auto-approve permission prompts
- Add `ALTIMATE_CLI_YOLO` / `OPENCODE_YOLO` env var flag
- Add `--yolo` as global CLI option (works with any subcommand)
- Add `--yolo` on `run` command for convenience
- Auto-approve (`"once"`) instead of auto-reject in headless mode
- Auto-approve in TUI via env var (skip permission prompt rendering)
- Global `--yolo` propagates to env var in middleware so all paths pick it up
- Explicit `deny` rules still enforced (safety by construction)
- Update permissions docs with Yolo Mode section
Closes #239
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix: yolo mode — dynamic getter, ACP support, adversarial tests
- CRITICAL FIX: `Flag.ALTIMATE_CLI_YOLO` was a static `const` evaluated at
module load time. `--yolo` CLI flag sets env var in middleware (after load),
so the flag was always `false` via CLI. Now uses `Object.defineProperty`
dynamic getter like other runtime-set flags.
- Add yolo mode handling to ACP agent (`acp/agent.ts`) — was missing,
causing ACP clients to hang on permission prompts even with `--yolo`
- Replace unsafe `(opts as any).yolo` with `"yolo" in opts && opts.yolo`
- Add 26 adversarial tests covering:
- Dynamic getter timing (the critical bug)
- Env var parsing edge cases (empty, arbitrary strings, case)
- Deny rules cannot be bypassed by yolo (safety by construction)
- Case sensitivity of deny patterns
- Multiple ruleset merge precedence
- Error type distinction (`DeniedError` vs `RejectedError`)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix: yolo mode — dynamic getter, ACP support, adversarial tests
- CRITICAL FIX: `Flag.ALTIMATE_CLI_YOLO` was a static `const` evaluated at
module load time. `--yolo` CLI flag sets env var in middleware (after load),
so the flag was always `false` via CLI. Now uses `Object.defineProperty`
dynamic getter like other runtime-set flags.
- Add yolo mode handling to ACP agent (`acp/agent.ts`) — was missing,
causing ACP clients to hang on permission prompts even with `--yolo`
- Replace unsafe `(opts as any).yolo` with `"yolo" in opts && opts.yolo`
- Add 26 adversarial tests covering:
- Dynamic getter timing (the critical bug)
- Env var parsing edge cases (empty, arbitrary strings, case)
- Deny rules cannot be bypassed by yolo (safety by construction)
- Case sensitivity of deny patterns
- Multiple ruleset merge precedence
- Error type distinction (`DeniedError` vs `RejectedError`)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* feat: E2E tests, TUI yolo indicator, minor review fixes
1. **E2E tests** (6 new integration tests):
- Deny rules throw `DeniedError` even with yolo env var set
- Allow rules pass without asking (no yolo needed)
- Ask rules wait for reply, resolved by yolo-style `"once"`
- Multiple simultaneous permissions all resolved individually
- Mixed deny + ask: deny throws, ask waits for reply
- Config-driven permissions: yolo auto-approves `ask`, can't touch `deny`
2. **TUI yolo indicator** — `△ YOLO` warning in footer status bar
when yolo mode is active, matching existing permission warning style
3. **Minor review fixes:**
- Remove duplicate `--yolo` option from `run.ts` (inherited from global)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* docs: update yolo mode documentation
- Remove "subcommand flag" section (duplicate --yolo removed from run.ts)
- Explain WHY deny rules are still enforced (thrown before events)
- Document env var precedence (ALTIMATE_CLI_YOLO overrides OPENCODE_YOLO)
- Mention TUI footer indicator
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>1 parent a3d3176 commit f5b5a73
File tree
8 files changed
+610
-9
lines changed- docs/docs/configure
- packages/opencode
- src
- acp
- cli/cmd
- tui
- context
- routes/session
- flag
- test
8 files changed
+610
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
110 | 134 | | |
111 | 135 | | |
112 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| |||
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
191 | 205 | | |
192 | 206 | | |
193 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
676 | 691 | | |
677 | 692 | | |
678 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
139 | 158 | | |
140 | 159 | | |
141 | 160 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
142 | 164 | | |
143 | 165 | | |
144 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
| |||
0 commit comments