cgcardona / muse public
feat main #84 / 100

feat: code-domain semantic commands + code tour de force demo (#54)

* feat: add code domain plugin with AST-based semantic versioning

Introduces muse/plugins/code/ — a first-class Muse plugin that treats source code as a structured system of named symbols rather than lines of text.

Key capabilities ---------------- - Python AST parsing via stdlib `ast` (zero new dependencies). Every function, class, method, variable, and import becomes a named symbol with a stable content-addressed identity (SHA-256 of normalized AST). - Semantic content IDs: two functions that differ only in whitespace or comments share the same content_id; reformatting a file produces no structured delta. - Rename detection: same body_hash + different name → ReplaceOp annotated "renamed to <new>". - Move detection: same content_id at a different address across files → cross-file move annotation on the DeleteOp/InsertOp pair. - Symbol-level OT merge: two agents modifying different functions in the same file auto-merge (ops commute); concurrent edits to the same function produce a conflict at address "src/utils.py::function_name" rather than a coarse file conflict. - Language adapter protocol (LanguageAdapter) for future TypeScript, Swift, Go adapters — falls back to file-level raw-bytes tracking for unsupported file types. - Full MuseDomainPlugin + StructuredMergePlugin conformance. - 76 tests: unit (AST parser, symbol diff golden cases, cross-file move annotation), snapshot (museignore, pycache filter, stability), semantic diff (add/remove/rename/reformat functions), merge (symbol- level conflict detection), drift, schema, protocol conformance. - Registered as "code" domain in muse/plugins/registry.py.

All gates pass: mypy strict (0 errors), typing_audit --max-any 0 (0 violations), pytest (773 tests, 0 failures).

* feat: add tree-sitter multi-language support to code plugin

Extends the code domain plugin from Python-only to 11 languages using tree-sitter — the same parsing technology used by GitHub Copilot, VS Code, Neovim, and Zed.

Languages added (all backed by real CSTs, no regex): JavaScript / JSX / MJS / CJS — function, class, method extraction TypeScript / TSX — + interface, type alias, enum, abstract class Go — methods qualified with receiver type (Dog.Bark) Rust — impl methods qualified with type (Dog.bark) Java — class, interface, method, constructor, enum C — function_definition extraction C++ — + class_specifier and struct_specifier C# — class, interface, struct, method, constructor, enum Ruby — class, module, method, singleton_method Kotlin — function, class (with method nesting)

All adapters compute content_id, body_hash, and signature_id from normalized CST text, enabling rename and implementation-change detection across all 11 languages. SEMANTIC_EXTENSIONS now covers 23 file extensions.

Adds 11 tree-sitter dependencies to pyproject.toml. Includes 25 new tests covering symbol extraction, qualified name construction, rename detection, and adapter routing for every supported extension.

* feat: add code-domain semantic commands and tour de force demo

Three new CLI commands impossible in Git:

- muse symbols: list every function, class, method in a snapshot, with content hashes, kind filter, file filter, and JSON output.

- muse symbol-log <address>: track a single named symbol through the full commit DAG — creation, renames, signature changes, implementation changes, cross-file moves — including through rename events where the address itself changes.

- muse detect-refactor: scan a commit range and emit a classified semantic refactoring report: RENAME (body_hash match), MOVE (content_id match), SIGNATURE, IMPLEMENTATION.

Also adds: - docs/demo/tour-de-force-code.md: 11-act narration script for a code plugin demo — from first commit through symbol-level auto-merge, muse symbol-log, muse detect-refactor, and multi-language support. - docs/demo/README.md: demo hub presenting both the music and code demos side by side with the shared architecture explained.

All three commands pass mypy --strict, zero typing_audit violations, 797 tests green.

---------

Co-authored-by: Gabriel Cardona <gabriel@tellurstori.com>

G Gabriel Cardona <cgcardona@gmail.com> · 1d ago Mar 18, 2026 · 062ae392 · parent 9cdb32a8
oldest
newest 17%

Comments

0

No comments yet. Be the first to start the discussion.