Skip to content

Commit e09a43e

Browse files
mimedingMichael Meding
authored andcommitted
feat(documents): agent tools read_workbook / read_workbook_cell / write_workbook
Exposes the typed Workbook surface to folder-mode agents. Stacks on top of the XLSX read (osaurus-ai#929) + write (osaurus-ai#936) PRs and completes the stage-4 round-trip goal: an agent can now ingest a spreadsheet, reason about cells and formulas in their native types, and emit a modified workbook — all without the model having to handroll XML. - read_workbook: returns a compact JSON summary of every sheet (names, row counts, merged ranges, truncated cell sample). Capped at 200 cells per sheet so large workbooks don't blow the context window; agents drop to read_workbook_cell for specific values. - read_workbook_cell: single-cell lookup by (path, sheet, A1 ref). Returns value, formula source, and type in a one-line JSON payload. - write_workbook: accepts a structured sheets array and emits the file via XLSXEmitter. Each cell carries its A1 ref, typed value, and optional formula; the schema enum guards against unknown types. write_workbook creates parent directories and surfaces a sheetCount / totalCells summary on success. - All three plug into FolderToolFactory.buildCoreTools alongside file_read / file_write, so they're registered the moment a working folder is selected and go away when it's cleared. - Tests: 8 tests covering sheet summary rendering, missing-file and out-of-root rejection, formula preservation on cell lookup, missing- sheet error, end-to-end write + re-parse fidelity, non-xlsx path refusal, and empty-sheets validation. Tests reuse the sample.xlsx fixture from the XLSX read PR.
1 parent 9549c12 commit e09a43e

3 files changed

Lines changed: 757 additions & 0 deletions

File tree

Packages/OsaurusCore/Folder/FolderTools.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,9 @@ enum FolderToolFactory {
12951295
FileDeleteTool(rootPath: rootPath),
12961296
DirCreateTool(rootPath: rootPath),
12971297
BatchTool(rootPath: rootPath),
1298+
ReadWorkbookTool(rootPath: rootPath),
1299+
ReadWorkbookCellTool(rootPath: rootPath),
1300+
WriteWorkbookTool(rootPath: rootPath),
12981301
]
12991302
}
13001303

0 commit comments

Comments
 (0)