diff --git a/scripts/lib/semantic-retrieval.py b/scripts/lib/semantic-retrieval.py index 67a5521..9f973c2 100644 --- a/scripts/lib/semantic-retrieval.py +++ b/scripts/lib/semantic-retrieval.py @@ -111,10 +111,11 @@ def sync(root, home, clients, enabled, dry_run, update): for client in clients: command_args = [client, 'mcp', 'add'] if client == 'claude': - command_args += ['--scope', 'user', '-e', f'HF_HOME={target / "model-cache"}'] + command_args += [NAME, '--scope', 'user', '-e', f'HF_HOME={target / "model-cache"}'] else: command_args += ['--env', f'HF_HOME={target / "model-cache"}'] - command_args += [NAME] + arguments + command_args += [NAME] + command_args += arguments if update and client in existing_clients: command(client, [client, 'mcp', 'remove', NAME] + (['--scope', 'user'] if client == 'claude' else []), home, False) command(client, command_args, home, False) diff --git a/scripts/test-semantic-retrieval.py b/scripts/test-semantic-retrieval.py index 4853d96..3daa0a0 100644 --- a/scripts/test-semantic-retrieval.py +++ b/scripts/test-semantic-retrieval.py @@ -13,6 +13,23 @@ SPEC.loader.exec_module(MODULE) class SemanticRetrievalTests(unittest.TestCase): + def test_claude_registration_places_name_before_environment(self): + with tempfile.TemporaryDirectory() as directory: + home = Path(directory) / 'home' + calls = [] + original = MODULE.command + original_runtime = MODULE.ensure_runtime + MODULE.command = lambda client, arguments, home, dry_run: calls.append((client, arguments)) + MODULE.ensure_runtime = lambda target, dry_run: target / '.venv' / 'bin' / 'python' + try: + MODULE.sync(ROOT, home, ['claude'], True, False, False) + finally: + MODULE.command = original + MODULE.ensure_runtime = original_runtime + add = calls[0][1] + self.assertEqual(add[:5], ['claude', 'mcp', 'add', MODULE.NAME, '--scope']) + self.assertIn('-e', add) + def test_disable_removes_owned_runtime_and_registration(self): with tempfile.TemporaryDirectory() as directory: home = Path(directory) / 'home'