@@ -1305,6 +1305,175 @@ func TestEntrypointHashWithInstallScript(t *testing.T) {
13051305 }
13061306}
13071307
1308+ // --- Yolo flag mapping regression tests ---
1309+
1310+ func TestYoloFlagForAgent (t * testing.T ) {
1311+ tests := []struct {
1312+ agent string
1313+ flag string
1314+ supported bool
1315+ }{
1316+ {"claude" , "--dangerously-skip-permissions" , true },
1317+ {"copilot" , "--allow-all-tools" , true },
1318+ {"gemini" , "--yolo" , true },
1319+ {"codex" , "--yolo" , true },
1320+ {"qwen" , "--yolo" , true },
1321+ {"cline" , "--yolo" , true },
1322+ {"kilocode" , "--yolo" , true },
1323+ {"crush" , "--yolo" , true },
1324+
1325+ // Unsupported agents — must not inject any flag
1326+ {"pi" , "" , false },
1327+ {"opencode" , "" , false },
1328+ {"goose" , "" , false },
1329+ {"droid" , "" , false },
1330+ {"unknown" , "" , false },
1331+ }
1332+
1333+ for _ , tt := range tests {
1334+ t .Run (tt .agent , func (t * testing.T ) {
1335+ flag , ok := yoloFlagForAgent (tt .agent )
1336+ if ok != tt .supported {
1337+ t .Fatalf ("yoloFlagForAgent(%q): supported=%v, want %v" , tt .agent , ok , tt .supported )
1338+ }
1339+ if flag != tt .flag {
1340+ t .Fatalf ("yoloFlagForAgent(%q): flag=%q, want %q" , tt .agent , flag , tt .flag )
1341+ }
1342+ })
1343+ }
1344+ }
1345+
1346+ func TestShouldEnableYolo (t * testing.T ) {
1347+ t .Run ("yolo_all enables any agent" , func (t * testing.T ) {
1348+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1349+ if ! shouldEnableYolo ("pi" , cfg ) {
1350+ t .Fatal ("expected yolo_all to enable yolo for any agent" )
1351+ }
1352+ })
1353+
1354+ t .Run ("per-agent list enables listed agent" , func (t * testing.T ) {
1355+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAgents : []string {"claude" }}}
1356+ if ! shouldEnableYolo ("claude" , cfg ) {
1357+ t .Fatal ("expected per-agent list to enable claude" )
1358+ }
1359+ })
1360+
1361+ t .Run ("per-agent list does not enable unlisted agent" , func (t * testing.T ) {
1362+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAgents : []string {"claude" }}}
1363+ if shouldEnableYolo ("pi" , cfg ) {
1364+ t .Fatal ("expected per-agent list not to enable pi" )
1365+ }
1366+ })
1367+
1368+ t .Run ("per-agent list with all enables any agent" , func (t * testing.T ) {
1369+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAgents : []string {"all" }}}
1370+ if ! shouldEnableYolo ("pi" , cfg ) {
1371+ t .Fatal ("expected 'all' in yolo_agents to enable any agent" )
1372+ }
1373+ })
1374+
1375+ t .Run ("empty config disables yolo" , func (t * testing.T ) {
1376+ cfg := & config.Config {}
1377+ if shouldEnableYolo ("claude" , cfg ) {
1378+ t .Fatal ("expected empty config to disable yolo" )
1379+ }
1380+ })
1381+
1382+ t .Run ("per-agent list is case-insensitive" , func (t * testing.T ) {
1383+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAgents : []string {"Claude" }}}
1384+ if ! shouldEnableYolo ("claude" , cfg ) {
1385+ t .Fatal ("expected case-insensitive match for Claude" )
1386+ }
1387+ })
1388+ }
1389+
1390+ func TestApplyYoloArgs (t * testing.T ) {
1391+ t .Run ("nil config returns args unchanged" , func (t * testing.T ) {
1392+ args := []string {"claude" }
1393+ got := applyYoloArgs (args , nil )
1394+ if len (got ) != 1 || got [0 ] != "claude" {
1395+ t .Fatalf ("expected unchanged args, got %v" , got )
1396+ }
1397+ })
1398+
1399+ t .Run ("empty args returns empty" , func (t * testing.T ) {
1400+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1401+ got := applyYoloArgs ([]string {}, cfg )
1402+ if len (got ) != 0 {
1403+ t .Fatalf ("expected empty, got %v" , got )
1404+ }
1405+ })
1406+
1407+ t .Run ("unsupported agent gets no flag even with yolo_all" , func (t * testing.T ) {
1408+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1409+ args := []string {"pi" , "--model" , "sonnet" }
1410+ got := applyYoloArgs (args , cfg )
1411+ if len (got ) != 3 || got [0 ] != "pi" {
1412+ t .Fatalf ("expected pi args unchanged (no yolo flag), got %v" , got )
1413+ }
1414+ })
1415+
1416+ t .Run ("claude gets --dangerously-skip-permissions" , func (t * testing.T ) {
1417+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1418+ args := []string {"claude" , "build it" }
1419+ got := applyYoloArgs (args , cfg )
1420+ if len (got ) != 3 || got [1 ] != "--dangerously-skip-permissions" {
1421+ t .Fatalf ("expected --dangerously-skip-permissions injected, got %v" , got )
1422+ }
1423+ })
1424+
1425+ t .Run ("copilot gets --allow-all-tools" , func (t * testing.T ) {
1426+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1427+ args := []string {"copilot" }
1428+ got := applyYoloArgs (args , cfg )
1429+ if len (got ) != 2 || got [1 ] != "--allow-all-tools" {
1430+ t .Fatalf ("expected --allow-all-tools injected, got %v" , got )
1431+ }
1432+ })
1433+
1434+ t .Run ("gemini gets --yolo" , func (t * testing.T ) {
1435+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1436+ args := []string {"gemini" }
1437+ got := applyYoloArgs (args , cfg )
1438+ if len (got ) != 2 || got [1 ] != "--yolo" {
1439+ t .Fatalf ("expected --yolo injected, got %v" , got )
1440+ }
1441+ })
1442+
1443+ t .Run ("flag not duplicated if already present" , func (t * testing.T ) {
1444+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : true }}
1445+ args := []string {"gemini" , "--yolo" }
1446+ got := applyYoloArgs (args , cfg )
1447+ if len (got ) != 2 {
1448+ t .Fatalf ("expected no duplicate flag, got %v" , got )
1449+ }
1450+ })
1451+
1452+ t .Run ("yolo not injected when config disabled" , func (t * testing.T ) {
1453+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAll : false , YoloAgents : nil }}
1454+ args := []string {"claude" }
1455+ got := applyYoloArgs (args , cfg )
1456+ if len (got ) != 1 {
1457+ t .Fatalf ("expected no flag injection when yolo disabled, got %v" , got )
1458+ }
1459+ })
1460+
1461+ t .Run ("per-agent yolo_agents enables only listed agent" , func (t * testing.T ) {
1462+ cfg := & config.Config {Agents : config.AgentsConfig {YoloAgents : []string {"claude" }}}
1463+ args := []string {"claude" }
1464+ got := applyYoloArgs (args , cfg )
1465+ if len (got ) != 2 || got [1 ] != "--dangerously-skip-permissions" {
1466+ t .Fatalf ("expected flag for listed agent, got %v" , got )
1467+ }
1468+
1469+ argsPi := []string {"pi" }
1470+ gotPi := applyYoloArgs (argsPi , cfg )
1471+ if len (gotPi ) != 1 {
1472+ t .Fatalf ("expected no flag for unlisted agent, got %v" , gotPi )
1473+ }
1474+ })
1475+ }
1476+
13081477// hashString is a test helper for SHA256 hashing
13091478func hashString (s string ) string {
13101479 // Use actual SHA256 for deterministic hashing
0 commit comments