fix(skill): remove auto activation setting

This commit is contained in:
Junyan Qin
2026-05-13 00:51:16 +08:00
parent a565f3e022
commit 4db0f20dc4
13 changed files with 33 additions and 90 deletions
+24 -8
View File
@@ -22,7 +22,6 @@ def _make_skill_data(
instructions='Do something',
package_root='',
entry_file='SKILL.md',
auto_activate=True,
**kwargs,
):
return {
@@ -32,7 +31,6 @@ def _make_skill_data(
'instructions': instructions,
'package_root': package_root,
'entry_file': entry_file,
'auto_activate': auto_activate,
**kwargs,
}
@@ -150,6 +148,30 @@ class TestSkillActivationHelper:
assert activation.cleaned_content == 'Working on it.'
assert set(query.variables[ACTIVATED_SKILLS_KEY].keys()) == {'primary', 'aux'}
def test_prepare_skill_activation_ignores_skills_not_bound_to_pipeline(self):
from langbot.pkg.skill.activation import prepare_skill_activation
from langbot.pkg.provider.tools.loaders.skill import ACTIVATED_SKILLS_KEY, PIPELINE_BOUND_SKILLS_KEY
from langbot.pkg.skill.manager import SkillManager
ap = _make_ap()
mgr = SkillManager(ap)
mgr.skills = {
'primary': _make_skill_data(name='primary', instructions='Primary instructions'),
'hidden': _make_skill_data(name='hidden', instructions='Hidden instructions'),
}
ap.skill_mgr = mgr
query = SimpleNamespace(variables={PIPELINE_BOUND_SKILLS_KEY: ['primary']}, use_funcs=[])
activation = prepare_skill_activation(
ap,
query,
'[ACTIVATE_SKILL: hidden]\n[ACTIVATE_SKILL: primary]\nWorking on it.',
)
assert activation is not None
assert activation.activated_skill_names == ['primary']
assert set(query.variables[ACTIVATED_SKILLS_KEY].keys()) == {'primary'}
class TestSkillPathHelpers:
def test_get_visible_skills_filters_by_bound_names(self):
@@ -252,7 +274,6 @@ class TestSkillAuthoringToolLoader:
'display_name': 'Prompt Skill',
'description': 'Prompt only skill',
'instructions': 'Follow these steps carefully.',
'auto_activate': False,
},
SimpleNamespace(),
)
@@ -263,7 +284,6 @@ class TestSkillAuthoringToolLoader:
'display_name': 'Prompt Skill',
'description': 'Prompt only skill',
'instructions': 'Follow these steps carefully.',
'auto_activate': False,
}
)
assert result == {
@@ -342,7 +362,6 @@ class TestSkillAuthoringToolLoader:
'name': 'time-now',
'description': 'Fixed to Beijing time',
'instructions': 'Always use Asia/Shanghai and never offer other timezones.',
'auto_activate': True,
},
SimpleNamespace(),
)
@@ -353,7 +372,6 @@ class TestSkillAuthoringToolLoader:
'name': 'time-now',
'description': 'Fixed to Beijing time',
'instructions': 'Always use Asia/Shanghai and never offer other timezones.',
'auto_activate': True,
},
)
assert result == {
@@ -400,7 +418,6 @@ class TestSkillAuthoringToolLoader:
'display_name': 'Cloned Skill',
'description': 'Imported from clone',
'instructions': 'Do work',
'auto_activate': True,
}
),
create_skill=AsyncMock(return_value=_make_skill_data(name='cloned-skill', package_root='/repo/root')),
@@ -430,7 +447,6 @@ class TestSkillAuthoringToolLoader:
'description': 'Imported from clone',
'instructions': 'Do work',
'package_root': os.path.realpath(repo_dir),
'auto_activate': True,
}
)
assert result['imported'] is True
+1 -13
View File
@@ -15,14 +15,11 @@ def _create_skill_file(
name: str = 'imported-skill',
display_name: str = '',
description: str = 'Imported from local directory',
auto_activate: bool = True,
body: str = 'Skill instructions',
) -> None:
frontmatter = ['name: ' + name, 'description: ' + description]
if display_name:
frontmatter.insert(1, 'display_name: ' + display_name)
if not auto_activate:
frontmatter.append('auto_activate: false')
path.write_text(
'---\n' + '\n'.join(frontmatter) + f'\n---\n\n{body}\n',
@@ -83,7 +80,6 @@ async def test_create_skill_import_preserves_existing_skill_content_when_form_fi
source_dir / 'SKILL.md',
display_name='Imported Skill',
description='Imported description',
auto_activate=False,
body='Original instructions',
)
@@ -96,7 +92,6 @@ async def test_create_skill_import_preserves_existing_skill_content_when_form_fi
'package_root': str(managed_root.resolve()),
'description': 'Imported description',
'instructions': 'Original instructions',
'auto_activate': False,
}
)
@@ -115,7 +110,6 @@ async def test_create_skill_import_preserves_existing_skill_content_when_form_fi
content = (managed_root / 'SKILL.md').read_text(encoding='utf-8')
assert 'display_name: Imported Skill' in content
assert 'description: Imported description' in content
assert 'auto_activate: false' in content
assert content.endswith('Original instructions')
@@ -139,7 +133,6 @@ async def test_create_skill_reuses_existing_managed_directory_without_copying(tm
'package_root': str(managed_root.resolve()),
'description': 'Already managed',
'instructions': 'Managed instructions',
'auto_activate': True,
}
)
@@ -167,11 +160,7 @@ def _build_skill_archive() -> bytes:
with zipfile.ZipFile(stream, 'w') as archive:
archive.writestr(
'demo-repo-main/skills/nested-skill/SKILL.md',
'---\n'
'name: imported-skill\n'
'description: Imported from GitHub archive\n'
'---\n\n'
'Skill instructions\n',
'---\nname: imported-skill\ndescription: Imported from GitHub archive\n---\n\nSkill instructions\n',
)
return stream.getvalue()
@@ -336,7 +325,6 @@ async def test_update_skill_rejects_package_root_change(tmp_path):
'display_name': 'Writer',
'description': 'Writes things',
'instructions': 'Do work',
'auto_activate': True,
}
)