ai-spector 0.9.21 → 0.9.25

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 (99) hide show
  1. package/contracts/bootstrap/config/prototype-screen-map.json +25 -0
  2. package/contracts/bootstrap/config/prototype.config.json +17 -0
  3. package/contracts/bootstrap/config/review-queue-pending.json +4 -0
  4. package/contracts/bootstrap/config/review-queue-registry.json +4 -0
  5. package/contracts/bootstrap/config/review.config.json +5 -0
  6. package/contracts/bootstrap/docs/ENTITY_REGISTRY_MIGRATION.md +192 -0
  7. package/contracts/bootstrap/docs/MIGRATION.md +463 -0
  8. package/contracts/bootstrap/docs/README.md +48 -0
  9. package/contracts/bootstrap/docs/adapters/README.md +32 -0
  10. package/contracts/bootstrap/docs/guides/COMMENTS_ENTITY_MIGRATION.md +195 -0
  11. package/contracts/bootstrap/docs/guides/DOCOPS_MANUAL_FALLBACK.md +177 -0
  12. package/contracts/bootstrap/docs/guides/PROJECT_LAYOUT.md +84 -0
  13. package/contracts/bootstrap/docs/modules/comments.md +77 -0
  14. package/contracts/bootstrap/docs/modules/generate.md +25 -0
  15. package/contracts/bootstrap/docs/modules/graph.md +31 -0
  16. package/contracts/bootstrap/docs/modules/prototype.md +26 -0
  17. package/contracts/bootstrap/docs/modules/review.md +25 -0
  18. package/contracts/bootstrap/docs/modules/translate.md +26 -0
  19. package/contracts/bootstrap/scripts/migrate-entity-registry.sh +55 -0
  20. package/contracts/bootstrap/templates/basic-design/db-design-template.md +177 -0
  21. package/contracts/bootstrap/templates/basic-design/detail-api-template.md +278 -0
  22. package/contracts/bootstrap/templates/basic-design/detail-screen-template.md +281 -0
  23. package/contracts/bootstrap/templates/basic-design/list-api-template.md +130 -0
  24. package/contracts/bootstrap/templates/basic-design/list-screen-template.md +242 -0
  25. package/contracts/bootstrap/templates/detail-design/common/architecture-overview-template.md +302 -0
  26. package/contracts/bootstrap/templates/detail-design/common/deployment-infrastructure-template.md +461 -0
  27. package/contracts/bootstrap/templates/detail-design/common/error-handling-patterns-template.md +460 -0
  28. package/contracts/bootstrap/templates/detail-design/common/integration-patterns-template.md +410 -0
  29. package/contracts/bootstrap/templates/detail-design/common/performance-standards-template.md +406 -0
  30. package/contracts/bootstrap/templates/detail-design/common/security-patterns-template.md +395 -0
  31. package/contracts/bootstrap/templates/detail-design/feature-detail-design-template.md +773 -0
  32. package/contracts/bootstrap/templates/detail-design/feature-list-template.md +39 -0
  33. package/contracts/bootstrap/templates/srs/1-introduction.md +58 -0
  34. package/contracts/bootstrap/templates/srs/2-overall-description.md +91 -0
  35. package/contracts/bootstrap/templates/srs/3-use-case-detail-template.md +142 -0
  36. package/contracts/bootstrap/templates/srs/3-use-cases.md +53 -0
  37. package/contracts/bootstrap/templates/srs/4-system-feature-detail-template.md +131 -0
  38. package/contracts/bootstrap/templates/srs/4-system-features-list-template.md +39 -0
  39. package/contracts/bootstrap/templates/srs/5-data-requirements.md +59 -0
  40. package/contracts/bootstrap/templates/srs/6-external-interfaces.md +56 -0
  41. package/contracts/bootstrap/templates/srs/7-quality-attributes.md +74 -0
  42. package/contracts/bootstrap/templates/srs/8-internationalization.md +36 -0
  43. package/contracts/bootstrap/templates/srs/9-other-requirements.md +46 -0
  44. package/contracts/examples/full-docops.config.json +54 -0
  45. package/contracts/examples/migrate-lifecycle.json +18 -0
  46. package/contracts/examples/minimal-comment-thread/comment-root.json +10 -0
  47. package/contracts/examples/minimal-comment-thread/meta_data.json +22 -0
  48. package/contracts/examples/minimal-docops.config.json +33 -0
  49. package/contracts/examples/minimal-lifecycle.json +17 -0
  50. package/contracts/examples/minimal-prototype.config.json +18 -0
  51. package/contracts/examples/minimal-screen-map.json +25 -0
  52. package/contracts/examples/registry/minimal-document.entity.json +15 -0
  53. package/contracts/examples/registry/minimal-manifest.json +7 -0
  54. package/contracts/examples/registry/minimal-screen.entity.json +11 -0
  55. package/contracts/examples/review/minimal-pending.json +14 -0
  56. package/contracts/examples/review/minimal-registry.json +31 -0
  57. package/contracts/examples/review/minimal-review.config.json +7 -0
  58. package/contracts/schemas/comments/comment_body.schema.json +19 -0
  59. package/contracts/schemas/comments/meta_data.schema.json +59 -0
  60. package/contracts/schemas/docops.config.schema.json +97 -0
  61. package/contracts/schemas/lifecycle.schema.json +43 -0
  62. package/contracts/schemas/prototype/config.schema.json +56 -0
  63. package/contracts/schemas/prototype/screen-map.schema.json +51 -0
  64. package/contracts/schemas/registry/document.entity.schema.json +38 -0
  65. package/contracts/schemas/registry/manifest.schema.json +18 -0
  66. package/contracts/schemas/registry/screen.entity.schema.json +28 -0
  67. package/contracts/schemas/review/registry.schema.json +72 -0
  68. package/contracts/schemas/review/review.config.schema.json +42 -0
  69. package/dist/cli.js +26 -1
  70. package/dist/cli.js.map +1 -1
  71. package/dist/core/docops/bootstrap.d.ts +4 -1
  72. package/dist/core/docops/bootstrap.d.ts.map +1 -1
  73. package/dist/core/docops/bootstrap.js +16 -9
  74. package/dist/core/docops/bootstrap.js.map +1 -1
  75. package/dist/core/docops/guide.d.ts +78 -0
  76. package/dist/core/docops/guide.d.ts.map +1 -0
  77. package/dist/core/docops/guide.js +554 -0
  78. package/dist/core/docops/guide.js.map +1 -0
  79. package/dist/core/docops/migrate.d.ts.map +1 -1
  80. package/dist/core/docops/migrate.js +40 -6
  81. package/dist/core/docops/migrate.js.map +1 -1
  82. package/dist/core/operations/docops.d.ts +8 -0
  83. package/dist/core/operations/docops.d.ts.map +1 -1
  84. package/dist/core/operations/docops.js +40 -0
  85. package/dist/core/operations/docops.js.map +1 -1
  86. package/dist/core/upgrade/checklist.json +2 -2
  87. package/package.json +2 -1
  88. package/scaffold/claude/.claude/skills/_skill-router.md +11 -8
  89. package/scaffold/claude/.claude/skills/ai-spector/references/cli-failures.md +3 -3
  90. package/scaffold/claude/.claude/skills/ai-spector/references/docops-migrate.md +112 -0
  91. package/scaffold/claude/.claude/skills/ai-spector/references/help.md +1 -1
  92. package/scaffold/claude/.claude/skills/ai-spector/references/runbook.md +49 -26
  93. package/scaffold/claude/.claude/skills/ai-spector/skill.md +3 -2
  94. package/scaffold/cursor/skills/_skill-router.md +11 -8
  95. package/scaffold/cursor/skills/ai-spector/SKILL.md +3 -2
  96. package/scaffold/cursor/skills/ai-spector/references/cli-failures.md +3 -3
  97. package/scaffold/cursor/skills/ai-spector/references/docops-migrate.md +112 -0
  98. package/scaffold/cursor/skills/ai-spector/references/help.md +1 -1
  99. package/scaffold/cursor/skills/ai-spector/references/runbook.md +49 -26
@@ -0,0 +1,463 @@
1
+ # Legacy → Docops migration guide
2
+
3
+ This file is **committed to your repository** when you run **Writer → Project Settings → Docops → Set up repository** (or `docops init`). You do **not** need ai-spector installed to follow this guide — only git, Bitbucket access, and Kari Writer.
4
+
5
+ **Start here if:** the project already has documents, an old folder layout, or `.ai-spector/` files and you want the Writer `.docops/` contract.
6
+
7
+ **Related:** [README.md](README.md) (contract overview) · [modules/](modules/) (per-feature guides)
8
+
9
+ ---
10
+
11
+ ## For AI agents (Cursor, ai-spector, Writer automation)
12
+
13
+ Use this section when an agent migrates a repo **without** guessing paths.
14
+
15
+ ### Goals
16
+
17
+ 1. Commit `.docops/docops.config.json` and scaffold files **without overwriting** existing destination files.
18
+ 2. Set **Writer project storage layout** (`legacy` or `docops`) to match what is on the branch.
19
+ 3. Set **`docTypes.*.path`** to **repo-root-relative** folders that already hold markdown (e.g. `docs/srs`, not `srs`).
20
+
21
+ ### Agent workflow (ordered)
22
+
23
+ ```text
24
+ 1. Detect layout (§1 table) on the target branch.
25
+ 2. List existing docs folders under docs/ (or custom roots).
26
+ 3. Copy legacy contract files (§2 table) — skip if destination exists.
27
+ 4. Create or edit .docops/docops.config.json (§2.2, §3 Step 3).
28
+ 5. Copy templates into docTypes.*.templatesPath if empty.
29
+ 6. Commit + push.
30
+ 7. In Writer: Project Settings → set storage layout (§2.1) to match migration state.
31
+ 8. Run post-migration checklist (§5).
32
+ ```
33
+
34
+ **CLI (optional):** Run **`npx ai-spector docops guide --json`** first — shows current vs expected structure, files, and example config for this repo.
35
+
36
+ ```bash
37
+ npx ai-spector docops migrate --dry-run # preview legacy → contract
38
+ npx ai-spector docops migrate # full legacy migrate (no overwrite of existing)
39
+ npx ai-spector docops migrate --repair # fill gaps when config already exists
40
+ npx ai-spector docops init # greenfield scaffold
41
+ ```
42
+
43
+ **CLI failed or unavailable?** Run `npx ai-spector docops guide --prompt` — includes **wrong vs correct** for this repo, a tailored `docops.config.json` example, document paths, and scaffold checklist. Then use this guide for manual gap-fill.
44
+
45
+ ### Hard rules for agents
46
+
47
+ | Rule | Detail |
48
+ |------|--------|
49
+ | **Do not overwrite** | Never replace an existing file at a contract path. Migration **fills gaps** only. |
50
+ | **Single layout path** | Writer reads **one** path per feature from **project storage layout** — no try-legacy-then-docops fallback. |
51
+ | **Repo-root-relative `docTypes.path`** | Use full paths like `docs/srs`. Short names like `srs` are **not** expanded to `docs/srs`. |
52
+ | **Do not move `docs/`** | Point `docTypes.*.path` at existing folders; keep markdown in place. |
53
+ | **Match storage layout to git** | Until git is fully on `.docops/`, keep Writer `storage_layout: legacy`; switch to `docops` after migration commit is on the working branch. |
54
+
55
+ ---
56
+
57
+ ## 1. Detect your situation (no CLI required)
58
+
59
+ Open the repo in Bitbucket (or locally) and check which files exist on the **branch you will migrate**:
60
+
61
+ | Check | Path | Meaning |
62
+ |-------|------|---------|
63
+ | A | `.docops/docops.config.json` | Writer contract manifest exists |
64
+ | B | `.ai-spector/docflow.config.json` | Legacy ai-spector layout |
65
+ | C | `comments/` at repo root | Legacy comments location |
66
+ | D | `.ai-spector/.docflow/review-queue/` | Legacy review queue |
67
+ | E | `docs/` with markdown | Document content (keep as-is) |
68
+
69
+ | A | B/C/D | Situation | Start at |
70
+ |---|-------|-----------|----------|
71
+ | no | no | **Greenfield** — new Writer project | [Path A](#path-a--greenfield-writer-web-only) |
72
+ | no | yes | **Legacy** — needs migration | [Path B](#path-b--legacy-migration-without-ai-spector) |
73
+ | yes | * | **Docops** — contract exists | [Path C](#path-c--fill-gaps-or-verify) |
74
+ | yes | yes | **Mixed** — partial migration | [Path C](#path-c--fill-gaps-or-verify) |
75
+
76
+ Writer **Project Settings → Docops** may also show layout hints when git is linked.
77
+
78
+ ---
79
+
80
+ ## 2. Path reference (legacy → contract)
81
+
82
+ Use this table when copying files manually (git `mv` or copy + commit):
83
+
84
+ | Legacy path | Contract path | Action |
85
+ |-------------|---------------|--------|
86
+ | `.ai-spector/docflow.config.json` | `.docops/docops.config.json` | **Rewrite** — use [examples/full-docops.config.json](examples/full-docops.config.json); map languages and `docTypes` from docflow + your `docs/` tree |
87
+ | `.ai-spector/review.config.json` | `.docops/review.config.json` | Copy if missing |
88
+ | `.ai-spector/.docflow/review-queue/` | `.docops/review-queue/` | Copy folder if missing |
89
+ | `comments/` (repo root) | `.docops/comments/` | Copy folder if missing |
90
+ | `prototype/screen-map.json` | `.docops/prototype/screen-map.json` | Copy if missing |
91
+ | `.ai-spector/.docflow/config/prototype/config.json` | `.docops/prototype/config.json` | Copy if missing |
92
+ | `.ai-spector/packs/*/templates/` | `.docops/templates/{layer}/` | Copy `*.md` templates per layer |
93
+ | (none) | `.docops/guide/` | Added by Writer setup — this documentation folder |
94
+
95
+ **Rule:** never overwrite existing destination files. Migration only **fills gaps**.
96
+
97
+ ### 2.1 Storage layout (Writer project setting)
98
+
99
+ Writer stores **which path family to read from git** on the **project** row (`storage_layout` in the database). This is **not** inferred by trying multiple paths.
100
+
101
+ | `storage_layout` | When to use | Comments root | Review queue | Prototype screen-map | Prototype config |
102
+ |------------------|-------------|---------------|--------------|----------------------|------------------|
103
+ | `legacy` | Repo still uses `.ai-spector/` paths (default for old projects) | `comments/` | `.ai-spector/.docflow/review-queue/` | `prototype/screen-map.json` | `.ai-spector/.docflow/config/prototype/config.json` |
104
+ | `docops` | Repo migrated to `.docops/` contract paths | `.docops/comments/` | `.docops/review-queue/` | `.docops/prototype/screen-map.json` | `.docops/prototype/config.json` |
105
+
106
+ **Set in Writer:** Project Settings → Docops (or project update API: `storageLayout: "legacy"` \| `"docops"`).
107
+
108
+ **After migration:** when `.docops/docops.config.json` and contract paths exist on the branch users work in, set **`storage_layout` to `docops`**.
109
+
110
+ **Git vs DB:** `.docops/docops.config.json` may include `"layout": "docops"`. Writer still uses the **project `storage_layout`** for reads. Keep DB and git in sync.
111
+
112
+ **Do not rely on:** `DOCOPS_LEGACY_PATHS` env dual-read (deprecated). One layout per project.
113
+
114
+ ### 2.2 Document folders (`docTypes.*.path`)
115
+
116
+ Document markdown lives under **`docTypes.<layer>.path`** — a folder **relative to the repository root**.
117
+
118
+ | `docTypes` key | Label | Example `path` | Typical on-disk layout |
119
+ |----------------|-------|----------------|------------------------|
120
+ | `srs` | SRS | `docs/srs` | `docs/srs/en/01-overview.md` |
121
+ | `basicDesign` | Basic Design | `docs/basic-design` | `docs/basic-design/en/screen-list.md` |
122
+ | `detailDesign` | Detail Design | `docs/detail-design` | `docs/detail-design/en/feature-list.md` |
123
+ | `otherDocument` | Other Document | `docs/other` | `docs/other/en/meeting-notes.md` |
124
+
125
+ **Default bootstrap:** `detailDesign` and `otherDocument` are written to config with `"enabled": false`. Detail Design templates still land in `.docops/templates/detail-design/`. Other Document has no `templatesPath`.
126
+
127
+ **Use full repo-root paths** in config:
128
+
129
+ ```json
130
+ "docTypes": {
131
+ "srs": {
132
+ "enabled": true,
133
+ "path": "docs/srs",
134
+ "label": "SRS",
135
+ "templatesPath": ".docops/templates/srs"
136
+ },
137
+ "basicDesign": {
138
+ "enabled": true,
139
+ "path": "docs/basic-design",
140
+ "label": "Basic Design",
141
+ "templatesPath": ".docops/templates/basic-design"
142
+ },
143
+ "detailDesign": {
144
+ "enabled": false,
145
+ "path": "docs/detail-design",
146
+ "label": "Detail Design",
147
+ "templatesPath": ".docops/templates/detail-design"
148
+ },
149
+ "otherDocument": {
150
+ "enabled": false,
151
+ "path": "docs/other",
152
+ "label": "Other Document"
153
+ }
154
+ }
155
+ ```
156
+
157
+ **Path rules:**
158
+
159
+ - **`path` is literal** — `docs/srs` stays `docs/srs`. A short value like `srs` means a folder named `srs` at repo root, **not** `docs/srs`.
160
+ - **`docsRoot`** (`"docs"` by default) is **not** prepended to `docTypes.path`. Put the full folder in `path`.
161
+ - **Custom roots** are allowed (e.g. `"path": "detail-design"` at repo root) when that matches your tree.
162
+ - **Logical paths** in review/comments stay without the docs prefix: `srs/01-overview`, `basic-design/screen-list`. Writer/ai-spector map them using `docTypes.*.path`.
163
+ - **Do not overwrite** existing `docTypes.*.path` in config during repair — only fill missing `templatesPath` or scaffold files.
164
+
165
+ **Infer from tree:** if `docs/srs/` exists, set `srs.path` to `docs/srs`. If `detail-design/` exists at repo root, set `detailDesign.path` to `detail-design`.
166
+
167
+ ---
168
+
169
+ ## Path A — Greenfield (Writer web only)
170
+
171
+ No legacy layout. **No ai-spector.**
172
+
173
+ 1. **Project Settings** → Bitbucket: repo URL + token → **Save**
174
+ 2. **Docops** section → choose **target branch** (use a feature branch if `main` is protected)
175
+ 3. Click **Set up repository** (or **Customize** first)
176
+ 4. Wait for the worker job to finish (status banner turns green)
177
+ 5. Complete [post-migration checklist](#5-post-migration-checklist)
178
+
179
+ **What setup commits:**
180
+
181
+ - `.docops/docops.config.json`, review scaffolding, templates
182
+ - `{docTypes.*.path}/{lang}/.gitkeep` placeholders (e.g. `docs/srs/en/.gitkeep`)
183
+ - `.docops/guide/` — this folder (README, MIGRATION, modules, schemas, examples)
184
+
185
+ ---
186
+
187
+ ## Path B — Legacy migration (without ai-spector)
188
+
189
+ For projects with legacy paths (table in §1) and **no** `.docops/docops.config.json` yet.
190
+
191
+ ### Step 1 — Branch and backup
192
+
193
+ ```bash
194
+ git checkout -b docops/migrate
195
+ git pull
196
+ ```
197
+
198
+ - [ ] Confirm you can push to this branch from Writer (Bitbucket token saved)
199
+
200
+ ### Step 2 — Copy legacy files
201
+
202
+ From **repo root**, copy only when the contract path does not exist:
203
+
204
+ ```bash
205
+ # Comments (if you have root comments/)
206
+ test -d comments && test ! -d .docops/comments && cp -r comments .docops/comments
207
+
208
+ # Review queue
209
+ test -d .ai-spector/.docflow/review-queue && test ! -d .docops/review-queue \
210
+ && cp -r .ai-spector/.docflow/review-queue .docops/review-queue
211
+
212
+ # Review config
213
+ test -f .ai-spector/review.config.json && test ! -f .docops/review.config.json \
214
+ && cp .ai-spector/review.config.json .docops/review.config.json
215
+
216
+ # Prototype (if used)
217
+ mkdir -p .docops/prototype
218
+ test -f prototype/screen-map.json && test ! -f .docops/prototype/screen-map.json \
219
+ && cp prototype/screen-map.json .docops/prototype/screen-map.json
220
+ test -f .ai-spector/.docflow/config/prototype/config.json \
221
+ && test ! -f .docops/prototype/config.json \
222
+ && cp .ai-spector/.docflow/config/prototype/config.json .docops/prototype/config.json
223
+ ```
224
+
225
+ Adjust paths if your project uses different legacy locations.
226
+
227
+ ### Step 3 — Create `docops.config.json`
228
+
229
+ 1. Copy [examples/full-docops.config.json](examples/full-docops.config.json) to `.docops/docops.config.json`
230
+ 2. Edit to match your project:
231
+
232
+ | Field | What to set |
233
+ |-------|-------------|
234
+ | `layout` | `"docops"` when this repo uses contract paths (see §2.1) |
235
+ | `languages[]` | Codes and folder names under each `docTypes.*.path` (e.g. `en`, `vi`) |
236
+ | `primaryLanguage` | Main authoring language |
237
+ | `docTypes` | Enabled layers (`srs`, `basicDesign`, `detailDesign`) — see §2.2 |
238
+ | `docTypes.*.path` | **Repo-root-relative** folder (e.g. `docs/srs`, `docs/basic-design`) — must match existing markdown tree |
239
+ | `docTypes.*.templatesPath` | `.docops/templates/srs`, `.docops/templates/basic-design`, etc. |
240
+ | `capabilities` | `true` / `false` per Writer feature you use |
241
+ | `paths` | Contract paths for comments, review, prototype (usually defaults under `.docops/`) |
242
+
243
+ Validate (optional):
244
+
245
+ ```bash
246
+ npx ajv-cli validate \
247
+ -s .docops/guide/schemas/docops.config.schema.json \
248
+ -d .docops/docops.config.json
249
+ ```
250
+
251
+ If you have `.ai-spector/docflow.config.json`, open it side-by-side and copy language codes, doc layer paths, and plugin flags into `capabilities`.
252
+
253
+ ### Step 4 — Templates
254
+
255
+ If `.docops/templates/` is empty, copy markdown templates:
256
+
257
+ ```bash
258
+ # Example: from ai-spector pack (adjust pack name to your project)
259
+ mkdir -p .docops/templates/srs .docops/templates/basic-design
260
+ cp -r .ai-spector/packs/kaopiz-srs/templates/* .docops/templates/srs/ 2>/dev/null || true
261
+ ```
262
+
263
+ Or run **Writer Set up repository** on a branch that still has **no** `docops.config.json` to scaffold templates — then merge with your copied legacy files.
264
+
265
+ ### Step 5 — Commit and push
266
+
267
+ ```bash
268
+ git add .docops
269
+ git commit -m "docops: migrate legacy layout to .docops contract"
270
+ git push -u origin docops/migrate
271
+ ```
272
+
273
+ ### Step 6 — Add guide folder (if missing)
274
+
275
+ If `.docops/guide/` is not in the commit yet:
276
+
277
+ 1. Merge or cherry-pick from a branch where Writer setup ran, **or**
278
+ 2. **Project Settings → Docops → Set up repository** on a branch **without** `docops.config.json` (e.g. temporary branch), copy `.docops/guide/` from that commit, **or**
279
+ 3. Run Writer setup on your migrate branch **before** adding `docops.config.json` (setup first, then add config + legacy copies in a second commit)
280
+
281
+ Recommended order for Writer-only teams:
282
+
283
+ ```text
284
+ 1. Create branch
285
+ 2. Writer Set up repository → gets guide/, templates, default config
286
+ 3. Edit docops.config.json for your languages/layers
287
+ 4. Copy legacy comments/review-queue over (only if destinations empty)
288
+ 5. Commit + push
289
+ ```
290
+
291
+ ### Step 7 — Verify
292
+
293
+ [Post-migration checklist](#5-post-migration-checklist)
294
+
295
+ ---
296
+
297
+ ## Path C — Fill gaps or verify
298
+
299
+ `.docops/docops.config.json` **already exists**.
300
+
301
+ ### Missing files only (manual)
302
+
303
+ | Symptom | Fix |
304
+ |---------|-----|
305
+ | Review queue 500 / `Expected JSON object` on `pending.json` | Replace with `{"version": 2, "jobs": []}` — see [examples/review/minimal-pending.json](examples/review/minimal-pending.json). Do **not** use a bare array of logical paths. |
306
+ | No review registry | Copy [examples/review/minimal-registry.json](examples/review/minimal-registry.json) → `.docops/review-queue/registry.json` and edit |
307
+ | No review config | Copy [examples/review/minimal-review.config.json](examples/review/minimal-review.config.json) |
308
+ | No guide docs | Copy from another initialized branch or re-run setup on a branch without config, then copy `.docops/guide/` |
309
+ | Empty templates | Copy `*.md` into `docTypes.*.templatesPath` or run setup on greenfield branch and copy template folders |
310
+ | Missing `detailDesign` / `otherDocument` in config | Merge keys from [full-docops.config.json](examples/full-docops.config.json) (`enabled: false`) — see [guides/DOCOPS_MANUAL_FALLBACK.md](guides/DOCOPS_MANUAL_FALLBACK.md) |
311
+ | Empty `.docops/templates/detail-design/` | Copy from bootstrap `templates/detail-design/` even when DD disabled — [guides/DOCOPS_MANUAL_FALLBACK.md](guides/DOCOPS_MANUAL_FALLBACK.md) §4 |
312
+ | Prototype not working | See [modules/prototype.md](modules/prototype.md) — config, screen-map, `.htpasswd` |
313
+
314
+ Writer **Set up repository** returns **409** if `docops.config.json` already exists. To scaffold **missing** files without CLI:
315
+
316
+ - Follow [guides/DOCOPS_MANUAL_FALLBACK.md](guides/DOCOPS_MANUAL_FALLBACK.md) (agent gap-fill), or
317
+ - Add files manually from `guide/examples/`, or
318
+ - Use a temporary branch without config for setup, then copy missing paths into your working branch
319
+
320
+ ### Optional automation (ai-spector installed)
321
+
322
+ If ai-spector is available locally:
323
+
324
+ ```bash
325
+ npx ai-spector docops migrate --dry-run # legacy → contract preview
326
+ npx ai-spector docops migrate # full legacy migrate
327
+ npx ai-spector docops migrate --repair # fill gaps when config exists
328
+ ```
329
+
330
+ This is optional — [Path B](#path-b--legacy-migration-without-ai-spector) covers the same result with git + Writer.
331
+
332
+ ---
333
+
334
+ ## 4. Projects that never used ai-spector
335
+
336
+ Some teams only have `docs/` and custom tooling (no `.ai-spector/`).
337
+
338
+ 1. Follow [Path A](#path-a--greenfield-writer-web-only) — Writer setup scaffolds the contract
339
+ 2. Edit `.docops/docops.config.json` so `docTypes.*.path` matches your existing folders (§2.2), e.g. `docs/srs`
340
+ 3. Do **not** move `docs/` — Writer reads markdown in place via configured `path`
341
+ 4. Set Writer **`storage_layout` to `docops`** once contract files exist on the branch
342
+ 5. Enable only `capabilities` you need; see [modules/](modules/) for each feature's files
343
+ 6. External adapters: read [adapters/README.md](adapters/README.md) — integration is **git files only**, no Writer API
344
+
345
+ ---
346
+
347
+ ## 5. Post-migration checklist
348
+
349
+ After any path, verify on the migrated branch (allow ~30s for Writer git cache):
350
+
351
+ ### Contract
352
+
353
+ - [ ] `.docops/docops.config.json` valid JSON; `languages` and `docTypes` match on-disk folders (§2.2)
354
+ - [ ] `docTypes.*.path` uses repo-root-relative paths (e.g. `docs/srs`, not bare `srs` unless that folder exists at root)
355
+ - [ ] Writer project **`storage_layout`** matches branch (`legacy` until `.docops/` paths are live, then `docops`)
356
+ - [ ] `.docops/guide/README.md` and `guide/MIGRATION.md` present (this file)
357
+ - [ ] Review: `.docops/review.config.json` + `.docops/review-queue/registry.json` (if `review: true`)
358
+ - [ ] Comments: threads under `.docops/comments/` (if `comments: true`)
359
+ - [ ] Templates: `*.md` in each `templatesPath` (if `generate: true`)
360
+ - [ ] Prototype: `screen-map.json`, auth — [modules/prototype.md](modules/prototype.md)
361
+
362
+ ### Writer UI
363
+
364
+ - [ ] **Project Settings → Docops** — setup complete, no blocking errors
365
+ - [ ] **Documents** tree loads
366
+ - [ ] **Templates** lists files from `.docops/templates/`
367
+ - [ ] **Review / Comments / Prototype** work for enabled capabilities
368
+
369
+ ### Git and team
370
+
371
+ - [ ] Migration commit on the branch users work in
372
+ - [ ] CI and bots updated to read `.docops/` paths (see [adapters/README.md](adapters/README.md))
373
+ - [ ] Team entry point: `.docops/guide/README.md`
374
+
375
+ ---
376
+
377
+ ## 6. Writer admin: storage layout per project
378
+
379
+ Each linked git project has **`storage_layout`** in the Writer database:
380
+
381
+ | Value | Git paths Writer reads |
382
+ |-------|-------------------------|
383
+ | `legacy` (default) | `comments/`, `.ai-spector/.docflow/review-queue/`, `prototype/screen-map.json`, legacy prototype config |
384
+ | `docops` | `.docops/comments/`, `.docops/review-queue/`, `.docops/prototype/screen-map.json`, `.docops/prototype/config.json` |
385
+
386
+ **Migration sequence:**
387
+
388
+ 1. While git still has only legacy paths → keep `storage_layout: legacy`
389
+ 2. After `.docops/` contract files are committed on the working branch → set `storage_layout: docops`
390
+ 3. Verify Documents, Review, Comments, Prototype on that branch
391
+
392
+ Writer does **not** fall back from docops path to legacy path (or vice versa) when a file is missing.
393
+
394
+ Deprecated: `DOCOPS_LEGACY_PATHS` environment dual-read. Use per-project `storage_layout` instead.
395
+
396
+ ---
397
+
398
+ ## 6.1 Entity registry and stable comment IDs
399
+
400
+ Full guide: **[ENTITY_REGISTRY_MIGRATION.md](ENTITY_REGISTRY_MIGRATION.md)** (commands, verification, rollback).
401
+
402
+ After `docops.config.json` includes `paths.registry`, run these **on each branch** that should use ID-keyed artifacts:
403
+
404
+ ```bash
405
+ npx ai-spector docops registry sync # 1. Build .docops/registry/ from docs/ (+ screen-map import)
406
+ npx ai-spector docops comments migrate # 2. Move comments/{path}/ → comments/documents/{entityId}/
407
+ npx ai-spector docops review-registry migrate # 3. Rekey review-queue/registry.json v3 → v4 (entityId keys)
408
+ ```
409
+
410
+ Or: `bash .docops/guide/scripts/migrate-entity-registry.sh` (copied during Writer setup).
411
+
412
+ Order matters: `registry sync` must run before comment or review migrations so logical paths resolve to entity UUIDs.
413
+
414
+ **Writer reads registry from git via Redis cache** — entity JSON is not mirrored into Postgres. The `git_document_registry` table remains for design-doc listing from `docs/` scans only.
415
+
416
+ Writer API and UI accept `entityId` (or `screenId` for prototype) when listing comments; `filePath` remains supported for one release (see `Deprecation` response headers).
417
+
418
+ ---
419
+
420
+ ## 7. Migration flow (summary)
421
+
422
+ ```text
423
+ Check repo files (§1)
424
+
425
+ ├─ greenfield ──────► Writer Set up repository (Path A)
426
+
427
+ ├─ legacy, no config ► copy legacy files (§2 table)
428
+ │ create docops.config.json (§2.2, Step 3)
429
+ │ commit + push
430
+ │ set Writer storage_layout (§2.1)
431
+ │ → checklist (§5)
432
+
433
+ └─ config exists ───► fill gaps manually (Path C)
434
+ or optional: ai-spector migrate --repair
435
+ ```
436
+
437
+ ---
438
+
439
+ ## 8. After migration
440
+
441
+ 1. [README.md](README.md) — contract overview
442
+ 2. [modules/](modules/) — per-module schema, Writer flow, examples
443
+ 3. [schemas/](schemas/) — validate JSON locally
444
+ 4. [examples/](examples/) — copy-paste starting points
445
+
446
+ ---
447
+
448
+ ## 9. Agent quick reference (copy for prompts)
449
+
450
+ ```text
451
+ Migrate repo to .docops contract:
452
+ - Branch: docops/migrate (or user branch)
453
+ - Copy legacy → contract (§2 table); skip existing destinations
454
+ - docops.config.json: layout "docops", docTypes.*.path = repo-root-relative (docs/srs, docs/basic-design, …)
455
+ - Always include detailDesign + otherDocument (enabled: false) unless already present
456
+ - Copy .docops/templates/detail-design/ from bootstrap even when DD disabled
457
+ - capabilities + paths per project needs
458
+ - templates: .docops/templates/{layer}/*.md
459
+ - gitkeep: {docTypes.path}/{lang}/.gitkeep for each enabled layer × language
460
+ - Commit; then Writer storage_layout = docops
461
+ - Never overwrite existing files; never use short docTypes.path expecting docs/ prefix
462
+ - CLI failed → `npx ai-spector docops guide --prompt` then guides/DOCOPS_MANUAL_FALLBACK.md
463
+ ```
@@ -0,0 +1,48 @@
1
+ # Docops contract — project guide
2
+
3
+ Writer reads this repo via git. Edit files here, commit, and push — no CLI required.
4
+
5
+ ## Folder map
6
+
7
+ | Path | Purpose |
8
+ |------|---------|
9
+ | `docops.config.json` | Languages, doc layers, paths, capabilities |
10
+ | `registry/` | **Entity registry** — stable UUIDs per design doc / screen (`registry sync`) |
11
+ | `review.config.json` | Review sign-off preset |
12
+ | `review-queue/` | Review sign-off state (v4 keys = `entityId`; legacy v3 = `logicalPath`) |
13
+ | `comments/` | Comment threads — `documents/{entityId}/` or `screens/{screenId}/` (legacy: path folders) |
14
+ | `prototype/` | Screen map (legacy) or registry screens after sync |
15
+ | `templates/` | Markdown templates per doc layer |
16
+ | `modules/` | Per-feature setup guides (this folder) |
17
+ | `adapters/` | External tool integration rules |
18
+
19
+ **Not the same as:** `.docops/review-queue/registry.json` (review sign-off) or `.ai-spector/registry/section-registry.json` (traceability section index for local graph).
20
+
21
+ ## Document paths
22
+
23
+ `docs/{docTypes.<layer>.path}/{language.path}/*.md`
24
+
25
+ Example: `docs/srs/en/1-introduction.md`
26
+
27
+ ## Capabilities
28
+
29
+ | Key | Writer feature |
30
+ |-----|----------------|
31
+ | `review` | Review queue + sign-off |
32
+ | `comments` | Inline comments |
33
+ | `prototype` | Prototype screen map |
34
+ | `graph` | Traceability graph in **Writer web UI** (local `npx ai-spector index` always builds `.ai-spector/graph/` regardless) |
35
+ | `generate` | Cloud generation from templates |
36
+ | `translate` | Translation workflow UI |
37
+
38
+ Set a capability to `false` to hide that feature (no error).
39
+
40
+ ## Module guides
41
+
42
+ - [Review](modules/review.md)
43
+ - [Comments](modules/comments.md)
44
+ - [Prototype](modules/prototype.md)
45
+ - [Generate](modules/generate.md)
46
+ - [Translate](modules/translate.md)
47
+ - [Graph](modules/graph.md)
48
+ - [External adapters](adapters/README.md)
@@ -0,0 +1,32 @@
1
+ # External Adapters — Docops Integration Guide
2
+
3
+ ## Principles
4
+
5
+ Writer and local tools integrate through **files in git** — not direct API calls between them.
6
+
7
+ | Rule | Detail |
8
+ |------|--------|
9
+ | File bus | All state lives in `.docops/`, `docs/`, and optional `.ai-spector/` |
10
+ | Branch-scoped | Contract files on branch X apply when users view branch X |
11
+ | No Writer API | Adapters read/write the repo filesystem or git remote — not Writer REST |
12
+ | Lenient validation | Unknown JSON keys are ignored; missing optional files hide features |
13
+
14
+ ## Concurrency
15
+
16
+ Comment threads and review registry use read-modify-write:
17
+
18
+ 1. Read current file (and git SHA when available)
19
+ 2. Apply change
20
+ 3. Commit; retry on conflict
21
+
22
+ Do not silently overwrite concurrent edits.
23
+
24
+ ## When to disable Writer UI
25
+
26
+ Set `capabilities.<module>: false` in `docops.config.json` when your adapter owns that workflow entirely. Writer hides the feature without error.
27
+
28
+ `capabilities.graph` and `capabilities.generate` affect **Writer cloud UI only**. The local ai-spector engine (MCP and CLI) always owns index, graph, and generate work sessions regardless of those flags.
29
+
30
+ ## Schema reference
31
+
32
+ Full schemas and examples: bundled in the ai-spector package at `contracts/schemas/` and `contracts/examples/`, or `.docops/guide/schemas/` in this project after init.