kith-coord 0.1.9 → 0.2.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +83 -141
  3. package/assets/brand/readme-header.png +0 -0
  4. package/assets/brand/readme-header.svg +1 -1
  5. package/assets/brand/social-preview.png +0 -0
  6. package/assets/brand/social-preview.svg +1 -1
  7. package/assets/demo/claim.jq +5 -0
  8. package/assets/demo/claims.gif +0 -0
  9. package/assets/demo/claims.tape +59 -0
  10. package/assets/demo/prepare.sh +63 -0
  11. package/dist/chunk-6ORNHRPG.js +47 -0
  12. package/dist/chunk-6ORNHRPG.js.map +1 -0
  13. package/dist/chunk-QLLTQNDL.js +6104 -0
  14. package/dist/chunk-QLLTQNDL.js.map +1 -0
  15. package/dist/chunk-SAHFIOEQ.js +13927 -0
  16. package/dist/chunk-SAHFIOEQ.js.map +1 -0
  17. package/dist/chunk-WYEINJKJ.js +44 -0
  18. package/dist/chunk-WYEINJKJ.js.map +1 -0
  19. package/dist/chunk-YIMAR7VS.js +9599 -0
  20. package/dist/chunk-YIMAR7VS.js.map +1 -0
  21. package/dist/cli/index.js +854 -33883
  22. package/dist/cli/index.js.map +1 -1
  23. package/dist/client-77BNXEAH.js +708 -0
  24. package/dist/client-77BNXEAH.js.map +1 -0
  25. package/dist/command-worker.js +34 -2
  26. package/dist/command-worker.js.map +1 -1
  27. package/dist/index.d.ts +199 -14
  28. package/dist/index.js +87 -7998
  29. package/dist/index.js.map +1 -1
  30. package/dist/server-V52W56AG.js +3116 -0
  31. package/dist/server-V52W56AG.js.map +1 -0
  32. package/dist/stdio-3NHW7PIO.js +692 -0
  33. package/dist/stdio-3NHW7PIO.js.map +1 -0
  34. package/docs/architecture.md +4 -1
  35. package/docs/install.md +183 -0
  36. package/docs/integrations.md +7 -3
  37. package/docs/protocol/tools.v1.json +53 -0
  38. package/docs/protocol.md +13 -2
  39. package/docs/reliability.md +1 -1
  40. package/docs/roadmap.md +2 -0
  41. package/docs/sessions-and-mutexes.md +1 -1
  42. package/docs/usage.md +45 -0
  43. package/package.json +10 -10
  44. package/server.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js","../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js","../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js","../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js","../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js","../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js","../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js","../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js","../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/src/client/stdio.ts"],"sourcesContent":["module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction checkPathExt (path, options) {\n var pathext = options.pathExt !== undefined ?\n options.pathExt : process.env.PATHEXT\n\n if (!pathext) {\n return true\n }\n\n pathext = pathext.split(';')\n if (pathext.indexOf('') !== -1) {\n return true\n }\n for (var i = 0; i < pathext.length; i++) {\n var p = pathext[i].toLowerCase()\n if (p && path.substr(-p.length).toLowerCase() === p) {\n return true\n }\n }\n return false\n}\n\nfunction checkStat (stat, path, options) {\n if (!stat.isSymbolicLink() && !stat.isFile()) {\n return false\n }\n return checkPathExt(path, options)\n}\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, path, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), path, options)\n}\n","module.exports = isexe\nisexe.sync = sync\n\nvar fs = require('fs')\n\nfunction isexe (path, options, cb) {\n fs.stat(path, function (er, stat) {\n cb(er, er ? false : checkStat(stat, options))\n })\n}\n\nfunction sync (path, options) {\n return checkStat(fs.statSync(path), options)\n}\n\nfunction checkStat (stat, options) {\n return stat.isFile() && checkMode(stat, options)\n}\n\nfunction checkMode (stat, options) {\n var mod = stat.mode\n var uid = stat.uid\n var gid = stat.gid\n\n var myUid = options.uid !== undefined ?\n options.uid : process.getuid && process.getuid()\n var myGid = options.gid !== undefined ?\n options.gid : process.getgid && process.getgid()\n\n var u = parseInt('100', 8)\n var g = parseInt('010', 8)\n var o = parseInt('001', 8)\n var ug = u | g\n\n var ret = (mod & o) ||\n (mod & g) && gid === myGid ||\n (mod & u) && uid === myUid ||\n (mod & ug) && myUid === 0\n\n return ret\n}\n","var fs = require('fs')\nvar core\nif (process.platform === 'win32' || global.TESTING_WINDOWS) {\n core = require('./windows.js')\n} else {\n core = require('./mode.js')\n}\n\nmodule.exports = isexe\nisexe.sync = sync\n\nfunction isexe (path, options, cb) {\n if (typeof options === 'function') {\n cb = options\n options = {}\n }\n\n if (!cb) {\n if (typeof Promise !== 'function') {\n throw new TypeError('callback not provided')\n }\n\n return new Promise(function (resolve, reject) {\n isexe(path, options || {}, function (er, is) {\n if (er) {\n reject(er)\n } else {\n resolve(is)\n }\n })\n })\n }\n\n core(path, options || {}, function (er, is) {\n // ignore EACCES because that just means we aren't allowed to run it\n if (er) {\n if (er.code === 'EACCES' || options && options.ignoreErrors) {\n er = null\n is = false\n }\n }\n cb(er, is)\n })\n}\n\nfunction sync (path, options) {\n // my kingdom for a filtered catch\n try {\n return core.sync(path, options || {})\n } catch (er) {\n if (options && options.ignoreErrors || er.code === 'EACCES') {\n return false\n } else {\n throw er\n }\n }\n}\n","const isWindows = process.platform === 'win32' ||\n process.env.OSTYPE === 'cygwin' ||\n process.env.OSTYPE === 'msys'\n\nconst path = require('path')\nconst COLON = isWindows ? ';' : ':'\nconst isexe = require('isexe')\n\nconst getNotFoundError = (cmd) =>\n Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })\n\nconst getPathInfo = (cmd, opt) => {\n const colon = opt.colon || COLON\n\n // If it has a slash, then we don't bother searching the pathenv.\n // just check the file itself, and that's it.\n const pathEnv = cmd.match(/\\//) || isWindows && cmd.match(/\\\\/) ? ['']\n : (\n [\n // windows always checks the cwd first\n ...(isWindows ? [process.cwd()] : []),\n ...(opt.path || process.env.PATH ||\n /* istanbul ignore next: very unusual */ '').split(colon),\n ]\n )\n const pathExtExe = isWindows\n ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM'\n : ''\n const pathExt = isWindows ? pathExtExe.split(colon) : ['']\n\n if (isWindows) {\n if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')\n pathExt.unshift('')\n }\n\n return {\n pathEnv,\n pathExt,\n pathExtExe,\n }\n}\n\nconst which = (cmd, opt, cb) => {\n if (typeof opt === 'function') {\n cb = opt\n opt = {}\n }\n if (!opt)\n opt = {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n const step = i => new Promise((resolve, reject) => {\n if (i === pathEnv.length)\n return opt.all && found.length ? resolve(found)\n : reject(getNotFoundError(cmd))\n\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n resolve(subStep(p, i, 0))\n })\n\n const subStep = (p, i, ii) => new Promise((resolve, reject) => {\n if (ii === pathExt.length)\n return resolve(step(i + 1))\n const ext = pathExt[ii]\n isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {\n if (!er && is) {\n if (opt.all)\n found.push(p + ext)\n else\n return resolve(p + ext)\n }\n return resolve(subStep(p, i, ii + 1))\n })\n })\n\n return cb ? step(0).then(res => cb(null, res), cb) : step(0)\n}\n\nconst whichSync = (cmd, opt) => {\n opt = opt || {}\n\n const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)\n const found = []\n\n for (let i = 0; i < pathEnv.length; i ++) {\n const ppRaw = pathEnv[i]\n const pathPart = /^\".*\"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw\n\n const pCmd = path.join(pathPart, cmd)\n const p = !pathPart && /^\\.[\\\\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd\n : pCmd\n\n for (let j = 0; j < pathExt.length; j ++) {\n const cur = p + pathExt[j]\n try {\n const is = isexe.sync(cur, { pathExt: pathExtExe })\n if (is) {\n if (opt.all)\n found.push(cur)\n else\n return cur\n }\n } catch (ex) {}\n }\n }\n\n if (opt.all && found.length)\n return found\n\n if (opt.nothrow)\n return null\n\n throw getNotFoundError(cmd)\n}\n\nmodule.exports = which\nwhich.sync = whichSync\n","'use strict';\n\nconst pathKey = (options = {}) => {\n\tconst environment = options.env || process.env;\n\tconst platform = options.platform || process.platform;\n\n\tif (platform !== 'win32') {\n\t\treturn 'PATH';\n\t}\n\n\treturn Object.keys(environment).reverse().find(key => key.toUpperCase() === 'PATH') || 'Path';\n};\n\nmodule.exports = pathKey;\n// TODO: Remove this for the next major release\nmodule.exports.default = pathKey;\n","'use strict';\n\nconst path = require('path');\nconst which = require('which');\nconst getPathKey = require('path-key');\n\nfunction resolveCommandAttempt(parsed, withoutPathExt) {\n const env = parsed.options.env || process.env;\n const cwd = process.cwd();\n const hasCustomCwd = parsed.options.cwd != null;\n // Worker threads do not have process.chdir()\n const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;\n\n // If a custom `cwd` was specified, we need to change the process cwd\n // because `which` will do stat calls but does not support a custom cwd\n if (shouldSwitchCwd) {\n try {\n process.chdir(parsed.options.cwd);\n } catch (err) {\n /* Empty */\n }\n }\n\n let resolved;\n\n try {\n resolved = which.sync(parsed.command, {\n path: env[getPathKey({ env })],\n pathExt: withoutPathExt ? path.delimiter : undefined,\n });\n } catch (e) {\n /* Empty */\n } finally {\n if (shouldSwitchCwd) {\n process.chdir(cwd);\n }\n }\n\n // If we successfully resolved, ensure that an absolute path is returned\n // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it\n if (resolved) {\n resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);\n }\n\n return resolved;\n}\n\nfunction resolveCommand(parsed) {\n return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);\n}\n\nmodule.exports = resolveCommand;\n","'use strict';\n\n// See http://www.robvanderwoude.com/escapechars.php\nconst metaCharsRegExp = /([()\\][%!^\"`<>&|;, *?])/g;\n\nfunction escapeCommand(arg) {\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n return arg;\n}\n\nfunction escapeArgument(arg, doubleEscapeMetaChars) {\n // Convert to string\n arg = `${arg}`;\n\n // Algorithm below is based on https://qntm.org/cmd\n // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input\n // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information\n\n // Sequence of backslashes followed by a double quote:\n // double up all the backslashes and escape the double quote\n arg = arg.replace(/(?=(\\\\+?)?)\\1\"/g, '$1$1\\\\\"');\n\n // Sequence of backslashes followed by the end of the string\n // (which will become a double quote later):\n // double up all the backslashes\n arg = arg.replace(/(?=(\\\\+?)?)\\1$/, '$1$1');\n\n // All other backslashes occur literally\n\n // Quote the whole thing:\n arg = `\"${arg}\"`;\n\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n // Double escape meta chars if necessary\n if (doubleEscapeMetaChars) {\n arg = arg.replace(metaCharsRegExp, '^$1');\n }\n\n return arg;\n}\n\nmodule.exports.command = escapeCommand;\nmodule.exports.argument = escapeArgument;\n","'use strict';\nmodule.exports = /^#!(.*)/;\n","'use strict';\nconst shebangRegex = require('shebang-regex');\n\nmodule.exports = (string = '') => {\n\tconst match = string.match(shebangRegex);\n\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\tconst [path, argument] = match[0].replace(/#! ?/, '').split(' ');\n\tconst binary = path.split('/').pop();\n\n\tif (binary === 'env') {\n\t\treturn argument;\n\t}\n\n\treturn argument ? `${binary} ${argument}` : binary;\n};\n","'use strict';\n\nconst fs = require('fs');\nconst shebangCommand = require('shebang-command');\n\nfunction readShebang(command) {\n // Read the first 150 bytes from the file\n const size = 150;\n const buffer = Buffer.alloc(size);\n\n let fd;\n\n try {\n fd = fs.openSync(command, 'r');\n fs.readSync(fd, buffer, 0, size, 0);\n fs.closeSync(fd);\n } catch (e) { /* Empty */ }\n\n // Attempt to extract shebang (null is returned if not a shebang)\n return shebangCommand(buffer.toString());\n}\n\nmodule.exports = readShebang;\n","'use strict';\n\nconst path = require('path');\nconst resolveCommand = require('./util/resolveCommand');\nconst escape = require('./util/escape');\nconst readShebang = require('./util/readShebang');\n\nconst isWin = process.platform === 'win32';\nconst isExecutableRegExp = /\\.(?:com|exe)$/i;\nconst isCmdShimRegExp = /node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i;\n\nfunction detectShebang(parsed) {\n parsed.file = resolveCommand(parsed);\n\n const shebang = parsed.file && readShebang(parsed.file);\n\n if (shebang) {\n parsed.args.unshift(parsed.file);\n parsed.command = shebang;\n\n return resolveCommand(parsed);\n }\n\n return parsed.file;\n}\n\nfunction parseNonShell(parsed) {\n if (!isWin) {\n return parsed;\n }\n\n // Detect & add support for shebangs\n const commandFile = detectShebang(parsed);\n\n // We don't need a shell if the command filename is an executable\n const needsShell = !isExecutableRegExp.test(commandFile);\n\n // If a shell is required, use cmd.exe and take care of escaping everything correctly\n // Note that `forceShell` is an hidden option used only in tests\n if (parsed.options.forceShell || needsShell) {\n // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`\n // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument\n // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,\n // we need to double escape them\n const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);\n\n // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\\bar)\n // This is necessary otherwise it will always fail with ENOENT in those cases\n parsed.command = path.normalize(parsed.command);\n\n // Escape command & arguments\n parsed.command = escape.command(parsed.command);\n parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));\n\n const shellCommand = [parsed.command].concat(parsed.args).join(' ');\n\n parsed.args = ['/d', '/s', '/c', `\"${shellCommand}\"`];\n parsed.command = process.env.comspec || 'cmd.exe';\n parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped\n }\n\n return parsed;\n}\n\nfunction parse(command, args, options) {\n // Normalize arguments, similar to nodejs\n if (args && !Array.isArray(args)) {\n options = args;\n args = null;\n }\n\n args = args ? args.slice(0) : []; // Clone array to avoid changing the original\n options = Object.assign({}, options); // Clone object to avoid changing the original\n\n // Build our parsed object\n const parsed = {\n command,\n args,\n options,\n file: undefined,\n original: {\n command,\n args,\n },\n };\n\n // Delegate further parsing to shell or non-shell\n return options.shell ? parsed : parseNonShell(parsed);\n}\n\nmodule.exports = parse;\n","'use strict';\n\nconst isWin = process.platform === 'win32';\n\nfunction notFoundError(original, syscall) {\n return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {\n code: 'ENOENT',\n errno: 'ENOENT',\n syscall: `${syscall} ${original.command}`,\n path: original.command,\n spawnargs: original.args,\n });\n}\n\nfunction hookChildProcess(cp, parsed) {\n if (!isWin) {\n return;\n }\n\n const originalEmit = cp.emit;\n\n cp.emit = function (name, arg1) {\n // If emitting \"exit\" event and exit code is 1, we need to check if\n // the command exists and emit an \"error\" instead\n // See https://github.com/IndigoUnited/node-cross-spawn/issues/16\n if (name === 'exit') {\n const err = verifyENOENT(arg1, parsed);\n\n if (err) {\n return originalEmit.call(cp, 'error', err);\n }\n }\n\n return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params\n };\n}\n\nfunction verifyENOENT(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawn');\n }\n\n return null;\n}\n\nfunction verifyENOENTSync(status, parsed) {\n if (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawnSync');\n }\n\n return null;\n}\n\nmodule.exports = {\n hookChildProcess,\n verifyENOENT,\n verifyENOENTSync,\n notFoundError,\n};\n","'use strict';\n\nconst cp = require('child_process');\nconst parse = require('./lib/parse');\nconst enoent = require('./lib/enoent');\n\nfunction spawn(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n\n // Hook into child process \"exit\" event to emit an error if the command\n // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n enoent.hookChildProcess(spawned, parsed);\n\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n // Parse the arguments\n const parsed = parse(command, args, options);\n\n // Spawn the child process\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n\n // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\n\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n",null],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,WAAO,UAAU;AACjB,UAAM,OAAO;AAEb,QAAI,KAAK,UAAQ,IAAI;AAErB,aAAS,aAAc,MAAM,SAAS;AACpC,UAAI,UAAU,QAAQ,YAAY,SAChC,QAAQ,UAAU,QAAQ,I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AK,SAAuB;AACxB,WAAO,IAAI,QAAQ,aAAU;AACzB,UAAI,CAAC,KAAK,UAAU,OAAO;AACvB,cAAM,IAAI,MAAM,eAAe;MACnC;AAEA,YAAM,OAAO,iBAAiB,OAAO;AACrC,UAAI,KAAK,SAAS,MAAM,MAAM,IAAI,GAAG;AACjC,gBAAO;MACX,OAAO;AACH,aAAK,SAAS,MAAM,KAAK,SAAS,OAAO;MAC7C;IACJ,CAAC;EACL;;","names":["spawn","process","process","spawn"]}
@@ -13,7 +13,8 @@ Kith runs locally. There is no coordination server: CLI and MCP clients share `.
13
13
  | `intents.ts` | Work declarations, task dependencies, transactional claims |
14
14
  | `ast-analyzer.ts`, `dep-graph.ts` | Advisory source-derived contracts and import relationships |
15
15
  | `shadow-git.ts` | Per-agent indexes, synthetic commits, dirty-tree merge probes |
16
- | `worktree-cow.ts` | Isolated worktree creation and dependency hydration |
16
+ | `worktree-cow.ts` | Isolated worktree creation, dependency hydration, and removal of worktrees Kith created |
17
+ | `worktree-adopt.ts` | Adopt an existing linked worktree (Claude Code's `.claude/worktrees/<name>` layout, or any `git worktree list` entry), and record created/adopted provenance |
17
18
  | `merge-train.ts` | Serialized integration through a disposable staging worktree |
18
19
  | `brief.ts` | The read-only situational summary shared by the offline reader, the CLI and the MCP tool |
19
20
  | `mode.ts` | Repository workflow mode: `worktrees` or `main` |
@@ -33,6 +34,8 @@ Git clients launched from subdirectories, symlink aliases and linked checkouts d
33
34
 
34
35
  Session capabilities are held in each engine's memory and hashed in the separate `agent_sessions` table. Agent records/status do not expose them. Mutation boundaries assert ownership inside writer transactions where applicable. `mutex_waiters` preserves handoff order independently of a resource row, and `mutex_runs` preserves execution exclusion even if session/resource rows expire. A private IPC handshake records a worker process group before it can execute a command. See [session and command lifecycle](sessions-and-mutexes.md).
35
36
 
37
+ A session that is already inside a linked worktree can register that checkout instead of creating one under `.coord/worktrees`. Hooks do this when the hook `cwd` is unambiguously that worktree. `kith adopt` and `kith_adopt_worktree` do it explicitly. The registration records whether Kith created the worktree. Garbage collection and `kith worktree remove` delete only worktrees Kith created; an adopted directory stays until `kith worktree remove --delete-adopted`. Integration of an adopted branch still goes through the merge train and the verification command. A detached HEAD and a branch checked out in another worktree are refused at that gate.
38
+
36
39
  Worktree edit reports read source bytes from the registered worktree and store repository-relative contracts. Git checkpoint/merge subprocesses receive the owning capability in their environment so generated pre-commit guards can authorize them. Generated pre-commit guards inspect the invoking Git checkout/index even when `--repo` selects shared state through another checkout.
37
40
 
38
41
  ## Adaptation
@@ -0,0 +1,183 @@
1
+ # Install
2
+
3
+ Kith needs **Git 2.38+** and **Node.js 22.13+ on 22.x, or Node.js 24+**. Full workflows target macOS and Linux. Native Windows MCP checks cover claims, worktrees, ports, integration and recovery; supervised mutex commands and shell hooks require macOS/Linux or WSL. See the [support evidence](client-validation.md#native-windows).
4
+
5
+ Git recording and integration require a commit identity configured for the repository (`user.name` and `user.email`). Kith does not change your global Git identity.
6
+
7
+ ## Which to use
8
+
9
+ | You want | Use |
10
+ | --- | --- |
11
+ | Claude Code only | The [Claude Code plugin](#claude-code-plugin). No global npm install. |
12
+ | Cursor, Codex, Claude Desktop, or the macOS menu bar | `npm i -g kith-coord && kith install` |
13
+ | Both | Keep both. The plugin hooks exit when `kith install` or `kith init` has already registered that Claude hook, so the tool call is checked once. `kith doctor` reports this and does not fail. |
14
+
15
+ `kith install` pins a runtime outside the npx cache. The plugin resolves `kith-coord` through `npx -y` on each hook and MCP start. The first call can be slower while npx fetches the package. Prefer `kith install` when you want that pin, Cursor hooks, or Radar.
16
+
17
+ ## Claude Code plugin
18
+
19
+ In Claude Code:
20
+
21
+ ```text
22
+ /plugin marketplace add connorhriley/kith
23
+ /plugin install kith@kith
24
+ ```
25
+
26
+ The same steps from a shell:
27
+
28
+ ```sh
29
+ claude plugin marketplace add connorhriley/kith
30
+ claude plugin install kith@kith
31
+ ```
32
+
33
+ The marketplace file is [`.claude-plugin/marketplace.json`](../.claude-plugin/marketplace.json). The plugin is [`plugins/kith`](../plugins/kith): [`.claude-plugin/plugin.json`](../plugins/kith/.claude-plugin/plugin.json), [`hooks/hooks.json`](../plugins/kith/hooks/hooks.json), and [`.mcp.json`](../plugins/kith/.mcp.json). Hooks and the MCP server run the published package:
34
+
35
+ ```text
36
+ npx -y kith-coord hook pre --client claude --auto
37
+ npx -y kith-coord mcp --compact
38
+ ```
39
+
40
+ `hooks/run.mjs` is the hook command Claude Code actually starts. It forwards stdin, including the hook `cwd`, to that `npx` command. If `~/.claude/settings.json`, or the project `.claude/settings.json` for `CLAUDE_PROJECT_DIR`, already contains the matching `kith hook` command, the script exits 0 and does not start a second check. PreToolUse uses `onFailure: "block"`, matching `kith install`.
41
+
42
+ When that session has joined and its `cwd` is a linked worktree, the hook adopts the checkout instead of creating another one. Claude Code's `claude --worktree` uses `.claude/worktrees/<name>`. The same adoption applies to any other `git worktree list` entry. Kith does not delete a worktree it did not create. `${CLAUDE_PROJECT_DIR}` stays on the original checkout and is not treated as the worktree. See [Adopt a worktree](usage.md#adopt-a-worktree-that-already-exists).
43
+
44
+ The plugin does not write `~/.claude/settings.json`, does not install Cursor hooks, and does not register the menu bar. Uninstall it from Claude Code's `/plugin` list. That does not remove hooks written by `kith install`; `kith uninstall` does.
45
+
46
+ The version field is omitted from the manifest, so a GitHub marketplace install tracks the commit Claude Code last fetched. The hook script still runs whatever `npx -y kith-coord` resolves, which is the current published package, not the git checkout.
47
+
48
+ ## `kith install`
49
+
50
+ ```sh
51
+ npm i -g kith-coord && kith install
52
+ ```
53
+
54
+ `kith install` puts `kith` on your `PATH` and keeps that runtime outside the npx cache. It writes a global MCP entry for each detected client, using the compact tool profile (`kith mcp --compact`), and installs silent-solo `--auto` hooks for Claude Code and Cursor. One agent stays at **Watching only** and does not write coordination state. When another writer overlaps, the hooks join Kith. If that session is already inside a linked worktree, joining adopts it. Otherwise the hooks isolate the work into a worktree Kith creates, or into a claim. On macOS it also loads a login LaunchAgent (`dev.kith.radar`) unless you pass `--no-autostart` or `--no-radar`. It does not claim any files. An agent claims when it starts a task.
55
+
56
+ Codex CLI has no native tool hooks, so it uses the MCP tools. Linux and Windows skip the menu bar; use `kith watch`.
57
+
58
+ Directories that scan a repository for an MCP server read the committed [`.mcp.json`](../.mcp.json): `npx -y kith-coord mcp` over stdio. That entry does not pin a checkout and does not install hooks. `kith install` does not read or edit it.
59
+
60
+ ### Upgrading
61
+
62
+ Stop existing Kith connections first. Back up stopped coordination state (including SQLite sidecars) and retain worktrees; upgrade all coordinators sharing a repository together. The storage schema stays 3 and the protocol stays 1.6.0. Databases already on schema 3 open without a version migration. The first open on 0.2.0 creates an optional `worktree_registrations` table; binaries from 0.1.6 through 0.1.9 ignore it. The first open on 0.1.8 or later creates an optional `handoffs` table; binaries from 0.1.6 and 0.1.7 ignore that table and keep working, but they do not read or write handoff notes. An upgrade from schema 2 still applies the 0.1.6 migration to schema 3, which older binaries refuse. After upgrading, run `kith install` so hooks and client entries use this runtime. `kith doctor` reports a hook or MCP entry still pinned to an older runtime. Existing custom launchers are preserved; review their pinned version before reconnecting. On macOS, `kith install` and `kith setup` register a login LaunchAgent unless `--no-autostart` or `--no-radar` is passed. See [recovery guidance](reliability.md#recovery).
63
+
64
+ ### VS Code or Cursor
65
+
66
+ Install **Kith** (`kith-coord.kith`) from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=kith-coord.kith) or [Cursor / Open VSX](https://open-vsx.org/extension/kith-coord/kith). You can also search for `kith-coord.kith` in the editor's Extensions view.
67
+
68
+ To select release **0.2.1** explicitly with an editor CLI already on your `PATH`:
69
+
70
+ ```sh
71
+ code --install-extension kith-coord.kith@0.2.1
72
+ cursor --install-extension kith-coord.kith@0.2.1
73
+ ```
74
+
75
+ Use the command for your editor. A marketplace lookup can temporarily select an older version; the [extension guide](../extensions/editor/README.md#install) also links the published 0.2.1 VSIX.
76
+
77
+ Open a trusted local Git checkout and approve Kith's MCP server through the editor. The extension bundles the coordination server, detects Node, and preserves existing MCP entries, hooks and tool permissions. **No global npm install is needed.** It registers the compact tool profile (`kith.mcp.profile`, `compact` by default, or `full`), shows a read-only global hook status note in Output, and adds **Kith: Install Global Hooks & Autostart** (`kith.installGlobal`). The bundled extension does not include the macOS menu-bar helper; run `kith install` from the CLI on macOS for Radar login autostart. Each agent still needs to use Kith's tools; installing the extension alone does not enforce claims on other writers.
78
+
79
+ Start with a scoped task:
80
+
81
+ ```text
82
+ Use Kith to begin an isolated task in this repository with a unique agent ID.
83
+ Claim only the files this task needs, edit the returned worktree, and report edits.
84
+ Run the project checks and complete through Kith with that verification command.
85
+ ```
86
+
87
+ The [extension guide](../extensions/editor/README.md) covers settings and existing configurations; [recorded editor checks](client-validation.md#editor-marketplaces-and-signed-in-chats) distinguish installation, native MCP registration and signed-in task results.
88
+
89
+ ### CLI and other MCP clients
90
+
91
+ Configure detected clients and add project instructions with:
92
+
93
+ ```sh
94
+ npx --yes --package kith-coord@0.2.1 kith setup
95
+ ```
96
+
97
+ **`kith install`** is the one-command onboarding path. `kith setup` remains a compatible alias:
98
+
99
+ - Configures global MCP servers with the concise **`--compact`** tool profile by default (`kith mcp --compact`, or `--full` for the complete surface).
100
+ - Installs global silent-solo `--auto` hooks for **Claude Code** (`~/.claude/settings.json`) and **Cursor** (`~/.cursor/hooks.json`). Solo work stays zero-write (`Watching only`); when concurrent activity overlaps, hooks auto-join Kith and isolate writers into worktrees or leases.
101
+ - On **macOS**, installs and starts a login `LaunchAgent` (`dev.kith.radar`) for background menu-bar Radar, and opens the read-only view. `--no-autostart` or `--no-radar` skips the login item. Repeat setup keeps the existing workspace.
102
+ - **`kith uninstall`** removes the macOS `LaunchAgent`, global Kith hooks, global MCP entries, retained runtimes and launcher symlinks.
103
+
104
+ Note the platform and client boundaries: **Codex CLI** does not expose native pre/post tool hooks, so it coordinates through `--compact` MCP tools and Radar/watcher observations rather than automatic hook interception. **Linux and Windows** skip macOS menu-bar autostart and use `kith watch` for passive supervision.
105
+
106
+ Durable setup starts with **0.1.7** (retaining an exact self-contained runtime outside npx's cache, verifying MCP discovery, and backing up modified files). Existing custom Kith launchers, peer servers, hooks and permissions are preserved. Reconnect the client and approve its MCP server through the client's normal controls.
107
+
108
+ Day to day, run `kith` (a read-only status overview in a terminal), `kith status`, `kith brief`, `kith run`, `kith gc`, `kith doctor [path]`, or `kith help --all`. The view says **Watching only** until a task or concurrent overlap is recorded. `kith install --dry-run` and `kith setup --dry-run` preview without writes.
109
+
110
+ [`.mcp.json`](../.mcp.json) is the directory discovery entry: `npx -y kith-coord mcp`. It is not a pin to this repository. `kith install` does not read or edit it, and `kith doctor` only reports that the launcher file is present; neither command starts the server or creates `.coord` state. A client that loads project MCP config, such as Claude Code, can start that published package from the file. Because `--repo` is omitted, the process does not pin this checkout or open the database until a tool call names one. `kith init` still replaces the `kith` server in a project `.mcp.json` with a launcher for the machine you are on; do not commit that rewrite over the discovery entry.
111
+
112
+ For source installation and the disposable demo, use the pinned **pnpm 10.20.0**:
113
+
114
+ ```sh
115
+ git clone https://github.com/connorhriley/kith.git
116
+ cd kith
117
+ corepack enable
118
+ pnpm install --frozen-lockfile
119
+ pnpm build
120
+ ```
121
+
122
+ ### See it work
123
+
124
+ ```sh
125
+ pnpm demo
126
+ ```
127
+
128
+ The demo starts **two real MCP clients**, gives each a separate Git worktree in a temporary repository, refuses an overlapping claim, records their edits, runs commands under a mutex, and verifies/integrates both changes. It removes the temporary repository afterward. No model calls or client credentials are needed.
129
+
130
+ ```text
131
+ auth: claimed src/auth.mjs in an isolated worktree
132
+ billing: overlapping claim on src/auth.mjs refused
133
+ billing: claimed src/billing.mjs in an isolated worktree
134
+ auth: checked its worktree through the MCP command supervisor
135
+ auth: isolated edit reported, verified, and integrated
136
+ billing: checked its worktree through the MCP command supervisor
137
+ billing: isolated edit reported, verified, and integrated
138
+ Two real MCP clients completed work in separate worktrees. Disposable example passed.
139
+ ```
140
+
141
+ The implementation is in [examples/two-agents.mjs](../examples/two-agents.mjs). This demonstrates the coordination protocol; [native-client validation](client-validation.md) separately exercises installed coding clients.
142
+
143
+ ### Client support
144
+
145
+ The editor extension bundles the server and offers it through native MCP registration; no global npm install is needed. Installing an extension or writing MCP configuration alone does not enforce claims on writers that do not call Kith tools unless global `--auto` hooks are installed for that client. Existing custom Kith entries retain precedence.
146
+
147
+ | Client | Setup and behaviour |
148
+ | --- | --- |
149
+ | VS Code / Cursor | Marketplace extension with `kith.mcp.profile` set to `compact` by default; **Kith: Install Global Hooks & Autostart** runs `kith install` |
150
+ | Claude Code | Plugin (`kith@kith`), or `kith install` / `kith setup` with silent-solo `--auto` hooks. The plugin defers when the install hooks are present |
151
+ | Cursor | Detected client configuration through `kith install` or `kith setup`; silent-solo `--auto` hooks join when work overlaps |
152
+ | Codex CLI | Detected global MCP configuration (`--compact` by default). Codex CLI has no native tool hooks, so coordination uses MCP tools and Radar or `kith watch` |
153
+ | Claude Desktop | Detected MCP configuration via `kith install` / `kith setup` |
154
+ | Other MCP clients | stdio server via `kith mcp` (`--compact` or `--full`); client-specific validation required |
155
+
156
+ Native evidence is version-specific. See [client validation](client-validation.md), [advanced integration setup](integrations.md) and [session ownership](sessions-and-mutexes.md). The npm package is **`kith-coord`** and the command is **`kith`**; the unrelated npm package `kith` is not this project.
157
+
158
+ ## Dev servers and shared config
159
+
160
+ `kith dev` runs a server with its allocated `PORT` and supports explicit `{port}` arguments. It scans from 3000 unless `--base` is set. `kith port` scans from 3100. File claims also accept an optional bounded wait:
161
+
162
+ ```sh
163
+ kith dev --agent web-a -- npm run dev -- --port '{port}'
164
+ # Within an existing owned session:
165
+ kith lock acquire --agent worker-1 --scope package.json --wait --wait-ms 30000
166
+ ```
167
+
168
+ See [dev-server launch and waiting claims](usage.md#launch-a-dev-server-on-its-allocated-port) for framework flags, session setup, cancellation, and MCP usage.
169
+
170
+ ## Read-only Radar
171
+
172
+ From 0.1.8, macOS `kith install` and `kith setup` load a `LaunchAgent` (`dev.kith.radar`) so menu-bar Radar runs in the background and restarts across logins for the selected checkout or workspace. It uses the retained installation, so clearing the npx cache does not break it. Repeat runs keep an existing Radar workspace selected. Use **Switch Workspace** in its menu to change it.
173
+
174
+ `kith install --no-autostart` (or `--no-radar`) configures MCP and hooks without loading the macOS login agent (useful on headless machines); `--dry-run` never writes or launches anything. Linux and Windows skip the macOS menu-bar app and `LaunchAgent`, using `kith watch` for passive monitoring instead (external IDE `presence.db` discovery is opt-in via `--include-presence`). Remove the login item anytime with `kith uninstall`, or inspect manually with:
175
+
176
+ ```sh
177
+ kith watch /path/to/workspace --once --json
178
+ kith menubar /path/to/workspace # macOS 12+, Intel or Apple Silicon
179
+ ```
180
+
181
+ The menu and editor lead with recorded tasks, current file claims, shared-resource waits and integrations that need inspection. A registered session without a task is shown separately. Saved checkouts and path comparisons stay in details; nothing is automatically deleted. The menu's default view omits the file-timestamp feed.
182
+
183
+ **Watching only** means no active Kith task is recorded. Shared dirty paths are files to review before integration, not a proven merge conflict. **Status unavailable** remains explicit when state cannot be inspected safely. Reads use private snapshots without renewing owners or migrating the original database. See [observation limits](usage.md#optional-read-only-worktree-observations).
@@ -2,6 +2,8 @@
2
2
 
3
3
  For CLI-generated configuration, install Kith persistently or build and link the checkout first. On macOS/Linux, generated configurations use the `kith` executable already on PATH; they do not download an unverified package at hook execution time.
4
4
 
5
+ Claude Code can load the same hooks and MCP server as a plugin (`/plugin marketplace add connorhriley/kith`, then `/plugin install kith@kith`). The plugin runs `npx -y kith-coord` and defers when `kith install` or `kith init` has already registered the Claude hook. Use one or both; `kith doctor` does not fail when both are present. Cursor, Codex, and the menu bar still come from `kith install`. See [which to use](install.md#which-to-use).
6
+
5
7
  | Selection | Files and behavior |
6
8
  | --- | --- |
7
9
  | `claude` | Merges Kith into `.mcp.json`; adds Claude edit hooks only when selected explicitly with `--only` and without `--mcp-only` |
@@ -41,6 +43,8 @@ Select clients explicitly without `--mcp-only` to add edit hooks, for example `k
41
43
 
42
44
  Before launching a hook client, run `eval "$(kith session start --agent <id> --owner-pid "$$" --shell)"`. The client, its MCP process, and hooks must inherit both `KITH_AGENT_ID` and `KITH_SESSION_TOKEN`. Use that same agent ID in MCP calls. A missing/forged/expired token blocks hook mutations for a session that presents an identity. See [session setup](sessions-and-mutexes.md).
43
45
 
46
+ **Hooks adopt an existing worktree when the context is unambiguous.** Claude Code sets the hook `cwd` to the worktree root while `${CLAUDE_PROJECT_DIR}` stays on the checkout where the session started. A joined `pre`, `post`, or `pre-commit` hook registers that linked worktree for the session when it is the only match in `git worktree list`, the session has no different worktree, and no other live agent owns the path. A hook whose `cwd` is the primary checkout does not adopt anything. The same registration is `kith adopt` or `kith_adopt_worktree` when you want it explicit. Kith does not delete that directory.
47
+
44
48
  **Hooks govern sessions that joined.** A process with no Kith identity at all (no `--agent`, no `--session-token`, and neither `KITH_AGENT_ID` nor `KITH_SESSION_TOKEN` in its environment) is not a participant: it cannot hold a claim, so there is nothing to enforce. Its `pre`, `post` and `pre-commit` hooks allow immediately, print nothing, and never open the coordination database. An editor, a plain terminal, CI or another agent client is therefore never blocked by a repository that has Kith hooks installed. A process that names an agent but cannot prove it (missing or forged token) is still refused. Pass `--require-session` to a hook command, or set `KITH_REQUIRE_SESSION=1`, to restore fail-closed behaviour for processes with no identity. Separate stateless shell calls cannot retain this setup. Prefer MCP and isolated worktrees when a persistent launcher environment is unavailable; AGENTS.md guidance alone cannot enforce writes.
45
49
 
46
50
  Shims are inactive until `.coord/bin` is prepended to PATH. Use an absolute path, for example `export PATH="$PWD/.coord/bin:$PATH"` at the repository root. Wrappers remove that directory from PATH before invoking the real package manager, avoiding recursive self-invocation. They serialize selected install/add/remove commands through the resource broker; leases renew while commands run, and FIFO tickets persist across releases. Protected work must remain in the supervised command group.
@@ -81,12 +85,12 @@ Uninstall restores the exact original bytes/permissions or deletes files created
81
85
 
82
86
  ## Registry installation
83
87
 
84
- The package is `kith-coord`, and its binary remains `kith`. Install it persistently (`npm install --global kith-coord@0.1.9`) before `kith init`, because generated configurations launch `kith` on PATH. Invoking init through npx alone does not create that persistent executable.
88
+ The package is `kith-coord`, and its binary remains `kith`. Install it persistently (`npm install --global kith-coord@0.2.1`) before `kith init`, because generated configurations launch `kith` on PATH. Invoking init through npx alone does not create that persistent executable.
85
89
 
86
90
  An MCP client can instead use a pinned registry launcher without a global install:
87
91
 
88
92
  ```json
89
- {"mcpServers":{"kith":{"command":"npx","args":["--yes","--package","kith-coord@0.1.9","kith","mcp","--repo","/absolute/checkout"]}}}
93
+ {"mcpServers":{"kith":{"command":"npx","args":["--yes","--package","kith-coord@0.2.1","kith","mcp","--repo","/absolute/checkout"]}}}
90
94
  ```
91
95
 
92
96
  Use a version you have verified; the unrelated npm package named `kith` is not Kith's distribution. Hook commands still need their configured executable to remain available. The clean-package smoke check exercises the installed binary, library, supervised worker and actual MCP discovery/status in a separate consumer.
@@ -99,7 +103,7 @@ Version 0.1.1 generates MCP configuration using the current absolute Node execut
99
103
 
100
104
  ## Configure detected local clients
101
105
 
102
- From 0.1.7, `npx --yes --package kith-coord@0.1.9 kith setup /absolute/checkout` is the single setup path. Versions through 0.1.6 need a persistent npm installation first. Setup retains the exact bundled runtime under `~/.local/share/kith/runtimes/`, validates actual MCP discovery without selecting a repository, configures supported detected clients and adds marked project guidance. Clearing the original npx cache does not break its launcher. Repeat setup reuses identical content. `kith install` removes retained runtimes under `~/.local/share/kith/runtimes/` that no live hook, MCP entry, or login agent still names, and keeps a runtime any of those configs still point at. A damaged selected runtime is refused rather than overwritten. Custom launchers remain custom. `kith doctor` fails when one of those configs points at a different Kith version than the CLI you just ran, and tells you to run `kith install`.
106
+ From 0.1.7, `npx --yes --package kith-coord@0.2.1 kith setup /absolute/checkout` is the single setup path. Versions through 0.1.6 need a persistent npm installation first. Setup retains the exact bundled runtime under `~/.local/share/kith/runtimes/`, validates actual MCP discovery without selecting a repository, configures supported detected clients and adds marked project guidance. Clearing the original npx cache does not break its launcher. Repeat setup reuses identical content. `kith install` removes retained runtimes under `~/.local/share/kith/runtimes/` that no live hook, MCP entry, or login agent still names, and keeps a runtime any of those configs still point at. A damaged selected runtime is refused rather than overwritten. Custom launchers remain custom. `kith doctor` fails when one of those configs points at a different Kith version than the CLI you just ran, and tells you to run `kith install`.
103
107
 
104
108
  **From 0.1.8,** `kith install` is the single onboarding command and `kith setup` remains an alias. Both retain the runtime above, and on macOS they open read-only Radar and register a login LaunchAgent (`dev.kith.radar`) unless `--no-radar` or `--no-autostart` is passed. Repeating setup keeps an existing view and its selected workspace; use its **Switch Workspace** menu to change projects. `--dry-run` previews without launching. Linux and Windows skip the menu-bar view and use `kith watch`. Radar makes no model calls. A Radar startup failure is reported with a nonzero exit while preserving completed client setup; rerun after resolving the error. `kith uninstall` removes the LaunchAgent, global hooks and global MCP entries it recorded.
105
109
 
@@ -94,6 +94,14 @@
94
94
  "type": "boolean",
95
95
  "description": "Recommended: true, giving each parallel agent a separate Git worktree"
96
96
  },
97
+ "adoptWorktree": {
98
+ "type": "boolean",
99
+ "description": "Register an existing linked worktree instead of creating one. Pass worktreePath when this server is not already inside it."
100
+ },
101
+ "worktreePath": {
102
+ "type": "string",
103
+ "description": "Absolute path of an existing linked worktree to adopt, such as a Claude Code .claude/worktrees/<name> checkout"
104
+ },
97
105
  "waitTimeoutMs": {
98
106
  "type": "integer",
99
107
  "minimum": 0,
@@ -140,6 +148,14 @@
140
148
  "type": "boolean",
141
149
  "description": "Recommended: true, giving the claiming agent an isolated Git worktree"
142
150
  },
151
+ "adoptWorktree": {
152
+ "type": "boolean",
153
+ "description": "Register an existing linked worktree instead of creating one"
154
+ },
155
+ "worktreePath": {
156
+ "type": "string",
157
+ "description": "Absolute path of an existing linked worktree to adopt"
158
+ },
143
159
  "waitTimeoutMs": {
144
160
  "type": "integer",
145
161
  "minimum": 0,
@@ -164,6 +180,43 @@
164
180
  "$schema": "http://json-schema.org/draft-07/schema#"
165
181
  }
166
182
  },
183
+ {
184
+ "name": "kith_adopt_worktree",
185
+ "description": "Register an existing linked Git worktree as this agent's workspace. Use this for Claude Code --worktree checkouts under .claude/worktrees/<name> and for any other git worktree list entry. Kith does not create, clean, or delete that directory.",
186
+ "inputSchema": {
187
+ "type": "object",
188
+ "properties": {
189
+ "agentId": {
190
+ "type": "string"
191
+ },
192
+ "sessionToken": {
193
+ "type": "string"
194
+ },
195
+ "client": {
196
+ "type": "string"
197
+ },
198
+ "worktreePath": {
199
+ "type": "string",
200
+ "description": "Absolute path of the linked worktree. Defaults to the server cwd when that cwd is already the worktree."
201
+ },
202
+ "operationKey": {
203
+ "type": "string",
204
+ "minLength": 1,
205
+ "maxLength": 128,
206
+ "description": "Unique key per mutation attempt; retry exact arguments/key after timeout. Not a credential. Use a new key after repair/backoff."
207
+ },
208
+ "repository": {
209
+ "type": "string",
210
+ "description": "Absolute original Git checkout; required without project context. Keep it unchanged for this task."
211
+ }
212
+ },
213
+ "required": [
214
+ "agentId"
215
+ ],
216
+ "additionalProperties": false,
217
+ "$schema": "http://json-schema.org/draft-07/schema#"
218
+ }
219
+ },
167
220
  {
168
221
  "name": "kith_add_task",
169
222
  "description": "Add a task to the orchestrated DAG queue with optional task dependencies and file scope globs.",
package/docs/protocol.md CHANGED
@@ -6,7 +6,7 @@ Kith is a local ledger for cooperating coding agents. Clients share one reposito
6
6
 
7
7
  Protocol 1.1 ships with package 0.1.2. Earlier `kith-coord@0.1.1` reports protocol 1.0 and includes full contracts in MCP status; the compact default and `includeContracts` input below require 0.1.2.
8
8
 
9
- `KITH_PROTOCOL_VERSION` and status responses advertise `1.6.0` starting with package 0.1.8; package 0.1.7 advertises `1.5.0`, and package 0.1.6 advertises `1.4.0`. Protocol 1.6 adds optional tools (`kith_write_handoff`, `kith_read_handoffs`, `kith_brief`) and additive result fields (handoffs, `workflowMode`, `session.leaseExpiresAt`, `completedIntegrationCount`). The storage schema stays 3. Opening the database creates an optional `handoffs` table that older binaries ignore. Package releases (`kith-coord`, beginning at 0.1.0) and the SQLite storage schema have independent versions. The [tool snapshot](protocol/tools.v1.json) contains all 17 tool names, descriptions and JSON input schemas, exported from an actual MCP `tools/list` response. `pnpm protocol:check` rejects snapshot drift in CI. Update deliberately using `pnpm protocol:export`.
9
+ `KITH_PROTOCOL_VERSION` and status responses advertise `1.6.0` starting with package 0.1.8; package 0.1.7 advertises `1.5.0`, and package 0.1.6 advertises `1.4.0`. Protocol 1.6 adds optional tools (`kith_write_handoff`, `kith_read_handoffs`, `kith_brief`) and additive result fields (handoffs, `workflowMode`, `session.leaseExpiresAt`, `completedIntegrationCount`). The storage schema stays 3. Opening the database creates an optional `handoffs` table that older binaries ignore. Package releases (`kith-coord`, beginning at 0.1.0) and the SQLite storage schema have independent versions. The [tool snapshot](protocol/tools.v1.json) contains every full-profile tool name, description and JSON input schema, exported from an actual MCP `tools/list` response. Package 0.2.0 adds `kith_adopt_worktree`, so the snapshot lists 18 tools. The advertised protocol version remains 1.6.0. `pnpm protocol:check` rejects snapshot drift in CI. Update deliberately using `pnpm protocol:export`.
10
10
 
11
11
  For protocol 1.x, existing tool names, required input fields and the ownership/claim semantics below remain compatible. New optional fields/tools and additive result fields use a minor version; compatible repairs use a patch version. Removing tools, adding required inputs or changing ownership semantics requires a major version. Clients should ignore unknown result fields. The snapshot describes inputs; it is not a machine-validated schema for every result or a guarantee of source-level library compatibility.
12
12
 
@@ -44,7 +44,18 @@ A session boundary used to erase what an agent learned: its claims were released
44
44
 
45
45
  A repository is in one of two modes, shared by every agent and worktree and stored with the coordination state (`worktrees` unless changed). In `worktrees` mode each agent may work in an isolated worktree and integrates through the merge train. In `main` mode every agent works in the one checkout and coordinates through scope claims: `kith_begin_work` and `kith_claim_next_task` never create a worktree, they ignore `isolateWorktree` and say so in `notes`, and completing work releases the claims with no integration step (so a `verificationCmd` is not run). Both tools and `kith_get_status` report `workflowMode`. Set it with `kith mode main|worktrees` or `kith init --mode`; `kith mode` shows it. Generated agent guidance describes the recorded mode.
46
46
 
47
- `kith mcp --compact`, the default used by `kith install`, advertises six workflow tools instead of the 17 in the snapshot: `kith_brief`, `kith_work`, `kith_claim`, `kith_handoff`, `kith_finish` and `kith_resource`. `kith mcp --full` restores the 17-tool list. Both advertise protocol 1.6.0.
47
+ `kith mcp --compact`, the default used by `kith install`, advertises six workflow tools instead of the full snapshot: `kith_brief`, `kith_work`, `kith_claim`, `kith_handoff`, `kith_finish` and `kith_resource`. `kith_work` with `action: "adopt"` registers an existing linked worktree. `kith mcp --full` restores the full list, including `kith_adopt_worktree`. Both advertise protocol 1.6.0.
48
+
49
+ ## 0.2.0: adopting an existing worktree
50
+
51
+ These fields ship in package 0.2.0 and do not change the advertised protocol version. Package 0.2.1 adds no tools and does not change the advertised protocol version or the storage schema.
52
+
53
+ - `kith_adopt_worktree` registers a linked worktree (`worktreePath`, or the server cwd when that cwd is already the worktree) for an agent. It does not create the directory, clean it, or delete it.
54
+ - `kith_begin_work` and `kith_claim_next_task` accept optional `adoptWorktree` and `worktreePath`. When either is set, Kith adopts that checkout instead of creating one. `isolateWorktree` is not also applied.
55
+ - The worktree object adds `provenance` (`created` or `adopted`), `source` (`kith`, `claude-code`, or `external`), `detached`, `dirty`, `branchCheckedOutElsewhere`, and `notes`. `branch` is null when HEAD is detached.
56
+ - `kith_get_status` adds `worktreeRegistrations`. Storage stays schema 3. Opening the database creates an optional `worktree_registrations` table that older binaries ignore.
57
+
58
+ A detached adopted HEAD is not integrated. A branch checked out in another worktree is not committed or integrated. An adopted branch that is unique still uses the verification gate below. Clients should keep sending the original checkout as `repository`.
48
59
 
49
60
  ## Workspace observation and integration
50
61
 
@@ -9,7 +9,7 @@ Scope intersection is exact within the documented grammar; unsupported scopes ar
9
9
  - Conflicting exclusive file locks and task claims have unique owners under simultaneous process contention.
10
10
  - Port reservations are rechecked atomically after asynchronous OS probes; exhaustion returns an error.
11
11
  - Setup previews without writes, preserves unrelated JSON settings, and rejects malformed config before writing selected configuration.
12
- - Worktree creation refuses an existing path or branch; removal refuses local, untracked, or ignored changes.
12
+ - Worktree creation refuses an existing path or branch; removal refuses local, untracked, or ignored changes. An adopted worktree is not deleted or pruned by garbage collection or `kith worktree remove`. Explicit `--delete-adopted` still refuses a dirty tree. Integration of an adopted branch stays behind the verification command; a detached HEAD and a branch checked out elsewhere are refused before that command runs.
13
13
  - Integration refuses a dirty target and concurrent Kith integrations; failed or mutating verification preserves the target and source worktree for retry. Checks cannot change the candidate commit, tracked/index contents, or leave new nonignored files behind.
14
14
  - Unresolved Git conflicts fail integration without custom source/JSON rewriting. Source and target work remain available for explicit repair and retry.
15
15
  - Shadow-tree deletions reach Git; invalid merge inputs surface errors.
package/docs/roadmap.md CHANGED
@@ -16,6 +16,8 @@ MCP is the default agent interface. Keep one shared ownership ledger per Git com
16
16
 
17
17
  Published 0.1.7 / protocol 1.5 is on npm, including durable setup and compact MCP replies. Kith 0.1.8 advances the additive protocol to 1.6 (handoffs, the brief, workflow mode, lease receipts and quieter status) and keeps storage schema 3, with an optional handoffs table that older binaries ignore. Each candidate must pass its own combined core/platform, bundled-server and clean-install gates before publication; a green prior release does not certify a new branch.
18
18
 
19
+ 0.2.0 registers a linked worktree an agent already has — Claude Code's `.claude/worktrees/<name>` layout first, and any other `git worktree list` entry — instead of always creating one. 0.2.1 keeps that protocol and schema and hardens crash recovery, staging, and fail-closed checks. Publish that package from the merged release commit; a green pull request is not a registry release.
20
+
19
21
  ## Deferred
20
22
 
21
23
  No new dashboard, fleet spawning, model router, automatic merges, semantic scoring, writer-PID attribution, whole-Mac crawler or new adapters are planned in this reliability pass. Prioritize concrete blocked workflows over feature requests. Actual external task completion remains a separate product-validation gate.
@@ -30,7 +30,7 @@ CLI sessions are anchored to their parent process unless `--owner-pid` is suppli
30
30
  eval "$(kith session start --agent auth-worker --new --owner-pid "$$" --shell)"
31
31
  ```
32
32
 
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.
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. That removal applies to a worktree Kith created. An adopted worktree (Claude Code's `.claude/worktrees/<name>`, or any other linked worktree registered with `kith adopt`) is not deleted by `kith worktree remove` or `kith gc`. Unregister it with `kith worktree forget`, or pass `--delete-adopted` when you mean to remove that directory.
34
34
 
35
35
  ## Git-ignored files and clearing a stuck auto-session
36
36
 
package/docs/usage.md CHANGED
@@ -24,6 +24,30 @@ kith_brief {"scopeGlobs":["src/auth/**"]} # the same, over MCP
24
24
 
25
25
  Run it before beginning work. With `kith init --only brief` Claude Code runs it for you at the start of every session.
26
26
 
27
+ ## Adopt a worktree that already exists
28
+
29
+ Claude Code's `claude --worktree <name>` creates `.claude/worktrees/<name>` on a branch named `worktree-<name>`. Subagent worktree isolation and `EnterWorktree` use that same directory. Other tools create ordinary linked worktrees anywhere `git worktree list` shows them. Kith can register that checkout as the agent's workspace.
30
+
31
+ A joined hook does this on its own when the hook input `cwd` (not `CLAUDE_PROJECT_DIR`, which stays on the original checkout) is inside exactly one linked worktree of this repository, the session does not already have a different worktree, and no other live agent has that path. The primary checkout is never adopted. Anything ambiguous is left alone. The [Claude Code plugin](install.md#claude-code-plugin) runs `kith hook pre|post --client claude --auto` and forwards that `cwd`. Once the auto session has joined, the worktree is adopted, and a later MCP call from the same client keeps that workspace. `kith install` hooks do the same check.
32
+
33
+ ```sh
34
+ kith adopt # current directory, when it is a linked worktree
35
+ kith adopt /path/to/worktree
36
+ kith worktree adopt /path/to/worktree
37
+ kith begin --adopt /path/to/worktree --scope 'src/auth/**'
38
+ ```
39
+
40
+ `--repo` stays the integration checkout. Pass it when you run the command from inside the worktree and the target is the primary checkout. On MCP, pass the original checkout as `repository` and the worktree as `worktreePath`:
41
+
42
+ ```text
43
+ kith_adopt_worktree {"agentId":"auth-worker","worktreePath":"/repo/.claude/worktrees/feature-auth"}
44
+ kith_begin_work {"agentId":"auth-worker","title":"Refresh authentication","scopeGlobs":["src/auth/**"],"adoptWorktree":true,"worktreePath":"/repo/.claude/worktrees/feature-auth"}
45
+ ```
46
+
47
+ Compact MCP uses `kith_work` with `action: "adopt"`. A dirty tree is adopted unchanged. `kith commit` records commits on a detached HEAD; integration waits until that HEAD is a branch. Integration and `kith commit` both refuse a branch that is also checked out in another worktree. A unique branch still integrates only when the verification command passes, and a failure leaves the target unchanged. In main-checkout mode the adopted directory is the workspace for claims and `kith commit`, and completion does not integrate.
48
+
49
+ `kith worktree forget` drops the registration and leaves the directory. `kith worktree remove` refuses an adopted worktree. `kith worktree remove --delete-adopted` removes a clean one. `kith gc` never deletes or prunes a worktree Kith did not create.
50
+
27
51
  ## Working in the main checkout
28
52
 
29
53
  Some teams work on the main branch with one checkout and treat worktrees as overhead. Say so once:
@@ -203,3 +227,24 @@ Never include session tokens in issues, terminal recordings, or shared logs. See
203
227
  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.
204
228
 
205
229
  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`.
230
+
231
+ ## How a task moves through Kith
232
+
233
+ 0. **Look first.** `kith brief` (or `kith_brief`) shows who is active on what, claims that overlap your scope, open handoffs and conflicts. It is read-only and needs no session.
234
+ 1. **Begin through MCP.** Call `kith_begin_work` with a unique `agentId`, explicit `scopeGlobs`, and `isolateWorktree: true`. The connection retains session ownership; no shell exports are needed for this MCP-only workflow.
235
+ 2. **Claim a scope.** Cooperating clients receive a conflict when an exclusive claim overlaps another claim.
236
+ 3. **Do the work.** Edit the returned `worktree.worktreePath`, report edits with `kith_record_file_edit`, and use `kith_run_with_mutex` for serialised commands. Heartbeat before expiry and keep the owning connection open.
237
+ 4. **Leave a handoff.** When you finish, get blocked or must stop, call `kith_write_handoff` with what is done, what remains, what failed and what you learned. `releaseTask` hands the task back to the queue. If a session ends without a note, Kith records what it observed. The next agent on the same scope receives these notes from `kith_begin_work` or `kith_claim_next_task`, labelled as untrusted information to verify.
238
+ 5. **Verify and complete.** For a worktree, Kith checkpoints changes and integrates through a separate staging worktree. The target may hold unrelated uncommitted work, but not edits to files the integration changes. Supply a check to require more than Git mergeability. With no check, a clean merge is the gate.
239
+
240
+ Failed verification leaves the target unchanged and keeps the worktree for repair. Successful integration also retains the worktree until explicit cleanup. External Git writers must still coordinate.
241
+
242
+ Inspect through `kith_get_status` or `kith status`: worktree paths and branches, dirty-file overlap, ahead/behind, heartbeat and commit age, and FIFO waiters are included. Use `kith_preview_integrate` for committed-tree conflict paths before completing. Normal status may reap expired owners. For non-mutating recovery inspection use:
243
+
244
+ ```sh
245
+ kith status --offline
246
+ kith recover
247
+ kith doctor
248
+ ```
249
+
250
+ Optional Claude and Cursor hooks support `--enforcement block` (default), `warn` and `off`; see [setup and safe uninstall](integrations.md). The [versioned protocol](protocol.md) records the tool schemas and ownership semantics.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kith-coord",
3
- "version": "0.1.9",
4
- "description": "Local coordination for cooperating coding agents: work claims, isolated worktrees, shared resources, and verified integration without a hosted service.",
3
+ "version": "0.2.1",
4
+ "description": "File ownership for coding agents you already run: claims, port and command locks, and checked integration, with no account and no coordination server.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "kith": "./dist/cli/index.js",
@@ -26,6 +26,7 @@
26
26
  "CODE_OF_CONDUCT.md",
27
27
  "CHANGELOG.md",
28
28
  "assets/brand",
29
+ "assets/demo",
29
30
  "bin/kith-menubar"
30
31
  ],
31
32
  "engines": {
@@ -49,20 +50,19 @@
49
50
  "test:menubar": "node scripts/test-menubar.mjs"
50
51
  },
51
52
  "keywords": [
52
- "ai-agents",
53
- "parallel-agents",
54
53
  "mcp",
54
+ "mcp-server",
55
55
  "claude-code",
56
- "codex",
57
- "antigravity",
58
56
  "cursor",
57
+ "codex",
58
+ "ai-agents",
59
+ "multi-agent",
59
60
  "git-worktree",
60
- "coordination",
61
- "multi-agent"
61
+ "coordination"
62
62
  ],
63
63
  "license": "MIT",
64
64
  "dependencies": {
65
- "@modelcontextprotocol/sdk": "^1.32.1",
65
+ "@modelcontextprotocol/sdk": "^1.32.2",
66
66
  "picomatch": "^4.0.2",
67
67
  "smol-toml": "^1.9.1",
68
68
  "zod": "^3.24.2"
@@ -71,7 +71,7 @@
71
71
  "@types/node": "^22.13.0",
72
72
  "@types/picomatch": "^4.0.0",
73
73
  "tsup": "^8.4.0",
74
- "vitest": "^3.0.7",
74
+ "vitest": "^5.1.1",
75
75
  "typescript": "^5.8.2"
76
76
  },
77
77
  "packageManager": "pnpm@10.20.0",
package/server.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.connorhriley/kith",
4
4
  "title": "Kith",
5
- "description": "Coordinate coding agents with work claims, Git worktrees, shared resources and verified integration.",
6
- "version": "0.1.9",
5
+ "description": "File ownership for coding agents you already run: claims, locks, checked integration.",
6
+ "version": "0.2.1",
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.9",
26
+ "version": "0.2.1",
27
27
  "runtimeHint": "npx",
28
28
  "runtimeArguments": [
29
29
  {