feat(stdlib): add file I/O and jq-filter commands#12
Open
sfo2001 wants to merge 3 commits intoopenclaw:mainfrom
Open
feat(stdlib): add file I/O and jq-filter commands#12sfo2001 wants to merge 3 commits intoopenclaw:mainfrom
sfo2001 wants to merge 3 commits intoopenclaw:mainfrom
Conversation
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>
76caa30 to
2e6230f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 beyondmap.file.read,file.write, andjq-filterfill these gaps: pipelines can ingest local datasets, persist intermediate results, and apply arbitrary jq expressionswithout leaving the pipeline or spawning ad-hoc shell commands.
Summary
file.readcommand: reads files into the pipeline with auto-detection of JSON, JSONL, and plain text formatsfile.writecommand: writes pipeline items to disk as JSON, JSONL, or text; supports tee passthrough for downstream stagesjq-filtercommand: applies jq expressions to each pipeline item, with--rawflag for plain string outputfile.read;file.writecreates parent directories by default (--mkdir)Changes
src/commands/stdlib/file_read.ts,file_write.ts,jq_filter.tssrc/commands/registry.ts(+3 registrations)src/cli.ts(minor)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 buildpassespnpm lintpasses (0 warnings)node --test dist/test/file_read.test.js-- 12 testsnode --test dist/test/file_write.test.js-- 10 testsnode --test dist/test/jq_filter.test.js-- 10 testsjqon PATH for jq-filter testsUse of AI