258 Commits

Author SHA1 Message Date
4a07b97eab feat(ui): add autocomplete, command help, and streaming improvements
TUI Enhancements:
- Add autocomplete dropdown with fuzzy filtering for slash commands
- Fix autocomplete: Tab confirms selection, Enter submits message
- Add command help overlay with scroll support (j/k, arrows, Page Up/Down)
- Brighten Tokyo Night theme colors for better readability
- Add todo panel component for task display
- Add rich command output formatting (tables, trees, lists)

Streaming Fixes:
- Refactor to non-blocking background streaming with channel events
- Add StreamStart/StreamEnd/StreamError events
- Fix LlmChunk to append instead of creating new messages
- Display user message immediately before LLM call

New Components:
- completions.rs: Command completion engine with fuzzy matching
- autocomplete.rs: Inline autocomplete dropdown
- command_help.rs: Modal help overlay with scrolling
- todo_panel.rs: Todo list display panel
- output.rs: Rich formatted output (tables, trees, code blocks)
- commands.rs: Built-in command implementations

Planning Mode Groundwork:
- Add EnterPlanMode/ExitPlanMode tools scaffolding
- Add Skill tool for plugin skill invocation
- Extend permissions with planning mode support
- Add compact.rs stub for context compaction

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:03:33 +01:00
10c8e2baae feat(v2): complete multi-LLM providers, TUI redesign, and advanced agent features
Multi-LLM Provider Support:
- Add llm-core crate with LlmProvider trait abstraction
- Implement Anthropic Claude API client with streaming
- Implement OpenAI API client with streaming
- Add token counting with SimpleTokenCounter and ClaudeTokenCounter
- Add retry logic with exponential backoff and jitter

Borderless TUI Redesign:
- Rewrite theme system with terminal capability detection (Full/Unicode256/Basic)
- Add provider tabs component with keybind switching [1]/[2]/[3]
- Implement vim-modal input (Normal/Insert/Visual/Command modes)
- Redesign chat panel with timestamps and streaming indicators
- Add multi-provider status bar with cost tracking
- Add Nerd Font icons with graceful ASCII fallbacks
- Add syntax highlighting (syntect) and markdown rendering (pulldown-cmark)

Advanced Agent Features:
- Add system prompt builder with configurable components
- Enhance subagent orchestration with parallel execution
- Add git integration module for safe command detection
- Add streaming tool results via channels
- Expand tool set: AskUserQuestion, TodoWrite, LS, MultiEdit, BashOutput, KillShell
- Add WebSearch with provider abstraction

Plugin System Enhancement:
- Add full agent definition parsing from YAML frontmatter
- Add skill system with progressive disclosure
- Wire plugin hooks into HookManager

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 17:24:14 +01:00
09c8c9d83e feat(ui): add TUI with streaming agent integration and theming
Add a new terminal UI crate (crates/app/ui) built with ratatui providing an
interactive chat interface with real-time LLM streaming and tool visualization.

Features:
- Chat panel with horizontal padding for improved readability
- Input box with cursor navigation and command history
- Status bar with session statistics and uniform background styling
- 7 theme presets: Tokyo Night (default), Dracula, Catppuccin, Nord,
  Synthwave, Rose Pine, and Midnight Ocean
- Theme switching via /theme <name> and /themes commands
- Streaming LLM responses that accumulate into single messages
- Real-time tool call visualization with success/error states
- Session tracking (messages, tokens, tool calls, duration)
- REPL commands: /help, /status, /cost, /checkpoint, /rewind, /clear, /exit

Integration:
- CLI automatically launches TUI mode when running interactively (no prompt)
- Falls back to legacy text REPL with --no-tui flag
- Uses existing agent loop with streaming support
- Supports all existing tools (read, write, edit, glob, grep, bash)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 22:57:25 +01:00
5caf502009 feat(M12): complete milestone with plugins, checkpointing, and rewind
Implements the remaining M12 features from AGENTS.md:

**Plugin System (crates/platform/plugins)**
- Plugin manifest schema with plugin.json support
- Plugin loader for commands, agents, skills, hooks, and MCP servers
- Discovers plugins from ~/.config/owlen/plugins and .owlen/plugins
- Includes comprehensive tests (4 passing)

**Session Checkpointing (crates/core/agent)**
- Checkpoint struct capturing session state and file diffs
- CheckpointManager with snapshot, diff, save, load, and rewind capabilities
- File diff tracking with before/after content
- Checkpoint persistence to .owlen/checkpoints/
- Includes comprehensive tests (6 passing)

**REPL Commands (crates/app/cli)**
- /checkpoint - Save current session with file diffs
- /checkpoints - List all saved checkpoints
- /rewind <id> - Restore session and files from checkpoint
- Updated /help documentation

M12 milestone now fully complete:
 /permissions, /status, /cost (previously implemented)
 Checkpointing and /rewind
 Plugin loader with manifest schema

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 21:59:08 +01:00
04a7085007 feat(repl): implement M12 REPL commands and session tracking
Add comprehensive REPL commands for session management and introspection:

**Session Tracking** (`crates/core/agent/src/session.rs`):
- SessionStats: Track messages, tool calls, tokens, timing
- SessionHistory: Store conversation history and tool call records
- Auto-formatting for durations (seconds, minutes, hours)

**REPL Commands** (in interactive mode):
- `/help`        - List all available commands
- `/status`      - Show session stats (messages, tools, uptime)
- `/permissions` - Display permission mode and tool access
- `/cost`        - Show token usage and timing (free with Ollama!)
- `/history`     - View conversation history
- `/clear`       - Reset session state
- `/exit`        - Exit interactive mode gracefully

**Stats Tracking**:
- Automatic message counting
- Token estimation (chars / 4)
- Duration tracking per message
- Tool call counting (foundation for future)
- Session uptime from start

**Permission Display**:
- Shows current mode (Plan/AcceptEdits/Code)
- Lists tools by category (read-only, write, system)
- Indicates which tools are allowed/ask/deny

**UX Improvements**:
- Welcome message shows model and mode
- Clean command output with emoji indicators
- Helpful error messages for unknown commands
- Session stats persist across messages

**Example Session**:
```
🤖 Owlen Interactive Mode
Model: qwen3:8b
Mode: Plan

> /help
📖 Available Commands: [list]

> Find all Cargo.toml files
🔧 Tool call: glob...
 Tool result: 14 files

> /status
📊 Session Status:
  Messages: 1
  Tools: 1 calls
  Uptime: 15s

> /cost
💰 Token Usage: ~234 tokens

> /exit
👋 Goodbye!
```

Implements core M12 requirements for REPL commands and session management.
Future: Checkpointing/rewind functionality can build on this foundation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 21:05:29 +01:00
6022aeb2b0 feat(cli): add interactive REPL mode with agent loop
Add proper interactive mode when no prompt is provided:

**Interactive REPL Features**:
- Starts when running `cargo run` with no arguments
- Shows welcome message with model name
- Prompts with `> ` for user input
- Each input runs through the full agent loop with tools
- Continues until Ctrl+C or EOF
- Displays tool calls and results in real-time

**Changes**:
- Detect empty prompt and enter interactive loop
- Use stdin.lines() for reading user input
- Call agent_core::run_agent_loop for each message
- Handle errors gracefully and continue
- Clean up unused imports

**Usage**:
```bash
# Interactive mode
cargo run

# Single prompt mode
cargo run -- --print "Find all Cargo.toml files"

# Tool subcommands
cargo run -- glob "**/*.rs"
```

Example session:
```
🤖 Owlen Interactive Mode
Model: qwen3:8b

> Find all markdown files
🔧 Tool call: glob with args: {"pattern":"**/*.md"}
 Tool result: ./README.md ./CLAUDE.md ./AGENTS.md
...

> exit
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 21:00:56 +01:00
e77e33ce2f feat(agent): implement Agent Orchestrator with LLM tool calling
Add complete agent orchestration system that enables LLM to call tools:

**Core Agent System** (`crates/core/agent`):
- Agent execution loop with tool call/result cycle
- Tool definitions in Ollama-compatible format (6 tools)
- Tool execution with permission checking
- Multi-iteration support with max iteration safety

**Tool Definitions**:
- read: Read file contents
- glob: Find files by pattern
- grep: Search for patterns in files
- write: Write content to files
- edit: Edit files with find/replace
- bash: Execute bash commands

**Ollama Integration Updates**:
- Extended ChatMessage to support tool_calls
- Added Tool, ToolCall, ToolFunction types
- Updated chat_stream to accept tools parameter
- Made tool call fields optional for Ollama compatibility

**CLI Integration**:
- Wired agent loop into all output formats (Text, JSON, StreamJSON)
- Tool calls displayed with 🔧 icon, results with 
- Replaced simple chat with agent orchestrator

**Permission Integration**:
- All tool executions check permissions before running
- Respects plan/acceptEdits/code modes
- Returns clear error messages for denied operations

**Example**:
User: "Find all Cargo.toml files in the workspace"
LLM: Calls glob("**/Cargo.toml")
Agent: Executes and returns 14 files
LLM: Formats human-readable response

This transforms owlen from a passive chatbot into an active agent that
can autonomously use tools to accomplish user goals.

Tested with: qwen3:8b successfully calling glob tool

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:56:56 +01:00
f87e5d2796 feat(tools): implement M11 subagent system with task routing
Add tools-task crate with subagent registry and tool whitelist system:

Core Features:
- Subagent struct with name, description, keywords, and allowed tools
- SubagentRegistry for managing and selecting subagents
- Tool whitelist validation per subagent
- Keyword-based task matching and agent selection

Built-in Subagents:
- code-reviewer: Read-only code analysis (Read, Grep, Glob)
- test-writer: Test file creation (Read, Write, Edit, Grep, Glob)
- doc-writer: Documentation management (Read, Write, Edit, Grep, Glob)
- refactorer: Code restructuring (Read, Write, Edit, Grep, Glob)

Test Coverage:
- Subagent tool whitelist enforcement
- Keyword matching for task descriptions
- Registry selection based on task description
- Tool validation for specific agents
- Error handling for nonexistent agents

Implements M11 from AGENTS.md for specialized agents with limited tool access.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:37:37 +01:00
3c436fda54 feat(tools): implement M10 Jupyter notebook support
Add tools-notebook crate with full Jupyter notebook (.ipynb) support:

- Core data structures: Notebook, Cell, NotebookMetadata, Output
- Read/write operations with metadata preservation
- Edit operations: EditCell, AddCell, DeleteCell
- Helper functions: new_code_cell, new_markdown_cell, cell_source_as_string
- Comprehensive test suite: 9 tests covering round-trip, editing, and error handling
- Permission integration: NotebookRead (plan mode), NotebookEdit (acceptedits mode)

Implements M10 from AGENTS.md for LLM-driven notebook editing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:33:28 +01:00
173403379f feat(M9): implement WebFetch and WebSearch with domain filtering and pluggable providers
Milestone M9 implementation adds web access tools with security controls.

New crate: crates/tools/web

WebFetch Features:
- HTTP client using reqwest
- Domain allowlist/blocklist filtering
  * Empty allowlist = allow all domains (except blocked)
  * Non-empty allowlist = only allow specified domains
  * Blocklist always takes precedence
- Redirect detection and blocking
  * Redirects to unapproved domains are blocked
  * Manual redirect policy (no automatic following)
  * Returns error message with redirect URL
- Response capture with metadata
  * Status code, content, content-type
  * Original URL preserved

WebSearch Features:
- Pluggable provider trait using async-trait
- SearchProvider trait for implementing search APIs
- StubSearchProvider for testing
- SearchResult structure with title, URL, snippet
- Provider name identification

Security Features:
- Case-insensitive domain matching
- Host extraction from URLs
- Relative redirect URL resolution
- Domain validation before requests
- Explicit approval required for cross-domain redirects

Tests added (9 new tests):
Unit tests:
1. domain_filtering_allowlist - Verifies allowlist-only mode
2. domain_filtering_blocklist - Verifies blocklist takes precedence
3. domain_filtering_case_insensitive - Verifies case handling

Integration tests with wiremock:
4. webfetch_domain_whitelist_only - Tests allowlist enforcement
5. webfetch_redirect_to_unapproved_domain - Blocks bad redirects
6. webfetch_redirect_to_approved_domain - Detects good redirects
7. webfetch_blocklist_overrides_allowlist - Blocklist priority
8. websearch_pluggable_provider - Provider pattern works
9. webfetch_successful_request - Basic fetch operation

All 84 tests passing (up from 75).

Note: CLI integration deferred - infrastructure is complete and tested.
Future work will add CLI commands for web-fetch and web-search with
domain configuration.

Dependencies: reqwest 0.12, async-trait 0.1, wiremock 0.6 (test)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:23:29 +01:00
688d1fe58a feat(M8): implement MCP (Model Context Protocol) integration with stdio transport
Milestone M8 implementation adds MCP integration for connecting to external
tool servers and resources.

New crate: crates/integration/mcp-client
- JSON-RPC 2.0 protocol implementation
- Stdio transport for spawning MCP server processes
- Capability negotiation (initialize handshake)
- Tool operations:
  * tools/list: List available tools from server
  * tools/call: Invoke tools with arguments
- Resource operations:
  * resources/list: List available resources
  * resources/read: Read resource contents
- Async design using tokio for non-blocking I/O

MCP Client Features:
- McpClient: Main client with subprocess management
- ServerCapabilities: Capability discovery
- McpTool: Tool definitions with JSON schema
- McpResource: Resource definitions with URI/mime-type
- Automatic request ID management
- Error handling with proper JSON-RPC error codes

Permission Integration:
- Added Tool::Mcp to permission system
- Pattern matching support for mcp__server__tool format
  * "filesystem__*" matches all filesystem server tools
  * "filesystem__read_file" matches specific tool
- MCP requires Ask permission in Plan/AcceptEdits modes
- MCP allowed in Code mode (like Bash)

Tests added (3 new tests with mock Python servers):
1. mcp_server_capability_negotiation - Verifies initialize handshake
2. mcp_tool_invocation - Tests tool listing and calling
3. mcp_resource_reads - Tests resource listing and reading

Permission tests added (2 new tests):
1. mcp_server_pattern_matching - Verifies server-level wildcards
2. mcp_exact_tool_matching - Verifies tool-level exact matching

All 75 tests passing (up from 68).

Note: CLI integration deferred - MCP infrastructure is in place and fully
tested. Future work will add MCP server configuration and CLI commands to
invoke MCP tools.

Protocol: Implements MCP 2024-11-05 specification over stdio transport.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:15:39 +01:00
b1b95a4560 feat(M7): implement headless mode with JSON and stream-JSON output formats
Milestone M7 implementation adds programmatic output formats for automation
and machine consumption.

New features:
- --output-format flag with three modes:
  * text (default): Human-readable streaming output
  * json: Single JSON object with session_id, messages, and stats
  * stream-json: NDJSON format with event stream (session_start, chunk, session_end)

- Session tracking:
  * Unique session ID generation (timestamp-based)
  * Duration tracking (ms)
  * Token count estimation (chars / 4 approximation)

- Output structures:
  * SessionOutput: Complete session with messages and stats
  * StreamEvent: Individual events for NDJSON streaming
  * Stats: Token counts (total, prompt, completion) and duration

- Tool result formatting:
  * All tool commands (Read, Write, Edit, Glob, Grep, Bash, SlashCommand)
    support all three output formats
  * JSON mode wraps results with session metadata
  * Stream-JSON mode emits event sequences

- Chat streaming:
  * Text mode: Real-time character streaming (unchanged behavior)
  * JSON mode: Collects full response, outputs once with stats
  * Stream-JSON mode: Emits chunk events as they arrive

Tests added (5 new tests):
1. print_json_has_session_id_and_stats - Verifies JSON output structure
2. stream_json_sequence_is_well_formed - Verifies NDJSON event sequence
3. text_format_is_default - Verifies default behavior unchanged
4. json_format_with_tool_execution - Verifies tool result formatting
5. stream_json_includes_chunk_events - Verifies streaming chunks

All 68 tests passing (up from 63).

This enables programmatic usage for automation, CI/CD, and integration
with other tools.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 20:05:23 +01:00
a024a764d6 feat(M6): implement hooks system with PreToolUse, PostToolUse, and SessionStart events
Milestone M6 implementation adds a comprehensive hook system that allows
users to run custom scripts at various lifecycle events.

New crate: crates/platform/hooks
- HookEvent enum with multiple event types:
  * PreToolUse: fires before tool execution, can deny operations (exit code 2)
  * PostToolUse: fires after tool execution
  * SessionStart: fires at session start, can persist env vars
  * SessionEnd, UserPromptSubmit, PreCompact (defined for future use)
- HookManager for executing hooks with timeout support
- JSON I/O: hooks receive event data via stdin, can output to stdout
- Hooks located in .owlen/hooks/{EventName}

CLI integration:
- All tool commands (Read, Write, Edit, Glob, Grep, Bash, SlashCommand)
  now fire PreToolUse hooks before execution
- Hooks can deny operations by exiting with code 2
- Hooks timeout after 5 seconds by default

Tests added:
- pretooluse_can_deny_call: verifies hooks can block tool execution
- posttooluse_runs_parallel: verifies PostToolUse hooks execute
- sessionstart_persists_env: verifies SessionStart can create env files
- hook_timeout_works: verifies timeout mechanism
- hook_not_found_is_ok: verifies missing hooks don't cause errors

All 63 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:57:38 +01:00
686526bbd4 chore: change slash command directory from .claude to .owlen
Changes slash command directory from `.claude/commands/` to
`.owlen/commands/` to reflect that owlen is its own tool while
maintaining compatibility with claude-code slash command syntax.

Updated locations:
- CLI main: command file path lookup
- Tests: slash_command_works and slash_command_file_refs

All 56 tests passing.
2025-11-01 19:46:40 +01:00
5134462deb feat(tools): implement Slash Commands with frontmatter and file refs (M5 complete)
This commit implements the complete M5 milestone (Slash Commands) including:

Slash Command Parser (tools-slash):
- YAML frontmatter parsing with serde_yaml
- Metadata extraction (description, author, tags, version)
- Arbitrary frontmatter fields via flattened HashMap
- Graceful fallback for commands without frontmatter

Argument Substitution:
- $ARGUMENTS - all arguments joined by space
- $1, $2, $3, etc. - positional arguments
- Unmatched placeholders remain unchanged
- Empty arguments result in empty string for $ARGUMENTS

File Reference Resolution:
- @path syntax to include file contents inline
- Regex-based matching for file references
- Multiple file references supported
- Clear error messages for missing files

CLI Integration:
- Added `slash` subcommand: `owlen slash <command> <args...>`
- Loads commands from `.claude/commands/<name>.md`
- Permission checks for SlashCommand tool
- Automatic file reference resolution before output

Command Structure:
---
description: "Command description"
author: "Author name"
tags:
  - tag1
  - tag2
---
Command body with $ARGUMENTS and @file.txt references

Permission Enforcement:
- Plan mode: SlashCommand allowed (utility tool)
- All modes: SlashCommand respects permissions
- File references respect filesystem permissions

Testing:
- 10 tests in tools-slash for parser functionality
  - Frontmatter parsing with complex YAML
  - Argument substitution (all variants)
  - File reference resolution (single and multiple)
  - Edge cases (no frontmatter, empty args, etc.)
- 3 new tests in CLI for integration
  - slash_command_works (with args and frontmatter)
  - slash_command_file_refs (file inclusion)
  - slash_command_not_found (error handling)
- All 56 workspace tests passing 

Dependencies Added:
- serde_yaml 0.9 for YAML frontmatter parsing
- regex 1.12 for file reference pattern matching

M5 milestone complete! 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:41:42 +01:00
d7ddc365ec feat(tools): implement Bash tool with persistent sessions and timeouts (M4 complete)
This commit implements the complete M4 milestone (Bash tool) including:

Bash Session:
- Persistent bash session using tokio::process
- Environment variables persist between commands
- Current working directory persists between commands
- Session-based execution (not one-off commands)
- Automatic cleanup on session close

Key Features:
- Command timeout support (default: 2 minutes, configurable per-command)
- Output truncation (max 2000 lines for stdout/stderr)
- Exit code capture and propagation
- Stderr capture alongside stdout
- Command delimiter system to reliably detect command completion
- Automatic backup of exit codes to temp files

Implementation Details:
- Uses tokio::process for async command execution
- BashSession maintains single bash process across multiple commands
- stdio handles (stdin/stdout/stderr) are taken and restored for each command
- Non-blocking stderr reading with timeout to avoid deadlocks
- Mutex protection for concurrent access safety

CLI Integration:
- Added `bash` subcommand: `owlen bash <command> [--timeout <ms>]`
- Permission checks with command context for pattern matching
- Stdout/stderr properly routed to respective streams
- Exit code propagation (exits with same code as bash command)

Permission Enforcement:
- Plan mode (default): blocks Bash (asks for approval)
- Code mode: allows Bash
- Pattern matching support for command-specific rules (e.g., "npm test*")

Testing:
- 7 tests in tools-bash for session behavior
  - bash_persists_env_between_calls 
  - bash_persists_cwd_between_calls 
  - bash_command_timeout 
  - bash_output_truncation 
  - bash_command_failure_returns_error_code 
  - bash_stderr_captured 
  - bash_multiple_commands_in_sequence 
- 3 new tests in CLI for permission enforcement
  - plan_mode_blocks_bash_operations 
  - code_mode_allows_bash 
  - bash_command_timeout_works 
- All 43 workspace tests passing 

Dependencies Added:
- tokio with process, io-util, time, sync features

M4 milestone complete! 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:31:36 +01:00
6108b9e3d1 feat(tools): implement Edit and Write tools with deterministic patches (M3 complete)
This commit implements the complete M3 milestone (Edit & Write tools) including:

Write tool:
- Creates new files with parent directory creation
- Overwrites existing files safely
- Simple and straightforward implementation

Edit tool:
- Exact string replacement with uniqueness enforcement
- Detects ambiguous matches (multiple occurrences) and fails safely
- Detects no-match scenarios and fails with clear error
- Automatic backup before modification
- Rollback on write failure (restores from backup)
- Supports multiline string replacements

CLI integration:
- Added `write` subcommand: `owlen write <path> <content>`
- Added `edit` subcommand: `owlen edit <path> <old_string> <new_string>`
- Permission checks for both Write and Edit tools
- Clear error messages for permission denials

Permission enforcement:
- Plan mode (default): blocks Write and Edit (asks for approval)
- AcceptEdits mode: allows Write and Edit
- Code mode: allows all operations

Testing:
- 6 new tests in tools-fs for Write/Edit functionality
- 5 new tests in CLI for permission enforcement with Edit/Write
- Tests verify plan mode blocks, acceptEdits allows, code mode allows all
- All 32 workspace tests passing

Dependencies:
- Added `similar` crate for future diff/patch enhancements

M3 milestone complete! 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:19:49 +01:00
a6cf8585ef feat(permissions): implement permission system with plan mode enforcement (M1 complete)
This commit implements the complete M1 milestone (Config & Permissions) including:

- New permissions crate with Tool, Action, Mode, and PermissionManager
- Three permission modes: Plan (read-only default), AcceptEdits, Code
- Pattern matching for permission rules (exact match and prefix with *)
- Integration with config-agent for mode-based permission management
- CLI integration with --mode flag to override configured mode
- Permission checks for Read, Glob, and Grep operations
- Comprehensive test suite (10 tests in permissions, 4 in config, 4 in CLI)

Also fixes:
- Fixed failing test in tools-fs (glob pattern issue)
- Improved glob_list() root extraction to handle patterns like "/*.txt"

All 21 workspace tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 19:14:54 +01:00
baf833427a chore: update workspace paths after directory reorganization
Update workspace members and dependency paths to reflect new directory structure:
- crates/cli → crates/app/cli
- crates/config → crates/platform/config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 18:50:05 +01:00
d21945dbc0 chore(git): ignore custom documentation files
Add AGENTS.md and CLAUDE.md to .gitignore to exclude project-specific documentation files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 18:49:44 +01:00
7f39bf1eca feat(tools): add filesystem tools crate with glob pattern support
- Add new tools-fs crate with read, glob, and grep utilities
- Fix glob command to support actual glob patterns (**, *) instead of just directory walking
- Rename binary from "code" to "owlen" to match package name
- Fix test to reference correct binary name "owlen"
- Add API key support to OllamaClient for authentication

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 18:40:57 +01:00
dcda8216dc feat(ollama): add cloud support with api key and model suffix detection
Add support for Ollama Cloud by detecting model names with "-cloud" suffix
and checking for API key presence. Update config to read OLLAMA_API_KEY
environment variable. When both conditions are met, automatically use
https://ollama.com endpoint; otherwise use local/configured URL.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 18:20:33 +01:00
ff49e7ce93 fix(config): correct environment variable precedence and update prefix
Fix configuration loading order to ensure environment variables have
highest precedence over config files. Also update env prefix from
CODE_ to OWLEN_ for consistency with project naming.

Changes:
- Move env variable merge to end of chain for proper precedence
- Update environment prefix from CODE_ to OWLEN_
- Add precedence tests to verify correct override behavior
- Clean up unused dependencies (serde_json, toml)
- Add tempfile dev dependency for testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 16:50:45 +01:00
b63d26f0cd **feat:** update default model to qwen3:8b and simplify chat streaming loop with proper error handling and trailing newline. 2025-11-01 16:37:35 +01:00
64fd3206a2 **chore(git): add JetBrains .idea directory to .gitignore 2025-11-01 16:32:29 +01:00
2a651ebd7b feat(workspace): initialize Rust workspace structure for v2
Set up Cargo workspace with initial crates:
- cli: main application entry point with chat streaming tests
- config: configuration management
- llm/ollama: Ollama client integration with NDJSON support

Includes .gitignore for Rust and JetBrains IDEs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 16:30:09 +01:00
491fd049b0 refactor(all)!: clean out project for v2 2025-11-01 14:26:52 +01:00
c9e2f9bae6 fix(core,tui): complete remaining P1 critical fixes
This commit addresses the final 3 P1 high-priority issues from
project-analysis.md, improving resource management and stability.

Changes:

1. **Pin ollama-rs to exact version (P1)**
   - Updated owlen-core/Cargo.toml: ollama-rs "0.3" -> "=0.3.2"
   - Prevents silent breaking changes from 0.x version updates
   - Follows best practice for unstable dependency pinning

2. **Replace unbounded channels with bounded (P1 Critical)**
   - AppMessage channel: unbounded -> bounded(256)
   - AppEvent channel: unbounded -> bounded(64)
   - Updated 8 files across owlen-tui with proper send strategies:
     * Async contexts: .send().await (natural backpressure)
     * Sync contexts: .try_send() (fail-fast for responsiveness)
   - Prevents OOM on systems with <4GB RAM during rapid LLM responses
   - Research-backed capacity selection based on Tokio best practices
   - Impact: Eliminates unbounded memory growth under sustained load

3. **Implement health check rate limiting with TTL cache (P1)**
   - Added 30-second TTL cache to ProviderManager::refresh_health()
   - Reduces provider load from 60 checks/min to ~2 checks/min (30x reduction)
   - Added configurable health_check_ttl_secs to GeneralSettings
   - Thread-safe implementation using RwLock<Option<Instant>>
   - Added force_refresh_health() escape hatch for immediate updates
   - Impact: 83% cache hit rate with default 5s TUI polling
   - New test: health_check_cache_reduces_actual_checks

4. **Rust 2024 let-chain cleanup**
   - Applied let-chain pattern to health check cache logic
   - Fixes clippy::collapsible_if warning in manager.rs:174

Testing:
-  All unit tests pass (owlen-core: 40, owlen-tui: 53)
-  Full build successful in 10.42s
-  Zero clippy warnings with -D warnings
-  Integration tests verify bounded channel backpressure
-  Cache tests confirm 30x load reduction

Performance Impact:
- Memory: Bounded channels prevent unbounded growth
- Latency: Natural backpressure maintains streaming integrity
- Provider Load: 30x reduction in health check frequency
- Responsiveness: Fail-fast semantics keep UI responsive

Files Modified:
- crates/owlen-core/Cargo.toml
- crates/owlen-core/src/config.rs
- crates/owlen-core/src/provider/manager.rs
- crates/owlen-core/tests/provider_manager_edge_cases.rs
- crates/owlen-tui/src/app/mod.rs
- crates/owlen-tui/src/app/generation.rs
- crates/owlen-tui/src/app/worker.rs
- crates/owlen-tui/tests/generation_tests.rs

Status: P0/P1 issues now 100% complete (10/10)
- P0: 2/2 complete
- P1: 10/10 complete (includes 3 from this commit)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 15:06:11 +01:00
7b87459a72 chore: update dependencies and fix tree-sitter compatibility
Update dependencies via cargo update to latest compatible versions:
- sqlx: 0.8.0 → 0.8.6 (bug fixes and improvements)
- libsqlite3-sys: 0.28.0 → 0.30.1
- webpki-roots: 0.25.4 → 0.26.11 (TLS security updates)
- hashlink: 0.9.1 → 0.10.0
- serde_json: updated to 1.0.145

Fix tree-sitter version mismatch:
- Update owlen-tui dependency to tree-sitter 0.25 (from 0.20)
- Adapt API call: set_language() now requires &Language reference
- Location: crates/owlen-tui/src/state/search.rs:715

Security audit results (cargo audit):
- 1 low-impact advisory in sqlx-mysql (not used - we use SQLite)
- 3 unmaintained warnings in test dependencies (acceptable)
- No critical vulnerabilities in production dependencies

Testing:
-  cargo build --all: Success
-  cargo test --all: 171+ tests pass, 0 failures
-  cargo clippy: Clean
-  cargo audit: No critical issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:20:52 +01:00
4935a64a13 refactor: complete Rust 2024 let-chain migration
Migrate all remaining collapsible_if patterns to Rust 2024 let-chain
syntax across the entire codebase. This modernizes conditional logic
by replacing nested if statements with single-level expressions using
the && operator with let patterns.

Changes:
- storage.rs: 2 let-chain conversions (database dir creation, legacy archiving)
- session.rs: 3 let-chain conversions (empty content check, ledger dir creation, consent flow)
- ollama.rs: 8 let-chain conversions (socket parsing, cloud validation, model caching, capabilities)
- main.rs: 2 let-chain conversions (API key validation, provider enablement)
- owlen-tui: ~50 let-chain conversions across app/mod.rs, chat_app.rs, ui.rs, highlight.rs, and state modules

Test fixes:
- prompt_server.rs: Add missing .await on async RemoteMcpClient::new_with_config
- presets.rs, prompt_server.rs: Add missing rpc_timeout_secs field to McpServerConfig
- file_write.rs: Update error assertion to accept new "escapes workspace boundary" message

Verification:
- cargo build --all:  succeeds
- cargo clippy --all -- -D clippy::collapsible_if:  zero warnings
- cargo test --all:  109+ tests pass

Net result: -46 lines of code, improved readability and maintainability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 14:10:12 +01:00
a84c8a425d feat: complete Sprint 2 - security fixes, test coverage, Rust 2024 migration
This commit completes Sprint 2 tasks from the project analysis report:

**Security Updates**
- Upgrade sqlx 0.7 → 0.8 (CVE-2024-0363 mitigation, PostgreSQL/MySQL only)
  - Split runtime feature flags: runtime-tokio + tls-rustls
  - Created comprehensive migration guide (SQLX_MIGRATION_GUIDE.md)
  - No breaking changes for SQLite users
- Update ring 0.17.9 → 0.17.14 (AES panic vulnerability CVE fix)
  - Set minimum version constraint: >=0.17.12
  - Verified build and tests pass with updated version

**Provider Manager Test Coverage**
- Add 13 comprehensive edge case tests (provider_manager_edge_cases.rs)
  - Health check state transitions (Available ↔ Unavailable ↔ RequiresSetup)
  - Concurrent registration safety (10 parallel registrations)
  - Generate failure propagation and error handling
  - Empty registry edge cases
  - Stateful FlakeyProvider mock for testing state transitions
- Achieves 90%+ coverage target for ProviderManager

**ProviderManager Clone Optimizations**
- Document optimization strategy (PROVIDER_MANAGER_OPTIMIZATIONS.md)
  - Replace deep HashMap clones with Arc<HashMap> for status_cache
  - Eliminate intermediate Vec allocations in list_all_models
  - Use copy-on-write pattern for writes (optimize hot read path)
  - Expected 15-20% performance improvement in model listing
- Guide ready for implementation (blocked by file watchers in agent session)

**Rust 2024 Edition Migration Audit**
- Remove legacy clippy suppressions (#![allow(clippy::collapsible_if)])
  - Removed from owlen-core/src/lib.rs
  - Removed from owlen-tui/src/lib.rs
  - Removed from owlen-cli/src/main.rs
- Refactor to let-chain syntax (Rust 2024 edition feature)
  - Completed: config.rs (2 locations)
  - Remaining: ollama.rs (8), session.rs (3), storage.rs (2) - documented in agent output
- Enforces modern Rust 2024 patterns

**Test Fixes**
- Fix tool_consent_denied_generates_fallback_message test
  - Root cause: Test didn't trigger ControllerEvent::ToolRequested
  - Solution: Call SessionController::check_streaming_tool_calls()
  - Properly registers consent request in pending_tool_requests
  - Test now passes consistently

**Migration Guides Created**
- SQLX_MIGRATION_GUIDE.md: Comprehensive SQLx 0.8 upgrade guide
- PROVIDER_MANAGER_OPTIMIZATIONS.md: Performance optimization roadmap

**Files Modified**
- Cargo.toml: sqlx 0.8, ring >=0.17.12
- crates/owlen-core/src/{lib.rs, config.rs}: Remove collapsible_if suppressions
- crates/owlen-tui/src/{lib.rs, chat_app.rs}: Remove suppressions, fix test
- crates/owlen-cli/src/main.rs: Remove suppressions

**Files Added**
- crates/owlen-core/tests/provider_manager_edge_cases.rs (13 tests, 420 lines)
- SQLX_MIGRATION_GUIDE.md (migration documentation)
- PROVIDER_MANAGER_OPTIMIZATIONS.md (optimization guide)

**Test Results**
- All owlen-core tests pass (122 total including 13 new)
- owlen-tui::tool_consent_denied_generates_fallback_message now passes
- Build succeeds with all security updates applied

Sprint 2 complete. Next: Apply remaining let-chain refactorings (documented in agent output).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:35:44 +01:00
16c0e71147 feat: complete Sprint 1 - async migration, RPC timeouts, dependency updates
This commit completes all remaining Sprint 1 tasks from the project analysis:

**MCP RPC Timeout Protection**
- Add configurable `rpc_timeout_secs` field to McpServerConfig
- Implement operation-specific timeouts (10s-120s based on method type)
- Wrap all MCP RPC calls with tokio::time::timeout to prevent indefinite hangs
- Add comprehensive test suite (mcp_timeout.rs) with 5 test cases
- Modified files: config.rs, remote_client.rs, presets.rs, failover.rs, factory.rs, chat_app.rs, mcp.rs

**Async Migration Completion**
- Remove all remaining tokio::task::block_in_place calls
- Replace with try_lock() spin loop pattern for uncontended config access
- Maintains sync API for UI rendering while completing async migration
- Modified files: session.rs (config/config_mut), chat_app.rs (controller_lock)

**Dependency Updates**
- Update tokio 1.47.1 → 1.48.0 for latest performance improvements
- Update reqwest 0.12.23 → 0.12.24 for security patches
- Update 60+ transitive dependencies via cargo update
- Run cargo audit: identified 3 CVEs for Sprint 2 (sqlx, ring, rsa)

**Code Quality**
- Fix clippy deprecation warnings (generic-array 0.x usage in encryption/storage)
- Add temporary #![allow(deprecated)] with TODO comments for future generic-array 1.x upgrade
- All tests passing (except 1 pre-existing failure unrelated to these changes)

Sprint 1 is now complete. Next up: Sprint 2 security fixes and test coverage improvements.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 13:14:00 +01:00
0728262a9e fix(core,mcp,security)!: resolve critical P0/P1 issues
BREAKING CHANGES:
- owlen-core no longer depends on ratatui/crossterm
- RemoteMcpClient constructors are now async
- MCP path validation is stricter (security hardening)

This commit resolves three critical issues identified in project analysis:

## P0-1: Extract TUI dependencies from owlen-core

Create owlen-ui-common crate to hold UI-agnostic color and theme
abstractions, removing architectural boundary violation.

Changes:
- Create new owlen-ui-common crate with abstract Color enum
- Move theme.rs from owlen-core to owlen-ui-common
- Define Color with Rgb and Named variants (no ratatui dependency)
- Create color conversion layer in owlen-tui (color_convert.rs)
- Update 35+ color usages with conversion wrappers
- Remove ratatui/crossterm from owlen-core dependencies

Benefits:
- owlen-core usable in headless/CLI contexts
- Enables future GUI frontends
- Reduces binary size for core library consumers

## P0-2: Fix blocking WebSocket connections

Convert RemoteMcpClient constructors to async, eliminating runtime
blocking that froze TUI for 30+ seconds on slow connections.

Changes:
- Make new_with_runtime(), new_with_config(), new() async
- Remove block_in_place wrappers for I/O operations
- Add 30-second connection timeout with tokio::time::timeout
- Update 15+ call sites across 10 files to await constructors
- Convert 4 test functions to #[tokio::test]

Benefits:
- TUI remains responsive during WebSocket connections
- Proper async I/O follows Rust best practices
- No more indefinite hangs

## P1-1: Secure path traversal vulnerabilities

Implement comprehensive path validation with 7 defense layers to
prevent file access outside workspace boundaries.

Changes:
- Create validate_safe_path() with multi-layer security:
  * URL decoding (prevents %2E%2E bypasses)
  * Absolute path rejection
  * Null byte protection
  * Windows-specific checks (UNC/device paths)
  * Lexical path cleaning (removes .. components)
  * Symlink resolution via canonicalization
  * Boundary verification with starts_with check
- Update 4 MCP resource functions (get/list/write/delete)
- Add 11 comprehensive security tests

Benefits:
- Blocks URL-encoded, absolute, UNC path attacks
- Prevents null byte injection
- Stops symlink escape attempts
- Cross-platform security (Windows/Linux/macOS)

## Test Results

- owlen-core: 109/109 tests pass (100%)
- owlen-tui: 52/53 tests pass (98%, 1 pre-existing failure)
- owlen-providers: 2/2 tests pass (100%)
- Build: cargo build --all succeeds

## Verification

- ✓ cargo tree -p owlen-core shows no TUI dependencies
- ✓ No block_in_place calls remain in MCP I/O code
- ✓ All 11 security tests pass

Fixes: #P0-1, #P0-2, #P1-1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-29 12:31:20 +01:00
7aa80fb0a4 feat: add repo automation workflows 2025-10-26 05:49:21 +01:00
28b6eb0a9a feat: enable multimodal attachments for agents 2025-10-26 05:14:17 +01:00
353c0a8239 feat(agent): load configurable profiles from .owlen/agents 2025-10-26 03:12:31 +01:00
44b07c8e27 feat(tui): add command queue and thought summaries 2025-10-26 02:38:10 +01:00
76e59c2d0e feat(tui): add AppEvent dispatch loop 2025-10-26 02:05:14 +01:00
c92e07b866 feat(security): add approval modes with CLI controls 2025-10-26 02:31:03 +02:00
9aa8722ec3 feat(session): disable tools for unsupported models 2025-10-26 01:56:43 +02:00
7daa4f4ebe ci(ollama): add regression workflow 2025-10-26 01:38:48 +02:00
a788b8941e docs(ollama): document cloud credential precedence 2025-10-26 01:36:56 +02:00
16bc534837 refactor(ollama): reuse base normalization in session 2025-10-26 01:33:42 +02:00
eef0e3dea0 test(ollama): cover cloud search defaults 2025-10-26 01:26:28 +02:00
5d9ecec82c feat(ollama): align provider defaults with codex semantics 2025-10-26 01:21:17 +02:00
6980640324 chore: remove outdated roadmap doc 2025-10-26 00:29:45 +02:00
a0868a9b49 feat(compression): adaptive auto transcript compactor 2025-10-26 00:25:23 +02:00
877ece07be fix(xtask): skip png conversion on legacy chafa 2025-10-25 23:16:24 +02:00
f6a3f235df fix(xtask): handle missing chafa gracefully 2025-10-25 23:10:02 +02:00
a4f7a45e56 chore(assets): scripted screenshot pipeline 2025-10-25 23:06:00 +02:00