package ai import "testing" func TestParseCommandsJSONBlock(t *testing.T) { raw := `Here is my plan: {"commands":[{"type":"restart_mining","args":{}}]}` cmds := ParseCommands(raw) if len(cmds) != 1 || cmds[0].Type != CmdRestartMining { t.Fatalf("got %+v", cmds) } } func TestParseCommandsToolCall(t *testing.T) { raw := `{"tool":"restart_agent","args":{}}` cmds := ParseCommands(raw) if len(cmds) != 1 || cmds[0].Type != CmdRestartMining { t.Fatalf("got %+v", cmds) } } func TestParseCommandsLineFallback(t *testing.T) { raw := "COMMAND: spread_now\nCOMMAND: noop" cmds := ParseCommands(raw) if len(cmds) != 2 || cmds[0].Type != CmdSpreadNow || cmds[1].Type != CmdNoop { t.Fatalf("got %+v", cmds) } } func TestParseCommandsAgentCommand(t *testing.T) { raw := `{"commands":[{"type":"agent_command","args":{"action":"pause"}}]}` cmds := ParseCommands(raw) if len(cmds) != 1 || cmds[0].Type != CmdAgentCommand { t.Fatalf("got %+v", cmds) } if cmds[0].Args["action"] != "pause" { t.Fatalf("args: %+v", cmds[0].Args) } }