repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | /** |
| #2 | * Skills Registry |
| #3 | * |
| #4 | * Install skills from remote sources: |
| #5 | * - Git repos: git clone <url> ~/.automaton/skills/<name> |
| #6 | * - URLs: fetch a SKILL.md from any URL |
| #7 | * - Self-created: the automaton writes its own SKILL.md files |
| #8 | */ |
| #9 | import path from "path"; |
| #10 | import { parseSkillMd } from "./format.js"; |
| #11 | /** |
| #12 | * Install a skill from a git repository. |
| #13 | * Clones the repo into ~/.automaton/skills/<name>/ |
| #14 | */ |
| #15 | export async function installSkillFromGit(repoUrl, name, skillsDir, db, runtime) { |
| #16 | const resolvedDir = resolveHome(skillsDir); |
| #17 | const targetDir = path.join(resolvedDir, name); |
| #18 | // Clone via sandbox exec |
| #19 | const result = await runtime.exec(`git clone --depth 1 ${repoUrl} ${targetDir}`, 60000); |
| #20 | if (result.exitCode !== 0) { |
| #21 | throw new Error(`Failed to clone skill repo: ${result.stderr}`); |
| #22 | } |
| #23 | // Look for SKILL.md |
| #24 | const skillMdPath = path.join(targetDir, "SKILL.md"); |
| #25 | const checkResult = await runtime.exec(`cat ${skillMdPath}`, 5000); |
| #26 | if (checkResult.exitCode !== 0) { |
| #27 | throw new Error(`No SKILL.md found in cloned repo at ${skillMdPath}`); |
| #28 | } |
| #29 | const skill = parseSkillMd(checkResult.stdout, skillMdPath, "git"); |
| #30 | if (!skill) { |
| #31 | throw new Error("Failed to parse SKILL.md from cloned repo"); |
| #32 | } |
| #33 | db.upsertSkill(skill); |
| #34 | return skill; |
| #35 | } |
| #36 | /** |
| #37 | * Install a skill from a URL (fetches a single SKILL.md). |
| #38 | */ |
| #39 | export async function installSkillFromUrl(url, name, skillsDir, db, runtime) { |
| #40 | const resolvedDir = resolveHome(skillsDir); |
| #41 | const targetDir = path.join(resolvedDir, name); |
| #42 | // Create directory |
| #43 | await runtime.exec(`mkdir -p ${targetDir}`, 5000); |
| #44 | // Fetch SKILL.md |
| #45 | const result = await runtime.exec(`curl -fsSL "${url}" -o ${targetDir}/SKILL.md`, 30000); |
| #46 | if (result.exitCode !== 0) { |
| #47 | throw new Error(`Failed to fetch SKILL.md from URL: ${result.stderr}`); |
| #48 | } |
| #49 | const content = await runtime.exec(`cat ${targetDir}/SKILL.md`, 5000); |
| #50 | const skillMdPath = path.join(targetDir, "SKILL.md"); |
| #51 | const skill = parseSkillMd(content.stdout, skillMdPath, "url"); |
| #52 | if (!skill) { |
| #53 | throw new Error("Failed to parse fetched SKILL.md"); |
| #54 | } |
| #55 | db.upsertSkill(skill); |
| #56 | return skill; |
| #57 | } |
| #58 | /** |
| #59 | * Create a new skill authored by the automaton itself. |
| #60 | */ |
| #61 | export async function createSkill(name, description, instructions, skillsDir, db, runtime) { |
| #62 | const resolvedDir = resolveHome(skillsDir); |
| #63 | const targetDir = path.join(resolvedDir, name); |
| #64 | // Create directory |
| #65 | await runtime.exec(`mkdir -p ${targetDir}`, 5000); |
| #66 | // Write SKILL.md |
| #67 | const content = `--- |
| #68 | name: ${name} |
| #69 | description: "${description}" |
| #70 | auto-activate: true |
| #71 | --- |
| #72 | ${instructions}`; |
| #73 | const skillMdPath = path.join(targetDir, "SKILL.md"); |
| #74 | await runtime.writeFile(skillMdPath, content); |
| #75 | const skill = { |
| #76 | name, |
| #77 | description, |
| #78 | autoActivate: true, |
| #79 | instructions, |
| #80 | source: "self", |
| #81 | path: skillMdPath, |
| #82 | enabled: true, |
| #83 | installedAt: new Date().toISOString(), |
| #84 | }; |
| #85 | db.upsertSkill(skill); |
| #86 | return skill; |
| #87 | } |
| #88 | /** |
| #89 | * Remove a skill (disable in DB and optionally delete from disk). |
| #90 | */ |
| #91 | export async function removeSkill(name, db, runtime, skillsDir, deleteFiles = false) { |
| #92 | db.removeSkill(name); |
| #93 | if (deleteFiles) { |
| #94 | const resolvedDir = resolveHome(skillsDir); |
| #95 | const targetDir = path.join(resolvedDir, name); |
| #96 | await runtime.exec(`rm -rf ${targetDir}`, 5000); |
| #97 | } |
| #98 | } |
| #99 | /** |
| #100 | * List all installed skills. |
| #101 | */ |
| #102 | export function listSkills(db) { |
| #103 | return db.getSkills(); |
| #104 | } |
| #105 | function resolveHome(p) { |
| #106 | if (p.startsWith("~")) { |
| #107 | return path.join(process.env.HOME || "/root", p.slice(1)); |
| #108 | } |
| #109 | return p; |
| #110 | } |
| #111 | //# sourceMappingURL=registry.js.map |