gabriel / muse public
refactor BREAKING task/eliminate-prod-clones #2 / 2
AI Agent gabriel · 59 days ago · Apr 19, 2026 · Diff

refactor: eliminate 9 prod clone groups — extract to canonical homes

Identified via `muse code query "kind=function" --unique-bodies`.

Batch 1 — core/coordination clones (3 functions × 2 files = 6 definitions → 2 imports): _coord_dir, _now_utc, _parse_dt were copy-pasted into dag.py and task_queue.py. Both now import from coordination.py (the canonical source).

Batch 2 — _is_test_file + _TEST_PATTERNS (2 copies → 1 in _query.py): gravity.py and semantic_test_coverage.py both defined identical _TEST_PATTERNS and _is_test_file. Extracted to plugins/code/_query.py as is_test_file() (public). Both callers updated; unused `import re` removed from each.

Batch 3 — _normalise_language + _LANG_CANONICAL (4 copies → 1 in _query.py): compare.py, grep.py, hotspots.py, stable.py each built _LANG_CANONICAL from _SUFFIX_LANG (already in _query.py) and defined identical _normalise_language. Extracted to _query.py as normalise_language() (public). All 4 callers updated; _SUFFIX_LANG import removed from each.

Batch 4 — _use_color (2 copies → muse/core/terminal.py): conflicts.py and merge.py both defined the identical NO_COLOR-aware colour check. New muse/core/terminal.py provides use_color(). Both callers updated; unused os/sys imports removed from conflicts.py.

sha256:e72374ff5644e8edbe8baa0f85fa82d40f7041d4c9acfd747855a5bd105846b7 sha
sha256:412c5056eb51843c11992571dc854640454478f1748b63670d64ad2d40d89e7b snapshot

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