Class: Agent::Lock::Skill
- Inherits:
-
Object
- Object
- Agent::Lock::Skill
- Defined in:
- lib/agent/lock/skill.rb
Overview
The skill this gem ships: a SKILL.md that teaches an agent how to claim
files with alock, copied into whichever skills directory the agent reads.
It lives inside the gem rather than in a repository of its own so that the instructions an agent follows can never describe a different version of the tool than the one it runs.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- NAME =
The skill's directory name, which is also the name it answers to.
"agent-lock"- ROOT =
Where the gem keeps its skills, one directory each.
File.("../../../skills", __dir__)
Instance Attribute Summary collapse
-
#into ⇒ String
readonly
The skills directory being installed into.
-
#source ⇒ String
readonly
The skill directory being copied.
Class Method Summary collapse
-
.default_into ⇒ String
Where most agents other than Claude Code look for a user's own skills; the CLI's
--for claudepoints at~/.claude/skillsinstead. -
.source ⇒ String
The bundled skill's directory.
Instance Method Summary collapse
-
#initialize(into: self.class.default_into, source: self.class.source) ⇒ Skill
constructor
A new instance of Skill.
-
#install(force: false) ⇒ Result
Copy the skill in, unless something is already there that this would destroy.
-
#target ⇒ String
The directory the skill ends up in.
Constructor Details
#initialize(into: self.class.default_into, source: self.class.source) ⇒ Skill
Returns a new instance of Skill.
47 48 49 50 |
# File 'lib/agent/lock/skill.rb', line 47 def initialize(into: self.class.default_into, source: self.class.source) @into = File.(into) @source = source end |
Instance Attribute Details
#into ⇒ String (readonly)
Returns the skills directory being installed into.
40 41 42 |
# File 'lib/agent/lock/skill.rb', line 40 def into @into end |
#source ⇒ String (readonly)
Returns the skill directory being copied.
43 44 45 |
# File 'lib/agent/lock/skill.rb', line 43 def source @source end |
Class Method Details
.default_into ⇒ String
Returns where most agents other than Claude Code look for
a user's own skills; the CLI's --for claude points at
~/.claude/skills instead.
36 |
# File 'lib/agent/lock/skill.rb', line 36 def default_into = File.join(Dir.home, ".agents", "skills") |
Instance Method Details
#install(force: false) ⇒ Result
Copy the skill in, unless something is already there that this would destroy. A copy that differs may be one somebody edited on purpose, and a symlink is another installer's, such as a dotfiles repository that links every skill it manages; replacing either without being asked is the silent last-writer-wins this gem exists to prevent.
63 64 65 66 67 68 69 70 71 |
# File 'lib/agent/lock/skill.rb', line 63 def install(force: false) refused = refusal(force) return refused if refused FileUtils.rm_rf(target) FileUtils.mkdir_p(into) FileUtils.cp_r(source, target) result(:installed) end |
#target ⇒ String
Returns the directory the skill ends up in.
53 |
# File 'lib/agent/lock/skill.rb', line 53 def target = File.join(into, NAME) |