Commit Graph

33 Commits

Author SHA1 Message Date
Levi Neely 2286ebded5 Remove openrouter backend alias
openrouter is OpenAI-compatible; just set OLLIE_OPENAI_URL to the
OpenRouter endpoint. No separate backend case needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:57:18 +02:00
Levi Neely 10fa7439ee Fix README: backends are ollama and openai only
openrouter is not a distinct backend; it's the openai backend pointed
at a different URL. Updated examples accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:56:54 +02:00
Levi Neely 062ff2afee config json sample 2026-04-01 00:55:57 +02:00
Levi Neely b5389e96c7 Update README to reflect current architecture
Covers: agentic design, execute_code built-in, backend selection,
env file, config.json with MCP servers and hooks, UI keybindings,
token usage display, skill system.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:55:21 +02:00
Levi Neely fd4bb235b5 MCP subprocess inherits only whitelisted env vars
Remove os.Environ() inheritance from MCP subprocess. The child
process receives only the vars explicitly listed in mcpServers[].env,
with values expanded from the parent environment via os.ExpandEnv.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:53:10 +02:00
Levi Neely d64e49e893 Fix MCP subprocess env: start from os.Environ(), append extras
The loop was calling append(os.Environ(), ...) on each iteration,
discarding all but the last extra env var. Start cmd.Env from
os.Environ() once, then append each configured key=value pair.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:51:32 +02:00
Levi Neely 6c38a1147c Expand env vars in MCP config; surface config errors in chat pane
os.ExpandEnv() applied to MCP server env values so \${VAR} syntax
works. Config load errors now appear in the startup display instead
of being silently dropped when using the default config path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:45:43 +02:00
Levi Neely fd696b99f5 Show MCP startup results in chat pane
Replace log.Printf MCP connection messages with entries in the
initial display slice, so connection status and tool counts appear
in the chat pane rather than on stderr.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:39:03 +02:00
Levi Neely 01b128fdf5 Restore MCP server support alongside built-in execute_code
Bring back ollie/mcp and ollie/tools packages. Config MCPServers
field restored. MCP tools are discovered at startup and added to
the agent tool list alongside execute_code. Dispatch routes by
server name for MCP tools, falls back to built-in execute_code.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:34:09 +02:00
Levi Neely f9ba6c8bce Track and display token usage per request
Add Usage{InputTokens, OutputTokens} to backend.Response. Both
OllamaBackend (prompt_eval_count/eval_count) and OpenAIBackend
(prompt_tokens/completion_tokens) populate it. The loop emits a
'usage' OutputMsg after each Chat call; the UI displays it as
[↑N ↓N tokens].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:31:03 +02:00
Levi Neely 75e00d438c Add chat history scrolling via PageUp/PageDown and ctrl+u/ctrl+d
Configure viewport keymap to use page-based scroll keys only, leaving
up/down arrows free for textarea cursor movement. Viewport is now
initialized once with the custom keymap and resized (not recreated)
on window resize. Key messages are routed to both viewport and textarea.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:24:19 +02:00
Levi Neely b59b9d9e31 Prohibit narration: call execute_code, don't describe it
Small models were writing markdown code blocks describing what they
would run instead of actually calling the tool. Explicitly forbid
this pattern in the system prompt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:11:15 +02:00
Levi Neely 715d68f974 Fix skill discovery instructions: must use 'tool' field, not 'code'
Model was putting discover_skill.sh in the 'code' field and running
it as inline bash. Explicitly state that 'tool' field is required for
discover_skill.sh and load_skill.sh, and that 'code' must not be used
for them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:05:13 +02:00
Levi Neely 75cadfeb53 Soften planning prompt: execute_code only when needed
The previous wording implied execute_code was always required after
planning. Clarified that the model should begin executing immediately,
using execute_code only if the step requires it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:02:54 +02:00
Levi Neely cf56df2ba0 Show tool invocations in chat; fix planning loop stall
Emit a 'call' message before each tool execution so the UI shows
execute_code(...) with full args before the result. Result lines
are now indented with '= ' to visually pair with the call.

System prompt now explicitly says to call execute_code immediately
after planning, without pausing for confirmation, to prevent smaller
models stalling after the planning step.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 00:02:31 +02:00
Levi Neely f2f61ee6be Make system prompt more prescriptive for smaller models
Replace high-level principles with explicit rules: when to call
execute_code, exact invocation syntax for all three modes, and
a numbered sequence (discover skills → plan → execute) that
smaller models can follow without inferring intent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:55:43 +02:00
Levi Neely b529c23d75 Rename OLLIE_API_KEY to OLLIE_OPENAI_KEY
Consistent with OLLIE_OPENAI_URL; makes it clear the key only applies
to openai/openrouter backends.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:51:01 +02:00
Levi Neely ebb726e384 Split OLLIE_API_URL into backend-specific vars
OLLIE_API_URL was shared across backends, causing the ollama backend
to use the OpenRouter URL when OLLIE_BACKEND was overridden on the
command line while the env file still set OLLIE_API_URL.

Replace with OLLIE_OLLAMA_URL and OLLIE_OPENAI_URL so each backend
only reads its own URL setting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:50:05 +02:00
Levi Neely 73b13451a0 Enforce planning and skill discovery in system prompt
Agent must discover and load relevant skills before acting on any task,
re-running discovery when domain shifts. Agent must also produce a
numbered plan before executing, and revise it if steps fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:44:56 +02:00
Levi Neely 6877d6b951 Default config to ~/.config/ollie/config.json
Fall back to the default path silently if the file does not exist.
Only fatal on a missing/invalid config if the path was explicitly
provided as a CLI argument.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:36:56 +02:00
Levi Neely 463457cd14 Load ~/.config/ollie/env before reading backend env vars
Env file is optional; existing environment variables take precedence.
Supports KEY=VALUE format with # comments and blank lines ignored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:32:36 +02:00
Levi Neely 6c9f056ed8 Wrap display lines to viewport width
Extract renderDisplay() to word-wrap each line at the viewport width
before setting content. Re-wrap on terminal resize. Fixes tool output
and long bot responses being truncated at the viewport edge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:27:56 +02:00
Levi Neely 07a212884a Add system prompt; delete BeadState
BeadState duplicated what execute_code already provides via tool scripts.
Removed it entirely. Added SystemPrompt field to agent.Config, prepended
as a system message each loop iteration. Built-in prompt covers
execute_code usage, sandbox behavior, and skill discovery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:18:40 +02:00
Levi Neely 06ccc80da6 Remove MCP layer; execute_code is the sole built-in tool
Drop ollie/mcp, ollie/tools, ollie/ollama packages. Config now only
carries hooks. main.go wires a single execute_code tool directly to
the agent loop — no MCP discovery or dispatch needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 23:13:05 +02:00
Levi Neely 25cc7a8c33 Wire agent loop into TUI: replace ad-hoc ollama loop with backend+agent
main.go now uses backend.New() for LLM selection (OLLIE_BACKEND env),
agent.Loop for observe/decide/act/update/terminate, and ollie/exec for
built-in execute_code. Multi-turn sessions persist across user inputs.
MCP tools route through mcpExecutor; unknown tools fall back to built-in.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 22:57:08 +02:00
Levi Neely 54e4f44635 Add agent package: observe/decide/act/update/terminate loop
Implements the core agent loop with two state backends:
- Session: ephemeral in-memory, lives for one process lifetime
- BeadState: bead-backed via 9beads tool scripts (claim/read/complete)

Loop is backend-agnostic; takes a ToolExecutor and emits OutputMsgs.
MaxSteps defaults to 1 for simple prompts; callers set higher for tasks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 22:53:40 +02:00
Levi Neely 127f428620 Add backend package: common LLM interface for ollama and OpenAI-compatible APIs
Defines a Backend interface with shared Message/Tool/ToolCall types.
OllamaBackend wraps /api/chat; OpenAIBackend covers OpenAI, OpenRouter,
and any compatible API. Factory reads OLLIE_BACKEND, OLLIE_API_URL,
OLLIE_API_KEY.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 22:40:42 +02:00
Levi Neely af34b2f267 Add ollie/exec package: extract execute_code from anvillm-mcp
Extracts execute_code into a shared ollie/exec package so anvillm-mcp
and ollie's agent loop can both use it. Includes sandboxed execution,
dangerous-pattern validation with per-Executor rate limiting, 9P tool
reading, and pipeline construction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 22:30:19 +02:00
Levi Neely 6767137bce
Add GNU General Public License v3 2026-02-21 22:21:21 +01:00
Levi Neely 52abc5174b Update usage section: clarify UI and tool dependencies 2026-02-21 20:55:47 +01:00
Levi Neely 58d185941c Improve README flow 2026-02-21 20:53:15 +01:00
Levi Neely ff1e3d60c8 Update README: tech editing pass and fix license 2026-02-21 20:49:15 +01:00
Levi Neely 12b8950ea5 Initial commit 2026-02-21 20:47:38 +01:00