fix(mma_exec): remove hardcoded C:\projects\misc\setup_*.ps1 paths — rely on PATH

This commit is contained in:
2026-03-02 16:42:11 -05:00
parent 3322b630c2
commit b30f040c7b
3 changed files with 26 additions and 9 deletions

View File

@@ -188,11 +188,7 @@ def execute_agent(role: str, prompt: str, docs: list[str], timeout: int | None =
print(f"Error inlining {doc}: {e}")
command_text += f"\n\nTASK: {prompt}\n\n"
# Spawn claude CLI non-interactively via PowerShell
ps_command = (
"if (Test-Path 'C:\\projects\\misc\\setup_claude.ps1') "
"{ . 'C:\\projects\\misc\\setup_claude.ps1' }; "
f"claude --model {model} --print --dangerously-skip-permissions"
)
ps_command = f"claude --model {model} --print --dangerously-skip-permissions"
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
try:
env = os.environ.copy()

View File

@@ -194,10 +194,7 @@ def execute_agent(role: str, prompt: str, docs: list[str], debug: bool = False,
command_text += f"\n\nTASK: {prompt}\n\n"
# Use subprocess with input to pipe the prompt via stdin, avoiding WinError 206.
# We use -p 'mma_task' to ensure non-interactive (headless) mode and valid parsing.
ps_command = (
f"if (Test-Path 'C:\\projects\\misc\\setup_gemini.ps1') {{ . 'C:\\projects\\misc\\setup_gemini.ps1' }}; "
f"gemini -p '{role}' --output-format json --model {model}"
)
ps_command = f"gemini -p '{role}' --output-format json --model {model}"
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
try:
env = os.environ.copy()

View File

@@ -67,5 +67,29 @@ class TestArchBoundaryPhase1(unittest.TestCase):
captured_input = mock_run.call_args[1].get('input', '')
self.assertIn('DEPENDENCY SKELETON: mcp_client.py', captured_input)
def test_mma_exec_no_hardcoded_path(self):
"""TEST 4: mma_exec.execute_agent must not contain hardcoded machine paths."""
import importlib as il
import sys as _sys
scripts_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'scripts'))
if scripts_path not in _sys.path:
_sys.path.insert(0, scripts_path)
import mma_exec as _mma
il.reload(_mma)
source = inspect.getsource(_mma.execute_agent)
self.assertNotIn('C:\\projects\\misc', source, "Hardcoded machine path must be removed from mma_exec.execute_agent")
def test_claude_mma_exec_no_hardcoded_path(self):
"""TEST 5: claude_mma_exec.execute_agent must not contain hardcoded machine paths."""
import importlib as il
import sys as _sys
scripts_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'scripts'))
if scripts_path not in _sys.path:
_sys.path.insert(0, scripts_path)
import claude_mma_exec as _cmma
il.reload(_cmma)
source = inspect.getsource(_cmma.execute_agent)
self.assertNotIn('C:\\projects\\misc', source, "Hardcoded machine path must be removed from claude_mma_exec.execute_agent")
if __name__ == '__main__':
unittest.main()