get-tbd 0.2.0 → 0.2.2

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 (37) hide show
  1. package/dist/bin.mjs +551 -168
  2. package/dist/bin.mjs.map +1 -1
  3. package/dist/cli.mjs +492 -159
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/docs/SKILL.md +2 -2
  6. package/dist/docs/guidelines/bun-monorepo-patterns.md +65 -66
  7. package/dist/docs/guidelines/cli-agent-skill-patterns.md +396 -158
  8. package/dist/docs/guidelines/common-doc-guidelines.md +2 -2
  9. package/dist/docs/guidelines/convex-limits-best-practices.md +39 -39
  10. package/dist/docs/guidelines/convex-rules.md +13 -13
  11. package/dist/docs/guidelines/electron-app-development-patterns.md +18 -18
  12. package/dist/docs/guidelines/general-comment-rules.md +1 -1
  13. package/dist/docs/guidelines/general-tdd-guidelines.md +4 -4
  14. package/dist/docs/guidelines/golden-testing-guidelines.md +9 -9
  15. package/dist/docs/guidelines/pnpm-monorepo-patterns.md +49 -49
  16. package/dist/docs/guidelines/python-cli-patterns.md +1 -1
  17. package/dist/docs/guidelines/python-modern-guidelines.md +4 -4
  18. package/dist/docs/guidelines/release-notes-guidelines.md +18 -2
  19. package/dist/docs/guidelines/supply-chain-hardening.md +84 -29
  20. package/dist/docs/guidelines/tbd-sync-troubleshooting.md +3 -3
  21. package/dist/docs/guidelines/typescript-cli-tool-rules.md +17 -17
  22. package/dist/docs/guidelines/typescript-code-coverage.md +5 -5
  23. package/dist/docs/guidelines/typescript-rules.md +3 -3
  24. package/dist/docs/guidelines/typescript-yaml-handling-rules.md +3 -3
  25. package/dist/docs/shortcuts/system/skill-baseline.md +2 -2
  26. package/dist/docs/tbd-design.md +40 -40
  27. package/dist/docs/tbd-docs.md +1 -1
  28. package/dist/docs/tbd-prime.md +3 -3
  29. package/dist/{id-mapping-CtfTfGIh.mjs → id-mapping-687_UEsy.mjs} +66 -16
  30. package/dist/id-mapping-687_UEsy.mjs.map +1 -0
  31. package/dist/{id-mapping-CFoPVinz.mjs → id-mapping-mtoSP9Qt.mjs} +1 -1
  32. package/dist/index.mjs +1 -1
  33. package/dist/{src-rIE4xSVs.mjs → src-BpvcrLnq.mjs} +2 -2
  34. package/dist/{src-rIE4xSVs.mjs.map → src-BpvcrLnq.mjs.map} +1 -1
  35. package/dist/tbd +551 -168
  36. package/package.json +1 -1
  37. package/dist/id-mapping-CtfTfGIh.mjs.map +0 -1
@@ -14,8 +14,8 @@ Commander 14 moves to security-only maintenance until May 2027.
14
14
  **Related**:
15
15
 
16
16
  - [TypeScript Rules](./typescript-rules.md)
17
- - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)
18
- follow the 14-day package-age rule for every CLI dependency.
17
+ - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)—follow
18
+ the 14-day package-age rule for every CLI dependency.
19
19
  Bundlers and CLI dependencies that execute at install time (`postinstall` scripts) are
20
20
  a primary attack surface.
21
21
 
@@ -368,10 +368,10 @@ context, output, and error handling.
368
368
  Strict separation of data and diagnostics enables pipeline composability.
369
369
 
370
370
  - **Data to stdout:** `data()`, `success()`, `notice()`, `dryRun()`, `table()`,
371
- `list()`, `count()` — all go to `console.log` (stdout).
371
+ `list()`, `count()`—all go to `console.log` (stdout).
372
372
 
373
373
  - **Diagnostics to stderr:** `info()`, `warn()`, `error()`, `command()`, `debug()`,
374
- `spinner` — all go to `console.error` (stderr) or `process.stderr.write`.
374
+ `spinner`—all go to `console.error` (stderr) or `process.stderr.write`.
375
375
 
376
376
  - **JSON mode wraps diagnostics:** `warn()` outputs `{"warning": "..."}` to stderr.
377
377
  `error()` outputs `{"error": "..."}` to stderr.
@@ -579,7 +579,7 @@ seamlessly in local dev and in remote environments.
579
579
  precedence logic, or runtime conditional loading from inside the CLI).
580
580
 
581
581
  - **Use `dotenv` only when needed:** Add `dotenv` only if your CLI must load env files
582
- programmatically e.g., it reads them after parsing command-line flags, performs
582
+ programmatically—e.g., it reads them after parsing command-line flags, performs
583
583
  variable expansion, or supports custom file paths the user cannot pre-bake into the
584
584
  `node` invocation.
585
585
 
@@ -615,11 +615,11 @@ seamlessly in local dev and in remote environments.
615
615
 
616
616
  - **Standard environment variables to respect:**
617
617
 
618
- - `NO_COLOR` — disable colors (standard)
619
- - `FORCE_COLOR` — force colors
620
- - `CI` — detect CI environment, force non-interactive
621
- - `DEBUG` — enable debug logging (or a namespaced equivalent like `<TOOL>_DEBUG`)
622
- - `PAGER` — custom pager command for long output
618
+ - `NO_COLOR`—disable colors (standard)
619
+ - `FORCE_COLOR`—force colors
620
+ - `CI`—detect CI environment, force non-interactive
621
+ - `DEBUG`—enable debug logging (or a namespaced equivalent like `<TOOL>_DEBUG`)
622
+ - `PAGER`—custom pager command for long output
623
623
 
624
624
  ## Sub-Command Logging for Testability
625
625
 
@@ -705,27 +705,27 @@ runtimes, Cloudflare Workers, etc.).
705
705
 
706
706
  **Key patterns:**
707
707
 
708
- - **Base Command Pattern** — All handlers extend `BaseCommand`, which provides
708
+ - **Base Command Pattern**—All handlers extend `BaseCommand`, which provides
709
709
  `CommandContext`, `OutputManager`, `execute()` error wrapping, and `checkDryRun()`
710
710
 
711
- - **Dual Output Mode** — `OutputManager.data(data, textFormatter)` switches between JSON
711
+ - **Dual Output Mode**—`OutputManager.data(data, textFormatter)` switches between JSON
712
712
  and text formatting based on `--json` flag
713
713
 
714
- - **Handler + Command Structure** — Command definition (`.option()`, `.action()`) is
714
+ - **Handler + Command Structure**—Command definition (`.option()`, `.action()`) is
715
715
  separate from handler class implementation.
716
716
  Action handlers do `new XxxHandler(command)` then `handler.run(options)`
717
717
 
718
- - **Version Handling** — Prefer deterministic runtime version resolution: build-time
718
+ - **Version Handling**—Prefer deterministic runtime version resolution: build-time
719
719
  injection first, then environment override for dev/test, then `package.json` fallback
720
720
 
721
- - **Global Options** — Define `--dry-run`, `--verbose`, `--quiet`, `--json`, `--color`,
721
+ - **Global Options**—Define `--dry-run`, `--verbose`, `--quiet`, `--json`, `--color`,
722
722
  and `--debug` at program level, plus tool-specific options as needed.
723
723
  Only add `--non-interactive` and `--yes` if the CLI has interactive prompts
724
724
 
725
- - **Stdout/Stderr Separation** — Data to stdout, diagnostics to stderr for pipeline
725
+ - **Stdout/Stderr Separation**—Data to stdout, diagnostics to stderr for pipeline
726
726
  compatibility. See the Stdout/Stderr Separation section above for details
727
727
 
728
- - **Terminal Width Management** — Cap help text and formatted output at a maximum width
728
+ - **Terminal Width Management**—Cap help text and formatted output at a maximum width
729
729
  (e.g., 88 chars) for readability, using narrower if the terminal is smaller
730
730
 
731
731
  ## Best Practices
@@ -7,14 +7,14 @@ author: Joshua Levy (github.com/jlevy) with LLM assistance
7
7
 
8
8
  **Last Updated**: 2026-05-21
9
9
 
10
- **Tracks**: Vitest `^4.1.7`, `@vitest/coverage-v8` `^4.1.7`. Vitest 5.0 is in beta do
10
+ **Tracks**: Vitest `^4.1.7`, `@vitest/coverage-v8` `^4.1.7`. Vitest 5.0 is in beta—do
11
11
  not adopt yet.
12
12
 
13
13
  **Related**:
14
14
 
15
- - [Companion: pnpm Monorepo Patterns Testing](./pnpm-monorepo-patterns.md#8-testing)
16
- - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)
17
- follow the 14-day package-age rule when installing or upgrading `vitest` and
15
+ - [Companion: pnpm Monorepo Patterns—Testing](./pnpm-monorepo-patterns.md#8-testing)
16
+ - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)—follow
17
+ the 14-day package-age rule when installing or upgrading `vitest` and
18
18
  `@vitest/coverage-v8`.
19
19
 
20
20
  ## Coverage Metrics
@@ -95,7 +95,7 @@ upgrade: use `ncu --cooldown 14` or `pnpm install --frozen-lockfile`.
95
95
  - **`coverage.all` was removed** in Vitest 4. Use `coverage.include` and
96
96
  `coverage.exclude` to define exactly which files are reported.
97
97
  - Coverage reporters and v8 provider now ship as part of `@vitest/coverage-v8` aligned
98
- with the Vitest major version pin them together.
98
+ with the Vitest major version—pin them together.
99
99
 
100
100
  ### Example Configuration
101
101
 
@@ -11,7 +11,7 @@ alwaysApply: true
11
11
 
12
12
  **Tracks**: TypeScript `^6.0.3` (stable).
13
13
  TypeScript 7.0 Beta (`@typescript/native-preview`, binary `tsgo`) is available but **not
14
- yet production-ready** — do not adopt for shipped builds.
14
+ yet production-ready**—do not adopt for shipped builds.
15
15
 
16
16
  **Related**:
17
17
 
@@ -21,7 +21,7 @@ yet production-ready** — do not adopt for shipped builds.
21
21
  - [TypeScript Code Coverage](./typescript-code-coverage.md)
22
22
  - [pnpm Monorepo Patterns](./pnpm-monorepo-patterns.md) and
23
23
  [Bun Monorepo Patterns](./bun-monorepo-patterns.md)
24
- - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation) the
24
+ - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)—the
25
25
  14-day package-age rule applies to every TypeScript dependency (`zod`, `commander`,
26
26
  `vitest`, `eslint`, type packages, etc.).
27
27
 
@@ -352,7 +352,7 @@ yet production-ready** — do not adopt for shipped builds.
352
352
 
353
353
  - **Barrel files:** The rules differ for libraries vs applications.
354
354
 
355
- **For libraries:** Use exactly ONE barrel file the root `index.ts` that defines the
355
+ **For libraries:** Use exactly ONE barrel file—the root `index.ts` that defines the
356
356
  public API. This is essential for consumers who `import { X } from 'your-library'`. Do
357
357
  NOT create module-level barrels (like `utils/index.ts` or `harness/index.ts`).
358
358
  Internal code should import directly from source files.
@@ -9,14 +9,14 @@ globs: "*.ts"
9
9
  **Last Updated**: 2026-05-21
10
10
 
11
11
  **Tracks**: `yaml@^2.8.4` (latest stable; 2026-05-02). The `yaml@3.0.0-1` release is
12
- tagged `next` (pre-release) do not adopt yet.
12
+ tagged `next` (pre-release)—do not adopt yet.
13
13
  Zod 4.x is the recommended validation companion.
14
14
 
15
15
  **Related**:
16
16
 
17
17
  - [TypeScript Rules](./typescript-rules.md)
18
- - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)
19
- follow the 14-day package-age rule for `yaml`, `zod`, and `gray-matter`.
18
+ - [Supply-Chain Mitigation](./pnpm-monorepo-patterns.md#supply-chain-mitigation)—follow
19
+ the 14-day package-age rule for `yaml`, `zod`, and `gray-matter`.
20
20
 
21
21
  These guidelines ensure consistent, safe, and readable YAML handling across TypeScript
22
22
  codebases. YAML is deceptively tricky—inconsistent quoting, serialization differences,
@@ -130,7 +130,7 @@ working branch. See `tbd guidelines tbd-sync-troubleshooting` for details.
130
130
 
131
131
  | Command | Purpose |
132
132
  | --- | --- |
133
- | `tbd create "title" --type task\|bug\|feature --priority=P2` | New bead (P0-P4, not “high/medium/low”) |
133
+ | `tbd create "title" --type=bug --priority=1` | New bead; run `tbd create --help` for all types and priorities (P0-P4, not “high/medium/low”) |
134
134
  | `tbd update <id> --status in_progress` | Claim work |
135
135
  | `tbd close <id> [--reason "..."]` | Mark complete |
136
136
 
@@ -168,6 +168,6 @@ working branch. See `tbd guidelines tbd-sync-troubleshooting` for details.
168
168
  ## Quick Reference
169
169
 
170
170
  - **Priority**: P0=critical, P1=high, P2=medium (default), P3=low, P4=backlog
171
- - **Types**: task, bug, feature, epic
171
+ - **Types**: issues default to `task`; run `tbd create --help` for the valid types
172
172
  - **Status**: open, in_progress, closed
173
173
  - **JSON output**: Add `--json` to any command
@@ -235,23 +235,23 @@ on demand.
235
235
 
236
236
  tbd provides **three integrated capabilities**:
237
237
 
238
- 1. **Task tracking (beads)** — Git-native issues, bugs, epics, and dependencies that
238
+ 1. **Task tracking (beads)**—Git-native issues, bugs, epics, and dependencies that
239
239
  persist across sessions.
240
240
  This alone is a step change in what agents can do.
241
- 2. **Spec-driven planning** — Workflows for writing specs, breaking them into issues,
242
- and implementing systematically.
243
- 3. **Instant knowledge injection** — 17+ detailed guideline docs covering TypeScript,
244
- Python, Convex, monorepo architecture, TDD, and more injected into the agent’s
241
+ 2. **Spec-driven planning**—Workflows for writing specs, breaking them into issues, and
242
+ implementing systematically.
243
+ 3. **Instant knowledge injection**—17+ detailed guideline docs covering TypeScript,
244
+ Python, Convex, monorepo architecture, TDD, and more—injected into the agent’s
245
245
  context on demand via shortcuts, guidelines, and templates.
246
246
 
247
247
  The **issue tracking layer** has four core principles:
248
248
 
249
- - **Durable storage in git** — Issues are version-controlled and distributed via
250
- standard git
251
- - **Works in almost any environment** — No daemon, no SQLite, no file locking issues on
249
+ - **Durable storage in git**—Issues are version-controlled and distributed via standard
250
+ git
251
+ - **Works in almost any environment**—No daemon, no SQLite, no file locking issues on
252
252
  network drives
253
- - **Simple, self-documenting CLI** — Designed for both AI agents and humans
254
- - **Transparent internal format** — Markdown/YAML files that are debuggable and friendly
253
+ - **Simple, self-documenting CLI**—Designed for both AI agents and humans
254
+ - **Transparent internal format**—Markdown/YAML files that are debuggable and friendly
255
255
  to other tooling
256
256
 
257
257
  It does *not* aim to be a full solution for real-time agent coordination.
@@ -291,17 +291,17 @@ layered on top of tbd or handled by other tools.
291
291
 
292
292
  **Related Projects:**
293
293
 
294
- - [Beads](https://github.com/steveyegge/beads) The original git-backed issue tracker
295
- tbd is designed to replace
296
- - [Agent Mail](https://github.com/Dicklesworthstone/mcp_agent_mail) Real-time agent
294
+ - [Beads](https://github.com/steveyegge/beads)—The original git-backed issue tracker tbd
295
+ is designed to replace
296
+ - [Agent Mail](https://github.com/Dicklesworthstone/mcp_agent_mail)—Real-time agent
297
297
  messaging via MCP (complementary to tbd for coordination)
298
- - [Gas Town](https://github.com/steveyegge/gastown) Multi-agent orchestration platform
298
+ - [Gas Town](https://github.com/steveyegge/gastown)—Multi-agent orchestration platform
299
299
  (complementary to tbd for real-time coordination)
300
- - [ticket](https://github.com/wedow/ticket) Bash-based Markdown+YAML tracker (~1900
300
+ - [ticket](https://github.com/wedow/ticket)—Bash-based Markdown+YAML tracker (~1900
301
301
  tickets in production)
302
- - [git-bug](https://github.com/git-bug/git-bug) Issues stored as git objects
303
- - [git-issue](https://github.com/dspinellis/git-issue) Shell-based with optional
304
- GitHub sync
302
+ - [git-bug](https://github.com/git-bug/git-bug)—Issues stored as git objects
303
+ - [git-issue](https://github.com/dspinellis/git-issue)—Shell-based with optional GitHub
304
+ sync
305
305
 
306
306
  ### 1.2 When to Use tbd vs Beads
307
307
 
@@ -790,10 +790,10 @@ $GIT_COMMON_DIR/tbd/
790
790
  └── meta.yml # Metadata (schema version)
791
791
  ```
792
792
 
793
- > **Future: Simple Mode** — For users who don’t need multi-machine sync, tbd could
794
- > support a “simple mode” where `data-sync/` is committed directly to main instead of
795
- > using a worktree. This would be enabled by removing `data-sync` from `.tbd/.gitignore`.
796
- > Not implemented in V1, but the naming structure supports this future option.
793
+ > **Future: Simple Mode**—For users who don’t need multi-machine sync, tbd could support
794
+ > a “simple mode” where `data-sync/` is committed directly to main instead of using a
795
+ > worktree. This would be enabled by removing `data-sync` from `.tbd/.gitignore`. Not
796
+ > implemented in V1, but the naming structure supports this future option.
797
797
 
798
798
  **Why this structure?**
799
799
 
@@ -887,7 +887,7 @@ backups/
887
887
  > Both differ from `.tbd/data-sync/attic/` on the sync branch which stores merge
888
888
  > conflict losers.
889
889
  >
890
- > **Note:** `workspaces/` must not be gitignored it stores outbox data that must be
890
+ > **Note:** `workspaces/` must not be gitignored—it stores outbox data that must be
891
891
  > committed to the working branch.
892
892
 
893
893
  #### .tbd/.gitattributes Contents
@@ -904,7 +904,7 @@ that directory.
904
904
  ```
905
905
 
906
906
  > **Why this is needed:** When a feature branch with outbox changes is merged back to
907
- > main (which has no outbox), git’s 3-way merge can delete `ids.yml` entirely treating
907
+ > main (which has no outbox), git’s 3-way merge can delete `ids.yml` entirely—treating
908
908
  > “no file” on main as the correct state.
909
909
  > This causes all tbd commands to crash with “No short ID mapping found”.
910
910
  > The `merge=union` built-in merge driver keeps all lines from both sides, preventing
@@ -1037,8 +1037,8 @@ async function checkWorktreeHealth(baseDir: string): Promise<{
1037
1037
 
1038
1038
  | Term | Path | Purpose |
1039
1039
  | --- | --- | --- |
1040
- | **Worktree path** | `$GIT_COMMON_DIR/tbd/data-sync-worktree/.tbd/data-sync/` | **Production path** — inside hidden worktree checkout |
1041
- | **Direct path** | `.tbd/data-sync/` | **Legacy fallback path** — gitignored on main, should NEVER contain data in production |
1040
+ | **Worktree path** | `$GIT_COMMON_DIR/tbd/data-sync-worktree/.tbd/data-sync/` | **Production path**—inside hidden worktree checkout |
1041
+ | **Direct path** | `.tbd/data-sync/` | **Legacy fallback path**—gitignored on main, should NEVER contain data in production |
1042
1042
 
1043
1043
  **Invariant:** In production, the worktree path is the ONLY correct path for issue data.
1044
1044
  The direct path exists ONLY for test fixtures that don’t use git.
@@ -1082,7 +1082,7 @@ async function resolveDataSyncDir(
1082
1082
 
1083
1083
  1. Production code MUST call `resolveDataSyncDir()` without `allowFallback`
1084
1084
  2. Only test code may use `allowFallback: true`
1085
- 3. If `.tbd/data-sync/issues/` contains data on main branch, this indicates a bug data
1085
+ 3. If `.tbd/data-sync/issues/` contains data on main branch, this indicates a bug—data
1086
1086
  was written to wrong location due to missing worktree
1087
1087
 
1088
1088
  #### Worktree Error Classes
@@ -1114,7 +1114,7 @@ export class SyncBranchError extends TbdError {
1114
1114
  Workspaces are directories under `.tbd/workspaces/` that store issue data for sync
1115
1115
  failure recovery, backups, and bulk editing workflows.
1116
1116
 
1117
- > **Note:** `.tbd/workspaces/` must not be gitignored outbox data must be committed to
1117
+ > **Note:** `.tbd/workspaces/` must not be gitignored—outbox data must be committed to
1118
1118
  > the working branch.
1119
1119
 
1120
1120
  #### Workspace Structure
@@ -2147,7 +2147,7 @@ SYNC(options):
2147
2147
  ```
2148
2148
 
2149
2149
  **Critical Invariant:** All operations in steps 1-6 MUST use the resolved `dataSyncDir`
2150
- path consistently. Never read from or write to `.tbd/data-sync/` directly always go
2150
+ path consistently. Never read from or write to `.tbd/data-sync/` directly—always go
2151
2151
  through the shared worktree at `$GIT_COMMON_DIR/tbd/data-sync-worktree/.tbd/data-sync/`.
2152
2152
 
2153
2153
  **Why most syncs are trivial (no merge needed):**
@@ -2374,8 +2374,8 @@ The CLI Layer provides a Beads-compatible command interface.
2374
2374
 
2375
2375
  All tbd commands require the repository to be initialized, except:
2376
2376
 
2377
- - `tbd init` — Creates a new tbd repository
2378
- - `tbd import --from-beads` — Can initialize and import in one step (auto-runs init if
2377
+ - `tbd init`—Creates a new tbd repository
2378
+ - `tbd import --from-beads`—Can initialize and import in one step (auto-runs init if
2379
2379
  needed)
2380
2380
 
2381
2381
  **Behavior when not initialized:**
@@ -2572,8 +2572,8 @@ Options:
2572
2572
  created/updated: newest first).
2573
2573
  The tiebreaker for issues with equal primary values is the internal ULID, which sorts
2574
2574
  lexicographically in chronological creation order.
2575
- This ensures deterministic, stable ordering issues created earlier always appear
2576
- before issues created later within the same priority level.
2575
+ This ensures deterministic, stable ordering—issues created earlier always appear before
2576
+ issues created later within the same priority level.
2577
2577
 
2578
2578
  **Examples:**
2579
2579
 
@@ -3498,9 +3498,9 @@ This follows the same convention as `git`, `ls`, `grep`, and other Unix tools.
3498
3498
  The actor name (used for `created_by` and recorded in sync commits) is resolved in this
3499
3499
  order:
3500
3500
 
3501
- 1. `--actor <name>` CLI flag (highest priority) — *not yet implemented*
3501
+ 1. `--actor <name>` CLI flag (highest priority)—*not yet implemented*
3502
3502
 
3503
- 2. `TBD_ACTOR` environment variable — *not yet implemented*
3503
+ 2. `TBD_ACTOR` environment variable—*not yet implemented*
3504
3504
 
3505
3505
  3. Git user.email from git config
3506
3506
 
@@ -4571,8 +4571,8 @@ all environments including cloud sandboxes.
4571
4571
 
4572
4572
  Claude Code hooks are always installed to the **project-local** `.claude/` directory,
4573
4573
  adjacent to `.git/` and `.tbd/` at the git repository root.
4574
- There is no global/user-level installation this avoids confusion and ensures hooks
4575
- work in any environment (local dev, Claude Code Cloud, etc.).
4574
+ There is no global/user-level installation—this avoids confusion and ensures hooks work
4575
+ in any environment (local dev, Claude Code Cloud, etc.).
4576
4576
 
4577
4577
  **A. JSON Settings Hooks** (installed to `.claude/settings.json` at project root)
4578
4578
 
@@ -4674,7 +4674,7 @@ Options:
4674
4674
  - `tbd list --status=in_progress` - Your active work
4675
4675
  - `tbd show <id>` - Detailed issue view with dependencies
4676
4676
 
4677
- ### Creating & Updating
4677
+ ### Creating and Updating
4678
4678
  - `tbd create "title" --type=task|bug|feature --priority=P2` - New issue
4679
4679
  - Priority: P0-P4 (P0=critical, P2=medium, P4=backlog)
4680
4680
  - `tbd update <id> --status=in_progress` - Claim work
@@ -4682,12 +4682,12 @@ Options:
4682
4682
  - `tbd close <id>` - Mark complete
4683
4683
  - `tbd close <id> --reason "explanation"` - Close with reason
4684
4684
 
4685
- ### Dependencies & Blocking
4685
+ ### Dependencies and Blocking
4686
4686
  - `tbd dep add <issue> <depends-on>` - Add dependency
4687
4687
  - `tbd blocked` - Show all blocked issues
4688
4688
  - `tbd show <id>` - See what's blocking/blocked by this issue
4689
4689
 
4690
- ### Sync & Collaboration
4690
+ ### Sync and Collaboration
4691
4691
  - `tbd sync` - Sync with git remote (run at session end)
4692
4692
  - `tbd sync --status` - Check sync status without syncing
4693
4693
 
@@ -30,7 +30,7 @@ Why a separate branch?
30
30
  - No conflicts across main or feature branches
31
31
  - Issues shared across all branches
32
32
 
33
- ## File format
33
+ ## File Format
34
34
 
35
35
  You usually don’t need to worry about where issues are stored, but it may be comforting
36
36
  to know that internally it’s very simple and transparent.
@@ -52,7 +52,7 @@ Every session must end with tbd in a clean state:
52
52
  - `tbd show <id>` - Detailed issue view with dependencies
53
53
  - Auto-displays parent context for child issues (use `--no-parent` to suppress)
54
54
 
55
- ### Creating & Updating
55
+ ### Creating and Updating
56
56
 
57
57
  - `tbd create "title" --type task|bug|feature --priority 2` - New issue
58
58
  - Priority: 0-4 (0=critical, 2=medium, 4=backlog).
@@ -63,13 +63,13 @@ Every session must end with tbd in a clean state:
63
63
  - `tbd close <id> --reason "explanation"` - Close with reason
64
64
  - **Tip**: When creating multiple issues, use parallel subagents for efficiency
65
65
 
66
- ### Dependencies & Blocking
66
+ ### Dependencies and Blocking
67
67
 
68
68
  - `tbd dep add <issue> <depends-on>` - Add dependency (issue depends on depends-on)
69
69
  - `tbd blocked` - Show all blocked issues
70
70
  - `tbd show <id>` - See what’s blocking/blocked by this issue
71
71
 
72
- ### Sync & Collaboration
72
+ ### Sync and Collaboration
73
73
 
74
74
  - `tbd sync` - Sync with git remote (run at session end)
75
75
  - `tbd sync --status` - Check sync status without syncing
@@ -1,10 +1,10 @@
1
1
  import { b as IdMappingYamlSchema } from "./schemas-f0EcuAVu.mjs";
2
2
  import { i as parseYamlToleratingDuplicateKeys, r as hasMergeConflictMarkers, s as stringifyYaml } from "./yaml-utils-BPy991by.mjs";
3
- import { mkdir, readFile, rmdir, stat } from "node:fs/promises";
3
+ import { mkdir, readFile, rename, rmdir, stat } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { writeFile } from "atomically";
6
+ import { randomBytes, randomUUID } from "node:crypto";
6
7
  import { monotonicFactory } from "ulid";
7
- import { randomBytes } from "node:crypto";
8
8
 
9
9
  //#region src/utils/lockfile.ts
10
10
  /**
@@ -36,10 +36,15 @@ import { randomBytes } from "node:crypto";
36
36
  *
37
37
  * 1. **Acquire**: `mkdir(lockDir)` — fails with EEXIST if held by another process
38
38
  * 2. **Hold**: Execute the critical section
39
- * 3. **Release**: `rmdir(lockDir)` — in a finally block
39
+ * 3. **Release**: `rmdir(lockDir)` — in a finally block, with a bounded retry to
40
+ * absorb transient Windows failures (EBUSY/EPERM from AV scanners or lingering
41
+ * handles) that would otherwise orphan the lock directory.
40
42
  * 4. **Stale detection**: If lock mtime exceeds a threshold, assume the holder
41
- * crashed and break the lock. This is a heuristic safe when the critical
42
- * section is short-lived (sub-second for file I/O).
43
+ * crashed and break the lock. Breaking is done **atomically** by renaming the
44
+ * stale directory aside (only one waiter can win the rename), so two waiters can
45
+ * never both break the same lock and end up running concurrently. This is a
46
+ * heuristic — safe when the critical section is short-lived (sub-second for
47
+ * file I/O).
43
48
  *
44
49
  * ## Failure on timeout
45
50
  *
@@ -87,6 +92,53 @@ var LockAcquisitionError = class extends Error {
87
92
  this.name = "LockAcquisitionError";
88
93
  }
89
94
  };
95
+ /** Filesystem error codes that are transient on Windows and worth retrying. */
96
+ const TRANSIENT_RMDIR_CODES = new Set([
97
+ "EBUSY",
98
+ "EPERM",
99
+ "EACCES",
100
+ "ENOTEMPTY"
101
+ ]);
102
+ /**
103
+ * Remove a lock directory, tolerating transient Windows failures.
104
+ *
105
+ * `rmdir` can intermittently fail with EBUSY/EPERM on Windows (antivirus scanners
106
+ * or lingering directory handles). A few short retries make release reliable; if it
107
+ * still fails, we give up and let stale detection reclaim the directory rather than
108
+ * throwing from a best-effort cleanup path.
109
+ */
110
+ async function removeLockDir(lockPath, attempts = 5) {
111
+ for (let attempt = 0; attempt < attempts; attempt++) try {
112
+ await rmdir(lockPath);
113
+ return;
114
+ } catch (error) {
115
+ const code = error.code;
116
+ if (code === "ENOENT") return;
117
+ if (attempt < attempts - 1 && code && TRANSIENT_RMDIR_CODES.has(code)) {
118
+ await new Promise((resolve) => setTimeout(resolve, 20 * (attempt + 1)));
119
+ continue;
120
+ }
121
+ return;
122
+ }
123
+ }
124
+ /**
125
+ * Atomically break a stale lock.
126
+ *
127
+ * Renames the stale directory to a unique sidecar path and removes it. `rename` is
128
+ * atomic, so when several waiters race to break the same stale lock only one wins the
129
+ * rename; the losers see ENOENT and simply retry. This prevents the classic
130
+ * non-atomic break race (rmdir + mkdir) where two waiters both break the lock and both
131
+ * acquire it, defeating mutual exclusion.
132
+ */
133
+ async function breakStaleLock(lockPath) {
134
+ const sidecar = `${lockPath}.stale-${randomUUID()}`;
135
+ try {
136
+ await rename(lockPath, sidecar);
137
+ } catch {
138
+ return;
139
+ }
140
+ await removeLockDir(sidecar);
141
+ }
90
142
  /**
91
143
  * Execute `fn` while holding a lockfile.
92
144
  *
@@ -125,26 +177,24 @@ async function withLockfile(lockPath, fn, options) {
125
177
  break;
126
178
  } catch (error) {
127
179
  if (error.code !== "EEXIST") throw error;
180
+ let lockStat;
128
181
  try {
129
- const lockStat = await stat(lockPath);
130
- if (Date.now() - lockStat.mtimeMs > staleMs) {
131
- try {
132
- await rmdir(lockPath);
133
- } catch {}
134
- continue;
135
- }
182
+ lockStat = await stat(lockPath);
136
183
  } catch {
137
184
  continue;
138
185
  }
186
+ if (!lockStat.isDirectory()) throw new Error(`Lock path exists but is not a directory: ${lockPath}. Refusing to break it; remove the conflicting file and retry.`);
187
+ if (Date.now() - lockStat.mtimeMs > staleMs) {
188
+ await breakStaleLock(lockPath);
189
+ continue;
190
+ }
139
191
  await new Promise((resolve) => setTimeout(resolve, pollMs));
140
192
  }
141
193
  if (!acquired) throw new LockAcquisitionError(lockPath, timeoutMs);
142
194
  try {
143
195
  return await fn();
144
196
  } finally {
145
- try {
146
- await rmdir(lockPath);
147
- } catch {}
197
+ await removeLockDir(lockPath);
148
198
  }
149
199
  }
150
200
 
@@ -723,4 +773,4 @@ function resolveIdMappingConflicts(content) {
723
773
 
724
774
  //#endregion
725
775
  export { withLockfile as C, DATA_SYNC_LOCK_OPTIONS as S, formatDisplayId as _, hasShortId as a, normalizeIssueId as b, parseIdMappingFromYaml as c, resolveToInternalId as d, saveIdMapping as f, formatDebugId as g, extractUlidFromInternalId as h, generateUniqueShortId as i, reconcileMappings as l, extractShortId as m, calculateOptimalLength as n, loadIdMapping as o, extractPrefix as p, createShortIdMapping as r, mergeIdMappings as s, addIdMapping as t, resolveIdMappingConflicts as u, generateInternalId as v, validateIssueId as x, makeInternalId as y };
726
- //# sourceMappingURL=id-mapping-CtfTfGIh.mjs.map
776
+ //# sourceMappingURL=id-mapping-687_UEsy.mjs.map