Checkpoint commit covering concurrent work across several archie-core-abg epics to avoid losing in-progress state: - Memory manager (18.7-18.16): background sync pipeline, prefetch with timeout, memory-write notification, threat scanning, shutdown drain with abandoned-write tracking, frozen snapshot pattern. Wired ScanContent and NotifyMemoryToolWrite into HandleToolCall so scanning and notification actually apply to writes, not just exist as unused primitives. - Fixed a literal unresolved merge-conflict that had been committed to internal/memory/scrubber/scrubber.go. - Tool provider/registry, MCP client/transport (stdio, HTTP, SSE), multimodal results, disclosure. - Pairing device auth store, rate limiting. - Gateway compression, session store, tasks. - Various workflow, plugin host, and agentexec updates.
64 lines
2.0 KiB
Go
64 lines
2.0 KiB
Go
package skill
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/samcharles93/archie-core/internal/tools"
|
|
)
|
|
|
|
// ActivateTool bridges a skill catalog into a single tools.ToolEntry a
|
|
// chat turn's agent loop can offer the model: one tool named
|
|
// "skill_activate", not one per skill -- this is the same progressive
|
|
// disclosure Catalog/LoadBody already implement (Tier 1 catalog entries
|
|
// cost ~100 tokens each and are always in context via the tool schema;
|
|
// Tier 2 full bodies are loaded only when the model actually activates a
|
|
// skill). Returns nil when catalog is empty, so an empty skills
|
|
// directory doesn't add a dead tool to the set.
|
|
func ActivateTool(dir string, catalog []CatalogEntry) *tools.ToolEntry {
|
|
if len(catalog) == 0 {
|
|
return nil
|
|
}
|
|
|
|
names := make([]any, len(catalog))
|
|
descByName := make(map[string]string, len(catalog))
|
|
dirByName := make(map[string]string, len(catalog))
|
|
for i, e := range catalog {
|
|
names[i] = e.Name
|
|
descByName[e.Name] = e.Description
|
|
dirByName[e.Name] = e.Dir
|
|
}
|
|
|
|
return &tools.ToolEntry{
|
|
Name: "skill_activate",
|
|
Toolset: "skill",
|
|
Description: "Load the full instructions for a named skill. Call this before attempting a task a cataloged skill covers.",
|
|
Schema: tools.JSONSchema{
|
|
"type": "object",
|
|
"properties": map[string]any{
|
|
"name": map[string]any{
|
|
"type": "string",
|
|
"description": "The skill name to activate, from the catalog below.",
|
|
"enum": names,
|
|
},
|
|
},
|
|
"required": []any{"name"},
|
|
},
|
|
Handler: func(_ context.Context, input map[string]any) (any, error) {
|
|
name, _ := input["name"].(string)
|
|
if name == "" {
|
|
return nil, fmt.Errorf("skill_activate: %q is required", "name")
|
|
}
|
|
skillDir, ok := dirByName[name]
|
|
if !ok {
|
|
return nil, fmt.Errorf("skill_activate: unknown skill %q", name)
|
|
}
|
|
body := LoadBody(dir, skillDir)
|
|
if body == "" {
|
|
return nil, fmt.Errorf("skill_activate: %q has no body (SKILL.md missing or empty)", name)
|
|
}
|
|
return body, nil
|
|
},
|
|
}
|
|
}
|