gabriel / muse public
feat patch mist task/mist-cli-phase2 #1 / 1
gabriel · 147 days ago · Apr 15, 2026 · Diff

feat(mist): add muse mist CLI — Phase 2, all 7 subcommands

- New muse/cli/commands/mist.py with complete subcommand tree: create, list, read, fork, push, embed, delete - muse mist create: validates filename, computes mist_id, detects artifact type/language, extracts symbol anchors — no network needed without --push; submits to MuseHub POST /api/mists when --push - muse mist create --sign: Ed25519 signature via identity.toml - muse mist create --agent-id / --model-id: AI provenance fields - muse mist list: cursor-paginated GET /api/{handle}/mists with --type filter and --limit - muse mist read: full content + metadata; supports owner/ID form - muse mist fork: POST /api/mists/{id}/fork; reports fork_parent_id - muse mist push: delegates to existing push infrastructure; validates domain=mist before pushing - muse mist embed: iframe + JS snippet + Markdown badge; --width/--height - muse mist delete: DELETE with --yes flag; 403 → exit 5 - _validate_tag: rejects XSS, null bytes, HTML specials, control chars - _hub_api: authenticated JSON client (same pattern as hub.py) - Registered in muse/cli/app.py at correct alphabetical position (mist) - 89 tests covering Tiers 1, 2, 3, 5, 6, 7, 8 — all green - 161 total mist tests (Phases 1+2) all green

sha256:d041bc2302482d577e3f8ea1ed1364b22cd08ccab7d4d6e1ee41acb0250e9da9 sha
+117 ~116 symbols
sha256:f414f9b4f5532640793c01f13492e4c34dab7ee13582d418124e2bb1225d0d2f snapshot
+117
symbols added
~116
symbols modified
0
dead code introduced
Semantic Changes 233 symbols
~ muse/cli/commands/mist.py .py 33 symbols added
+ _ALLOWED_API_SCHEMES variable variable _ALLOWED_API_SCHEMES L86–86
+ _ALLOWED_VISIBILITY variable variable _ALLOWED_VISIBILITY L85–85
+ _MAX_MIST_BYTES variable variable _MAX_MIST_BYTES L82–82
+ _MAX_TAGS variable variable _MAX_TAGS L84–84
+ _MAX_TAG_LENGTH variable variable _MAX_TAG_LENGTH L83–83
+ _get_hub_url function function _get_hub_url L94–127
+ _hub_api function function _hub_api L130–244
+ _require_hub function function _require_hub L247–276
+ _validate_tag function function _validate_tag L279–303
+ ExitCode import import ExitCode L65–65
+ IdentityEntry import import IdentityEntry L66–66
+ TYPE_CHECKING import import TYPE_CHECKING L63–63
+ _validate_mist_filename import import _validate_mist_filename L68–68
+ annotations import import annotations L55–55
+ argparse import import argparse L57–57
+ compute_mist_id import import compute_mist_id L68–68
+ detect_artifact_type import import detect_artifact_type L68–68
+ extract_mist_symbol_anchors import import extract_mist_symbol_anchors L68–68
+ json import import json L58–58
+ load_identity import import load_identity L66–66
+ os import import os L59–59
+ sanitize_display import import sanitize_display L67–67
+ sys import import sys L60–60
+ parse import import urllib.parse L61–61
+ request import import urllib.request L62–62
+ register function function register L979–1245
+ run_create function function run_create L311–508
+ run_delete function function run_delete L918–971
+ run_embed function function run_embed L832–915
+ run_fork function function run_fork L717–768
+ run_list function function run_list L511–620
+ run_push function function run_push L771–829
+ run_read function function run_read L623–714
~ tests/test_mist_cli.py .py 83 symbols added
+ TestMistCliDataIntegrity class class TestMistCliDataIntegrity L380–461
+ test_artifact_type_matches_detect method method test_artifact_type_matches_detect L392–400
+ test_mist_id_base58_only method method test_mist_id_base58_only L424–430
+ test_mist_id_matches_compute_mist_id method method test_mist_id_matches_compute_mist_id L383–390
+ test_signed_false_without_sign_flag method method test_signed_false_without_sign_flag L408–411
+ test_size_bytes_matches_actual method method test_size_bytes_matches_actual L402–406
+ test_symbol_anchors_contain_function_name method method test_symbol_anchors_contain_function_name L418–422
+ test_symbol_anchors_list_type method method test_symbol_anchors_list_type L413–416
+ test_validate_tag_accepts_normal_tag method method test_validate_tag_accepts_normal_tag L456–461
+ test_validate_tag_rejects_control_char method method test_validate_tag_rejects_control_char L450–454
+ test_validate_tag_rejects_null_byte method method test_validate_tag_rejects_null_byte L438–442
+ test_validate_tag_rejects_too_long method method test_validate_tag_rejects_too_long L444–448
+ test_validate_tag_rejects_xss method method test_validate_tag_rejects_xss L432–436
+ TestMistCliDocstrings class class TestMistCliDocstrings L570–608
+ test_function_has_docstring method method test_function_has_docstring L594–601
+ test_module_docstring method method test_module_docstring L588–591
+ test_register_docstring_lists_all_subcommands method method test_register_docstring_lists_all_subcommands L603–608
+ TestMistCliPerformance class class TestMistCliPerformance L469–487
+ test_create_1mb_file_under_200ms method method test_create_1mb_file_under_200ms L472–477
+ test_create_deterministic_ids_10_calls_under_500ms method method test_create_deterministic_ids_10_calls_under_500ms L479–487
+ TestMistCliSecurity class class TestMistCliSecurity L495–562
+ test_content_over_10mb_rejected method method test_content_over_10mb_rejected L518–523
+ test_file_not_found_exits_nonzero method method test_file_not_found_exits_nonzero L538–541
+ test_invalid_filename_rejected method method test_invalid_filename_rejected L504–516
+ test_invalid_visibility_rejected method method test_invalid_visibility_rejected L525–528
+ test_mist_id_collision_resistance_1000_payloads method method test_mist_id_collision_resistance_1000_payloads L558–562
+ test_mist_id_not_sequential_for_sequential_content method method test_mist_id_not_sequential_for_sequential_content L543–548
+ test_too_many_tags_rejected method method test_too_many_tags_rejected L530–536
+ test_xss_tag_rejected_via_validate_tag method method test_xss_tag_rejected_via_validate_tag L550–556
+ TestMistCliShape class class TestMistCliShape L120–180
+ test_all_subcommands_in_help method method test_all_subcommands_in_help L131–135
+ test_create_json_flag_present method method test_create_json_flag_present L166–168
+ test_create_push_flag_present method method test_create_push_flag_present L170–172
+ test_create_sign_flag_present method method test_create_sign_flag_present L174–176
+ test_create_visibility_flag_present method method test_create_visibility_flag_present L178–180
+ test_mist_help_exits_0 method method test_mist_help_exits_0 L126–129
+ test_mist_registered_in_app method method test_mist_registered_in_app L160–164
+ test_register_function_importable method method test_register_function_importable L150–153
+ test_run_functions_importable method method test_run_functions_importable L144–148
+ test_subcommand_help_exits_0 method method test_subcommand_help_exits_0 L138–141
+ test_validate_tag_importable method method test_validate_tag_importable L155–158
+ TestMistCreateEdgeCases class class TestMistCreateEdgeCases L291–372
+ test_create_different_content_different_mist_id method method test_create_different_content_different_mist_id L352–361
+ test_create_empty_file_exits_0 method method test_create_empty_file_exits_0 L294–299
+ test_create_empty_file_symbol_anchors_empty method method test_create_empty_file_symbol_anchors_empty L301–304
+ test_create_json_file_abi method method test_create_json_file_abi L314–319
+ test_create_json_file_schema method method test_create_json_file_schema L321–326
+ test_create_markdown_file method method test_create_markdown_file L328–334
+ test_create_same_content_same_mist_id method method test_create_same_content_same_mist_id L363–372
+ test_create_solidity_file method method test_create_solidity_file L336–342
+ test_create_ten_tags_accepted method method test_create_ten_tags_accepted L344–350
+ test_create_unknown_extension method method test_create_unknown_extension L306–312
+ TestMistCreateRoundTrip class class TestMistCreateRoundTrip L188–283
+ test_create_filename_correct method method test_create_filename_correct L240–243
+ test_create_human_readable_output method method test_create_human_readable_output L250–254
+ test_create_midi_artifact_type_is_midi method method test_create_midi_artifact_type_is_midi L224–227
+ test_create_midi_file_exits_0 method method test_create_midi_file_exits_0 L220–222
+ test_create_midi_symbol_anchors_empty method method test_create_midi_symbol_anchors_empty L229–232
+ test_create_no_url_without_push method method test_create_no_url_without_push L245–248
+ test_create_python_artifact_type_is_code method method test_create_python_artifact_type_is_code L208–212
+ test_create_python_file_exits_0 method method test_create_python_file_exits_0 L191–193
+ test_create_python_file_returns_json method method test_create_python_file_returns_json L195–201
+ test_create_python_mist_id_is_12_chars method method test_create_python_mist_id_is_12_chars L203–206
+ test_create_python_symbol_anchors_non_empty method method test_create_python_symbol_anchors_non_empty L214–218
+ test_create_size_bytes_correct method method test_create_size_bytes_correct L234–238
+ test_create_with_agent_flags method method test_create_with_agent_flags L269–279
+ test_create_with_description_flag method method test_create_with_description_flag L261–263
+ test_create_with_secret_visibility method method test_create_with_secret_visibility L281–283
+ test_create_with_tag_flag method method test_create_with_tag_flag L265–267
+ test_create_with_title_flag method method test_create_with_title_flag L256–259
+ empty_file function function empty_file L100–104
+ annotations import import annotations L37–37
+ json import import json L39–39
+ os import import os L40–40
+ pathlib import import pathlib L41–41
+ pytest import import pytest L46–46
+ sys import import sys L42–42
+ time import import time L43–43
+ types import import types L44–44
+ invoke_mist function function invoke_mist L54–75
+ large_file function function large_file L108–112
+ midi_file function function midi_file L91–96
+ python_file function function python_file L79–87
← Older Oldest on task/mist-cli-phase2
All commits
Newer → Latest on task/mist-cli-phase2

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