diff --git a/README.md b/README.md index e4acc5a..47b8966 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,41 @@ # Pi Extensions -Private workspace and public Git bundle for Pi extensions maintained by Iury -Souza. The root package is never published. It exposes one explicit Pi resource -catalog while each child package remains independently publishable as -`@iurysza/*`. +A working collection of extensions, skills, and themes for [Pi](https://pi.dev), +the terminal coding agent. These are focused tools rather than a single +all-or-nothing setup: install the packages that fit your workflow. -## Status +| Package | Description | +| --- | --- | +| [@iurysza/pi-ext](packages/pi-ext) | Command palette, review tooling, session workflows, TUI polish, and Pi integrations. | +| [@iurysza/pi-token-tank](packages/pi-token-tank) | Subscription quota gauges for OpenAI Codex, Kimi, GitHub Copilot, and Cursor. | +| [@iurysza/pi-agent-explorer](packages/pi-agent-explorer) | Read-only Neovim snapshot of Pi's loaded runtime. | +| [@iurysza/pi-context-audit](packages/pi-context-audit) | Inspect prompt, tool-schema, context, and MCP overhead. | +| [@iurysza/pi-tmux-title](packages/pi-tmux-title) | Keep Pi and tmux window titles aligned with the session. | +| [@iurysza/pi-secret-env](packages/pi-secret-env) | Load shared credentials while blocking and redacting secret access. | -All six packages are present. The three former standalone repositories retain -unsquashed subtree history; the three local extensions were copied from clean, -committed source files. Git installation remains unadvertised until isolated -installation validation is complete. +## Install -Packages: +Install any package with Pi: -- `@iurysza/pi-ext` — attributed fork of `tomsej/pi-ext` -- `@iurysza/pi-context-audit` -- `@iurysza/pi-agent-explorer` -- `@iurysza/pi-token-tank` -- `@iurysza/pi-tmux-title` -- `@iurysza/pi-secret-env` +```bash +pi install npm:@iurysza/pi-token-tank +``` -The root `pi.extensions`, `pi.skills`, and `pi.themes` fields deliberately list -the prefixed union of all child manifests. Pi does not recursively discover -workspace manifests. +Restart Pi or run `/reload` after installation. Each package README covers its +configuration and requirements. ## Development -```sh +```bash npm ci npm run check ``` -`check-catalog` validates the private root, child metadata, resource union, -source namespaces, paths, and the single-lockfile rule. `check-packs` performs a -read-only dry run of every publishable tarball and rejects development leakage. - -## Upstream synchronization - -The first `pi-ext` subtree import came from `iurysza/pi-ext`. Future source syncs -come from `tomsej/pi-ext`: - -```sh -scripts/sync-pi-ext.sh -``` - -The script must run from a clean repository root, pulls without `--squash`, and -then runs catalog, legal, install, typecheck, test, and pack checks. Merge -conflicts are deliberately left visible for human resolution. - -## Imported sources - -| Package | Source | Imported SHA | -| --- | --- | --- | -| `pi-ext` | `https://github.com/iurysza/pi-ext` `main` | `08d03577f0be043c1fc5f4bd169d8d9550b5a2b8` | -| `pi-agent-explorer` | `https://github.com/iurysza/pi-agent-explorer` `main` | `139de6ef2eccf900edef968d5fe156de1cd9e369` | -| `pi-token-tank` | `https://github.com/iurysza/pi-token-tank` `main` | `1f7b4977f3bae45272aba4a2d74aabdd889cee37` | - -Token Tank's recorded local source was clean at `70b6150`; GitHub `main` had two -new descendant commits. The newer `1f7b497` snapshot was explicitly approved -for import. - -The repositories were imported with `git subtree` without `--squash`. Never use -Git submodules. Future `pi-ext` source synchronization comes from -`https://github.com/tomsej/pi-ext`. - -## Extracted sources - -| Package | Source path | Source commit | -| --- | --- | --- | -| `pi-context-audit` | `agents/pi/agent/extensions/context-audit.ts` | `8651d8d73928f96e29d4618e3aace772aef5cbc6` | -| `pi-tmux-title` | `agents/pi/agent/extensions/pi-tmux-kebab-title.ts` | `466f46ae1834a0ad66c4909186494d31b9a8dbdd` | -| `pi-secret-env` | `agents/pi/agent/extensions/secret-env.ts` | `cd71561e8ae282c89c44ac1965e96a7cf5db0217` | - -The dirty, behind-remote `agents` repository was not modified. Original local -extensions and all old repositories remain available until migration parity is -proven. +The repository is an npm workspace. The root package is private; each package +under [`packages/`](packages) is independently publishable. -## Licensing and provenance +## License -The root [LICENSE](LICENSE) covers only Iury-owned packages. `packages/pi-ext` -is excluded from that ownership claim: it retains its own MIT license, component -licenses, and [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md) obligations. -See the root [third-party notices](THIRD_PARTY_NOTICES.md) for the boundary. +The root [MIT license](LICENSE) covers Iury-owned packages. `pi-ext` retains +its own [license](packages/pi-ext/LICENSE) and +[third-party notices](packages/pi-ext/THIRD_PARTY_NOTICES.md). \ No newline at end of file diff --git a/packages/pi-agent-explorer/README.md b/packages/pi-agent-explorer/README.md index 86200d9..7030e42 100644 --- a/packages/pi-agent-explorer/README.md +++ b/packages/pi-agent-explorer/README.md @@ -1,11 +1,13 @@ -# Pi Agent Explorer +# pi-agent-explorer -A [Pi package](https://pi.dev) that creates a read-only snapshot of the current Pi runtime: loaded skills, context files, extensions, tools, commands, session paths, and context usage. +Inspect what Pi actually loaded. Agent Explorer opens a read-only, timestamped +Neovim snapshot of the current runtime: extensions, skills, context files, +tools, commands, session paths, and context usage. ## Install ```bash -pi install git:github.com/iurysza/pi-agent-explorer +pi install npm:@iurysza/pi-agent-explorer ``` Restart Pi or run `/reload`, then run: @@ -14,22 +16,25 @@ Restart Pi or run `/reload`, then run: /agent-explorer ``` -## Launch behavior +## What opens -1. **Herdr 0.7.4+** — an 80% modal popup. The package links its tiny local Herdr plugin on first use. -2. **tmux** — a focused right-hand split. -3. **No multiplexer** — a new Ghostty window on macOS. +- **Herdr 0.7.4+** — an 80% modal; the package links its small Herdr plugin on + first use. +- **tmux** — a focused split to the right. +- **No multiplexer** — a new Ghostty window on macOS. -The explorer runs `nvim -R` on a timestamped snapshot under Pi's cache directory. Neo-tree is used when your Neovim setup opens it for directories; otherwise Neovim's directory browser is used. +The snapshot opens with `nvim -R` from Pi's cache directory. If your Neovim +configuration enables Neo-tree for directories, it appears there; otherwise +Neovim's built-in directory browser does. ## Requirements - Pi - Neovim -- Optional: Herdr 0.7.4+ for popups -- Optional: tmux for split fallback -- Ghostty on macOS for the no-multiplexer fallback +- Optional: Herdr 0.7.4+ for the modal +- Optional: tmux for the split fallback +- Ghostty on macOS when no multiplexer is active ## License -MIT +MIT \ No newline at end of file diff --git a/packages/pi-context-audit/README.md b/packages/pi-context-audit/README.md index 7b8edbf..1b3b45c 100644 --- a/packages/pi-context-audit/README.md +++ b/packages/pi-context-audit/README.md @@ -1,36 +1,43 @@ -# @iurysza/pi-context-audit +# pi-context-audit -Pi extension that measures the current system prompt, active and available tool -schemas, context files, skills, MCP cache, context usage, and the last captured -provider payload. +See where Pi's context goes. Context Audit measures the active system prompt, +tool schemas, context files, skills, MCP cache, context usage, and the last +captured provider payload. -Run: +## Install + +```bash +pi install npm:@iurysza/pi-context-audit +``` + +Restart Pi or run `/reload` after installation. + +## Run an audit ```text /context-audit [md|json] [open] [copy] ``` -Audits are written under Pi's agent cache directory. Markdown and JSON audit -generation are portable. The optional `open` and `copy` actions call macOS -`open` and `pbcopy`, respectively. +Audits are written to Pi's agent cache directory. `md` and `json` choose the +output format; `open` and `copy` use macOS `open` and `pbcopy` when available. -The extension records size metadata and serialized schemas; review generated -audits before sharing because provider payload summaries may describe the -current session. +## What it captures -## Development +- System prompt and context-file size +- Active and available tool schemas +- Skills, commands, and MCP cache metadata +- Context-window usage +- Size metadata for the latest captured provider payload -```sh -npm run check -npm pack --dry-run -``` +Audits contain serialized schemas and may summarize the current session. Review +them before sharing. -## Provenance +## Requirements -Extracted from -`agents/pi/agent/extensions/context-audit.ts` at source commit -`8651d8d73928f96e29d4618e3aace772aef5cbc6`. +- Pi +- Node.js 22.19 or newer +- macOS only for `open` and `copy` ## License -MIT +MIT \ No newline at end of file diff --git a/packages/pi-ext/README.md b/packages/pi-ext/README.md index 617819a..9f24d4c 100644 --- a/packages/pi-ext/README.md +++ b/packages/pi-ext/README.md @@ -1,196 +1,130 @@ -``` - ██▓███ ██▓ ▓█████ ▒██ ██▒▄▄▄█████▓ - ▓██░ ██▒▓██▒ ▓█ ▀ ▒▒ █ █ ▒░▓ ██▒ ▓▒ - ▓██░ ██▓▒▒██▒ ▄▄▄▄▄ ▒███ ░░ █ ░▒ ▓██░ ▒░ - ▒██▄█▓▒ ▒░██░ ░░░░░ ▒▓█ ▄ ░ █ █ ▒ ░ ▓██▓ ░ - ▒██▒ ░ ░░██░ ░▒████▒▒██▒ ▒██▒ ▒██▒ ░ - ▒▓▒░ ░ ░░▓░ ░░ ▒░ ░▒▒ ░ ░▓ ░ ▒ ░░ - ░▒ ░ ░▒░ ░ ░ ░░░ ░▒ ░ ░ - ░░ ░░ ░ ░ ░ ░ - ░ ░ ░ -``` - - -https://github.com/user-attachments/assets/d1e5f848-176f-43cb-85bb-3d518e5b0bdd - - +# pi-ext -A collection of extensions, skills, and themes for [Pi](https://github.com/badlogic/pi), the AI coding agent for the terminal. - -Extensions cover everything from UI polish (custom footer, tool pills, leader-key palette) to deep workflow tooling (semantic git review, session archiving, context handoff between sessions, cmux integration). The package is MIT licensed; derived components retain their original notices in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). - -This fork tracks [tomsej/pi-ext](https://github.com/tomsej/pi-ext) and adds: - -- Herdr, tmux, and cmux-aware handoff and split-fork behavior -- A standalone `/split-fork` command -- Restored bash output rendering in Tool Pills -- OpenSpec workflow output that follows the active session language instead of forcing Czech - -> *Leader key palette → fuzzy finder → semantic review → handoff to a fresh session* +A practical extension pack for [Pi](https://pi.dev): command palettes, code +review, session workflows, terminal integrations, compact UI, skills, and a +theme. ## Install ```bash -pi install git:github.com/iurysza/pi-ext@main +pi install npm:@iurysza/pi-ext ``` -Or using the full URL: - -```bash -pi install https://github.com/iurysza/pi-ext@main -``` +Restart Pi or run `/reload` after installation. -To install the full package but only load specific extensions or skills, use package filtering in your `settings.json`: +To load only selected resources, filter the package in `settings.json`: ```json { "packages": [ { - "source": "git:github.com/iurysza/pi-ext@main", - "extensions": ["extensions/leader-key"], - "skills": [] + "source": "npm:@iurysza/pi-ext", + "extensions": [ + "extensions/leader-key/index.ts", + "extensions/review/review.ts" + ], + "skills": ["skills/sem"] } ] } ``` -See [Pi Packages docs](https://github.com/badlogic/pi/blob/main/docs/packages.md) for more filtering options. - -Requires [Pi](https://github.com/badlogic/pi) v0.37.3+. +Omit a resource type to load all of it. Use an empty array to load none. ## Extensions -### [Leader Key](extensions/leader-key/) - -Press `Ctrl+X` to open a floating command palette — like Vim's which-key or Emacs' leader key. Actions are organized into single-character groups (`s` for Session, `m` for Model, `f` for Favourites, `t` for Thinking level, `l` for Labels, `c` for Spec — the OpenSpec explore/spec/apply/review/archive flow). Auto-discovers extension commands and merges them with built-in actions. In session actions, `Shift+key` runs the tab/window variant when available. - -Includes sub-modules: -- **Model Switcher** — searchable provider → model → thinking level picker -- **Favourite Models** — quick-switch to preset model+thinking combos via `favourite-models.json` -- **Thinking Picker** — adjust reasoning effort (off, minimal, low, medium, high, xhigh) -- **Session / Label Actions** — rename, archive, label, and jump between sessions - -#### OpenSpec workflow - -Press `Ctrl+X`, then `c` to open the Spec group: - -| Key | Action | Command | -|---|---|---| -| `e` | Explore before proposing | `/opsx-explore` | -| `s` | Create a proposal, specs, and tasks | `/opsx-propose` | -| `a` | Implement a change interactively | `/opsx-apply` | -| `r` | Run the multi-angle review taskflow | `/tf:openspec-review` | -| `x` | Sync specs and archive a change | `/opsx-archive` | - -OpenSpec prompts and skills are project-local. Initialize each project that uses the workflow: - -```bash -openspec init --tools pi -``` - -The review command also needs the taskflow engine and the bundled review flow: +| Extension | Description | +| --- | --- | +| [Leader Key](extensions/leader-key) | `Ctrl+X` command palette for sessions, models, thinking levels, labels, and extension commands. | +| [Code Review](extensions/review) | `/review` workflows for pull requests, branches, commits, and uncommitted changes. | +| [pi-sem](extensions/pi-sem) | Entity-aware Git diff, context, history, blame, and impact tools powered by `sem`. | +| [Pi Telescope](extensions/pi-telescope) | Native fuzzy finder for sessions, files, commands, and other providers. | +| [Custom Footer](extensions/custom-footer) | Compact status line with Git, token, context, timing, and model information. | +| [Tool Pills](extensions/tool-pills) | Compact tool labels, collapsible output, and highlighted write/edit diffs. | +| [Permissions](extensions/permissions) | Switchable `yolo`, `safe`, and `read-only` command policies. | +| [Session Query](extensions/session-query) | Ask focused questions about previous Pi session files. | +| [Session Store](extensions/session-store) | Search indexed session history with `/search`. | +| [Session Snap](extensions/session-snap) | Review, archive, restore, and remove old sessions. | +| [Handoff](extensions/handoff) | Transfer compacted context to a fresh Pi session. | +| [Split Fork](extensions/split-fork) | Fork the current session into a tmux, cmux, or Herdr split or tab. | +| [Ask User](extensions/ask-user-question) | Structured single- or multi-select questions with an interactive Pi UI. | +| [cmux](extensions/cmux) | Notifications, status, browser, and workspace integration for cmux. | +| [Superconductor](extensions/superconductor) | Worktree status and controls when Pi runs under Superconductor. | -```bash -pi install npm:pi-taskflow -npm --prefix ~/.pi/agent/git/github.com/iurysza/pi-ext run flows:install -``` - -Run `/reload` after setup. Explore follows the conversation language. Final review reports use the session language when available and default to English; paths, identifiers, commands, and `VERDICT:` remain unchanged. - -### [Custom Footer](extensions/custom-footer/) - -Replaces Pi's default footer with a compact powerline-style status bar: - -``` -~/project (main) │ ↑12k ↓8k $0.42 │ 42%/200k │ ◷ ended 3:59 pm · 1m 50s ago │ ⚡ claude-sonnet-4 • medium -``` - -Shows working directory, git branch, token usage, cost, context window utilization, live time since the last response ended, and active model — all in a single line. - -### [Tool Pills](extensions/tool-pills/) - -Compact colored pill labels for built-in tools (`ls`, `read`, `find`, `grep`, `bash`) with collapsed output, plus Shiki-powered syntax-highlighted diffs for `write` and `edit`. Makes long tool outputs scannable without losing detail on demand. - -### [Code Review](extensions/review/) +### Leader Key -`/review` command with multiple modes: review a GitHub PR (checks it out locally), diff against a base branch, review uncommitted changes, review a specific commit, or provide custom review instructions. Supports project-specific `REVIEW_GUIDELINES.md`. +Press `Ctrl+X` to open the palette. Actions are grouped by single-character +keys and include model switching, favourite models, thinking level, session +operations, labels, extension commands, and workflow shortcuts. -When `pi-sem` is also loaded, `/review` nudges the agent toward a semantic workflow: -- `sem_diff` for a one-shot overview of changed entities -- `sem_impact` for blast radius / affected tests on risky entities -- `sem_context` for focused understanding of suspicious functions or classes -- raw `git diff` / `read` for final line-level evidence +Favourite model presets live in +`extensions/leader-key/favourite-models.json`. Optional display roles live in +`extensions/leader-key/model-nicknames.json`. -Derived from [mitsuhiko/agent-stuff](https://github.com/mitsuhiko/agent-stuff) (Apache 2.0). +### Permissions -### [pi-sem](extensions/pi-sem/) +Use `/mode` to switch policy: -Semantic git tooling powered by [sem](https://github.com/Ataraxy-Labs/sem). Exposes entity-aware tools — `sem_diff`, `sem_impact`, `sem_context`, `sem_log`, `sem_entities`, `sem_blame`, and `sem_eval` — so the agent can reason about functions, classes, and config properties instead of raw line hunks. +- `yolo` allows every command. +- `safe` applies rules and asks about unknown shell commands. +- `read-only` blocks repository and home-directory writes. -Includes a local evaluator to compare `sem diff` vs `git diff` on the same selection: +Rules merge from project `.agents/permissions.json`, global +`~/.pi/agent/permissions.json`, and built-ins. -```bash -npm run sem:evaluate -- --staged -npm run sem:evaluate -- --from origin/main --to HEAD -``` - -### [Pi-Telescope](extensions/pi-telescope/) - -Native TUI fuzzy finder, inspired by telescope.nvim and [Television](https://github.com/alexpasmantier/television). Fuzzy search with pattern modifiers (`'exact`, `^prefix`, `suffix$`, `!negate`), multi-select, provider switching, preview toggle, frecency-aware sorting, and provider-specific actions. Bound to `Ctrl+Space` by default. - -### [Session Snap](extensions/session-snap/) - -Session archiver and cleaner. `/snap` scans all sessions, classifies them (delete trivial ones, archive old ones, keep active ones), and lets you review before executing. `/archive` browses archived sessions with search, restore, and permanent delete. +### Review and semantic tools -### [Session Query](extensions/session-query/) +`/review` can inspect a GitHub pull request, compare against a base branch, +review uncommitted changes, inspect one commit, or follow custom instructions. +Projects can add `REVIEW_GUIDELINES.md`. -Gives the model a tool to query previous pi sessions for context, decisions, or code changes. Uses an uncapped VCC summary (~9K tokens) by default, with optional `detailed: true` mode (~80K tokens) for queries that need exact file contents or tool output. Works with the handoff extension to let a new session look up details from its parent. +When `pi-sem` is loaded, review agents can use: -### [Handoff](extensions/handoff/) +- `sem_diff` for changed entities; +- `sem_impact` for dependents and affected tests; +- `sem_context` for focused function or class context; +- `sem_log`, `sem_entities`, and `sem_blame` for history and ownership; and +- `sem_eval` to compare semantic and raw Git diff coverage. -`/handoff [--tab] ` transfers context to a fresh pi session in a tmux/cmux split by default, or a new tab/window with `--tab`. Uses pi-vcc's algorithmic compaction (no LLM calls) to build a summary, plus algorithmic extraction of git state, working files, and language detection. Includes current tasks from pi-tasks. The new session starts with the summary + goal as its initial prompt. +The optional `@ataraxy-labs/sem` dependency installs automatically when the +platform supports it. You can also install `sem` with Homebrew or Cargo. -### [Permissions](extensions/permissions/) +### Session workflows -Three-mode permission system: `yolo` (everything allowed), `safe` (rule-based checks, asks for unknown bash commands), `read-only` (no repo/home writes, built-in edits restricted to `/tmp`, bash restricted to safe read-only commands). `/mode [yolo|safe|read-only]` to switch. Rules merge project (`.agents/permissions.json`) → global (`~/.pi/agent/permissions.json`) → built-ins. +- `/snap` reviews old sessions before archiving or deleting them. +- `/archive` browses archived sessions for restore or permanent removal. +- `/handoff [--tab] ` starts a fresh session with compacted context. +- `/split-fork [--tab]` forks into Herdr, tmux, or cmux. +- `/search` searches the local session index. -### [cmux](extensions/cmux/) - -Native integration with [cmux](https://github.com/badlogic/cmux). Context-aware notifications via the cmux socket API, sidebar status pills (model, state, thinking, tokens), and custom tools for the model (browser, workspace, notify). `/split-fork [--tab]` works in tmux or cmux; other cmux features stay silent when not running inside cmux. - -### [Superconductor](extensions/superconductor/) - -Native integration with [Superconductor](https://superconductor.dev) via the `sc` CLI. Footer pill with the Superconductor-owned target branch and diff size, a `superconductor_worktree` tool for the model (status, diff, target branch, list/create worktrees), and commands (`/sc-fork`, `/sc-worktree`). Silent no-op when not running inside Superconductor. - -### [Ask User Question](extensions/ask-user-question/) - -Registers an `ask_user_question` tool the model uses to ask 1–4 structured clarifying questions (with 2–4 options each) instead of asking in plain text. Interactive UI with optional multi-select and short header labels for a tab bar. +Multiplexer integrations stay quiet when their host application is absent. ## Skills | Skill | Description | -|-------|-------------| -| [commit](skills/commit/) | Conventional Commits-style `git commit` — infers type, scope, and summary from the diff | -| [github](skills/github/) | Recipes for the `gh` CLI — PR checks, CI runs, issue queries, JSON output | -| [sem](skills/sem/) | Entity-aware change analysis workflow — prefer `sem_context` and `sem_impact`, use `sem_diff` selectively for summaries and reviews | -| [session-query](skills/session-query/) | Guide for querying past pi sessions via the `session-query` tool | -| [visit-webpage](skills/visit-webpage/) | Fetch and extract content from a URL as markdown (via Jina Reader), or download images | -| [web-search](skills/web-search/) | Lightweight web search via the Jina Search API — no browser required | - -## Themes +| --- | --- | +| [commit](skills/commit) | Create concise Conventional Commit messages from the current diff. | +| [github](skills/github) | Work with issues, pull requests, and CI through `gh`. | +| [pr-review-comments](skills/pr-review-comments) | Triage and resolve pull-request review comments. | +| [sem](skills/sem) | Apply entity-aware context and impact analysis during code review. | +| [session-query](skills/session-query) | Recover decisions and details from previous Pi sessions. | +| [visit-webpage](skills/visit-webpage) | Extract readable Markdown or download an image from a URL. | +| [web-search](skills/web-search) | Search the web through Jina without opening a browser. | -| Theme | Description | -|-------|-------------| -| [catppuccin-mocha](themes/catppuccin-mocha.json) | Dark theme based on [Catppuccin Mocha](https://github.com/catppuccin/catppuccin) | +## Theme -## Configuration +[Catppuccin Mocha](themes/catppuccin-mocha.json) provides a dark Pi theme based +on the [Catppuccin](https://github.com/catppuccin/catppuccin) palette. -Most extensions work out of the box. Notable config: +## Requirements -- **Leader Key** — Scoped Models follows Pi's ordered `enabledModels`; optionally map exact entries to display roles in `extensions/leader-key/model-nicknames.json` -- **Permissions** — edit `~/.pi/agent/permissions.json` (global) or `.agents/permissions.json` (project) to add bash rules; use `/mode` to switch modes -- **pi-sem** — `npm install` should fetch the optional `@ataraxy-labs/sem` wrapper automatically; otherwise install `sem` globally with Homebrew or Cargo +- Pi +- Node.js 22.19 or newer +- Optional host tools only for their matching integrations: `gh`, `sem`, Herdr, + tmux, cmux, or Superconductor ## License -[MIT](LICENSE) © 2025 tomsej, © 2026 Iury Souza. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for component attribution. +MIT © 2025 tomsej, © 2026 Iury Souza. This package derives from +[tomsej/pi-ext](https://github.com/tomsej/pi-ext); component attribution remains +in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). \ No newline at end of file diff --git a/packages/pi-secret-env/README.md b/packages/pi-secret-env/README.md index ffe7739..824ebb2 100644 --- a/packages/pi-secret-env/README.md +++ b/packages/pi-secret-env/README.md @@ -1,47 +1,49 @@ -# @iurysza/pi-secret-env +# pi-secret-env -Pi extension that loads shared AI credentials from -`~/.config/ai/secrets.env` while preventing agents from reading the file or -printing loaded values. +Load shared credentials into Pi without handing the agent an easy way to read +or print them. Secret Env reads a local env file, injects its values into Pi and +user shell commands, then blocks direct access and redacts final tool output. -It: +## Install -- injects loaded values into Pi and user `!` / `!!` commands; -- blocks secret-file paths in shell and file-tool calls; -- blocks direct environment dumps such as `env`, `printenv`, `export -p`, and - `set`; -- redacts loaded values and `KEY=value` pairs from final text tool results. +```bash +pi install npm:@iurysza/pi-secret-env +``` + +Restart Pi or run `/reload` after installation. -Missing or unreadable env files are ignored so normal command execution remains -available. Protected path checks remain fail-closed. The package never ships an -env file or secret fixture. +## Setup -File format: +Create `~/.config/ai/secrets.env` with mode `600`: ```env -KEY=value -OTHER_KEY="quoted value" -# comments allowed +OPENAI_API_KEY="..." +OTHER_KEY=value +# comments are allowed ``` -Keep the real file mode at `600`. Final-result redaction cannot guarantee that a -streaming or partial renderer never briefly displays output, so do not ask tools -to print credentials. +The extension accepts normal `KEY=value` entries and quoted values. A missing +or unreadable file changes nothing: Pi continues normally. -## Development +## Protection -```sh -npm run check -npm pack --dry-run -``` +Secret Env: + +- blocks reads of the configured secret file through shell and file tools; +- blocks direct environment dumps such as `env`, `printenv`, `export -p`, and + `set`; +- redacts loaded values and `KEY=value` pairs from final text tool results; and +- makes loaded values available to Pi and user `!` or `!!` commands. -Tests use inline fake values only. +This is a guardrail, not a sandbox. Streaming or partial renderers can expose +output before final-result redaction runs. Never ask a tool to print a +credential, and do not put secrets in project files or command-line arguments. -## Provenance +## Requirements -Extracted from `agents/pi/agent/extensions/secret-env.ts` at source commit -`cd71561e8ae282c89c44ac1965e96a7cf5db0217`. +- Pi +- Node.js 22.19 or newer ## License -MIT +MIT \ No newline at end of file diff --git a/packages/pi-tmux-title/README.md b/packages/pi-tmux-title/README.md index dedb71b..d8747fa 100644 --- a/packages/pi-tmux-title/README.md +++ b/packages/pi-tmux-title/README.md @@ -1,28 +1,33 @@ -# @iurysza/pi-tmux-title +# pi-tmux-title -Pi extension that turns the session name or first user prompt into a compact -kebab-case title, updates Pi's terminal title, and keeps the current tmux window -name in sync. +Keep the Pi terminal title and current tmux window named after the session. +Titles come from the session name or first user prompt, normalized to a compact +kebab-case slug. -It requires tmux for window renaming. Outside tmux, the extension still updates -Pi's terminal title and tmux operations are a no-op. On shutdown it restores -tmux automatic window naming when running inside tmux. +## Install -Use `/retitle` to force synchronization after renaming a session. +```bash +pi install npm:@iurysza/pi-tmux-title +``` -## Development +Restart Pi or run `/reload` after installation. -```sh -npm run check -npm pack --dry-run -``` +## How it works + +- Updates Pi's terminal title when the session title changes. +- Renames the current tmux window when Pi runs inside tmux. +- Restores tmux automatic window naming when the session shuts down. +- Provides `/retitle` to synchronize after you rename a session. + +Outside tmux, the terminal title still updates and tmux operations are silent +no-ops. -## Provenance +## Requirements -Extracted from -`agents/pi/agent/extensions/pi-tmux-kebab-title.ts` at source commit -`466f46ae1834a0ad66c4909186494d31b9a8dbdd`. +- Pi +- Node.js 22.19 or newer +- tmux only for window renaming ## License -MIT +MIT \ No newline at end of file diff --git a/packages/pi-token-tank/README.md b/packages/pi-token-tank/README.md index 5b7d008..7d4d9e1 100644 --- a/packages/pi-token-tank/README.md +++ b/packages/pi-token-tank/README.md @@ -1,35 +1,19 @@ -

- Token Tank fuel gauge banner -

+# pi-token-tank -

pi-token-tank

- -

Your token mileage at a glance.

- -Provider-aware subscription quota status for Pi. It follows the active model and fetches that provider’s quota. +See your subscription mileage without leaving Pi. Token Tank follows the active +model and adds provider quota, usage pressure, and reset timing to the footer. ```text ▰▱▱▱ 24% ↻ 3h 25m ``` -## Supported providers - -| Active model provider | Subscription | Authentication | Quota windows | -| --- | --- | --- | --- | -| `openai`, `openai-codex` | OpenAI Codex | Pi `/login openai-codex` | 5 hour, weekly | -| `kimi-coding` | Kimi Coding | Pi `/login kimi-coding` or `KIMI_API_KEY` | 5 hour, weekly | -| `github-copilot` | GitHub Copilot | Pi `/login github-copilot` | Monthly AI credits/premium requests | -| `cursor` | Cursor | Registered Pi Cursor provider + `CURSOR_SESSION_TOKEN` | Billing-cycle total, Auto, API | - -Unsupported model providers produce no footer status. Cursor appears only when Pi reports a registered `cursor` provider or a Cursor model is active. - ## Install -```sh -pi install git:github.com/iurysza/pi-token-tank +```bash +pi install npm:@iurysouza/pi-token-tank ``` -Then authenticate the provider you use: +Authenticate the providers you use, then restart Pi or run `/reload`: ```text /login openai-codex @@ -37,81 +21,82 @@ Then authenticate the provider you use: /login github-copilot ``` -### Cursor setup - -Token Tank detects Cursor through Pi's public ModelRegistry. Install and configure a Pi extension that registers provider id `cursor`, such as `pi-cursor-sdk`; Token Tank does not depend on or import it. - -Cursor's SDK API key cannot read dashboard quota. For personal quota, copy the **value only** of the `WorkosCursorSessionToken` cookie from a signed-in `cursor.com` browser session and expose it to the process that launches Pi: - -```sh -read -rs CURSOR_SESSION_TOKEN -CURSOR_SESSION_TOKEN="$CURSOR_SESSION_TOKEN" pi -unset CURSOR_SESSION_TOKEN -``` +## Supported providers -The value is a sensitive, short-lived browser session credential. The shell variable is not broadly exported. Token Tank captures it when the extension registers, immediately removes it from Pi's `process.env` so tools do not inherit it, and keeps it only in process memory across extension reloads. It never discovers, refreshes, logs, or persists it. An expired value shows `—`, or a stale last-good result when one exists, until Pi restarts with a replacement. Do not put the value in project files or command-line arguments. +| Provider | Subscription | Quota | +| --- | --- | --- | +| OpenAI Codex | Pi `/login openai-codex` | 5-hour and weekly windows | +| Kimi Coding | Pi `/login kimi-coding` or `KIMI_API_KEY` | 5-hour and weekly windows | +| GitHub Copilot | Pi `/login github-copilot` | Monthly premium requests | +| Cursor | Registered Pi Cursor provider plus `CURSOR_SESSION_TOKEN` | Billing-cycle total, Auto, and API | -Reload Pi after installation or environment changes. +Unsupported providers produce no footer status. ## Footer modes -Minimal mode is the default and shows the provider’s primary window: +Minimal mode shows the active provider's primary window: ```text ▰▱▱▱ 24% ↻ 3h 25m ``` -Full mode adds the configured detail windows: +Full mode includes every available window: ```text 5h ▰▱▱▱ 24% ↻ 3h 25m · 7d ▰▱▱▱ 15% ↻ 4d 11h ``` -- Four gauge cells represent 25-point usage buckets. -- Percentage colors show urgency: green under 70%, yellow under 90%, red at 90%+. -- `~` after a percentage means the extension is showing stale last-good data. -- Reset countdowns show relative time (`3h 25m`, `4d 11h`, or `soon`). +| Command | Description | +| --- | --- | +| `/token-tank` | Refresh and show detailed quota for configured providers. | +| `/token-tank minimal` | Use the compact primary-window footer. | +| `/token-tank full` | Show every available quota window. | -## Commands +Four gauge cells represent 25-point usage buckets. Green is below 70%, yellow +is below 90%, and red is 90% or higher. `~` marks stale last-good data; `—` +means credentials are missing; `!` means a request failed without cached data. -| Command | Action | -| --- | --- | -| `/token-tank` | Toggle detailed quota data for every configured provider | -| `/token-tank minimal` | Use the compact footer with the primary quota window | -| `/token-tank full` | Use the bigger footer with every configured quota window | +The selected mode is stored in `pi-token-tank.json` under Pi's agent directory. +The file contains only the footer mode—never credentials or quota data. -The details widget keeps every configured provider on one width-aware line, including all available quota windows, so it stays below Pi's 10-line widget cap instead of dropping later providers. It also reminds you about `minimal` and `full`. +## Cursor setup -The selected mode is stored in `pi-token-tank.json` under Pi’s agent directory. The file contains only `{ "footerMode": "minimal" | "full" }`—never credentials or quota data. +Token Tank detects Cursor through Pi's public model registry. Install a Pi +extension that registers provider ID `cursor`; Token Tank does not import or +depend on that extension. -## Refresh and failure behavior +Cursor's normal API key cannot read dashboard quota. Start Pi with the value of +the `WorkosCursorSessionToken` cookie from a signed-in `cursor.com` session: -- Fetches the active provider on session start. -- Refreshes after turns and model switches when cached data is older than five minutes. -- Routes immediately when the active model changes. -- Opening `/token-tank` forces all registered providers to refresh independently. -- Keeps last-good data and marks it stale if a later request fails. -- Shows `—` when credentials are missing and `!` when a request fails without cached data. +```bash +read -rs CURSOR_SESSION_TOKEN +CURSOR_SESSION_TOKEN="$CURSOR_SESSION_TOKEN" pi +unset CURSOR_SESSION_TOKEN +``` -## Provider API notes +Treat this value as a sensitive browser credential. Do not store it in project +files or pass it as a command-line argument. Token Tank captures it during +extension registration, removes it from `process.env`, retains it only in +process memory, and never logs or persists it. -GitHub Copilot quota uses the read-only, undocumented `https://api.github.com/copilot_internal/user` endpoint. It supports GitHub.com, including Enterprise Cloud seats hosted on GitHub.com; custom GitHub Enterprise Server domains are rejected before any request. Token Tank reads Pi's stored GitHub OAuth token only in memory for that request. Tokens and raw responses are never logged, cached, or persisted. Normalized quota uses the existing in-memory five-minute/stale cache and is never persisted. The endpoint may change without notice. +## Refresh behavior -Cursor quota uses the read-only, undocumented `https://cursor.com/api/usage-summary` dashboard endpoint. Detection uses only Pi's public ModelRegistry (`cursor` registered or active); package/filesystem detection is never used. Authentication is explicit opt-in through `CURSOR_SESSION_TOKEN`; Token Tank does not inspect browser cookie stores, Cursor Desktop/Agent auth databases, or `pi-cursor-sdk` internals. The Pi Cursor API key and `pi-cursor-sdk-cursor-api-key-placeholder` are never treated as dashboard auth. +- Fetches the active provider at session start. +- Refreshes stale data after turns and model switches. +- Refreshes all configured providers when `/token-tank` opens. +- Preserves last-good data when a later request fails. +- Keeps normalized quota only in the process-memory cache. -The adapter prefers Cursor's own total plan percentage, then a finite plan ratio, Enterprise personal cap, or Enterprise pooled ratio. It does not infer quota from model calls. The session token is retained only in the non-environment process slot described above and is never logged or persisted. Raw responses are never logged, cached, or persisted; only normalized quota enters the existing process-memory five-minute/stale cache. The private endpoint may change without notice. +GitHub Copilot and Cursor quota depend on read-only undocumented endpoints. +Those endpoints can change without notice. Raw responses, tokens, and quota +snapshots are never logged or persisted. -## Development +## Requirements -```sh -npm install -npm run check -npm test -npm pack --dry-run -``` +- Pi +- Node.js 22.19 or newer +- Provider authentication for each quota source -## Troubleshooting +## License -- `—`: authenticate the active model provider; for Cursor, refresh `CURSOR_SESSION_TOKEN`. -- `!`: verify credentials and network access. -- Missing footer segment with a custom footer: the custom `ctx.ui.setFooter()` implementation must render extension statuses. `/token-tank` remains available. +MIT \ No newline at end of file