An AI-powered Excel agent for investment banking and hedge fund workflows. Generates formula-driven, professionally formatted spreadsheet operations from natural language.
User <-> Excel Add-in (Office.js + React + TypeScript) <-> FastAPI Backend <-> ReAct Planner/Tools <-> LLM (LM Studio/Ollama/Claude/GPT-4o)
cd backend
pip install -r requirements.txt
cp ../.env.example ../.env # Edit with your API keys
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload# Install: https://ollama.com/download
ollama pull llama3.1:8b
ollama servecd plugin
npm install
npm run dev # Starts HTTPS server on port 3443
npm run generate:api-types
npm run verify # Typecheck + production build
npm run sideload # Sideloads into Excel.\scripts\verify.ps1
.\scripts\verify-full-stack.ps1 # slower V7 default-readiness gatecp .env.example .env # Edit with your API keys
docker-compose up -dexcel-ai-plugin/
├── backend/ # Python FastAPI backend
│ ├── agents/ # ReAct loop, tools, rules, prompts, and template routing
│ ├── api/routes/ # Trust-first task, session, document, benchmark, template, and enterprise APIs
│ ├── benchmarks/ # Production benchmark suite and deterministic quality gate
│ ├── excel/ # Formula, formatting, chart, citation, diff, and fingerprint helpers
│ ├── llm/ # Multi-provider LLM layer
│ │ ├── router.py # Smart routing (local → cloud)
│ │ └── providers/ # Ollama, Anthropic, OpenAI
│ ├── models/ # Typed workbook operation contracts
│ ├── services/ # Operation planning and validation services
│ ├── storage/ # SQLite migrations and storage protocols
│ ├── config.py # Configuration, paths, providers, and enterprise flags
│ └── main.py # FastAPI app assembly and legacy compatibility tail
├── plugin/ # Office.js Excel Plugin
│ ├── manifest.xml # Add-in manifest
│ └── src/taskpane/ # React trust workspace, API client, and Excel adapter
└── docker-compose.yml # Full stack orchestration
- Blue font: Hard-coded inputs/assumptions
- Black font: Formulas
- Green font: Cross-sheet links
- Parentheses: Negative numbers
- Double border: Totals
- Calibri 10pt: Standard font
POST /api/v1/tasks/plancreates a typed, validated workbook operation plan.POST /api/v1/tasks/applyapproves a plan, records a durable rollback snapshot, and issues a durable two-phase apply token before Excel writes.POST /api/v1/tasks/apply/resultverifies the apply token, records the Office.js apply outcome, and marks the plan applied, failed, or abandoned.POST /api/v1/tasks/askanswers workbook questions without mutations.GET /api/v1/tasks/plans/{plan_id}/v2returns a strictOperationPlanV2contract view of an existing durable plan.POST /api/v1/contracts/operation-plan-v2/validatevalidates the discriminated V2 operation plan schema without touching Excel.GET /api/v1/sessions/{id}/timelinereturns messages, plans, snapshots, and audit events.GET /api/v1/sessions/{id}/citationsreturns source/document/formula citations for the session.GET /api/v1/sessions/{id}/audit/exportexports audit events as CSV.POST /api/v1/sessions/{id}/rollbackreturns restore operations for a saved snapshot.- Frontend API contracts are generated from FastAPI OpenAPI into
plugin/src/taskpane/api-types.ts; do not edit that file by hand.
- V7 stays experimental: defaults remain on
PLAN_ENGINE_VERSION=v2, and live workbook mutation still goes only through Office.js after explicit approval. POST /api/v1/experiments/v7/reviewsbuilds a read-onlyV7WorkbookReviewcombining truth model V5, formula graph V5, simulation V6, source evidence V3, registry coverage, confidence gaps, checkpoints, repair candidates, and next actions.GET /api/v1/experiments/v7/reviews/{review_id}reloads the durable SQLite artifact;/exportreturns a JSON audit artifact.GET /api/v1/experiments/v7/readiness,POST /api/v1/experiments/v7/readiness/run, andGET /api/v1/experiments/v7/readiness/historyexpose the persistedV7DefaultReadinessReportand compact history used to decide whether V7 is blocked, warning, or ready for a later default switch.GET /api/v1/experiments/v7/replays,POST /api/v1/experiments/v7/replays/evaluate,POST /api/v1/experiments/v7/replays/capture,GET /api/v1/experiments/v7/replays/baselines, andPOST /api/v1/experiments/v7/replays/baselinesexpose anonymized local replay artifacts, deterministic drift evaluation, privacy-checked local capture, and pinned local replay baselines. Capture stores schema versions, operation types, counts, gate statuses, checkpoint counts, rollback availability, and stable hashes; payloads containing workbook values, formulas, raw prompts, sheet text, or source content are rejected.GET /api/v1/experiments/v7/golden-casesandPOST /api/v1/experiments/v7/golden-cases/evaluateexpose the workbook fixture gate as golden-case evidence for truth, formula, simulation, rollback, and repair expectations.- The taskpane Settings drawer includes a persisted local
V7 local accuracy modetoggle and replay-capture controls. When the toggle is off, planning stays on the shipped V2 path; when on, V7 review, readiness, replay, simulation, and agent-run calls use the experimental surfaces while writes remain checkpointed Office.js handoffs. - The taskpane command palette includes a read-only V7 workbench across Understand, Trace, Simulate, Repair, and Audit plus readiness history, replay baselines, golden cases, retry/resume, rollback, and audit commands without switching the default planner.
- The V7 registry now marks screenshot and sparkline operations as low-risk opt-in coverage with host-capability fallbacks; pivot mutations remain safely gated with explicit readiness reasons.
- Local verification entrypoints:
.\scripts\verify-full-stack.ps1python -m backend.benchmarks.local_accuracypython -m backend.benchmarks.local_replay --evaluatepython -m backend.benchmarks.v7_readinesspython -m backend.benchmarks.v7_golden_cases.\scripts\verify-local-accuracy.ps1.\scripts\verify-v7-default-prep.ps1cd plugin && npm run lintcd plugin && npm run test:office-mockcd plugin && npm run test:taskpane
- Runtime state lives under
data/and is ignored by git. - To back up local sessions, stop the backend and copy
data/sessions.dbplus any matchingsessions.db-wal/sessions.db-shmfiles to a secure backup location. - Avoid committing
.env, cache folders, generated frontenddist/, or local database exports. - Private local golden workbooks can live under
backend/benchmarks/fixtures/private/; that folder is ignored so power-user regression cases stay local.
- Source-backed modeling:
POST /api/v1/documents/upload,GET /api/v1/documents/{id}, andPOST /api/v1/documents/{id}/planpersist PDF/CSV/XLSX artifacts and create cited typed plans. - Benchmark gates:
POST /api/v1/benchmarks/run,GET /api/v1/benchmarks/runs,GET /api/v1/benchmarks/cases, andGET /api/v1/benchmarks/regression. Runtime benchmark history is stored under the managed data directory. - Enterprise controls:
/api/v1/enterprise/*exposes SQLite-backed users, API keys, teams, roles, SSO/provider/retention policies, and readiness summaries. - The React taskpane wires ask/preview/apply, audit/rollback, upload-to-plan, template forms, rules, benchmarks, settings, and formula trace. Google Sheets is intentionally out of scope.
python -m pytest backend\tests -qpython -m backend.benchmarks.local_accuracypython -m backend.benchmarks.local_replay --evaluatepython -m backend.benchmarks.v7_readinesspython -m backend.benchmarks.v7_golden_casespython -c "import asyncio, json; from backend.benchmarks import get_benchmark_runner, deterministic_benchmark_pipeline, evaluate_gates; run=asyncio.run(get_benchmark_runner().run_suite(pipeline_fn=deterministic_benchmark_pipeline)); gate=evaluate_gates(run); print(json.dumps({'run_id': run.run_id, 'score': run.overall_score, 'gate': gate['status']}, indent=2)); raise SystemExit(0 if gate['status']=='passed' else 1)"cd plugin && npm run verify && npm run lint && npm run test:office-mock && npm run test:taskpane && npm audit --audit-level=criticalcd workbook-worker && npm testpython -c "from backend.main import app; print(app.title)".\scripts\verify.ps1.\scripts\verify-v7-default-prep.ps1.\scripts\verify-full-stack.ps1