Skip to content

About

PI-Desktop plugin: see what each conversation actually sends to the model

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PI Context

A PI-Desktop plugin that shows what your conversations actually send to the model. It contributes two views:

View Placement / scope What it shows
Context Overview (上下文总览) left sidebar page, scope: "global" every conversation's context, token usage by day and by model, compactions, tools
Context (上下文) work panel tab, scope: "session" one conversation in depth: window usage, composition, per-request timeline, every request's content

Context Overview

Context view in a conversation

Browsing one request Dark theme

Context Overview (global)

  • Overview: conversations, running now, requests, turns, input / output tokens, cache hit rate, compactions (failures marked), active time, cost.
  • Token Usage: daily input, cache read and output for the last 7 / 14 / 30 days, from PI-Desktop's completed-turn records (usage.read), so it includes conversations from before the plugin was installed.
  • By Model: tokens per model in the same range.
  • Conversations: every watched conversation with project, model, used share of the window (colored by pressure, tick at the auto compaction point), a sparkline of its requests with compactions, requests, compactions and last update; filter, sort by recent / fullest / busiest, expand a row for the current request's composition and details.
  • Context Composition and Tool Calls across all conversations.

Context (per conversation)

  • Context Stats: turns, requests, messages, tool schemas, provider input / output tokens, cost, compactions, and calls per tool (failures marked).
  • Current Context: used tokens against the model's context window (the same figure the composer ring uses), the automatic compaction point and the part PI-Desktop keeps for the reply, split into system prompt, tool schemas, user, assistant, thinking, tool calls, tool results and images.
  • Token Stats: everything sent over the conversation by category.
  • Timing Stats: active time split into time to first token, generation, tool runs and the rest; output tokens per second.
  • Context Timeline: one bar per model request (total or change per category), turns, request duration and compactions; click a bar for the request brief.
  • Context Browser: every item of the selected request, filterable, with its text.

How it works

agent sidecar                       plugin main process              views
extension/index.mjs  ──writes──▶  <data>/sessions/<id>.json  ◀──reads── main.js ◀──invoke── context.js (one conversation)
 (before_provider_request,          <data>/sessions/<id>/req-N.json             ◀──invoke── overview.js (all conversations)
  message_end, tool_*, compact…)                                  pi.usage.listTurns ──▶ daily usage, models, titles

The agent extension only observes; it never changes a request. Token counts per category are estimates from the request body; the window usage and the session totals come from PI-Desktop and the provider.

Requirements

  • PI-Desktop with plugin view placement and scope support.
  • Permissions ui.view, agent.extension and usage.read. Agent extensions are trusted code, so the plugin is installed from a local folder (Settings → Plugins → install from folder), not from the marketplace.

Layout

Path Role
manifest.json Plugin manifest
extension/index.mjs Agent extension: records snapshots per conversation
extension/analyze.mjs Splits a provider request (OpenAI Chat/Responses, Anthropic, Google) into categories
main.js Plugin main process: serves snapshots and usage to the views
views/shared.js Formatting, icons and charts shared by both views
views/overview.{html,css,js} Global overview page
views/context.{html,css,js} Per-conversation work panel view (no build step; English and Chinese)

About

PI-Desktop plugin: see what each conversation actually sends to the model

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages