gabriel / muse public
feat patch query dev
AI Agent gabriel · 159 days ago · Apr 19, 2026 · Diff

feat(query): supercharge muse code query for agents

- Add `-j` short alias for `--json` (consistent with patch/predict) - Add `_QueryJson` TypedDict — formal schema for single-snapshot JSON output - Add `_AllCommitsJson` TypedDict — formal schema for --all-commits JSON output - Add `exit_code` and `duration_ms` to both JSON envelopes (agent-parseable) - Sanitize predicate values in all human-readable no-match / summary lines - Expand `run()` docstring to document both JSON envelope shapes - Expand `register()` docstring to list all accepted arguments - Add `tests/test_query_supercharge.py`: 71 new tests (zero CLI-level tests existed before) covering -j alias, schema validation, TypedDict imports, filters, --all-commits, security (null bytes, ANSI), and docstrings

sha256:0a1fd6d57978f4526ddec102e2dabdac464b656f1d2ea7417febb0230d7a90d9 sha
+96 ~2 symbols
sha256:2b7927f1af9c61f7c00b3ea248595f033fa22dc1b65de1fd2d5b1bccc47ab3b0 snapshot
+96
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 98 symbols
~ tests/test_query_supercharge.py .py 92 symbols added
+ TestAllCommitsJson class class TestAllCommitsJson L220–278
+ test_all_commits_j_alias_works method method test_all_commits_j_alias_works L263–268
+ test_all_commits_json_duration_ms_positive method method test_all_commits_json_duration_ms_positive L257–261
+ test_all_commits_json_exit_code_zero method method test_all_commits_json_exit_code_zero L247–250
+ test_all_commits_json_exits_zero method method test_all_commits_json_exits_zero L221–223
+ test_all_commits_json_has_duration_ms method method test_all_commits_json_has_duration_ms L252–255
+ test_all_commits_json_has_exit_code method method test_all_commits_json_has_exit_code L242–245
+ test_all_commits_json_has_mode method method test_all_commits_json_has_mode L230–234
+ test_all_commits_json_has_results method method test_all_commits_json_has_results L225–228
+ test_all_commits_json_has_truncated method method test_all_commits_json_has_truncated L236–240
+ test_all_commits_result_record_schema method method test_all_commits_result_record_schema L270–278
+ TestCLIAllCommits class class TestCLIAllCommits L468–497
+ test_all_commits_count method method test_all_commits_count L494–497
+ test_all_commits_exits_zero method method test_all_commits_exits_zero L469–471
+ test_all_commits_finds_symbols method method test_all_commits_finds_symbols L473–476
+ test_all_commits_mutual_exclusive_with_commit method method test_all_commits_mutual_exclusive_with_commit L478–481
+ test_all_commits_since_filter method method test_all_commits_since_filter L483–488
+ test_all_commits_since_requires_all_commits method method test_all_commits_since_requires_all_commits L490–492
+ TestCLIBasic class class TestCLIBasic L351–390
+ test_query_bad_predicate_exits_one method method test_query_bad_predicate_exits_one L383–385
+ test_query_class_returns_class class method test_query_class_returns_class L357–361
+ test_query_count_only method method test_query_count_only L377–381
+ test_query_file_filter method method test_query_file_filter L372–375
+ test_query_functions_returns_results method method test_query_functions_returns_results L352–355
+ test_query_missing_predicate_exits_one method method test_query_missing_predicate_exits_one L387–390
+ test_query_name_contains method method test_query_name_contains L367–370
+ test_query_no_match_exits_zero method method test_query_no_match_exits_zero L363–365
+ TestCLIFilters class class TestCLIFilters L398–460
+ test_hashes_adds_content_id method method test_hashes_adds_content_id L438–446
+ test_limit_caps_results method method test_limit_caps_results L399–402
+ test_limit_sets_truncated_flag method method test_limit_sets_truncated_flag L404–412
+ test_not_predicate method method test_not_predicate L454–460
+ test_or_predicate method method test_or_predicate L448–452
+ test_sort_by_name method method test_sort_by_name L414–418
+ test_sort_by_size_largest_first method method test_sort_by_size_largest_first L420–424
+ test_unique_bodies_deduplicates method method test_unique_bodies_deduplicates L426–436
+ TestCLISecurity class class TestCLISecurity L505–518
+ test_ansi_not_in_all_commits_json_output method method test_ansi_not_in_all_commits_json_output L516–518
+ test_ansi_not_in_json_output method method test_ansi_not_in_json_output L512–514
+ test_control_chars_in_predicate_value_rejected method method test_control_chars_in_predicate_value_rejected L506–510
+ TestDocstrings class class TestDocstrings L526–546
+ test_register_docstring_exists method method test_register_docstring_exists L544–546
+ test_run_docstring_exists method method test_run_docstring_exists L527–530
+ test_run_docstring_mentions_duration_ms method method test_run_docstring_mentions_duration_ms L540–542
+ test_run_docstring_mentions_exit_code method method test_run_docstring_mentions_exit_code L536–538
+ test_run_docstring_mentions_json method method test_run_docstring_mentions_json L532–534
+ TestJsonAlias class class TestJsonAlias L99–137
+ test_j_alias_emits_valid_json method method test_j_alias_emits_valid_json L104–108
+ test_j_alias_exits_zero method method test_j_alias_exits_zero L100–102
+ test_j_alias_has_results method method test_j_alias_has_results L110–113
+ test_j_alias_no_match_empty_results method method test_j_alias_no_match_empty_results L129–132
+ test_j_alias_result_count_matches_json_flag method method test_j_alias_result_count_matches_json_flag L124–127
+ test_j_alias_same_keys_as_json_flag method method test_j_alias_same_keys_as_json_flag L115–122
+ test_j_alias_with_count method method test_j_alias_with_count L134–137
+ TestSingleSnapshotJson class class TestSingleSnapshotJson L145–212
+ test_json_duration_ms_positive method method test_json_duration_ms_positive L187–191
+ test_json_exit_code_is_zero method method test_json_exit_code_is_zero L177–180
+ test_json_exits_zero method method test_json_exits_zero L146–148
+ test_json_has_commit method method test_json_has_commit L161–164
+ test_json_has_duration_ms method method test_json_has_duration_ms L182–185
+ test_json_has_exit_code method method test_json_has_exit_code L172–175
+ test_json_has_results method method test_json_has_results L150–154
+ test_json_has_schema_version method method test_json_has_schema_version L156–159
+ test_json_has_truncated method method test_json_has_truncated L166–170
+ test_json_no_match_duration_ms_present method method test_json_no_match_duration_ms_present L209–212
+ test_json_no_match_exit_code_zero method method test_json_no_match_exit_code_zero L203–207
+ test_json_result_record_schema method method test_json_result_record_schema L193–201
+ TestTypedDicts class class TestTypedDicts L286–343
+ test_all_commits_json_has_duration_ms method method test_all_commits_json_has_duration_ms L340–343
+ test_all_commits_json_has_exit_code method method test_all_commits_json_has_exit_code L335–338
+ test_all_commits_json_has_mode method method test_all_commits_json_has_mode L325–328
+ test_all_commits_json_has_results method method test_all_commits_json_has_results L330–333
+ test_all_commits_json_importable method method test_all_commits_json_importable L321–323
+ test_query_json_has_commit method method test_query_json_has_commit L296–299
+ test_query_json_has_duration_ms method method test_query_json_has_duration_ms L316–319
+ test_query_json_has_exit_code method method test_query_json_has_exit_code L311–314
+ test_query_json_has_results method method test_query_json_has_results L301–304
+ test_query_json_has_schema_version method method test_query_json_has_schema_version L291–294
+ test_query_json_has_truncated method method test_query_json_has_truncated L306–309
+ test_query_json_importable method method test_query_json_importable L287–289
+ _commit function function _commit L50–54
+ _run function function _run L46–47
+ cli variable variable cli L37–37
+ CliRunner import import CliRunner L35–35
+ annotations import import annotations L26–26
+ json import import json L28–28
+ pathlib import import pathlib L29–29
+ pytest import import pytest L33–33
+ textwrap import import textwrap L30–30
+ typing import import typing L31–31
+ repo function function repo L63–91
+ runner variable variable runner L38–38
~ muse/cli/commands/query.py .py 4 symbols added, 2 symbols modified
+ _AllCommitsJson class class _AllCommitsJson L111–131
+ _QueryJson class class _QueryJson L84–108
+ TypedDict import import TypedDict L61–61
+ start_timer import import start_timer L75–75
~ run
← Older Oldest on dev
All commits
Newer → Latest on dev

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:0a1fd6d57978f4526ddec102e2dabdac464b656f1d2ea7417febb0230d7a90d9 --body "your comment"