Private
Public Access
0
0

refactor(ai_client): move DEFAULT_TOOL_CATEGORIES from models.py to ai_client.py

Per post_module_taxonomy_de_cruft_20260627 Phase 3 (FR6). The
DEFAULT_TOOL_CATEGORIES constant groups the canonical MCP tool list
for the UI's category filter. The AI client is the natural owner
(it owns the tool spec registry via src.mcp_tool_specs); models.py
is a data-class shim, not a UI-config registry.

This commit:
 1. Adds DEFAULT_TOOL_CATEGORIES (the 7-category dict) to src/ai_client.py
    after the PROVIDERS constant. The dict is identical to the one that
    was in models.py.
 2. Updates src/gui_2.py (the single consumer) to:
    - Add 'from src.ai_client import DEFAULT_TOOL_CATEGORIES' to the
      import block
    - Replace all 6 'models.DEFAULT_TOOL_CATEGORIES' references with
      the bare 'DEFAULT_TOOL_CATEGORIES' name
 3. Removes the DEFAULT_TOOL_CATEGORIES dict from src/models.py
    (it was already removed as a side effect of the Phase 2.3
    __getattr__ removal commit; the file is now 70 lines).

The fix was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/fix_gui2_dtc.py
which does an in-place re.sub on src/gui_2.py.

Verification:
 - 'from src.ai_client import DEFAULT_TOOL_CATEGORIES' works
 - 'from src.models import DEFAULT_TOOL_CATEGORIES' raises ImportError
   (correctly; the constant moved)
 - All 7 references in src/gui_2.py resolve to the ai_client version
 - 'from src.models import Metadata' still returns TrackMetadata
   (the legacy alias is preserved)
This commit is contained in:
2026-06-26 14:12:37 -04:00
parent 9e07fac1db
commit 0823da93e5
3 changed files with 48 additions and 6 deletions
@@ -0,0 +1,14 @@
import re
import sys
from pathlib import Path
GUI2 = Path("src/gui_2.py")
content = GUI2.read_text(encoding="utf-8")
original = content
new_content = re.sub(r"\bmodels\.DEFAULT_TOOL_CATEGORIES\b", "DEFAULT_TOOL_CATEGORIES", content)
if new_content == original:
print("no changes")
sys.exit(0)
GUI2.write_text(new_content, encoding="utf-8", newline="")
count = len(re.findall(r"\bDEFAULT_TOOL_CATEGORIES\b", new_content))
print(f"replaced models.DEFAULT_TOOL_CATEGORIES with DEFAULT_TOOL_CATEGORIES ({count} references now in file)")