Skip to content

feat: decouple Pi plugin from @loreai/core via gateway /v1/compact endpoint#271

Merged
BYK merged 1 commit into
mainfrom
feat/pi-compaction-decoupling
May 12, 2026
Merged

feat: decouple Pi plugin from @loreai/core via gateway /v1/compact endpoint#271
BYK merged 1 commit into
mainfrom
feat/pi-compaction-decoupling

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 12, 2026

Summary

Removes Pi plugin's last direct @loreai/core dependency by routing compaction through a new gateway HTTP endpoint. Pi is now a pure HTTP client and works with remote/hosted gateways.

What changed

Gateway (3 files):

  • session.ts — Added x-lore-session-id to KNOWN_SESSION_HEADERS (Tier 1 identification). Pi requests now get stable session identification instead of falling through to Tier 3 fingerprint matching.
  • pipeline.ts — Extracted generateCompactionSummary() from handleCompaction (shared by both HTTP-intercepted compaction and the new endpoint). Added handleCompactEndpoint() for POST /v1/compact.
  • server.ts — Added POST /v1/compact route.

Pi plugin (4 files):

  • src/index.ts — Injects x-lore-session-id header via registerProvider({ headers }), re-registers on session_start with the real session ID. Replaced distillation.loadForSession() with HTTP fetch to /v1/compact. Graceful fallback on error (returns undefined → Pi uses default compaction). Replaced log import with console.
  • package.json — Removed @loreai/core from dependencies.
  • script/build.ts — Removed @loreai/core from esbuild externals.
  • tsconfig.json — Removed @loreai/core path alias.

Why

Pi's session_before_compact hook directly imported distillation from @loreai/core, requiring the full core + SQLite DB locally. This was the last blocker preventing Pi from working with a remote/hosted gateway.

Additional benefits

  • Better session identification: Pi now uses Tier 1 header-based identification (was Tier 3 fingerprint — fragile across compaction boundaries).
  • Better compaction quality: Upgraded from raw distillation dump to full LLM-synthesized summary (force-distill + knowledge injection + compact prompt).
  • Graceful degradation: If the endpoint returns an error (older gateway, network issue), Pi falls back to its default compaction — no broken sessions.

Verification

  • Typecheck: 4 packages pass
  • Tests: 1304 pass, 0 fail
  • Build: success

…dpoint

Pi's session_before_compact hook previously imported distillation from
@loreai/core directly, preventing it from working with a remote/hosted
gateway. This was the last direct core dependency.

Changes:
- Add x-lore-session-id to gateway KNOWN_SESSION_HEADERS (Tier 1)
- Pi injects session header via registerProvider({ headers }) and
  re-registers on session_start with the real session ID
- Extract generateCompactionSummary() from handleCompaction for reuse
- Add POST /v1/compact gateway endpoint that accepts project_path and
  previous_summary, resolves session from headers, and returns a full
  LLM-synthesized compaction summary
- Replace Pi's distillation.loadForSession() call with HTTP fetch to
  /v1/compact — graceful fallback on error
- Remove @loreai/core from Pi's dependencies, externals, and tsconfig

Pi is now a pure HTTP client. Compaction quality is upgraded from raw
distillation dump to full force-distill + knowledge + compact prompt.
@BYK BYK merged commit ec56ca9 into main May 12, 2026
7 checks passed
@BYK BYK deleted the feat/pi-compaction-decoupling branch May 12, 2026 21:26
This was referenced May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant