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

feat: supercharge muse code patch for agents

- Add -j alias for --json (consistent with narrative/other commands) - Add exit_code + duration_ms to JSON envelope (_PatchJson TypedDict) - Add symbols_preserved to JSON (was only in human text, now in JSON too) - Add _PatchJson TypedDict with full field docstrings as formal output schema - Auto-reindent replacement body to match original symbol's indentation (agents write unindented code; patch now handles methods/nested scopes) - Expand docstrings on _locate_symbol, _read_new_body, register(), run()

TDD: 32 new tests in tests/test_patch_supercharge.py — all green. Existing 34 tests in test_cmd_patch.py — still green.

sha256:1ab52cf90c7d7f1433b267240a7fe9ddb703d7f18ad0aacddc488a9ce51ab4fd sha
+55 ~4 symbols
sha256:37060d0ee4f416366700857f525b36991f14cedab10adc4333931418c14b8d46 snapshot
+55
symbols added
~4
symbols modified
0
dead code introduced
Semantic Changes 59 symbols
~ tests/test_patch_supercharge.py .py 51 symbols added
+ TestDataIntegrity class class TestDataIntegrity L322–372
+ test_bytes_after_symbol_unchanged method method test_bytes_after_symbol_unchanged L344–362
+ test_bytes_before_symbol_unchanged method method test_bytes_before_symbol_unchanged L323–342
+ test_patched_file_is_valid_python method method test_patched_file_is_valid_python L364–372
+ TestEmptyBody class class TestEmptyBody L431–456
+ test_empty_body_does_not_corrupt_file method method test_empty_body_does_not_corrupt_file L446–456
+ test_empty_body_rejected method method test_empty_body_rejected L432–444
+ TestJsonAlias class class TestJsonAlias L68–106
+ test_j_alias_emits_valid_json method method test_j_alias_emits_valid_json L77–85
+ test_j_alias_exits_zero method method test_j_alias_exits_zero L69–75
+ test_j_alias_same_output_as_json_flag method method test_j_alias_same_output_as_json_flag L87–106
+ TestJsonDurationMs class class TestJsonDurationMs L150–179
+ test_duration_ms_is_positive method method test_duration_ms_is_positive L160–168
+ test_duration_ms_present method method test_duration_ms_present L151–158
+ test_duration_ms_present_on_dry_run method method test_duration_ms_present_on_dry_run L170–179
+ TestJsonExitCode class class TestJsonExitCode L114–142
+ test_exit_code_is_zero_on_success method method test_exit_code_is_zero_on_success L124–131
+ test_exit_code_present method method test_exit_code_present L115–122
+ test_exit_code_present_on_dry_run method method test_exit_code_present_on_dry_run L133–142
+ TestJsonSymbolsPreserved class class TestJsonSymbolsPreserved L187–230
+ test_dry_run_preserved_matches_live method method test_dry_run_preserved_matches_live L218–230
+ test_symbols_preserved_correct_count method method test_symbols_preserved_correct_count L197–206
+ test_symbols_preserved_present_on_dry_run method method test_symbols_preserved_present_on_dry_run L208–216
+ test_symbols_preserved_present_on_live_patch method method test_symbols_preserved_present_on_live_patch L188–195
+ TestPatchJsonTypedDict class class TestPatchJsonTypedDict L238–281
+ test_patch_json_has_address method method test_patch_json_has_address L243–246
+ test_patch_json_has_dry_run method method test_patch_json_has_dry_run L268–271
+ test_patch_json_has_duration_ms method method test_patch_json_has_duration_ms L278–281
+ test_patch_json_has_exit_code method method test_patch_json_has_exit_code L273–276
+ test_patch_json_has_file method method test_patch_json_has_file L248–251
+ test_patch_json_has_lines_replaced method method test_patch_json_has_lines_replaced L253–256
+ test_patch_json_has_new_lines method method test_patch_json_has_new_lines L258–261
+ test_patch_json_has_symbols_preserved method method test_patch_json_has_symbols_preserved L263–266
+ test_patch_json_typeddict_importable method method test_patch_json_typeddict_importable L239–241
+ TestPatchMethod class class TestPatchMethod L380–423
+ test_patch_class_method class method test_patch_class_method L381–393
+ test_patch_method_json_schema method method test_patch_method_json_schema L408–423
+ test_patch_method_leaves_sibling_method_intact method method test_patch_method_leaves_sibling_method_intact L395–406
+ TestShortBodyFlag class class TestShortBodyFlag L289–314
+ test_b_and_body_are_equivalent method method test_b_and_body_are_equivalent L299–314
+ test_b_short_form_works method method test_b_short_form_works L290–297
+ cli variable variable cli L27–27
+ CliRunner import import CliRunner L25–25
+ annotations import import annotations L16–16
+ json import import json L18–18
+ pathlib import import pathlib L19–19
+ pytest import import pytest L23–23
+ textwrap import import textwrap L20–20
+ typing import import typing L21–21
+ repo function function repo L37–60
+ runner variable variable runner L28–28
~ muse/cli/commands/patch.py .py 4 symbols added, 4 symbols modified
+ _PatchJson class class _PatchJson L73–99
+ TypedDict import import TypedDict L62–62
+ start_timer import import start_timer L66–66
+ textwrap import import textwrap L61–61
~ 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:1ab52cf90c7d7f1433b267240a7fe9ddb703d7f18ad0aacddc488a9ce51ab4fd --body "your comment"