feat(runtime): track user-level Pi configuration with the provider key templated

Mirrors ~/.pi/agent/ as the authoritative copy. models.json becomes
models.json.template with ${ZENMUX_API_KEY} substituted; the real value stays
in secrets/zenmux.env, which is untracked and enforced by the pre-commit guard.

Excluded with rationale: auth.json, trust.json, models-store.json, sessions/,
herdr-agent-state.ts (installer-managed, overwritten on reinstall) and the
third-party skills under ~/.agents/skills.

Recorded during migration: the configured fallback model zenmux/x-ai/grok-4.6 is
absent from models.json, so pi falls back to an undeclared custom model id with
no context window, cost table or thinkingLevelMap. Fixing that is a behaviour
change and is deferred rather than folded into this zero-change migration.
This commit is contained in:
Kai
2026-08-26 22:52:48 -07:00
parent 734e63aa28
commit 98635022d0
9 changed files with 505 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import type {
ExtensionAPI,
ProjectTrustEventResult,
} from "@earendil-works/pi-coding-agent";
import { realpathSync } from "node:fs";
import { resolve } from "node:path";
const MEMO_WORKSPACE = "/home/claw/pi-workspaces/memo-inbox";
export default function piMemoTrust(pi: ExtensionAPI) {
pi.on("project_trust", async (event): Promise<ProjectTrustEventResult> => {
try {
if (realpathSync(resolve(event.cwd)) === realpathSync(MEMO_WORKSPACE)) {
return { trusted: "yes", remember: true };
}
} catch {
// Fall through to Pi's normal trust decision for every other path.
}
return { trusted: "undecided" };
});
}