gabriel / muse public
feat patch init task/init-supercharge #1 / 1
AI Agent gabriel · 163 days ago · Apr 17, 2026 · Diff

feat(init): supercharge JSON output with typed schema, warnings, timing, and error helpers

- Add _InitJson and _InitErrorJson TypedDicts matching documented schema - Add status/error/warnings/exit_code fields to all JSON responses - Add duration_ms (float, milliseconds) and created_at (ISO 8601 UTC) to success output - Add _emit_error() helper centralising error JSON emission and SystemExit - Thread warnings list through _copy_template() for symlink/muse-dir skip notices - Update module docstring to document both success and error JSON schemas - Fix existing TestCopyTemplate tests to pass warnings list argument - Add 50 new tests in test_init_supercharge.py covering schema shape, types, exit codes, warnings, duration, created_at, TypedDict annotations, docstring

sha256:1614412b25e147598b21f12d44c4530620388e4b000b38313051c3ca1ead2f3d sha
+77 ~14 symbols
sha256:c389caed134997c8f7454bf5a414c5afa51960b555653819c05e63c26ebf86c7 snapshot
+77
symbols added
~14
symbols modified
0
dead code introduced
Semantic Changes 91 symbols
~ tests/test_init_supercharge.py .py 72 symbols added
+ TestCreatedAt class class TestCreatedAt L374–405
+ test_created_at_changes_on_reinit method method test_created_at_changes_on_reinit L393–399
+ test_created_at_is_iso8601_utc method method test_created_at_is_iso8601_utc L379–384
+ test_created_at_is_recent method method test_created_at_is_recent L386–391
+ test_created_at_matches_repo_json method method test_created_at_matches_repo_json L401–405
+ test_created_at_present method method test_created_at_present L375–377
+ TestDocstringSchema class class TestDocstringSchema L456–491
+ test_docstring_documents_created_at_field method method test_docstring_documents_created_at_field L481–485
+ test_docstring_documents_duration_ms_field method method test_docstring_documents_duration_ms_field L475–479
+ test_docstring_documents_error_schema method method test_docstring_documents_error_schema L487–491
+ test_docstring_documents_exit_code_field method method test_docstring_documents_exit_code_field L463–467
+ test_docstring_documents_status_field method method test_docstring_documents_status_field L457–461
+ test_docstring_documents_warnings_field method method test_docstring_documents_warnings_field L469–473
+ TestDurationMs class class TestDurationMs L349–366
+ test_duration_ms_is_float method method test_duration_ms_is_float L358–360
+ test_duration_ms_is_non_negative method method test_duration_ms_is_non_negative L354–356
+ test_duration_ms_present method method test_duration_ms_present L350–352
+ test_no_legacy_timing_keys method method test_no_legacy_timing_keys L362–366
+ TestErrorPayloadShape class class TestErrorPayloadShape L192–233
+ _assert_error_shape method method _assert_error_shape L195–202
+ test_already_exists_error_shape method method test_already_exists_error_shape L214–218
+ test_bad_branch_error_shape method method test_bad_branch_error_shape L204–208
+ test_bad_domain_error_shape method method test_bad_domain_error_shape L210–212
+ test_nonexistent_template_error_shape method method test_nonexistent_template_error_shape L230–233
+ test_symlink_template_error_shape method method test_symlink_template_error_shape L220–228
+ TestExitCodeField class class TestExitCodeField L241–270
+ test_exit_code_matches_process_exit_code method method test_exit_code_matches_process_exit_code L263–270
+ test_exit_code_nonzero_on_bad_branch method method test_exit_code_nonzero_on_bad_branch L256–261
+ test_exit_code_zero_on_bare method method test_exit_code_zero_on_bare L246–248
+ test_exit_code_zero_on_reinit method method test_exit_code_zero_on_reinit L250–254
+ test_exit_code_zero_on_success method method test_exit_code_zero_on_success L242–244
+ TestInitJsonTypedDict class class TestInitJsonTypedDict L414–445
+ test_init_error_json_typed_dict_exists method method test_init_error_json_typed_dict_exists L421–425
+ test_init_json_has_duration_ms_key method method test_init_json_has_duration_ms_key L442–445
+ test_init_json_has_exit_code_key method method test_init_json_has_exit_code_key L432–435
+ test_init_json_has_status_key method method test_init_json_has_status_key L427–430
+ test_init_json_has_warnings_key method method test_init_json_has_warnings_key L437–440
+ test_init_json_typed_dict_exists method method test_init_json_typed_dict_exists L415–419
+ TestJsonSchemaAgent class class TestJsonSchemaAgent L82–141
+ test_all_required_keys_present_on_bare_init method method test_all_required_keys_present_on_bare_init L115–120
+ test_all_required_keys_present_on_fresh_init method method test_all_required_keys_present_on_fresh_init L99–104
+ test_all_required_keys_present_on_reinit method method test_all_required_keys_present_on_reinit L106–113
+ test_field_types_correct method method test_field_types_correct L127–141
+ test_no_extra_unknown_keys method method test_no_extra_unknown_keys L122–125
+ TestStatusField class class TestStatusField L149–181
+ test_error_field_empty_on_success method method test_error_field_empty_on_success L164–166
+ test_status_error_on_bad_branch method method test_status_error_on_bad_branch L168–171
+ test_status_error_on_bad_domain method method test_status_error_on_bad_domain L173–175
+ test_status_error_on_existing_no_force method method test_status_error_on_existing_no_force L177–181
+ test_status_ok_on_bare method method test_status_ok_on_bare L154–156
+ test_status_ok_on_reinit method method test_status_ok_on_reinit L158–162
+ test_status_ok_on_success method method test_status_ok_on_success L150–152
+ TestWarningsField class class TestWarningsField L278–341
+ test_multiple_symlinks_produce_multiple_warnings method method test_multiple_symlinks_produce_multiple_warnings L331–341
+ test_warnings_empty_on_bare_init method method test_warnings_empty_on_bare_init L283–285
+ test_warnings_empty_on_clean_init method method test_warnings_empty_on_clean_init L279–281
+ test_warnings_empty_on_reinit_no_template method method test_warnings_empty_on_reinit_no_template L287–293
+ test_warnings_list_always_list_not_null method method test_warnings_list_always_list_not_null L323–329
+ test_warnings_populated_when_template_has_muse_dir method method test_warnings_populated_when_template_has_muse_dir L309–321
+ test_warnings_populated_when_template_has_symlinks method method test_warnings_populated_when_template_has_symlinks L295–307
+ _init function function _init L51–58
+ _init_json function function _init_json L61–64
+ _init_json_fail function function _init_json_fail L67–71
+ CliRunner import import CliRunner L41–41
+ InvokeResult import import InvokeResult L41–41
+ annotations import import annotations L32–32
+ datetime import import datetime L34–34
+ json import import json L35–35
+ os import import os L36–36
+ pathlib import import pathlib L37–37
+ pytest import import pytest L39–39
+ runner variable variable runner L43–43
~ muse/cli/commands/init.py .py 5 symbols added, 2 symbols modified
+ _InitErrorJson class class _InitErrorJson L100–104
+ _InitJson class class _InitJson L84–97
+ _emit_error function function _emit_error L328–339
+ TypedDict import import TypedDict L69–69
+ time import import time L67–67
~ run
← Older Oldest on task/init-supercharge
All commits
Newer → Latest on task/init-supercharge

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:1614412b25e147598b21f12d44c4530620388e4b000b38313051c3ca1ead2f3d --body "your comment"