feat(jq): add input_filename / input_line_number / $ENV stubs#1490
Merged
feat(jq): add input_filename / input_line_number / $ENV stubs#1490
Conversation
Real jq exposes three IO-introspection facilities that jaq does not: `input_filename`, `input_line_number`, and the `$ENV` variable. LLM agents trained on stedfan/jq routinely emit calls to these and were hitting bashkit's compile error against ~800 chars of prepended stdlib, which they fail to recognise as "function missing" and re-run on a loop. Resolution: - Define `input_filename: null;` and `input_line_number: 0;` in the compatibility shim. Bashkit reads inputs as a single concatenated stream via shell redirection, so per-input file metadata is not tracked; null/0 mirror jq's documented "no input" defaults. - Bind `$ENV` as a public global variable with the same shell-env map the existing `env` filter exposes. `$ENV == env` now holds true. - Add a dedicated jq guide (`crates/bashkit/docs/jq.md`) listing the supported flags, variables, and notable shimmed/stubbed filters so downstream agents and humans have a documented surface to target. Closes #1486
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | e3623b5 | Commit Preview URL Branch Preview URL |
Apr 30 2026, 10:02 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Real jq exposes three IO-introspection facilities that jaq does not —
input_filename,input_line_number, and the$ENVvariable. LLM agents trained on stedfan/jq routinely emit calls to these and hit bashkit's compile error against ~800 chars of prepended stdlib, which they fail to recognise as "function missing" and re-run on a loop.Changes
input_filename: null;andinput_line_number: 0;added toJQ_COMPAT_DEFS. Bashkit reads inputs as a single concatenated stream via shell redirection, so per-input file metadata is not tracked;null/0mirror jq's documented "no input" defaults.$ENVregistered as a public global variable bound to the same shell-env map that the existingenvfilter exposes.$ENV == envnow holds true.crates/bashkit/docs/jq.md— new rustdoc guide listing supported flags, variables, and notable shimmed/stubbed filters so downstream agents and humans have a documented surface to target. Wired in asjq_guideinlib.rs.Tests
crates/bashkit/src/builtins/jq.rs:test_jq_input_filename_compiles_and_returns_nulltest_jq_input_filename_with_chained_filter_compiles— reproduces the LLM idiom from the bug reporttest_jq_input_line_number_compiles_and_returns_zerotest_jq_dollar_env_returns_shell_envtest_jq_dollar_env_matches_env_functioncrates/bashkit/tests/spec_cases/jq/jq.test.sh:jq_input_filename_returns_nulljq_input_line_number_returns_zerojq_dollar_env_returns_shell_envTest plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test -p bashkit --features "jq http_client"(lib + doctests, all 116 doctests + 2211 lib tests green)cargo test -p bashkit --features jq --test spec_tests(jq_spec_testsincludes new cases)Closes #1486
Generated by Claude Code