get-tbd 0.2.3 → 0.3.0

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 (83) hide show
  1. package/README.md +38 -6
  2. package/dist/bin.mjs +3494 -949
  3. package/dist/bin.mjs.map +1 -1
  4. package/dist/cli.mjs +1827 -1312
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/{config-1ouUTKQr.mjs → config-B1w3pAkY.mjs} +142 -290
  7. package/dist/config-B1w3pAkY.mjs.map +1 -0
  8. package/dist/config-DXhifxOw.mjs +3 -0
  9. package/dist/doc-cache-CamtXfi4.mjs +1035 -0
  10. package/dist/doc-cache-CamtXfi4.mjs.map +1 -0
  11. package/dist/doc-cache-CiBwpDTf.mjs +3 -0
  12. package/dist/doc-fork-BMjqzfAs.mjs +3 -0
  13. package/dist/doc-fork-CoPi1G1N.mjs +304 -0
  14. package/dist/doc-fork-CoPi1G1N.mjs.map +1 -0
  15. package/dist/docref-C7g0sjvL.mjs +167 -0
  16. package/dist/docref-C7g0sjvL.mjs.map +1 -0
  17. package/dist/docs/README.md +38 -6
  18. package/dist/docs/SKILL.md +13 -4
  19. package/dist/docs/guidelines/backward-compatibility-rules.md +1 -0
  20. package/dist/docs/guidelines/bun-monorepo-patterns.md +1 -0
  21. package/dist/docs/guidelines/cli-agent-skill-patterns.md +124 -38
  22. package/dist/docs/guidelines/commit-conventions.md +1 -0
  23. package/dist/docs/guidelines/common-doc-guidelines.md +1 -0
  24. package/dist/docs/guidelines/convex-limits-best-practices.md +1 -0
  25. package/dist/docs/guidelines/convex-rules.md +1 -0
  26. package/dist/docs/guidelines/electron-app-development-patterns.md +1 -0
  27. package/dist/docs/guidelines/error-handling-rules.md +1 -0
  28. package/dist/docs/guidelines/general-coding-rules.md +1 -0
  29. package/dist/docs/guidelines/general-comment-rules.md +1 -0
  30. package/dist/docs/guidelines/general-eng-agent-principles.md +1 -0
  31. package/dist/docs/guidelines/general-tdd-guidelines.md +1 -0
  32. package/dist/docs/guidelines/general-testing-rules.md +1 -0
  33. package/dist/docs/guidelines/golden-testing-guidelines.md +1 -0
  34. package/dist/docs/guidelines/pnpm-monorepo-patterns.md +1 -0
  35. package/dist/docs/guidelines/python-cli-patterns.md +1 -0
  36. package/dist/docs/guidelines/python-modern-guidelines.md +1 -0
  37. package/dist/docs/guidelines/python-rules.md +1 -0
  38. package/dist/docs/guidelines/release-notes-guidelines.md +1 -0
  39. package/dist/docs/guidelines/supply-chain-hardening.md +3 -2
  40. package/dist/docs/guidelines/tbd-sync-troubleshooting.md +1 -0
  41. package/dist/docs/guidelines/typescript-cli-tool-rules.md +1 -0
  42. package/dist/docs/guidelines/typescript-code-coverage.md +1 -0
  43. package/dist/docs/guidelines/typescript-rules.md +1 -0
  44. package/dist/docs/guidelines/typescript-sorting-patterns.md +1 -0
  45. package/dist/docs/guidelines/typescript-yaml-handling-rules.md +1 -0
  46. package/dist/docs/references/docmap-format.md +64 -0
  47. package/dist/docs/references/docref-format.md +71 -0
  48. package/dist/docs/shortcuts/standard/checkout-third-party-repo.md +17 -4
  49. package/dist/docs/shortcuts/standard/new-shortcut.md +5 -5
  50. package/dist/docs/shortcuts/standard/plan-implementation-with-beads.md +1 -1
  51. package/dist/docs/shortcuts/standard/suggest-upstream-improvements.md +69 -0
  52. package/dist/docs/shortcuts/standard/sync-failure-recovery.md +1 -1
  53. package/dist/docs/shortcuts/standard/welcome-user.md +28 -0
  54. package/dist/docs/shortcuts/system/skill-baseline.md +13 -4
  55. package/dist/docs/tbd-design.md +141 -0
  56. package/dist/docs/tbd-docs.md +169 -5
  57. package/dist/docs/tbd-prime.md +0 -1
  58. package/dist/docs/templates/qa-playbook.md +3 -1
  59. package/dist/docs/templates/research-brief.md +2 -2
  60. package/dist/fork-manifest-ByU7U2do.mjs +253 -0
  61. package/dist/fork-manifest-ByU7U2do.mjs.map +1 -0
  62. package/dist/fork-manifest-C7lGRq-6.mjs +3 -0
  63. package/dist/{id-mapping-mtoSP9Qt.mjs → id-mapping-D0iitY-F.mjs} +1 -1
  64. package/dist/{id-mapping-687_UEsy.mjs → id-mapping-DAIeLKzm.mjs} +8 -200
  65. package/dist/id-mapping-DAIeLKzm.mjs.map +1 -0
  66. package/dist/index.d.mts +90 -13
  67. package/dist/index.mjs +3 -3
  68. package/dist/lockfile-BR0laSDy.mjs +198 -0
  69. package/dist/lockfile-BR0laSDy.mjs.map +1 -0
  70. package/dist/paths-C1DpnZJW.mjs +405 -0
  71. package/dist/paths-C1DpnZJW.mjs.map +1 -0
  72. package/dist/{schemas-f0EcuAVu.mjs → schemas-lCwRk30L.mjs} +19 -6
  73. package/dist/schemas-lCwRk30L.mjs.map +1 -0
  74. package/dist/{src-DTyyuaG_.mjs → src-CxKOynr1.mjs} +3 -3
  75. package/dist/src-CxKOynr1.mjs.map +1 -0
  76. package/dist/tbd +3494 -949
  77. package/dist/yaml-utils-BPy991by.mjs.map +1 -1
  78. package/package.json +1 -1
  79. package/dist/config-1ouUTKQr.mjs.map +0 -1
  80. package/dist/config-YRRW9l89.mjs +0 -3
  81. package/dist/id-mapping-687_UEsy.mjs.map +0 -1
  82. package/dist/schemas-f0EcuAVu.mjs.map +0 -1
  83. package/dist/src-DTyyuaG_.mjs.map +0 -1
@@ -0,0 +1,71 @@
1
+ ---
2
+ title: Docref Format
3
+ description: A single-string, URI-like address for any document, the one source-address grammar used across tbd
4
+ author: Joshua Levy (github.com/jlevy) with LLM assistance
5
+ category: general
6
+ ---
7
+ # Docref Format (v0.1)
8
+
9
+ A **docref** is a single-string, URI-like address for a document.
10
+ It is the one address syntax used everywhere tbd names where a doc comes from or lives:
11
+ `docs_cache.files` values, the fork manifest’s `source` field, and future `tbd docs add`
12
+ arguments. The grammar is tool-agnostic: any application can adopt it, and the reference
13
+ implementation (`src/docref/` in tbd) is standalone and dependency-free.
14
+
15
+ ## Forms
16
+
17
+ | Form | Example | Meaning |
18
+ | --- | --- | --- |
19
+ | internal | `internal:guidelines/python-rules.md` | A doc bundled inside the consuming tool. App-relative: each tool resolves it against its own bundled collection. |
20
+ | local | `./docs/general/`, `../shared/rules.md`, `/abs/f.md`, `C:/docs/f.md` | A filesystem path. Must be **anchored**: `./`, `../`, `/`, or a Windows drive letter. |
21
+ | url | `https://example.com/style.md` | A plain URL, kept verbatim. |
22
+ | git | `github:owner/repo@ref//path/to/file.md` | A file in a git host’s repo. `gitlab:` likewise. `@ref` is optional; `//` separates repo from path. |
23
+ | git + fragment | `github:o/r@main//f.md#naming` | Optional in-document anchor, preserved verbatim. |
24
+
25
+ The `//` separator makes refs with slashes unambiguous:
26
+ `github:o/r@feature/x//docs/f.md` pins ref `feature/x`. Unlike GitHub blob URLs, where
27
+ ref and path cannot be split reliably.
28
+
29
+ ## Strictness
30
+
31
+ The grammar is deliberately strict; consumers may be lenient at their own boundary:
32
+
33
+ - **Bare relative strings are not docrefs** (`guidelines/x.md` is invalid).
34
+ A consumer that wants to accept them may prepend `./` before parsing.
35
+ A strict grammar plus lenient consumers composes; the reverse can never be tightened.
36
+ - **Home-relative paths (`~/…`) are rejected** in v0.1 (no portable expansion
37
+ semantics).
38
+ - **Unknown schemes are rejected** (`mailto:…`, `git:…`). Additional protocols, for
39
+ example a host-bearing git scheme for forges beyond GitHub/GitLab, may be added in
40
+ future versions.
41
+
42
+ ## Normalization
43
+
44
+ Web URLs that point at a known git host’s file view normalize to the canonical scheme,
45
+ so one file has one address:
46
+
47
+ - `https://github.com/o/r/blob/main/f.md` → `github:o/r@main//f.md`
48
+ - `https://raw.githubusercontent.com/o/r/main/f.md` → `github:o/r@main//f.md`
49
+ - `https://gitlab.com/o/r/-/blob/main/f.md` → `gitlab:o/r@main//f.md`
50
+
51
+ URL fragments are preserved through normalization; a normalizer must never silently drop
52
+ data.
53
+
54
+ ## Equality
55
+
56
+ Two docrefs are equal when their canonical forms are identical, except that local paths
57
+ compare with a single leading `./` ignored.
58
+ Equality is purely syntactic: hosts and owners are not case-normalized, and no network
59
+ or filesystem is consulted.
60
+
61
+ ## Prior Art
62
+
63
+ [purl](https://github.com/package-url/purl-spec) addresses *packages*
64
+ (`pkg:type/namespace/name@version`); its identity is the package, with file paths as an
65
+ awkward suffix. docref’s identity is the *document*, with in-repo paths and anchored
66
+ local files as first-class forms, which is why a separate small grammar exists rather
67
+ than a purl profile.
68
+
69
+ <!-- This document follows common-doc-guidelines.md.
70
+ See github.com/jlevy/practical-prose and review guidelines before editing.
71
+ -->
@@ -28,12 +28,24 @@ need.
28
28
  3. **Identify the version in use**: Check `package.json`, `requirements.txt`,
29
29
  `Cargo.toml`, etc. for the exact version of the dependency you’re investigating.
30
30
 
31
- 4. **Clone the repo**:
31
+ 4. **Reuse an existing checkout**: If `attic/<repo-name>` already exists—common when a
32
+ repo is consulted across sessions—use it instead of re-cloning.
33
+ Confirm it is clean; attic clones are read-only, so it should be, and if it is dirty,
34
+ stop and flag it rather than discarding changes.
35
+ Then update to the version you need and skip the clone step below.
36
+ ```bash
37
+ git -C attic/<repo-name> status # Should be clean; if dirty, stop and flag
38
+ git -C attic/<repo-name> pull # Update the clone...
39
+ # ...or, if it is pinned to a tag (detached HEAD, where plain pull fails):
40
+ git -C attic/<repo-name> fetch --tags && git -C attic/<repo-name> checkout <tag>
41
+ ```
42
+
43
+ 5. **Clone the repo** (if not already in `attic/`):
32
44
  ```bash
33
45
  git clone <repo-url> attic/<repo-name>
34
46
  ```
35
47
 
36
- 5. **Checkout the matching version**: Find the tag or branch matching your project’s
48
+ 6. **Checkout the matching version**: Find the tag or branch matching your project’s
37
49
  version:
38
50
  ```bash
39
51
  cd attic/<repo-name>
@@ -41,13 +53,14 @@ need.
41
53
  git checkout <tag-or-branch>
42
54
  ```
43
55
 
44
- 6. **Explore**: Now use standard tools (Grep, Read, Glob) to investigate the source.
56
+ 7. **Explore**: Now use standard tools (Grep, Read, Glob) to investigate the source.
45
57
 
46
58
  ## Notes
47
59
 
48
60
  - The `attic/` directory is gitignored—cloned repos won’t pollute your project
49
61
  - You can clone multiple repos into attic/ as needed
50
- - Delete cloned repos when done to save disk space
62
+ - Delete cloned repos to save disk space when you no longer need them—but keep a clone
63
+ if you expect to consult the same repo again (reuse it via the step above)
51
64
 
52
65
  <!-- This document follows common-doc-guidelines.md.
53
66
  See github.com/jlevy/practical-prose and review guidelines before editing.
@@ -56,13 +56,13 @@ Examples: `code-review-and-commit`, `new-plan-spec`, `review-code-typescript`
56
56
  ## Referencing Other Shortcuts
57
57
 
58
58
  Refer to other shortcuts, guidelines, and templates by **name**, using the command that
59
- surfaces them never by file path:
59
+ surfaces them, never by file path:
60
60
 
61
61
  - Another shortcut: `tbd shortcut <name>` (e.g. `tbd shortcut precommit-process`)
62
62
  - A guideline: `tbd guidelines <name>` (e.g. `tbd guidelines typescript-rules`)
63
63
  - A template: `tbd template <name>` (e.g. `tbd template plan-spec`)
64
64
 
65
- The name stays valid wherever the file ends up read directly, served via
65
+ The name stays valid wherever the file ends up: read directly, served via
66
66
  `tbd shortcut`, or embedded in another tool.
67
67
  File paths and relative markdown links break when shortcuts are flattened into the
68
68
  `.tbd` cache or relocated, so don’t use them to point at other shortcuts.
@@ -80,10 +80,10 @@ For official shortcuts: `pnpm build` in packages/tbd/
80
80
 
81
81
  For official shortcuts added to `packages/tbd/docs/shortcuts/standard/`:
82
82
 
83
- 1. **Update root README.md** Add to the “Available shortcuts” table (grouped by
83
+ 1. **Update root README.md:** Add to the “Available shortcuts” table (grouped by
84
84
  category: Planning, Documentation, Review, Git, Cleanup, Session, Meta)
85
- 2. **Sync docs cache** Run `tbd setup --auto` to update `.tbd/docs/`
86
- 3. **Rebuild** `pnpm build` in packages/tbd/ (also copies README to package)
85
+ 2. **Sync docs cache:** Run `tbd setup --auto` to update `.tbd/docs/`
86
+ 3. **Rebuild:** `pnpm build` in packages/tbd/ (also copies README to package)
87
87
 
88
88
  ## Shortcuts vs Guidelines
89
89
 
@@ -48,7 +48,7 @@ If unclear, ask the user if they want you to create a spec first using
48
48
 
49
49
  - **Parent/Child** (`--parent`): Hierarchical grouping.
50
50
  All implementation beads should be children of the epic.
51
- Children inherit context from their parent `tbd show` auto-displays the parent’s
51
+ Children inherit context from their parent; `tbd show` auto-displays the parent’s
52
52
  details, so child descriptions don’t need to duplicate the parent’s context.
53
53
 
54
54
  - **Blocker** (`tbd dep add`): Sequential ordering.
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: Suggest Upstream Improvements
3
+ description: Review local doc-fork customizations and contribute the generally useful changes back upstream
4
+ category: meta
5
+ author: Joshua Levy (github.com/jlevy) with LLM assistance
6
+ ---
7
+ This shortcut reviews the docs this project has forked and customized (in `docs/tbd/`),
8
+ decides which changes generalize beyond this project, and proposes them upstream, to the
9
+ tbd repo for tbd’s bundled docs, or to your org’s docs repo for docs added by URL.
10
+
11
+ ## When to Use
12
+
13
+ - Forked guidelines or shortcuts have accumulated edits that would help other projects.
14
+ - Before unforking: upstream the good parts first, so nothing is lost when the fork goes
15
+ away.
16
+ - After `tbd docs update` keeps producing the same conflict because upstream lacks an
17
+ improvement you made locally.
18
+
19
+ ## Instructions
20
+
21
+ Create a to-do list with the following items then perform all of them:
22
+
23
+ 1. **Collect customizations**: Run `tbd docs status --json` and collect every doc in
24
+ `customized` state (including customized docs that also have upstream updates
25
+ pending).
26
+
27
+ 2. **Review each diff**: For each doc, run `tbd docs diff <name> --base` (your file vs
28
+ its recorded base, exactly what this project changed).
29
+ Classify each hunk:
30
+ - **Generally applicable**: fixes, clarifications, better examples, rules any project
31
+ would benefit from. Candidates for upstreaming.
32
+ - **Project-specific**: team conventions, internal links, stack-specific overrides.
33
+ These stay in the fork; do not propose them.
34
+
35
+ 3. **Identify the upstream target** for each doc with generalizable hunks:
36
+ - Bundled docs (manifest `source` starts with `internal:`): the tbd repo
37
+ (`jlevy/tbd`), where doc sources live under `packages/tbd/docs/`.
38
+ - URL-added docs: the repo their docref points at (for example, your org’s shared
39
+ docs repo).
40
+
41
+ 4. **Draft the proposal**: For each doc, draft an issue or PR body containing:
42
+ - Which doc (name and kind) and why the change is generally useful.
43
+ - Only the generalizable diff hunks, in fenced code blocks.
44
+ - Brief project context: what prompted the change here.
45
+
46
+ 5. **Confirm, then file**: Show the draft to the user and get confirmation.
47
+ Then:
48
+ - Issue: `gh issue create -R jlevy/tbd` (or the org’s repo) with the drafted body.
49
+ - PR (preferred when the change is small and ready): apply the generalizable hunks to
50
+ the upstream source file on a branch and open a PR with `gh pr create`.
51
+
52
+ 6. **Close the loop (after upstream merges)**: Once the change ships upstream and tbd is
53
+ upgraded, run `tbd docs update`. If upstream adopted the customization, the merge
54
+ converges and the doc returns to unmodified `forked` state, then a plain
55
+ `tbd docs unfork <name>` (no `--force` needed) completes the cleanup, or keep the
56
+ fork for future edits.
57
+
58
+ ## Notes
59
+
60
+ - Only propose hunks you would accept as a maintainer: each should stand alone, with
61
+ rationale.
62
+ - Never file an issue or PR without showing the user the draft first.
63
+ - Diff views: `tbd docs diff <name>` (no flag) compares your copy against current
64
+ upstream; `--base` is the right view for “what did we change”; `--upstream` shows
65
+ incoming upstream changes.
66
+
67
+ <!-- This document follows common-doc-guidelines.md.
68
+ See github.com/jlevy/practical-prose and review guidelines before editing.
69
+ -->
@@ -31,7 +31,7 @@ git commit -m "tbd: save outbox"
31
31
  git push
32
32
  ```
33
33
 
34
- **Note:** Do not gitignore `.tbd/workspaces/` it must be committed to your working
34
+ **Note:** Do not gitignore `.tbd/workspaces/`; it must be committed to your working
35
35
  branch.
36
36
 
37
37
  ## Later, When Sync Works
@@ -13,6 +13,33 @@ project.
13
13
  First, run `tbd status` to check the current state.
14
14
  Give a brief summary of the status (repository, sync status, integrations).
15
15
 
16
+ Then make the two-axis guidelines offer, one short question per axis:
17
+
18
+ 1. **Scope:** keep **all** standard guidelines active (recommended), or just a subset
19
+ for this project’s languages and stack?
20
+ Give a few examples of what the standard set covers, such as Python guidelines,
21
+ TypeScript guidelines, documentation guidelines, testing guidelines, and commit
22
+ conventions. Note that `tbd guidelines --list` shows the full set.
23
+ 2. **Visibility:** leave them in tbd’s hidden cache (the default, which just works), or
24
+ fork them into `docs/tbd/` so they are visible on GitHub, reviewable in PRs, and
25
+ editable (checked into git)?
26
+
27
+ When explaining visibility, give this guidance: for small repos or quick work, you
28
+ usually don’t want to fork.
29
+ Leaving the docs in tbd’s hidden cache is the simplest start and just works.
30
+ For larger projects with a lot of customization, forking can make sense: it gives you
31
+ maximum control to adapt, improve, and customize every guideline.
32
+ Either way the choice is reversible: you can tell tbd you want to fork the docs later,
33
+ so starting with the hidden cache loses nothing.
34
+
35
+ Explain that forking changes nothing about how guidelines work.
36
+ Both paths serve the same guidelines; forking only makes them visible and customizable.
37
+ If the user wants visible docs, the recommendation is to fork the general guidelines
38
+ plus the categories for the project’s languages and frameworks:
39
+ `tbd docs fork --category=general --category=<language>` (e.g. `--category=typescript`).
40
+ Use `tbd docs fork --all` for everything, or `tbd docs fork <name> [<name>...]` to fork
41
+ individual docs by name (preview with `--dry-run` first).
42
+
16
43
  Then show the welcome message:
17
44
 
18
45
  * * *
@@ -50,6 +77,7 @@ Here are examples of things you can say and what happens:
50
77
  | “I’m building a TypeScript CLI” | Applies TypeScript CLI guidelines |
51
78
  | “Help me set up better testing” | Applies testing guidelines |
52
79
  | “What are the Python best practices?” | Applies Python guidelines |
80
+ | “Make the guidelines visible in my repo” | Forks them into `docs/tbd/` (`tbd docs fork --category=general --category=<lang>`, or `tbd docs fork --all`) |
53
81
 
54
82
  **Tips:**
55
83
 
@@ -17,12 +17,15 @@ description: Full tbd workflow guide for agents
17
17
  ## Installation
18
18
 
19
19
  ```bash
20
- npm install -g get-tbd@latest
20
+ npm install -g get-tbd@latest # Install or upgrade the CLI (same command for both)
21
21
  tbd setup --auto --prefix=<name> # Fresh project (--prefix is REQUIRED: 2-8 alphabetic chars recommended. ALWAYS ASK THE USER FOR THE PREFIX; do not guess it)
22
- tbd setup --auto # Existing tbd project (prefix already set)
22
+ tbd setup --auto # Existing tbd project — also the upgrade step (applies any format migration; commit the diff it reports)
23
23
  tbd setup --from-beads # Migration from .beads/ if `bd` has been used
24
24
  ```
25
25
 
26
+ If tbd refuses with “This repository requires a newer version of tbd”, run the two
27
+ install/upgrade commands above.
28
+
26
29
  ## Routine Commands
27
30
 
28
31
  ```bash
@@ -34,7 +37,7 @@ tbd setup --auto # Run any time to refresh setup
34
37
  tbd prime # Restore full context on tbd after compaction
35
38
  ```
36
39
 
37
- ## CRITICAL: You Operate tbd The User Doesn’t
40
+ ## CRITICAL: You Operate tbd, the User Doesn’t
38
41
 
39
42
  **You are the tbd operator:** Users talk naturally; you translate their requests to tbd
40
43
  actions. DO NOT tell users to run tbd commands.
@@ -82,6 +85,10 @@ or want help → run `tbd shortcut welcome-user`
82
85
  | **Documentation** | |
83
86
  | “Research this topic” | `tbd shortcut new-research-brief` |
84
87
  | “Document architecture” | `tbd shortcut new-architecture-doc` |
88
+ | “What guidelines/docs are there?” | `tbd docs list` |
89
+ | “Make the guidelines visible / customize doc X” | `tbd docs fork --category=general --category=<lang>` (recommended: general + the repo’s languages), or `tbd docs fork <name>` / `--all`; then edit in `docs/tbd/` |
90
+ | “Update the guidelines to the latest” | `tbd docs update`; on conflicts ask the user, then `--merge` or `--keep-ours` |
91
+ | “I deleted a forked doc file” | `tbd docs status` shows it `missing`; restore with `tbd docs fork <name> --force` or finalize with `tbd docs unfork <name>` |
85
92
  | **Cleanup & Maintenance** | |
86
93
  | “Clean up this code” / “Remove dead code” | `tbd shortcut code-cleanup-all` |
87
94
  | “Fix repository problems” | `tbd doctor --fix` |
@@ -96,7 +103,7 @@ these apply to all code regardless of language.
96
103
  Then load the group for the language or framework in use (TypeScript, Python, Convex,
97
104
  etc.). Run `tbd guidelines --list` to see all available guidelines.
98
105
 
99
- **Note:** Never gitignore `.tbd/workspaces/` the outbox must be committed to your
106
+ **Note:** Never gitignore `.tbd/workspaces/`; the outbox must be committed to your
100
107
  working branch. See `tbd guidelines tbd-sync-troubleshooting` for details.
101
108
 
102
109
  ## CRITICAL: Session Closing Protocol
@@ -171,6 +178,8 @@ working branch. See `tbd guidelines tbd-sync-troubleshooting` for details.
171
178
  | `tbd guidelines <name>` | Load coding guidelines |
172
179
  | `tbd guidelines --list` | List guidelines |
173
180
  | `tbd template <name>` | Output a template |
181
+ | `tbd docs` / `tbd docs list` | Managed-docs overview / cross-kind list with state markers |
182
+ | `tbd docs fork/unfork/update <name>` | Fork docs into `docs/tbd/`, return to upstream, pull upstream updates |
174
183
 
175
184
  ## Quick Reference
176
185
 
@@ -71,6 +71,7 @@ agents.
71
71
  - [2.8.5 Comparison with Beads](#285-comparison-with-beads)
72
72
  - [2.8.6 Future Dependency Types](#286-future-dependency-types)
73
73
  - [2.8.7 Future: Transitive Blocking Option](#287-future-transitive-blocking-option)
74
+ - [2.9 Managed Docs: Copies, Forks, and Synchronization](#29-managed-docs-copies-forks-and-synchronization)
74
75
  - [3. Git Layer](#3-git-layer)
75
76
  - [3.1 Overview](#31-overview)
76
77
  - [3.2 Sync Branch Architecture](#32-sync-branch-architecture)
@@ -119,6 +120,7 @@ agents.
119
120
  - [4.10 Global Options](#410-global-options)
120
121
  - [4.11 Attic Commands](#411-attic-commands)
121
122
  - [4.12 Output Formats](#412-output-formats)
123
+ - [4.13 Docs Commands](#413-docs-commands)
122
124
  - [5. Beads Compatibility](#5-beads-compatibility)
123
125
  - [5.1 Import Strategy](#51-import-strategy)
124
126
  - [5.1.1 Import Command](#511-import-command)
@@ -1968,6 +1970,107 @@ Add transitive blocking as an opt-in feature if users request it after real-worl
1968
1970
 
1969
1971
  * * *
1970
1972
 
1973
+ ### 2.9 Managed Docs: Copies, Forks, and Synchronization
1974
+
1975
+ tbd manages documentation (guidelines, shortcuts, templates) alongside issues.
1976
+ With forkable docs (format f05, `plan-2026-06-11-forkable-docs.md`), a doc can exist as
1977
+ up to **four copies plus a manifest**, each with a distinct owner and lifecycle.
1978
+ This section is the canonical statement of that model and the invariants that make every
1979
+ combination of user actions safe.
1980
+
1981
+ #### The copies
1982
+
1983
+ | Copy | Location | In git? | Written by | Role |
1984
+ | --- | --- | --- | --- | --- |
1985
+ | Bundled | npm package (`dist/docs/`) | n/a (per tbd version) | tbd releases | The upstream for `internal:` docs; immutable per installed version |
1986
+ | Cache | `.tbd/docs/` | gitignored | doc sync only | Complete, pristine, machine-local mirror of all upstream docs (bundled + URL sources); disposable |
1987
+ | Fork | `docs/tbd/<kind>/<name>.md` | tracked | `tbd docs fork/update` + the user/agent | The editable copy that tbd serves; optional, per-doc |
1988
+ | Base | `.tbd/doc-forks/base/<kind>/<name>.md` | tracked | `tbd docs fork/update` | Verbatim upstream snapshot at the fork point; the three-way merge base |
1989
+ | Manifest | `.tbd/doc-forks/forks.yml` | tracked | `tbd docs fork/unfork/update` | Provenance per fork: source docref, `base_hash` (LF-normalized sha256), `tbd_version` at fork point, `conflicted` flag |
1990
+
1991
+ A doc’s identity is **kind + name**; paths follow fixed conventions
1992
+ (`<kind-dir>/<name>.md`, flat; nested folders are not scanned).
1993
+
1994
+ The model follows one principle: **resolve by convention; track only what cannot be
1995
+ derived; publish the inventory as a generated view.** Lookup is a fixed search path over
1996
+ conventional locations; no registry that can drift from disk.
1997
+ The only stored tracking is the fork manifest, which records the one fact that cannot be
1998
+ recomputed from the files: each fork’s upstream source and base snapshot.
1999
+ The docmap that doc commands emit is a generated view of this state, never an input to
2000
+ resolution. (A copy-all-and-gitignore variant of the fork dir was considered and
2001
+ rejected: gitignored mirrors are invisible on GitHub and in PRs, and edits to them
2002
+ diverge silently with no team-visible artifact; `tbd docs fork --all` provides the
2003
+ all-visible posture in tracked form.
2004
+ See the spec’s Alternatives.)
2005
+
2006
+ #### Invariants
2007
+
2008
+ 1. **Serving precedence**: the fork dir is prepended to every kind’s lookup path, so a
2009
+ forked (or hand-authored local) file shadows the cache copy by name.
2010
+ With nothing forked, lookup paths reduce to the cache and behavior is byte-identical
2011
+ to pre-f05.
2012
+ 2. **Cache completeness**: doc sync always installs *all* upstream docs into the cache,
2013
+ including forked ones.
2014
+ The cache copy is the pristine reference: the staleness comparator, the “theirs” side
2015
+ of every update merge, and the fallback after unfork.
2016
+ 3. **The cache is never authored**: only doc sync writes it, nothing else reads from
2017
+ anywhere else for upstream content, and deleting it is always safe (auto-sync
2018
+ regenerates it on the next doc access, including on fresh clones).
2019
+ 4. **Tracked files mutate only via explicit `tbd docs` verbs** (fork/unfork/update).
2020
+ Setup, `tbd sync`, and background auto-sync refresh the cache and *report* drift but
2021
+ never write the fork dir, bases, or manifest.
2022
+ 5. **Tracking is derived, not stored**: every doc state
2023
+ (`upstream/forked/customized/stale/conflicted/local/missing/orphaned`) is a pure
2024
+ function of (manifest entry present?, file hash, base hash, cache hash, conflicted
2025
+ flag, markers present).
2026
+ There is no hidden database, so no sequence of git operations (commit, pull, merge,
2027
+ revert, partial commits) can desynchronize tbd from the files: collaborators
2028
+ recompute identical states from identical content.
2029
+ 6. **The base is the fork point**: advanced only by fork (refresh) and update; with the
2030
+ stored snapshot, `customized` (file ≠ base), `stale` (cache ≠ base), and three-way
2031
+ merging are exact, offline operations for every collaborator regardless of which tbd
2032
+ version created the fork.
2033
+ 7. **The format gate**: forking bumps nothing at runtime, but the f05 `tbd_format` in
2034
+ `config.yml` (mirrored into the machine-local common-dir `layout.yml`) makes pre-f05
2035
+ clients refuse the repo; they would otherwise serve upstream copies of docs the team
2036
+ has customized. Within the f05 era, the manifest’s per-entry `tbd_version` guards the
2037
+ remaining skew: `tbd docs update` refuses to touch a doc whose fork point was
2038
+ advanced by a newer tbd than the one running, since that client’s bundled “upstream”
2039
+ is older than the fork point and updating would silently downgrade the doc.
2040
+
2041
+ #### Who writes what (synchronization flows)
2042
+
2043
+ | Flow | Reads | Writes | Tracked files touched |
2044
+ | --- | --- | --- | --- |
2045
+ | npm upgrade | — | bundle | none |
2046
+ | Doc sync (`tbd sync --docs`, auto-sync, setup) | bundle + URL sources | cache | none |
2047
+ | `tbd docs fork` | cache | fork file, base, manifest, fork-dir README | yes (explicit) |
2048
+ | `tbd docs update` | cache, base, fork file | fork file and/or base, manifest, README | yes (explicit) |
2049
+ | `tbd docs unfork` | base, fork file | removes fork artifacts, README | yes (explicit) |
2050
+ | User/agent edits | — | fork dir (any way they like) | yes (theirs) |
2051
+ | git operations | — | any tracked artifact | yes (theirs) |
2052
+
2053
+ Staleness appears exactly when doc sync moves the cache past a fork’s base; awareness
2054
+ surfaces (`tbd docs status`, the one-line `tbd sync` drift notice) report it, and only
2055
+ the explicit `tbd docs update` acts on it.
2056
+
2057
+ #### Drift and degraded modes
2058
+
2059
+ Because of invariant 5, arbitrary user actions in the fork dir resolve to defined
2060
+ states: edits → `customized`; deletion → `missing` (serving falls back to the cache);
2061
+ rename → `missing` + `local`; new files → `local` (served, no upstream); deleting the
2062
+ manifest → everything `local` (serving unaffected); moving into subfolders → not scanned
2063
+ (documented). Degraded modes fail soft: an unreachable URL source keeps serving the
2064
+ last-good cache copy; an empty cache self-heals via auto-sync; a deleted base blocks
2065
+ merging only for that doc (repairable via `update --keep-ours`); the upgrade abort path
2066
+ is specified in `tbd-docs.md` §Troubleshooting.
2067
+ The drift matrix with resolutions is user-facing in `tbd-docs.md` §“Forked Docs in Your
2068
+ Repo”; the state matrix, update decision table, and drift scenarios are pinned by
2069
+ `fork-manifest`/`fork-update`/`doc-fork` unit tests and the `cli-docs-fork`/
2070
+ `cli-docs-update` golden tryscripts.
2071
+
2072
+ * * *
2073
+
1971
2074
  ## 3. Git Layer
1972
2075
 
1973
2076
  ### 3.1 Overview
@@ -2034,6 +2137,8 @@ main branch: tbd-sync branch:
2034
2137
  .tbd/.gitignore # Controls what's gitignored below
2035
2138
  .tbd/.gitattributes # Merge strategies (merge=union for ids.yml)
2036
2139
  .tbd/workspaces/ # Persistent state (outbox, named workspaces)
2140
+ .tbd/doc-forks/ # Fork manifest + base snapshots (see §2.9; f05+)
2141
+ docs/tbd/ # Forked docs, outside .tbd/ (see §2.9; only when fork is used)
2037
2142
  ```
2038
2143
 
2039
2144
  #### Files Gitignored (local only)
@@ -3660,6 +3765,42 @@ tbd attic restore proj-a1b2 2025-01-07T10-30-00Z
3660
3765
 
3661
3766
  * * *
3662
3767
 
3768
+ ### 4.13 Docs Commands
3769
+
3770
+ Operations on managed docs (see §2.9 for the data model) live under the noun-scoped
3771
+ `tbd docs` group, alongside the existing per-kind readers (`tbd guidelines`,
3772
+ `tbd shortcut`, `tbd template`, which serve forked copies transparently via lookup
3773
+ precedence):
3774
+
3775
+ ```bash
3776
+ tbd docs fork [names...] [--kind] [--all] [--force] [--dry-run] # copy into docs/tbd/
3777
+ tbd docs unfork [names...] [--all] [--force] # back to upstream; refuses to drop edits
3778
+ tbd docs status [--json] # per-doc states + missing/local hints
3779
+ tbd docs update [names...] [--merge|--keep-ours] [--dry-run] # reconcile with upstream
3780
+ tbd docs diff <name> [--base|--upstream] # net fork / your changes / incoming
3781
+ tbd docs list [--kind] [--json] # cross-kind list with state markers
3782
+ ```
3783
+
3784
+ tbd has three deliberately separate update surfaces; they differ in scope, risk, and
3785
+ failure mode, and doc updates are the only one that can merge and mutate tracked files:
3786
+
3787
+ | Command | Scope | Touches | Modifies tracked files? |
3788
+ | --- | --- | --- | --- |
3789
+ | `tbd sync` | project data (issues) | sync worktree + `tbd-sync` branch; refreshes the doc cache and *reports* fork drift | never |
3790
+ | `tbd setup --auto` | installation + integrations | skills, hooks, settings, `AGENTS.md`; invokes a docs-cache sync | only generated integration files |
3791
+ | `tbd docs update` | forked docs | fork dir + bases + manifest (offline, against the cache) | **yes, the only doc command that does** |
3792
+
3793
+ Update semantics (the full decision table is unit-tested row by row): an unmodified
3794
+ stale fork is replaced; a customized stale fork gets a `git merge-file` three-way merge
3795
+ that applies automatically when clean; conflicts are skipped by default and listed with
3796
+ the two explicit strategies: `--merge` (combine, standard conflict markers, sets the
3797
+ `conflicted` flag until markers are resolved) and `--keep-ours` (keep the local content,
3798
+ advance the fork point).
3799
+ Forked files are git-tracked, so every applied update is reviewable in `git diff` and
3800
+ revertible; git is the undo.
3801
+
3802
+ * * *
3803
+
3663
3804
  ## 5. Beads Compatibility
3664
3805
 
3665
3806
  ### 5.1 Import Strategy