app.py
python
| 1 | """Muse CLI — entry point for the ``muse`` console script. |
| 2 | |
| 3 | Core VCS commands:: |
| 4 | |
| 5 | init status log commit diff |
| 6 | show branch checkout merge reset |
| 7 | revert stash cherry-pick tag domains |
| 8 | |
| 9 | Music-domain semantic commands (impossible in Git):: |
| 10 | |
| 11 | notes list every note in a MIDI track as musical notation |
| 12 | note-log note-level commit history for a track |
| 13 | note-blame per-bar attribution — which commit wrote these notes? |
| 14 | harmony chord analysis and key detection |
| 15 | piano-roll ASCII piano roll visualization |
| 16 | note-hotspots bar-level churn leaderboard |
| 17 | velocity-profile dynamic range and velocity histogram |
| 18 | transpose transpose all notes by N semitones (agent command) |
| 19 | mix combine two MIDI tracks into one (agent command) |
| 20 | music-query music DSL predicate search over commit history |
| 21 | music-check enforce musical invariant rules (polyphony, range, key, fifths) |
| 22 | |
| 23 | Code-domain semantic commands — symbol graph:: |
| 24 | |
| 25 | symbols list every semantic symbol in a snapshot |
| 26 | symbol-log track a single symbol through commit history |
| 27 | detect-refactor report semantic refactoring operations across commits |
| 28 | grep search the symbol graph by name / kind / language |
| 29 | blame show which commit last touched a specific symbol |
| 30 | hotspots symbol churn leaderboard — which functions change most |
| 31 | stable symbol stability leaderboard — your bedrock |
| 32 | coupling file co-change analysis — hidden dependencies |
| 33 | compare semantic comparison between any two historical snapshots |
| 34 | languages language and symbol-type breakdown |
| 35 | patch surgical semantic patch — modify exactly one symbol (all-language validation) |
| 36 | query symbol graph predicate DSL — OR, NOT, grouping, --all-commits temporal search |
| 37 | query-history temporal symbol search across a commit range |
| 38 | deps import graph + Python call-graph with --reverse |
| 39 | find-symbol cross-commit, cross-branch content_id / name search |
| 40 | |
| 41 | Code-domain semantic commands — call-graph tier:: |
| 42 | |
| 43 | impact transitive blast-radius — what breaks if this function changes? |
| 44 | dead dead code detection — symbols with no callers and no importers |
| 45 | coverage class interface call-coverage — which methods are actually used? |
| 46 | |
| 47 | Code-domain semantic commands — provenance & topology:: |
| 48 | |
| 49 | lineage full provenance chain of a symbol through commit history |
| 50 | api-surface public API surface and how it changed between commits |
| 51 | codemap semantic topology — cycles, centrality, boundary files |
| 52 | clones find exact and near-duplicate symbols across the snapshot |
| 53 | checkout-symbol restore a historical version of a specific symbol |
| 54 | semantic-cherry-pick cherry-pick named symbols from a historical commit |
| 55 | |
| 56 | Code-domain semantic commands — index acceleration:: |
| 57 | |
| 58 | index manage local indexes: status, rebuild symbol_history / hash_occurrence |
| 59 | |
| 60 | Multi-agent coordination commands:: |
| 61 | |
| 62 | reserve advisory symbol reservation — announce intent before editing |
| 63 | intent declare a specific operation before executing it |
| 64 | forecast predict merge conflicts from active reservations and intents |
| 65 | plan-merge dry-run semantic merge plan — classify conflicts without writing |
| 66 | shard partition the codebase into N low-coupling work zones |
| 67 | reconcile recommend merge ordering and integration strategy |
| 68 | """ |
| 69 | from __future__ import annotations |
| 70 | |
| 71 | import typer |
| 72 | |
| 73 | from muse.cli.commands import ( |
| 74 | api_surface, |
| 75 | attributes, |
| 76 | blame, |
| 77 | branch, |
| 78 | cherry_pick, |
| 79 | checkout, |
| 80 | checkout_symbol, |
| 81 | clones, |
| 82 | codemap, |
| 83 | commit, |
| 84 | compare, |
| 85 | coupling, |
| 86 | coverage, |
| 87 | dead, |
| 88 | deps, |
| 89 | detect_refactor, |
| 90 | diff, |
| 91 | domains, |
| 92 | find_symbol, |
| 93 | forecast, |
| 94 | grep, |
| 95 | harmony, |
| 96 | hotspots, |
| 97 | impact, |
| 98 | index_rebuild, |
| 99 | init, |
| 100 | intent, |
| 101 | languages, |
| 102 | lineage, |
| 103 | log, |
| 104 | merge, |
| 105 | mix, |
| 106 | midi_check, |
| 107 | midi_query, |
| 108 | note_blame, |
| 109 | note_hotspots, |
| 110 | note_log, |
| 111 | notes, |
| 112 | patch, |
| 113 | piano_roll, |
| 114 | plan_merge, |
| 115 | query, |
| 116 | query_history, |
| 117 | reconcile, |
| 118 | reserve, |
| 119 | reset, |
| 120 | revert, |
| 121 | semantic_cherry_pick, |
| 122 | shard, |
| 123 | show, |
| 124 | stable, |
| 125 | stash, |
| 126 | status, |
| 127 | symbol_log, |
| 128 | symbols, |
| 129 | tag, |
| 130 | breakage, |
| 131 | invariants, |
| 132 | transpose, |
| 133 | velocity_profile, |
| 134 | ) |
| 135 | |
| 136 | cli = typer.Typer( |
| 137 | name="muse", |
| 138 | help="Muse — domain-agnostic version control for multidimensional state.", |
| 139 | no_args_is_help=True, |
| 140 | ) |
| 141 | |
| 142 | # Core VCS |
| 143 | cli.add_typer(attributes.app, name="attributes", help="Display .museattributes merge-strategy rules.") |
| 144 | cli.add_typer(init.app, name="init", help="Initialise a new Muse repository.") |
| 145 | cli.add_typer(commit.app, name="commit", help="Record the current working tree as a new version.") |
| 146 | cli.add_typer(status.app, name="status", help="Show working-tree drift against HEAD.") |
| 147 | cli.add_typer(log.app, name="log", help="Display commit history.") |
| 148 | cli.add_typer(diff.app, name="diff", help="Compare working tree against HEAD, or two commits.") |
| 149 | cli.add_typer(show.app, name="show", help="Inspect a commit: metadata, diff, files.") |
| 150 | cli.add_typer(branch.app, name="branch", help="List, create, or delete branches.") |
| 151 | cli.add_typer(checkout.app, name="checkout", help="Switch branches or restore working tree from a commit.") |
| 152 | cli.add_typer(merge.app, name="merge", help="Three-way merge a branch into the current branch.") |
| 153 | cli.add_typer(reset.app, name="reset", help="Move HEAD to a prior commit.") |
| 154 | cli.add_typer(revert.app, name="revert", help="Create a new commit that undoes a prior commit.") |
| 155 | cli.add_typer(cherry_pick.app, name="cherry-pick", help="Apply a specific commit's changes on top of HEAD.") |
| 156 | cli.add_typer(stash.app, name="stash", help="Shelve and restore uncommitted changes.") |
| 157 | cli.add_typer(tag.app, name="tag", help="Attach and query semantic tags on commits.") |
| 158 | cli.add_typer(domains.app, name="domains", help="Domain plugin dashboard — list capabilities and scaffold new domains.") |
| 159 | |
| 160 | # MIDI-domain commands |
| 161 | cli.add_typer(notes.app, name="notes", help="[midi] List every note in a MIDI track as musical notation.") |
| 162 | cli.add_typer(note_log.app, name="note-log", help="[midi] Note-level commit history — which notes were added or removed in each commit.") |
| 163 | cli.add_typer(note_blame.app, name="note-blame", help="[midi] Per-bar attribution — which commit introduced the notes in this bar?") |
| 164 | cli.add_typer(harmony.app, name="harmony", help="[midi] Chord analysis and key detection from MIDI note content.") |
| 165 | cli.add_typer(piano_roll.app, name="piano-roll", help="[midi] ASCII piano roll visualization of a MIDI track.") |
| 166 | cli.add_typer(note_hotspots.app, name="note-hotspots", help="[midi] Bar-level churn leaderboard — which bars change most across commits.") |
| 167 | cli.add_typer(velocity_profile.app, name="velocity-profile", help="[midi] Dynamic range and velocity histogram for a MIDI track.") |
| 168 | cli.add_typer(transpose.app, name="transpose", help="[midi] Transpose all notes in a MIDI track by N semitones.") |
| 169 | cli.add_typer(mix.app, name="mix", help="[midi] Combine notes from two MIDI tracks into a single output track.") |
| 170 | cli.add_typer(midi_query.app, name="midi-query", help="[midi] MIDI DSL predicate query over commit history — bars, chords, agents, pitches.") |
| 171 | cli.add_typer(midi_check.app, name="midi-check", help="[midi] Enforce MIDI invariant rules (polyphony, pitch range, key consistency, parallel fifths).") |
| 172 | |
| 173 | # Code-domain commands |
| 174 | cli.add_typer(symbols.app, name="symbols", help="[code] List every semantic symbol (function, class, method…) in a snapshot.") |
| 175 | cli.add_typer(symbol_log.app, name="symbol-log", help="[code] Track a single symbol through the full commit history.") |
| 176 | cli.add_typer(detect_refactor.app, name="detect-refactor", help="[code] Detect semantic refactoring operations (renames, moves, extractions) across commits.") |
| 177 | cli.add_typer(grep.app, name="grep", help="[code] Search the symbol graph by name, kind, or language — not file text.") |
| 178 | cli.add_typer(blame.app, name="blame", help="[code] Show which commit last touched a specific symbol (function, class, method).") |
| 179 | cli.add_typer(hotspots.app, name="hotspots", help="[code] Symbol churn leaderboard — which functions change most often.") |
| 180 | cli.add_typer(stable.app, name="stable", help="[code] Symbol stability leaderboard — the bedrock of your codebase.") |
| 181 | cli.add_typer(coupling.app, name="coupling", help="[code] File co-change analysis — discover hidden semantic dependencies.") |
| 182 | cli.add_typer(compare.app, name="compare", help="[code] Deep semantic comparison between any two historical snapshots.") |
| 183 | cli.add_typer(languages.app, name="languages", help="[code] Language and symbol-type breakdown of a snapshot.") |
| 184 | cli.add_typer(patch.app, name="patch", help="[code] Surgical semantic patch — modify exactly one named symbol (all-language syntax validation).") |
| 185 | cli.add_typer(query.app, name="query", help="[code] Symbol graph predicate DSL — OR/NOT/grouping, --all-commits temporal search.") |
| 186 | cli.add_typer(query_history.app, name="query-history", help="[code] Temporal symbol search — first seen, last seen, change count across a commit range.") |
| 187 | cli.add_typer(deps.app, name="deps", help="[code] Import graph + Python call-graph; --reverse for callers/importers.") |
| 188 | cli.add_typer(find_symbol.app, name="find-symbol", help="[code] Cross-commit, cross-branch symbol search by hash, name, or kind.") |
| 189 | cli.add_typer(impact.app, name="impact", help="[code] Transitive blast-radius — every caller affected if this symbol changes.") |
| 190 | cli.add_typer(dead.app, name="dead", help="[code] Dead code candidates — symbols with no callers and no importers.") |
| 191 | cli.add_typer(coverage.app, name="coverage", help="[code] Class interface call-coverage — which methods are actually called?") |
| 192 | cli.add_typer(lineage.app, name="lineage", help="[code] Full provenance chain of a symbol — created, renamed, moved, copied, deleted.") |
| 193 | cli.add_typer(api_surface.app, name="api-surface", help="[code] Public API surface at a commit; --diff to show added/removed/changed symbols.") |
| 194 | cli.add_typer(codemap.app, name="codemap", help="[code] Semantic topology — module sizes, import cycles, centrality, boundary files.") |
| 195 | cli.add_typer(clones.app, name="clones", help="[code] Find exact and near-duplicate symbols (body_hash / signature_id clusters).") |
| 196 | cli.add_typer(checkout_symbol.app, name="checkout-symbol", help="[code] Restore a historical version of one symbol into the working tree.") |
| 197 | cli.add_typer(semantic_cherry_pick.app, name="semantic-cherry-pick", help="[code] Cherry-pick named symbols from a historical commit into the working tree.") |
| 198 | cli.add_typer(index_rebuild.app, name="index", help="[code] Manage local indexes: status, rebuild symbol_history / hash_occurrence.") |
| 199 | cli.add_typer(breakage.app, name="breakage", help="[code] Detect symbol-level structural breakage in the working tree vs HEAD.") |
| 200 | cli.add_typer(invariants.app, name="invariants", help="[code] Enforce architectural rules from .muse/invariants.toml.") |
| 201 | |
| 202 | # Multi-agent coordination commands |
| 203 | cli.add_typer(reserve.app, name="reserve", help="[coord] Advisory symbol reservation — announce intent before editing.") |
| 204 | cli.add_typer(intent.app, name="intent", help="[coord] Declare a specific operation before executing it.") |
| 205 | cli.add_typer(forecast.app, name="forecast", help="[coord] Predict merge conflicts from active reservations and intents.") |
| 206 | cli.add_typer(plan_merge.app, name="plan-merge", help="[coord] Dry-run semantic merge plan — classify conflicts without writing.") |
| 207 | cli.add_typer(shard.app, name="shard", help="[coord] Partition the codebase into N low-coupling work zones for parallel agents.") |
| 208 | cli.add_typer(reconcile.app, name="reconcile", help="[coord] Recommend merge ordering and integration strategy from coordination state.") |
| 209 | |
| 210 | |
| 211 | if __name__ == "__main__": |
| 212 | cli() |