fix(mma_exec): remove hardcoded C:\projects\misc\setup_*.ps1 paths — rely on PATH
This commit is contained in:
@@ -188,11 +188,7 @@ def execute_agent(role: str, prompt: str, docs: list[str], timeout: int | None =
|
|||||||
print(f"Error inlining {doc}: {e}")
|
print(f"Error inlining {doc}: {e}")
|
||||||
command_text += f"\n\nTASK: {prompt}\n\n"
|
command_text += f"\n\nTASK: {prompt}\n\n"
|
||||||
# Spawn claude CLI non-interactively via PowerShell
|
# Spawn claude CLI non-interactively via PowerShell
|
||||||
ps_command = (
|
ps_command = f"claude --model {model} --print --dangerously-skip-permissions"
|
||||||
"if (Test-Path 'C:\\projects\\misc\\setup_claude.ps1') "
|
|
||||||
"{ . 'C:\\projects\\misc\\setup_claude.ps1' }; "
|
|
||||||
f"claude --model {model} --print --dangerously-skip-permissions"
|
|
||||||
)
|
|
||||||
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
|
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
|
||||||
try:
|
try:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
|||||||
@@ -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"
|
command_text += f"\n\nTASK: {prompt}\n\n"
|
||||||
# Use subprocess with input to pipe the prompt via stdin, avoiding WinError 206.
|
# 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.
|
# We use -p 'mma_task' to ensure non-interactive (headless) mode and valid parsing.
|
||||||
ps_command = (
|
ps_command = f"gemini -p '{role}' --output-format json --model {model}"
|
||||||
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}"
|
|
||||||
)
|
|
||||||
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
|
cmd = ['powershell.exe', '-NoProfile', '-Command', ps_command]
|
||||||
try:
|
try:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
|||||||
@@ -67,5 +67,29 @@ class TestArchBoundaryPhase1(unittest.TestCase):
|
|||||||
captured_input = mock_run.call_args[1].get('input', '')
|
captured_input = mock_run.call_args[1].get('input', '')
|
||||||
self.assertIn('DEPENDENCY SKELETON: mcp_client.py', captured_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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user