Skip to content

Commit 75d1143

Browse files
committed
reduced TOOLS.md to reduce token usage and fixed avail skills missing location
1 parent 1e4d1fa commit 75d1143

File tree

5 files changed

+123
-63
lines changed

5 files changed

+123
-63
lines changed

cmd/yaocc/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func runInit() {
4141
createFileFromTemplate(p("USER.md"), "USER.md")
4242
createFileFromTemplate(p("BOOTSTRAP.md"), "BOOTSTRAP.md")
4343
createFileFromTemplate(p("MEMORY.md"), "MEMORY.md")
44+
createFileFromTemplate(p("SKILLS_TUTORIAL.md"), "SKILLS_TUTORIAL.md")
4445

4546
// 3. Create sample cron skill
4647
if err := os.MkdirAll(p("skills/cron"), 0755); err != nil {

cmd/yaocc/skills.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67
"sort"
78
"strings"
89

@@ -146,6 +147,44 @@ func runSkills(args []string) {
146147
fmt.Printf(" - %s -> %s\n", name, path)
147148
}
148149

150+
case "get":
151+
// Usage: yaocc skills get <name>
152+
if len(args) < 2 {
153+
fmt.Println("Usage: yaocc skills get <name>")
154+
return
155+
}
156+
name := args[1]
157+
158+
// Check if it's a registered skill
159+
if scriptPath, ok := cfg.Skills.Registered[name]; ok {
160+
fmt.Printf("Skill '%s' points to script '%s'.\n", name, scriptPath)
161+
// Generally, skills documentation will be under the same folder named SKILL.md
162+
// Try to automatically read it
163+
dir := config.ResolveConfigDir()
164+
resolvedScript, _ := resolveSafePath(dir, scriptPath)
165+
skillDir := filepath.Dir(resolvedScript)
166+
readmePath := filepath.Join(skillDir, "SKILL.md")
167+
if content, err := os.ReadFile(readmePath); err == nil {
168+
fmt.Printf("\n--- SKILL.md ---\n%s\n", string(content))
169+
} else {
170+
fmt.Printf("Warning: Could not automatically find SKILL.md near the script at %s\n", readmePath)
171+
}
172+
return
173+
}
174+
175+
// Otherwise, it might be a built-in skill, or we should look through actual paths.
176+
// For built-ins, we can point them to the docs.
177+
fmt.Printf("Skill '%s' is not registered as a custom script skill. If it's built-in (e.g. cron, file_manager, websearch), refer to the core documentation or verify the name.\n", name)
178+
179+
case "tutorial":
180+
dir := config.ResolveConfigDir()
181+
tutorialPath := filepath.Join(dir, "SKILLS_TUTORIAL.md")
182+
if content, err := os.ReadFile(tutorialPath); err == nil {
183+
fmt.Printf("\n--- SKILLS_TUTORIAL.md ---\n%s\n", string(content))
184+
} else {
185+
fmt.Printf("Warning: Could not find SKILLS_TUTORIAL.md at %s. Try running 'yaocc init' to generate it.\n", tutorialPath)
186+
}
187+
149188
case "help":
150189
printSkillsHelp()
151190

@@ -182,5 +221,7 @@ func printSkillsHelp() {
182221
fmt.Println(" register <name> <path> Register a new skill")
183222
fmt.Println(" unregister <name> Unregister an existing skill")
184223
fmt.Println(" list List all skills (built-in and registered)")
224+
fmt.Println(" get <name> Read the instructions (SKILL.md) for a skill")
225+
fmt.Println(" tutorial Read the comprehensive skill creation tutorial")
185226
fmt.Println(" <name> [args] Execute a registered skill")
186227
}

pkg/agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func (a *Agent) GetSystemPrompt(provider messaging.Provider) string {
443443
sb.WriteString(fmt.Sprintf("\n### %s\n%s\n%s\n", skill.Name, skill.Description, skill.Content))
444444
} else {
445445
// New behavior: XML manifest
446-
sb.WriteString(fmt.Sprintf(" <skill>\n <name>%s</name>\n <description>%s</description>\n </skill>\n", skill.Name, skill.Description))
446+
sb.WriteString(fmt.Sprintf(" <skill>\n <name>%s</name>\n <description>%s</description>\n <location>%s</location>\n </skill>\n", skill.Name, skill.Description, skill.Path))
447447
}
448448
}
449449
sb.WriteString("</available_skills>\n")

pkg/templates/SKILLS_TUTORIAL.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Skill Creation Tutorial
2+
3+
Here is the comprehensive guide on how to create and register custom skills for YAOCC.
4+
You can extend your capabilities by creating new "Skills". A skill is simply a set of instructions and examples stored in a markdown file. and sometimes is accompanied by a script (Python, Bash, JS, etc.)(js preferred) that you register as a new command. Before creating a skill verify it doest exist yet using `yaocc skills list`.
5+
6+
### 1. Create the Script and Skill Definition
7+
First, create the script and the `SKILL.md` file as usual.
8+
9+
To add a new skill:
10+
1. Create a directory: `skills/<skill_name>/`
11+
2. Create a file: `skills/<skill_name>/SKILL.md`
12+
3. Write the skill definition in frontmatter and instructions in the body.
13+
14+
#### Example: Creating a "Weather" Skill using `file write`
15+
16+
```bash
17+
yaocc file write skills/weather/SKILL.md "---
18+
name: weather
19+
description: Checks the weather of a city.
20+
---
21+
# Weather api
22+
23+
To check the weather of a city run
24+
\`\`\`bash
25+
yaocc skills weather <city>
26+
\`\`\`
27+
```
28+
### 2. Create script and verify it runs
29+
sometimes you can get away only with SKILL.md
30+
but sometimes you'll need to create the script, in this case
31+
32+
**Note:** You cannot use reserved names like `list`, `register`, `file`, `cron`, etc.
33+
34+
#### Example: Creating a "Weather" Skill script
35+
1. **Create the script:**
36+
```bash
37+
yaocc file write skills/weather/weather.js "console.log(`Weather in \${process.argv[2]}: Sunny`);"
38+
```
39+
40+
2. **Verify it runs:**
41+
verify it runs correctly before you register!
42+
```bash
43+
yaocc file run skills/weather/weather.js Paris
44+
```
45+
46+
3. **Register it:**
47+
Use the `yaocc skills register` command to link a command name to your script.
48+
very important you can register the skill only after it runs correctly in the previous step
49+
50+
```bash
51+
yaocc skills register <command_name> <path_to_script>
52+
```
53+
example:
54+
```bash
55+
yaocc skills register weather skills/weather/weather.js
56+
```
57+
58+
4. **Use it:**
59+
You can now use `yaocc skills weather <city>` directly!
60+
```bash
61+
yaocc skills weather Paris
62+
```
63+
64+
5. **List Skills:**
65+
```bash
66+
yaocc skills list
67+
```
68+
69+
6. **Unregister:**
70+
```bash
71+
yaocc skills unregister weather
72+
```

pkg/templates/TOOLS.md

Lines changed: 8 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,75 +18,21 @@ yaocc skills list
1818
## Creating and Using Skills
1919
You can extend your capabilities by creating new "Skills". A skill is simply a set of instructions and examples stored in a markdown file. and sometimes is accompanied by a script (Python, Bash, JS, etc.)(js preferred) that you register as a new command. Before creating a skill verify it doest exist yet using `yaocc skills list`.
2020

21-
### 1. Create the Script and Skill Definition
22-
First, create the script and the `SKILL.md` file as usual.
23-
24-
To add a new skill:
25-
1. Create a directory: `skills/<skill_name>/`
26-
2. Create a file: `skills/<skill_name>/SKILL.md`
27-
3. Write the skill definition in frontmatter and instructions in the body.
28-
29-
#### Example: Creating a "Weather" Skill using `file write`
30-
31-
```bash
32-
yaocc file write skills/weather/SKILL.md "---
33-
name: weather
34-
description: Checks the weather of a city.
35-
---
36-
# Weather api
37-
38-
To check the weather of a city run
39-
\`\`\`bash
40-
yaocc skills weather <city>
41-
\`\`\`
42-
```
43-
### 2. Create script and verify it runs
44-
sometimes you can get away only with SKILL.md
45-
but sometimes you'll need to create the script, in this case
46-
47-
**Note:** You cannot use reserved names like `list`, `register`, `file`, `cron`, etc.
48-
49-
#### Example: Creating a "Weather" Skill script
50-
1. **Create the script:**
21+
**CRITICAL RULE FOR UNFAMILIAR SKILLS:** If you see a skill in your `<available_skills>` manifest but do not know its precise arguments, you MUST read its documentation first using:
5122
```bash
52-
yaocc file write skills/weather/weather.js "console.log(`Weather in ${process.argv[2]}: Sunny`);"
23+
yaocc skills get <skill_name>
5324
```
25+
Do not attempt to guess the arguments of a custom skill before reading its `SKILL.md` body.
5426

55-
2. **Verify it runs:**
56-
verify it runs correctly before you register!
27+
### Creating a Custom Skill from Scratch
28+
If the user asks you to create a brand new custom skill, you MUST first read the tutorial to learn the framework mechanics by running:
5729
```bash
58-
yaocc file run skills/weather/weather.js Paris
30+
yaocc skills tutorial
5931
```
32+
DO NOT attempt to create a custom skill without reading the tutorial first.
6033

61-
3. **Register it:**
62-
Use the `yaocc skills register` command to link a command name to your script.
63-
very important you can register the skill only after it runs correctly in the previous step
64-
65-
```bash
66-
yaocc skills register <command_name> <path_to_script>
67-
```
68-
example:
69-
```bash
70-
yaocc skills register weather skills/weather/weather.js
71-
```
72-
73-
4. **Use it:**
74-
You can now use `yaocc skills weather <city>` directly!
75-
```bash
76-
yaocc skills weather Paris
77-
```
78-
79-
5. **List Skills:**
80-
```bash
81-
yaocc skills list
82-
```
83-
84-
6. **Unregister:**
85-
```bash
86-
yaocc skills unregister weather
87-
```
8834

89-
### 7. Execute Shell Commands
35+
### Execute Shell Commands
9036
```bash
9137
yaocc exec <command>
9238
```

0 commit comments

Comments
 (0)