Repository navigation
refactor(deps): remove jq dependency, route through airc_core.gistparse (closes #188) - #263
Conversation
…se (closes #188) jq was a hard dep that overlapped with python3 (the existing truth- layer dep since #152 Phase 0). Joel called this out 2026-04-28: 'why do we have so many damn dependencies now?' — the answer was 'we shouldn't.' ## What changed New `lib/airc_core/gistparse.py` (Python stdlib JSON only) with subcommands: - get <path> [--default ...] — extract dot/index path - get_json <path> — same but always emits compact JSON - get_first_of <p1> <p2> ... — fallback chain (jq's `a // b`) - pick_addr <scope> — first {addr|port} matching scope - pick_addr_first — first entry's {addr|port} - list_lan_entries — each LAN entry as compact JSON - gist_content — extract first file's .content from gh-api response ## Sites converted (27 jq calls → 0) airc top-level (host_address_set / peer_pick_address): 8 sites → gistparse cmd_connect.sh (gist envelope parsing): 19 sites → gistparse install.sh: dropped jq from prereq probe + winget package map cmd_doctor.sh: dropped jq from environment health checks ## Why the bash bare-grep fallback path is also gone The old code had a 'jq missing' fallback that grepped raw_content for '@.*@' lines and sed-stripped JSON syntax. With Python now mandatory and gistparse handling envelopes structurally, the fallback path's trigger condition is gone — but we kept it as a last-resort for truly malformed gist content (legacy raw-string envelopes from before the JSON envelope landed). ## Verification test/integration.sh tabs: 19/0 ✓ test/integration.sh queue: 7/0 ✓ test/integration.sh general_sidecar_default: 10/0 ✓ test/integration.sh room: 14/0 ✓ Standalone gistparse smoke: get / get_json / get_first_of / pick_addr / list_lan_entries / gist_content all return expected values per jq -r equivalents. ## Effect on installs install.sh prereq list shrinks from 6 commands (git gh jq openssl ssh-keygen python3) to 5 (jq dropped). Linux/macOS/Windows installers all benefit; users with restricted package managers (Windows Server without winget) have one less thing to install. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Refactors gist JSON parsing to remove the external jq dependency by routing envelope/address extraction through a new airc_core.gistparse Python module (stdlib json), simplifying installation and runtime requirements.
Changes:
- Introduces
lib/airc_core/gistparse.pyproviding CLI subcommands for envelope field extraction and address selection. - Updates
cmd_connect.shandaircaddress-picking logic to useairc_core.gistparseinstead ofjq. - Removes
jqfrom installer prereqs and doctor checks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/airc_core/gistparse.py | New Python CLI module to replace jq-based gist/envelope/address parsing. |
| lib/airc_bash/cmd_doctor.sh | Drops jq probing from doctor / connect preflight checks. |
| lib/airc_bash/cmd_connect.sh | Replaces jq extraction of gist content and envelope fields with gistparse. |
| install.sh | Removes jq package mapping and jq from prereq installation checks. |
| airc | Switches peer_pick_address from jq pipelines to gistparse subcommands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # #188: jq removed — airc's gist envelope parser now uses Python's | ||
| # stdlib JSON (lib/airc_core/gistparse.py). Python was already a hard | ||
| # dep since #152 Phase 0; jq was redundant. Drop the dep + the | ||
| # winget step that would install it. | ||
| for cmd in git gh openssl ssh-keygen python3; do | ||
| # Strict probe: presence on PATH AND a successful --version invocation. |
There was a problem hiding this comment.
This PR drops jq from prereqs, but the runtime still appears to depend on it: lib/airc_bash/mesh.sh uses gh api ... --jq (which requires jq) and other jq parsing. Without adding equivalent gistparse-based extraction there (or replacing --jq usage), installs without jq will break mesh operations despite being marked as supported here.
| @@ -50,7 +50,6 @@ cmd_doctor() { | |||
| _doctor_probe "ssh" "$mgr" "OpenSSH client for the wire" || issues=$((issues+1)) | |||
| _doctor_probe "ssh-keygen" "$mgr" "Identity keypair generation" || issues=$((issues+1)) | |||
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |||
There was a problem hiding this comment.
jq is no longer probed here, but mesh functionality still uses jq via gh api --jq and direct jq invocations (see lib/airc_bash/mesh.sh). Either remove/replace those remaining jq call sites, or keep the jq doctor probe so users get an actionable diagnosis when mesh operations fail.
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |
| _doctor_probe "jq" "$mgr" "Mesh JSON parsing" || issues=$((issues+1)) |
| @@ -341,7 +340,6 @@ _doctor_connect_preflight() { | |||
| _doctor_probe "ssh" "$mgr" "OpenSSH client for the wire" || issues=$((issues+1)) | |||
| _doctor_probe "ssh-keygen" "$mgr" "Identity keypair generation" || issues=$((issues+1)) | |||
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |||
There was a problem hiding this comment.
Same as the top-level doctor check: jq is removed from preflight probes, but mesh operations still require jq today via gh api --jq / jq usage in lib/airc_bash/mesh.sh. Consider keeping the jq probe until those remaining runtime dependencies are eliminated.
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |
| _doctor_probe "python3" "$mgr" "Monitor formatter + heredocs" || issues=$((issues+1)) | |
| _doctor_probe "jq" "$mgr" "Mesh JSON parsing at runtime" || issues=$((issues+1)) |
| read stdout into a local var. Errors (malformed JSON, etc.) also | ||
| exit 0 with empty output unless --strict is passed; jq's behavior was | ||
| quiet-and-empty for malformed input and we preserve that. |
There was a problem hiding this comment.
Module docstring says malformed JSON "also exit 0 with empty output unless --strict is passed", but the CLI doesn't define a --strict flag (and argparse will exit non-zero on parse errors). Either implement the documented --strict behavior or update the docstring to match the actual CLI contract.
| read stdout into a local var. Errors (malformed JSON, etc.) also | |
| exit 0 with empty output unless --strict is passed; jq's behavior was | |
| quiet-and-empty for malformed input and we preserve that. | |
| read stdout into a local var. Error-handling for malformed JSON and | |
| other invalid input is defined by the implementation; this module does | |
| not provide a documented `--strict` CLI flag. |
| if entry.get("scope") == args.scope: | ||
| addr = entry.get("addr", "") | ||
| port = entry.get("port", "") | ||
| if addr and port != "": | ||
| print(f"{addr}|{port}") | ||
| return 0 |
There was a problem hiding this comment.
cmd_pick_addr can emit an invalid "addr|port" when the JSON contains a null port: entry.get("port", "") returns None, the condition port != "" passes, and stdout becomes addr|None. Tighten validation to require port is not None (and ideally is an int/str) before printing.
| if isinstance(data, list) and data and isinstance(data[0], dict): | ||
| addr = data[0].get("addr", "") | ||
| port = data[0].get("port", "") | ||
| if addr and port != "": | ||
| print(f"{addr}|{port}") | ||
| return 0 |
There was a problem hiding this comment.
cmd_pick_addr_first has the same null-port issue as cmd_pick_addr: if the first entry has "port": null, port != "" is true and it will print addr|None. Add a check to treat None as missing (or coerce/validate port) before emitting.
27 jq sites → airc_core.gistparse (Python stdlib JSON). One less hard dep; install.sh prereq list drops from 6 to 5. Tests green.