fableforge-agent-skills 0.1.0__tar.gz
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.
- fableforge_agent_skills-0.1.0/.github/workflows/release.yml +38 -0
- fableforge_agent_skills-0.1.0/.gitignore +15 -0
- fableforge_agent_skills-0.1.0/LICENSE +21 -0
- fableforge_agent_skills-0.1.0/PKG-INFO +141 -0
- fableforge_agent_skills-0.1.0/README.md +124 -0
- fableforge_agent_skills-0.1.0/__init__.py +0 -0
- fableforge_agent_skills-0.1.0/pyproject.toml +27 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/__init__.py +3 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/cli.py +166 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/decomposition.py +310 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/lora_builder.py +365 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/registry.py +286 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/bash.yaml +18 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/debug.yaml +20 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/edit.yaml +18 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/plan.yaml +19 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/recover.yaml +21 -0
- fableforge_agent_skills-0.1.0/src/agent_skills/skills/verify.yaml +19 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
packages: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-publish:
|
|
14
|
+
name: Build and publish to PyPI
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment:
|
|
17
|
+
name: pypi
|
|
18
|
+
url: https://pypi.org/p/fableforge-agent-skills
|
|
19
|
+
permissions:
|
|
20
|
+
id-token: write
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout code
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: '3.12'
|
|
30
|
+
|
|
31
|
+
- name: Install build dependencies
|
|
32
|
+
run: python -m pip install --upgrade build
|
|
33
|
+
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: python -m build
|
|
36
|
+
|
|
37
|
+
- name: Publish package to PyPI
|
|
38
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 FableForge Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fableforge-agent-skills
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Skill registry, decomposition, and LoRA building for coding agents
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: click>=8.0
|
|
8
|
+
Requires-Dist: peft>=0.7
|
|
9
|
+
Requires-Dist: pydantic>=2.0
|
|
10
|
+
Requires-Dist: pyyaml>=6.0
|
|
11
|
+
Requires-Dist: rich>=13.0
|
|
12
|
+
Requires-Dist: torch>=2.1
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# AgentSkills.org
|
|
19
|
+
|
|
20
|
+
[](LICENSE) [](https://www.python.org/downloads/) [](tests/)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Skill registry, decomposition, and LoRA building for coding agents.
|
|
24
|
+
|
|
25
|
+
## Overview
|
|
26
|
+
|
|
27
|
+
AgentSkills.org provides a framework for extracting, publishing, and building LoRA adapters from recurring skill patterns in agent traces. Think of it as a package manager for agent capabilities.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install agent-skills
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### Install a Skill
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
askill install debug
|
|
41
|
+
askill install edit
|
|
42
|
+
askill list
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Extract Skills from Traces
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
askill decompose traces.jsonl --min-occurrences 3
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Build LoRA Adapters
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
askill build traces.jsonl --base-model Qwen/Qwen2.5-14B --output-dir output/lora
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Programmatic Usage
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from agent_skills import SkillRegistry, SkillDecomposer
|
|
61
|
+
from agent_skills.lora_builder import build_lora
|
|
62
|
+
|
|
63
|
+
# Install and list skills
|
|
64
|
+
registry = SkillRegistry()
|
|
65
|
+
registry.install("debug")
|
|
66
|
+
skills = registry.list_skills()
|
|
67
|
+
|
|
68
|
+
# Extract skills from traces
|
|
69
|
+
decomposer = SkillDecomposer(min_occurrences=3)
|
|
70
|
+
skills = decomposer.extract_skills_from_trace("traces.jsonl")
|
|
71
|
+
clusters = decomposer.cluster_skills()
|
|
72
|
+
|
|
73
|
+
# Build LoRA adapters from skill clusters
|
|
74
|
+
for cluster in clusters:
|
|
75
|
+
adapter = build_lora(cluster, base_model="Qwen/Qwen2.5-14B")
|
|
76
|
+
print(f"Built: {adapter.name} with {adapter.num_examples} examples")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Built-in Skills
|
|
80
|
+
|
|
81
|
+
| Skill | Tools | Description |
|
|
82
|
+
|-------|-------|-------------|
|
|
83
|
+
| **debug** | read, bash, grep | Diagnose and fix errors in code |
|
|
84
|
+
| **edit** | edit, write | Make targeted edits to code files |
|
|
85
|
+
| **verify** | bash, read, grep | Run tests and verify correctness |
|
|
86
|
+
| **recover** | bash, edit, read, grep | Recover from errors and retry |
|
|
87
|
+
| **plan** | question, glob, read | Plan and coordinate multi-step tasks |
|
|
88
|
+
| **bash** | bash | Execute shell commands and scripts |
|
|
89
|
+
|
|
90
|
+
## Skill YAML Format
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
name: debug
|
|
94
|
+
version: "1.0.0"
|
|
95
|
+
description: "Diagnose and fix errors in code"
|
|
96
|
+
category: "core"
|
|
97
|
+
tools:
|
|
98
|
+
- read
|
|
99
|
+
- bash
|
|
100
|
+
- grep
|
|
101
|
+
triggers:
|
|
102
|
+
- "fix the bug"
|
|
103
|
+
- "debug this error"
|
|
104
|
+
author: "your-name"
|
|
105
|
+
license: "MIT"
|
|
106
|
+
tags:
|
|
107
|
+
- debugging
|
|
108
|
+
- error-recovery
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
MIT
|
|
114
|
+
|
|
115
|
+
## Ecosystem
|
|
116
|
+
|
|
117
|
+
Part of the [FableForge](../) ecosystem — 21 open-source projects built from 210K real agent traces:
|
|
118
|
+
|
|
119
|
+
| Project | Description |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| **[Anvil](../anvil)** | Self-verified coding agent |
|
|
122
|
+
| **[VerifyLoop](../verifyloop)** | Plan→Execute→Verify→Recover framework |
|
|
123
|
+
| **[ErrorRecovery](../error-recovery)** | Self-healing middleware (3,725 error patterns) |
|
|
124
|
+
| **[FableForge-14B](../fableforge-14b)** | The fine-tuned 14B model (4-stage training) |
|
|
125
|
+
| **[ShellWhisperer](../shell-whisperer)** | 1.5B edge agent (phone/RPi, 50ms) |
|
|
126
|
+
| **[ReasonCritic](../reason-critic)** | Verification model (130 benchmark tasks) |
|
|
127
|
+
| **[TraceCompiler](../trace-compiler)** | Compile traces → LoRA skills |
|
|
128
|
+
| **[AgentRuntime](../agent-runtime)** | Persistent agent daemon (systemd for AI) |
|
|
129
|
+
| **[AgentSwarm](../agent-swarm)** | Multi-agent from real trace transitions |
|
|
130
|
+
| **[AgentTelemetry](../agent-telemetry)** | Datadog for agents (token tracking, costs) |
|
|
131
|
+
| **[BenchAgent](../bench-agent)** | HumanEval for tool-use (107 tasks) |
|
|
132
|
+
| **[AgentDev](../agent-dev)** | VSCode extension with verification |
|
|
133
|
+
| **[TraceViz](../trace-viz)** | Trace replay visualizer (Next.js) |
|
|
134
|
+
| **[AgentSkills](../agent-skills)** | npm for agent behaviors |
|
|
135
|
+
| **[AgentCurriculum](../agent-curriculum)** | 5-stage progressive training |
|
|
136
|
+
| **[AgentFuzzer](../agent-fuzzer)** | Adversarial testing for agents |
|
|
137
|
+
| **[AgentConstitution](../agent-constitution)** | Safety guardrails from traces |
|
|
138
|
+
| **[CostOptimizer](../cost-optimizer)** | Token cost reduction (50-80%) |
|
|
139
|
+
| **[AgentProfiler](../agent-profiler)** | Behavioral fingerprinting |
|
|
140
|
+
| **[TrajectoryDistiller](../trajectory-distiller)** | Trace→training data pipeline |
|
|
141
|
+
| **[Fable5-Dataset](../fable5-dataset)** | HuggingFace dataset release |
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# AgentSkills.org
|
|
2
|
+
|
|
3
|
+
[](LICENSE) [](https://www.python.org/downloads/) [](tests/)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Skill registry, decomposition, and LoRA building for coding agents.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
AgentSkills.org provides a framework for extracting, publishing, and building LoRA adapters from recurring skill patterns in agent traces. Think of it as a package manager for agent capabilities.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install agent-skills
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
### Install a Skill
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
askill install debug
|
|
24
|
+
askill install edit
|
|
25
|
+
askill list
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Extract Skills from Traces
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
askill decompose traces.jsonl --min-occurrences 3
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Build LoRA Adapters
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
askill build traces.jsonl --base-model Qwen/Qwen2.5-14B --output-dir output/lora
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Programmatic Usage
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from agent_skills import SkillRegistry, SkillDecomposer
|
|
44
|
+
from agent_skills.lora_builder import build_lora
|
|
45
|
+
|
|
46
|
+
# Install and list skills
|
|
47
|
+
registry = SkillRegistry()
|
|
48
|
+
registry.install("debug")
|
|
49
|
+
skills = registry.list_skills()
|
|
50
|
+
|
|
51
|
+
# Extract skills from traces
|
|
52
|
+
decomposer = SkillDecomposer(min_occurrences=3)
|
|
53
|
+
skills = decomposer.extract_skills_from_trace("traces.jsonl")
|
|
54
|
+
clusters = decomposer.cluster_skills()
|
|
55
|
+
|
|
56
|
+
# Build LoRA adapters from skill clusters
|
|
57
|
+
for cluster in clusters:
|
|
58
|
+
adapter = build_lora(cluster, base_model="Qwen/Qwen2.5-14B")
|
|
59
|
+
print(f"Built: {adapter.name} with {adapter.num_examples} examples")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Built-in Skills
|
|
63
|
+
|
|
64
|
+
| Skill | Tools | Description |
|
|
65
|
+
|-------|-------|-------------|
|
|
66
|
+
| **debug** | read, bash, grep | Diagnose and fix errors in code |
|
|
67
|
+
| **edit** | edit, write | Make targeted edits to code files |
|
|
68
|
+
| **verify** | bash, read, grep | Run tests and verify correctness |
|
|
69
|
+
| **recover** | bash, edit, read, grep | Recover from errors and retry |
|
|
70
|
+
| **plan** | question, glob, read | Plan and coordinate multi-step tasks |
|
|
71
|
+
| **bash** | bash | Execute shell commands and scripts |
|
|
72
|
+
|
|
73
|
+
## Skill YAML Format
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
name: debug
|
|
77
|
+
version: "1.0.0"
|
|
78
|
+
description: "Diagnose and fix errors in code"
|
|
79
|
+
category: "core"
|
|
80
|
+
tools:
|
|
81
|
+
- read
|
|
82
|
+
- bash
|
|
83
|
+
- grep
|
|
84
|
+
triggers:
|
|
85
|
+
- "fix the bug"
|
|
86
|
+
- "debug this error"
|
|
87
|
+
author: "your-name"
|
|
88
|
+
license: "MIT"
|
|
89
|
+
tags:
|
|
90
|
+
- debugging
|
|
91
|
+
- error-recovery
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT
|
|
97
|
+
|
|
98
|
+
## Ecosystem
|
|
99
|
+
|
|
100
|
+
Part of the [FableForge](../) ecosystem — 21 open-source projects built from 210K real agent traces:
|
|
101
|
+
|
|
102
|
+
| Project | Description |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| **[Anvil](../anvil)** | Self-verified coding agent |
|
|
105
|
+
| **[VerifyLoop](../verifyloop)** | Plan→Execute→Verify→Recover framework |
|
|
106
|
+
| **[ErrorRecovery](../error-recovery)** | Self-healing middleware (3,725 error patterns) |
|
|
107
|
+
| **[FableForge-14B](../fableforge-14b)** | The fine-tuned 14B model (4-stage training) |
|
|
108
|
+
| **[ShellWhisperer](../shell-whisperer)** | 1.5B edge agent (phone/RPi, 50ms) |
|
|
109
|
+
| **[ReasonCritic](../reason-critic)** | Verification model (130 benchmark tasks) |
|
|
110
|
+
| **[TraceCompiler](../trace-compiler)** | Compile traces → LoRA skills |
|
|
111
|
+
| **[AgentRuntime](../agent-runtime)** | Persistent agent daemon (systemd for AI) |
|
|
112
|
+
| **[AgentSwarm](../agent-swarm)** | Multi-agent from real trace transitions |
|
|
113
|
+
| **[AgentTelemetry](../agent-telemetry)** | Datadog for agents (token tracking, costs) |
|
|
114
|
+
| **[BenchAgent](../bench-agent)** | HumanEval for tool-use (107 tasks) |
|
|
115
|
+
| **[AgentDev](../agent-dev)** | VSCode extension with verification |
|
|
116
|
+
| **[TraceViz](../trace-viz)** | Trace replay visualizer (Next.js) |
|
|
117
|
+
| **[AgentSkills](../agent-skills)** | npm for agent behaviors |
|
|
118
|
+
| **[AgentCurriculum](../agent-curriculum)** | 5-stage progressive training |
|
|
119
|
+
| **[AgentFuzzer](../agent-fuzzer)** | Adversarial testing for agents |
|
|
120
|
+
| **[AgentConstitution](../agent-constitution)** | Safety guardrails from traces |
|
|
121
|
+
| **[CostOptimizer](../cost-optimizer)** | Token cost reduction (50-80%) |
|
|
122
|
+
| **[AgentProfiler](../agent-profiler)** | Behavioral fingerprinting |
|
|
123
|
+
| **[TrajectoryDistiller](../trajectory-distiller)** | Trace→training data pipeline |
|
|
124
|
+
| **[Fable5-Dataset](../fable5-dataset)** | HuggingFace dataset release |
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fableforge-agent-skills"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Skill registry, decomposition, and LoRA building for coding agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"pydantic>=2.0",
|
|
13
|
+
"pyyaml>=6.0",
|
|
14
|
+
"click>=8.0",
|
|
15
|
+
"rich>=13.0",
|
|
16
|
+
"torch>=2.1",
|
|
17
|
+
"peft>=0.7",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
askill = "agent_skills.cli:cli"
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
dev = ["pytest>=7.0", "ruff>=0.1"]
|
|
25
|
+
|
|
26
|
+
[tool.hatch.build.targets.wheel]
|
|
27
|
+
packages = ["src/agent_skills"]
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""AgentSkills CLI — Command-line interface for skill management."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
from rich.table import Table
|
|
12
|
+
|
|
13
|
+
from agent_skills.registry import SkillRegistry
|
|
14
|
+
from agent_skills.decomposition import SkillDecomposer
|
|
15
|
+
from agent_skills.lora_builder import build_lora, LoRABuildConfig
|
|
16
|
+
|
|
17
|
+
console = Console()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@click.group()
|
|
21
|
+
@click.version_option("0.1.0")
|
|
22
|
+
def cli() -> None:
|
|
23
|
+
"""AgentSkills — Skill registry, decomposition, and LoRA building for coding agents."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@cli.command()
|
|
27
|
+
@click.argument("skill_name")
|
|
28
|
+
@click.option("--source", "-s", help="Local path or URL to install from")
|
|
29
|
+
def install(skill_name: str, source: str | None) -> None:
|
|
30
|
+
"""Install a skill from the registry or a local path."""
|
|
31
|
+
registry = SkillRegistry()
|
|
32
|
+
try:
|
|
33
|
+
meta = registry.install(skill_name, source=source)
|
|
34
|
+
console.print(f"[green]✓[/green] Installed skill: {meta.name} v{meta.version}")
|
|
35
|
+
console.print(f" Description: {meta.description}")
|
|
36
|
+
console.print(f" Tools: {', '.join(meta.tools)}")
|
|
37
|
+
console.print(f" Category: {meta.category}")
|
|
38
|
+
except ValueError as e:
|
|
39
|
+
console.print(f"[red]✗[/red] {e}")
|
|
40
|
+
sys.exit(1)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@cli.command("list")
|
|
44
|
+
@click.option("--category", "-c", help="Filter by category")
|
|
45
|
+
def list_skills(category: str | None) -> None:
|
|
46
|
+
"""List all available skills."""
|
|
47
|
+
registry = SkillRegistry()
|
|
48
|
+
skills = registry.list_skills(category=category)
|
|
49
|
+
|
|
50
|
+
if not skills:
|
|
51
|
+
console.print("[yellow]No skills found[/yellow]")
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
table = Table(title="AgentSkills Registry")
|
|
55
|
+
table.add_column("Name", style="cyan")
|
|
56
|
+
table.add_column("Version", style="green")
|
|
57
|
+
table.add_column("Category", style="yellow")
|
|
58
|
+
table.add_column("Tools", style="white")
|
|
59
|
+
table.add_column("Description", style="white", max_width=40)
|
|
60
|
+
|
|
61
|
+
for skill in skills:
|
|
62
|
+
table.add_row(
|
|
63
|
+
skill.name,
|
|
64
|
+
skill.version,
|
|
65
|
+
skill.category,
|
|
66
|
+
", ".join(skill.tools),
|
|
67
|
+
skill.description[:40] + "..." if len(skill.description) > 40 else skill.description,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
console.print(table)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@cli.command()
|
|
74
|
+
@click.argument("skill_path", type=click.Path(exists=True))
|
|
75
|
+
def publish(skill_path: str) -> None:
|
|
76
|
+
"""Publish a skill to the local registry."""
|
|
77
|
+
registry = SkillRegistry()
|
|
78
|
+
meta = registry.publish(skill_path)
|
|
79
|
+
console.print(f"[green]✓[/green] Published skill: {meta.name} v{meta.version}")
|
|
80
|
+
console.print(f" Path: {meta.install_path}")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@cli.command()
|
|
84
|
+
@click.argument("skill_name")
|
|
85
|
+
def download(skill_name: str) -> None:
|
|
86
|
+
"""Download a skill from the remote registry."""
|
|
87
|
+
registry = SkillRegistry()
|
|
88
|
+
try:
|
|
89
|
+
meta = registry.download(skill_name)
|
|
90
|
+
console.print(f"[green]✓[/green] Downloaded skill: {meta.name} v{meta.version}")
|
|
91
|
+
except ValueError as e:
|
|
92
|
+
console.print(f"[red]✗[/red] {e}")
|
|
93
|
+
sys.exit(1)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@cli.command()
|
|
97
|
+
@click.argument("trace_path", type=click.Path(exists=True))
|
|
98
|
+
@click.option("--min-occurrences", default=3, help="Minimum occurrences to include a skill")
|
|
99
|
+
@click.option("--min-success-rate", default=0.5, help="Minimum success rate to include a skill")
|
|
100
|
+
def decompose(trace_path: str, min_occurrences: int, min_success_rate: float) -> None:
|
|
101
|
+
"""Extract skills from a trace file and cluster them."""
|
|
102
|
+
decomposer = SkillDecomposer(
|
|
103
|
+
min_occurrences=min_occurrences,
|
|
104
|
+
min_success_rate=min_success_rate,
|
|
105
|
+
)
|
|
106
|
+
skills = decomposer.extract_skills_from_trace(trace_path)
|
|
107
|
+
|
|
108
|
+
if not skills:
|
|
109
|
+
console.print("[yellow]No skills extracted from trace[/yellow]")
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
console.print(f"\n[bold]Extracted {len(skills)} skills:[/bold]")
|
|
113
|
+
for skill in skills:
|
|
114
|
+
console.print(f" [cyan]{skill.name}[/cyan]: {skill.description}")
|
|
115
|
+
console.print(f" Tools: {', '.join(skill.tools)}")
|
|
116
|
+
console.print(f" Occurrences: {skill.occurrence_count}, Success: {skill.success_rate:.1%}")
|
|
117
|
+
|
|
118
|
+
clusters = decomposer.cluster_skills()
|
|
119
|
+
console.print(f"\n[bold]Clustered into {len(clusters)} groups:[/bold]")
|
|
120
|
+
for cluster in clusters:
|
|
121
|
+
console.print(f" [yellow]{cluster.name}[/yellow]: {', '.join(s.name for s in cluster.skills)}")
|
|
122
|
+
console.print(f" Tools: {', '.join(cluster.representative_tools)}")
|
|
123
|
+
console.print(f" Avg success: {cluster.avg_success_rate:.1%}")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@cli.command()
|
|
127
|
+
@click.argument("trace_path", type=click.Path(exists=True))
|
|
128
|
+
@click.option("--base-model", default="Qwen/Qwen2.5-14B", help="Base model for LoRA")
|
|
129
|
+
@click.option("--output-dir", default="output/lora", help="Output directory")
|
|
130
|
+
@click.option("--lora-r", default=16, help="LoRA rank")
|
|
131
|
+
@click.option("--lora-alpha", default=32, help="LoRA alpha")
|
|
132
|
+
def build(trace_path: str, base_model: str, output_dir: str, lora_r: int, lora_alpha: int) -> None:
|
|
133
|
+
"""Build a LoRA adapter from a trace file."""
|
|
134
|
+
decomposer = SkillDecomposer()
|
|
135
|
+
skills = decomposer.extract_skills_from_trace(trace_path)
|
|
136
|
+
if not skills:
|
|
137
|
+
console.print("[red]✗ No skills extracted from trace[/red]")
|
|
138
|
+
sys.exit(1)
|
|
139
|
+
|
|
140
|
+
clusters = decomposer.cluster_skills()
|
|
141
|
+
if not clusters:
|
|
142
|
+
console.print("[red]✗ Could not cluster skills[/red]")
|
|
143
|
+
sys.exit(1)
|
|
144
|
+
|
|
145
|
+
config = LoRABuildConfig(
|
|
146
|
+
base_model=base_model,
|
|
147
|
+
output_dir=output_dir,
|
|
148
|
+
LoRA_r=lora_r,
|
|
149
|
+
LoRA_alpha=lora_alpha,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Build a LoRA for each cluster
|
|
153
|
+
adapters = []
|
|
154
|
+
for cluster in clusters:
|
|
155
|
+
adapter = build_lora(cluster, base_model=base_model, output_dir=output_dir, config=config)
|
|
156
|
+
adapters.append(adapter)
|
|
157
|
+
console.print(f"[green]✓[/green] Built LoRA: {adapter.name}")
|
|
158
|
+
console.print(f" Output: {adapter.output_path}")
|
|
159
|
+
console.print(f" Examples: {adapter.num_examples}")
|
|
160
|
+
console.print(f" Quality: {adapter.quality_score:.1%}")
|
|
161
|
+
|
|
162
|
+
console.print(f"\n[bold]Built {len(adapters)} LoRA adapters[/bold]")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
if __name__ == "__main__":
|
|
166
|
+
cli()
|