Skip to content

feat(stdlib): add file I/O and jq-filter commands#12

Open
sfo2001 wants to merge 3 commits intoopenclaw:mainfrom
sfo2001:feat/file-io-jq-filter
Open

feat(stdlib): add file I/O and jq-filter commands#12
sfo2001 wants to merge 3 commits intoopenclaw:mainfrom
sfo2001:feat/file-io-jq-filter

Conversation

@sfo2001
Copy link

@sfo2001 sfo2001 commented Feb 15, 2026

Motivation

Pipelines currently have no native way to read from or write to local files. Loading data requires shelling out (exec cat + manual parsing), and there is no structured JSON transformation primitive beyond map. file.read, file.write, and jq-filter fill these gaps: pipelines can ingest local datasets, persist intermediate results, and apply arbitrary jq expressions
without leaving the pipeline or spawning ad-hoc shell commands.

Summary

  • Add file.read command: reads files into the pipeline with auto-detection of JSON, JSONL, and plain text formats
  • Add file.write command: writes pipeline items to disk as JSON, JSONL, or text; supports tee passthrough for downstream stages
  • Add jq-filter command: applies jq expressions to each pipeline item, with --raw flag for plain string output
  • 50 MB file size guard on file.read; file.write creates parent directories by default (--mkdir)

Changes

Category Files
New commands src/commands/stdlib/file_read.ts, file_write.ts, jq_filter.ts
Registry src/commands/registry.ts (+3 registrations)
CLI src/cli.ts (minor)
Tests test/file_read.test.ts (12 tests), test/file_write.test.ts (10 tests), test/jq_filter.test.ts (10 tests)

+682 lines across 9 files.

Test plan

  • pnpm build passes
  • pnpm lint passes (0 warnings)
  • node --test dist/test/file_read.test.js -- 12 tests
  • node --test dist/test/file_write.test.js -- 10 tests
  • node --test dist/test/jq_filter.test.js -- 10 tests
  • Requires jq on PATH for jq-filter tests

Use of AI

sfo2001 and others added 3 commits February 15, 2026 11:29
Dead code left over from the clawd-only refactor in 5679042.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three new pipeline commands for file I/O and jq-based filtering:
- file.read: read files as JSON, JSONL, text, or auto-detect format
- file.write: write pipeline items to files with tee semantics
- jq-filter: apply jq expressions to each pipeline item

Includes format validation, 50 MB file size guard, Windows platform
skip for jq tests, and 30 tests covering all formats, edge cases,
named arg alternatives, and error paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Passes -r to jq and yields stdout lines as plain strings instead of
JSON-parsed values. Mirrors jq's native raw output mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sfo2001 sfo2001 force-pushed the feat/file-io-jq-filter branch from 76caa30 to 2e6230f Compare February 15, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant