diff --git a/.agents/install.py b/.agents/install.py index 6f7360e9f..69cbac3bf 100755 --- a/.agents/install.py +++ b/.agents/install.py @@ -281,10 +281,16 @@ def plan(args, model_map, agents): steps = [] warnings = [] seen = set() + protected_targets = [name for name in TARGETS if args.uninstall and name not in args.target] for target in args.target: info = TARGETS[target] skill_dir = os.path.join(base, *info['skills']) - for skill in args.skills: + shared_with = [name for name in protected_targets if TARGETS[name]['skills'] == info['skills']] + if shared_with: + warnings.append('Keeping shared skills in {0}. Include {1} in --target to remove them.' + .format(skill_dir, ' '.join(shared_with))) + skills = () if shared_with else args.skills + for skill in skills: dest = os.path.join(skill_dir, skill) if dest in seen: continue diff --git a/.agents/tests/test_install_shared_skills.py b/.agents/tests/test_install_shared_skills.py new file mode 100644 index 000000000..bcf65ce30 --- /dev/null +++ b/.agents/tests/test_install_shared_skills.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: LGPL-3.0-only +"""Exercise shared-skill retention during uninstall in an isolated project.""" +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + + +INSTALL = Path(__file__).resolve().parents[1] / 'install.py' + + +class SharedSkillsUninstallTests(unittest.TestCase): + def setUp(self): + directory = tempfile.TemporaryDirectory() + self.addCleanup(directory.cleanup) + self.project = Path(directory.name) + + def install(self, *args, expected_exit=0): + result = subprocess.run( + [sys.executable, str(INSTALL), '--scope', 'project', '--project-dir', + str(self.project), *args], + stdin=subprocess.DEVNULL, capture_output=True, text=True, check=False, + ) + self.assertEqual(result.returncode, expected_exit, result.stdout + result.stderr) + return result.stdout + result.stderr + + def test_uninstall_one_tool_keeps_shared_skills(self): + self.install('--target', 'openai', 'google') + skills = self.project / '.agents/skills/thincurr-run' + codex = self.project / '.codex/agents' + gemini = self.project / '.gemini/agents' + self.assertTrue(list(codex.iterdir()) and list(gemini.iterdir())) + self.assertIn('Keeping shared skills', self.install('--target', 'openai', '--uninstall', '--force')) + self.assertTrue(skills.is_dir()) + self.assertFalse(list(codex.iterdir())) + self.assertTrue(list(gemini.iterdir())) + self.install('--target', 'openai', 'google', '--uninstall', '--force') + self.assertFalse(skills.exists()) + self.assertFalse(list(gemini.iterdir())) diff --git a/AGENTS.md b/AGENTS.md index 882dd49ac..9e720bb9a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -100,6 +100,9 @@ free of paths into this repository (use `/scripts/...`), and when add agent frontmatter fields, check that `install.py` translates or drops them: Codex and Gemini CLI reject agent files with unknown keys. +During uninstall, select both `openai` and `google` to remove their shared skills. +Selecting only one removes that tool's agents and keeps the shared skills. + ## Build System OFT uses a two-stage build: `src/utilities/build_libs.py` builds external libraries and