Commit Graph

1959 Commits

Author SHA1 Message Date
Ollie Agent 25924d0909 fs: add /help ctl command — returns command reference 2026-08-09 03:32:21 +02:00
Ollie Agent 05e9c45495 update kde submodule: slash command hints match ctl 2026-08-09 03:15:27 +02:00
Ollie Agent 6147ec00bd docs: update architecture diagram, fix ellie.el for ctl rdwr
README: mermaid diagram now shows o CLI as the foundation layer
between text frontends and 9P. KDE/Kate connect directly to 9P.

ellie.el (both versions): add ellie--9p-rdwr wrapper, use ctl rdwr
for systemprompt (no longer a standalone file).
2026-08-09 03:14:00 +02:00
Ollie Agent aa74e1c683 docs: fix stale references in 9p.md, usage.md, misc.md
- 9p.md: update agent file table to current namespace
- usage.md: readloop→read -l, tail→read chat, command table updated,
  TUI description updated (no grep pipe)
- misc.md: readloop→read -l
2026-08-09 03:10:20 +02:00
Ollie Agent 42823dab2e docs: update README, AGENTS.md, architecture, evolution for Aug 9 changes
- README: fix CLI commands, repo layout (remove detach/, add fsedsl/lib9p)
- AGENTS.md: update architecture section (ctl rdwr, bypass, tool_load)
- architecture.md: rewrite namespace tree to match current state
- evolution.md: add Aug 9 section documenting all simplifications
2026-08-09 03:06:05 +02:00
Ollie Agent cbfc08875b fs: unify ctl — all levels use rdwrHandler + rdwrDispatch
Root, session, and agent ctl files all share the same dispatch
mechanism: rdwrHandler map → rdwrDispatch → Request (rdwr).

- ctlHandler/ctlDispatch (write-only) removed
- Root and session ctl upgraded to Request (rdwr), return 'ok'
- systemprompt moved to agent ctl command
- nopRead removed (dead)
2026-08-09 02:58:09 +02:00
Ollie Agent 0025003aa0 fs: refactor agent ctl to map-based dispatch
Replace switch statement with rdwrHandler map. Each command is a
function value in agentCtlHandlers — easy to extend, test individually,
and introspect.
2026-08-09 02:53:17 +02:00
Ollie Agent 993d5a812a fs: move tools to ctl commands, remove tools file
/tools        — lists loaded tools
/tool_load X  — loads a tool by name

System prompt updated to instruct the agent to use ctl for tool
management instead of writing to a tools file.
2026-08-09 02:52:06 +02:00
Ollie Agent 94088ccc94 fs: move cwd to ctl command, remove cwd file
/cwd returns current directory, /cwd X changes it (with stat check).
One fewer file in the agent namespace.
2026-08-09 02:48:50 +02:00
Ollie Agent 2561e01574 fs: move per-agent models to ctl command, remove models file
/models now lists available models for the agent's backend via ctl.
One fewer file in the agent namespace. The root-level models file
(all backends) remains unchanged.
2026-08-09 02:47:26 +02:00
Ollie Agent c05f4d1ef0 fs: agent ctl becomes rdwr (request-response)
The ctl file is now a Request handler: write a command, read the
response. Commands with no args return current state:

  /model        → prints current model
  /agent        → prints current profile
  /cwd          → prints working directory
  /name         → prints agent name
  /model X      → switches model, returns new model
  /compact      → compacts, returns 'ok'

o ctl now uses 'ollie-9p rdwr' to get the response.
This enables /model (no args) to show the current model from
any frontend.
2026-08-09 02:44:21 +02:00
Ollie Agent a4e5f7c9c5 unify commands: / == o ctl, all operations are ctl commands
The slash prefix in prompts now routes directly to the agent's ctl
file. No special-cased commands in the agent — the ctl handler is the
single command surface:

  /stop, /compact, /clear, /model X, /inject X, /agent X, /cwd X

New ctl commands:
  inject <text>  — overwrites any pending inject (replaces /i and /irw)
  agent <name>   — switch agent profile (moved from commands.go)

Agent methods added: Compact(), Clear(), SwitchProfile() — called by
the ctl handler, testable independently.

HandleCommand is now a thin trampoline: strip /, run 'o ctl <rest>'.
commands.go reduced from 155 to 50 lines.

REPL: / → o ctl, !q/!quit → exit TUI.
2026-08-09 02:40:48 +02:00
Ollie Agent 1bc438771f agent: replace 12 slash commands with ! prefix
! runs 'o' with session/agent context, giving access to the entire
namespace from any frontend (TUI, GUI, Emacs). Examples:
  !ctl compact       — compact context
  !ctl stop          — stop agent
  !read stats        — show usage/cost/ctxsz
  !read models       — list models

Kept: /i (inject mid-turn), /irw (rewrite inject), /agent (profile switch).
Removed: /backend, /models, /model, /maxsteps, /agents, /compact,
/context, /cost, /usage, /history, /clear, /sp.

Also simplified the o prompt REPL: slash commands reduced to /i and
/quit. Everything else via !<cmd>.

Dead code removed: contextDebug() in history.go.
2026-08-09 02:33:03 +02:00
Ollie Agent c7aea0db59 rename elevate→bypass throughout
The sandbox escape mechanism is a bypass, not privilege elevation.
The old name caused the agent to confuse it with sudo.

- elevate/ → bypass/ (package, types, tests)
- elevate_notify.go → bypass_notify.go
- Namespace: /elevate → /bypass, session/*/elevate → session/*/bypass
- Tool arg: "elevated" → "bypass"
- Env: OLLIE_ELEVATE_SOCKET → OLLIE_BYPASS_SOCKET
- File: elevate-policy.yaml → bypass-policy.yaml
- All docs, prompts, and scripts updated
2026-08-09 02:22:39 +02:00
Ollie Agent d1907adfae o script: audit cleanup
- Merge readloop into read -l (loop mode)
- Remove chatstream command (TUI uses 'o read chat' directly)
- Rework ctl: o ctl <cmd> [session] [agent] — dispatches to
  session ctl for kill/pause/resume, agent ctl for the rest
- Add trap EXIT to kill background statewait loop (fixes zombie)
- Remove -1 compatibility flag from generate
- Remove no-op bracketed paste bind from prompt REPL
- Fix /i help text: 'inject prompt (mid-turn or queued)'
- Update all help text to reflect current commands
2026-08-09 02:15:48 +02:00
Ollie Agent 49c93eab5f remove usage_log.go (write-only telemetry), clean AGENT_FILES
- Delete agent/usage_log.go — wrote JSONL to disk but nothing read it
- Remove appendUsageLog call from turn.go
- Remove dead 'offset' from AGENT_FILES tab-completion list
- TUI: grep markers+fences from o log (single read, not streaming)
2026-08-09 02:03:51 +02:00
Ollie Agent 72db6d900d fs: namespace cleanup — merge and remove dead files
- fifo.in + fifo.out → single fifo (write enqueues, read dequeues)
- cost + usage + ctxsz → single stats (key=value lines)
- Remove connection (no consumers, heartbeat handles it)
- Remove dead prevPrompt field and write (prompt.prev gone from spec)
- Clean AGENT_FILES: remove state, context, tail (all already absent
  from spec, were only in the tab-completion list)
2026-08-09 01:57:41 +02:00
Ollie Agent 744f775eb5 fs: split chat into chat (filtered text) and chat.raw (full markup)
chat — strips [[[...]]] markers and source fences at the byte level.
Partial lines pass through immediately for true streaming. Terminals
and text editors use this.

chat.raw — full block-structured stream with markers and fences.
GUIs that parse blocks (KDE, web) use this.

The TUI no longer pipes through grep (which was line-buffering and
killing char-by-char streaming since Aug 4).

The stripMarkers state machine processes each chunk from the server:
- Complete lines starting with [[[ and ending with ]]] → dropped
- Fence lines (```...) → dropped (open toggles in-fence state)
- Partial lines (no trailing \n) → always emitted immediately
- Everything else → passed through
2026-08-09 01:43:39 +02:00
Ollie Agent b2700b6e50 session: remove dead New() constructor and per-session sessionsDir
session.New() had zero callers — all sessions are created via
NewEmpty() + buildAgent(). Remove it along with the Config struct
(20 fields) and the per-session sessionsDir field (always identical
to pkgSessionsDir).

-92 net lines
2026-08-09 01:12:10 +02:00
Ollie Agent 7070e56346 session: remove dead env map (was stored but never read back) 2026-08-09 01:09:46 +02:00
Ollie Agent 57984dfa3f agent: replace sync.Cond with close-channel signal for WaitChange
sync.Cond is the wrong primitive for Go — it requires holding a mutex
during Wait and needs context.AfterFunc hacks to integrate with ctx
cancellation.

Replace with a simple signal channel: notifyChange() closes it and
swaps in a fresh one; WaitChange() selects on the channel and
ctx.Done(). Simpler, idiomatic, no spurious wakeups.
2026-08-09 01:08:41 +02:00
Ollie Agent 5b11e8afcb agent: embed GenerationParams in AgentConfig, remove GenParams()
Add JSON tags to backend.GenerationParams and embed it directly in
AgentConfig. The 14 duplicated sampling fields and the field-by-field
copy method disappear. Callers use cfg.GenerationParams directly.
2026-08-09 01:05:32 +02:00
Ollie Agent 5c81eefe0a remove dead code: TaskState subsystem, Verbosity, dead session fields
Remove entire TaskState machinery:
- TaskState struct, render(), taskState()/updateTaskState() on History
- inferTaskStateUpdate() — heuristic plan tracking
- Replan gate (replanGate const, roundsWithoutPlan counter)
- Stall detection (stallThreshold, stallRounds, lastAction)
- Plan reinject (planReinjectInterval, periodic re-injection)
- ReadPlanStep plumbing (AgentCfg → Agent → TurnCtx → loop)

None of this worked in practice — the model ignores the nudges,
ReadPlanStep was never wired to a non-nil value, and TaskState
fields were only populated by inferTaskStateUpdate (which depends
on ReadPlanStep being set).

Compaction now uses plain summary text in the cold zone instead
of serialized TaskState JSON.

Also remove:
- Verbosity field (declared, threaded, never read by any backend)
- DisallowTools (config field never wired to session)
- Session.listHandlers, plan, prevPrompt (never read)
- Config.Output, Config.ListHandlers, Config.ReadPlanStep (never set)

-246 net lines
2026-08-09 01:03:19 +02:00
Ollie Agent 625654fcef agent: simplify prompt resolver to file-path-only
All agent configs use the same pattern: JSON array of file paths with
env var expansion. Remove unused features:

- Shell command execution via resolveStringPrompt (the `!cmd` prefix
  path is kept as a trivial fallback but the 30s timeout/stderr
  capture/cwd probing is gone)
- Prompt directory search (PromptsDirs, resolvePromptFile)
- Shell metacharacter detection guard
- Literal-text-if-contains-newline heuristic
- IsExec flag on Prompt type (both string and array now mean the same
  thing: list of file paths)

207 + 49 → 104 + 38 lines (-114)
2026-08-09 00:51:13 +02:00
Ollie Agent 12894027dd session: export immutable fields, extract buildAgent helper
- Export ID, Uname, Ctx, Cancel, Proc, Keeper, Remote as struct fields
  (set-once at creation, not raced during agent loop)
- Keep mutex-protected accessors only for Name, ToolsConn, IsPaused
  which are read/written concurrently
- Extract buildAgent() shared helper used by both CreateAgent and
  restoreMultiAgentSession — eliminates ~100 lines of duplicated
  orchestration (tool server setup, prompt layers, runtime, backend)
- Paused sessions skip tool server entirely during restore (minimal
  agent with just history)
- Update fs/session_node.go delegators for exported fields
- 1638 → 1523 lines (-115)
2026-08-09 00:45:39 +02:00
Ollie Agent 010ad83944 simplify preamble: section-based model, no string surgery
Replace the monolithic preamble string with Preamble struct — an
ordered list of named sections joined on demand. Updates are simple
Set() calls; no marker-based string splicing.

Changes:
- Delete prompts/tool_discovery.md (content already in system_prompt.md)
- Reduce prompts/ package to just the embed + ResolveSystemPrompt
- Replace buildPreamble() with direct section construction
- Replace refreshToolListing() 90-line string surgery with one Set()
- Replace SetCWD string.ReplaceAll with env section rebuild
- Remove RenamePreamble (was a no-op; session ID is a template var)
- Export EnvironmentBlock() for session setup
- All callers use PreambleString() instead of raw string field
2026-08-09 00:32:49 +02:00
Ollie Agent 96d6d0b4cd update kde submodule: scroll-follow restored 2026-08-09 00:16:52 +02:00
Ollie Agent 97ee63cd9c update kde submodule: always-on chat stream 2026-08-09 00:14:38 +02:00
Ollie Agent bceb3708e9 update kde submodule: incremental rendering 2026-08-09 00:12:30 +02:00
Ollie Agent 8093566e67 justfile: standardize all installs to ~/.local/bin
Previously, Go binaries and scripts installed to ~/bin while cmake
(KDE) installed to ~/.local/bin. This caused stale binaries in ~/bin
to shadow fresh builds since ~/bin comes first on PATH.

- Change bin variable from ~/bin to ~/.local/bin
- Add migrate-bin target to clean stale ~/bin copies
- Run migrate-bin automatically during install
2026-08-09 00:03:49 +02:00
Ollie Agent 50a0737635 kde: fix gui deadlock (demand-driven chat streaming) 2026-08-08 23:20:11 +02:00
Ollie Agent dec80c85d2 kde: revert gui bulk load (didn't fix the freeze) 2026-08-08 23:16:11 +02:00
Ollie Agent fe5e99618e kde: update submodule (fix gui freeze on agent switch) 2026-08-08 23:15:04 +02:00
Ollie Agent 2c5444e902 o: /agent with no args shows current agent profile 2026-08-08 23:07:54 +02:00
Ollie Agent b5404fff87 o: /cwd with no args shows current working directory 2026-08-08 23:07:26 +02:00
Ollie Agent cf1866d646 o: /model and /backend with no args show current value 2026-08-08 23:04:33 +02:00
Ollie Agent 79afb09f3d o: fix /i command — was sending double-slash to prompt
$line still had the leading / from input, so echo "/$line" sent
//i ... to the agent. Use $cmd (which has the / stripped) instead.
2026-08-08 23:00:59 +02:00
Ollie Agent d596c31606 backend: move default backend selection to backends.conf
backends.conf now supports a top-level 'backend = name' line that
selects the default backend for new sessions. Lookup order:

  1. backends.conf 'backend = ...'
  2. OLLIE_BACKEND env var (fallback)
  3. session-level backend= parameter (override)

No env file needed for backend/model config anymore.
2026-08-08 22:57:37 +02:00
Ollie Agent c9df895445 data: add model field to copilot/kiro in sample backends.conf 2026-08-08 22:55:00 +02:00
Ollie Agent c1c0013f2d all: kill loadEnvFile dupe, extract text parser, tidy tests
backend:
- Delete loadEnvFile (env.EnsureDefaults at startup covers it)
- Move newFromEnv to test file (only tests use it)
- Delete dead tests (TestLoadEnvFile*, env-file override tests)
- new.go: 150→60 lines

agent:
- Extract text tool-call parser to text_parse.go (288 lines)
  parseTextToolCalls, shorthandToJSON, extractBalanced,
  parseExtraKV, extractJSONObject, relaxJSON
- loop.go: 1113→835 lines
2026-08-08 17:06:51 +02:00
Ollie Agent 68b844bbfa fs: fix cfg display — dereference pointer fields, omit when nil
temperature, topP, topK are *float64/*int pointers. Previously
printed as hex addresses or <nil>. Now shows actual values when
set, omitted when nil.
2026-08-08 16:58:48 +02:00
Ollie Agent 2c26a7fb9c backend: add backends.conf for per-backend configuration
Each backend is now configured via ~/.config/ollie/backends.conf:

    [openrouter]
    key = sk-or-v1-...
    model = qwen/qwen3-235b-a22b

    [anthropic]
    key = sk-ant-...

Each backend knows its own default URL (openrouter → openrouter.ai/api,
anthropic → api.anthropic.com, etc). Only key and optional model needed.

Env vars (OLLIE_OPENAI_KEY, OLLIE_ANTHROPIC_KEY, etc) still work as
fallback for backward compatibility, but backends.conf is the canonical
config path going forward.

- Delete openAIName() (URL no longer determines backend identity)
- Delete geminiKey() (config handles fallback)
- Install template with mode 600 (contains API keys)
- Only install template if user hasn't created their own
2026-08-08 16:25:47 +02:00
Ollie Agent f4caf29a35 fs: fix nil panic in sessionBindings — RootState captured at build time
The previous commit (3b83b9d) replaced globalRootState with
ctx.Root.Data.(*RootState), but ctx.Root is nil inside closures
captured by BuildTree (Root is set *after* the tree is built).

Fix: add RootState field to HandlerCtx and create it before BuildTree
so all closures capture the live pointer directly.
2026-08-08 16:17:42 +02:00
Ollie Agent 5f960b56f8 justfile: remove deleted packages (detach, skills) from build/test targets 2026-08-08 16:15:21 +02:00
Ollie Agent 455434608a all: merge toolsrv files, fix context hierarchy, remove dead params
toolsrv:
- Merge rpc.go into conn.go (wire types already there)
- Merge tools.go + discover.go into registry.go
- Merge accessors.go into server.go
- 4 files eliminated

fs:
- HandlerCtx.Context now carries the session context (set via
  sessionBindings Applier). Previously it was the daemon context
  which never cancels — handlers checking ctx.Done() now properly
  detect session kill/pause.
- Session-scoped blocking handlers (streamAgentChat, blockAgentStateWait)
  merge session context with per-read timeout via mergeCtx(). A session
  kill now immediately unblocks readers without waiting for the 5s timeout.
- Remove redundant manual AfterFunc in blockAgentStateWait.

session:
- Remove unused _ string parameter from WaitEvent
2026-08-08 16:13:55 +02:00
Ollie Agent 5b64d62d2e agent: remove auditLog (was always derived from log)
The audit logger was never a separate destination — it was always
log.Sub("audit"), writing to the same sink with a prefix. The
fallback in NewAgent even warned 'deriving from Log' every time.

Replace ag.auditLog.Debug() calls with ag.log.Debug() directly.
Remove the field, AgentCfg.AuditLog, and all session plumbing.
2026-08-08 15:59:00 +02:00
Ollie Agent 705a7226a2 all: merge thin packages and small files
- Merge detach/ into toolsrv/detach.go (single consumer)
  Rename Process → DetachedProcess to avoid collision with spawn.go
- Merge agent/state.go into loop.go (types used only there)
- Merge agent/runtime.go into runtime.go (formerly build_runtime.go)
- Merge agent/compaction.go + models.go into history.go
- Merge agent/new.go into agent.go (constructor lives with struct)
- Rename ResultTier → MemoryTier (TierHot/Warm/Cold → MemoryHot/Warm/Cold)
- Rename build_runtime.go → runtime.go
2026-08-08 15:56:26 +02:00
Ollie Agent 8152dec075 all: delete dead code, tighten API surface
toolsrv:
- Delete WithOnClose, WithOnEnvSet, SetOnExit (dead Options)
- Delete ListDetached, ListDetachedInfo (only ListDetachedRaw used)
- Delete Execute (dead wrapper)
- Delete CWD, ToolRegistry, SessionID, InjectContent (dead accessors)
- Delete ExecuteInSandbox, ExecuteElevated (zero external callers)
- Delete Summaries, RefreshLoaded from Registry (dead)
- Delete DialSSH (alias for RemoteDial)
- Simplify Dial: takes socket string directly, kill Addr/LocalAddr/SSHAddr
- Rename Server receiver e → s
- Unexport context import (no longer needed in tools.go)

session:
- Delete SaveFuncs, AgentAt, AgentCount, NextUncheckedStep
- Delete SetDisallowTools, SaveAllSessions

env:
- Delete Set, Get, All, Format, managed (dead exports)
- Unexport LoadFile → loadFile

fs:
- Delete HandlerCtx.ToolReg, Skills, SaveFn (never read by handlers)
- Delete Config.MkdirAll, Config.SkillsRegistry (dead plumbing)
- Delete AgentLog: Plan, SetPlan, PrevPrompt, Mu, LogInfo, Remote methods
- Delete unused type aliases (NodeOption, FileTree, FileConfig, etc.)

backend:
- Delete ClosePool, PoolStats (dead), New() (dead)
- Delete kiroTokenExpiringSoon standalone func (dead)
- Unexport SharedTransport/SharedClient → sharedTransport/sharedClient

skills:
- Delete entire package (zero importers; feature works via tool scripts)

agent:
- Delete BroadcastChange (dead duplicate of notifyChange)
- Delete HasHistory, ToolCallCount, CompactionModel, SetCompactionModel
- Unexport SetReply, BuildPreamble, DefaultPromptsDir
2026-08-08 15:51:13 +02:00
Ollie Agent 06a996e967 all: replace toolsrv.Runner interface with *toolsrv.Conn
The agent always talks to a *Conn (never a *Server directly).
Replace the Runner interface with the concrete type throughout:

- Runtime.ToolServer is now *toolsrv.Conn
- BuildRuntime takes *toolsrv.Conn
- session.Config, SessionInfra, InfraConfig use *toolsrv.Conn
- All inline type assertions in agent.go deleted — methods called
  directly on *Conn (SetEnv, SetCWD, Close, Detach, ListDetachedRaw,
  SignalDetached, GetDetachedOutput, DismissDetached, SetAllowTools,
  SetOnToolsChanged, Ping, ToolRegistryRevision)
- Added Conn.ToolRegistryRevision() that returns 0 (remote connections
  don't support revision tracking; use push-based OnToolsChanged instead)
- Deleted the Runner interface and its test
- Renamed LoadToolOnRunner → LoadToolOnConn
2026-08-08 15:10:01 +02:00
Ollie Agent 3b83b9d373 all: delete dead interfaces, kill globalRootState
- agent: delete 'state' interface (one implementation: *History). run()
  now takes *History directly.
- agent: delete 'backendNamer' interface. resolveCompactionModel takes
  backend.Backend directly.
- fs: delete Shutdown/InterruptAll/Lookup wrappers that took *Tree they
  never used. Callers (olliesrv) now call session.* directly.
- fs: delete globalRootState. sessionBindings uses ctx.Root.Data.(*RootState)
  via the HandlerCtx that was always available.
2026-08-08 14:58:47 +02:00