Skip to content

feat: add spreadsheet computation and analysis #782

Description

@avoidwork

Summary

Add spreadsheet computation and analysis tools — running calculations, generating spreadsheets with formulas, data analysis (pivot, filter, aggregate), and CSV import/export as a standalone capability.

Motivation

The existing XLSX tool is read-only extraction. There is no capability for running calculations on data, generating new spreadsheets with formulas, performing data analysis (pivot tables, filtering, aggregation), or CSV import/export as a standalone tool. In office workflows, spreadsheet computation is fundamental — users need to ask the agent to "calculate the average of column B," "create a pivot table by region," or "export this data as CSV." Currently the agent must fall back to shell commands or manual data handling, which is fragile and loses formula fidelity.

Proposed Solution

Create a spreadsheet skill that provides:

  • Compute: Run calculations on data (sum, average, count, min, max, custom formulas)
  • Generate: Create new spreadsheets with formulas, formatting, and multiple sheets
  • Analyze: Pivot tables, filtering, aggregation, statistical operations
  • CSV import/export: Read CSV files, write CSV files, convert between formats
  • Modify existing: Open an existing XLSX, apply transformations, save back with formulas preserved
  • Output formats: XLSX (with formulas), CSV, JSON

Alternatives Considered

  • Shell-based tools (awk, python scripts): fragile, no formula preservation, requires user-installed dependencies.
  • Read-only XLSX extraction: insufficient for any computation workflow.
  • Web-based spreadsheet service: adds infrastructure complexity for a local-first tool.

OpenSpec Note

This project uses OpenSpec for feature development. If this request is approved, I will:

  1. Run /opsx:propose to generate a full proposal with specs and tasks
  2. Iterate on the design before any code is written
  3. Follow the task-driven implementation workflow

Additional Context

This should integrate with the document creation gap (#778) — e.g., generating a spreadsheet and then embedding it in a DOCX report. The existing xlsx.js read tool (src/tools/fileExtract/xlsx.js) would serve as the input layer for this tool.

Audit Findings (for Issue #782)

  • src/tools/fileExtract/xlsx.js — Existing XLSX read tool (xlsxExtract). This is the input layer; the new spreadsheet tool would accept the same file paths and parse the same ZIP structure, then apply computations.
  • src/tools/fileExtract/xlsxParser.js — XLSX-to-markdown parser; the new tool would need a complementary parser that preserves cell formulas and types (not just markdown rendering).
  • src/tools/fileExtract/xlsxJson.js — XLSX-to-JSON converter; useful as an intermediate format for the computation tool.
  • src/tools/fileExtract/zipExtractor.js — Shared ZIP extraction; the new tool would need the inverse (ZIP packing) to generate .xlsx files.
  • src/tools/fileExtract/formatValidator.js — Shared validation; reusable for input file validation.
  • src/tools/index.js — Tools are registered here with TOOL_PERMISSIONS and TOOL_CLASSIFICATIONS. Spreadsheet computation tools would need filesystem:read, filesystem:write, and potentially network:outbound (for formula libraries).
  • src/tools/fileExtract/docx.js — Cross-reference: the output of spreadsheet computation could be embedded in DOCX reports via the document creation tool (feat: add document creation/writing capability #778).
  • Dependency note — Formula-preserving XLSX generation requires a library like exceljs, xlsx (SheetJS), or xlsxwriter (Python). CSV handling requires csv-parse/csv-stringify or a similar library. Pivot table logic would need to be implemented from scratch or adapted from a library like lodash/groupby.
  • Integration point — The existing xlsx read tool's output format (markdown tables or JSON) should be the canonical input for the computation tool to minimize format conversion overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions