Skip to content

Commit 5d6908a

Browse files
author
Alex
committed
feat(terraphim): add project-local .terraphim KG + thesaurus for terraphim-grep
KG-driven search configuration specific to pi_agent_rust so terraphim-grep works offline (no server) with project-aware concept boosting. - .terraphim/kg/: 13 project concepts (provider, session, extension, tool, sse, model-registry, acp, interactive-tui, conformance, hashline-edit, auth, asupersync, pi-terraphim-router), each with description + synonyms:: - .terraphim/thesaurus.json: 180 compiled entries (synonym -> {id, nterm}) - .terraphim/config.json: Pi Agent Rust Engineer role -> project KG + Ripgrep haystack terraphim-grep loads the thesaurus (180 entries), fff-search scans the repo, and matched concepts (e.g. 'extension','hostcall') boost relevant chunks above the baseline score. Requires terraphim-grep built with the code-search feature (fff-search); without it search_code is compiled out.
1 parent 48de429 commit 5d6908a

15 files changed

Lines changed: 875 additions & 0 deletions

.terraphim/config.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "Pi Agent Rust Engineer",
3+
"shortname": "piarust",
4+
"relevance_function": "terraphim-graph",
5+
"terraphim_it": true,
6+
"theme": "united",
7+
"kg": {
8+
"automata_path": null,
9+
"knowledge_graph_local": {
10+
"input_type": "markdown",
11+
"path": "/home/alex/projects/terraphim/pi_agent_rust/.terraphim/kg"
12+
},
13+
"public": false,
14+
"publish": false
15+
},
16+
"haystacks": [
17+
{
18+
"location": "/home/alex/projects/terraphim/pi_agent_rust",
19+
"service": "Ripgrep",
20+
"read_only": true,
21+
"fetch_content": false,
22+
"atomic_server_secret": null,
23+
"extra_parameters": {}
24+
}
25+
],
26+
"llm_enabled": false,
27+
"llm_provider": "ollama",
28+
"ollama_model": "llama3.2:3b",
29+
"ollama_base_url": "http://127.0.0.1:11434",
30+
"llm_router_enabled": false,
31+
"llm_context_window": 32768,
32+
"extra": {}
33+
}

.terraphim/kg/acp.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ACP
2+
3+
Agent Client Protocol support. `pi --acp` runs pi as an ACP server (stdin JSON-RPC) so external clients drive it headlessly. Supports `session/set_model`, `session/set_config_option`, and `--session-dir` persistence. The runtime-parking fix (#107) stopped idle `--acp` from burning ~200% CPU. Distinct from the interactive TUI and the RPC/stdin bridge in `src/rpc.rs`.
4+
5+
**Key files:** `src/main.rs`, `src/acp.rs`, `src/rpc.rs`
6+
7+
Related: interactive-tui, session, rpc
8+
9+
synonyms:: acp, agent client protocol, --acp, acp server, acp session, set_model, set_config_option, session-dir, json-rpc server, rpc mode, stdin mode, rpc

.terraphim/kg/asupersync.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# asupersync
2+
3+
Structured-concurrency async runtime from the sibling `../asupersync` crate. Powers HTTP client, TLS (webpki-roots), SQLite, cancellation, and explicit capability context (Cx). Enables deterministic testing via LabRuntime. pi pins `asupersync = "0.3.4"`. The runtime-parking fix (#107) relies on it to idle `--acp` without CPU spin.
4+
5+
**Key files:** `Cargo.toml`, `src/http/client.rs`
6+
7+
Related: provider, sse, session
8+
9+
synonyms:: asupersync, async runtime, structured concurrency, runtime, labruntime, capability context, cx, http client, tls, webpki roots, cancellation, runtime parking

.terraphim/kg/auth.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Auth
2+
3+
Credential storage and OAuth flows (`src/auth.rs`). `auth.json` (perms 600) at `~/.pi/agent/auth.json` holds OAuth tokens (openai-codex via localhost:1455 callback, anthropic, google gemini-cli via :8085, github copilot, kimi-for-coding) and API keys. `/login <provider>` runs the in-TUI OAuth flow; `pi doctor` reports token validity. Expired tokens must be re-logged-in.
4+
5+
**Key files:** `src/auth.rs`, `~/.pi/agent/auth.json`
6+
7+
Related: provider, interactive-tui
8+
9+
synonyms:: auth, authentication, oauth, auth.json, login, /login, credentials, oauth token, token expired, api key, openai-codex login, kimi oauth, copilot login, auth storage, re-login

.terraphim/kg/conformance.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Conformance
2+
3+
Fixture-based conformance tests validating tool/provider/session behaviour against JSON fixtures (`tests/conformance.rs`, `tests/installer_regression.sh`). Fixture shape: `{version, tool, cases:[{name, setup, input, expected:{content_contains, content_regex, details_exact}}]}`. Run with `cargo test conformance`. Extension conformance lives under `tests/ext_conformance/`. Installer/skill integrity is gated by `scripts/skill-smoke.sh`.
4+
5+
**Key files:** `tests/conformance.rs`, `tests/installer_regression.sh`, `scripts/skill-smoke.sh`
6+
7+
Related: tool, extension, session
8+
9+
synonyms:: conformance, conformance test, fixture, fixture test, conformance suite, installer regression, skill smoke, ext_conformance, test fixture, content_contains, details_exact

.terraphim/kg/extension.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Extension
2+
3+
JavaScript extension runtime on QuickJS with a capability policy layer. Extensions provide extra tools/providers via hostcalls bridged through `src/extensions_js.rs`. The policy engine (`src/extensions.rs`) enforces allow/deny capability controls (filesystem, network, subprocess). Conformance fixtures under `tests/ext_conformance/` validate JS parity and taxonomy. The `wasm-host` feature gates a Wasmtime runtime alternative.
4+
5+
**Key files:** `src/extensions.rs`, `src/extensions_js.rs`, `tests/ext_conformance/`
6+
7+
Related: tool, provider, conformance
8+
9+
synonyms:: extension, extensions, quickjs, quickjs runtime, javascript extension, capability policy, hostcall, hostcalls, extension runtime, wasm host, wasmtime, extension parity, extension taxonomy, extension oauth

.terraphim/kg/hashline-edit.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# hashline_edit
2+
3+
Precise-edit tool using `LINE#HASH` anchors emitted by `read`/`grep` with `hashline=true`. Avoids ambiguous string-match edits by pinning each edit to a line number + content hash, so concurrent drift can't silently mis-apply. One of the 8 built-in tools in `src/tools.rs`.
4+
5+
**Key files:** `src/tools.rs`
6+
7+
Related: tool
8+
9+
synonyms:: hashline_edit, hashline, line hash, hash line, precise edit, line hash edit, hash anchor, LINE#HASH, hashline edit tool

.terraphim/kg/interactive-tui.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Interactive TUI
2+
3+
Interactive terminal front-end (`src/interactive.rs`, `src/tui.rs`) built on the charmed_rust stack (bubbletea/lipgloss/bubbles/glamour) gated behind the default-on `tui` feature. 60fps differential rendering. Slash commands live in `src/interactive/commands.rs` (`/login`, `/model`, `/mcp`, `/help`). Mouse capture can be disabled with `PI_NO_MOUSE_CAPTURE=1` to let terminal-native copy/paste work during OAuth.
4+
5+
**Key files:** `src/interactive.rs`, `src/interactive/commands.rs`, `src/tui.rs`, `Cargo.toml` (`tui` feature)
6+
7+
Related: rpc, acp, model-registry
8+
9+
synonyms:: interactive, tui, interactive tui, terminal ui, bubbletea, charmed_rust, lipgloss, glamour, slash command, /login, /model, /mcp, mouse capture, pi no mouse capture, frontend

.terraphim/kg/model-registry.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ModelRegistry
2+
3+
Model resolution layer (`src/models.rs`, `src/app.rs`). Resolves `ModelEntry` records from built-in seeds, a legacy generated catalog, and a user `models.json` (with env/file value resolution). Upstream commit #117 made the data catalog authoritative for reasoning effort + thinking-control metadata. `PROVIDER_DEFAULT_MODELS` in `src/app.rs` lists newest-first default candidates per provider (e.g. kimi-for-coding -> kimi-k2.7, kimi-k2.6, ...). Autocomplete candidates drive the `/model` picker.
4+
5+
**Key files:** `src/models.rs`, `src/app.rs`, `docs/provider-upstream-model-ids-snapshot.json`
6+
7+
Related: provider, interactive-tui, auth
8+
9+
synonyms:: model registry, modelregistry, model entry, modelentry, models.json, model catalog, built-in models, provider default models, model resolution, autocomplete, reasoning effort, thinking control, default model, model id, model fetch, kimi-k2.7, glm-5.2
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# pi_terraphim_router
2+
3+
Optional knowledge-graph model router (`src/pi_terraphim_router/`, ~1495 lines: mod/rpc_client/types/error). Feature-gated behind `terraphim-routing` (off by default). Uses a KgRouter with Aho-Corasick concept matching + readiness-aware fallback to pick a provider/model for a prompt. **Currently BLOCKED** on `task/terraphim-router-blocked`: its path deps (`terraphim_router/types/automata`) were extracted to the standalone terraphim-core repo (registry deps, Gitea #1910) and need migrating.
4+
5+
**Key files:** `src/pi_terraphim_router/`, branch `task/terraphim-router-blocked`, `examples/terraphim_router.rs`
6+
7+
Related: model-registry, provider, auth
8+
9+
synonyms:: pi_terraphim_router, terraphim router, kg router, model routing, intelligent model selection, demoroute, demo-route, readiness-aware routing, terraphim-routing, terraphim-routing feature, aho-corasick router

0 commit comments

Comments
 (0)