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

feat(clones): supercharge for agents — -j alias, exit_code, duration_ms, _ClonesOutputJson

- Add -j alias to --json - Add _ClonesOutputJson TypedDict covering all 17 JSON envelope fields - Import start_timer; wire elapsed() to duration_ms in JSON output - Add exit_code=0 to JSON output - Update run() docstring with JSON envelope section - Add tests/test_clones_supercharge.py (39 tests): TestJsonAlias, TestDurationMs, TestExitCode, TestTypedDicts, TestDocstrings, TestAnsiSanitization, TestPerformance - Fix 4 stale assertions in test_cmd_clones.py: short_id() now returns 12-char hex (not 8) for raw hashes and 'sha256:<12hex>' (not bare 8 hex) for sha256-prefixed commit IDs; determinism test now pops duration_ms before comparing - All 105 clones tests pass

sha256:e641ef877058c01e87e96f73d4eb75bb62cd0c5ac98d7556b34e85f737e1a419 sha
+61 ~6 −3 symbols
sha256:93971dceae5689344a1c2789c82a822f15e01242a00fc3d62095222222396a0c snapshot
+61
symbols added
~6
symbols modified
−3
symbols removed
0
dead code introduced
Semantic Changes 70 symbols
~ tests/test_clones_supercharge.py .py 56 symbols added
+ TestAnsiSanitization class class TestAnsiSanitization L316–329
+ test_j_alias_output_no_ansi method method test_j_alias_output_no_ansi L323–325
+ test_json_output_no_ansi method method test_json_output_no_ansi L319–321
+ test_tier_near_json_no_ansi method method test_tier_near_json_no_ansi L327–329
+ TestDocstrings class class TestDocstrings L297–308
+ test_run_docstring_mentions_duration_ms method method test_run_docstring_mentions_duration_ms L305–308
+ test_run_docstring_mentions_exit_code method method test_run_docstring_mentions_exit_code L300–303
+ TestDurationMs class class TestDurationMs L149–190
+ test_duration_ms_with_no_clones method method test_duration_ms_with_no_clones L178–190
+ test_duration_ms_with_tier_exact method method test_duration_ms_with_tier_exact L172–176
+ test_j_alias_duration_ms_present method method test_j_alias_duration_ms_present L167–170
+ test_json_duration_ms_is_float method method test_json_duration_ms_is_float L162–165
+ test_json_duration_ms_nonnegative method method test_json_duration_ms_nonnegative L157–160
+ test_json_has_duration_ms method method test_json_has_duration_ms L152–155
+ TestExitCode class class TestExitCode L198–243
+ test_exit_code_mirrors_process_exit method method test_exit_code_mirrors_process_exit L222–225
+ test_exit_code_zero_with_no_clones method method test_exit_code_zero_with_no_clones L227–237
+ test_exit_code_zero_with_tier_near method method test_exit_code_zero_with_tier_near L239–243
+ test_j_alias_exit_code_present method method test_j_alias_exit_code_present L217–220
+ test_json_exit_code_is_int method method test_json_exit_code_is_int L212–215
+ test_json_exit_code_zero_on_success method method test_json_exit_code_zero_on_success L206–210
+ test_json_has_exit_code method method test_json_has_exit_code L201–204
+ TestJsonAlias class class TestJsonAlias L95–141
+ test_j_alias_exits_zero method method test_j_alias_exits_zero L98–100
+ test_j_alias_has_clusters_key method method test_j_alias_has_clusters_key L106–109
+ test_j_alias_has_commit_key method method test_j_alias_has_commit_key L111–114
+ test_j_alias_same_cluster_count method method test_j_alias_same_cluster_count L125–129
+ test_j_alias_same_top_level_keys_as_json_flag method method test_j_alias_same_top_level_keys_as_json_flag L116–123
+ test_j_alias_valid_json method method test_j_alias_valid_json L102–104
+ test_j_alias_with_tier_exact method method test_j_alias_with_tier_exact L131–135
+ test_j_alias_with_tier_near method method test_j_alias_with_tier_near L137–141
+ TestPerformance class class TestPerformance L337–353
+ test_duration_ms_is_float_not_int method method test_duration_ms_is_float_not_int L350–353
+ test_j_alias_duration_under_2000ms method method test_j_alias_duration_under_2000ms L345–348
+ test_json_duration_under_2000ms method method test_json_duration_under_2000ms L340–343
+ TestTypedDicts class class TestTypedDicts L251–289
+ test_clones_output_json_exists method method test_clones_output_json_exists L254–255
+ test_cluster_dict_exists method method test_cluster_dict_exists L288–289
+ test_has_duration_ms_annotation method method test_has_duration_ms_annotation L261–263
+ test_has_exit_code_annotation method method test_has_exit_code_annotation L257–259
+ test_member_dict_exists method method test_member_dict_exists L285–286
+ test_retains_clusters_annotation method method test_retains_clusters_annotation L265–267
+ test_retains_commit_annotation method method test_retains_commit_annotation L269–271
+ test_retains_exact_clone_clusters_annotation method method test_retains_exact_clone_clusters_annotation L273–275
+ test_retains_file_hotspots_annotation method method test_retains_file_hotspots_annotation L281–283
+ test_retains_near_clone_clusters_annotation method method test_retains_near_clone_clusters_annotation L277–279
+ _env function function _env L35–36
+ _run function function _run L39–40
+ clones_repo function function clones_repo L49–87
+ CliRunner import import CliRunner L25–25
+ annotations import import annotations L17–17
+ json import import json L19–19
+ pathlib import import pathlib L20–20
+ pytest import import pytest L23–23
+ textwrap import import textwrap L21–21
+ runner variable variable runner L27–27
~ muse/cli/commands/clones.py .py 2 symbols added, 2 symbols modified
+ _ClonesOutputJson class class _ClonesOutputJson L129–167
+ start_timer import import start_timer L90–90
~ run
~ tests/test_cmd_clones.py .py 3 symbols added, 3 symbols removed, 4 symbols modified
− test_hash_truncated_to_8_chars method method test_hash_truncated_to_8_chars L359–361
− test_member_hashes_truncated method method test_member_hashes_truncated L369–374
− test_json_commit_is_8_char_hex method method test_json_commit_is_8_char_hex L631–634
+ test_hash_is_short_id method method test_hash_is_short_id L359–363
+ test_member_hashes_are_short_ids method method test_member_hashes_are_short_ids L371–377
+ test_json_commit_is_short_id method method test_json_commit_is_short_id L634–640
← 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:e641ef877058c01e87e96f73d4eb75bb62cd0c5ac98d7556b34e85f737e1a419 --body "your comment"