kith-coord 0.1.7 → 0.1.9
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/CHANGELOG.md +26 -1
- package/CONTRIBUTING.md +7 -1
- package/README.md +37 -19
- package/bin/kith-menubar +0 -0
- package/dist/cli/index.js +14623 -7720
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +424 -7
- package/dist/index.js +5390 -1595
- package/dist/index.js.map +1 -1
- package/docs/architecture.md +5 -2
- package/docs/integrations.md +17 -6
- package/docs/protocol/tools.v1.json +205 -29
- package/docs/protocol.md +32 -2
- package/docs/reliability.md +5 -1
- package/docs/roadmap.md +1 -1
- package/docs/sessions-and-mutexes.md +51 -0
- package/docs/usage.md +38 -10
- package/package.json +10 -2
- package/server.json +2 -2
|
@@ -32,6 +32,57 @@ eval "$(kith session start --agent auth-worker --new --owner-pid "$$" --shell)"
|
|
|
32
32
|
|
|
33
33
|
`--new` does not steal a live session. Worktree paths are retained across generations. After successful worktree integration, use a new maintenance session to run `kith worktree remove`; changed, untracked, and ignored files still prevent removal.
|
|
34
34
|
|
|
35
|
+
## Git-ignored files and clearing a stuck auto-session
|
|
36
|
+
|
|
37
|
+
Kith does not lock, parse for AST contracts, snapshot/quarantine in Bash guards, or record merge conflicts on a path that `git check-ignore` reports as ignored in the repository the path belongs to (a nested checkout uses its own rules). Dev-server logs, build traces and caches are therefore invisible to coordination. Conflicts, file claims and contract rows that older versions recorded on ignored paths are deleted automatically when any Kith engine opens the repository or reaps dead agents. Tracked files are never treated as ignored.
|
|
38
|
+
|
|
39
|
+
An auto-joined hook session (`auto-<client>-<hash>`) normally recovers by itself: if the caller is in the same process tree as the registered owner (or the prior owner died or expired) and its saved capability no longer resumes, the hook reclaims the registration automatically. If a separate live process holds that session key (`Auto-session capability conflict for <client>:<session-id>`), passive hooks warn with a recovery command without blocking unrelated shell commands or unlocked files (edits to files locked by another active session remain blocked). Clear it by hand from the repository:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
kith session clear claude:<session-id> # or the agent id, e.g. auto-claude-1a2b3c4d
|
|
43
|
+
kith session clear --conflicts # only delete recorded conflicts, keep sessions
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`kith session clear <target>` forgets the session's saved capability and presence, releases its claims, marks the agent dead and deletes conflicts recorded against it. The session registers again on its next tool call. It needs no session token, so run it only for sessions you own.
|
|
47
|
+
|
|
48
|
+
When a client with `--auto` hooks also registers an MCP session (`kith_begin_work` or `kith_work`), Kith automatically binds the MCP capability to the parent client's `presence.db` session and transfers any locks held by its `auto-*` agent ID so subsequent hook calls and MCP calls share a single session.
|
|
49
|
+
|
|
50
|
+
## Committing while other sessions are active
|
|
51
|
+
|
|
52
|
+
The Bash guard refuses Git commands that can replace another session's checkout or refs.
|
|
53
|
+
|
|
54
|
+
In a shared checkout (`kith mode main`, or any checkout another active session is also using), `git reset`, `git checkout`, and the other recognized checkout-rewriting commands are blocked while a peer is active. A compare-and-swap `git update-ref` of `HEAD` or `refs/heads/<the current branch>` is allowed when the pre-hook can prove it is a fast-forward of exactly one commit and every changed path belongs to the caller. The same shape with shell variables is checked after the command and reverted if that proof fails. Anything else, including an `update-ref` with no old value, stays blocked. To commit only your own files there, run:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
kith commit -m "feat: scoped change" [files...]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If `[files...]` is omitted, `kith commit` collects the caller session's recorded modified files (from active file/narrow-glob locks, `presence.db` touched files, and active task scopes), verifies no target file is locked by another live agent, stages only those paths in a temporary index under `.coord/commit.lock`, advances `HEAD` with compare-and-swap `git update-ref`, and runs `git reset -q HEAD -- <files>` so `.git/index` stays synchronized with `HEAD` without touching peers' dirty files. You can also run `kith commit` inside `kith_run_with_mutex` / `kith_resource` (`action: "mutex"`) or pass `commitMessage` (and optional `commitFiles`) to `kith_finish`.
|
|
61
|
+
|
|
62
|
+
In an isolated worktree the guard allows `git update-ref` when the ref belongs only to the caller. That means the caller has `worktree_path`, the ref is `HEAD` or `refs/heads/<that worktree's branch>` checked out in the worktree, and no other active agent shares the worktree or the branch. A temporary-index commit in that worktree (`git commit-tree`, then `git update-ref HEAD <new> <old>`) is allowed, including with `-m <msg>`, `--no-deref`, and `--create-reflog`. `git -C <dir>` is resolved from the worktree; a `-C` or `cd` that leaves the worktree does not count as owned. `git update-ref -d` is allowed only for a ref the caller owns.
|
|
63
|
+
|
|
64
|
+
In a shared checkout the same temporary-index shape is allowed only after the pre-hook checks all of the following, before the command runs:
|
|
65
|
+
|
|
66
|
+
- the command is `git update-ref` with optional `-m`, `--no-deref`, and `--create-reflog`, and the ref is `HEAD` or `refs/heads/<the branch checked out in that directory>`
|
|
67
|
+
- `<old>` is present and resolves to the ref's current value (a compare-and-swap)
|
|
68
|
+
- `<new>` resolves to a commit with exactly one parent, and that parent is `<old>` (one fast-forward commit; merges and history rewrites are refused)
|
|
69
|
+
- every path in `git diff-tree -r --name-only` from `<old>` to `<new>`, including deletions and both sides of a rename, is a file the caller has claimed, locked, or recorded the way `kith commit` records files (active file and narrow-glob locks, `presence.db` touched files, and active task scopes; a `**` lock does not count). No changed path may be locked or claimed by another active agent
|
|
70
|
+
|
|
71
|
+
`<new>` and `<old>` may be literal SHAs or other revisions that resolve at check time. Shell variables and command substitutions such as `$(git commit-tree ...)` are not executed during the pre-hook, so the commit they will create cannot be read yet. When the command is still exactly that compare-and-swap shape, the pre-hook records the current ref value and lets the command run. The post-hook then applies the same parent and path checks to the commit that landed. If they fail, it compare-and-swaps the ref back to the recorded value and prints the reason, including a `kith commit -m "<message>" <files>` command built from the caller's recorded files. A short lease keeps other agents from moving the same ref until that post-hook finishes: their ref-moving commands are refused, and `kith commit` waits, so a peer does not build on a commit that is about to be reverted. If the reverting compare-and-swap loses to a later update, the hook reports that and does not force the ref.
|
|
72
|
+
|
|
73
|
+
A blocked command keeps the existing `kith commit` guidance and adds the specific reason, for example `No compare-and-swap old value` or `path src/x.ts is claimed by agent peer`. When the caller has recorded dirty files, the message includes a ready-to-run `kith commit -m "<message>" <those files>`.
|
|
74
|
+
|
|
75
|
+
These stay blocked while a peer is active:
|
|
76
|
+
|
|
77
|
+
- updates to the integration branch from an isolated worktree, or to another agent's branch
|
|
78
|
+
- a shared-checkout `update-ref` with no `<old>`, a merge or multi-commit jump, a path the caller does not own, or a path another agent claims
|
|
79
|
+
- `HEAD` updates that are not the one-commit fast-forward above, including `--no-deref` on a symbolic `HEAD` (that would retarget the symlink instead of the branch)
|
|
80
|
+
- `git update-ref --stdin` batches, `update-ref -d`, and any ref command the parser cannot classify
|
|
81
|
+
- `git symbolic-ref`, except a read or pointing the caller's own `HEAD` at `refs/heads/<the caller's branch>`
|
|
82
|
+
- `git worktree remove`, `git worktree prune`, and `git branch` `-d`/`-D`/`-m`/`-M`/`-f`/`--delete`/`--move`/`--force`
|
|
83
|
+
|
|
84
|
+
After `update-ref`, the post-hook resyncs the index of the checkout that command ran in: the caller's worktree, the directory selected with `-C` when that checkout belongs to the same repository, or the checkout named by a compare-and-swap `update-ref` whose values are shell variables.
|
|
85
|
+
|
|
35
86
|
## MCP ownership
|
|
36
87
|
|
|
37
88
|
`kith_begin_work`, `kith_claim_next_task`, and `kith_start_session` return a session token when they register or resume a session. A single stdio connection retains its granted capabilities internally. Another connection must explicitly present the capability to resume the same live ID. All agent-scoped mutation tools accept an optional `sessionToken`; a mixed CLI/hook/MCP client can inherit `KITH_AGENT_ID` and `KITH_SESSION_TOKEN` instead.
|
package/docs/usage.md
CHANGED
|
@@ -4,22 +4,50 @@
|
|
|
4
4
|
|
|
5
5
|
Connect through the [MCP-only client setup](integrations.md). Each parallel agent uses its own MCP connection and worktree. No shell exports are needed when using only MCP. Omit `sessionToken` on subsequent calls on the same connection; the initial grant reply still contains it, so keep client transcripts private. The connection retains its granted capability; another connection needs that capability to resume the same ID.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
For a new task, begin directly on one connection; `kith_begin_work` creates the session and claims its scope. A separate session-start, status poll, lock acquisition or manual contract publication is not needed for the same work:
|
|
8
8
|
|
|
9
9
|
```text
|
|
10
10
|
kith_begin_work {"agentId":"auth-worker","title":"Refresh authentication","scopeGlobs":["src/auth/**"],"isolateWorktree":true}
|
|
11
11
|
# Edit files under the returned worktree.worktreePath.
|
|
12
12
|
kith_record_file_edit {"agentId":"auth-worker","filePath":"src/auth/middleware.ts"}
|
|
13
|
-
kith_run_with_mutex {"agentId":"auth-worker","mutexName":"project-checks","command":["pnpm","typecheck"]}
|
|
14
|
-
kith_heartbeat {"agentId":"auth-worker"}
|
|
15
13
|
kith_complete_work {"agentId":"auth-worker","verificationCmd":"pnpm typecheck"}
|
|
16
14
|
```
|
|
17
15
|
|
|
18
|
-
Use a different ID and nonoverlapping scope for another agent. An overlapping exclusive scope returns a tool error. Commands run with the MCP server permissions and require client approval; their working directory defaults to the registered worktree. Keep the connection open
|
|
16
|
+
Use a different ID and nonoverlapping scope for another agent. An overlapping exclusive scope returns a tool error. Commands run with the MCP server permissions and require client approval; their working directory defaults to the registered worktree. Keep the connection open. Owned calls already renew the lease. From 0.1.8 their replies include `session.leaseExpiresAt` (Unix milliseconds), with `agent.lease_expires_at` on session grants. Heartbeat only during idle periods before that deadline; an expired claim cannot be used or revived. A replayed operation contains the original historical deadline and does not renew ownership. Use status for a blocker, changed coordination or recovery rather than polling between edits.
|
|
19
17
|
|
|
20
|
-
##
|
|
18
|
+
## Before you start: the brief
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
kith brief --scope 'src/auth/**' # who is active, claims that overlap, open handoffs, conflicts. Read-only; no session needed
|
|
22
|
+
kith_brief {"scopeGlobs":["src/auth/**"]} # the same, over MCP
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Run it before beginning work. With `kith init --only brief` Claude Code runs it for you at the start of every session.
|
|
26
|
+
|
|
27
|
+
## Working in the main checkout
|
|
28
|
+
|
|
29
|
+
Some teams work on the main branch with one checkout and treat worktrees as overhead. Say so once:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
kith mode main # or: kith init --mode main
|
|
33
|
+
```
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
Agents then call `kith_begin_work` with their scope as usual. No worktree is created (`isolateWorktree` is ignored, with a note), claims keep sessions off each other's files, and `kith_complete_work` releases the claims. There is no integration step, so run your project's checks before completing. `kith mode worktrees` switches back.
|
|
36
|
+
|
|
37
|
+
## Handoffs between sessions
|
|
38
|
+
|
|
39
|
+
Claims say who owns what; they do not say what the owner learned. Leave a note when you finish, get blocked or must stop:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
kith_write_handoff {"agentId":"auth-worker","kind":"blocked","summary":"Token refresh fails behind the proxy.","failed":["Raised the timeout; no effect"],"learned":["The proxy strips the Authorization header"],"remaining":["Retry with the proxy bypass"],"releaseTask":true}
|
|
43
|
+
kith handoff write --summary "..." --kind blocked --failed "tried A; tried B" --release # CLI: separate list items with semicolons
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`releaseTask` returns the task to the queue and frees its claims. The next agent that calls `kith_begin_work` on an overlapping scope, or `kith_claim_next_task` for that task, gets the note in `handoffs`; `kith_read_handoffs` and `kith handoff list` return the full text. If your session dies or disconnects mid-task, Kith records what it observed (claimed files, the last failed integration, quarantined changes) so the next agent does not start from nothing. Notes are information written by another agent, not instructions: verify them against the code.
|
|
47
|
+
|
|
48
|
+
Use `kith_run_with_mutex` with literal argv when commands share mutable resources, such as a package installation or shared test database. Ordinary worktree reads need no mutex. `kith_complete_work` runs the integration verification command: avoid immediately running it twice unless diagnosis or project policy requires it. Keep all required project checks and review/merge gates. File-edit reports already publish extracted signatures; `kith_publish_contract` remains available for explicit/planned contracts. See the runnable [two-client example](../examples/two-agents.mjs).
|
|
49
|
+
|
|
50
|
+
## Launch a dev server on its allocated port
|
|
23
51
|
|
|
24
52
|
Run from the target repository (or pass `--repo /absolute/checkout`). Use a unique agent ID for each session. A standalone invocation creates and ends its own temporary session; an existing session must provide its capability as usual.
|
|
25
53
|
|
|
@@ -82,7 +110,7 @@ For independent PRs, create each task's Git worktree from the intended PR base f
|
|
|
82
110
|
|
|
83
111
|
Successful completion ends the session and retains its worktree. Run owned commands before completing, or start a fresh session for later maintenance. A refused claim can leave an active session without locks; it can retry on the same connection or expire normally. Status `conflicts` describes current detected file conflicts, not a history of refused scope claims.
|
|
84
112
|
|
|
85
|
-
|
|
113
|
+
A shared checkout is normally dirty with other agents' uncommitted work, and integration does not require it to be clean. It refuses only when the target has uncommitted or untracked changes to a file the integration itself changes, and names those files; unrelated local work is left exactly as it was. Commit or preserve the named files, use a separate integration checkout, or keep the existing PR workflow above. Do not blanket-ignore unknown files to silence the guard. The supervised command runner uses the server's permissions, including network access; it is not a sandbox. `verificationCmd` is an explicit shell string; mutex commands use literal argv.
|
|
86
114
|
|
|
87
115
|
## CLI fallback: keep the owning shell alive
|
|
88
116
|
|
|
@@ -106,7 +134,7 @@ unset KITH_AGENT_ID KITH_SESSION_TOKEN
|
|
|
106
134
|
|
|
107
135
|
Quote globs so the shell does not expand them. CLI scopes are comma-separated. Use `file:src/routes/[id]/page.tsx` for a literal filename containing glob syntax; see [scope grammar and discovery](path-and-scope-rules.md). An ID alone cannot resume another session. Dead or expired sessions release coordination resources when a mutating operation reaps them. Active supervised command guards survive expiry until shutdown is confirmed.
|
|
108
136
|
|
|
109
|
-
Completion checkpoints uncommitted worktree changes and integrates into the branch currently checked out in the selected repository checkout (`--repo` when supplied). The target
|
|
137
|
+
Completion checkpoints uncommitted worktree changes and integrates into the branch currently checked out in the selected repository checkout (`--repo` when supplied). The target may hold unrelated uncommitted work, but not edits to files the integration changes. A verification failure leaves the target unchanged and the worktree available for repair. Successful completion also keeps the worktree for inspection; removal is explicit and refuses dirty, untracked, or ignored work. Existing branches are never reset to create a worktree. Hydration tries filesystem clones and falls back to an independent copy; cost depends on the filesystem and dependency size.
|
|
110
138
|
|
|
111
139
|
A verification command is optional. Without one, integration checks Git mergeability only. Choose a command that actually checks your project.
|
|
112
140
|
|
|
@@ -128,7 +156,7 @@ kith status
|
|
|
128
156
|
kith status --offline
|
|
129
157
|
kith recover
|
|
130
158
|
kith doctor
|
|
131
|
-
# Preview committed source/target trees; dirty
|
|
159
|
+
# Preview committed source/target trees; a dirty source is refused, and a dirty target only when it overlaps the integration
|
|
132
160
|
kith worktree preview --agent worker-1
|
|
133
161
|
|
|
134
162
|
# Allocate a cooperating client's port; start your service promptly
|
|
@@ -174,4 +202,4 @@ Never include session tokens in issues, terminal recordings, or shared logs. See
|
|
|
174
202
|
|
|
175
203
|
The read-only watcher excludes byte-identical dirty copies (including matching executable modes) across linked worktrees. Remaining shared dirty paths are advisories, not proven merge conflicts. Files over 8 MiB and non-file objects remain unverified rather than being treated as identical. The menu shows at most eight overlap rows; `kith watch --once` provides the full observations.
|
|
176
204
|
|
|
177
|
-
Omit `--once` for continuous observation. `--notify=false` suppresses optional macOS notifications. On macOS 12 or newer, `kith menubar /absolute/checkout` opens the same limited read-only view. The package includes an Intel/Apple Silicon executable, launched with this installation's Node and CLI paths; unavailable/failed scans remain visibly unavailable. Other platforms use `kith watch`. Source contributors can rebuild with `pnpm build:menubar` using Apple's command-line tools, and run the pipe/timeout regressions with `pnpm test:menubar`.
|
|
205
|
+
Omit `--once` for continuous observation. `--notify=false` suppresses optional macOS notifications. From 0.1.8, macOS `kith install` and `kith setup` open Radar and register a login LaunchAgent unless `--no-radar` or `--no-autostart` is passed. Dry runs never launch it. An existing view keeps its selected workspace; choose **Switch Workspace** in its menu to change it. Radar polls local state without model calls or MCP conversation traffic. On macOS 12 or newer, `kith menubar /absolute/checkout` opens the same limited read-only view. The package includes an Intel/Apple Silicon executable, launched with this installation's Node and CLI paths; unavailable/failed scans remain visibly unavailable. Other platforms use `kith watch`. Source contributors can rebuild with `pnpm build:menubar` using Apple's command-line tools, and run the pipe/timeout regressions with `pnpm test:menubar`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kith-coord",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Local coordination for cooperating coding agents: work claims, isolated worktrees, shared resources, and verified integration without a hosted service.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"test:clients": "pnpm build && node scripts/validate-native-clients.mjs",
|
|
45
45
|
"protocol:export": "pnpm build && node scripts/export-protocol.mjs",
|
|
46
46
|
"protocol:check": "node scripts/export-protocol.mjs --check",
|
|
47
|
+
"release:check": "node scripts/check-release-manifest.mjs",
|
|
47
48
|
"build:menubar": "node scripts/build-menubar.mjs",
|
|
48
49
|
"test:menubar": "node scripts/test-menubar.mjs"
|
|
49
50
|
},
|
|
@@ -86,5 +87,12 @@
|
|
|
86
87
|
"access": "public",
|
|
87
88
|
"registry": "https://registry.npmjs.org"
|
|
88
89
|
},
|
|
89
|
-
"mcpName": "io.github.connorhriley/kith"
|
|
90
|
+
"mcpName": "io.github.connorhriley/kith",
|
|
91
|
+
"pnpm": {
|
|
92
|
+
"overrides": {
|
|
93
|
+
"@hono/node-server": "~2.1.8",
|
|
94
|
+
"fast-uri": "~3.1.9",
|
|
95
|
+
"hono": "~4.13.18"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
90
98
|
}
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.connorhriley/kith",
|
|
4
4
|
"title": "Kith",
|
|
5
5
|
"description": "Coordinate coding agents with work claims, Git worktrees, shared resources and verified integration.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.9",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/connorhriley/kith",
|
|
9
9
|
"source": "github"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"registryType": "npm",
|
|
24
24
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
25
25
|
"identifier": "kith-coord",
|
|
26
|
-
"version": "0.1.
|
|
26
|
+
"version": "0.1.9",
|
|
27
27
|
"runtimeHint": "npx",
|
|
28
28
|
"runtimeArguments": [
|
|
29
29
|
{
|