Skip to content

feat(pi): add a Pi package that routes Anthropic through context-guru - #977

Merged
amiddavid merged 2 commits into
mainfrom
feat/pi-plugin-anthropic
Nov 9, 2026
Merged

amiddavid merged 2 commits into
mainfrom
feat/pi-plugin-anthropic

Conversation

@amiddavid

Copy link
Copy Markdown
Collaborator

Summary

Adds pi-package/, a Pi package that routes Pi's Anthropic models through a local context-guru proxy. It is the Pi counterpart of the Claude Code plugin. OpenAI follows in a stacked PR.

Data dependence: metadata only. The extension sends the proxy Pi's session id (a header) and session end and compaction events (id, event, reason). It adds no component, so docs/data-dependence.md does not change.

Behavior change: none for existing users. This is a new, opt-in package.

What changed

  • /context-guru setup asks one question. On yes it:
    1. downloads the proxy release and checks its SHA-256 (or uses context-guru-proxy on PATH);
    2. starts the proxy as a user service (LaunchAgent on macOS, systemd --user on Linux);
    3. then sets providers.anthropic.baseUrl in ~/.pi/agent/models.json.
      A failed start writes no route.
  • No work per session or per request. Routing is in models.json, and the service is up before Pi starts. The extension makes no network call on session start or on a request.
  • The extension does three small things:
    • adds x-context-guru-session: <Pi session id> to routed requests, so the proxy keeps one session across a compaction;
    • stops Pi's own cache warming for routed models while the proxy keep-alive is on, so the cache has one pinger, not two (none leaves Pi's warming as it is);
    • posts session end and compaction signals to /signal, fire and forget.
  • Commands: /context-guru status | preset | cache-strategy | update | uninstall. preset and cache-strategy restart the proxy after a yes.
  • Presets and cache strategies are the same as the Claude Code plugin. A test fails if the strategy keys drift apart.
  • Undo: uninstall, and a reset hatch copied out of the package to ~/.local/state/context-guru-pi/context-guru-reset. Both remove the route first and touch only what context-guru wrote. A baseUrl the user changed after setup stays.
  • If models.json already sends Anthropic elsewhere (a gateway), setup refuses and changes nothing.

How it was tested

  • 16 Python tests (scripts/test_pi_plugin.py), in a temp HOME: route install and restore, refusal of a broken or foreign models.json, no route when the proxy does not come up, consent required, reset hatch, strategy parity with the Claude Code plugin. They pass on macOS (Python 3.13) and on the eval box (Python 3.9).
  • 4 Node tests (tests/context-guru.test.ts) for the extension's pure helpers. Pass on Node 22.18.
  • Type check of the extension against @earendil-works/pi-coding-agent 1.5.0 (tsc --noEmit, strict).
  • Real proxy (v0.7.0): it starts with each generated config (ultrahigh/auto, off/none, medium/2-ping, high/1-ping) and reports the right preset. /signal returns 204 for the extension's end and compaction bodies.
  • go vet and gofmt are clean on the eval box. pi_test.go runs both test sets from go test ./.... It skips the Node tests when Node is older than 22.18.

Not tested yet: a real Pi session end to end. Pi 1.5.0 needs Node 22.19 and this laptop has 22.18. The service install (launchd and systemd) is also not run, because it changes the machine.

Open questions

  • Distribution. pi install git: has no subfolder syntax, so this version installs from a local clone. Publish to npm later, or add a root package.json with a pi manifest?
  • Pi's cache warming. The extension stops Pi's warming in both phases while the proxy keep-alive is on. During a long tool run Pi would ping until 60 minutes. The proxy keep-alive stops after 2 pings. Is one owner the right call, or should Pi keep its in-run warming?
  • Session id format. Pi's session ids pass the proxy's id check ([A-Za-z0-9._:-]{1,128}). This depends on Pi keeping that format.

🤖 Generated with Claude Code

Add pi-package/, a Pi package with one extension and a controller
script. /context-guru setup asks once, starts the proxy as a user
service (launchd or systemd --user), then sets
providers.anthropic.baseUrl in ~/.pi/agent/models.json. Nothing runs
per session start or per request: the extension only tags routed
requests with Pi's session id, stops Pi's own cache warming while the
proxy keep-alive is on, and posts session end and compaction signals.

Uninstall and a reset hatch outside the package undo only what
context-guru wrote. Presets and cache strategies match the Claude
Code plugin, and a test keeps the strategies in step.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 29c71687b1f6 blocking

Verdict: blocking

Findings

  1. pi-package/extensions/context-guru.ts:210 — a bare /context-guru never runs status; it reports an unknown subcommand.
    • What fails: the user types /context-guru with no arguments. The code means to default to status, but "".trim().split(/\s+/) returns [""], not []. Destructuring defaults apply only to undefined, so sub is the empty string. The switch falls to default and the user sees Unknown subcommand . Use one of: setup, status, … (with an empty name).
    • Proof: node -e 'const [sub="status"]="".split(/\s+/); console.log(sub)' prints an empty line. args.trim() of "" is "", and "".split(/\s+/) is [""].
    • Fix: filter empties before the switch, for example const [sub = "status", value = ""] = args.trim().split(/\s+/).filter(Boolean);. Add a test for the dispatch of a bare command; the current tests cover only the pure helpers, which is why this slipped through.

Non-blocking

  • pi-package/extensions/context-guru.ts:231 — update --install re-downloads the release binary with the 180 s default timeout, while setup allows 300 s for the same download (line 147). On a slow link the update dies where setup succeeds.
  • pi-package/scripts/pi_plugin.py:404 — the port in install.json is sticky forever. If another app takes the recorded port while the proxy is down, setup and configure fail at the health check on every retry, and the only recovery is uninstall.
  • pi-package/extensions/context-guru.ts:184-192 — configure and update restart the proxy without any confirmation when Pi has no UI. The README says "Restarts the proxy after a yes". setup handles print mode correctly ("no answer is a no"); these two commands do not.
  • pi-package/scripts/pi_plugin.py:119-123 — facts(detail=error) prints str(exception) on one key=value line. An exception whose text contains a newline breaks the one-fact-per-line protocol, and parseFacts in the extension then shows fragments.
  • pi-package/scripts/reset.sh:38-40 — read -r answer under set -e exits the script silently when stdin is closed (no result= line, exit status 1). The README tells the user to run it from a normal shell, so this is an edge case.

What I checked

  • Read the full diff (10 new files, 1514 lines) and the code around each assumption the package makes about the rest of the repo.
  • Proxy surface, all confirmed present and matching: POST /anthropic/v1/messages, GET /healthz, POST /signal, POST /tool-defer/probe, GET /stats (returns preset and requests), flags --listen, --config, --dashboard, --dashboard-db, --version (prints context-guru-proxy <version> (commit …), so out[1] is the version).
  • Config rendering: preset: off/conservative/medium/high/xhigh/ultrahigh all exist in config/config.go; every cache: key written by render_config exists in the strict loader; preset: off parses as the string "off" (existing tests use it); an absent cache: section leaves the keep-alive off, so strategy none is correct.
  • Signals: endKind maps to prompt_input_exit, clear, resume, other — all in the proxy's closed kind set; SessionStart compact matches. Local mode needs no auth token on /signal (tenants == nil resolves the static tenant). The extension's 128-char id regex matches session.MaxExplicitLen; the same id is used for the header and the signal, so both scope to the same key.
  • Strategy parity: the four names and the seven cache keys match context-guru-plugin/scripts/settings.py (the Python test enforces this at run time).
  • Release download: archive name and checksums.txt match .goreleaser.yaml (context-guru_<version>_<os>_<arch>.tar.gz, sha256, wrapped in a directory — the extractor matches on basename, so that is handled); the checksum is enforced before install; the tar member is read with extractfile, so no path traversal; minimum version 0.4.0 is below the current release line (v0.6.8).
  • Ordering and undo: proxy starts before the route is written and the route is removed before the service stops; models_route.restore puts back only keys that still hold our URL; a foreign baseUrl makes setup refuse.
  • Rules: the PR adds no component, states its data dependence (metadata only) and its behavior change (none for existing users); pi-package does not import proxy or any library package, so the host boundary holds.
  • Tests read in full: Python tests sandbox HOME/XDG state and mock the service; the Go wrapper skips cleanly when python3 or Node 22.18+ is missing.
  • Not verifiable in this repo: the Pi SDK surface (before_provider_headers, cache_warming_decision, session_compact, session_shutdown reasons, pi.exec, ctx.ui.*, registerCommand) and Pi's baseUrl semantics. No Pi package or types are vendored. The PR body discloses that no real Pi session was tested end to end; keep that gap in mind when the follow-up OpenAI route lands.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 29c71687b1f6 approve

Verdict: approve

The PR adds pi-package/: a Pi extension, a Python controller, a models.json route helper,
a reset hatch, and a Go test wrapper. I read all 10 files in full. I found no defect I can
prove. The package's claims against the proxy all check out (details below).

Findings

None.

Non-blocking

  • pi-package/extensions/context-guru.ts:110 — the bare /context-guru default is dead code.
    args.trim().split(/\s+/) on "" yields [""], so sub is "", not undefined. The
    sub = "status" default never applies. A bare /context-guru prints
    "Unknown subcommand . Use one of: …" instead of running status. Cosmetic: the message
    lists the valid subcommands. Fix: const [sub0] = …; const sub = sub0 || "status".
  • pi-package/extensions/context-guru.ts:353 — print mode runs uninstall, update and
    configure with no confirmation.
    setup refuses in print mode ("no answer is a no"),
    but uninstall removes the route, the service and the binary without a yes. Typing the
    command is intent, so this is a design choice — but it is the opposite of setup's rule.
    Say so in the README, or gate the destructive commands the same way.
  • pi-package/scripts/models_route.py:541 — the backup file is dead. install writes
    models.json.before-context-guru when no routing record exists. No code reads it;
    restore works from routing.json. Remove it, or say in the README that it is for humans.
  • Python and TypeScript disagree on a trailing slash. The TS isRouted strips trailing
    slashes (context-guru.ts:167); the Python is_routed/conflicts compare the exact
    string (models_route.py:505). A user who adds a trailing slash to our URL reads as
    "not routed" in /context-guru status and as a foreign conflict on re-setup.
  • pi-package/scripts/pi_plugin.py:722 — healthy trusts any 200 from /healthz.
    Setup reuses the recorded port without re-checking that our service owns it. A local
    process that squats the port and answers /healthz with 200 would receive Pi's traffic.
    Low probability, bounded by the port range walk at first install.
  • The event wiring has no test. The Node tests cover only the pure helpers
    (isRouted, parseFacts, endKind, readInstall). The header stamping, the signal
    posts, and the cache-warming stop are untested. The Pi API
    (@earendil-works/pi-coding-agent) is not vendored, so I could not check event names,
    ctx shapes, or whether pi.exec rejects on a non-zero exit. The code is internally
    consistent (it treats non-zero exits as non-throwing), but only a real Pi install proves it.
  • docs/data-dependence.md was not touched. The keep-alive row says "the plugin turns
    keep-alive on by default". The Pi package also defaults to a spending strategy (auto).
    The README's Data section discloses what the package sends, so this is a wording gap,
    not a data gap.

What I checked

  • Every changed line of all 10 new files, plus the code around each claim they make.
  • Proxy endpoints the package calls, all present:
    • POST /signal (proxy/proxy.go:593): the closed event set accepts SessionEnd /
      SessionStart; endKind's kinds (prompt_input_exit, clear, resume, other) and
      the compact mapping are all in lifecycleKinds (proxy/clientsignal.go:112).
      Single-tenant mode authenticates the loopback caller with no token
      (proxy/tenancy.go:764).
    • POST /tool-defer/probe returns 202 (proxy/proxy.go:595, clientsignal.go:281).
    • GET /healthz (proxy.go:596), GET /stats (serves preset and requests,
      metrics/metrics.go:660,712), /dashboard/ (proxy.go:615).
    • x-context-guru-session is read on every non-Bob route (proxy/proxy.go:743), and the
      extension's id regex matches the proxy's safeExplicit charset, so the header session
      and the signal session key the same id.
  • Config the package writes: every cache: key in STRATEGIES exists in
    config/config.go, and the values pass its validation (3540 < 3600, pings within caps).
    The strategy dicts match context-guru-plugin/scripts/settings.py line for line
    (DEFAULT_STRATEGY is "auto", so the parity test's key lookup works; settings.py has
    a __main__ guard, so runpy.run_path is safe). The presets
    off…ultrahigh all exist in config.go. Keep-alive is off by default in the loader, so
    strategy none (no cache: keys) really is off.
  • Release download: the archive name matches .goreleaser.yaml
    (context-guru_<version>_<os>_<arch>.tar.gz, checksums.txt, wrapped directory); the
    checksum parser handles both spacing forms; extraction is by member name into a temp file,
    so a crafted archive path cannot traverse.
  • The Go wrapper is safe for CI: test-only packages already exist
    (context-guru-plugin/, internal/boundary/), so go build ./... / go vet ./... in
    ci.yaml are unaffected. The Python tests sandbox HOME, XDG_* and
    PI_CODING_AGENT_DIR, start no service, and open no network; the Node test skips on Node
    older than 22.18.
  • models.json handling: a foreign baseUrl is refused before any write (both in plan
    and after consent); broken JSON raises instead of being overwritten; restore puts back
    only keys that still hold our URL, keeps user-added keys, and removes only entries the
    installer created; re-install keeps the first record's previous.
  • CLI flags --listen, --config, --dashboard, --dashboard-db exist in
    cmd/context-guru-proxy/main.go.
  • Unverified, by nature: the Pi extension API itself (event names, ctx shapes,
    pi.exec semantics, ui.confirm/select). It is a peer dependency that is not in this
    repo. See the non-blocking note above.

Round-1 review fixes for the Pi package:
- A bare /context-guru now runs status. An empty split gave an empty
  subcommand, which fell through to "Unknown subcommand".
- configure, update and uninstall need an interactive yes, like setup.
  Print mode changes nothing.
- update --install gets the same 300 s timeout as setup.
- setup takes a new port when another program holds the recorded one.
- A fact never spans two lines, so an error text cannot fake a fact.
- models.json URLs compare without a trailing slash, as in the extension.
- The reset hatch reads a closed stdin as a no instead of exiting.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1: replies to both reviews

Fixed in 18b60bc9. Tests: 20 Python (was 16), 5 Node (was 4), tsc --noEmit clean against Pi 1.5.0.

Reviewer 1, blocking

  1. Bare /context-guru reports an unknown subcommand. Fixed. The new parseArgs filters empty words, so a bare command runs status. A test covers "", spaces, one word and two words.

Non-blocking (both reviewers)

  • update --install timeout 180 s. Fixed: 300 s, the same as setup.
  • Recorded port is sticky. Fixed: choose_port keeps the recorded port only while our proxy answers there or nothing holds it. Otherwise setup takes a new port. Tested.
  • configure, update, uninstall change things in print mode with no yes. Fixed: all three use one agree() gate, the same rule as setup. In print mode they change nothing. The README now says so.
  • A newline in an error breaks one fact per line. Fixed: facts() joins lines. Tested.
  • reset.sh exits on closed stdin. Fixed: closed stdin is a no and prints result=cancelled. Tested.
  • Trailing slash: Python and TypeScript disagree. Fixed: Python compares without trailing slashes too. Tested.
  • Backup file is dead. Kept on purpose: it is a copy for a person. A code comment and the README say that uninstall works from the routing record only.
  • healthy trusts any 200 on /healthz. Not changed. The port is chosen by binding it free at first install, and it is kept only while our service holds it or it is free. A program that squats a loopback port and answers /healthz is outside this package's threat model, the same as for the Claude Code and Codex plugins.
  • No test of the event wiring. Not changed in this PR. The Pi API is a peer dependency. I type-checked the extension against @earendil-works/pi-coding-agent 1.5.0 (strict), so the event names and ctx shapes match the real types. An end-to-end run in Pi is still open, as the PR body says.
  • docs/data-dependence.md not touched. Not changed. The keep-alive row describes the feature for every host, and its data dependence does not change. The package README states that the default strategy auto spends quota.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 18b60bc9fea0 approve

Verdict: approve

Findings

None. My round-1 finding is fixed, and the fix commit introduces no new defect.

Status of earlier findings

  • Mine, blocking (bare /context-guru ran "Unknown subcommand"): fixed. parseArgs (extensions/context-guru.ts:61-64) filters empty words before the destructuring default, so "" and " " give status. A Node test covers "", spaces, one word and two words. I re-checked the logic: "".split(/\s+/) is [""], .filter(Boolean) gives [], and the default now applies.
  • Non-blocking, update --install 180 s timeout: fixed. Now 300 s, the same as setup (extensions/context-guru.ts:244).
  • Non-blocking, sticky recorded port: fixed. choose_port (scripts/pi_plugin.py:152-158) keeps the recorded port only while our proxy answers there or nothing holds it. Tested with mocks. configure still uses the recorded port as it is, but setup now recovers with a new port, so uninstall is no longer the only way out.
  • Non-blocking, no yes in print mode for configure/update/uninstall: fixed. One agree() gate (extensions/context-guru.ts:190-199), the same rule as setup. Print mode changes nothing and says why. The README states the rule.
  • Non-blocking, a newline in a fact value: fixed. facts() joins lines and strips \r (scripts/pi_plugin.py:123). Tested, including a value that starts with result= — it can no longer fake a fact.
  • Non-blocking, reset.sh exits on closed stdin: fixed. read -r answer || true with answer= preset (scripts/reset.sh:39-40). Closed stdin now prints result=cancelled and exits 0. Tested with stdin=DEVNULL.
  • Reviewer 2, trailing-slash disagreement between Python and TypeScript: fixed. _same (scripts/models_route.py:54-56) strips trailing slashes in is_routed, conflicts and restore. Tested.
  • Reviewer 2, dead backup file: rejected, and I accept the reason. The copy is for a person; uninstall works from the routing record. A code comment and the README now say so.
  • Reviewer 2, healthy trusts any 200: rejected, and I accept the reason. A program that squats a loopback port and answers /healthz with 200 is on the user's own machine, the same threat model as the Claude Code and Codex plugins. choose_port also narrows the window: the port is kept only while our proxy or no one holds it.
  • Reviewer 2, no test of the event wiring: rejected, and I accept the reason. The Pi SDK is a peer dependency, not in this repo. The extension is type-checked against @earendil-works/pi-coding-agent 1.5.0, and the PR body keeps the missing end-to-end run disclosed.
  • Reviewer 2, docs/data-dependence.md not touched: rejected, and I accept the reason. The keep-alive row describes the feature for every host. The PR states its data dependence, and the package README says the default strategy spends quota.

Non-blocking

  • choose_port tests the port with a bind and start_service binds it again a moment later. Another program could take the port in between. The window is milliseconds and the failure path is the health check, so I see no action needed.

What I checked

  • Last review: round 1, 29c7168, 2026-11-09T16:03:37Z.
  • New commits read: 1 — 18b60bc9 "fix(pi): run status on a bare command and ask before every change".
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-1 review (7 non-blocking notes, each checked against the code above); the author's reply comment (each fix verified in the diff, each rejection checked for a sound reason); the fix commit (every changed hunk read, plus the code around it).
  • The fix diff touches 7 files, all inside pi-package/. I read each hunk and the surrounding code: parseArgs and agree in the extension, choose_port and the one-line facts change in the controller, _same in the route helper and its three call sites, the reset.sh stdin fix, the README additions, and the 5 new tests (4 Python, 1 Node).
  • Re-ran the round-1 reasoning on the changed paths: the consent rules now cover all four writing commands; configure still restarts only after a yes; the trailing-slash change cannot make a foreign gateway read as ours, because _same compares the full URL, not just the host.
  • The rejections I accepted: each names a reason I could check against the code (backup-file comment at scripts/models_route.py:107, README note; loopback threat model; SDK peer dependency; host-generic data-dependence row).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 18b60bc9fea0 approve

Verdict: approve

The fix commit 18b60bc9 addresses every round-1 finding. I checked each fix in the
code. All are correct. Two rejections have reasons I accept. One new rough edge came out
of the port fix; it is non-blocking.

Round-1 findings

Mine (all non-blocking):

  1. Bare /context-guru default is dead code — fixed. parseArgs
    (context-guru.ts:61) filters empty words, so "" gives [] and the sub = "status"
    default applies. Tested for "", spaces, one word, two words.
  2. Print mode runs uninstall/update/configure with no yes — fixed. One agree()
    gate (context-guru.ts:190) covers all three, with setup's rule: no dialog, no change.
    The README says so.
  3. Backup file is dead — rejected, with a reason I accept. It is a copy for a person.
    A code comment (models_route.py:107) and the README now say uninstall uses the routing
    record only.
  4. Trailing-slash disagreement — fixed. _same (models_route.py:54) compares without
    trailing slashes in is_routed, conflicts and restore. Tested.
  5. healthy trusts any 200 on /healthz — rejected, with a reason I accept. A program
    that can bind a loopback port on the user's machine is already local code; the proxy and
    the other client plugins have the same exposure. choose_port also narrows the window:
    the port is kept only while our proxy answers it or nothing holds it.
  6. No test of the event wiring — deferred, reasonably. The Pi API is a peer dependency.
    The author type-checked the extension strict against Pi 1.5.0. An end-to-end run in Pi
    stays open, as the PR body discloses.
  7. docs/data-dependence.md untouched — rejected, with a reason I accept. The
    keep-alive row describes the feature's data dependence, which does not change. The
    package README states that the default strategy auto spends quota.

Reviewer 1's blocking finding (bare command): fixed, see item 1. I checked the fix
myself: "".trim().split(/\s+/).filter(Boolean) is [], so both destructuring defaults
apply, and the handler now calls parseArgs.

Reviewer 1's non-blocking items: the timeout (fixed to 300 s), the sticky port
(fixed for setup, see below), print mode (fixed), the newline in facts (fixed),
reset.sh closed stdin (fixed). All verified in the diff.

Findings

None.

Non-blocking

  • pi-package/scripts/pi_plugin.py:423 — the port fix creates a refuse-on-our-own-route
    corner.
    When another program holds the recorded port, choose_port returns a new port.
    conflicts then sees our own old-port URL in models.json as foreign, and setup refuses
    with base_url_already_set (pi_plugin.py:447). The user must remove the baseUrl by
    hand, or run the reset hatch — which the refusal message does not name. Reachable only
    when a squatter sits on the exact recorded port, and the old behavior (health-check
    failure on every retry) was no better. Fix later: when the clash URL is one of our own
    recorded base_urls, treat it as ours and rewrite the route to the new port.
  • configure still uses the recorded port (pi_plugin.py unchanged). On a squatted
    port it reports not_applied and changes nothing. This is fail-safe, and configure
    cannot move the port without rewriting the models.json route, which is setup's job.
    Recovery is the reset hatch plus setup.

What I checked

  • Last review: round 1, 29c7168, 2026-11-09T16:05:06Z.
  • New commits read: 1 — 18b60bc9 "fix(pi): run status on a bare command and ask before
    every change". Full diff read (git diff 29c71687..HEAD), plus each changed file around
    the changes: setup/choose_port/facts in pi_plugin.py, _same in
    models_route.py, parseArgs/agree in context-guru.ts, reset.sh, both test
    files, the README.
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt,
    .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review: reviewer 1's round-1 review (16:03:37Z, read now; its
    blocking finding overlaps my bare-command note), the author's reply comment (16:07:07Z),
    and the fix commit (16:06:33Z). Each checked above.
  • Each fix traced in the code:
    • parseArgs: filter(Boolean) before destructuring; bare and space-only input reach
      the status default; the handler uses it; tests cover four input shapes.
    • agree: all three write paths gate on it; print mode prints "needs an interactive
      yes, so nothing changed" and returns false; setup keeps its own print-mode refusal.
    • facts: " ".join(str(value).split("\n")).replace("\r", " ") keeps one fact per
      line, so an error text can no longer forge a result= fact; test asserts the exact
      output.
    • choose_port: keeps the recorded port when healthy or free; takes a new one
      otherwise; tested with mocks for all three branches.
    • _same: applied to is_routed, conflicts and restore; None still means absent,
      so an unset baseUrl is not "ours"; test covers the trailing-slash case.
    • reset.sh: read -r answer || true with answer= preset; closed stdin yields
      result=cancelled, exit 0; tested with stdin=DEVNULL.
    • update --install timeout is now 300 s, the same as setup.
  • New tests checked for CI safety: all still run in the sandboxed temp HOME, mock the
    service, and open no network.

@amiddavid
amiddavid merged commit c550c7c into main Nov 9, 2026
10 of 11 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 9, 2026
amiddavid added a commit that referenced this pull request Nov 10, 2026
Pi's setup now routes the openai provider to /openai/v1, as well as
anthropic. A route URL counts as ours only for the provider it was
written for. An Anthropic-only install gets OpenAI only after the user
runs /context-guru setup again and says yes.

Behavior change: Pi users of this package (new in #977). With cache
strategy auto, 1-ping or 2-ping, the proxy also pings OpenAI GPT-5.6+
sessions after 28 minutes idle. This uses the user's OpenAI quota;
the consent question says so. Off: /context-guru cache-strategy none
stops all pings; /context-guru uninstall removes both routes.
Owner's yes, 2026-11-10, in the integrator session: "yes".

Data dependence: metadata only, as #977 (session id header, session
end and compaction events).

Reviews: 2 offload reviews (GLM), round 2, both approve at 33633c0.
After #977 merged, the branch was rebased onto main as 95a72a7; the
#982-only patch is unchanged (patch-id 860502d6b543 before and after).
DCO: both commits are signed off. The DCO app still reported the old
stacked range; the owner approved merging past that stale result,
2026-11-10, in the integrator session ("yes u may").

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant