skills

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeployAll

func DeployAll(baseDir string) error

DeployAll extracts all embedded skill directories under baseDir. Each skill is deployed to baseDir/<skill-name>/. Files are only written when their content differs from the embedded version.

baseDir is entirely the caller's choice and this package makes no claim about where it lives — a general-purpose package naming its caller's layout would go stale the moment that layout changes, so the errors below quote the path and say nothing else about it.

There is no longer a daemon-side production caller at all: the sandbox skill set reaches a job by being baked into the runner image at build time (build/container/Dockerfile copies internal/skills/data to /opt/boid/skills) and symlinked into the workspace home by the init container. What still calls in here is the HOST-skill sibling (DeployHostSkills, deploy_host.go) behind `boid install-skills`.

Every write below goes through the symlink-safe, fd-relative helpers in safe_deploy.go rather than string-path-based os.MkdirAll/os.CreateTemp/ os.Rename — see safe_deploy.go's package comment for the threat model this guards against. It is retained even though the current default caller's baseDir is out of reach of any job: the same helpers also serve MkdirAllNoSymlink, whose caller DOES write into the job-owned workspace HOME, and nothing about them costs anything on a directory jobs cannot reach. A future caller is therefore free to point baseDir at attacker-writable storage again without re-deriving the threat model.

func DeployHostSkills added in v0.2.0

func DeployHostSkills(baseDir string) error

DeployHostSkills extracts the embedded host skill directories under baseDir, same idempotent/content-diff-only-write contract as DeployAll (see deploy.go's doc comment) — it shares the same underlying deployAllFrom/deploySkillDir machinery, just pointed at hostSkillsFS's "hostdata" root instead of skillsFS's "data" root.

func EmbeddedSkillNames added in v0.0.6

func EmbeddedSkillNames() []string

EmbeddedSkillNames returns the slugs of the embedded skill directories in stable lexical order. dispatcher uses it to compute the claude-side ~/.claude/skills/<name> bind targets without hard-coding the list — both the mkdir of those targets inside the workspace HOME and the per-skill read-only mounts homeMounts declares (internal/dispatcher/ skills_overlay.go and sandbox_builder.go).

func HostSkillNames added in v0.2.0

func HostSkillNames() []string

HostSkillNames returns the slugs of the embedded host skill directories in stable lexical order. Used only by `boid install-skills` to report what it installed — unlike EmbeddedSkillNames, nothing in internal/dispatcher consults this.

func MkdirAllNoSymlink(dir string) (ownerUID int, err error)

MkdirAllNoSymlink creates dir and every missing component leading to it, using the same symlink-refusing openat2 walk DeployAll writes through (see this file's package comment for the threat model), and reports the uid that owns the resulting directory. dir must be absolute; creating an already-existing directory is a no-op.

The dispatcher calls this to pre-create the per-skill bind TARGETS (<home>/.claude and <home>/.claude/skills/<name>) inside the workspace HOME before bind-mounting each embedded skill in from a host-visible runtime dir. A missing bind target would otherwise be auto-created by the container engine as uid 0, which locks the uid 1000 harness out of ~/.claude/.credentials.json.

Those targets sit inside a directory the job owns read-write, which is precisely why this is not an os.MkdirAll: a job that leaves ~/.claude behind as a symlink must not turn the next dispatch's mkdir into a write somewhere else on the daemon's filesystem.

The returned uid answers the question a bare mkdir cannot: "is the directory now at this path one I own, or one somebody else created first?" A caller that pre-creates a bind target inside job-owned storage needs that — an EEXIST is indistinguishable from success otherwise, and a target already created by the engine as uid 0 is not repairable afterwards (see internal/dispatcher/skills_overlay.go, the caller that acts on it, for why that is the outcome worth failing on). It is deliberately a plain uid rather than a bool: this package cannot know which uid its caller considers its own, and hard-coding one (1000) would be wrong on any deploy that runs the daemon as some other user.

It is read with fstat(2) on the descriptor the walk ended on, never a stat by path. A stat by path would re-resolve every component from scratch, so it could report the owner of a directory other than the one just created or entered — exactly the check-then-use gap this file's openat2 design exists to remove. Doing the ownership check through such a gap would make the check itself the race.

No separate "is it a directory" result is returned because there is nothing left to report: every component of the walk is opened with O_DIRECTORY (see openOrCreateDirNoSymlink), so a non-directory at any position — a plain file left at ~/.claude, say — fails the call outright with ENOTDIR rather than reaching this return. internal/dispatcher's TestDispatch_SkillsBindTargetPrepFails_MarksJobFailedAndCallsCleanup pins that end of it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL