@avee1234/worklease 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/bin/worklease.js +671 -0
- package/package.json +39 -0
- package/src/adapters/git-hook.js +164 -0
- package/src/check.js +43 -0
- package/src/claim.js +70 -0
- package/src/conformance.js +82 -0
- package/src/glob.js +92 -0
- package/src/index.js +39 -0
- package/src/registry.js +233 -0
- package/src/schema.js +230 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abhi Das
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# worklease
|
|
2
|
+
|
|
3
|
+
**The open coordination format for fleets of AI coding agents.** Before an agent starts editing, it files a *claim* — "I intend to touch `src/auth/**` for the next 20 minutes" — to a shared, conflict-free registry. Other agents see it and steer clear. So parallel agents stop duplicating work and colliding on hotspot files. Zero dependencies.
|
|
4
|
+
|
|
5
|
+
> Working name — see [`vision.md`](vision.md). Grounded in the mid-2026 state of parallel agent coding.
|
|
6
|
+
|
|
7
|
+
Git worktrees are now the default for running many coding agents at once (Claude Code, Codex, Cursor) — but they only isolate the *filesystem*. Nothing warns you when two agents are about to edit the same code, so parallel runs still produce merge conflicts, duplicated features, and logic that compiles but disagrees at runtime. worklease is the missing coordination layer: a format for *intent*, not another orchestrator.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
worklease claim "src/auth/**" --intent "add OAuth" --ttl 20m # I'm taking this
|
|
11
|
+
worklease check "src/auth/login.ts" # is anyone else on it?
|
|
12
|
+
worklease list # who holds what, expiring when
|
|
13
|
+
worklease release <id> # done
|
|
14
|
+
worklease conformance registry.jsonl merges.json # did the fleet actually coordinate?
|
|
15
|
+
worklease hook install # auto-check staged files before every commit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**Why it's different:** advisory, not a hard lock — it *warns and coordinates* so agents can pick different work. The registry is append-only JSONL with content-hash IDs, so it never merge-conflicts with itself even when many agents write at once. Harness-neutral: Claude Code, Codex, Cursor, or a factory worker.
|
|
19
|
+
|
|
20
|
+
Same open-format-and-conformance playbook as [opentrajectory](https://github.com/abhid1234/opentrajectory) and [constraintguard](https://github.com/abhid1234/constraintguard) — the coordination standard for the one thing a fleet can't currently share: *what it's about to touch.*
|
|
21
|
+
|
|
22
|
+
### `worklease claim <globs...>`
|
|
23
|
+
|
|
24
|
+
Files a claim — declares that you intend to edit the given globs, for a reason,
|
|
25
|
+
for a while — and **appends** it to the registry as one JSON line. This is the
|
|
26
|
+
write verb: `check` only ever reports clear until someone has claimed something.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
worklease claim "src/auth/**" --intent "add OAuth" --ttl 20m --agent me
|
|
30
|
+
worklease claim "src/api/**" --intent "rate limits" --json # print the claim object
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- `--intent <str>` — **required**; why you're claiming (a claim without intent
|
|
34
|
+
isn't useful — it's what lets another agent decide to wait or pick other work).
|
|
35
|
+
- `--ttl <dur>` — lease length: `<n>s`/`<n>m`/`<n>h` (e.g. `90s`, `20m`, `2h`) or a
|
|
36
|
+
bare integer number of seconds. Default `30m`.
|
|
37
|
+
- `--agent <id>` (or `WORKLEASE_AGENT`) — who is filing; **required**.
|
|
38
|
+
- `--registry <path>` (or `WORKLEASE_REGISTRY`) — registry file location
|
|
39
|
+
(default `.worklease/registry.jsonl`; the parent directory is created if
|
|
40
|
+
missing).
|
|
41
|
+
- `--json` — print the created claim object instead of the human summary.
|
|
42
|
+
|
|
43
|
+
The written record is a fully-valid claim: `id` is the registry's deterministic
|
|
44
|
+
content hash of the record, and `expires` is `created + ttl`. The claim is
|
|
45
|
+
validated before it's written, so an unsupported glob is rejected rather than
|
|
46
|
+
appended. Exit `0` on write, `1` on any input or validation error.
|
|
47
|
+
|
|
48
|
+
The library also exports the pure `makeClaim(globs, meta)` constructor (no I/O,
|
|
49
|
+
no clock — `created` is passed in) for building claims programmatically.
|
|
50
|
+
|
|
51
|
+
### `worklease check <globs...>`
|
|
52
|
+
|
|
53
|
+
Asks whether your planned edit overlaps any **active** claim held by **another**
|
|
54
|
+
agent — the safe pre-edit question. Overlap is decided purely from the glob
|
|
55
|
+
strings (conservative *satisfiability*: any concrete path could match both), with
|
|
56
|
+
no filesystem access, so it is correct even for files that don't exist yet.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
worklease check "src/auth/**" # human summary; exit 1 on conflict
|
|
60
|
+
worklease check "src/**/*.ts" --json # { clear, conflicts: [...] } for harnesses
|
|
61
|
+
worklease check "src/auth/**" --agent me # my own claims count as clear
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- `--agent <id>` (or `WORKLEASE_AGENT`) — treat your own claims as clear.
|
|
65
|
+
- `--registry <path>` (or `WORKLEASE_REGISTRY`) — registry file location
|
|
66
|
+
(default `.worklease/registry.jsonl`).
|
|
67
|
+
- `--json` — emit `{ clear, conflicts }` verbatim.
|
|
68
|
+
- Exit `0` when clear, `1` when any conflict — an advisory signal a pre-edit hook
|
|
69
|
+
can gate on, not a hard lock.
|
|
70
|
+
|
|
71
|
+
### `worklease list`
|
|
72
|
+
|
|
73
|
+
Shows the active claims — who holds what, and when each lease expires — resolved
|
|
74
|
+
from the append log at read time (latest claim per id, releases applied, and
|
|
75
|
+
TTL-expired claims treated as inactive). One row each, sorted by soonest expiry.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
worklease list # active claims: agent, globs, intent, expiry, id8
|
|
79
|
+
worklease list --all # also released + expired, labeled
|
|
80
|
+
worklease list --agent me # only my claims
|
|
81
|
+
worklease list --json # the resolved claim array, for harnesses
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- `--all` — include `released` and `expired` claims, each labeled with its
|
|
85
|
+
effective status (default shows only `active`).
|
|
86
|
+
- `--agent <id>` — filter to a single holder.
|
|
87
|
+
- `--json` — emit the resolved claim array verbatim (each claim carries its
|
|
88
|
+
effective `status`).
|
|
89
|
+
- `--registry <path>` (or `WORKLEASE_REGISTRY`) — registry file location.
|
|
90
|
+
- An empty or missing registry prints `no active claims` (`[]` under `--json`)
|
|
91
|
+
and exits `0`.
|
|
92
|
+
|
|
93
|
+
### `worklease release <id>`
|
|
94
|
+
|
|
95
|
+
Drops a claim you're done with by **appending** a release record — it never edits
|
|
96
|
+
or deletes the original claim line, so a concurrent writer can't be lost.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
worklease release fb964bcd # by short id (unambiguous prefix)
|
|
100
|
+
worklease release <full-id> --agent me # record who released it
|
|
101
|
+
worklease release <id> --json # print the appended release record
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- Resolves the target by full `id` or an **unambiguous** id prefix (the short ids
|
|
105
|
+
`list` prints work); an ambiguous prefix or an unknown id is an error (exit `1`).
|
|
106
|
+
- `--agent <id>` (or `WORKLEASE_AGENT`) — who is releasing; a release by someone
|
|
107
|
+
other than the holder is allowed but noted (advisory cleanup across the fleet).
|
|
108
|
+
- Releasing an already-`released` or already-`expired` claim is a **no-op** with a
|
|
109
|
+
note (still exit `0` — the desired end state already holds).
|
|
110
|
+
- `--registry <path>` (or `WORKLEASE_REGISTRY`) — registry file location.
|
|
111
|
+
|
|
112
|
+
### `worklease conformance <registry> <merges>`
|
|
113
|
+
|
|
114
|
+
Scores, **after the fact**, whether the fleet actually coordinated. Given the
|
|
115
|
+
registry and a **merges** file — the concrete files each agent touched — it grades
|
|
116
|
+
every `(agent, file)` change: did the acting agent hold a claim covering the file,
|
|
117
|
+
and did it edit a file under another agent's live claim?
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
worklease conformance .worklease/registry.jsonl merges.json # human summary; exit 1 on any violation
|
|
121
|
+
worklease conformance registry.jsonl merges.json --json # { score, total, respected, violations, warnings }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The **merges** file is a JSON array (or JSONL, one per line) of merge records
|
|
125
|
+
`{ agent, files: ["path", …], at? }`, where `at` is the optional ISO-8601-UTC
|
|
126
|
+
time the change landed. Each record is flattened to one change per touched file.
|
|
127
|
+
|
|
128
|
+
- **respected** — the agent held a matching claim for the file *and* it collided
|
|
129
|
+
with no other agent's live claim. These are the numerator of the score.
|
|
130
|
+
- **violation** — the file fell under a **different** agent's claim active at the
|
|
131
|
+
change time (temporal `created ≤ at < expires` when `at` is given, else the
|
|
132
|
+
claim's `status`). One entry per conflicting claim, each with the full
|
|
133
|
+
`conflicting_claim` record. This is the collision worklease exists to prevent.
|
|
134
|
+
- **warning** — the change was **uncovered** and collided with no one (an edit to
|
|
135
|
+
an unclaimed file). It lowers the score but is **not** a failure.
|
|
136
|
+
- `score` = `respected / total`, a float in `[0, 1]` (`1` when there are no
|
|
137
|
+
changes). A fleet that never claims anything scores `0` — the score rewards
|
|
138
|
+
coverage, not just the absence of collisions.
|
|
139
|
+
- Exit `0` when there are **no violations**, `1` when any violation is found. A
|
|
140
|
+
low score from warnings alone does **not** fail — the score is advisory, the
|
|
141
|
+
non-zero exit a hint a CI/merge gate *may* act on.
|
|
142
|
+
- Missing registry or merges files are tolerated as empty inputs; a malformed
|
|
143
|
+
merges JSON is a clear error (exit `1`).
|
|
144
|
+
|
|
145
|
+
### `worklease hook install`
|
|
146
|
+
|
|
147
|
+
Installs a **git pre-commit hook** that runs `worklease check` on the files a
|
|
148
|
+
commit is about to change — the dogfood adapter that makes worklease actually
|
|
149
|
+
catch collisions in a live parallel-agent setup, before the edit lands.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
worklease hook install # advisory: prints conflicts, never blocks a commit
|
|
153
|
+
worklease hook install --strict # strict: a conflict aborts the commit (exit 1)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The hook is **advisory by default** (roadmap principle #1 — coordinate, don't
|
|
157
|
+
enforce): on a conflict it prints who holds the overlapping globs and lets the
|
|
158
|
+
commit through. `--strict` makes a conflict fatal so git aborts the commit.
|
|
159
|
+
Install is **idempotent** and **preserves an existing hook** — it manages only a
|
|
160
|
+
marked block (`# >>> worklease >>>` … `# <<< worklease <<<`), so re-running it
|
|
161
|
+
never duplicates the block or clobbers hand-written hook logic. A committed
|
|
162
|
+
[`examples/pre-commit.sample`](examples/pre-commit.sample) shows what it writes.
|
|
163
|
+
|
|
164
|
+
Under the hood the hook calls `worklease hook run`, which lists the staged files
|
|
165
|
+
(`git diff --cached --name-only`) and checks them against active claims. Set
|
|
166
|
+
`WORKLEASE_AGENT` in the commit environment so your own claims count as clear.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
worklease hook run # what the hook runs: check staged files (exit 0 even on conflict)
|
|
170
|
+
worklease hook run --strict # exit 1 on conflict, for a blocking hook
|
|
171
|
+
worklease hook run --json # { clear, conflicts: [...] } for tooling
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### The registry
|
|
175
|
+
|
|
176
|
+
The store is an **append-only JSONL file** (default `.worklease/registry.jsonl`),
|
|
177
|
+
meant to be **committed** so it's shareable across worktrees and harnesses. New
|
|
178
|
+
records are appended as whole lines; existing lines are never rewritten. Every
|
|
179
|
+
record's `id` is a content hash of its own content, so a duplicated append is
|
|
180
|
+
idempotent on read and two agents appending at once union-merge cleanly instead
|
|
181
|
+
of conflicting. A line that fails its integrity check (or won't parse) is skipped
|
|
182
|
+
with a note — one bad line never discards the rest of the registry.
|
|
183
|
+
|
|
184
|
+
Dogfood target: the author's own parallel-agent software factory + Conductor sessions.
|
|
185
|
+
|
|
186
|
+
Status: **drafting** — see [`roadmap.md`](roadmap.md). MIT · zero dependencies · harness-neutral.
|