zettcode-skills 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zettcode/skills/__init__.py +13 -0
- zettcode/skills/mentions.py +47 -0
- zettcode/skills/plugin.py +51 -0
- zettcode/skills/py.typed +0 -0
- zettcode_skills-0.4.1.dist-info/METADATA +19 -0
- zettcode_skills-0.4.1.dist-info/RECORD +8 -0
- zettcode_skills-0.4.1.dist-info/WHEEL +4 -0
- zettcode_skills-0.4.1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""The skills of ZettCode: the ``@`` provider that offers them to the composer, and the extension that lists them for
|
|
2
|
+
the model and lets it read one.
|
|
3
|
+
|
|
4
|
+
A part of the program that lives in a distribution of its own, found through the ``zettcode.agent`` entry point and
|
|
5
|
+
activated with the agent's other parts. ``[skills] enabled`` in the configuration is what turns it off.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .mentions import SkillMentions
|
|
11
|
+
from .plugin import SkillResources, SkillTool
|
|
12
|
+
|
|
13
|
+
__all__ = ["SkillMentions", "SkillResources", "SkillTool"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""The ``@`` provider for skills."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Sequence
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from zett_agent.extensions.skill import SkillExtension
|
|
9
|
+
|
|
10
|
+
from zettcode.mention import Mention, MentionProvider
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class SkillMentions(MentionProvider):
|
|
14
|
+
"""Skills discovered from the configured roots, named for the model to load."""
|
|
15
|
+
|
|
16
|
+
kind = "skill"
|
|
17
|
+
#: A skill is the more specific thing to mean when a repository holds a file of the same name, so it is asked
|
|
18
|
+
#: ahead of the files whatever order the plugins were registered in (a session still goes first).
|
|
19
|
+
precedence = -10
|
|
20
|
+
|
|
21
|
+
def __init__(self, roots: Sequence[Path]) -> None:
|
|
22
|
+
"""Discover skills once, the same way the agent's skill extension does."""
|
|
23
|
+
self._skills = {skill.name: skill for skill in SkillExtension(roots).skills}
|
|
24
|
+
|
|
25
|
+
def candidates(self, query: str) -> Sequence[Mention]:
|
|
26
|
+
"""List the discovered skills whose name starts with ``query``."""
|
|
27
|
+
return tuple(
|
|
28
|
+
Mention(token=f"@{skill.name}", kind=self.kind, name=skill.name, description=skill.description)
|
|
29
|
+
for skill in self._skills.values()
|
|
30
|
+
if skill.name.startswith(query)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def expand(self, name: str) -> str | None:
|
|
34
|
+
"""Name the skill and leave loading its instructions to the model.
|
|
35
|
+
|
|
36
|
+
The system prompt already catalogs every skill, and ``read_skill`` loads
|
|
37
|
+
the file, so the message only has to say which one the user meant;
|
|
38
|
+
inlining the body would spend context on instructions that may not be
|
|
39
|
+
needed.
|
|
40
|
+
"""
|
|
41
|
+
skill = self._skills.get(name)
|
|
42
|
+
if skill is None:
|
|
43
|
+
return None
|
|
44
|
+
return (
|
|
45
|
+
f'Use the "{skill.name}" skill: call read_skill(name="{skill.name}") '
|
|
46
|
+
"if its instructions are useful and not already in context."
|
|
47
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""The plugins that offer skills: to the composer as ``@`` references, and to the model as a list and a tool."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from zettcode.engine.plugins.plugin import Plugin, PluginSetting
|
|
8
|
+
|
|
9
|
+
from .mentions import SkillMentions
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING: # pragma: no cover - annotations only
|
|
12
|
+
from zett_agent.extensions.base import AgentExtension
|
|
13
|
+
|
|
14
|
+
from zettcode.engine.plugins.context import PluginContext
|
|
15
|
+
from zettcode.engine.plugins.state import AgentBuild
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SkillResources(Plugin):
|
|
19
|
+
"""The ``@`` resource provider for the skills on this machine.
|
|
20
|
+
|
|
21
|
+
Registering it from a plugin rather than inside the shell keeps the shell generic: it merges whatever providers
|
|
22
|
+
the bundle holds, and the skills are simply one of them.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
name = "skills"
|
|
26
|
+
setting = PluginSetting("skills_enabled", "skills")
|
|
27
|
+
|
|
28
|
+
def activate(self, ctx: PluginContext) -> None:
|
|
29
|
+
"""Offer the discovered skills as ``@`` resources, when skills are on."""
|
|
30
|
+
if ctx.config.skills_enabled:
|
|
31
|
+
ctx.agent.register_mention(SkillMentions(ctx.config.skill_search_roots()))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class SkillTool(Plugin):
|
|
35
|
+
"""The skills the model can load: their list in the prompt and the tool that reads one."""
|
|
36
|
+
|
|
37
|
+
name = "skill-tool"
|
|
38
|
+
description = "Skills the model can load"
|
|
39
|
+
|
|
40
|
+
def activate(self, ctx: PluginContext) -> None:
|
|
41
|
+
"""Hand the agent the skills found under the configured roots, when skills are on."""
|
|
42
|
+
config = ctx.config
|
|
43
|
+
if not config.skills_enabled:
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
def build(_: AgentBuild) -> AgentExtension:
|
|
47
|
+
from zett_agent.extensions.skill import SkillExtension
|
|
48
|
+
|
|
49
|
+
return SkillExtension(config.skill_search_roots())
|
|
50
|
+
|
|
51
|
+
ctx.agent.register_extension_factory("SkillExtension", build)
|
zettcode/skills/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zettcode-skills
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: The skills of ZettCode: the @ references and the tool that lets the model read one, as a part of the agent that lives apart from it
|
|
5
|
+
Project-URL: Repository, https://github.com/Chang-LeHung/zettcode
|
|
6
|
+
Author: Chang-LeHung
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: agent,skills,zettcode
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: zett-agent<0.3,>=0.2.7
|
|
19
|
+
Requires-Dist: zettcode-engine
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
zettcode/skills/__init__.py,sha256=udywuXGnKJHVs7ZJLgvOjxCGDEDOyfFt7BB_-8pHShM,554
|
|
2
|
+
zettcode/skills/mentions.py,sha256=bmRe2AIqm--sUWhFKsR2XaOyPX5Jjet6nC6E3718FLE,1876
|
|
3
|
+
zettcode/skills/plugin.py,sha256=jBEUpO6s4gqEj6H2wLIMf8MC0ldUQuLh_P2WyeRRGQo,1824
|
|
4
|
+
zettcode/skills/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
zettcode_skills-0.4.1.dist-info/METADATA,sha256=_RI2AAzvdzuwAUCYZgCsW2dqzN_s43OTlk7QIjhjQIQ,826
|
|
6
|
+
zettcode_skills-0.4.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
7
|
+
zettcode_skills-0.4.1.dist-info/entry_points.txt,sha256=QhYOHNFzsvThnzX7E5Ay0Gj21iavNXp61V6hlEVrJ8Y,110
|
|
8
|
+
zettcode_skills-0.4.1.dist-info/RECORD,,
|