tmustier/pi-for-excel
À propos
Complément expérimental d’agent pour le volet latéral d’Excel. Compatible avec plusieurs modèles et basé sur Pi.
IA et apprentissage automatiqueWhat you can do
- get_workbook_overview - Structural blueprint — sheets, headers, named ranges, tables, charts, pivots
- read_range - Read cells in compact (markdown), CSV, or detailed (with formatting) mode
- write_cells - Write values/formulas with overwrite protection and auto-verification
- fill_formula - AutoFill a formula across a range (relative refs adjust automatically)
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +2
- in 15 days
- +3
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalPi for Excel
English | 简体中文
Open-source, multi-model AI sidebar add-in for Microsoft Excel. Powered by Pi.
Pi for Excel is an AI agent that lives inside Excel. It reads your workbook, makes changes, and does research — using any model you choose. Bring your own API key or OAuth login for Anthropic, OpenAI, Google Gemini, or GitHub Copilot.
Features
Core spreadsheet tools — 16 built-in tools that the AI can call to interact with your workbook:
| Tool | What it does |
|---|---|
get_workbook_overview |
Structural blueprint — sheets, headers, named ranges, tables, charts, pivots |
read_range |
Read cells in compact (markdown), CSV, or detailed (with formatting) mode |
write_cells |
Write values/formulas with overwrite protection and auto-verification |
fill_formula |
AutoFill a formula across a range (relative refs adjust automatically) |
search_workbook |
Find text, values, or formula references across all sheets |
modify_structure |
Insert/delete rows/columns, add/rename/delete/hide sheets |
format_cells |
Apply formatting — fonts, colors, number formats, borders, named styles |
conditional_format |
Add or clear conditional formatting rules |
trace_dependencies |
Trace formula lineage (precedents upstream or dependents downstream) |
explain_formula |
Plain-language formula explanation with cited cell references |
view_settings |
Gridlines, headings, freeze panes, tab color, sheet visibility |
comments |
Read, add, update, reply, resolve/reopen cell comments |
workbook_history |
List/restore automatic in-between-saves backups for workbook mutations |
instructions |
Persistent user-level and workbook-level guidance for the AI |
conventions |
Configurable formatting defaults (currency, negatives, zeros, decimal places) |
skills |
Bundled Agent Skills for task-specific workflows |
Multi-model support — use any supported provider; switch models mid-conversation:
- Anthropic (Claude) — API key or OAuth
- OpenAI / OpenAI Codex — API key
- Google Gemini — API key
- GitHub Copilot — OAuth
- Custom OpenAI-compatible gateways — configure endpoint + model + API key in
/settings
Session management — multiple session tabs per workbook, auto-save/restore, session history, /resume to pick up where you left off.
Auto-context injection — the AI automatically receives the workbook blueprint, your current selection, and recent cell changes before every turn. No need to manually describe what you're looking at.
Workbook recovery — automatic checkpoints before every mutation. One-click revert from the sidebar if something goes wrong.
Formatting conventions — define your house style once (currency symbol, negative style, decimal places) and the AI follows it automatically.
Slash commands — /model, /login, /settings, /rules, /extensions, /tools, /export, /compact, /new, /resume, /history, /shortcuts, and more.
Extensions — install sidebar extensions (mini-apps) from chat. The AI can generate and install extension code directly via the extensions_manager tool. Extensions run in an iframe sandbox by default.
Integrations — opt-in external tool integrations:
- Web Search (Jina default, Serper/Tavily/Brave) +
fetch_page— find and read external sources without leaving Excel - MCP Gateway — connect to user-configured MCP servers for custom tool access
Bridge + advanced controls (managed via /experimental):
- Tmux bridge settings — configure bridge URL/token and run health checks
- Python / LibreOffice bridge settings — configure bridge URL/token
- Advanced extension controls — remote URL opt-in, sandbox rollback, and Widget API v2
Files workspace — shared artifact storage across sessions (built-in docs under assistant-docs/ are read-only). Pi's writes and deletes ask for approval in Confirm mode, and in Auto mode whenever they would overwrite or delete a file Pi did not create in this chat.
(Web Search + MCP are managed in /tools, or /extensions → Connections.)
Install
- Download
manifest.prod.xml - Add it to Excel — see install guide for step-by-step instructions (macOS + Windows)
- Click Open Pi in the ribbon
- Connect a provider (API key or OAuth), or configure a custom OpenAI-compatible gateway in
/settings - Start chatting — try
What sheets do I have?orSummarize my current selection
Developer Quick Start
Prerequisites
- Node.js ≥ 22.19.0 (or ≥24), matching
package.jsonengines - mkcert — for local HTTPS (required by Office.js)
Setup
git clone https://github.com/tmustier/pi-for-excel.git
cd pi-for-excel
npm install
# Generate local HTTPS certs (Office.js requires HTTPS)
mkcert -install # one-time CA setup
mkcert localhost # creates localhost.pem + localhost-key.pem
mv localhost-key.pem key.pem
mv localhost.pem cert.pem
Run
npm run dev # Vite dev server on https://localhost:3141
Note: the dev port is
3141(π) — deliberately off the crowded:3000. If you sideloaded a manifest before the move from:3000, re-copymanifest.xmlinto Excel'sweffolder and fully restart Excel.
Optional: prefer a stable named URL (
https://pi-excel.localhost, no mkcert, no fixed port)? See docs/portless.md for the opt-in portless flow.
Then sideload the dev manifest into Excel:
macOS (Microsoft docs):
cp manifest.xml ~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/
Then open Excel → Insert → My Add-ins → Pi for Excel.
Windows (Microsoft docs):
Windows desktop Excel can't upload a manifest directly — it installs from a trusted shared-folder catalog:
- Share a local folder (folder Properties → Sharing → Share) and note its network path.
- In Excel: File → Options → Trust Center → Trust Center Settings → Trusted Add-in Catalogs → add the network path as Catalog Url, tick Show in Menu, restart Excel.
- Copy
manifest.xmlinto the shared folder. - Home → Add-ins → Advanced → SHARED FOLDER → Pi for Excel.
Excel on the web (Microsoft docs):
Home → Add-ins → More Settings → Upload My Add-in → select manifest.xml.
The dev manifest points to https://localhost:3141. The production manifest (manifest.prod.xml) points to the hosted Vercel deployment.
Useful commands
| Command | Description |
|---|---|
npm run dev |
Start Vite dev server (port 3141, HTTPS) |
npm run dev:portless |
Opt-in: dev server behind portless — docs/portless.md |
npm run build |
Production build → dist/ |
npm run check |
Lint + typecheck + CSS theme checks |
npm run typecheck |
TypeScript type checking only |
npm run lint |
ESLint |
npm run test:models |
Unit tests — model ordering |
npm run test:context |
Unit tests — tools, context, sessions, extensions, integrations |
npm run test:security |
Security policy tests — proxy, CORS, sandbox, OAuth |
npm run proxy:https |
CORS proxy for OAuth flows (default https://localhost:3003; random port only if 3003 is busy and no healthy default proxy is already running) |
npm run validate |
Validate the Office add-in manifest |
CORS proxy
Some OAuth token endpoints are blocked by CORS inside Office webviews. If OAuth login fails:
- User setup command:
npx pi-for-excel-proxy(orcurl -fsSL https://piforexcel.com/proxy | shif Node is missing) - Dev/source setup command:
npm run proxy:https(defaults tohttps://localhost:3003; if 3003 is busy for another service, copy the random port printed in the terminal) - In Pi →
/settings→ Proxy → enable and set the printed URL - Retry login
API-key auth generally works without the proxy.
Local bridges (Python / tmux)
Use one-command local bridge helpers:
- Python / LibreOffice bridge:
npx pi-for-excel-python-bridge(default URLhttps://localhost:3340, real mode) - tmux bridge:
npx pi-for-excel-tmux-bridge(default URLhttps://localhost:3341, real mode)
In Pi, these localhost bridge URLs are used by default. Configure /experimental ...-bridge-url only when you want a non-default URL.
Real-mode prerequisites:
python3must be installed forpython_run/python_transform_range- LibreOffice (
sofficeorlibreoffice) is required forlibreoffice_convert tmuxis required for the tmux bridge real mode
Optional assisted install (macOS/Homebrew):
npx pi-for-excel-python-bridge --install-missingnpx pi-for-excel-tmux-bridge --install-missing
Manual macOS install:
brew install tmux
brew install --cask libreoffice
To force safe simulated mode instead:
PYTHON_BRIDGE_MODE=stub npx pi-for-excel-python-bridgeTMUX_BRIDGE_MODE=stub npx pi-for-excel-tmux-bridge
Source-checkout alternatives remain available via npm run python:bridge:https and npm run tmux:bridge:https.
Architecture
Pi for Excel is a single-page Office taskpane add-in built with:
- Vite — dev server + production bundler
- Lit — web components for the sidebar UI
- pi-agent-core — agent runtime (tool loop, streaming, state management)
- pi-ai — multi-provider LLM abstraction (Anthropic, OpenAI, Google, GitHub Copilot)
- pi-web-ui — shared web UI components (message rendering, storage, settings dialogs)
- Office.js — Excel workbook API
Source layout
src/
├── taskpane/ # App init, session management, tab layout, context injection
├── taskpane.html # Entry HTML (loads Office.js + taskpane.ts)
├── taskpane.ts # Entry script
├── boot.ts # Pre-mount setup (CSS, patches)
├── tools/ # 16 core tools + feature-flagged tools + registry
├── prompt/ # System prompt builder
├── context/ # Workbook blueprint cache, selection/change tracking
├── auth/ # OAuth providers, API proxy, credential restore
├── models/ # Model ordering + version scoring
├── ui/ # Sidebar component, tool renderers, theme CSS
│ └── theme/ # Design tokens, component styles (DM Sans + teal-green palette)
├── commands/ # Slash command registry + builtins
├── extensions/ # Extension store, sandbox runtime, permissions
├── integrations/ # Web Search + MCP Gateway integration catalog
├── skills/ # Agent Skills catalog + runtime loader
├── experiments/ # Feature flag definitions + toggle logic
├── workbook/ # Workbook identity (hashed), session association, coordinator
├── conventions/ # Formatting defaults (currency, negatives, dp)
├── rules/ # Persistent user/workbook rules store
├── compaction/ # Auto-compaction thresholds + logic
├── storage/ # IndexedDB initialization
├── files/ # Files workspace (Pi writes/deletes are approval-gated)
├── audit/ # Workbook change audit log
├── messages/ # Message conversion helpers
├── debug/ # Debug mode utilities
├── stubs/ # Browser stubs for CSP/Node-only deps (Ajv, Bedrock, stream, etc.)
├── compat/ # Compatibility patches (Lit, marked, model selector)
└── utils/ # Shared helpers (HTML escape, type guards, errors)
scripts/ # Dev helpers — CORS proxy, tmux/python bridges, manifest gen
pkg/proxy/ # Publishable npm CLI package: `pi-for-excel-proxy`
pkg/python-bridge/ # Publishable npm CLI package: `pi-for-excel-python-bridge`
pkg/tmux-bridge/ # Publishable npm CLI package: `pi-for-excel-tmux-bridge`
tests/ # Unit + security tests (~50 test files)
docs/ # Current docs (install/deploy/features/policy) + archive/ for historical plans
skills/ # Bundled Agent Skill definitions (web-search, mcp-gateway, tmux-bridge, python-bridge)
public/assets/ # Add-in icons (16/32/80/128px)
Key design patterns
- Tool registry as single source of truth —
src/tools/registry.tsdefines all core tool names and construction. UI renderers, input humanizers, and prompt docs all derive from it. - Workbook coordinator — serializes mutating tool calls per-workbook to prevent concurrent writes from multiple session tabs.
- Auto-context — the workbook blueprint, selection state, and recent changes are injected before each user message so the AI always knows what it's looking at.
- Execution policy — each tool is classified as
read/noneormutate/content|structureto determine locking and checkpoint behavior. - Recovery checkpoints — mutations automatically snapshot affected cells before writing, enabling one-click rollback.
- Extension sandbox — untrusted extensions (inline code, remote URLs) run in an iframe sandbox by default; built-in/local modules run on the host.
Deployment
The production build is a static site deployed to Vercel. See docs/deploy-vercel.md for maintainer setup.
Users install by downloading manifest.prod.xml and uploading it in Excel — the manifest points to the hosted Vercel URL. Updates are automatic (close and reopen the taskpane).
Documentation
| Doc | Description |
|---|---|
| docs/install.md | Non-technical install guide |
| docs/deploy-vercel.md | Hosted deployment (Vercel) |
| docs/extensions.md | Extension authoring guide |
| docs/integrations-external-tools.md | Web Search + MCP integration setup |
| docs/security-threat-model.md | Security threat model |
| docs/compaction.md | Session compaction (/compact) |
| src/tools/DECISIONS.md | Tool behavior decisions log |
| src/ui/README.md | UI architecture + Tailwind v4 notes |
Credits
- Pi by @badlogic (Mario Zechner) — the agent framework powering this project. Pi for Excel uses pi-agent-core, pi-ai, and pi-web-ui for the agent loop, LLM abstraction, and session storage.
- whimsical.ts by @mitsuhiko (Armin Ronacher) — the rotating "Working…" messages are adapted from his Pi extension, rewritten for a spreadsheet/finance audience.
License
MIT © Thomas Mustier
Explorer des projets similaires
Chargement…