.roo/rules-debug/cli.md
When debugging the CLI, console.log will break the TUI (Terminal User Interface). Use file-based logging to capture debug output without interfering with the application's display.
Write logs to a temporary file instead of console:
Create a log file at a known location, e.g., /tmp/roo-cli-debug.log
Use fs.appendFileSync() to write timestamped log entries
Example logging utility:
import fs from "fs"
const DEBUG_LOG = "/tmp/roo-cli-debug.log"
function debugLog(message: string, data?: unknown) {
const timestamp = new Date().toISOString()
const entry = data
? `[${timestamp}] ${message}: ${JSON.stringify(data, null, 2)}\n`
: `[${timestamp}] ${message}\n`
fs.appendFileSync(DEBUG_LOG, entry)
}
Clear the log file before each debugging session:
echo "" > /tmp/roo-cli-debug.log or use fs.writeFileSync(DEBUG_LOG, "") at app startup during debuggingFollow this feedback loop to systematically narrow down issues:
cat /tmp/roo-cli-debug.log to retrieve the captured output[STATE], [EVENT], [ERROR], [FLOW]await statements// Add logging to investigate a picker selection issue
debugLog("[FLOW] PickerSelect onSelect called", { selectedIndex, item })
debugLog("[STATE] Current selection state", { currentValue, isOpen })
// After async operation
const result = await fetchOptions()
debugLog("[FLOW] fetchOptions completed", { resultCount: result.length })
Then ask: "Please reproduce the issue by [specific steps]. When you're done, let me know and I'll analyze the debug logs."