omp packages

@rackrot/pi-core0.14.0

Core rackrot pi extension and shared utilities for the other @rackrot packages

GitHub Actions Published 12 hours ago MIT ~3.5K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@rackrot/pi-core

The core rackrot extension, plus shared code for the other @rackrot/pi-* packages.

pi install npm:@rackrot/pi-core

Install this one everywhere. It is where always-on behavior goes.

Features

Anthropic thinking-block binding

Anthropic ties each thinking-block signature to the system prompt, tools and earlier messages that produced it. When that prefix changes (an extension edits a tool description, or pi restarts into an old session) every earlier block is dropped server-side on every later turn, and pi reports Anthropic dropped N thinking blocks: prefix_binding_mismatch for the rest of the session.

The extension fingerprints system + tools on each Anthropic request. When the fingerprint changes it strips thinking from the replayed history once, records a cutoff in the session, and keeps stripping anything at or before it. Cases the fingerprint can't see (already-broken sessions, rewritten history) are caught from Anthropic's own prefix_binding_mismatch diagnostic, costing one warning instead of one per turn. Only anthropic-messages models are touched; session files keep the original blocks; there is no configuration. A message that is only thinking is left as is.

Adapted from luan/agents pi-thinking-binding (MIT). Uninstall that package if you have it, or both will act.

/cache-ttl

Anthropic prompt-cache TTL is 1h by default (writes cost 2x base input instead of 1.25x; reads are unchanged). Core sets pi's own PI_CACHE_RETENTION=long unless you already set that variable, so pi applies it only to models that support it. /cache-ttl [5m|1h] changes it for the session (no argument toggles), stores the choice in the session, and shows cache:1h in the status bar. A switch only affects later cache writes.

Subagents run in the same process and follow the same variable. To keep them on 5m, set "cacheRetention": "short" in ~/.pi/agent/subagents.json (@tintinweb/pi-subagents). Inspired by mackenney/pi-cache-ttl-config; uninstall that package if you have it.

codebase-memory indexing

When the codebase-memory-mcp CLI is installed, core starts its daemon and indexes the working directory in the background at session start, so the graph tools have data. Sessions without a UI (subagents, pi -p) skip it. Turn it off with "codebaseMemory": { "enabled": false } in the global or project config, or under Core in /rackrot-config.

/rackrot-config

One command for every rackrot package's config. With no argument it lists the sections of the installed packages (Subagents, Skill index, Council, Model aliases, Forgejo MCP); /rackrot-config <id> opens one, /rackrot-config show prints a summary of each. Tab in a screen switches the save target between global (~/.pi/agent/rackrot/config.json(c)) and project (.pi/rackrot.json(c)); project values win. Packages add a section with registerConfigSection from @rackrot/pi-core/config-ui: pass fields for scalar settings (core draws the screen) or open for a custom editor.

/rackrot-init writes ~/.pi/agent/rackrot/config.jsonc with every installed package's defaults and examples, commented out, under a $schema line that points at the schema below. It is only registered while no global config exists.

/rackrot-config check validates the global and project files against the schema and prints one file: path: message line per problem: unknown keys (typos), wrong types and values, and keys set in the project file that only the global file can set (those are ignored). It only reports; loading the config never depends on it.

/rackrot-config migrate drops the keys check reports as unknown from both files, which is how settings a release removed (such as modelAliases) go away. It lists them and asks first; without a UI, run /rackrot-config migrate --yes. Comments and every other key are kept. Typos count as unknown, so read the list.

Config schema

schema/rackrot-config.schema.json is a JSON Schema (draft 7) of the whole rackrot config, every key at every depth, with descriptions and the parsers' defaults. Objects are closed, so an unknown key is an error. Settings that only the global layer reads carry "x-global-only": true. Point an editor at it for completion, hover docs and error squiggles (JSONC comments are fine):

{ "$schema": "./node_modules/@rackrot/pi-core/schema/rackrot-config.schema.json" }

Use the path of the installed copy, or the file:// URL /rackrot-init writes. The schema is generated from each package's src/config-schema.ts by node scripts/build-config-schema.ts (--check fails when the committed file is stale). When you add or change a config key, change the package's fragment, rerun the script and commit the result; each package's test compares the schema's defaults with what its parser resolves, so a wrong default fails. The schema is advisory documentation and checking: the hand-written parsers still load the config. Rules JSON Schema cannot state, such as memory.consolidate.reviewThreshold being capped at autoThreshold, are in the descriptions.

Shared utilities

Other packages in this repo depend on it ("@rackrot/pi-core": "workspace:*" in dependencies):

import { readJson, writeJsonAtomic, readConfigLayers } from "@rackrot/pi-core";
// or: "@rackrot/pi-core/json", "@rackrot/pi-core/config", "@rackrot/pi-core/thinking-binding"
Export Purpose
readJson(path) Read a JSON object; {} if missing or invalid
readJsonStrict(path) Same, but throws on bad content and returns the file's indent
writeJsonAtomic(path, data) Write via temp file + rename, creating parent dirs
configPath(scope, cwd) ~/.pi/agent/rackrot/config.json(c) or .pi/rackrot.json(c)
readConfig(path) Read a JSONC object; {} if missing or invalid
readConfigStrict(path) Same, but throws on bad content
readConfigLayers(key, cwd) One top-level key from each layer (global, project)
editConfig(path, fn) Rewrite changed top-level keys only, keeping comments

Put code here only when two or more packages need it.

@rackrot/pi-core/retrieval (embedder, reranker, BM25 and fusion helpers) does not bring the ONNX runtime with it. A package that uses the onnx provider depends on @huggingface/transformers itself and passes a loader: createEmbedder(cfg, () => import("@huggingface/transformers")).

Shared retrieval models

embedding, reranker and decision are one settings group, retrieval, in the global config (/rackrot-config > Retrieval models). Every package that searches (pi-skill-index, pi-memory, pi-research) starts from it; each can override any field in its own config block (skillIndex, memory, research). Resolution is core defaults, then retrieval, then the package's own block, field by field. The group is read from the global layer only: a block names an endpoint that receives text and the environment variable whose key is sent to it, so a checked-in project config cannot set it.

{
	"retrieval": {
		"embedding": {
			"provider": "http",
			"baseUrl": "https://api.example.com/v1",
			"model": "my-embed",
			"apiKeyEnv": "EXAMPLE_API_KEY"
		},
		"reranker": { "provider": "none" }
	}
}

resolveRetrieval(...layers) and sharedRetrieval(cwd) from @rackrot/pi-core/retrieval-config do the resolution. pi-memory's own default is no reranker; a shared retrieval.reranker replaces that.

@rackrot/pi-core/decision holds the System One client shared by pi-skill-index and pi-memory: createDecider(cfg, { typesafe, laya }) returns ask(state, questions) with a yes-probability per question. The calling package depends on @typesafe-ai/sdk (and optionally @receptron/laya) and passes loaders, like the transformers loader above.

@rackrot/pi-core/okf, /schema and /structured hold the schema layer. typebox is a peer dependency of this package, so a package that imports them must have it installed.

  • okf: typebox schemas for OKF v0.3 frontmatter (docs/okf/SPEC-0.3.md in the repo). normalizeOkf reads leniently, as spec 11.2 requires: unknown keys are kept, null and empty values count as absent, a scalar tags is one tag, and an entry without its required key is dropped with a warning. okfErrors is the strict check for what we write.
  • schema: schemaErrors(schema, value) and readJsonFile(path, schema), which returns undefined for a missing file and throws for a corrupt one; the caller decides whether that is fatal.
  • structured: structuredCall asks a model for JSON matching a schema. It sends the schema as a submit tool (strict JSON-schema sampling preferred) and in the system prompt, reads the tool call or else JSON in the text, and on a mismatch sends the model its own answer, the errors and the schema again (2 retries by default). textCaller wraps it as a (system, prompt, schema?) => text function.

Published with pnpm publish so the workspace: dependency ranges resolve to real versions; earlier releases were not installable from npm.

/init-deep

/init-deep [focus] asks the agent to create or update the root AGENTS.md, ARCHITECTURE.md and STRUCTURE.md, then review the directories and add a nested AGENTS.md only where a subtree materially differs (at most 10 per run). It edits in place, marks unverifiable facts UNCONFIRMED and does not commit. Text after the command is appended to the prompt.

Usage log

Records which tools, skills, agents and commands get used in <agentDir>/rackrot/usage.sqlite, so updates can follow data. Tables: events (what happened), catalog (what was available, so never-used items show up), sessions. It stores names, counts and timings only, never prompts, arguments, results or search queries. Events older than 365 days are pruned.

  • /usage [days] prints a report: per-kind counts, errors, p50/p95 duration, never-used items, and for skill_search the skills offered versus loaded later in the same session.
  • Turn it off with {"usage": {"enabled": false}} in the rackrot config (or /rackrot-config).
  • Other packages record domain events with record() from @rackrot/pi-core/usage; it never throws.
  • Agents and workflows come from pi-subagents' subagents:* events (so workflow-spawned and scheduled agents count too); @rackrot/pi-agents supplies their catalog. Each event is stored under the session it fired in, so a subagent's own tool calls carry the subagent's session id.
  • Limits: a skill counts as loaded when its SKILL.md is read or /skill:name is typed, so a skill applied from the prompt alone is not seen. Agents from other packages are catalogued only once they have an override.