Between `open(lockPath, O_CREAT | O_EXCL)` and `fd.writeFile(pid)` there is an async await gap. If a second process reads the lock file during that window it sees empty content, which parseInt returns as NaN. The previous code returned `true` (dead) for non-finite PID values, causing the second process to unlink the live lock and steal it — both processes then entered readModifyWriteStateMd simultaneously, producing a lost-update TOCTOU. Fix: return `null` (unknown) instead of `true` when the lock file contains no parseable PID. The caller already treats `null` as "not confirmed dead" and falls through to the normal retry + timeout path, giving the first process time to finish writing its PID. The CJS acquireStateLock in state.cjs never had this race because it uses synchronous fs.openSync / fs.writeSync / fs.closeSync with no async gap. Fixes intermittent failure of: #1925 TOCTOU: state commands use readModifyWriteStateMd → state add-blocker: both concurrent calls append different blockers (observed: macos-latest / Node 22 and windows-latest / Node 22 on main) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gsd-build/sdk
TypeScript SDK for Get Shit Done: deterministic query/mutation handlers, plan execution, and event-stream telemetry so agents focus on judgment, not shell plumbing.
Install
npm install @gsd-build/sdk
Quickstart — programmatic
import { GSD, createRegistry } from '@gsd-build/sdk';
const gsd = new GSD({ projectDir: process.cwd(), sessionId: 'my-run' });
const tools = gsd.createTools();
const registry = createRegistry(gsd.eventStream, 'my-run');
const { data } = await registry.dispatch('state.json', [], process.cwd());
Quickstart — CLI
From a project that depends on this package, invoke the CLI with Node (recommended in CI and local dev):
node ./node_modules/@gsd-build/sdk/dist/cli.js query state.json
node ./node_modules/@gsd-build/sdk/dist/cli.js query roadmap.analyze
If no native handler is registered for a command, the CLI can transparently shell out to get-shit-done/bin/gsd-tools.cjs (see stderr warning), unless GSD_QUERY_FALLBACK=off.
What ships
| Area | Entry |
|---|---|
| Query registry | createRegistry() in src/query/index.ts — same handlers as gsd-sdk query |
| Tools bridge | GSDTools — native dispatch with optional CJS subprocess fallback |
| Orchestrators | PhaseRunner, InitRunner, GSD |
| CLI | gsd-sdk — query, run, init, auto |
Guides
- Handler registry & contracts:
src/query/QUERY-HANDLERS.md - Repository docs (when present):
docs/ARCHITECTURE.md,docs/CLI-TOOLS.mdat repo root
Environment
| Variable | Purpose |
|---|---|
GSD_QUERY_FALLBACK |
off / never disables CLI fallback to gsd-tools.cjs for unknown commands |
GSD_AGENTS_DIR |
Override directory scanned for installed GSD agents (~/.claude/agents by default) |