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

feat(ls-files): supercharge JSON envelope, typed schema, consistent errors

Envelope additions (always present, no dict.get guards needed): - status: 'ok' on success, 'error' on failure - error: '' on success, message on failure - branch: branch HEAD resolved to (null when --commit given explicitly) - path_prefix: echoes the active filter (null when no --path-prefix) - duration_ms: float wall-clock timing - exit_code: 0 on success

TypedDicts: - Add _LsFilesJson (10 fields) and _LsFilesErrorJson (3 fields)

Error payloads: - _emit_error() centralises emission; suppresses prose in --json mode - All error paths emit {status, error, exit_code} — no bare {'error': '...'} dicts - No ❌ emoji leaking to stdout in --json mode

Test fixes (17 pre-existing failures): - _oid() now returns 'sha256:' prefixed IDs to match write_object() requirement - object_id length assertions updated: startswith('sha256:') + 64-hex suffix - snapshot_id assertion: startswith('sha256:') instead of len == 64 - --commit nonexistent test: use canonical sha256:fff...fff form - text OID assertion: startswith('sha256:') instead of len == 64 - test_ansi_in_path_preserved_in_json: fix always-True tautology in assertion

New tests (29 in test_ls_files_supercharge.py): - Envelope schema, error shape, branch field, path_prefix echo, TypedDicts, docstring, data integrity, no prose pollution

sha256:761347ed8917eb6e319c62db6482e402c7bdc2ee47756870d19b79e5c35f7a0d sha
+82 ~10 −1 symbols
sha256:695494c847b201773661e97dd35e91f606c95f41dcff9120e5f39ec8d7fb4745 snapshot
+82
symbols added
~10
symbols modified
−1
symbol removed
0
dead code introduced
Semantic Changes 93 symbols
~ tests/test_ls_files_supercharge.py .py 76 symbols added
+ TestBranchField class class TestBranchField L231–252
+ test_branch_is_dev_when_on_dev method method test_branch_is_dev_when_on_dev L238–242
+ test_branch_is_main_when_on_main method method test_branch_is_main_when_on_main L232–236
+ test_branch_is_none_when_explicit_commit_given method method test_branch_is_none_when_explicit_commit_given L244–252
+ TestDataIntegrity class class TestDataIntegrity L343–379
+ test_commit_id_matches_stored method method test_commit_id_matches_stored L362–366
+ test_files_sorted_alphabetically method method test_files_sorted_alphabetically L368–373
+ test_object_ids_sha256_prefixed_in_json method method test_object_ids_sha256_prefixed_in_json L344–351
+ test_object_ids_sha256_prefixed_in_text method method test_object_ids_sha256_prefixed_in_text L353–360
+ test_path_prefix_file_count_consistent method method test_path_prefix_file_count_consistent L375–379
+ TestDocstring class class TestDocstring L312–335
+ test_docstring_documents_branch method method test_docstring_documents_branch L317–319
+ test_docstring_documents_duration_ms method method test_docstring_documents_duration_ms L325–327
+ test_docstring_documents_error method method test_docstring_documents_error L333–335
+ test_docstring_documents_exit_code method method test_docstring_documents_exit_code L329–331
+ test_docstring_documents_path_prefix method method test_docstring_documents_path_prefix L321–323
+ test_docstring_documents_status method method test_docstring_documents_status L313–315
+ TestErrorPayloadShape class class TestErrorPayloadShape L183–223
+ test_error_exit_code_nonzero method method test_error_exit_code_nonzero L204–208
+ test_error_keys_exactly_three method method test_error_keys_exactly_three L184–189
+ test_error_message_nonempty method method test_error_message_nonempty L198–202
+ test_error_status_is_error method method test_error_status_is_error L191–196
+ test_invalid_commit_error_payload method method test_invalid_commit_error_payload L210–216
+ test_nonexistent_commit_error_payload method method test_nonexistent_commit_error_payload L218–223
+ TestJsonEnvelopeSchema class class TestJsonEnvelopeSchema L101–175
+ test_all_required_keys_present method method test_all_required_keys_present L102–107
+ test_commit_id_sha256_prefixed method method test_commit_id_sha256_prefixed L165–169
+ test_duration_ms_nonnegative_float method method test_duration_ms_nonnegative_float L134–139
+ test_error_empty_string_on_success method method test_error_empty_string_on_success L122–126
+ test_exit_code_zero_on_success method method test_exit_code_zero_on_success L128–132
+ test_file_count_matches_files_length method method test_file_count_matches_files_length L141–145
+ test_files_is_list method method test_files_is_list L147–151
+ test_no_extra_undocumented_keys method method test_no_extra_undocumented_keys L109–114
+ test_path_prefix_echoed_when_filtered method method test_path_prefix_echoed_when_filtered L159–163
+ test_path_prefix_none_when_not_filtered method method test_path_prefix_none_when_not_filtered L153–157
+ test_snapshot_id_sha256_prefixed method method test_snapshot_id_sha256_prefixed L171–175
+ test_status_ok_on_success method method test_status_ok_on_success L116–120
+ TestNoProsePollution class class TestNoProsePollution L387–412
+ test_error_stdout_is_valid_json method method test_error_stdout_is_valid_json L409–412
+ test_no_emoji_in_json_error_output method method test_no_emoji_in_json_error_output L401–407
+ test_no_emoji_in_json_success_output method method test_no_emoji_in_json_success_output L394–399
+ test_success_stdout_is_valid_json method method test_success_stdout_is_valid_json L388–392
+ TestPathPrefixEchoed class class TestPathPrefixEchoed L260–277
+ test_path_prefix_echoed_nested method method test_path_prefix_echoed_nested L273–277
+ test_path_prefix_echoed_src method method test_path_prefix_echoed_src L267–271
+ test_path_prefix_null_without_filter method method test_path_prefix_null_without_filter L261–265
+ TestTypedDicts class class TestTypedDicts L285–304
+ test_ls_files_error_json_has_all_annotations method method test_ls_files_error_json_has_all_annotations L301–304
+ test_ls_files_error_json_typed_dict_exists method method test_ls_files_error_json_typed_dict_exists L290–292
+ test_ls_files_json_has_all_annotations method method test_ls_files_json_has_all_annotations L294–299
+ test_ls_files_json_typed_dict_exists method method test_ls_files_json_typed_dict_exists L286–288
+ _REQUIRED_ERROR_KEYS variable variable _REQUIRED_ERROR_KEYS L35–35
+ _REQUIRED_SUCCESS_KEYS variable variable _REQUIRED_SUCCESS_KEYS L31–34
+ _TS variable variable _TS L37–37
+ _add_commit function function _add_commit L58–82
+ _ls function function _ls L85–87
+ _ls_json function function _ls_json L90–93
+ _make_repo function function _make_repo L48–55
+ _oid function function _oid L44–45
+ CliRunner import import CliRunner L27–27
+ CommitRecord import import CommitRecord L25–25
+ InvokeResult import import InvokeResult L27–27
+ Manifest import import Manifest L26–26
+ SnapshotRecord import import SnapshotRecord L25–25
+ annotations import import annotations L14–14
+ compute_commit_id import import compute_commit_id L24–24
+ compute_snapshot_id import import compute_snapshot_id L24–24
+ datetime import import datetime L16–16
+ hashlib import import hashlib L17–17
+ json import import json L18–18
+ pathlib import import pathlib L19–19
+ pytest import import pytest L21–21
+ write_commit import import write_commit L25–25
+ write_object import import write_object L23–23
+ write_snapshot import import write_snapshot L25–25
+ runner variable variable runner L29–29
~ muse/cli/commands/ls_files.py .py 5 symbols added, 1 symbol modified
+ _LsFilesErrorJson class class _LsFilesErrorJson L102–106
+ _LsFilesJson class class _LsFilesJson L84–99
+ _emit_error function function _emit_error L109–123
+ TypedDict import import TypedDict L67–67
+ time import import time L66–66
~ run
~ tests/test_cmd_ls_files.py .py 1 symbol added, 1 symbol removed, 9 symbols modified
← Older Oldest on task/ls-files-supercharge
All commits
Newer → Latest on task/ls-files-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:761347ed8917eb6e319c62db6482e402c7bdc2ee47756870d19b79e5c35f7a0d --body "your comment"