Add OpenViking extension for the pi coding agent (github.com/mariozechner/pi-coding-agent).
Provides synchronous recall, auto-capture, 7 LLM tools, session commit, and memory indexing.
Architecture: 8 TypeScript files + config, loaded by pi's jiti transpiler — zero dependencies
beyond Node.js. Design informed by all three existing OV plugins (OpenClaw for synchronous recall,
Claude Code for production-hardened capture/ranking, Hermes for anti-patterns).
Key features:
- Synchronous recall via pi's context event (not stale prefetch)
- 7 native LLM tools (search, read, browse, remember, forget, add_resource, archive_expand)
- Tool USE preservation, tool result dropping
- Token-budgeted content resolution with graceful degradation
- Memory pollution prevention (context block stripping)
- Client-driven commit threshold
- Pre-compact commit, session resume rehydration
- Memory index (map model vs flashlight)
- Write queue with batching
- Globs-based bypass patterns
- Env var config overrides (OPENVIKING_URL, OPENVIKING_API_KEY, etc.)
~1692 lines TypeScript + 29 lines config. Tested with local OpenViking server:
7/7 tests passing (load, sync, commit, recall, 7 tools, /viking command, continuation).
Summary
Adds an OpenViking memory extension for the Pi coding agent (
@mariozechner/pi-coding-agent).Pi is a terminal-based LLM coding agent harness (similar to Claude Code, built in TypeScript) with a native extension API — event-driven lifecycle hooks, tool registration, system prompt injection, and session management. This extension brings OpenViking's long-term semantic memory to pi sessions: synchronous recall, automatic turn capture, 7 LLM tools, session commit with memory extraction, and a knowledge index so the model knows what OV contains.
Design lineage: Informed by deep study of all three existing OV agent plugins:
The extension is 8 TypeScript files (~1692 LOC) + a JSON config, loaded by pi's built-in
jititranspiler — zero npm dependencies beyond Node.js. All communication uses the OpenViking REST API (same endpoints as the CC plugin'sov-session.mjsclient).Type of Change
Key Features
contextevent searches OV with current prompt, injects<relevant-memories>block in same turnpi.registerTool()— search, read, browse, remember, forget, add_resource, archive_expandturn_endevent extracts user + assistant turns (tool USE preserved, tool RESULTS dropped)pending_tokensfrom OV session, commits at threshold (20k default)session_before_compactevent commits before pi rewrites the transcriptbefore_agent_start<openviking-context>,<relevant-memories>,<system-reminder>before pushing to OVOPENVIKING_URL,OPENVIKING_API_KEY,OPENVIKING_ACCOUNT,OPENVIKING_USER,OPENVIKING_AGENT_IDArchitecture
The extension wires into pi's event lifecycle:
Testing
/vikingcommand (status + manual commit)pi -csession continuation with tools availableviking_searchoutput trimmed torecallMaxContentChars(500 default)pi -cresume (workaround for pi internal quirk)Related Issues
N/A — new contribution.
Checklist
Maintainer Routing
This is a new agent integration example in
examples/. It doesn't modify any Python/Go/Rust code.The existing
examples/claude-code-memory-pluginis the closest sibling. This extension is the pi equivalent — same REST API surface, complementary design choices (native tools vs MCP delegation, map index vs flashlight search).Possible reviewers:
@qin-ctx(platform/integration) or any cross-module maintainer.