pi-spreadsheet

Fast, zero-Python spreadsheet recalculation, inspection, and formula tracing for Pi, Pi Durable (Cloudflare), and code-mode agents — powered by Formualizer WASM.

Packages

Package details

extensionskill

Install pi-spreadsheet from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-spreadsheet
Package
pi-spreadsheet
Version
0.1.0
Published
Nov 21, 2026
Downloads
369/mo · 369/wk
Author
psu3d0
License
MIT OR Apache-2.0
Types
extension, skill
Size
170.2 KB
Dependencies
1 dependency · 3 peers
Pi manifest JSON
{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./extensions/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-spreadsheet

Fast, zero-Python spreadsheet recalculation, inspection, and formula dependency tracing for Pi, Pi Durable (Cloudflare Durable Objects), and code-mode TypeScript agents — powered by Formualizer 0.15.0 WASM.

  • Zero setup friction: No Python venv, no LibreOffice, no background daemon, no doctor --install. One command works everywhere.
  • Byte-preserving XLSX recalc: Uses Formualizer's xlsx-recalc pipeline to recompute and write cached formula values while leaving styles, charts, drawings, and unrelated XML untouched.
  • Code-mode native: First-class TypeScript SDK (openWorkbook, recalculateXlsx, inspectWorkbook, readRange, traceWorkbook) and structured JSON-schema tools (outputSchema / structuredOutputSchema) in the spreadsheet namespace for both Pi coding-agent and @earendil-works/pi-durable/codemode.
  • Cloudflare Workers / pi-durable native: Pure JS + static WebAssembly.Module entrypoints (pi-spreadsheet/durable, pi-spreadsheet/workers) with zero node:* imports and replay: "safe" read-only tools.
  • Optional native CLI acceleration: On local Node hosts, optionally dispatches large strict-profile file recalcs to @formualizer/cli when installed.

Install

Pi coding-agent

pi install npm:pi-spreadsheet

Or test directly from a local checkout:

pi -e .

This registers the four spreadsheet_* tools (spreadsheet_recalc, spreadsheet_inspect, spreadsheet_range, spreadsheet_trace), the /recalc slash command, the --spreadsheet-engine flag, and the bundled skills/spreadsheet/SKILL.md.

Pi Durable (Cloudflare Durable Objects + Code Mode)

import { DurableObject } from "cloudflare:workers";
import { createRegistry, Harness } from "@earendil-works/pi-durable";
import { createCodemodeExtension } from "@earendil-works/pi-durable/codemode";
import { createSpreadsheetExtension, formualizerWasmModule } from "pi-spreadsheet/workers";

const registry = createRegistry();
registry.install(
  createSpreadsheetExtension({
    wasmModule: formualizerWasmModule,
    // Defaults to api.env.readBinaryFile / writeFile, or pass custom R2 / DO SQLite hooks:
    // readBytes: async (path) => ...,
    // writeBytes: async (path, bytes) => ...,
  }),
);

Because createSpreadsheetExtension declares the spreadsheet ToolNamespace and structuredOutputSchema on every tool, pi-durable/codemode automatically exposes strongly typed tools.spreadsheet_recalc, tools.spreadsheet_inspect, tools.spreadsheet_range, and tools.spreadsheet_trace inside QuickJS code-mode sandboxes with deterministic replay.

Code-First TypeScript SDK (Node.js)

import { openWorkbook, recalculateXlsx, traceWorkbook } from "pi-spreadsheet";

// 1. Byte-preserving cache recalculation
const report = await recalculateXlsx("model.xlsx");
console.log(report.status, report.formulaCells, report.errorCells);

// 2. Dependency tracing
const graph = await traceWorkbook("model.xlsx", ["Summary!G12"], {
  direction: "precedents",
  maxDepth: 3,
});

// 3. In-memory what-if sweeps (auto-frees WASM via `using`)
using wb = await openWorkbook("model.xlsx");
for (const growth of [0.05, 0.1, 0.15]) {
  wb.setValue("Assumptions!B3", growth);
  console.log(growth, wb.evaluateCell("Summary!G12"));
}

Entrypoints

Import Environment Notes
pi-spreadsheet Node.js ≥ 20 Code-first SDK with automatic WASM loading (no flags/bundler) + optional @formualizer/cli acceleration
pi-spreadsheet/core Any JS runtime Pure bytes-in / bytes-out operations (recalculateXlsxBytes, openWorkbookBytes, etc.) — zero node:* imports
pi-spreadsheet/durable Pi Durable (Node or Cloudflare) createSpreadsheetExtension(options) — zero node:* imports
pi-spreadsheet/workers Cloudflare Workers / workerd Statically imports formualizer_wasm_bg.wasm + exports formualizerWasmModule & createSpreadsheetExtension
pi-spreadsheet/extension Pi coding-agent Extension factory (pi.registerTool, /recalc, resources_discover)

License

Dual-licensed under MIT OR Apache-2.0.