@sandrinio/vdoc 3.8.0 → 3.9.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 (63) hide show
  1. package/README.md +50 -12
  2. package/bin/vdoc.mjs +10 -0
  3. package/package.json +1 -1
  4. package/skills/agents/references/audit-workflow.md +41 -10
  5. package/skills/agents/references/create-workflow.md +77 -0
  6. package/skills/agents/references/discovery-protocol.md +211 -0
  7. package/skills/agents/references/doc-template.md +102 -32
  8. package/skills/agents/references/init-workflow.md +103 -23
  9. package/skills/agents/references/manifest-schema.json +2 -1
  10. package/skills/claude/references/audit-workflow.md +39 -10
  11. package/skills/claude/references/create-workflow.md +41 -18
  12. package/skills/claude/references/discovery-protocol.md +211 -0
  13. package/skills/claude/references/doc-template.md +102 -32
  14. package/skills/claude/references/init-workflow.md +99 -19
  15. package/skills/claude/references/manifest-schema.json +2 -1
  16. package/skills/cline/references/audit-workflow.md +41 -10
  17. package/skills/cline/references/create-workflow.md +77 -0
  18. package/skills/cline/references/discovery-protocol.md +211 -0
  19. package/skills/cline/references/doc-template.md +102 -32
  20. package/skills/cline/references/init-workflow.md +103 -23
  21. package/skills/cline/references/manifest-schema.json +2 -1
  22. package/skills/continue/references/audit-workflow.md +41 -10
  23. package/skills/continue/references/create-workflow.md +77 -0
  24. package/skills/continue/references/discovery-protocol.md +211 -0
  25. package/skills/continue/references/doc-template.md +102 -32
  26. package/skills/continue/references/init-workflow.md +103 -23
  27. package/skills/continue/references/manifest-schema.json +2 -1
  28. package/skills/cursor/references/audit-workflow.md +41 -10
  29. package/skills/cursor/references/create-workflow.md +77 -0
  30. package/skills/cursor/references/discovery-protocol.md +211 -0
  31. package/skills/cursor/references/doc-template.md +102 -32
  32. package/skills/cursor/references/init-workflow.md +103 -23
  33. package/skills/cursor/references/manifest-schema.json +2 -1
  34. package/skills/gemini/references/audit-workflow.md +41 -10
  35. package/skills/gemini/references/create-workflow.md +77 -0
  36. package/skills/gemini/references/discovery-protocol.md +211 -0
  37. package/skills/gemini/references/doc-template.md +102 -32
  38. package/skills/gemini/references/init-workflow.md +103 -23
  39. package/skills/gemini/references/manifest-schema.json +2 -1
  40. package/skills/jetbrains-ai/references/audit-workflow.md +41 -10
  41. package/skills/jetbrains-ai/references/create-workflow.md +77 -0
  42. package/skills/jetbrains-ai/references/discovery-protocol.md +211 -0
  43. package/skills/jetbrains-ai/references/doc-template.md +102 -32
  44. package/skills/jetbrains-ai/references/init-workflow.md +103 -23
  45. package/skills/jetbrains-ai/references/manifest-schema.json +2 -1
  46. package/skills/junie/references/audit-workflow.md +41 -10
  47. package/skills/junie/references/create-workflow.md +77 -0
  48. package/skills/junie/references/discovery-protocol.md +211 -0
  49. package/skills/junie/references/doc-template.md +102 -32
  50. package/skills/junie/references/init-workflow.md +103 -23
  51. package/skills/junie/references/manifest-schema.json +2 -1
  52. package/skills/vscode/references/audit-workflow.md +41 -10
  53. package/skills/vscode/references/create-workflow.md +77 -0
  54. package/skills/vscode/references/discovery-protocol.md +211 -0
  55. package/skills/vscode/references/doc-template.md +102 -32
  56. package/skills/vscode/references/init-workflow.md +101 -21
  57. package/skills/vscode/references/manifest-schema.json +2 -1
  58. package/skills/windsurf/resources/audit-workflow.md +41 -10
  59. package/skills/windsurf/resources/create-workflow.md +77 -0
  60. package/skills/windsurf/resources/discovery-protocol.md +211 -0
  61. package/skills/windsurf/resources/doc-template.md +102 -32
  62. package/skills/windsurf/resources/init-workflow.md +105 -25
  63. package/skills/windsurf/resources/manifest-schema.json +2 -1
package/README.md CHANGED
@@ -6,6 +6,22 @@ One install command. Your AI handles the rest.
6
6
 
7
7
  ---
8
8
 
9
+ ## Why vdoc?
10
+
11
+ ### 1. Better AI context
12
+
13
+ Your AI reads code, but code doesn't tell it *why* auth tokens expire in 15 minutes, *what happens* when a webhook fails at 2 AM, or *which features depend on each other*. Without that context, the AI guesses — and gets things wrong. vdoc generates feature-centric docs that give it real system knowledge, plus a `_manifest.json` that acts as a routing table — one read and the AI knows exactly which doc to open for any question.
14
+
15
+ ### 2. Developer onboarding
16
+
17
+ New developer joins the team. Instead of spending days reading code and asking questions, they point their AI at the `vdocs/` folder and get up to speed immediately. Every feature is documented with end-to-end flows, data models, error scenarios, security patterns, and architectural decisions — the stuff that normally lives only in senior devs' heads.
18
+
19
+ ### 3. No data leaves your machine
20
+
21
+ vdoc is not a service, not a CLI that phones home, not a SaaS product. It's a set of skill/rule files that get copied into your AI platform's config folder. Your code is read by the same AI agent you're already using. Nothing is sent anywhere, no accounts, no API keys, no telemetry.
22
+
23
+ ---
24
+
9
25
  ## What is vdoc?
10
26
 
11
27
  vdoc gives your AI coding agent the ability to create and maintain feature-centric documentation for your codebase. It's not a CLI you run — it's a skill file that gets installed into your AI platform. After install, you just talk to your AI.
@@ -169,26 +185,46 @@ Docs are **feature-centric** — organized by what your system does, not by file
169
185
 
170
186
  Every generated doc follows a consistent structure:
171
187
 
172
- - **Overview** — what it does, why it exists
173
- - **How It Works** — core logic with mermaid diagrams (max 7-9 nodes per diagram)
174
- - **Data Model** — entities and relationships
175
- - **Key Files** — source files that implement this feature
188
+ - **Overview** — value proposition: what problem this solves for the user
189
+ - **User Workflows** — step-by-step journeys: what the user does, what the system does, what the user sees
190
+ - **How It Works** — end-to-end flows with mermaid sequence diagrams (every actor shown)
191
+ - **Data Model** — actual column names, types, and descriptions from schema files
192
+ - **Key Files** — every file in the execution path, not just the "main" files
176
193
  - **Dependencies & Integrations** — external services, internal features
177
- - **Configuration** — env vars, feature flags, secrets
178
- - **Error Handling** — failure modes and user-facing behavior
179
- - **Constraints & Decisions** — why it's built this way, what you can't change
180
- - **Related Features** — cross-references and blast radius
194
+ - **Configuration** — actual env vars and secrets from the code
195
+ - **Error Handling & Edge Cases** — specific failure scenarios with system behavior and user impact
196
+ - **Security** — auth patterns, service roles, access control, secrets handling
197
+ - **Constraints & Decisions** — non-obvious architectural choices with reasoning
198
+ - **Related Features** — cross-references by doc filename with coupling explanation
181
199
 
182
200
  ---
183
201
 
184
- ## Manifest
202
+ ## Manifest — The AI's Entry Point
203
+
204
+ The `_manifest.json` is the first file any AI agent should read when it encounters your project. It solves a fundamental problem: **how does an AI know what your project does without reading everything?**
205
+
206
+ ### How it works
185
207
 
186
- The `_manifest.json` is a map for your AI. Instead of reading every doc to find the right one, the AI reads the manifest first and picks the relevant doc based on rich descriptions and tags.
208
+ 1. AI opens `vdocs/_manifest.json` one read
209
+ 2. Sees the project fingerprint (language, framework, architecture)
210
+ 3. Matches the user's question against rich doc descriptions
211
+ 4. Reads only the relevant doc — not the entire codebase
187
212
 
188
- When you ask "how does authentication work?", the AI matches your question against manifest descriptions and goes straight to `AUTHENTICATION_DOC.md` — no scanning, no guessing.
213
+ **Without manifest:** "How does auth work?" AI scans dozens of files, misses context, hallucinates details
214
+
215
+ **With manifest:** "How does auth work?" → AI reads manifest → routes to `AUTHENTICATION_DOC.md` → gets the complete OAuth2 flow, JWT lifecycle, error scenarios, and security patterns
216
+
217
+ ### Example
189
218
 
190
219
  ```json
191
220
  {
221
+ "project": "my-saas-app",
222
+ "fingerprint": {
223
+ "languages": ["TypeScript"],
224
+ "frameworks": ["Next.js 14", "Prisma", "NextAuth"],
225
+ "archetypes": ["Full-stack Framework"],
226
+ "scope": "~85 files, medium"
227
+ },
192
228
  "documentation": [
193
229
  {
194
230
  "filepath": "AUTHENTICATION_DOC.md",
@@ -201,6 +237,8 @@ When you ask "how does authentication work?", the AI matches your question again
201
237
  }
202
238
  ```
203
239
 
240
+ The `description` field is intentionally rich — it's written for semantic matching, not for humans to skim. The more specific the description, the better the AI routes questions to the right doc.
241
+
204
242
  ---
205
243
 
206
244
  ## Uninstall
@@ -241,4 +279,4 @@ None. Your AI coding agent is the runtime.
241
279
 
242
280
  ---
243
281
 
244
- *vdoc v3.5.2 — Documentation skills for AI coding agents*
282
+ *vdoc v3.8.0 — Documentation skills for AI coding agents*
package/bin/vdoc.mjs CHANGED
@@ -18,6 +18,7 @@ const PLATFORMS = {
18
18
  { src: 'claude/references/create-workflow.md', dest: '.claude/skills/vdoc/references/create-workflow.md' },
19
19
  { src: 'claude/references/audit-workflow.md', dest: '.claude/skills/vdoc/references/audit-workflow.md' },
20
20
  { src: 'claude/references/exploration-strategies.md', dest: '.claude/skills/vdoc/references/exploration-strategies.md' },
21
+ { src: 'claude/references/discovery-protocol.md', dest: '.claude/skills/vdoc/references/discovery-protocol.md' },
21
22
  { src: 'claude/references/doc-template.md', dest: '.claude/skills/vdoc/references/doc-template.md' },
22
23
  { src: 'claude/references/manifest-schema.json', dest: '.claude/skills/vdoc/references/manifest-schema.json' },
23
24
  { src: 'claude/commands/vdoc-init.md', dest: '.claude/commands/vdoc-init.md' },
@@ -34,6 +35,7 @@ const PLATFORMS = {
34
35
  { src: 'cursor/references/doc-template.md', dest: '.cursor/rules/vdoc/references/doc-template.md' },
35
36
  { src: 'cursor/references/manifest-schema.json', dest: '.cursor/rules/vdoc/references/manifest-schema.json' },
36
37
  { src: 'cursor/references/exploration-strategies.md', dest: '.cursor/rules/vdoc/references/exploration-strategies.md' },
38
+ { src: 'cursor/references/discovery-protocol.md', dest: '.cursor/rules/vdoc/references/discovery-protocol.md' },
37
39
  { src: 'cursor/vdoc-command.md', dest: '.cursor/commands/vdoc.md' },
38
40
  ],
39
41
  },
@@ -45,6 +47,7 @@ const PLATFORMS = {
45
47
  { src: 'windsurf/resources/doc-template.md', dest: '.windsurf/skills/vdoc/resources/doc-template.md' },
46
48
  { src: 'windsurf/resources/manifest-schema.json', dest: '.windsurf/skills/vdoc/resources/manifest-schema.json' },
47
49
  { src: 'windsurf/resources/exploration-strategies.md', dest: '.windsurf/skills/vdoc/resources/exploration-strategies.md' },
50
+ { src: 'windsurf/resources/discovery-protocol.md', dest: '.windsurf/skills/vdoc/resources/discovery-protocol.md' },
48
51
  { src: 'windsurf/vdoc-workflow.md', dest: '.windsurf/workflows/vdoc.md' },
49
52
  ],
50
53
  },
@@ -56,6 +59,7 @@ const PLATFORMS = {
56
59
  { src: 'vscode/references/doc-template.md', dest: '.github/skills/vdoc/references/doc-template.md' },
57
60
  { src: 'vscode/references/manifest-schema.json', dest: '.github/skills/vdoc/references/manifest-schema.json' },
58
61
  { src: 'vscode/references/exploration-strategies.md', dest: '.github/skills/vdoc/references/exploration-strategies.md' },
62
+ { src: 'vscode/references/discovery-protocol.md', dest: '.github/skills/vdoc/references/discovery-protocol.md' },
59
63
  { src: 'vscode/vdoc.instructions.md', dest: '.github/instructions/vdoc.instructions.md' },
60
64
  { src: 'vscode/vdoc.prompt.md', dest: '.github/prompts/vdoc.prompt.md' },
61
65
  { src: 'vscode/copilot-instructions.md', dest: '.github/copilot-instructions.md', inject: true },
@@ -70,6 +74,7 @@ const PLATFORMS = {
70
74
  { src: 'continue/references/doc-template.md', dest: '.continue/references/vdoc/doc-template.md' },
71
75
  { src: 'continue/references/manifest-schema.json', dest: '.continue/references/vdoc/manifest-schema.json' },
72
76
  { src: 'continue/references/exploration-strategies.md', dest: '.continue/references/vdoc/exploration-strategies.md' },
77
+ { src: 'continue/references/discovery-protocol.md', dest: '.continue/references/vdoc/discovery-protocol.md' },
73
78
  ],
74
79
  },
75
80
  cline: {
@@ -81,6 +86,7 @@ const PLATFORMS = {
81
86
  { src: 'cline/references/doc-template.md', dest: '.clinerules/vdoc/doc-template.md' },
82
87
  { src: 'cline/references/manifest-schema.json', dest: '.clinerules/vdoc/manifest-schema.json' },
83
88
  { src: 'cline/references/exploration-strategies.md', dest: '.clinerules/vdoc/exploration-strategies.md' },
89
+ { src: 'cline/references/discovery-protocol.md', dest: '.clinerules/vdoc/discovery-protocol.md' },
84
90
  ],
85
91
  },
86
92
  gemini: {
@@ -92,6 +98,7 @@ const PLATFORMS = {
92
98
  { src: 'gemini/references/doc-template.md', dest: '.gemini/vdoc/doc-template.md' },
93
99
  { src: 'gemini/references/manifest-schema.json', dest: '.gemini/vdoc/manifest-schema.json' },
94
100
  { src: 'gemini/references/exploration-strategies.md', dest: '.gemini/vdoc/exploration-strategies.md' },
101
+ { src: 'gemini/references/discovery-protocol.md', dest: '.gemini/vdoc/discovery-protocol.md' },
95
102
  ],
96
103
  },
97
104
  jetbrains: {
@@ -102,6 +109,7 @@ const PLATFORMS = {
102
109
  { src: 'jetbrains-ai/references/doc-template.md', dest: '.aiassistant/vdoc/doc-template.md' },
103
110
  { src: 'jetbrains-ai/references/manifest-schema.json', dest: '.aiassistant/vdoc/manifest-schema.json' },
104
111
  { src: 'jetbrains-ai/references/exploration-strategies.md', dest: '.aiassistant/vdoc/exploration-strategies.md' },
112
+ { src: 'jetbrains-ai/references/discovery-protocol.md', dest: '.aiassistant/vdoc/discovery-protocol.md' },
105
113
  ],
106
114
  },
107
115
  junie: {
@@ -112,6 +120,7 @@ const PLATFORMS = {
112
120
  { src: 'junie/references/doc-template.md', dest: '.junie/vdoc/doc-template.md' },
113
121
  { src: 'junie/references/manifest-schema.json', dest: '.junie/vdoc/manifest-schema.json' },
114
122
  { src: 'junie/references/exploration-strategies.md', dest: '.junie/vdoc/exploration-strategies.md' },
123
+ { src: 'junie/references/discovery-protocol.md', dest: '.junie/vdoc/discovery-protocol.md' },
115
124
  ],
116
125
  },
117
126
  agents: {
@@ -122,6 +131,7 @@ const PLATFORMS = {
122
131
  { src: 'agents/references/doc-template.md', dest: '.agents/vdoc/doc-template.md' },
123
132
  { src: 'agents/references/manifest-schema.json', dest: '.agents/vdoc/manifest-schema.json' },
124
133
  { src: 'agents/references/exploration-strategies.md', dest: '.agents/vdoc/exploration-strategies.md' },
134
+ { src: 'agents/references/discovery-protocol.md', dest: '.agents/vdoc/discovery-protocol.md' },
125
135
  ],
126
136
  },
127
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandrinio/vdoc",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "Documentation skills for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +1,7 @@
1
1
  # Audit Workflow
2
2
 
3
+ Detect stale, missing, dead, and low-quality documentation. Report and patch. Do NOT create scripts, shell files, scanners, or any tooling — use your built-in tools (Read, Glob, Grep, Bash for git commands) for everything.
4
+
3
5
  ## Step 1 — Read Current State
4
6
 
5
7
  Read `vdocs/_manifest.json`. Load the list of documented features and their metadata.
@@ -8,7 +10,7 @@ Read `vdocs/_manifest.json`. Load the list of documented features and their meta
8
10
 
9
11
  Run `git log --name-only --since="<last_updated>" --pretty=format:""` or use `git diff` to find all source files that changed since the last audit.
10
12
 
11
- Cross-reference changed files against each doc's "Key Files" section to identify which docs are stale.
13
+ Cross-reference changed files against each doc's `keyFiles` frontmatter (or Key Files section) to identify which docs are stale.
12
14
 
13
15
  ## Step 3 — Detect Coverage Gaps
14
16
 
@@ -22,15 +24,36 @@ If you find undocumented features, propose new docs.
22
24
 
23
25
  ## Step 4 — Detect Dead Docs
24
26
 
25
- Check each doc's "Key Files" section against the actual filesystem. If key files no longer exist, the doc may be dead. Flag it: "PAYMENT_PROCESSING_DOC.md references 3 files that no longer exist — remove or archive?"
27
+ Check each doc's Key Files (from frontmatter `keyFiles` and the Key Files table) against the actual filesystem. If key files no longer exist, the doc may be dead. Flag it: "PAYMENT_PROCESSING_DOC.md references 3 files that no longer exist — remove or archive?"
26
28
 
27
29
  ## Step 5 — Check Cross-References
28
30
 
29
- Read each doc's "Related Features" section. Verify that:
30
- - Referenced doc filenames still exist
31
+ Read each doc's Related Features table and `relatedDocs` frontmatter. Verify that:
32
+ - Referenced doc filenames still exist in `vdocs/` and in `_manifest.json`
33
+ - The `deps` array in the manifest matches the Related Features table
31
34
  - The described coupling is still accurate (skim the relevant code)
32
35
 
33
- ## Step 6 — Report
36
+ ## Step 6 — Quality Score
37
+
38
+ Run mechanical quality checks on each doc. Score = percentage of checks passing.
39
+
40
+ | # | Check | How to verify |
41
+ |---|-------|---------------|
42
+ | 1 | Valid YAML frontmatter | Has all required fields: title, description, tags, version, keyFiles, relatedDocs, lastUpdated |
43
+ | 2 | CORE sections present and non-empty | Overview, Business Rules, How It Works, Key Files, Testing, Constraints & Decisions, Related Features all exist with content |
44
+ | 3 | Key File paths exist | Every path in frontmatter `keyFiles` and Key Files table resolves to a real file |
45
+ | 4 | How It Works has a diagram | Contains at least one `mermaid` code block |
46
+ | 5 | Business Rules has ≥1 rule | At least one bullet point in the section |
47
+ | 6 | relatedDocs resolve | Every filename in frontmatter `relatedDocs` exists in `vdocs/` |
48
+ | 7 | lastUpdated freshness | Delta between `lastUpdated` and latest git blame on key files is within acceptable range |
49
+ | 8 | Testing section has run command | Contains a code-formatted command string |
50
+
51
+ **Score thresholds:**
52
+ - **80-100%** — Good quality
53
+ - **60-79%** — Acceptable, minor improvements suggested
54
+ - **Below 60%** — Low quality — generate a "quality fix" task
55
+
56
+ ## Step 7 — Report
34
57
 
35
58
  Present a clear report:
36
59
 
@@ -41,6 +64,11 @@ STALE (source files changed):
41
64
  - AUTHENTICATION_DOC.md — src/lib/auth.ts changed (added GitHub provider)
42
65
  - API_REFERENCE_DOC.md — 2 new endpoints added
43
66
 
67
+ QUALITY SCORES:
68
+ - AUTHENTICATION_DOC.md — 88% (Good) ✓
69
+ - API_REFERENCE_DOC.md — 50% (Low) ✗ Missing: Business Rules, Testing section, mermaid diagram
70
+ - DATABASE_SCHEMA_DOC.md — 75% (Acceptable) ~ Missing: Testing section
71
+
44
72
  COVERAGE GAPS (undocumented features):
45
73
  - src/services/notification.ts — no doc covers notifications
46
74
 
@@ -49,17 +77,20 @@ DEAD DOCS (source files removed):
49
77
 
50
78
  CROSS-REF ISSUES:
51
79
  - AUTHENTICATION_DOC.md references BILLING_DOC.md which no longer exists
80
+ - Manifest deps for PAYMENTS_DOC.md lists "invoicing" but no invoicing doc exists
52
81
 
53
82
  CURRENT (no changes needed):
54
- - DATABASE_SCHEMA_DOC.md
55
- - PROJECT_OVERVIEW_DOC.md
83
+ - PROJECT_OVERVIEW_DOC.md — 100% quality
56
84
 
57
85
  Proceed with fixes?
58
86
  ```
59
87
 
60
88
  Wait for user direction, then:
61
89
  - Patch stale docs (re-read source files, update affected sections only)
62
- - Generate new docs for coverage gaps (follow init workflow for each)
90
+ - Fix low-quality docs (add missing CORE sections, fix broken key file paths)
91
+ - Generate new docs for coverage gaps (follow create workflow for each)
63
92
  - Flag dead docs for user to confirm deletion
64
- - Fix cross-reference issues
65
- - Update manifest: bump versions, update `last_updated`, `last_commit`
93
+ - Fix cross-reference issues (update relatedDocs frontmatter + manifest deps)
94
+ - Regenerate context slices for any patched/updated docs in `vdocs/_slices/`
95
+ - Update manifest: bump `version`, update `last_updated`, `last_commit`, fix `deps` arrays
96
+ - Bump frontmatter `version` (increment by 1) and `lastUpdated` on every patched doc
@@ -0,0 +1,77 @@
1
+ # Create Workflow
2
+
3
+ Create one feature doc based on the user's description. Do NOT create scripts, shell files, scanners, or any tooling — use your built-in tools (Read, Glob, Grep) for everything.
4
+
5
+ ## Step 1 — Locate
6
+
7
+ Use the user's description to find the relevant source files:
8
+
9
+ 1. If `vdocs/_planning/_exploration_log.md` exists, read it first — it maps the codebase and may already have the feature signal you need
10
+ 2. Otherwise, search the codebase with Glob and Grep to find files matching the user's description
11
+ 3. Read ALL relevant source files — not just the main file, but helpers, types, middleware, tests, API routes, components
12
+ 4. **Trace the end-to-end flow** — pick the primary user action and follow it through every layer: frontend → API route → service/lib → database → external service → response. Read each file in the chain. Don't stop at the service layer.
13
+ 5. **Search for consumers** — grep for the feature's key types, table names, API endpoints, and module imports across the entire codebase. This catches secondary workflows (exports, scheduled jobs, webhooks, notifications, external automation) that live in different directories but depend on this feature. If you find consumers, read them and include those workflows in the doc.
14
+
15
+ Do not skim. Understand how the feature actually works before writing.
16
+
17
+ ## Step 2 — Generate
18
+
19
+ 1. Read the template from [doc-template.md](./doc-template.md) and follow it exactly
20
+ 2. Write to `vdocs/FEATURE_NAME_DOC.md`
21
+
22
+ **Writing rules:**
23
+
24
+ - **YAML frontmatter** — every doc MUST start with frontmatter: `title`, `description`, `tags`, `version` (start at 1), `keyFiles` (array of primary source file paths), `relatedDocs` (array of other doc filenames), `lastUpdated` (YYYY-MM-DD). This metadata is the machine-readable contract — keep it in sync with the doc body.
25
+ - **CORE vs CONDITIONAL sections** — follow the `[CORE]` and `[CONDITIONAL]` markers in the template. Omit conditional sections entirely when not relevant. Do NOT leave empty sections or write "N/A".
26
+ - **Overview** must open with the value proposition — what problem does this feature solve for the user? Not just "manages X" but "enables users to Y without Z." A PM should understand the feature from this section alone.
27
+ - **Business Rules** — plain-language rules that govern behavior. No code. If you can't find explicit rules, derive them from the code and mark with `Inferred from code — verify with team`.
28
+ - **User Workflows** — describe 1-3 primary user journeys. [CONDITIONAL: omit for non-user-facing features]
29
+ - **"How It Works" must use sequence diagrams** for the primary flow — show every actor. Trace the COMPLETE path.
30
+ - **Key Files** — list every file in the execution path with a Type column (Source, Test, Config, Migration, etc.). Include test files and config files.
31
+ - **Testing** — include the test run command, test file locations, coverage gaps, and manual testing steps.
32
+ - **Common Tasks** — cookbook recipes for recurring modifications. [CONDITIONAL: omit when not applicable]
33
+ - **Data Model** — actual column names, types, descriptions. [CONDITIONAL: omit for features without persistent state]
34
+ - **Error Handling & Edge Cases** — specific failure scenarios, not generic. [CONDITIONAL: omit for features with no non-obvious failure modes]
35
+ - **Constraints & Decisions** — non-obvious choices + security considerations (auth, access control, secrets).
36
+ - **Related Features** — structured table: Doc, Relationship, Blast radius. Also populate `relatedDocs` frontmatter.
37
+ - **Change Log** — add initial entry with today's date.
38
+
39
+ ## Step 3 — Update Manifest
40
+
41
+ Read `vdocs/_manifest.json` and add the new doc entry using the schema in [manifest-schema.json](./manifest-schema.json).
42
+
43
+ Include the `deps` array — list feature names (matching other manifest entries' titles) that would break if this feature changes. Populate from the Related Features table.
44
+
45
+ If `vdocs/_manifest.json` doesn't exist, create it with the project name, version, and this doc as the first entry.
46
+
47
+ ## Step 4 — Generate Context Slice
48
+
49
+ Create a token-optimized context slice at `vdocs/_slices/{FEATURE_NAME}_SLICE.md`.
50
+
51
+ Extract ONLY these sections from the full doc:
52
+ - **Overview** (first paragraph only)
53
+ - **Business Rules** (full section)
54
+ - **Key Files** table (full table)
55
+ - **Constraints & Decisions** (full section)
56
+ - **Related Features** table (full table)
57
+
58
+ Add a header comment: `<!-- Context slice for {Feature Title} — auto-generated, do not edit manually -->` and a link back to the full doc.
59
+
60
+ ## Step 5 — Self-Review
61
+
62
+ Before finishing, verify:
63
+
64
+ - [ ] Doc has valid YAML frontmatter (title, description, tags, version, keyFiles, relatedDocs, lastUpdated)
65
+ - [ ] Frontmatter `keyFiles` matches Key Files table entries
66
+ - [ ] Frontmatter `relatedDocs` matches Related Features table doc filenames
67
+ - [ ] Doc has at least one mermaid diagram in "How It Works"
68
+ - [ ] Doc has at least 2 entries in "Constraints & Decisions"
69
+ - [ ] Key Files lists real paths with Type column
70
+ - [ ] Doc has a Testing section with run command and coverage info
71
+ - [ ] Doc has Business Rules with at least one plain-language rule
72
+ - [ ] CONDITIONAL sections are omitted (not left empty) when not relevant
73
+ - [ ] Related Features uses structured table format (Doc, Relationship, Blast radius)
74
+ - [ ] Manifest entry includes `deps` array populated from Related Features
75
+ - [ ] Manifest `description` is detailed enough for semantic routing
76
+ - [ ] Context slice exists in `vdocs/_slices/`
77
+ - [ ] Doc explains WHY and HOW, not just WHAT
@@ -0,0 +1,211 @@
1
+ # Universal Discovery Protocol
2
+
3
+ After running the archetype playbook from `exploration-strategies.md`, apply these four discovery layers to find **behaviors** — not just files. The archetype playbook tells you WHERE to look. This protocol tells you WHAT to look for.
4
+
5
+ Run all four layers regardless of archetype. Each layer produces signals that feed the documentation plan.
6
+
7
+ ---
8
+
9
+ ## Layer 1 — Capability Surface
10
+
11
+ **Goal:** Map everything a user/consumer can DO.
12
+
13
+ The capability surface is the complete set of entry points into your system. Every entry point = a potential doc.
14
+
15
+ | Project Type | Capability Source | How to Find |
16
+ |-------------|------------------|-------------|
17
+ | SPA / Mobile | Route definitions | Glob: `**/routes*`, `**/router*`, `**/app/**/page.*`, `**/screens/**` |
18
+ | Web API | Endpoint definitions | Glob: `**/routes/**`, `**/controllers/**`; Grep: `@Get\|@Post\|app.get\|router.` |
19
+ | CLI | Command definitions | Glob: `**/commands/**`, `**/cmd/**`; Grep: `.command(\|.subcommand\|Subcommand` |
20
+ | Library/SDK | Public exports | Read main entry point (`index.*`), check `exports` in package config |
21
+ | Pipeline | DAG/flow definitions | Glob: `**/dags/**`, `**/pipelines/**`, `**/flows/**`, `**/workflows/**` |
22
+ | Event-driven | Event handlers | Grep: `on\(\|addEventListener\|@EventHandler\|subscribe\|consumer` |
23
+
24
+ ### SPA-Specific: Route Tree = Feature Map
25
+
26
+ For SPAs (React, Angular, Vue, Svelte), the route tree IS the documentation outline:
27
+
28
+ 1. **Extract the full route tree** — read router config, `app/` directory structure, or navigation definitions
29
+ 2. **Classify each route:**
30
+ - **Core domain** — the primary value (e.g., `/projects/:id`, `/dashboard`)
31
+ - **Auth** — login, register, forgot password, OAuth callbacks
32
+ - **Settings/Admin** — configuration, user management
33
+ - **Utility** — 404, error pages, maintenance
34
+ 3. **For each core domain route, identify:**
35
+ - What data it displays (state selectors, API calls, props)
36
+ - What actions the user can take (buttons, forms, modals)
37
+ - What happens after each action (navigation, API mutation, toast)
38
+
39
+ **Framework-specific best signals:**
40
+
41
+ | Framework | Best Feature Signal | Pattern to Grep |
42
+ |-----------|-------------------|-----------------|
43
+ | React | Custom hooks | `export function use[A-Z]` or `export const use[A-Z]` |
44
+ | Angular | Feature modules + services | `@NgModule\|@Injectable` |
45
+ | Vue 3 | Composables | `export function use[A-Z]` in `composables/` |
46
+ | Svelte | Stores + loaders | `writable\|readable\|derived` or `+page.ts` `load` functions |
47
+ | Solid | Signals + resources | `createSignal\|createResource` |
48
+
49
+ Each custom hook/composable/service that encapsulates a reusable behavior = one documentable feature.
50
+
51
+ ### API-Specific: Endpoint Map
52
+
53
+ 1. **Check for API specs first** — OpenAPI/Swagger (`swagger.json`, `openapi.yaml`), GraphQL schemas (`schema.graphql`, `*.gql`), protobuf definitions (`*.proto`), tRPC routers. These are free structured input — parse them instead of re-discovering.
54
+ 2. **Group endpoints by resource** — `/users/*`, `/projects/*`, `/billing/*` — each group is a feature.
55
+ 3. **Trace middleware chains** — what runs before each endpoint? (auth, validation, rate limiting, logging)
56
+
57
+ ---
58
+
59
+ ## Layer 2 — Data Flows
60
+
61
+ **Goal:** For each capability, trace how data moves from source to screen (or from input to storage).
62
+
63
+ ### Discovery questions per feature:
64
+ 1. **Where does the data come from?** (API call, local state, URL params, localStorage, real-time subscription)
65
+ 2. **How is it transformed?** (selectors, computed values, mappers, formatters)
66
+ 3. **Where is it displayed?** (which components/views consume it)
67
+ 4. **How does the user modify it?** (forms, inline edits, drag-drop, toggles)
68
+ 5. **Where does the mutation go?** (API endpoint, store dispatch, optimistic update)
69
+ 6. **What's the loading/error/empty state?** (skeleton, spinner, error boundary, empty state message)
70
+
71
+ ### Patterns to discover:
72
+
73
+ | Pattern | Grep Signal | What It Reveals |
74
+ |---------|------------|-----------------|
75
+ | API client calls | `fetch\|axios\|httpClient\|trpc\|useSWR\|useQuery\|graphql` | Backend dependencies per feature |
76
+ | State management | `useSelector\|useStore\|mapState\|inject\|useContext\|getState` | Shared state between features |
77
+ | Form handling | `useForm\|FormGroup\|Formik\|react-hook-form\|zod\|yup\|validate` | User input flows + validation rules |
78
+ | Caching | `cache\|staleTime\|revalidate\|TTL\|memo\|persist` | Data freshness strategy |
79
+ | Optimistic updates | `optimistic\|rollback\|onMutate\|pending` | UX patterns for mutations |
80
+
81
+ ### SPA data flow trace template:
82
+ ```
83
+ Feature: [name]
84
+ User action → Component → Hook/Service → API call → Backend endpoint
85
+ Response → Transform → State update → Re-render → User sees [result]
86
+ Error → Error handler → User sees [error state]
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Layer 3 — Shared Behaviors
92
+
93
+ **Goal:** Find cross-cutting concerns that affect multiple features.
94
+
95
+ These don't belong to any single feature — they're system-wide patterns that deserve their own docs or dedicated sections.
96
+
97
+ ### Must-find behaviors:
98
+
99
+ | Behavior | Where to Look | Grep Patterns |
100
+ |----------|--------------|---------------|
101
+ | **Authentication** | Middleware, guards, interceptors, context providers | `auth\|token\|session\|jwt\|oauth\|login\|guard\|protect\|interceptor` |
102
+ | **Authorization** | Route guards, role checks, permission gates | `role\|permission\|can\|ability\|policy\|rbac\|acl\|isAdmin\|gate` |
103
+ | **Error handling** | Error boundaries, global handlers, interceptors | `ErrorBoundary\|catch\|onError\|handleError\|errorHandler\|fallback\|retry` |
104
+ | **Notifications** | Toast systems, push notifications, in-app alerts | `toast\|notify\|alert\|snackbar\|notification\|push\|banner` |
105
+ | **Real-time** | WebSocket, SSE, polling, subscriptions | `WebSocket\|socket\|SSE\|EventSource\|subscribe\|polling\|realtime\|live` |
106
+ | **Theming/i18n** | Theme providers, translation files, locale configs | `theme\|dark\|light\|i18n\|locale\|translate\|intl\|t\(` |
107
+ | **Analytics** | Tracking calls, event logging | `track\|analytics\|gtag\|mixpanel\|segment\|posthog\|amplitude` |
108
+ | **Feature flags** | Flag checks, A/B tests, experimental UI | `feature.*flag\|experiment\|variant\|canary\|flipper\|unleash\|launchDarkly` |
109
+
110
+ ### Discovery process:
111
+ 1. Grep for each behavior's patterns across the codebase
112
+ 2. If found, read the implementation to understand scope
113
+ 3. In the exploration log, note which features are affected
114
+ 4. In the plan, decide: standalone doc vs dedicated section in each affected feature doc
115
+
116
+ ---
117
+
118
+ ## Layer 4 — Integration Boundary
119
+
120
+ **Goal:** Find every point where the system touches the outside world.
121
+
122
+ ### Outgoing integrations (your app calls external services):
123
+
124
+ | Pattern | How to Find |
125
+ |---------|------------|
126
+ | HTTP clients | Grep: `fetch\|axios\|got\|httpClient\|request\|urllib` — read the base URL and endpoint |
127
+ | SDK imports | Grep: `import.*from ['"]@?(?:aws-sdk\|stripe\|twilio\|sendgrid\|firebase\|supabase)` |
128
+ | Database connections | Grep: `createClient\|createPool\|mongoose.connect\|PrismaClient\|createConnection` |
129
+ | Cache connections | Grep: `redis\|memcache\|createClient.*cache` |
130
+ | Queue producers | Grep: `publish\|sendMessage\|enqueue\|dispatch.*queue\|produce` |
131
+
132
+ ### Incoming integrations (external services call your app):
133
+
134
+ | Pattern | How to Find |
135
+ |---------|------------|
136
+ | Webhook handlers | Grep: `webhook\|/hook\|/callback` in route definitions |
137
+ | OAuth callbacks | Grep: `callback\|/auth/.*callback\|redirect_uri` |
138
+ | Queue consumers | Grep: `consume\|subscribe\|onMessage\|process.*queue\|worker` |
139
+ | Cron / scheduled tasks | Grep: `cron\|schedule\|@Cron\|setInterval.*60\|recurring`; Glob: `**/cron/**`, `**/jobs/**`, `**/tasks/**`, `**/workers/**` |
140
+
141
+ ### Hidden work (no user present):
142
+
143
+ This is the most underdocumented layer in any project. Actively hunt for:
144
+
145
+ 1. **Background jobs** — Glob: `**/jobs/**`, `**/workers/**`, `**/queues/**`, `**/tasks/**`
146
+ 2. **Scheduled tasks** — Grep: `cron\|schedule\|@Scheduled\|setInterval`; check CI/CD configs for scheduled workflows
147
+ 3. **Event handlers** — Grep: `on\(\|emit\(\|EventEmitter\|addEventListener\|subscribe`; check for pub/sub patterns
148
+ 4. **Database triggers** — Read migration files for trigger definitions
149
+ 5. **Cleanup / maintenance** — Grep: `cleanup\|purge\|archive\|expire\|gc\|garbage`
150
+
151
+ ### Environment as documentation:
152
+
153
+ Read `.env.example`, `.env.sample`, or environment config files. Each env var is a configuration surface:
154
+ - `DATABASE_URL` → database dependency
155
+ - `STRIPE_SECRET_KEY` → payment integration
156
+ - `REDIS_URL` → caching layer
157
+ - `WEBHOOK_SECRET` → incoming integration
158
+
159
+ Group env vars by feature — they reveal the integration map without reading any code.
160
+
161
+ ---
162
+
163
+ ## How to Use This Protocol
164
+
165
+ ### During Init (Step 1 — Explore):
166
+
167
+ After the archetype playbook:
168
+ 1. Run Layer 1 to build the capability map
169
+ 2. For each capability, run Layer 2 to trace data flows
170
+ 3. Run Layer 3 once for the whole project to find shared behaviors
171
+ 4. Run Layer 4 once to map the integration boundary
172
+
173
+ ### During Audit:
174
+
175
+ Layers 1 and 4 are the best sources for coverage gaps:
176
+ - New routes/endpoints = new capabilities not yet documented
177
+ - New env vars with external URLs = new integrations not yet documented
178
+ - New cron/job files = new background work not yet documented
179
+
180
+ ### In the Exploration Log:
181
+
182
+ Add a section per layer:
183
+
184
+ ```markdown
185
+ ## Capability Surface
186
+ | Entry Point | Type | Proposed Doc |
187
+ |-------------|------|-------------|
188
+ | /api/auth/* | Auth routes (5 endpoints) | AUTHENTICATION_DOC.md |
189
+ | /dashboard | Page + 3 sub-routes | DASHBOARD_DOC.md |
190
+
191
+ ## Data Flows
192
+ | Feature | State Source | API Calls | Mutations |
193
+ |---------|-------------|-----------|-----------|
194
+ | Dashboard | useDashboardStore | GET /api/stats, GET /api/projects | None (read-only) |
195
+ | Project Editor | useProjectStore | GET /api/projects/:id | PUT /api/projects/:id, POST /api/tasks |
196
+
197
+ ## Shared Behaviors
198
+ | Behavior | Scope | Implementation |
199
+ |----------|-------|----------------|
200
+ | Auth | All /app/* routes | NextAuth middleware + useSession hook |
201
+ | Error handling | Global | ErrorBoundary + toast on API errors |
202
+ | Feature flags | 3 features | LaunchDarkly SDK, checked in useFeatureFlag hook |
203
+
204
+ ## Integration Boundary
205
+ | Direction | System | Purpose | Env Var |
206
+ |-----------|--------|---------|---------|
207
+ | Outgoing | Stripe API | Payments | STRIPE_SECRET_KEY |
208
+ | Outgoing | SendGrid | Emails | SENDGRID_API_KEY |
209
+ | Incoming | Stripe webhooks | Payment events | /api/webhooks/stripe |
210
+ | Background | Cron: cleanup-sessions | Expire old sessions | runs daily via Vercel Cron |
211
+ ```