feat: support agent skills
feat:support agent skills
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
// +build ignore
|
||||
|
||||
// Docker sandbox test program
|
||||
// Usage: go run cmd/skills-demo/docker_test.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/sandbox"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println(" Docker Sandbox Test Suite")
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Get the path to examples/skills
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
fmt.Println("Error: Failed to get current file path")
|
||||
os.Exit(1)
|
||||
}
|
||||
scriptsDir := filepath.Join(filepath.Dir(filename), "..", "..", "examples", "skills", "pdf-processing", "scripts")
|
||||
|
||||
// Create Docker sandbox
|
||||
config := sandbox.DefaultConfig()
|
||||
config.Type = sandbox.SandboxTypeDocker
|
||||
config.FallbackEnabled = false
|
||||
config.DockerImage = "python:3.11-slim"
|
||||
|
||||
mgr, err := sandbox.NewManager(config)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Failed to create sandbox manager: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("✅ Sandbox Type: %s\n\n", mgr.GetType())
|
||||
|
||||
// Test 1: Basic script execution
|
||||
fmt.Println("Test 1: Basic Script Execution")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"sample.pdf"},
|
||||
})
|
||||
|
||||
// Test 2: Script with different arguments
|
||||
fmt.Println("\nTest 2: Script with Different Arguments")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "extract_text.py"),
|
||||
Args: []string{"document.pdf", "--page", "1"},
|
||||
})
|
||||
|
||||
// Test 3: Environment variables
|
||||
fmt.Println("\nTest 3: Environment Variables")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
Env: map[string]string{
|
||||
"DEBUG": "true",
|
||||
"LOG_LEVEL": "verbose",
|
||||
},
|
||||
})
|
||||
|
||||
// Test 4: Network isolation (default: no network)
|
||||
fmt.Println("\nTest 4: Network Isolation (network disabled)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
AllowNetwork: false,
|
||||
})
|
||||
|
||||
// Test 5: Memory limits
|
||||
fmt.Println("\nTest 5: Memory Limits (128MB)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
MemoryLimit: 128 * 1024 * 1024, // 128MB
|
||||
})
|
||||
|
||||
// Test 6: CPU limits
|
||||
fmt.Println("\nTest 6: CPU Limits (0.5 cores)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
CPULimit: 0.5,
|
||||
})
|
||||
|
||||
// Test 7: Read-only filesystem
|
||||
fmt.Println("\nTest 7: Read-only Root Filesystem")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
ReadOnlyRootfs: true,
|
||||
})
|
||||
|
||||
// Test 8: Custom timeout
|
||||
fmt.Println("\nTest 8: Custom Timeout (10s)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
Timeout: 10 * time.Second,
|
||||
})
|
||||
|
||||
fmt.Println("\n" + strings.Repeat("=", 71))
|
||||
fmt.Println(" All Tests Completed!")
|
||||
fmt.Println(strings.Repeat("=", 71))
|
||||
}
|
||||
|
||||
func runTest(ctx context.Context, mgr sandbox.Manager, config *sandbox.ExecuteConfig) {
|
||||
startTime := time.Now()
|
||||
result, err := mgr.Execute(ctx, config)
|
||||
totalTime := time.Since(startTime)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf(" Script: %s\n", filepath.Base(config.Script))
|
||||
fmt.Printf(" Args: %v\n", config.Args)
|
||||
fmt.Printf(" Exit Code: %d\n", result.ExitCode)
|
||||
fmt.Printf(" Duration: %v (total: %v)\n", result.Duration, totalTime)
|
||||
fmt.Printf(" Success: %v\n", result.IsSuccess())
|
||||
|
||||
if result.Stdout != "" {
|
||||
// Show just the first 3 lines of output
|
||||
lines := strings.Split(result.Stdout, "\n")
|
||||
preview := strings.Join(lines[:min(3, len(lines))], "\n")
|
||||
fmt.Printf(" Output (preview):\n %s\n", strings.ReplaceAll(preview, "\n", "\n "))
|
||||
}
|
||||
|
||||
if result.Stderr != "" {
|
||||
fmt.Printf(" Stderr: %s\n", strings.TrimSpace(result.Stderr))
|
||||
}
|
||||
|
||||
if result.Error != "" {
|
||||
fmt.Printf(" Error: %s\n", result.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
// Docker sandbox test program
|
||||
// Usage: go run cmd/skills-demo/docker_test.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/sandbox"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println(" Docker Sandbox Test Suite")
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Get the path to examples/skills
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
fmt.Println("Error: Failed to get current file path")
|
||||
os.Exit(1)
|
||||
}
|
||||
scriptsDir := filepath.Join(filepath.Dir(filename), "..", "..", "examples", "skills", "pdf-processing", "scripts")
|
||||
|
||||
// Create Docker sandbox
|
||||
config := sandbox.DefaultConfig()
|
||||
config.Type = sandbox.SandboxTypeDocker
|
||||
config.FallbackEnabled = false
|
||||
config.DockerImage = "python:3.11-slim"
|
||||
|
||||
mgr, err := sandbox.NewManager(config)
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Failed to create sandbox manager: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("✅ Sandbox Type: %s\n\n", mgr.GetType())
|
||||
|
||||
// Test 1: Basic script execution
|
||||
fmt.Println("Test 1: Basic Script Execution")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"sample.pdf"},
|
||||
})
|
||||
|
||||
// Test 2: Script with different arguments
|
||||
fmt.Println("\nTest 2: Script with Different Arguments")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "extract_text.py"),
|
||||
Args: []string{"document.pdf", "--page", "1"},
|
||||
})
|
||||
|
||||
// Test 3: Environment variables
|
||||
fmt.Println("\nTest 3: Environment Variables")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
Env: map[string]string{
|
||||
"DEBUG": "true",
|
||||
"LOG_LEVEL": "verbose",
|
||||
},
|
||||
})
|
||||
|
||||
// Test 4: Network isolation (default: no network)
|
||||
fmt.Println("\nTest 4: Network Isolation (network disabled)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
AllowNetwork: false,
|
||||
})
|
||||
|
||||
// Test 5: Memory limits
|
||||
fmt.Println("\nTest 5: Memory Limits (128MB)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
MemoryLimit: 128 * 1024 * 1024, // 128MB
|
||||
})
|
||||
|
||||
// Test 6: CPU limits
|
||||
fmt.Println("\nTest 6: CPU Limits (0.5 cores)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
CPULimit: 0.5,
|
||||
})
|
||||
|
||||
// Test 7: Read-only filesystem
|
||||
fmt.Println("\nTest 7: Read-only Root Filesystem")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
ReadOnlyRootfs: true,
|
||||
})
|
||||
|
||||
// Test 8: Custom timeout
|
||||
fmt.Println("\nTest 8: Custom Timeout (10s)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
runTest(ctx, mgr, &sandbox.ExecuteConfig{
|
||||
Script: filepath.Join(scriptsDir, "analyze_form.py"),
|
||||
Args: []string{"test.pdf"},
|
||||
Timeout: 10 * time.Second,
|
||||
})
|
||||
|
||||
fmt.Println("\n" + strings.Repeat("=", 71))
|
||||
fmt.Println(" All Tests Completed!")
|
||||
fmt.Println(strings.Repeat("=", 71))
|
||||
}
|
||||
|
||||
func runTest(ctx context.Context, mgr sandbox.Manager, config *sandbox.ExecuteConfig) {
|
||||
startTime := time.Now()
|
||||
result, err := mgr.Execute(ctx, config)
|
||||
totalTime := time.Since(startTime)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("❌ Error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf(" Script: %s\n", filepath.Base(config.Script))
|
||||
fmt.Printf(" Args: %v\n", config.Args)
|
||||
fmt.Printf(" Exit Code: %d\n", result.ExitCode)
|
||||
fmt.Printf(" Duration: %v (total: %v)\n", result.Duration, totalTime)
|
||||
fmt.Printf(" Success: %v\n", result.IsSuccess())
|
||||
|
||||
if result.Stdout != "" {
|
||||
// Show just the first 3 lines of output
|
||||
lines := strings.Split(result.Stdout, "\n")
|
||||
preview := strings.Join(lines[:min(3, len(lines))], "\n")
|
||||
fmt.Printf(" Output (preview):\n %s\n", strings.ReplaceAll(preview, "\n", "\n "))
|
||||
}
|
||||
|
||||
if result.Stderr != "" {
|
||||
fmt.Printf(" Stderr: %s\n", strings.TrimSpace(result.Stderr))
|
||||
}
|
||||
|
||||
if result.Error != "" {
|
||||
fmt.Printf(" Error: %s\n", result.Error)
|
||||
}
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
// Package main provides a demo program to test the Agent Skills functionality.
|
||||
// This simulates the agent workflow without requiring a full server setup.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// go run cmd/skills-demo/main.go [sandbox-type]
|
||||
//
|
||||
// sandbox-type can be: local, docker (default: local)
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/agent/skills"
|
||||
"github.com/Tencent/WeKnora/internal/sandbox"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println(" Agent Skills Demo - Progressive Disclosure in Action")
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Parse sandbox type from command line
|
||||
sandboxType := "local"
|
||||
if len(os.Args) > 1 {
|
||||
sandboxType = os.Args[1]
|
||||
}
|
||||
|
||||
// Get the path to examples/skills
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
fmt.Println("Error: Failed to get current file path")
|
||||
os.Exit(1)
|
||||
}
|
||||
skillsDir := filepath.Join(filepath.Dir(filename), "..", "..", "examples", "skills")
|
||||
|
||||
fmt.Printf("📁 Skills directory: %s\n\n", skillsDir)
|
||||
|
||||
// ========================================
|
||||
// Step 1: Initialize Sandbox Manager
|
||||
// ========================================
|
||||
fmt.Println("Step 1: Initialize Sandbox Manager")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
fmt.Printf(" Requested sandbox type: %s\n", sandboxType)
|
||||
|
||||
sandboxMgr, err := sandbox.NewManagerFromType(sandboxType, false) // Disable fallback to test specific mode
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating sandbox: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("✅ Sandbox initialized (type: %s)\n\n", sandboxMgr.GetType())
|
||||
|
||||
// ========================================
|
||||
// Step 2: Initialize Skills Manager
|
||||
// ========================================
|
||||
fmt.Println("Step 2: Initialize Skills Manager")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
skillsConfig := &skills.ManagerConfig{
|
||||
SkillDirs: []string{skillsDir},
|
||||
AllowedSkills: []string{}, // Allow all
|
||||
Enabled: true,
|
||||
}
|
||||
|
||||
skillsManager := skills.NewManager(skillsConfig, sandboxMgr)
|
||||
if err := skillsManager.Initialize(ctx); err != nil {
|
||||
fmt.Printf("Error initializing skills: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
metadata := skillsManager.GetAllMetadata()
|
||||
fmt.Printf("✅ Discovered %d skills\n\n", len(metadata))
|
||||
|
||||
// ========================================
|
||||
// Step 3: Show Level 1 - Metadata (System Prompt)
|
||||
// ========================================
|
||||
fmt.Println("Step 3: Level 1 - Skill Metadata (injected into System Prompt)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
// Simulate what gets injected into system prompt
|
||||
fmt.Println("\n### Available Skills\n")
|
||||
fmt.Println("The following skills are available. When a user request matches a skill's description,")
|
||||
fmt.Println("use the `read_skill` tool to load its full instructions before proceeding.\n")
|
||||
for i, m := range metadata {
|
||||
fmt.Printf("%d. **%s**: %s\n", i+1, m.Name, m.Description)
|
||||
}
|
||||
fmt.Println("\nUse `read_skill` with the skill name to load detailed instructions when needed.")
|
||||
fmt.Println("Use `execute_skill_script` to run utility scripts bundled with a skill.")
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Step 4: Simulate Agent Tool Calls
|
||||
// ========================================
|
||||
fmt.Println("Step 4: Simulate Agent Tool Calls")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
// Scenario: User asks "Help me extract text from a PDF"
|
||||
fmt.Println("\n🤖 Scenario: User asks 'Help me extract text from a PDF'")
|
||||
fmt.Println(" Agent recognizes this matches 'pdf-processing' skill")
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Step 5: Level 2 - Load Skill Instructions
|
||||
// ========================================
|
||||
fmt.Println("Step 5: Level 2 - Agent calls read_skill tool")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
// Simulate tool call: read_skill(skill_name="pdf-processing")
|
||||
skill, err := skillsManager.LoadSkill(ctx, "pdf-processing")
|
||||
if err != nil {
|
||||
fmt.Printf("Error loading skill: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("✅ Tool: read_skill(skill_name=\"pdf-processing\")\n")
|
||||
fmt.Printf(" Success: true\n")
|
||||
fmt.Printf(" Skill: %s\n", skill.Name)
|
||||
fmt.Printf(" Description: %s\n", skill.Description)
|
||||
fmt.Printf(" Instructions preview (first 500 chars):\n")
|
||||
instructions := skill.Instructions
|
||||
if len(instructions) > 500 {
|
||||
instructions = instructions[:500] + "\n... (truncated)"
|
||||
}
|
||||
for _, line := range strings.Split(instructions, "\n") {
|
||||
fmt.Printf(" │ %s\n", line)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Step 6: Level 3 - Load Additional Resource
|
||||
// ========================================
|
||||
fmt.Println("Step 6: Level 3 - Agent reads additional file (FORMS.md)")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
// Simulate tool call: read_skill(skill_name="pdf-processing", file_path="FORMS.md")
|
||||
formsContent, err := skillsManager.ReadSkillFile(ctx, "pdf-processing", "FORMS.md")
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading FORMS.md: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("✅ Tool: read_skill(skill_name=\"pdf-processing\", file_path=\"FORMS.md\")\n")
|
||||
fmt.Printf(" Success: true\n")
|
||||
fmt.Printf(" Content length: %d characters\n", len(formsContent))
|
||||
// Show first few lines
|
||||
lines := strings.Split(formsContent, "\n")
|
||||
fmt.Printf(" Preview (first 10 lines):\n")
|
||||
for i, line := range lines {
|
||||
if i >= 10 {
|
||||
fmt.Printf(" │ ... (truncated)\n")
|
||||
break
|
||||
}
|
||||
fmt.Printf(" │ %s\n", line)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Step 7: Execute Skill Script
|
||||
// ========================================
|
||||
fmt.Println("Step 7: Agent executes skill script in sandbox")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
// Simulate tool call: execute_skill_script(skill_name="pdf-processing", script_path="scripts/analyze_form.py", args=["test.pdf"])
|
||||
args := []string{"test.pdf"}
|
||||
argsJSON, _ := json.Marshal(args)
|
||||
fmt.Printf("✅ Tool: execute_skill_script\n")
|
||||
fmt.Printf(" skill_name: \"pdf-processing\"\n")
|
||||
fmt.Printf(" script_path: \"scripts/analyze_form.py\"\n")
|
||||
fmt.Printf(" args: %s\n", string(argsJSON))
|
||||
|
||||
result, err := skillsManager.ExecuteScript(ctx, "pdf-processing", "scripts/analyze_form.py", args)
|
||||
if err != nil {
|
||||
fmt.Printf(" Error: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf(" Exit Code: %d\n", result.ExitCode)
|
||||
fmt.Printf(" Duration: %v\n", result.Duration)
|
||||
fmt.Printf(" Output:\n")
|
||||
for _, line := range strings.Split(result.Stdout, "\n") {
|
||||
fmt.Printf(" │ %s\n", line)
|
||||
}
|
||||
if result.Stderr != "" {
|
||||
fmt.Printf(" Stderr:\n")
|
||||
for _, line := range strings.Split(result.Stderr, "\n") {
|
||||
fmt.Printf(" │ %s\n", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Step 8: List all files in skill
|
||||
// ========================================
|
||||
fmt.Println("Step 8: List all available files in skill")
|
||||
fmt.Println("-" + strings.Repeat("-", 50))
|
||||
|
||||
files, err := skillsManager.ListSkillFiles(ctx, "pdf-processing")
|
||||
if err != nil {
|
||||
fmt.Printf("Error listing files: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("✅ Files in pdf-processing skill:\n")
|
||||
for _, f := range files {
|
||||
isScript := skills.IsScript(f)
|
||||
scriptTag := ""
|
||||
if isScript {
|
||||
scriptTag = " [executable]"
|
||||
}
|
||||
fmt.Printf(" - %s%s\n", f, scriptTag)
|
||||
}
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
// ========================================
|
||||
// Summary
|
||||
// ========================================
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println(" Summary: Progressive Disclosure Flow")
|
||||
fmt.Println("=" + strings.Repeat("=", 70))
|
||||
fmt.Println()
|
||||
fmt.Println(" Level 1 (Metadata) : ~100 tokens/skill in system prompt")
|
||||
fmt.Println(" → Agent knows which skills exist")
|
||||
fmt.Println()
|
||||
fmt.Println(" Level 2 (Instructions) : Loaded on-demand via read_skill")
|
||||
fmt.Println(" → Agent learns skill instructions")
|
||||
fmt.Println()
|
||||
fmt.Println(" Level 3 (Resources) : Additional files loaded as needed")
|
||||
fmt.Println(" → Agent accesses reference docs & scripts")
|
||||
fmt.Println()
|
||||
fmt.Println(" 🎉 Demo completed successfully!")
|
||||
fmt.Println()
|
||||
}
|
||||
Reference in New Issue
Block a user