summaryrefslogtreecommitdiff
path: root/internal
AgeCommit message (Collapse)Author
2026-03-02lsp: decompose detectAndHandleChat into focused helpers (task 418)Paul Buetow
2026-03-02llmutils: remove remaining default-model wrappers in callers (task 413)Paul Buetow
2026-03-02lsp: cancel handler contexts on shutdown via server context (task 423)Paul Buetow
2026-03-02lsp: use context-mode registry for additional context dispatch (task 408)Paul Buetow
2026-03-02appconfig: split App into focused section helpers (task 406)Paul Buetow
2026-03-02lsp: extract completion/chat/codeaction server subtypes (task 406)Paul Buetow
2026-03-02lsp: make exit flag atomic to avoid data race (task 406)Paul Buetow
2026-03-02lsp: handle code action payload marshal errors (task 406)Paul Buetow
2026-03-02lsp: simplify ServerOptions to config-first model (task 410)Paul Buetow
2026-03-02lsp: return cleanly on exit and propagate runner errors (task 410)Paul Buetow
2026-03-02llmutils: centralize provider normalization and client setup (task 410)Paul Buetow
2026-03-02codeaction: add Build/Resolve handler registries (task 410)Paul Buetow
2026-03-02llm: add provider registry and self-registration factories (task 410)Paul Buetow
2026-03-02appconfig: split config module and decompose oversized funcs (task 406)Paul Buetow
2026-02-13chore: deprecate hexai-mcp-server as experimentalPaul Buetow
Add deprecation notices across hexai-mcp-server codebase and documentation. The MCP server is now considered experimental and not actively maintained, as prompts are managed through slash commands and meta-commands instead. Changes: - Add runtime deprecation warning to stderr on binary startup - Mark feature as deprecated in README.md - Add deprecation notices to all 8 MCP documentation files - Add deprecation log message to run.go - Update Magefile.go build comment The code remains fully functional but warns users of its experimental status. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12feat: add design_prompt meta-prompt for implementation planningPaul Buetow
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12Rename hexai-lsp command to hexai-lsp-serverPaul Buetow
Amp-Thread-ID: https://ampcode.com/threads/T-019c50bc-2906-77db-a31e-0d553338d99b Co-authored-by: Amp <amp@ampcode.com>
2026-02-12feat: add automatic MCP prompt to slash command syncingPaul Buetow
Adds optional syncing of MCP prompts to Markdown slash command files for AI agents that don't yet support MCP prompts (e.g., Cursor IDE). Features: - Syncs prompts on create/update/delete operations - Configurable via TOML config, environment vars, or CLI flags - Backfill support with --sync-all flag - Thread-safe atomic file writes - Non-fatal sync failures (logged but don't break operations) - Comprehensive test coverage (81.1% total) Configuration: - Config: [mcp] slashcommand_sync = true, slashcommand_dir = "~/.cursor/commands" - Env: HEXAI_MCP_SLASHCOMMAND_SYNC, HEXAI_MCP_SLASHCOMMAND_DIR - CLI: --slashcommand-sync, --slashcommand-dir, --sync-all Fixes config merging bug where project config would reset global MCP settings. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11chore: bump version to 0.20.0Paul Buetow
2026-02-11fix: simplify meta-prompts to not require programmatic prompt fetchingPaul Buetow
Update update_prompt and delete_prompt meta-prompts to work without requiring Claude to programmatically fetch prompts via prompts/get (which isn't available as a callable tool in the MCP client). Changes: - delete_prompt: Simplified to just ask for confirmation without fetching - update_prompt: Ask what changes to make without fetching current version - Removed duplicate/confusing instructions - More direct workflow: confirm → execute tool This fixes the issue where Claude would try to use listMcpResources or other incorrect APIs when trying to follow the meta-prompt instructions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11fix: clarify prompt retrieval method in meta-promptsPaul Buetow
Update update_prompt and delete_prompt meta-prompts to explicitly instruct Claude to use "prompts/get" instead of vague "access via prompts capability". This prevents Claude from incorrectly trying to use the resources API. Changes: - update_prompt: "use prompts/get to retrieve the current prompt" - delete_prompt: "use prompts/get to retrieve the prompt and show details" Fixes issue where Claude would try to access "plugin:hexai-prompts" resources instead of using the correct prompts/get method on the hexai-prompts server. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11feat: add delete_prompt built-in meta-promptPaul Buetow
Adds a third built-in meta-prompt for interactively deleting custom prompts with confirmation. This completes the prompt management trilogy (save, update, delete). Changes: - Add delete_prompt meta-prompt with prompt_name argument - Interactive workflow: show prompt → confirm → delete via delete_prompt tool - Update test to expect 3 built-in prompts (was 2) - Includes safety notes about built-in prompts and backups The meta-prompt ensures users see what they're deleting and must explicitly confirm before the delete_prompt tool is called. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11feat: add MCP Tools support for prompt managementPaul Buetow
Implements tools/list and tools/call endpoints to expose prompt management operations (create, update, delete) as callable MCP tools. This enables Claude to use the meta-prompts (save_prompt, update_prompt) to actually create and modify prompts. Key changes: - Add Tool type definitions (Tool, ListToolsRequest, CallToolRequest, etc.) - Implement handleToolsList() returning 3 tools with JSON Schemas - Implement handleToolsCall() with tool wrappers for create/update/delete - Add 17 comprehensive unit tests (82.8% coverage maintained) - Update meta-prompts to reference tools instead of JSON-RPC methods - Enable listChanged notifications for immediate prompt availability - Refactor large functions into helpers to stay under 50-line limit Tools advertised alongside Prompts capability. All functions under 50 lines. Backward compatible - existing prompts/* JSON-RPC methods unchanged. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11refactor: compile built-in prompts into binary instead of external filesPaul Buetow
This change moves built-in meta-prompts (save_prompt, update_prompt) from external JSONL files into compiled Go code, making them always available and version-controlled with the binary. Changes: - Add default_prompts.go with built-in meta-prompt definitions - Update store to load built-ins from code, not files - Add protection: built-ins cannot be updated/deleted - Handle name conflicts: built-ins take precedence with warnings - Update docs to reflect new architecture (no default.jsonl needed) - Add comprehensive tests for built-in protection - Add hexai-mcp-server binary to .gitignore Benefits: - Built-ins always in sync with binary version - No setup required (no default.jsonl to manage) - Clear separation between built-in and user prompts - Protection prevents accidental modification of meta-prompts Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11refactor: consolidate cache and state into .local/hexai directoryPaul Buetow
Move all cache and state files under ~/.local/hexai/ with subdirectories: - ~/.local/hexai/cache/ (was ~/.cache/hexai/) - ~/.local/hexai/state/ (was ~/.local/state/hexai/) - ~/.local/hexai/data/ (was ~/.local/share/hexai/) This centralizes all non-config hexai files under a single .local/hexai directory, making it easier to manage and back up user data. Amp-Thread-ID: https://ampcode.com/threads/T-019c4e03-73db-70a2-ae27-3e1cc31d59c3 Co-authored-by: Amp <amp@ampcode.com>
2026-02-11Fix MCP protocol version negotiation and null prompts arrayPaul Buetow
Two issues prevented Claude Code CLI from discovering MCP prompts: 1. Protocol version mismatch: Server always returned "2025-06-18" but Claude Code sends "2025-11-25". Per MCP spec, server must echo back the client's version if supported. Now supports all known versions (2024-11-05 through 2025-11-25). 2. Null prompts array: Go nil slices marshal as JSON null, but Claude Code expects an empty array []. Initialize prompts slice with make() to ensure [] in JSON output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11Fix MCP transport to use JSONL instead of Content-Length framingPaul Buetow
The MCP stdio protocol uses newline-delimited JSON (JSONL), not LSP-style Content-Length headers. This was discovered during integration testing with Claude Code CLI which could not connect to the server. Also updates docs/mcp-setup.md with correct Claude Code CLI configuration (use `claude mcp add` instead of editing JSON files) and adds integration test runbook for testing against real Claude Code CLI instances. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10Refactor MCP server to meet project standards and remove built-in promptsPaul Buetow
Ensures all code complies with AGENTS.md standards: - Refactored functions to be under 50 lines each - Removed built-in prompts - all prompts now served from database only - Split handlePromptsCreate (72→37 lines) with helper functions - Split handlePromptsUpdate (76→44 lines) with helper function - Deleted internal/promptstore/builtin.go (no longer needed) - Updated tests to create prompts dynamically instead of relying on built-ins All tests pass with 81.5% coverage maintained. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10Add MCP server implementation with comprehensive test coveragePaul Buetow
Implements a full Model Context Protocol (MCP) server for managing and serving prompts to LLM applications. The server provides CRUD operations for prompts with automatic backups and template rendering support. Key additions: - cmd/hexai-mcp-server: Main MCP server binary entrypoint - internal/hexaimcp: Server orchestrator with configuration and setup - internal/mcp: Core MCP protocol implementation (JSON-RPC 2.0) - internal/promptstore: Prompt storage with JSONL backend and automatic backups - Comprehensive test suites achieving 80%+ coverage for all MCP packages - Magefile targets for building and installing the MCP server - Complete documentation for setup, API, prompts, and backups Test coverage: - internal/hexaimcp: 84.3% - internal/mcp: 80.3% - internal/promptstore: 81.2% - Overall project: 81.5% Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10Add tmux popup history storage and consolidate state files to XDG_STATE_HOMEPaul Buetow
- Add StateDir() helper function respecting XDG_STATE_HOME (~/.local/state/hexai/) - Implement JSONL-based history storage for tmux popup submissions - New history.go with AppendHistory() and GetHistory() functions - Store timestamp, agent name, cwd, and submitted text - Comprehensive unit tests for history functionality - Integrate history append into tmux edit workflow after successful submission - Move logs from /tmp/ to persistent state directory: - hexai-lsp.log: ~/.local/state/hexai/hexai-lsp.log - hexai-tmux-edit.log: ~/.local/state/hexai/hexai-tmux-edit.log - Update README.md with File Locations section documenting XDG directories - Fix pre-existing test failures by isolating project config in unit tests - Panic on state directory creation failure instead of silent fallback All unit tests pass. Follows XDG Base Directory Specification for proper state file management with persistence across reboots. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10Fix hexai-tmux-edit to open in current working directoryPaul Buetow
hexai-tmux-edit was opening in the wrong directory because the tmux popup wasn't being told which directory to use. This fix: - Updates bind-key example to cd into pane's current path - Passes working directory to popup via -d flag using os.Getwd() - Updates all documentation with corrected bind-key examples Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08Bump version to 0.18.2Paul Buetow
2026-02-08Add unit tests to improve coverage above 80% targetPaul Buetow
Implement comprehensive unit tests for critical internal packages to increase overall test coverage from 80.9% to 81.8%, providing a buffer above the 80% threshold specified in project guidelines. Changes: - Add config parsing tests (parseTemperatureValue, decodeModelEntry, resolvedModel, parseSurfaceEntries) - Add HumanBytes utility tests with edge cases and boundary values - Fix HumanBytes bug: corrected suffix array indexing (off-by-one error) - Fix HumanBytes to handle negative values correctly - Add comprehensive shellJoin and isSafeBare tests for shell escaping - Update comments to reflect actual behavior and implementation details Coverage impact: - internal/appconfig: Improved config parsing function coverage - internal/textutil: HumanBytes now at 100% coverage (fixed bug in process) - internal/tmux: shellJoin and isSafeBare now at 100% coverage - Overall project: 80.9% → 81.8% (+0.9%) All tests pass. Code formatted with gofumpt. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08Bump version to 0.18.1Paul Buetow
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08Fix Claude agent clearing to use readline instead of vim commandsPaul Buetow
Claude Code's prompt input field does not support vim commands for clearing. The previous sequence 'Escape gg C-v G d i' resulted in literal text 'gGdijo' appearing in the prompt instead of clearing it. Changed to 'C-a C-k' (Emacs/readline style): - C-a: Move cursor to start of line - C-k: Kill (delete) from cursor to end of line Also added 150ms delay after Escape key in sendClearSequence to ensure mode transitions complete before subsequent keys are sent (though Claude uses readline, this helps other potential vim-based agents). Changes: - internal/tmuxedit/claude_agent.go: clearKeys "C-a C-k" instead of vim - internal/tmuxedit/claude_agent_test.go: Update test expectations - internal/tmuxedit/agentutil.go: Add time import and Escape delay - docs/usage.md: Update claude clear method documentation - docs/tmux.md: Clarify claude uses readline not vim - config.toml.example: Update claude description Integration tested: - Extracted: "final verification test" - Sent: "FINAL REPLACED TEXT NO VIM COMMANDS" - Result: Clean replacement with NO vim command artifacts - All unit tests pass (67/67) - Coverage: 80.9% Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08Fix amp agent prompt extraction to use TUI box patternPaul Buetow
Amp CLI runs in TUI mode with box-drawing UI (│ text │) similar to Cursor, not shell-style (> prompt). Updated prompt pattern from `(?m)>\s*(.+)$` to `(?m)│\s*(.+?)\s*│\s*$` to correctly extract text from amp's box UI. Changes: - internal/tmuxedit/config_agent.go: Update amp promptPat to box pattern - internal/tmuxedit/config_agent_test.go: Update test to use box format - docs/usage.md: Document detection order and clear methods for all agents - docs/tmux.md: Clarify input mode handling (Vim vs Emacs/readline) - config.toml.example: Add detailed agent descriptions and patterns - prompts/tmux-edit-integration-tests.md: Add test status, mock editor best practices Integration tests verified: - Amp detection: amp/sourcegraph keywords - Prompt extraction: "hello world test" correctly captured - End-to-end workflow: text modification and sending works - Multi-line support: all lines delivered correctly - All unit tests pass (67/67) - Coverage: 80.9% (meets requirement) - Cursor and Claude implementations unchanged Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08refactor tmuxedit to Agent interface with cursor/claude/config implementationsPaul Buetow
Replace monolithic AgentConfig struct with an Agent interface backed by baseAgent defaults and separate implementations for cursor (box-drawing extraction, bulk backspace clearing) and claude (section-scoped extraction with continuation lines, vim clearing). Simple agents (amp, aider) and user-defined agents use configAgent with baseAgent defaults. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08fix hexai-tmux-edit agent detection, multi-line extraction, and clearingPaul Buetow
- Reorder agents: cursor first to avoid false positive from "Claude 4.5 Sonnet" model name appearing in cursor panes - Change cursor detect pattern to box-drawing UI elements instead of name-based matching - Change claude detect pattern to ❯ prompt instead of generic "claude" - Support multi-line prompt extraction using last-contiguous-block algorithm to ignore command-review and dialog boxes - Fix deduplicateText to always return full edited text (clear + resend) instead of stripping original prefix which caused double-removal - Replace vim-style clear (Escape gg dG i) with universal End+BSpace*200 since cursor's prompt is not actually vim - Add Key*N repeat syntax in ClearKeys (parsed by parseKeyRepeat, sent via tmux send-keys -N) - Add 300ms sleep after clear to let TUI drain queued backspaces before new text arrives - Add debug logging to /tmp/hexai-tmux-edit.log - Add strip pattern for "ctrl+c to stop" noise in cursor prompt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08add hexai-tmux-edit: tmux popup editor for AI agent promptsPaul Buetow
New tool that opens $EDITOR in a tmux popup for composing longer prompts when working with AI CLI agents (Claude Code, Cursor, Amp, Aider, etc.). Captures existing prompt text from the target pane, pre-fills the editor, and sends edited text back via tmux send-keys. Config-driven agent detection via regex patterns in [tmux_edit] config section. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08add gitignore-aware file filtering for LSP completions and code actionsPaul Buetow
Files matching .gitignore patterns or user-configured extra patterns are now skipped for completions and code actions. Configurable via [ignore] section in config.toml with gitignore, extra_patterns, and lsp_notify_ignored options. Includes hot-reload support and env var overrides (HEXAI_IGNORE_*). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08add per-project .hexaiconfig.toml config override and lower coverage target ↵Paul Buetow
to 80% Introduce support for a .hexaiconfig.toml file at the git repository root that selectively overrides the global config. Precedence order: defaults → global config → project config → env vars. Also lower the coverage threshold from 85% to 80%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06chore: bump version to 0.17.0paul@buetow.org
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06Remove GitHub Copilot provider supportpaul@buetow.org
Remove all GitHub Copilot integration from the codebase to streamline the supported provider set to OpenAI, OpenRouter, Anthropic, and Ollama. Changes: - Delete core Copilot implementation (copilot.go) and all related tests - Remove Copilot configuration fields from App struct and Config - Remove Copilot from provider factory and API key handling - Update all test files to replace Copilot references with other providers - Remove Copilot documentation from README, configuration guide, and examples - Remove Copilot section from config.toml.example All tests pass successfully after removal. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06chore: bump version to 0.16.1paul@buetow.org
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-06fix: add missing Anthropic and OpenRouter provider support in config and LSPpaul@buetow.org
- Add Anthropic field merging in config.mergeProviderFields() to properly load AnthropicModel/BaseURL/Temperature from config.toml - Add anthropic and openrouter cases in lsp.resolveDefaultModel() to prevent fallback to OpenAI defaults - Update default Anthropic model to valid claude-3-5-sonnet-20240620 (previous 20241022 doesn't exist) - Update test expectation to match new default model This fixes the issue where Anthropic provider configuration was ignored, causing LSP to return dummy completions instead of real LLM responses. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-01fix: pass RequestTimeout to all llm.Config instancesFlorian
Add RequestTimeout field to llm.Config construction in: - internal/hexailsp/run.go (buildClientIfNil) - internal/llmutils/client.go (NewClientFromApp) - internal/lsp/server.go (newClientForProvider) This ensures the configured timeout is used in all code paths, not just the ones already updated.
2026-01-31feat: add configurable request timeout for LLM callsFlorian
Local LLMs (LM Studio, Ollama, etc.) often need more than the default 30-second timeout. Added request_timeout config option (in seconds) to [general] section and HEXAI_REQUEST_TIMEOUT env var. Original constructor signatures preserved via *WithTimeout variants, so no test changes required.
2026-01-30chore: bump version to 0.16.0Paul Buetow
Major features: - Native Anthropic API provider support - Configurable completion_wait_all option for multi-backend completions
2026-01-30feat: add completion_wait_all config and fix Anthropic system messagesPaul Buetow
- Add completion_wait_all config option (default true) to wait for all backends before returning results, or return first result immediately - Fix Anthropic API: extract system messages to top-level system field as required by Messages API (was causing 400 errors) - Add anthropic case to server.go clientFor() for model overrides
2026-01-29refactor: apply code style best practices to Anthropic implementationPaul Buetow
- Reorganize anthropic.go: types, interface checks, constructor, public methods, private methods - Extract helper methods from Chat() and ChatStream() to keep functions under 50 lines - Add resolveOptions(), sendRequest(), extractContent() private methods - Add explicit interface satisfaction check for Client and Streamer - Add documentation comments to all public methods (Chat, Name, DefaultModel, ChatStream) - Apply gofmt and gofumpt formatting - Apply goimports for import ordering All 51 tests in llm package pass All code adheres to best practices from go-projects.md: - Value semantics (value receivers only) - Constructors before methods - Public before private - Functions under 50 lines - Explicit interface satisfaction - Documentation on all public identifiers - Proper error handling - Context as first parameter for I/O functions Amp-Thread-ID: https://ampcode.com/threads/T-019c0af1-f215-72cf-9940-b014b1a9576b Co-authored-by: Amp <amp@ampcode.com>