agent-lock 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +16 -0
- data/README.md +22 -11
- data/Rakefile +36 -4
- data/lib/agent/lock/cli/commands/{skill.rb → skills.rb} +11 -6
- data/lib/agent/lock/cli.rb +31 -3
- data/lib/agent/lock/launcher.rb +0 -30
- data/lib/agent/lock/skill.rb +4 -0
- data/lib/agent/lock/store/redis_store.rb +54 -6
- data/lib/agent/lock/store.rb +4 -2
- data/lib/agent/lock/version.rb +1 -1
- metadata +162 -157
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 346f625f1722df2953c505cc28486065520780e3f85dbe45806a7605e2b73130
|
|
4
|
+
data.tar.gz: 74d61fc0c079449ca1b16d076eef5581fa21396b029ee0ae1c207d3f581c69e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0fdd381dd171d53d14bf9e24db275c31af2036f9edb3385705dd5e40bf7c2383b5e2c2514128577551590ef965b2e28921aabd27e0c38f4c3947bfe29bf506d
|
|
7
|
+
data.tar.gz: 9647370b0d347701c4d425122d8b87186df7b278cbe414038cb0d601637d772f9d683a0bc29c8cdad5c8b73b47a4064c001a84e538adeae7460f2a4e849f2156
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.0
|
|
1
|
+
4.1.0-preview1
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Development moves to Ruby 4.1.0-preview1 (`.ruby-version`). CI runs the suite on both 4.0.6 and 4.1.0-preview1, and rubocop on whatever `.ruby-version` names. `required_ruby_version` is unchanged.
|
|
8
|
+
- `alock skill install` and `alock skill path` are now `alock skills install` and `alock skills path`. The old `skill` spelling is gone.
|
|
9
|
+
- `alock skills install --help` names every skill it installs, and renders at all: an empty example string used to crash dry-cli-help, and the launcher exited 0 with no output.
|
|
10
|
+
|
|
11
|
+
## [2.1.0]
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Help screens come from `dry-cli-help`: `alock -h` now opens with the gem's title and a description of what it does and how the two backends are chosen, lists commands in registration order, and wraps everything at 85 columns. The hand-written backend banner that used to print above dry-cli's own help is gone.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Finding a Redis now cascades: `REDIS_URL` is tried first when it is set, then `redis://127.0.0.1:6379/0`, and only when neither answers does a virgin tree default to the file store. Previously `REDIS_URL` replaced the local default rather than preceding it, so a shared Redis being down sent the tree straight to the filesystem even with one running locally. `RedisStore.url` now reports the URL that actually answered.
|
|
20
|
+
|
|
5
21
|
## [0.2.0]
|
|
6
22
|
|
|
7
23
|
### Added
|
data/README.md
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
# Agent
|
|
1
|
+
# Agent Lock `agent-lock` CLI
|
|
2
2
|
|
|
3
3
|
[](https://github.com/kigster/agent-lock/actions/workflows/main.yml)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A CLI utility `alock` that supports advisory locks on files and folders with pluggable backends (redis and file-system provided out the box, with redis being the default if it's available locally). This locking tool is meant to be used by the coding agents that share a project.
|
|
6
|
+
|
|
7
|
+
> [!NOTE]
|
|
8
|
+
>
|
|
9
|
+
> Please note that `agent-lock` is part of a three-part system: [`agentilda`](htttps://github.com/kigster/agentilda) is an AI harness workflow that works by creating specs, plans, and executing the plan until one or more PRs passing CI are created, and [`agentilda-ai-setup`](https://kigster/agentilda-ai-setup) — the GitHub repo that's a mixture of BASH and Ruby installers. It's comes with the [`configuration.yml`](https://github.com/kigster/agentilda-ai-setup/blob/main/configuration.example.yml) file, which determines what skills, commands, plugins and AI coding agents are locally installed.
|
|
10
|
+
>
|
|
11
|
+
> That said, you can absolutely use `agent-lock` gem in your own environment.
|
|
6
12
|
|
|
7
13
|
## What it is
|
|
8
14
|
|
|
@@ -18,6 +24,8 @@ Git does not help here. Two agents on one branch and one working tree never prod
|
|
|
18
24
|
|
|
19
25
|
- **Harnesses** that launch agents over a repository and need them to stay out of each other's way.
|
|
20
26
|
|
|
27
|
+
- **Supports multiple local nodes** with the same project directories, if `$REDIS_URL` is set to a non-local Redis instance (it needs to be set to the same value on all participating nodes)
|
|
28
|
+
|
|
21
29
|
Not for work that can have a checkout of its own. A git worktree per agent removes the sharing altogether, which is better than coordinating it. The locks are advisory: they protect a file only from agents that check. `--enforce` exists for the few files that must not move at all.
|
|
22
30
|
|
|
23
31
|
## How to use it
|
|
@@ -26,7 +34,8 @@ Not for work that can have a checkout of its own. A git worktree per agent remov
|
|
|
26
34
|
|
|
27
35
|
```bash
|
|
28
36
|
gem install agent-lock
|
|
29
|
-
|
|
37
|
+
hash -r
|
|
38
|
+
alock version # alock must be on PATH
|
|
30
39
|
```
|
|
31
40
|
|
|
32
41
|
Or add `gem "agent-lock"` to a Gemfile.
|
|
@@ -98,10 +107,10 @@ Three things matter, and each one fails silently if skipped:
|
|
|
98
107
|
The gem ships a skill that teaches an agent all of the above, so the rules reach the agents rather than living only in this README. Install it into the skills directory your agent reads:
|
|
99
108
|
|
|
100
109
|
```bash
|
|
101
|
-
alock
|
|
102
|
-
alock
|
|
103
|
-
alock
|
|
104
|
-
alock
|
|
110
|
+
alock skills install # default: into ~/.agents/skills, for most agents
|
|
111
|
+
alock skills install --for claude # into ~/.claude/skills instead
|
|
112
|
+
alock skills install --into some/path # anywhere else, --for is ignored if both are given
|
|
113
|
+
alock skills path # where the bundled copy is
|
|
105
114
|
```
|
|
106
115
|
|
|
107
116
|
`install` refuses to overwrite a copy that differs (`--force` replaces it) and never touches a symlink, since a symlink is some other installer's.
|
|
@@ -281,8 +290,8 @@ Only live claims are counted as held. `--json` gives every record its `status` a
|
|
|
281
290
|
| `release-all` | Everything this session and its sub-agents hold | 0 |
|
|
282
291
|
| `break <scope>` | Take a live lock away from its holder | 0 |
|
|
283
292
|
| `whoami` | The name this session signs locks with, and its parent | 0 |
|
|
284
|
-
| `
|
|
285
|
-
| `
|
|
293
|
+
| `skills install` | Copy the bundled skill into a skills directory | 1 if a different copy or a symlink is there |
|
|
294
|
+
| `skills path` | Where the bundled skill is | 0 |
|
|
286
295
|
| `completion bash\|zsh` | Print a shell completion script | 1 for any other shell |
|
|
287
296
|
|
|
288
297
|
Flags:
|
|
@@ -316,11 +325,13 @@ Names every command and flag `alock` currently knows, since the script is genera
|
|
|
316
325
|
| `AGENT_LOCK_MUTEX_TIMEOUT` | `15` | Seconds a claim waits for the store's mutex before giving up with exit 2 |
|
|
317
326
|
| `AGENT_LOCK_BACKEND` | `redis` if one answers, else `file` | `file` or `redis` |
|
|
318
327
|
| `AGENT_LOCK_TTL_SECONDS` | `0` | Redis expiry. `0` means no TTL |
|
|
319
|
-
| `REDIS_URL` | `redis://127.0.0.1:6379/0`
|
|
328
|
+
| `REDIS_URL` | unset | A shared Redis, tried before `redis://127.0.0.1:6379/0` |
|
|
320
329
|
|
|
321
330
|
## Backends
|
|
322
331
|
|
|
323
|
-
Redis stores the same documents as the file store, and buys two things a filesystem cannot: its mutex holds across machines, and a TTL expires an abandoned lock without anybody having to reason about liveness. A tree defaults to Redis when one answers
|
|
332
|
+
Redis stores the same documents as the file store, and buys two things a filesystem cannot: its mutex holds across machines, and a TTL expires an abandoned lock without anybody having to reason about liveness. A tree defaults to Redis when one answers, and falls back to the file store, which needs nothing installed, when none does.
|
|
333
|
+
|
|
334
|
+
The search for a Redis runs in a fixed order: `REDIS_URL` first, when it is set, then `redis://127.0.0.1:6379/0`. A `REDIS_URL` nobody answers on is not the end of it, since the usual reason to set one is a shared instance that is occasionally down, and a local Redis is still a better lock store than the filesystem. Only when neither answers does the tree land on the file store. `alock list` names the store in use, so it is never a guess which one you are on.
|
|
324
335
|
|
|
325
336
|
```bash
|
|
326
337
|
AGENT_LOCK_BACKEND=redis alock acquire workflow/** # force it, rather than autodetect
|
data/Rakefile
CHANGED
|
@@ -2,11 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
require "bundler/gem_tasks"
|
|
4
4
|
require "rspec/core/rake_task"
|
|
5
|
+
require "timeout"
|
|
6
|
+
require "yard"
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
def shell(*args)
|
|
9
|
+
puts "running: #{args.join(" ")}"
|
|
10
|
+
system(args.join(" "))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Clean all temporary files"
|
|
14
|
+
task :clean do
|
|
15
|
+
shell("rm -rf pkg/ tmp/ coverage/ doc/ ")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Build the gem locally into pkg/"
|
|
19
|
+
task gem: [:build] do
|
|
20
|
+
shell("gem install pkg/*")
|
|
21
|
+
end
|
|
7
22
|
|
|
8
|
-
|
|
23
|
+
desc "Set permissions on all files so that users can read them"
|
|
24
|
+
task permissions: [:clean] do
|
|
25
|
+
# One traversal replaces a six-level glob chain that printed "No such file
|
|
26
|
+
# or directory" for every level this project does not have, skipped dotfiles
|
|
27
|
+
# entirely, and silently stopped at depth six. .git is pruned — its objects
|
|
28
|
+
# have no business being group-readable.
|
|
29
|
+
shell("find . -path ./.git -prune -o -type d -exec chmod o+rx,g+rx {} + -o -type f -exec chmod o+r,g+r {} +")
|
|
30
|
+
end
|
|
9
31
|
|
|
10
|
-
|
|
32
|
+
desc "Build the gem and set the permissions"
|
|
33
|
+
task build: :permissions
|
|
34
|
+
|
|
35
|
+
desc "Generate yard documentation"
|
|
36
|
+
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
37
|
+
t.files = %w[lib/**/*.rb exe/*.rb - README.md CHANGELOG.md AGENTS.md LICENSE.txt]
|
|
38
|
+
t.options.unshift("--title", '"FlowEngine — DSL + AST for buildiong complex flows in Ruby."')
|
|
39
|
+
t.after = -> { exec("open doc/index.html") } if RUBY_PLATFORM.match?(/darwin/)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
11
43
|
|
|
12
|
-
task default:
|
|
44
|
+
task default: :spec
|
|
@@ -9,7 +9,7 @@ module Agent
|
|
|
9
9
|
module Commands
|
|
10
10
|
# Where the bundled skill is, for a harness that would rather link it
|
|
11
11
|
# than copy it, or a configuration that names it by path.
|
|
12
|
-
class
|
|
12
|
+
class SkillsPath < Base
|
|
13
13
|
desc "Print the directory of the skill this gem ships"
|
|
14
14
|
|
|
15
15
|
def call(**)
|
|
@@ -19,8 +19,8 @@ module Agent
|
|
|
19
19
|
|
|
20
20
|
# Copy the bundled skill into a skills directory, so an agent learns
|
|
21
21
|
# how to claim files before it first needs to.
|
|
22
|
-
class
|
|
23
|
-
desc "Copy the
|
|
22
|
+
class SkillsInstall < Base
|
|
23
|
+
desc "Copy the skills this gem ships into a skills directory: #{Skill.bundled.join(", ")}"
|
|
24
24
|
|
|
25
25
|
option :into, type: :string, default: nil, aliases: ["-o"],
|
|
26
26
|
desc: "The skills directory, default ~/.agents/skills"
|
|
@@ -29,8 +29,13 @@ module Agent
|
|
|
29
29
|
option :force, type: :boolean, default: false, aliases: ["-f"],
|
|
30
30
|
desc: "Replace a copy that differs from this one"
|
|
31
31
|
|
|
32
|
-
example
|
|
33
|
-
|
|
32
|
+
# An empty example crashes dry-cli-help's renderer, so the default
|
|
33
|
+
# install is spelled out as an option-free line with a comment.
|
|
34
|
+
example [
|
|
35
|
+
" # into ~/.agents/skills",
|
|
36
|
+
"--for claude # into ~/.claude/skills",
|
|
37
|
+
"--into ~/some/skills --force # replace a copy that differs"
|
|
38
|
+
]
|
|
34
39
|
|
|
35
40
|
# @param options [Hash]
|
|
36
41
|
def call(**options)
|
|
@@ -63,7 +68,7 @@ module Agent
|
|
|
63
68
|
when :current then say("UP TO DATE #{result.path}")
|
|
64
69
|
when :differs
|
|
65
70
|
warn_("REFUSED: #{result.path} differs from the copy this gem ships")
|
|
66
|
-
warn_(" #{program}
|
|
71
|
+
warn_(" #{program} skills install --force # replace it")
|
|
67
72
|
when :linked
|
|
68
73
|
warn_("REFUSED: #{result.path} is a symlink, so something else installs it; left alone")
|
|
69
74
|
end
|
data/lib/agent/lock/cli.rb
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "manager"
|
|
4
|
+
require_relative "version"
|
|
4
5
|
require "dry/cli"
|
|
6
|
+
require "dry/cli/help"
|
|
5
7
|
|
|
6
8
|
module Agent
|
|
7
9
|
module Lock
|
|
@@ -15,6 +17,32 @@ module Agent
|
|
|
15
17
|
# line, so guessing it wrong is not a cosmetic mistake.
|
|
16
18
|
PROGRAM_NAME = "alock"
|
|
17
19
|
|
|
20
|
+
# What `alock -h` says before it lists the commands. Wrapped by
|
|
21
|
+
# dry-cli-help at HELP_WIDTH rather than the terminal's width, so the
|
|
22
|
+
# screen reads the same in a wide terminal, a narrow one, and a log.
|
|
23
|
+
HELP_WIDTH = 85
|
|
24
|
+
|
|
25
|
+
DESCRIPTION = <<~TEXT
|
|
26
|
+
Advisory locks for AI coding agents working concurrently in one checkout.
|
|
27
|
+
An agent claims the file or directory it is about to write, and every other
|
|
28
|
+
agent that checks sees who holds it and why. Nothing is enforced: the locks
|
|
29
|
+
work because every agent checks before it writes.
|
|
30
|
+
|
|
31
|
+
Locks live in one of two backends. Redis, when one answers on REDIS_URL or
|
|
32
|
+
on localhost:6379, holds across machines and can expire an abandoned lock.
|
|
33
|
+
The file store, used when no Redis answers, needs nothing installed. The
|
|
34
|
+
first process in a tree records which backend it chose, and every later
|
|
35
|
+
process in that tree stays on it. Set AGENT_LOCK_BACKEND to `redis` or
|
|
36
|
+
`file` to choose one yourself.
|
|
37
|
+
TEXT
|
|
38
|
+
|
|
39
|
+
Dry::CLI::Help.configure do
|
|
40
|
+
title "Agent Lock, Version #{Agent::Lock::VERSION}"
|
|
41
|
+
description DESCRIPTION
|
|
42
|
+
epilogue "Documentation: https://github.com/kigster/agent-lock"
|
|
43
|
+
width HELP_WIDTH
|
|
44
|
+
end
|
|
45
|
+
|
|
18
46
|
# A registry whose commands are already bound to this launcher, so a
|
|
19
47
|
# command writes to the streams it was given rather than to the process's.
|
|
20
48
|
#
|
|
@@ -53,7 +81,7 @@ require_relative "cli/commands/break"
|
|
|
53
81
|
require_relative "cli/commands/note"
|
|
54
82
|
require_relative "cli/commands/resume"
|
|
55
83
|
require_relative "cli/commands/whoami"
|
|
56
|
-
require_relative "cli/commands/
|
|
84
|
+
require_relative "cli/commands/skills"
|
|
57
85
|
require_relative "cli/commands/version"
|
|
58
86
|
require_relative "cli/commands/completion"
|
|
59
87
|
|
|
@@ -71,8 +99,8 @@ module Agent
|
|
|
71
99
|
"note" => [Commands::Note, []],
|
|
72
100
|
"resume" => [Commands::Resume, []],
|
|
73
101
|
"whoami" => [Commands::Whoami, []],
|
|
74
|
-
"
|
|
75
|
-
"
|
|
102
|
+
"skills path" => [Commands::SkillsPath, []],
|
|
103
|
+
"skills install" => [Commands::SkillsInstall, []],
|
|
76
104
|
"version" => [Commands::Version, %w[-v --version]]
|
|
77
105
|
}.freeze
|
|
78
106
|
end
|
data/lib/agent/lock/launcher.rb
CHANGED
|
@@ -70,8 +70,6 @@ module Agent
|
|
|
70
70
|
# @return [void] always exits, with 0 unless something said otherwise
|
|
71
71
|
# rubocop:disable-next Metrics/AbcSize
|
|
72
72
|
def execute!
|
|
73
|
-
backend_banner if %w[-h --help].intersect?(argv)
|
|
74
|
-
|
|
75
73
|
code = 0
|
|
76
74
|
Dry::CLI.new(CLI.registry_for(self)).call(arguments: argv, out: stdout, err: stderr)
|
|
77
75
|
rescue SystemExit => e
|
|
@@ -93,34 +91,6 @@ module Agent
|
|
|
93
91
|
def p(msg = "")
|
|
94
92
|
stdout.puts(msg)
|
|
95
93
|
end
|
|
96
|
-
|
|
97
|
-
# The two backends, ahead of dry-cli's own `--help` for each command, so
|
|
98
|
-
# a reader learns the shape of the choice before any subcommand's flags.
|
|
99
|
-
#
|
|
100
|
-
# @return [void]
|
|
101
|
-
# rubocop:disable-next Metrics/AbcSize
|
|
102
|
-
def backend_banner
|
|
103
|
-
p(bold(yellow("Agent Lock, Version #{green(Agent::Lock::VERSION)}")))
|
|
104
|
-
p
|
|
105
|
-
p(bold(blue("Usage:")))
|
|
106
|
-
p(" alock [command [ subcommand ]] [options]")
|
|
107
|
-
p
|
|
108
|
-
p(bold(blue("Description:")))
|
|
109
|
-
p(" This is a CLI utility aimed at the agents working concurrently in the same")
|
|
110
|
-
p(" environment, sharing filesystem, worktrees, etc. Agent Lock allows fine-grained")
|
|
111
|
-
p(" and effective locking, and can use multiple backends to store and maintain locks.")
|
|
112
|
-
p
|
|
113
|
-
p(cyan(" • Redis-Based Locking"))
|
|
114
|
-
p(" This mechanism uses locally running Redis instance to coordinate access to shared")
|
|
115
|
-
p(" resources (default, if Redis is available and accessible).")
|
|
116
|
-
p
|
|
117
|
-
p(cyan(" • File System Locking"))
|
|
118
|
-
p(" This mechanism uses file system locks to coordinate access to shared resources.")
|
|
119
|
-
p
|
|
120
|
-
p(" You can set the environment variable #{yellow("AGENT_LOCK_BACKEND")} to either")
|
|
121
|
-
p(" 'redis' or 'file' to override the default.")
|
|
122
|
-
p
|
|
123
|
-
end
|
|
124
94
|
end
|
|
125
95
|
end
|
|
126
96
|
end
|
data/lib/agent/lock/skill.rb
CHANGED
|
@@ -30,6 +30,10 @@ module Agent
|
|
|
30
30
|
# @return [String] the bundled skill's directory
|
|
31
31
|
def source = File.join(ROOT, NAME)
|
|
32
32
|
|
|
33
|
+
# @return [Array<String>] the name of every skill the gem ships, so
|
|
34
|
+
# help text can say what `install` puts on disk
|
|
35
|
+
def bundled = Dir.children(ROOT).select { |name| File.directory?(File.join(ROOT, name)) }.sort
|
|
36
|
+
|
|
33
37
|
# @return [String] where most agents other than Claude Code look for
|
|
34
38
|
# a user's own skills; the CLI's `--for claude` points at
|
|
35
39
|
# `~/.claude/skills` instead
|
|
@@ -20,10 +20,14 @@ module Agent
|
|
|
20
20
|
# markdown document either way.
|
|
21
21
|
#
|
|
22
22
|
# Picked with AGENT_LOCK_BACKEND=redis, or by default when one answers on
|
|
23
|
-
# REDIS_URL
|
|
23
|
+
# REDIS_URL, or failing that on the local default. See Store's moduledoc
|
|
24
|
+
# for how that default is decided.
|
|
24
25
|
class RedisStore
|
|
25
26
|
NAMESPACE = "agent-lock"
|
|
26
27
|
|
|
28
|
+
# Tried after REDIS_URL, or alone when it is unset.
|
|
29
|
+
LOCAL_URL = "redis://127.0.0.1:6379/0"
|
|
30
|
+
|
|
27
31
|
# How long the store mutex outlives a holder that died holding it. A
|
|
28
32
|
# claim's critical section is a SCAN and one SET, so ten seconds is
|
|
29
33
|
# somebody gone, not somebody busy.
|
|
@@ -206,15 +210,59 @@ module Agent
|
|
|
206
210
|
end
|
|
207
211
|
|
|
208
212
|
class << self
|
|
209
|
-
|
|
213
|
+
# The URL of the Redis actually in use, once one has answered, or
|
|
214
|
+
# the first one that will be tried before then.
|
|
215
|
+
#
|
|
216
|
+
# @return [String]
|
|
217
|
+
def url = @url || candidate_urls.first
|
|
218
|
+
|
|
219
|
+
# Where to look, in order: `REDIS_URL` when set, then the local
|
|
220
|
+
# default. A `REDIS_URL` that nobody answers on is not the end of
|
|
221
|
+
# the search, because the usual reason it is set is a shared
|
|
222
|
+
# instance that is sometimes down, and a local one is still better
|
|
223
|
+
# than falling all the way back to the filesystem.
|
|
224
|
+
#
|
|
225
|
+
# @return [Array<String>]
|
|
226
|
+
def candidate_urls
|
|
227
|
+
configured = ENV["REDIS_URL"].to_s.strip
|
|
228
|
+
[configured.empty? ? nil : configured, LOCAL_URL].compact.uniq
|
|
229
|
+
end
|
|
210
230
|
|
|
231
|
+
# Tries each candidate URL in turn and keeps the first that answers.
|
|
232
|
+
#
|
|
211
233
|
# @return Array[RedisClient,NilClass,Exception] the client if it could be created,
|
|
212
|
-
# or the error that prevented it
|
|
234
|
+
# or the error that prevented it (the last one tried)
|
|
213
235
|
def create_client
|
|
214
|
-
@client
|
|
215
|
-
|
|
236
|
+
return [@client, nil] if @client
|
|
237
|
+
|
|
238
|
+
error = nil
|
|
239
|
+
candidate_urls.each do |candidate|
|
|
240
|
+
client, error = connect(candidate)
|
|
241
|
+
next unless client
|
|
242
|
+
|
|
243
|
+
@url = candidate
|
|
244
|
+
@client = client
|
|
245
|
+
return [@client, nil]
|
|
216
246
|
end
|
|
217
|
-
[
|
|
247
|
+
[nil, error]
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Drops the memoized client, so the next `create_client` probes again.
|
|
251
|
+
#
|
|
252
|
+
# @return [void]
|
|
253
|
+
def reset!
|
|
254
|
+
@client = nil
|
|
255
|
+
@url = nil
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
private
|
|
259
|
+
|
|
260
|
+
# @param candidate [String]
|
|
261
|
+
# @return Array[RedisClient,NilClass,Exception]
|
|
262
|
+
def connect(candidate)
|
|
263
|
+
client = ::Redis.new(url: candidate)
|
|
264
|
+
client.info["redis_version"]
|
|
265
|
+
[client, nil]
|
|
218
266
|
rescue Redis::CannotConnectError, Redis::BaseError, Errno::ECONNREFUSED, SocketError => e
|
|
219
267
|
[nil, e]
|
|
220
268
|
end
|
data/lib/agent/lock/store.rb
CHANGED
|
@@ -12,7 +12,8 @@ module Agent
|
|
|
12
12
|
#
|
|
13
13
|
# AGENT_LOCK_BACKEND wins when set. Otherwise a tree that already has a
|
|
14
14
|
# marker keeps using it. A virgin tree defaults to Redis when one answers
|
|
15
|
-
#
|
|
15
|
+
# on REDIS_URL or, failing that, on the local default; file when neither
|
|
16
|
+
# does.
|
|
16
17
|
#
|
|
17
18
|
# That default is still never a runtime auto-*switch*: once a marker
|
|
18
19
|
# exists, every later process in that tree is bound to it regardless of
|
|
@@ -90,7 +91,8 @@ module Agent
|
|
|
90
91
|
|
|
91
92
|
def marker_path(tree) = File.join(tree.store_dir, MARKER)
|
|
92
93
|
|
|
93
|
-
# @return [String] "redis" when one answers on REDIS_URL,
|
|
94
|
+
# @return [String] "redis" when one answers on REDIS_URL or, failing
|
|
95
|
+
# that, on RedisStore::LOCAL_URL; "file" when neither does
|
|
94
96
|
def default_backend
|
|
95
97
|
local_redis_available? ? "redis" : "file"
|
|
96
98
|
end
|
data/lib/agent/lock/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,182 +1,187 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: agent-lock
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Konstantin Gredeskoul
|
|
7
|
+
- Konstantin Gredeskoul
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- !ruby/object:Gem::
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- !ruby/object:Gem::
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: dry-cli
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "1.4"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "1.4"
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: dry-cli-autocomplete
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
-
|
|
33
|
+
- ~>
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: "0.6"
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
-
|
|
41
|
+
- ~>
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: "0.6"
|
|
44
|
+
- !ruby/object:Gem::Dependency
|
|
45
|
+
name: dry-cli-help
|
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
-
|
|
49
|
+
- ~>
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: "0.6"
|
|
52
|
+
type: :runtime
|
|
53
|
+
prerelease: false
|
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
-
|
|
57
|
+
- ~>
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: "0.6"
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: dry-cli-ui
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
-
|
|
65
|
+
- ~>
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: "0.7"
|
|
68
|
+
type: :runtime
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
-
|
|
73
|
+
- ~>
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: "0.7"
|
|
76
|
+
- !ruby/object:Gem::Dependency
|
|
77
|
+
name: pastel
|
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
-
|
|
81
|
+
- ~>
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: "0.8"
|
|
84
|
+
type: :runtime
|
|
85
|
+
prerelease: false
|
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
-
|
|
89
|
+
- ~>
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: "0.8"
|
|
92
|
+
- !ruby/object:Gem::Dependency
|
|
93
|
+
name: redis
|
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
|
95
|
+
requirements:
|
|
96
|
+
-
|
|
97
|
+
- ~>
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: "5.0"
|
|
100
|
+
type: :runtime
|
|
101
|
+
prerelease: false
|
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
103
|
+
requirements:
|
|
104
|
+
-
|
|
105
|
+
- ~>
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: "5.0"
|
|
108
|
+
description: "This compact ruby gem is purely CLI utility: it's meant to be used by a team of AI agentsexecuting along one or more the plans in a given repo. Using worktrees and parallelism it's easy to 10x the speed of develpoment of software development compared to even a single agent working on it. Plus each agent can specialize. Such agents require globsl shared locking mechanism to ensure they are not working on the same directory, or the same files in same worktree. That is exactly what this gem does. The CLI binary you invoke is called 'alock'which comes with sub-command 'completion' which you can load for BASH or ZSH. However, you are not very likely going toinvoke this gem directly. It's used by an Agentic Workflow gem 'agentilda' to protect shared resources. To try the entire system, it's recommended to download the repo https://github.com/kigster/agentilda-ai-setup which both installs the two gems, and offers a configuration file that installs a set of coding agents, skills, plugins, commands, from various guthub folders, or via running commands, and so on. In other words the repo's purpose is to ensure your agentic setup is identical from machine to machine, and by modifying the config file you can pick and choose your skills, your AGENT.md/CLAUDE.md file and so on."
|
|
105
109
|
email:
|
|
106
|
-
- kigster@gmail.com
|
|
110
|
+
- kigster@gmail.com
|
|
107
111
|
executables:
|
|
108
|
-
- agent-lock
|
|
109
|
-
- alock
|
|
112
|
+
- agent-lock
|
|
113
|
+
- alock
|
|
110
114
|
extensions: []
|
|
111
115
|
extra_rdoc_files: []
|
|
112
116
|
files:
|
|
113
|
-
-
|
|
114
|
-
-
|
|
115
|
-
- AGENTS.md
|
|
116
|
-
- CHANGELOG.md
|
|
117
|
-
- LICENSE.txt
|
|
118
|
-
- README.md
|
|
119
|
-
- Rakefile
|
|
120
|
-
- exe/agent-lock
|
|
121
|
-
- exe/alock
|
|
122
|
-
- justfile
|
|
123
|
-
- lib/agent/lock.rb
|
|
124
|
-
- lib/agent/lock/cli.rb
|
|
125
|
-
- lib/agent/lock/cli/commands/acquire.rb
|
|
126
|
-
- lib/agent/lock/cli/commands/base.rb
|
|
127
|
-
- lib/agent/lock/cli/commands/break.rb
|
|
128
|
-
- lib/agent/lock/cli/commands/check.rb
|
|
129
|
-
- lib/agent/lock/cli/commands/completion.rb
|
|
130
|
-
- lib/agent/lock/cli/commands/list.rb
|
|
131
|
-
- lib/agent/lock/cli/commands/mine.rb
|
|
132
|
-
- lib/agent/lock/cli/commands/note.rb
|
|
133
|
-
- lib/agent/lock/cli/commands/release.rb
|
|
134
|
-
- lib/agent/lock/cli/commands/release_all.rb
|
|
135
|
-
- lib/agent/lock/cli/commands/resume.rb
|
|
136
|
-
- lib/agent/lock/cli/commands/
|
|
137
|
-
- lib/agent/lock/cli/commands/version.rb
|
|
138
|
-
- lib/agent/lock/cli/commands/whoami.rb
|
|
139
|
-
- lib/agent/lock/error.rb
|
|
140
|
-
- lib/agent/lock/freeze.rb
|
|
141
|
-
- lib/agent/lock/identity.rb
|
|
142
|
-
- lib/agent/lock/launcher.rb
|
|
143
|
-
- lib/agent/lock/manager.rb
|
|
144
|
-
- lib/agent/lock/process_info.rb
|
|
145
|
-
- lib/agent/lock/record.rb
|
|
146
|
-
- lib/agent/lock/scope.rb
|
|
147
|
-
- lib/agent/lock/skill.rb
|
|
148
|
-
- lib/agent/lock/store.rb
|
|
149
|
-
- lib/agent/lock/store/file_system_store.rb
|
|
150
|
-
- lib/agent/lock/store/redis_store.rb
|
|
151
|
-
- lib/agent/lock/tree.rb
|
|
152
|
-
- lib/agent/lock/version.rb
|
|
153
|
-
- sig/agent/lock.rbs
|
|
154
|
-
- skills/agent-lock/SKILL.md
|
|
155
|
-
homepage: https://github.com/kigster/agent-lock
|
|
117
|
+
- .claude/CLAUDE.md
|
|
118
|
+
- .ruby-version
|
|
119
|
+
- AGENTS.md
|
|
120
|
+
- CHANGELOG.md
|
|
121
|
+
- LICENSE.txt
|
|
122
|
+
- README.md
|
|
123
|
+
- Rakefile
|
|
124
|
+
- exe/agent-lock
|
|
125
|
+
- exe/alock
|
|
126
|
+
- justfile
|
|
127
|
+
- lib/agent/lock.rb
|
|
128
|
+
- lib/agent/lock/cli.rb
|
|
129
|
+
- lib/agent/lock/cli/commands/acquire.rb
|
|
130
|
+
- lib/agent/lock/cli/commands/base.rb
|
|
131
|
+
- lib/agent/lock/cli/commands/break.rb
|
|
132
|
+
- lib/agent/lock/cli/commands/check.rb
|
|
133
|
+
- lib/agent/lock/cli/commands/completion.rb
|
|
134
|
+
- lib/agent/lock/cli/commands/list.rb
|
|
135
|
+
- lib/agent/lock/cli/commands/mine.rb
|
|
136
|
+
- lib/agent/lock/cli/commands/note.rb
|
|
137
|
+
- lib/agent/lock/cli/commands/release.rb
|
|
138
|
+
- lib/agent/lock/cli/commands/release_all.rb
|
|
139
|
+
- lib/agent/lock/cli/commands/resume.rb
|
|
140
|
+
- lib/agent/lock/cli/commands/skills.rb
|
|
141
|
+
- lib/agent/lock/cli/commands/version.rb
|
|
142
|
+
- lib/agent/lock/cli/commands/whoami.rb
|
|
143
|
+
- lib/agent/lock/error.rb
|
|
144
|
+
- lib/agent/lock/freeze.rb
|
|
145
|
+
- lib/agent/lock/identity.rb
|
|
146
|
+
- lib/agent/lock/launcher.rb
|
|
147
|
+
- lib/agent/lock/manager.rb
|
|
148
|
+
- lib/agent/lock/process_info.rb
|
|
149
|
+
- lib/agent/lock/record.rb
|
|
150
|
+
- lib/agent/lock/scope.rb
|
|
151
|
+
- lib/agent/lock/skill.rb
|
|
152
|
+
- lib/agent/lock/store.rb
|
|
153
|
+
- lib/agent/lock/store/file_system_store.rb
|
|
154
|
+
- lib/agent/lock/store/redis_store.rb
|
|
155
|
+
- lib/agent/lock/tree.rb
|
|
156
|
+
- lib/agent/lock/version.rb
|
|
157
|
+
- sig/agent/lock.rbs
|
|
158
|
+
- skills/agent-lock/SKILL.md
|
|
159
|
+
homepage: "https://github.com/kigster/agent-lock"
|
|
156
160
|
licenses:
|
|
157
|
-
- MIT
|
|
161
|
+
- MIT
|
|
158
162
|
metadata:
|
|
159
|
-
allowed_push_host: https://rubygems.org
|
|
160
|
-
homepage_uri: https://github.com/kigster/agent-lock
|
|
161
|
-
source_code_uri: https://github.com/kigster/agent-lock
|
|
162
|
-
changelog_uri: https://github.com/kigster/agent-lock/blob/main/CHANGELOG.md
|
|
163
|
-
rubygems_mfa_required:
|
|
163
|
+
allowed_push_host: "https://rubygems.org"
|
|
164
|
+
homepage_uri: "https://github.com/kigster/agent-lock"
|
|
165
|
+
source_code_uri: "https://github.com/kigster/agent-lock"
|
|
166
|
+
changelog_uri: "https://github.com/kigster/agent-lock/blob/main/CHANGELOG.md"
|
|
167
|
+
rubygems_mfa_required: "true"
|
|
164
168
|
rdoc_options: []
|
|
165
169
|
require_paths:
|
|
166
|
-
- lib
|
|
170
|
+
- lib
|
|
167
171
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
172
|
requirements:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
-
|
|
174
|
+
- ">="
|
|
175
|
+
- !ruby/object:Gem::Version
|
|
176
|
+
version: 3.2.0
|
|
172
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
178
|
requirements:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
-
|
|
180
|
+
- ">="
|
|
181
|
+
- !ruby/object:Gem::Version
|
|
182
|
+
version: "0"
|
|
177
183
|
requirements: []
|
|
178
|
-
rubygems_version: 4.0.
|
|
184
|
+
rubygems_version: 4.1.0.beta2
|
|
179
185
|
specification_version: 4
|
|
180
|
-
summary: Advisory locks to prevent race conditions and general mayhem when multiple
|
|
181
|
-
AI agents unknowinly modify the same souce three.
|
|
186
|
+
summary: Advisory locks to prevent race conditions and general mayhem when multiple AI agents unknowinly modify the same souce three.
|
|
182
187
|
test_files: []
|