Extract common flag processing logic from TUI and headless code paths into
shared flagProcessor module. This eliminates code duplication where both
paths independently converted readonly/auto flags to mode and structured
permission overrides.
Changes:
- Add src/flags/flagProcessor.ts with shared flag processing functions
- Replace duplicated logic in chat.ts (lines 168-173 and 259-264)
- Add comprehensive unit tests for all flag processing scenarios
- Add validation for conflicting --readonly and --auto flags
This is a pure refactor with no behavior changes. All existing functionality
preserved while eliminating 20+ lines of duplicated code.
Add --silent flag to headless mode (-p/--print) that removes <think></think>
tags and excess whitespace from LLM responses. This enables clean output
suitable for shell piping and automation.
## Why --silent instead of --no-think
The flag was renamed from --no-think to --silent because:
- Commander.js treats --no- prefix as negation flags, expecting a base --think option
- --silent provides clearer semantic meaning for "quiet, clean output"
- Follows Unix convention where --silent typically means suppress extra output
## Problem Solved
Many models (like Nemotron - Llama 3.3 Nemotron Super 49B v1.5) emit <think></think>
tags that interfere with shell piping:
Without --silent:
```
$ cn -p "Echo a shell script that prints 'Hello World' Output only the script and NOTHING ELSE. No code fences. No markdown."
<think>
I need to write a shell script. Let me think about this.
The user wants a simple Hello World script.
</think>
#\!/bin/bash
echo "Hello World"
```
With --silent:
```
$ cn -p --silent "Echo a shell script that prints 'Hello World' Output only the script and NOTHING ELSE. No code fences. No markdown."
#\!/bin/bash
echo "Hello World"
```
This makes piping work correctly:
```
$ eval $(cn -p --silent "Write a shell script that prints 'Hello World'")
Hello World
```
## Features
- Strips all <think></think> blocks and their content
- Reduces excessive whitespace (3+ consecutive newlines become 2)
- Works with --format json flag
- Includes comprehensive unit and e2e tests
- Only available with -p/--print flag (headless mode)
- Mock the 'open' module to prevent actual URLs from opening during test runs
- Add dedicated URL handling security tests to verify mocking behavior
- Prevent potential security issues where tests could open arbitrary URLs
- Verify URL construction logic without actual browser opening
- Document security considerations around URL opening in tests
- All tests pass with proper mocking in place
Security improvement: Tests now cannot accidentally open malicious URLs
during automated test runs, while still verifying the URL opening logic.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add third option "Switch to a different configuration" to free trial UI
- Integrate with existing ConfigSelector component for seamless config switching
- Update navigation to support 3 options with arrow keys and number selection
- Add comprehensive UI tests covering all interaction branches:
- Initial screen rendering and formatting
- Navigation with arrow keys and number keys
- Boundary checking for navigation
- Proper callback handling for all three options
- Visual styling and layout verification
- Props interface testing
- Tests verify proper integration between FreeTrialTransitionUI and TUIChat
- All existing functionality preserved and tested
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Create testable pure functions for Anthropic API key validation
- Ensure consistent validation across all entry points (must start with "sk-ant-")
- Add automatic switching to local config after API key entry in CLI
- Update all free trial transition flows to use centralized validation
- Add comprehensive test coverage for validation logic
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>