trinity-method-sdk 2.0.9 → 2.2.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 (147) hide show
  1. package/CHANGELOG.md +702 -267
  2. package/README.md +550 -540
  3. package/dist/cli/commands/deploy/agents.js +1 -1
  4. package/dist/cli/commands/deploy/ci-cd.d.ts +4 -3
  5. package/dist/cli/commands/deploy/ci-cd.js +10 -9
  6. package/dist/cli/commands/deploy/claude-setup.js +28 -35
  7. package/dist/cli/commands/deploy/configuration.js +10 -11
  8. package/dist/cli/commands/deploy/directories.js +13 -14
  9. package/dist/cli/commands/deploy/gitignore.js +3 -5
  10. package/dist/cli/commands/deploy/index.d.ts +1 -1
  11. package/dist/cli/commands/deploy/index.js +7 -3
  12. package/dist/cli/commands/deploy/knowledge-base.js +3 -3
  13. package/dist/cli/commands/deploy/pre-flight.js +1 -1
  14. package/dist/cli/commands/deploy/root-files.js +3 -18
  15. package/dist/cli/commands/deploy/sdk-install.js +1 -1
  16. package/dist/cli/commands/deploy/summary.js +3 -3
  17. package/dist/cli/commands/deploy/templates.js +33 -20
  18. package/dist/cli/commands/update/agents.js +1 -1
  19. package/dist/cli/commands/update/backup.js +6 -12
  20. package/dist/cli/commands/update/commands.d.ts +1 -0
  21. package/dist/cli/commands/update/commands.js +18 -45
  22. package/dist/cli/commands/update/knowledge-base.js +2 -2
  23. package/dist/cli/commands/update/pre-flight.js +11 -11
  24. package/dist/cli/commands/update/summary.js +5 -5
  25. package/dist/cli/commands/update/templates.js +35 -13
  26. package/dist/cli/commands/update/verification.js +5 -5
  27. package/dist/cli/commands/update/version.js +1 -1
  28. package/dist/cli/utils/deploy-ci.d.ts +3 -2
  29. package/dist/cli/utils/deploy-ci.js +24 -24
  30. package/dist/cli/utils/deploy-linting.js +101 -6
  31. package/dist/cli/utils/error-classes.d.ts +2 -2
  32. package/dist/cli/utils/linting-tools.js +14 -6
  33. package/dist/cli/utils/template-processor.js +2 -4
  34. package/dist/templates/{claude → .claude}/EMPLOYEE-DIRECTORY.md.template +16 -22
  35. package/dist/templates/{agents → .claude/agents}/aj-team/apo-documentation-specialist.md.template +10 -10
  36. package/dist/templates/{agents → .claude/agents}/aj-team/bas-quality-gate.md.template +13 -15
  37. package/dist/templates/{agents → .claude/agents}/aj-team/bon-dependency-manager.md.template +4 -4
  38. package/dist/templates/{agents → .claude/agents}/aj-team/cap-configuration-specialist.md.template +3 -3
  39. package/dist/templates/{agents → .claude/agents}/aj-team/dra-code-reviewer.md.template +8 -10
  40. package/dist/templates/{agents → .claude/agents}/aj-team/kil-task-executor.md.template +11 -13
  41. package/dist/templates/{agents → .claude/agents}/aj-team/uro-refactoring-specialist.md.template +3 -3
  42. package/dist/templates/{agents → .claude/agents}/audit/juno-auditor.md.template +46 -42
  43. package/dist/templates/{agents → .claude/agents}/deployment/ein-cicd.md.template +59 -164
  44. package/dist/templates/{agents → .claude/agents}/deployment/ino-context.md.template +25 -22
  45. package/dist/templates/{agents → .claude/agents}/deployment/tan-structure.md.template +32 -30
  46. package/dist/templates/{agents → .claude/agents}/deployment/zen-knowledge.md.template +28 -23
  47. package/dist/templates/{agents → .claude/agents}/leadership/aj-maestro.md.template +10 -6
  48. package/dist/templates/{agents → .claude/agents}/leadership/aly-cto.md.template +22 -19
  49. package/dist/templates/{agents → .claude/agents}/planning/eus-decomposer.md.template +8 -4
  50. package/dist/templates/{agents → .claude/agents}/planning/mon-requirements.md.template +8 -4
  51. package/dist/templates/{agents → .claude/agents}/planning/ror-design.md.template +8 -4
  52. package/dist/templates/{agents → .claude/agents}/planning/tra-planner.md.template +10 -4
  53. package/dist/templates/{shared/claude-commands → .claude/commands/execution}/trinity-audit.md.template +15 -15
  54. package/dist/templates/.claude/commands/execution/trinity-breakdown.md.template +535 -0
  55. package/dist/templates/{shared/claude-commands → .claude/commands/execution}/trinity-orchestrate.md.template +48 -48
  56. package/dist/templates/{shared/claude-commands → .claude/commands/infrastructure}/trinity-init.md.template +32 -54
  57. package/dist/templates/{shared/claude-commands → .claude/commands/investigation}/trinity-create-investigation.md.template +13 -7
  58. package/dist/templates/{shared/claude-commands → .claude/commands/investigation}/trinity-investigate-templates.md.template +19 -15
  59. package/dist/templates/{shared/claude-commands → .claude/commands/investigation}/trinity-plan-investigation.md.template +12 -6
  60. package/dist/templates/{shared/claude-commands → .claude/commands/maintenance}/trinity-changelog.md.template +9 -8
  61. package/dist/templates/.claude/commands/maintenance/trinity-docs-update.md.template +279 -0
  62. package/dist/templates/.claude/commands/maintenance/trinity-docs.md.template +2828 -0
  63. package/dist/templates/{shared/claude-commands → .claude/commands/maintenance}/trinity-readme.md.template +21 -20
  64. package/dist/templates/{shared/claude-commands → .claude/commands/planning}/trinity-decompose.md.template +6 -4
  65. package/dist/templates/{shared/claude-commands → .claude/commands/planning}/trinity-design.md.template +6 -4
  66. package/dist/templates/{shared/claude-commands → .claude/commands/planning}/trinity-plan.md.template +7 -5
  67. package/dist/templates/{shared/claude-commands → .claude/commands/planning}/trinity-requirements.md.template +6 -4
  68. package/dist/templates/{shared/claude-commands → .claude/commands/session}/trinity-continue.md.template +30 -24
  69. package/dist/templates/{shared/claude-commands → .claude/commands/session}/trinity-end.md.template +403 -397
  70. package/dist/templates/{shared/claude-commands → .claude/commands/session}/trinity-start.md.template +9 -4
  71. package/dist/templates/{shared/claude-commands → .claude/commands/utility}/trinity-agents.md.template +11 -8
  72. package/dist/templates/{shared/claude-commands → .claude/commands/utility}/trinity-verify.md.template +56 -57
  73. package/dist/templates/{shared/claude-commands → .claude/commands/utility}/trinity-workorder.md.template +13 -9
  74. package/dist/templates/ci/ci.yml.template +2 -2
  75. package/dist/templates/root/CLAUDE.md.template +9 -9
  76. package/dist/templates/root/linting/nodejs/.husky-pre-commit.template +5 -0
  77. package/dist/templates/source/base-CLAUDE.md.template +310 -310
  78. package/dist/templates/source/flutter-CLAUDE.md.template +593 -593
  79. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -531
  80. package/dist/templates/source/python-CLAUDE.md.template +510 -510
  81. package/dist/templates/source/react-CLAUDE.md.template +513 -513
  82. package/dist/templates/source/rust-CLAUDE.md.template +653 -653
  83. package/dist/templates/trinity/CLAUDE.md.template +14 -14
  84. package/dist/templates/{knowledge-base → trinity/knowledge-base}/AI-DEVELOPMENT-GUIDE.md.template +1 -1
  85. package/dist/templates/{knowledge-base → trinity/knowledge-base}/ARCHITECTURE.md.template +5 -5
  86. package/dist/templates/{knowledge-base → trinity/knowledge-base}/CODING-PRINCIPLES.md.template +1 -1
  87. package/dist/templates/{knowledge-base → trinity/knowledge-base}/DOCUMENTATION-CRITERIA.md.template +1 -1
  88. package/dist/templates/{knowledge-base → trinity/knowledge-base}/ISSUES.md.template +9 -9
  89. package/dist/templates/{knowledge-base → trinity/knowledge-base}/TESTING-PRINCIPLES.md.template +1 -1
  90. package/dist/templates/{knowledge-base → trinity/knowledge-base}/Technical-Debt.md.template +2 -4
  91. package/dist/templates/{knowledge-base → trinity/knowledge-base}/To-do.md.template +2 -2
  92. package/dist/templates/{knowledge-base → trinity/knowledge-base}/Trinity.md.template +6 -6
  93. package/dist/templates/trinity/templates/documentation/api-docs/README.md.template +218 -0
  94. package/dist/templates/trinity/templates/documentation/configuration/documentation-structure.md.template +71 -0
  95. package/dist/templates/trinity/templates/documentation/configuration/env-example-generator.md.template +387 -0
  96. package/dist/templates/trinity/templates/documentation/discovery/api-endpoint-scanner.md.template +343 -0
  97. package/dist/templates/trinity/templates/documentation/discovery/component-discovery.md.template +254 -0
  98. package/dist/templates/trinity/templates/documentation/discovery/env-variable-extraction.md.template +316 -0
  99. package/dist/templates/trinity/templates/documentation/discovery/framework-detection.md.template +205 -0
  100. package/dist/templates/trinity/templates/documentation/guides/api-development.md.template +375 -0
  101. package/dist/templates/trinity/templates/documentation/guides/contributing.md.template +488 -0
  102. package/dist/templates/trinity/templates/documentation/guides/deployment.md.template +565 -0
  103. package/dist/templates/trinity/templates/documentation/guides/getting-started.md.template +118 -0
  104. package/dist/templates/trinity/templates/documentation/mermaid-diagrams/api-endpoint-map.md.template +56 -0
  105. package/dist/templates/trinity/templates/documentation/mermaid-diagrams/component-hierarchy.md.template +60 -0
  106. package/dist/templates/trinity/templates/documentation/mermaid-diagrams/database-er.md.template +49 -0
  107. package/dist/templates/trinity/templates/documentation/mermaid-diagrams/mvc-flow.md.template +41 -0
  108. package/dist/templates/trinity/templates/documentation/processes/error-handling-protocol.md.template +166 -0
  109. package/dist/templates/trinity/templates/documentation/processes/fallback-mechanism.md.template +88 -0
  110. package/dist/templates/trinity/templates/documentation/reports/apo-docs-update-checklist.md.template +343 -0
  111. package/dist/templates/trinity/templates/documentation/reports/juno-docs-update-checklist.md.template +1337 -0
  112. package/dist/templates/trinity/templates/documentation/reports/juno-final-report.md.template +237 -0
  113. package/dist/templates/trinity/templates/documentation/reports/juno-internal-report.md.template +461 -0
  114. package/dist/templates/trinity/templates/documentation/validation/documentation-verification-rules.md.template +379 -0
  115. package/dist/templates/trinity/templates/documentation/validation/juno-quality-gates.md.template +282 -0
  116. package/dist/templates/{investigations → trinity/templates/investigations}/bug.md.template +14 -14
  117. package/dist/templates/{investigations → trinity/templates/investigations}/feature.md.template +14 -14
  118. package/dist/templates/{investigations → trinity/templates/investigations}/performance.md.template +14 -14
  119. package/dist/templates/{investigations → trinity/templates/investigations}/security.md.template +14 -14
  120. package/dist/templates/{investigations → trinity/templates/investigations}/technical.md.template +14 -14
  121. package/dist/templates/{work-orders → trinity/templates/work-orders}/ANALYSIS-TEMPLATE.md.template +10 -13
  122. package/dist/templates/{work-orders → trinity/templates/work-orders}/AUDIT-TEMPLATE.md.template +10 -26
  123. package/dist/templates/{work-orders → trinity/templates/work-orders}/IMPLEMENTATION-TEMPLATE.md.template +10 -26
  124. package/dist/templates/{work-orders → trinity/templates/work-orders}/INVESTIGATION-TEMPLATE.md.template +10 -25
  125. package/dist/templates/{work-orders → trinity/templates/work-orders}/PATTERN-TEMPLATE.md.template +10 -26
  126. package/dist/templates/{work-orders → trinity/templates/work-orders}/VERIFICATION-TEMPLATE.md.template +10 -26
  127. package/package.json +99 -94
  128. package/dist/templates/agents/leadership/aj-cc.md.template +0 -462
  129. package/dist/templates/ci/cd.yml.template +0 -175
  130. package/dist/templates/ci/github-actions.yml +0 -86
  131. package/dist/templates/root/TRINITY.md.template +0 -52
  132. package/dist/templates/shared/claude-commands/trinity-docs.md.template +0 -2577
  133. /package/dist/templates/{linting → root/linting}/flutter/.pre-commit-config.yaml.template +0 -0
  134. /package/dist/templates/{linting → root/linting}/flutter/analysis_options.yaml.template +0 -0
  135. /package/dist/templates/{linting → root/linting}/nodejs/.eslintrc-commonjs.json.template +0 -0
  136. /package/dist/templates/{linting → root/linting}/nodejs/.eslintrc-esm.json.template +0 -0
  137. /package/dist/templates/{linting → root/linting}/nodejs/.eslintrc-typescript.json.template +0 -0
  138. /package/dist/templates/{linting → root/linting}/nodejs/.pre-commit-config.yaml.template +0 -0
  139. /package/dist/templates/{linting → root/linting}/nodejs/.prettierrc.json.template +0 -0
  140. /package/dist/templates/{linting → root/linting}/python/.flake8.template +0 -0
  141. /package/dist/templates/{linting → root/linting}/python/.pre-commit-config.yaml.template +0 -0
  142. /package/dist/templates/{linting → root/linting}/python/pyproject.toml.template +0 -0
  143. /package/dist/templates/{linting → root/linting}/rust/.pre-commit-config.yaml.template +0 -0
  144. /package/dist/templates/{linting → root/linting}/rust/clippy.toml.template +0 -0
  145. /package/dist/templates/{linting → root/linting}/rust/rustfmt.toml.template +0 -0
  146. /package/dist/templates/{documentation → trinity/templates/documentation}/ROOT-README.md.template +0 -0
  147. /package/dist/templates/{documentation → trinity/templates/documentation}/SUBDIRECTORY-README.md.template +0 -0
@@ -1,2577 +0,0 @@
1
- # Trinity docs/ Directory Management
2
-
3
- **Purpose:** Launch APO (Documentation Specialist) to create, organize, and maintain the project's `docs/` directory with proper structure, seeded content, and navigation.
4
-
5
- **Use Case:** Create organized docs/ directory structure, seed initial documentation content, migrate scattered docs, generate navigation, validate links.
6
-
7
- **Deliverable:** docs/ organization report in `trinity/reports/DOCS-ORGANIZATION-{date}.md`
8
-
9
- ---
10
-
11
- ## Overview
12
-
13
- The `/trinity-docs` command invokes APO (Documentation Specialist) to **create and organize** the `docs/` directory. This command creates a well-structured documentation directory with relevant starter content based on your project's actual codebase.
14
-
15
- **APO's Responsibilities:**
16
- - Analyze codebase to gather project context
17
- - Scan existing docs/ files and scattered documentation
18
- - Create hierarchical directory structure (guides/, api/, architecture/, reference/, images/)
19
- - Seed initial documentation content based on project type
20
- - Migrate scattered documentation files into organized structure
21
- - Auto-generate architecture documentation from codebase
22
- - Generate docs/README.md navigation file
23
- - Validate and fix documentation links
24
- - Integrate auto-generated API docs (TypeDoc, Rustdoc, etc.)
25
- - Provide actionable recommendations for empty categories
26
-
27
- **What This Command Does NOT Handle:**
28
- - ❌ Root README.md (use `/trinity-readme`)
29
- - ❌ CHANGELOG.md updates (use `/trinity-changelog`)
30
- - ❌ Trinity infrastructure files (trinity/, CLAUDE.md)
31
- - ❌ Technical source READMEs (src/README.md, tests/README.md)
32
-
33
- ---
34
-
35
- ## CRITICAL: APO Must Perform Work DIRECTLY
36
-
37
- **APO is NOT a planning agent. APO is an EXECUTION agent for documentation.**
38
-
39
- **✅ APO MUST:**
40
- - ANALYZE codebase for project context **in this command execution**
41
- - CREATE docs/ directory structure **in this command execution**
42
- - SEED initial documentation content **in this command execution**
43
- - MIGRATE scattered documentation **in this command execution**
44
- - GENERATE architecture docs **in this command execution**
45
- - ORGANIZE existing documentation files **in this command execution**
46
- - VALIDATE and FIX documentation links **in this command execution**
47
- - Report COMPLETED work in Phase 5 (past tense: "Created docs/guides/getting-started.md")
48
-
49
- **❌ APO MUST NOT:**
50
- - Create work orders for docs organization
51
- - Create "recommendations" instead of performing organization
52
- - Skip work because "it's too much effort"
53
- - Defer work to future execution
54
- - Move Trinity infrastructure files (trinity/, CLAUDE.md)
55
- - Move technical source READMEs (src/README.md, etc.)
56
-
57
- ---
58
-
59
- ## DOCUMENTATION RULES
60
-
61
- **These rules apply to ALL documentation created by this command. NO EXCEPTIONS.**
62
-
63
- ### Rule 1: No Self-Serving Trinity Documentation
64
-
65
- **❌ FORBIDDEN:**
66
- - Including information about Trinity Method in project documentation
67
- - Explaining what Trinity Method is in README/docs
68
- - Mentioning Trinity agents (APO, MON, ROR, KIL, BAS, etc.) in user-facing docs
69
- - Documenting Trinity slash commands in project docs
70
- - Adding Trinity Method badges, links, or references to project documentation
71
- - Describing the Trinity Method SDK in project documentation
72
-
73
- **✅ CORRECT:**
74
- - Document the USER'S codebase exclusively
75
- - Focus on the project's functionality, architecture, and usage
76
- - Trinity Method is a development tool, not the subject of documentation
77
- - The project documentation is about the project, not about how it was documented
78
-
79
- **Why:** Trinity Method SDK is a tool for developers. The project's documentation should focus exclusively on the project's code, features, and usage - not on the development methodology used to create it.
80
-
81
- #### Rule 1 Forbidden Patterns
82
-
83
- **APO MUST scan for and REMOVE these patterns from ALL generated documentation:**
84
-
85
- **Trinity Infrastructure References:**
86
- - ❌ `trinity/` paths (e.g., `trinity/reports/`, `trinity/knowledge-base/`)
87
- - ❌ `.claude/` paths (e.g., `.claude/agents/`, `.claude/commands/`)
88
- - ❌ Links to CLAUDE.md files
89
- - ❌ Links to Trinity reports or session files
90
-
91
- **Trinity Agent Names:**
92
- - ❌ APO, MON, ROR, KIL, BAS, DRA, URO, EUS, TRA, EIN, INO, TAN, ZEN, JUNO, BON, CAP (when referring to agents)
93
- - ✅ OK if these are actual project variable/function names in code examples
94
-
95
- **Trinity Commands:**
96
- - ❌ `/trinity-start`, `/trinity-audit`, `/trinity-readme`, `/trinity-docs`, etc.
97
- - ❌ Any slash commands starting with `/trinity-`
98
-
99
- **Trinity Method Terminology:**
100
- - ❌ "Trinity Method v2.0"
101
- - ❌ "Trinity infrastructure"
102
- - ❌ "Trinity SDK"
103
- - ❌ "Trinity orchestration"
104
- - ❌ "Trinity workflow"
105
- - ❌ References to Trinity Method as a development tool
106
-
107
- **Exceptions:**
108
- - ✅ "Trinity" as a project name (e.g., "Trinity Healthcare App")
109
- - ✅ "Trinity" in code comments if part of project code
110
- - ✅ Database names, class names, or other project-specific uses of "Trinity"
111
-
112
- **Verification Command:**
113
- ```bash
114
- # After generating all docs, run:
115
- grep -rni "trinity\|/trinity-\|APO\|MON\|ROR\|KIL\|BAS" docs/
116
-
117
- # Expected result: NO MATCHES (or only project-specific Trinity usage)
118
- ```
119
-
120
- **If Trinity references found:**
121
- 1. Remove the reference from the documentation
122
- 2. Log the violation in Phase 5 report
123
- 3. Update templates to prevent future violations
124
-
125
- ### Rule 2: Evidence-Based Documentation Only
126
-
127
- **CRITICAL: Only document tools, libraries, and features that actually exist in this codebase.**
128
-
129
- **Before documenting ANY tool, you MUST verify:**
130
-
131
- 1. **Package Manager Verification**
132
- - Node.js: Check `package.json` dependencies or devDependencies
133
- - Python: Check `requirements.txt`, `pyproject.toml`, or `setup.py`
134
- - Rust: Check `Cargo.toml` dependencies
135
- - Go: Check `go.mod` require statements
136
-
137
- 2. **Configuration File Verification**
138
- - Check for tool config files (`.eslintrc.js`, `jest.config.js`, `.lighthouserc.json`, etc.)
139
- - Check for tool-specific directories (`.github/workflows/`, `__tests__/`, etc.)
140
-
141
- 3. **Usage Evidence**
142
- - Search for tool imports/usage in code
143
- - Check `package.json` scripts for tool commands
144
- - Look for generated files/reports from the tool
145
-
146
- **❌ DO NOT DOCUMENT:**
147
- - Tools you "recognize" for this project type
148
- - "Best practice" or "recommended" tools not actually installed
149
- - Tools from your training data that "PWA projects typically use"
150
- - Features without verified implementation code
151
-
152
- **✅ ONLY DOCUMENT:**
153
- - Tools explicitly listed in package manager files
154
- - Tools with configuration files present
155
- - Features with actual implementation code you can reference
156
-
157
- **Example - Lighthouse:**
158
- ```bash
159
- # BEFORE documenting Lighthouse, verify:
160
- 1. grep '"lighthouse"' package.json → NOT FOUND ❌
161
- 2. Check for .lighthouserc.json → DOES NOT EXIST ❌
162
- 3. Check for lighthouse-reports/ → DOES NOT EXIST ❌
163
- CONCLUSION: Do NOT document Lighthouse
164
-
165
- # Verification failed = Skip entirely
166
- ```
167
-
168
- **Example - Jest (Verified):**
169
- ```bash
170
- # BEFORE documenting Jest, verify:
171
- 1. grep '"jest"' package.json → FOUND ✅
172
- 2. Check for jest.config.js → EXISTS ✅
173
- 3. Check for __tests__/ or *.test.js → EXISTS ✅
174
- CONCLUSION: Document Jest
175
-
176
- # Verification passed = Document with confidence
177
- ```
178
-
179
- **Why This Matters:**
180
- This command is used globally across all stacks. Without verification:
181
- - Node.js PWAs would document Lighthouse (assumed tool)
182
- - Python projects would document Sphinx (assumed tool)
183
- - Rust projects would document cargo-deny (assumed tool)
184
-
185
- **Result:** Documentation describes an "ideal" project, not the actual project.
186
-
187
- **With verification:** Documentation accurately reflects only installed tools and implemented features.
188
-
189
- ---
190
-
191
- ## When to Use `/trinity-docs`
192
-
193
- ### Perfect Use Cases:
194
- ✅ **New Project** - Setting up docs/ for the first time with seeded content
195
- ✅ **Empty docs/** - docs/ exists but contains no useful documentation
196
- ✅ **Disorganized docs/** - Files scattered without structure
197
- ✅ **Missing Navigation** - No docs/README.md to guide users
198
- ✅ **Documentation Growth** - docs/ has grown and needs reorganization
199
- ✅ **Scattered Documentation** - .md files scattered across project
200
- ✅ **Pre-Release** - Ensure documentation is well-organized with starter content
201
-
202
- ### When NOT to Use:
203
- ❌ **Root README Updates** - Use `/trinity-readme` instead
204
- ❌ **CHANGELOG Updates** - Use `/trinity-changelog` instead
205
- ❌ **API Documentation Generation** - Use TypeDoc, Rustdoc, etc. first (this command integrates them)
206
-
207
- ---
208
-
209
- ## Usage
210
-
211
- ### Basic Usage
212
- ```bash
213
- /trinity-docs
214
- ```
215
-
216
- APO performs complete docs/ creation and organization:
217
- 1. Analyzes codebase for project context (framework, tech stack, architecture)
218
- 2. Scans existing docs/ files and scattered documentation
219
- 3. Creates directory structure (guides/, api/, architecture/, reference/, images/)
220
- 4. Seeds initial documentation content based on project type
221
- 5. Migrates scattered .md files into organized structure
222
- 6. Auto-generates architecture documentation
223
- 7. Integrates auto-generated API docs (TypeDoc, etc.)
224
- 8. Validates and fixes documentation links
225
- 9. Generates docs/README.md navigation with coverage metrics
226
- 10. Generates comprehensive organization report
227
-
228
- ---
229
-
230
- ## APO Execution Principles
231
-
232
- ### Unlimited Token Budget
233
-
234
- **CRITICAL: APO has NO token budget limits for this command.**
235
-
236
- **✅ APO MUST:**
237
- 1. Complete ALL 5 phases regardless of token usage
238
- 2. Create ALL seeded content and organize ALL files (no "budget exceeded" stops)
239
- 3. NEVER claim "token budget constraints" as reason for incomplete work
240
-
241
- **❌ APO MUST NOT:**
242
- 1. Stop execution due to token concerns
243
- 2. Skip phases due to "budget constraints"
244
- 3. Defer work to future sessions
245
-
246
- ---
247
-
248
- ## Phase Execution Rules
249
-
250
- **ALL 5 phases are MANDATORY. APO MUST execute phases in sequence.**
251
-
252
- **FORBIDDEN:**
253
- - ❌ Skipping phases
254
- - ❌ "Deferring" phases to future sessions
255
- - ❌ Claiming phases are "optional"
256
-
257
- ---
258
-
259
- ## APO's 5-Phase docs/ Organization Process
260
-
261
- ### Phase 1: Discovery & Codebase Analysis
262
-
263
- **Goal:** Scan existing documentation, detect scattered files, and analyze codebase for context
264
-
265
- **Step 1: Check if docs/ Exists**
266
-
267
- ```bash
268
- # Check if docs/ directory exists
269
- if exists("docs/"):
270
- docs_exists = true
271
- # Scan docs/ directory
272
- Use Glob pattern: "docs/**/*"
273
- else:
274
- docs_exists = false
275
- # Will create structure in Phase 2
276
- ```
277
-
278
- **Step 2: Inventory Existing docs/ Files**
279
-
280
- If docs/ exists:
281
-
282
- ```javascript
283
- docs_files = []
284
- docs_dirs = []
285
-
286
- for each path in glob_results:
287
- if is_file(path):
288
- docs_files.push(path)
289
- else if is_directory(path):
290
- docs_dirs.push(path)
291
-
292
- // Categorize files by type
293
- markdown_files = docs_files.filter(f => f.endsWith('.md'))
294
- image_files = docs_files.filter(f => f.endsWith('.png', '.jpg', '.svg', '.gif'))
295
- html_files = docs_files.filter(f => f.endsWith('.html')) // TypeDoc, etc.
296
- other_files = docs_files.filter(f => not markdown nor image nor html)
297
- ```
298
-
299
- **Step 3: Analyze Current docs/ Structure**
300
-
301
- ```javascript
302
- has_guides_dir = docs_dirs.includes("docs/guides")
303
- has_api_dir = docs_dirs.includes("docs/api")
304
- has_architecture_dir = docs_dirs.includes("docs/architecture")
305
- has_reference_dir = docs_dirs.includes("docs/reference")
306
- has_images_dir = docs_dirs.includes("docs/images")
307
- has_navigation = docs_files.includes("docs/README.md")
308
-
309
- structure_score = (
310
- (has_guides_dir ? 20 : 0) +
311
- (has_api_dir ? 20 : 0) +
312
- (has_architecture_dir ? 20 : 0) +
313
- (has_reference_dir ? 20 : 0) +
314
- (has_navigation ? 20 : 0)
315
- )
316
- ```
317
-
318
- **Step 4: Scan for Scattered Documentation (ENHANCEMENT 3)**
319
-
320
- **CRITICAL: Identify documentation scattered outside docs/ for migration**
321
-
322
- ```bash
323
- # Search entire project for .md files outside docs/
324
- Use Glob: "**/*.md"
325
-
326
- # EXCLUDE these patterns (DO NOT migrate):
327
- excluded_patterns = [
328
- "node_modules/**",
329
- ".git/**",
330
- "docs/**", # Already in docs/
331
- "trinity/**", # Trinity infrastructure - NEVER move
332
- "**/CLAUDE.md", # All CLAUDE.md files - NEVER move
333
- "README.md", # Root README - keep in root
334
- "CHANGELOG.md", # Root CHANGELOG - keep in root
335
- "CONTRIBUTING.md", # Root CONTRIBUTING - keep in root
336
- "LICENSE", # Root LICENSE - keep in root
337
- "CODE_OF_CONDUCT.md", # Root standards - keep in root
338
- "SECURITY.md" # Root standards - keep in root
339
- ]
340
-
341
- scattered_docs = []
342
-
343
- for each file in glob_results:
344
- # Skip if matches excluded patterns
345
- if matches_any(file, excluded_patterns):
346
- continue
347
-
348
- # Categorize by filename/content patterns
349
- category = detect_category(file)
350
-
351
- # Check if it's a technical source README (src/README.md, tests/README.md)
352
- if file.endsWith("/README.md"):
353
- parent_dir = get_parent_directory(file)
354
- if is_source_directory(parent_dir): // src/, tests/, lib/, pkg/, etc.
355
- continue # Keep technical READMEs with source code
356
-
357
- # This is orphaned documentation - mark for migration
358
- scattered_docs.push({
359
- file: file,
360
- suggested_category: category
361
- })
362
-
363
- // Category detection logic
364
- function detect_category(filename):
365
- if matches("architecture*", "design*", "*-architecture", "*-design"):
366
- return "docs/architecture/"
367
-
368
- if matches("api*", "endpoints*", "*-api", "*-endpoints"):
369
- return "docs/api/"
370
-
371
- if matches("guide*", "tutorial*", "how-to*", "*-guide", "*-tutorial"):
372
- return "docs/guides/"
373
-
374
- if matches("*-reference", "spec*", "*-spec", "glossary*"):
375
- return "docs/reference/"
376
-
377
- // Default category
378
- return "docs/guides/"
379
- ```
380
-
381
- **Step 5: Codebase Context Analysis (ENHANCEMENT 1)**
382
-
383
- **CRITICAL: Gather project information to seed relevant documentation**
384
-
385
- ```bash
386
- # Detect project type and extract metadata
387
- project_metadata = {}
388
-
389
- # Check package manifests
390
- if exists("package.json"):
391
- package_json = read("package.json")
392
- project_metadata.type = "Node.js"
393
- project_metadata.name = package_json.name
394
- project_metadata.version = package_json.version
395
- project_metadata.description = package_json.description
396
- project_metadata.dependencies = Object.keys(package_json.dependencies || {})
397
- project_metadata.framework = detect_framework(package_json.dependencies)
398
-
399
- else if exists("Cargo.toml"):
400
- cargo_toml = read("Cargo.toml")
401
- project_metadata.type = "Rust"
402
- project_metadata.name = cargo_toml.package.name
403
- project_metadata.version = cargo_toml.package.version
404
- project_metadata.description = cargo_toml.package.description
405
-
406
- else if exists("pyproject.toml") or exists("setup.py"):
407
- project_metadata.type = "Python"
408
- pyproject = read("pyproject.toml" or "setup.py")
409
- # Extract Python project metadata
410
-
411
- else if exists("pubspec.yaml"):
412
- pubspec = read("pubspec.yaml")
413
- project_metadata.type = "Flutter"
414
- project_metadata.name = pubspec.name
415
- project_metadata.version = pubspec.version
416
-
417
- else if exists("go.mod"):
418
- go_mod = read("go.mod")
419
- project_metadata.type = "Go"
420
- # Extract Go module info
421
-
422
- # Detect framework
423
- function detect_framework(dependencies):
424
- if has("react"): return "React"
425
- if has("next"): return "Next.js"
426
- if has("express"): return "Express"
427
- if has("vue"): return "Vue"
428
- if has("@nestjs"): return "NestJS"
429
- if has("django"): return "Django"
430
- if has("flask"): return "Flask"
431
- if has("fastapi"): return "FastAPI"
432
- return "Unknown"
433
-
434
- # Scan source directory structure
435
- if exists("src/"):
436
- src_structure = analyze_directory_structure("src/")
437
- project_metadata.architecture = detect_architecture_pattern(src_structure)
438
- project_metadata.entry_point = find_entry_point()
439
-
440
- # Detect architecture pattern
441
- function detect_architecture_pattern(structure):
442
- if has_dirs(["controllers", "models", "views"]): return "MVC"
443
- if has_dirs(["components", "pages", "hooks"]): return "React Component Architecture"
444
- if has_dirs(["services", "repositories"]): return "Service Layer Architecture"
445
- if has_dirs(["handlers", "middleware"]): return "Middleware-based Architecture"
446
- return "Modular Architecture"
447
-
448
- # Check for existing documentation candidates
449
- if exists("CONTRIBUTING.md"):
450
- project_metadata.has_contributing = true
451
-
452
- if exists(".env.example"):
453
- project_metadata.has_env_example = true
454
- ```
455
-
456
- **Step 6: Tool & Feature Verification (CRITICAL)**
457
-
458
- **Before creating any documentation content, verify what tools actually exist.**
459
-
460
- **For Node.js/TypeScript Projects:**
461
- ```bash
462
- # Read package.json
463
- package_json = read("package.json")
464
- all_deps = {
465
- ...package_json.dependencies,
466
- ...package_json.devDependencies
467
- }
468
-
469
- # Verify common tools
470
- verified_tools = {
471
- typescript: "typescript" in all_deps,
472
- jest: "jest" in all_deps && exists("jest.config.js" or "jest.config.ts"),
473
- eslint: "eslint" in all_deps && exists(".eslintrc.*" or "eslint.config.js"),
474
- prettier: "prettier" in all_deps && exists(".prettierrc*"),
475
- lighthouse: "lighthouse" in all_deps && exists(".lighthouserc.json"),
476
- webpack: "webpack" in all_deps && exists("webpack.config.js"),
477
- vite: "vite" in all_deps && exists("vite.config.*"),
478
- next: "next" in all_deps,
479
- react: "react" in all_deps
480
- }
481
- ```
482
-
483
- **For Python Projects:**
484
- ```bash
485
- # Check requirements files
486
- deps = []
487
- if exists("requirements.txt"):
488
- deps += read("requirements.txt").lines
489
- if exists("pyproject.toml"):
490
- deps += extract_dependencies("pyproject.toml")
491
-
492
- verified_tools = {
493
- pytest: "pytest" in deps && exists("pytest.ini" or "pyproject.toml[tool.pytest]"),
494
- black: "black" in deps && exists("pyproject.toml[tool.black]"),
495
- mypy: "mypy" in deps && exists("mypy.ini" or "pyproject.toml[tool.mypy]"),
496
- sphinx: "sphinx" in deps && exists("docs/conf.py")
497
- }
498
- ```
499
-
500
- **For Rust Projects:**
501
- ```bash
502
- # Check Cargo.toml
503
- cargo = read("Cargo.toml")
504
- deps = extract_dependencies(cargo)
505
-
506
- verified_tools = {
507
- serde: "serde" in deps,
508
- tokio: "tokio" in deps,
509
- clippy: exists("clippy.toml"),
510
- cargo_deny: exists("deny.toml")
511
- }
512
- ```
513
-
514
- **Verification Report:**
515
- Log what was verified for transparency:
516
- ```
517
- ✅ TypeScript: Found in package.json + tsconfig.json exists
518
- ✅ Jest: Found in package.json + jest.config.js exists
519
- ✅ ESLint: Found in package.json + .eslintrc.js exists
520
- ❌ Lighthouse: NOT in package.json, no .lighthouserc.json → SKIP
521
- ❌ Prettier: NOT in package.json, no .prettierrc → SKIP
522
- ```
523
-
524
- **CRITICAL:** Use this `verified_tools` object in Phase 2 to conditionally create documentation. **Do NOT document unverified tools.**
525
-
526
- **Step 7: Detect Auto-Generated API Documentation (ENHANCEMENT 8)**
527
-
528
- ```bash
529
- # Detect TypeDoc (Node.js/TypeScript)
530
- if exists("docs/index.html") and exists("docs/modules.html"):
531
- project_metadata.api_docs = {
532
- type: "TypeDoc",
533
- location: "docs/",
534
- entry: "index.html"
535
- }
536
-
537
- # Detect JSDoc
538
- if exists("docs/jsdoc/index.html"):
539
- project_metadata.api_docs = {
540
- type: "JSDoc",
541
- location: "docs/jsdoc/",
542
- entry: "index.html"
543
- }
544
-
545
- # Detect Rustdoc
546
- if exists("target/doc/index.html"):
547
- project_metadata.api_docs = {
548
- type: "Rustdoc",
549
- location: "target/doc/",
550
- entry: "index.html"
551
- }
552
-
553
- # Detect Sphinx (Python)
554
- if exists("docs/_build/html/index.html"):
555
- project_metadata.api_docs = {
556
- type: "Sphinx",
557
- location: "docs/_build/html/",
558
- entry: "index.html"
559
- }
560
- ```
561
-
562
- **Step 7: Detect Duplicate Documentation (ENHANCEMENT 6)**
563
-
564
- ```bash
565
- # Find potential duplicates
566
- all_md_files = glob("**/*.md", exclude=excluded_patterns)
567
- duplicates = []
568
-
569
- for each file1 in all_md_files:
570
- title1 = extract_title(file1)
571
-
572
- for each file2 in all_md_files (after file1):
573
- title2 = extract_title(file2)
574
-
575
- # Check for similar titles
576
- if similarity(title1, title2) > 0.8:
577
- duplicates.push({file1, file2, similarity_score})
578
-
579
- # Check for similar content
580
- content_similarity = compare_content(file1, file2)
581
- if content_similarity > 0.7:
582
- duplicates.push({file1, file2, type: "content", similarity_score})
583
- ```
584
-
585
- **APO Output:**
586
-
587
- ```markdown
588
- === PHASE 1: DISCOVERY & CODEBASE ANALYSIS ===
589
-
590
- **docs/ Exists:** {✅ YES | ❌ NO}
591
-
592
- **Current docs/ Files:** {count}
593
- - Markdown files: {count}
594
- - Image files: {count}
595
- - HTML files (TypeDoc/etc): {count}
596
- - Other files: {count}
597
-
598
- **Current docs/ Directories:** {count}
599
- - guides/: {✅ EXISTS | ❌ MISSING}
600
- - api/: {✅ EXISTS | ❌ MISSING}
601
- - architecture/: {✅ EXISTS | ❌ MISSING}
602
- - reference/: {✅ EXISTS | ❌ MISSING}
603
- - images/: {✅ EXISTS | ❌ MISSING}
604
- - Navigation (README.md): {✅ EXISTS | ❌ MISSING}
605
-
606
- **Structure Score:** {structure_score}/100
607
- - 0-25: Needs complete organization
608
- - 26-50: Needs significant organization
609
- - 51-75: Needs minor organization
610
- - 76-100: Well-organized
611
-
612
- **Scattered Documentation Found:** {scattered_docs.length} files
613
- {For each scattered doc:}
614
- - {file} → {suggested_category}
615
-
616
- **Duplicate Documentation:** {duplicates.length} potential duplicates
617
- {For each duplicate:}
618
- - {file1} ↔ {file2} (similarity: {score}%)
619
-
620
- **Project Context:**
621
- - **Type:** {project_metadata.type}
622
- - **Name:** {project_metadata.name}
623
- - **Version:** {project_metadata.version}
624
- - **Framework:** {project_metadata.framework}
625
- - **Architecture:** {project_metadata.architecture}
626
- - **Entry Point:** {project_metadata.entry_point}
627
-
628
- **Auto-Generated API Docs:**
629
- {if api_docs detected:}
630
- - ✅ {api_docs.type} detected at {api_docs.location}
631
- {else:}
632
- - ❌ No auto-generated API docs detected
633
-
634
- **Existing Documentation Assets:**
635
- - CONTRIBUTING.md: {✅ YES | ❌ NO}
636
- - .env.example: {✅ YES | ❌ NO}
637
- ```
638
-
639
- ---
640
-
641
- ### Phase 2: Directory Structure & Content Seeding
642
-
643
- **Goal:** Create hierarchical docs/ structure with seeded initial content
644
-
645
- **🚨 CRITICAL EXECUTION REQUIREMENT:**
646
-
647
- APO MUST use the **Write tool** to create documentation files in this phase.
648
- - Creating directories is NOT enough
649
- - Showing content templates is NOT enough
650
- - APO MUST execute `Write("docs/guides/getting-started.md", content)` commands
651
- - Minimum 4 files MUST be created: getting-started.md, api/README.md, architecture/overview.md, reference/README.md
652
-
653
- **Standard Directory Structure:**
654
-
655
- ```
656
- docs/
657
- ├── README.md (navigation - created in Phase 4)
658
- ├── guides/ (How-to guides, tutorials)
659
- │ └── getting-started.md (seeded)
660
- ├── api/ (API documentation)
661
- │ └── README.md (seeded with project context)
662
- ├── architecture/ (Architecture diagrams, design docs)
663
- │ └── overview.md (auto-generated from codebase)
664
- ├── reference/ (Reference documentation)
665
- │ └── README.md (seeded with CLI commands, env vars)
666
- └── images/ (Images, diagrams, screenshots)
667
- ```
668
-
669
- **Step 1: Create Missing Directories**
670
-
671
- ```javascript
672
- required_dirs = [
673
- "docs/guides",
674
- "docs/api",
675
- "docs/architecture",
676
- "docs/reference",
677
- "docs/images"
678
- ]
679
-
680
- created_dirs = []
681
-
682
- for each dir in required_dirs:
683
- if not exists(dir):
684
- create_directory(dir)
685
- created_dirs.push(dir)
686
- ```
687
-
688
- **Step 2: Seed docs/guides/ Content (ENHANCEMENT 2)**
689
-
690
- **CRITICAL: Create useful starter guides based on project type, not empty placeholders**
691
-
692
- **✅ APO MUST:**
693
- 1. USE Write tool to create docs/guides/getting-started.md with project-specific content
694
- 2. USE Write tool to create framework-specific guides (if applicable)
695
- 3. Content MUST be based on actual project metadata from Phase 1
696
- 4. NO generic placeholders - use real project name, version, dependencies
697
-
698
- **EXECUTION REQUIRED:**
699
- ```javascript
700
- // APO MUST execute these Write commands:
701
-
702
- // 1. Create getting-started.md
703
- Write("docs/guides/getting-started.md", getting_started_content);
704
-
705
- // 2. Create framework-specific guide (if detected)
706
- if (framework === "Express" || framework === "NestJS") {
707
- Write("docs/guides/api-development.md", api_dev_content);
708
- }
709
- if (framework === "React" || framework === "Next.js") {
710
- Write("docs/guides/component-development.md", component_dev_content);
711
- }
712
- if (framework === "Django" || framework === "Flask") {
713
- Write("docs/guides/django-development.md", django_dev_content);
714
- }
715
- ```
716
-
717
- **CONTENT TEMPLATE for docs/guides/getting-started.md:**
718
-
719
- ```markdown
720
-
721
- # Getting Started with {{PROJECT_NAME}}
722
-
723
- **Version:** {{VERSION}}
724
- **Last Updated**: {{CURRENT_DATE}}
725
-
726
- ## Overview
727
-
728
- {project_metadata.description or "This guide will help you get started with {{PROJECT_NAME}}."}
729
-
730
- ## Prerequisites
731
-
732
- {if project_metadata.type === "Node.js":}
733
- - Node.js ≥ {extract from package.json engines or "16.0.0"}
734
- - npm or yarn package manager
735
-
736
- {if project_metadata.type === "Python":}
737
- - Python ≥ {extract from pyproject.toml or "3.8"}
738
- - pip package manager
739
-
740
- {if project_metadata.type === "Rust":}
741
- - Rust {extract from Cargo.toml or "latest stable"}
742
- - Cargo build tool
743
-
744
- {if project_metadata.type === "Flutter":}
745
- - Flutter SDK {extract from pubspec.yaml or "latest"}
746
- - Dart SDK
747
-
748
- ## Installation
749
-
750
- {if project_metadata.type === "Node.js":}
751
- ```bash
752
- # Clone the repository
753
- git clone {repository URL from package.json or placeholder}
754
- cd {{PROJECT_NAME}}
755
-
756
- # Install dependencies
757
- npm install
758
-
759
- # Run development server
760
- npm run dev
761
- ```
762
-
763
- {if project_metadata.type === "Python":}
764
- ```bash
765
- # Clone the repository
766
- git clone {repository URL}
767
- cd {{PROJECT_NAME}}
768
-
769
- # Create virtual environment
770
- python -m venv venv
771
- source venv/bin/activate # On Windows: venv\Scripts\activate
772
-
773
- # Install dependencies
774
- pip install -r requirements.txt
775
-
776
- # Run application
777
- python main.py
778
- ```
779
-
780
- {if project_metadata.type === "Rust":}
781
- ```bash
782
- # Clone the repository
783
- git clone {repository URL}
784
- cd {{PROJECT_NAME}}
785
-
786
- # Build project
787
- cargo build
788
-
789
- # Run project
790
- cargo run
791
- ```
792
-
793
- ## Project Structure
794
-
795
- ```
796
- {actual src/ directory structure from Phase 1 scan}
797
- ```
798
-
799
- ## Next Steps
800
-
801
- - [API Documentation](../api/) - Learn about available APIs
802
- - [Architecture Overview](../architecture/overview.md) - Understand system design
803
- {if has CONTRIBUTING.md:}
804
- - [Contributing Guide](../../CONTRIBUTING.md) - Contribute to the project
805
-
806
- ## Common Issues
807
-
808
- {if project_metadata.type === "Node.js":}
809
- ### "Module not found" errors
810
- - Ensure you've run `npm install`
811
- - Clear node_modules and reinstall: `rm -rf node_modules && npm install`
812
-
813
- {if project_metadata.type === "Python":}
814
- ### Import errors
815
- - Ensure virtual environment is activated
816
- - Reinstall dependencies: `pip install -r requirements.txt`
817
-
818
- ## Support
819
-
820
- {Placeholder for support information}
821
- - GitHub Issues: [repository]/issues
822
- - Documentation: [docs/](../)
823
- ```
824
-
825
- **Create Framework-Specific Guides (ENHANCEMENT 10)**
826
-
827
- ```markdown
828
- {if framework === "Express":}
829
- ### docs/guides/api-development.md
830
-
831
- # API Development Guide
832
-
833
- ## Creating Routes
834
-
835
- ```javascript
836
- // src/routes/example.js
837
- const express = require('express');
838
- const router = express.Router();
839
-
840
- router.get('/example', (req, res) => {
841
- res.json({ message: 'Example endpoint' });
842
- });
843
-
844
- module.exports = router;
845
- ```
846
-
847
- ## Middleware
848
-
849
- {Examples based on detected middleware patterns in codebase}
850
-
851
- ## Error Handling
852
-
853
- {if error handling patterns detected, show them}
854
-
855
- {if framework === "React":}
856
- ### docs/guides/component-development.md
857
-
858
- # Component Development Guide
859
-
860
- ## Component Structure
861
-
862
- ```jsx
863
- // Functional Component Example
864
- import React from 'react';
865
-
866
- export const ExampleComponent = ({ prop1, prop2 }) => {
867
- return (
868
- <div>
869
- {/* Component content */}
870
- </div>
871
- );
872
- };
873
- ```
874
-
875
- ## State Management
876
-
877
- {if Redux detected: show Redux patterns}
878
- {if Context API detected: show Context patterns}
879
-
880
- {if framework === "Django":}
881
- ### docs/guides/django-development.md
882
-
883
- # Django Development Guide
884
-
885
- ## Creating Apps
886
-
887
- ```bash
888
- python manage.py startapp myapp
889
- ```
890
-
891
- ## Models and Migrations
892
-
893
- {Examples of model creation and migration workflow}
894
-
895
- ## Admin Panel
896
-
897
- {Django admin setup instructions}
898
- ```
899
-
900
- **Step 3: Seed docs/api/ Content (ENHANCEMENT 2 + 8)**
901
-
902
- **✅ APO MUST:**
903
- 1. USE Write tool to create docs/api/README.md
904
- 2. Include links to auto-generated API docs if detected in Phase 1
905
- 3. If no auto-generated docs, create basic API documentation structure
906
-
907
- **EXECUTION REQUIRED:**
908
- ```javascript
909
- // APO MUST execute this Write command:
910
- Write("docs/api/README.md", api_readme_content);
911
- ```
912
-
913
- **CONTENT TEMPLATE for docs/api/README.md:**
914
-
915
- ```markdown
916
-
917
- # API Documentation
918
-
919
- {if project_metadata.api_docs (TypeDoc/Rustdoc/etc):}
920
-
921
- **Auto-Generated API Reference:** [{api_docs.type}]({api_docs.entry})
922
-
923
- Full API documentation is available in the auto-generated {api_docs.type} documentation.
924
-
925
- {else if framework matches API framework (Express, FastAPI, etc):}
926
-
927
- **{project_metadata.name}** API documentation.
928
-
929
- ## Endpoints
930
-
931
- {if Express and routes detected:}
932
- ### Available Routes
933
-
934
- {scan src/ for route files and list endpoints}
935
-
936
- - `GET /api/example` - Example endpoint
937
- {list actual detected routes from codebase}
938
-
939
- ## Authentication
940
-
941
- {if authentication patterns detected, document them}
942
-
943
- ## Request/Response Format
944
-
945
- All API responses follow this format:
946
-
947
- ```json
948
- {
949
- "success": true,
950
- "data": {},
951
- "error": null
952
- }
953
- ```
954
-
955
- {else:}
956
-
957
- API documentation for {{PROJECT_NAME}}.
958
-
959
- ## Overview
960
-
961
- {Framework-specific API documentation guidance}
962
-
963
- {if project_metadata.type === "Node.js":}
964
- Consider using tools like:
965
- - Swagger/OpenAPI for REST APIs
966
- - GraphQL documentation for GraphQL APIs
967
- - TypeDoc for TypeScript API reference
968
-
969
- {if project_metadata.type === "Python":}
970
- Consider using tools like:
971
- - Sphinx for Python API reference
972
- - FastAPI automatic documentation (available at /docs)
973
- - Django REST Framework browsable API
974
- ```
975
-
976
- **Step 4: Auto-Generate docs/architecture/overview.md (ENHANCEMENT 4)**
977
-
978
- **CRITICAL: Create real architecture documentation from codebase analysis**
979
-
980
- **✅ APO MUST:**
981
- 1. USE Write tool to create docs/architecture/overview.md
982
- 2. Content MUST be auto-generated from Phase 1 codebase analysis
983
- 3. Include actual directory structure, detected patterns, entry points
984
- 4. NO generic templates - use real project metadata
985
-
986
- **EXECUTION REQUIRED:**
987
- ```javascript
988
- // APO MUST execute this Write command:
989
- Write("docs/architecture/overview.md", architecture_overview_content);
990
- ```
991
-
992
- **CONTENT TEMPLATE for docs/architecture/overview.md:**
993
-
994
- ```markdown
995
-
996
- # Architecture Overview
997
-
998
- **Project:** {{PROJECT_NAME}}
999
- **Type:** {project_metadata.type}
1000
- **Framework:** {project_metadata.framework}
1001
- **Version:** {project_metadata.version}
1002
- **Last Updated**: {{CURRENT_DATE}}
1003
-
1004
- ## System Overview
1005
-
1006
- {project_metadata.description}
1007
-
1008
- ## Technology Stack
1009
-
1010
- **Runtime/Language:** {project_metadata.type} {version}
1011
- **Framework:** {project_metadata.framework}
1012
-
1013
- {if project_metadata.type === "Node.js":}
1014
- **Package Manager:** npm/yarn
1015
- **Build Tool:** {detect from package.json scripts}
1016
-
1017
- {if project_metadata.dependencies.length > 0:}
1018
- **Key Dependencies:**
1019
- {list major dependencies from package.json}
1020
- - {dependency}: {purpose detected or version}
1021
-
1022
- {if database detected:}
1023
- **Database:** {detected database from dependencies}
1024
-
1025
- ## Architecture Pattern
1026
-
1027
- **Pattern:** {project_metadata.architecture}
1028
-
1029
- {if architecture === "MVC":}
1030
- This project follows the Model-View-Controller (MVC) architectural pattern:
1031
- - **Models:** Data structures and business logic
1032
- - **Views:** Presentation layer
1033
- - **Controllers:** Request handling and coordination
1034
-
1035
- {if architecture === "React Component Architecture":}
1036
- This project follows React's component-based architecture:
1037
- - **Components:** Reusable UI building blocks
1038
- - **Pages:** Top-level route components
1039
- - **Hooks:** Custom React hooks for shared logic
1040
- - **Context:** Global state management
1041
-
1042
- {if architecture === "Service Layer Architecture":}
1043
- This project uses a service-oriented architecture:
1044
- - **Services:** Business logic layer
1045
- - **Repositories:** Data access layer
1046
- - **Controllers:** API endpoint handlers
1047
-
1048
- ## Directory Structure
1049
-
1050
- ```
1051
- {actual src/ directory structure from Phase 1 analysis}
1052
- ```
1053
-
1054
- **Key Directories:**
1055
- {for each major directory in src/:}
1056
- - **{directory}:** {purpose based on name/content}
1057
-
1058
- ## Entry Points
1059
-
1060
- {if project_metadata.entry_point:}
1061
- **Main Entry:** {entry_point}
1062
-
1063
- {if CLI commands detected from package.json:}
1064
- **CLI Commands:**
1065
- {list npm scripts or CLI commands}
1066
- - `{command}`: {purpose}
1067
-
1068
- ## Data Flow
1069
-
1070
- {if architecture pattern is recognized, describe typical data flow}
1071
-
1072
- {if API framework:}
1073
- 1. Request received at endpoint
1074
- 2. Middleware processing
1075
- 3. Controller handles request
1076
- 4. Service layer executes business logic
1077
- 5. Repository accesses data
1078
- 6. Response sent to client
1079
-
1080
- ## Configuration
1081
-
1082
- {if .env.example exists:}
1083
- **Environment Variables:** See [.env.example](../../.env.example)
1084
-
1085
- {list detected config files:}
1086
- **Configuration Files:**
1087
- - {config file}: {purpose}
1088
-
1089
- ## Build & Deployment
1090
-
1091
- {from package.json scripts or build system:}
1092
- **Build Command:** `{build command}`
1093
- **Development:** `{dev command}`
1094
- **Production:** `{start command}`
1095
-
1096
- ## Architecture Diagrams
1097
-
1098
- *Architecture diagrams can be added to the [images/](../images/) directory and linked here.*
1099
-
1100
- Recommended diagrams:
1101
- - System architecture diagram
1102
- - Component interaction diagram
1103
- - Data flow diagram
1104
- - Deployment architecture
1105
-
1106
- ## Design Decisions
1107
-
1108
- {if ADR files detected, link to them}
1109
-
1110
- Key architectural decisions are documented in:
1111
- - [Architecture Decision Records](adr/) - ADRs documenting major technical decisions
1112
-
1113
- ## Performance Considerations
1114
-
1115
- {Framework-specific performance guidance}
1116
-
1117
- ## Security Considerations
1118
-
1119
- {Framework-specific security guidance}
1120
-
1121
- ---
1122
-
1123
- For detailed API documentation, see [../api/](../api/).
1124
- ```
1125
-
1126
- **Step 5: Seed docs/reference/ Content (ENHANCEMENT 2)**
1127
-
1128
- **✅ APO MUST:**
1129
- 1. USE Write tool to create docs/reference/README.md
1130
- 2. Include actual CLI commands from package.json scripts
1131
- 3. Document environment variables if .env.example exists
1132
- 4. List configuration options if detected
1133
-
1134
- **EXECUTION REQUIRED:**
1135
- ```javascript
1136
- // APO MUST execute this Write command:
1137
- Write("docs/reference/README.md", reference_readme_content);
1138
- ```
1139
-
1140
- **CONTENT TEMPLATE for docs/reference/README.md:**
1141
-
1142
- ```markdown
1143
-
1144
- # Reference Documentation
1145
-
1146
- Quick reference materials for {{PROJECT_NAME}}.
1147
-
1148
- ## CLI Commands
1149
-
1150
- {if package.json scripts detected:}
1151
- ### npm Scripts
1152
-
1153
- {for each script in package.json.scripts:}
1154
- - **`npm run {script}`** - {infer purpose from script name or command}
1155
-
1156
- {if Makefile detected:}
1157
- ### Make Commands
1158
-
1159
- {for each target in Makefile:}
1160
- - **`make {target}`** - {purpose}
1161
-
1162
- ## Environment Variables
1163
-
1164
- {if .env.example exists:}
1165
- See [.env.example](../../.env.example) for all available environment variables.
1166
-
1167
- **Required Variables:**
1168
- {parse .env.example and list required vars}
1169
- - `{VAR_NAME}` - {purpose}
1170
-
1171
- ## Configuration
1172
-
1173
- {list detected config files and their purpose}
1174
-
1175
- ## API Reference
1176
-
1177
- {if auto-generated API docs:}
1178
- See [API Documentation](../api/) for complete API reference.
1179
-
1180
- ## Dependencies
1181
-
1182
- **Production Dependencies:** {count}
1183
- {list major production dependencies}
1184
-
1185
- **Development Dependencies:** {count}
1186
- {list major dev dependencies}
1187
-
1188
- ## Glossary
1189
-
1190
- {Project-specific terminology}
1191
- ```
1192
-
1193
- **Step 6: Migrate CONTRIBUTING.md to Reference (if exists)**
1194
-
1195
- ```bash
1196
- if exists("CONTRIBUTING.md"):
1197
- # Don't move the file, but reference it from docs/reference/
1198
- # Add link in docs/reference/README.md
1199
- ```
1200
-
1201
- **Step 7: Create Category README Files**
1202
-
1203
- For each category, create README.md that lists actual content:
1204
-
1205
- ```markdown
1206
- ### docs/guides/README.md
1207
-
1208
- # Guides
1209
-
1210
- User guides and tutorials for {{PROJECT_NAME}}.
1211
-
1212
- ## Available Guides
1213
-
1214
- {if getting-started.md created:}
1215
- - [Getting Started](getting-started.md) - Quick start guide for new users
1216
-
1217
- {if framework-specific guide created:}
1218
- - [{Framework} Development](....md) - {Framework}-specific development guide
1219
-
1220
- {if scattered docs migrated to guides/:}
1221
- {list migrated files}
1222
-
1223
- ## Planned Guides
1224
-
1225
- *Additional guides can be added to this directory. Common guide topics include:*
1226
- - Deployment guide
1227
- - Testing guide
1228
- - Troubleshooting guide
1229
- - Advanced features guide
1230
-
1231
- ## Contributing
1232
-
1233
- To add a new guide:
1234
- 1. Create a new .md file in this directory
1235
- 2. Follow the guide template format:
1236
- - Clear title and objective
1237
- - Prerequisites section
1238
- - Step-by-step instructions
1239
- - Expected outcomes
1240
- - Troubleshooting tips
1241
- 3. Update this README with a link to your guide
1242
-
1243
- ---
1244
-
1245
- See [../README.md](../README.md) for complete documentation index.
1246
- ```
1247
-
1248
- ```markdown
1249
- ### docs/api/README.md
1250
-
1251
- {Content from Step 3 - already seeded with project-specific info}
1252
- ```
1253
-
1254
- ```markdown
1255
- ### docs/architecture/README.md
1256
-
1257
- # Architecture Documentation
1258
-
1259
- System architecture and design documentation for {{PROJECT_NAME}}.
1260
-
1261
- ## Architecture Overview
1262
-
1263
- **Main Document:** [Architecture Overview](overview.md) - Complete system architecture
1264
-
1265
- {if ADR directory exists or should be created:}
1266
- ## Architecture Decision Records (ADRs)
1267
-
1268
- *Architecture Decision Records document significant architectural decisions made during development.*
1269
-
1270
- {if ADR files exist:}
1271
- {list ADR files}
1272
-
1273
- {else:}
1274
- ADRs can be added to the `adr/` subdirectory following the [ADR template format](https://github.com/joelparkerhenderson/architecture-decision-record).
1275
-
1276
- ## Architecture Diagrams
1277
-
1278
- {if images/ has architecture diagrams:}
1279
- {list diagram files}
1280
-
1281
- {else:}
1282
- *Architecture diagrams can be added to [../images/](../images/) directory.*
1283
-
1284
- Recommended diagrams:
1285
- - System architecture diagram
1286
- - Component interaction diagram
1287
- - Data flow diagram
1288
- - Deployment architecture
1289
-
1290
- ## Technology Stack
1291
-
1292
- See [Architecture Overview](overview.md#technology-stack) for complete technology stack details.
1293
-
1294
- ---
1295
-
1296
- See [../README.md](../README.md) for complete documentation index.
1297
- ```
1298
-
1299
- ```markdown
1300
- ### docs/reference/README.md
1301
-
1302
- {Content from Step 5 - already seeded with CLI commands, env vars}
1303
- ```
1304
-
1305
- **Phase 2 Execution Summary:**
1306
-
1307
- **✅ MANDATORY FILE CREATIONS:**
1308
-
1309
- APO MUST have executed Write tool for these files (minimum required):
1310
- 1. ✅ docs/guides/getting-started.md
1311
- 2. ✅ docs/api/README.md
1312
- 3. ✅ docs/architecture/overview.md
1313
- 4. ✅ docs/reference/README.md
1314
-
1315
- **Optional (based on detected framework):**
1316
- - docs/guides/{framework}-development.md (if Express/React/Django/etc detected)
1317
-
1318
- **VERIFICATION:**
1319
-
1320
- If APO did NOT create these files using Write tool, APO has FAILED Phase 2.
1321
-
1322
- **APO Output:**
1323
-
1324
- ```markdown
1325
- === PHASE 2: DIRECTORY STRUCTURE & CONTENT SEEDING ===
1326
-
1327
- **Directories Created:** {created_dirs.length}
1328
- - ✅ docs/guides/
1329
- - ✅ docs/api/
1330
- - ✅ docs/architecture/
1331
- - ✅ docs/reference/
1332
- - ✅ docs/images/
1333
-
1334
- **Files Created with Write Tool:** {count} files
1335
-
1336
- **VERIFICATION - Files Created:**
1337
-
1338
- **Guides:**
1339
- - ✅ docs/guides/getting-started.md ({line_count} lines)
1340
- {if framework-specific guide created:}
1341
- - ✅ docs/guides/{framework}-development.md ({line_count} lines)
1342
-
1343
- **API Documentation:**
1344
- - ✅ docs/api/README.md ({line_count} lines)
1345
- {if TypeDoc integrated:}
1346
- - ✅ Integrated {api_docs.type} documentation
1347
-
1348
- **Architecture:**
1349
- - ✅ docs/architecture/overview.md ({line_count} lines) - AUTO-GENERATED from codebase
1350
- {if ADR directory created:}
1351
- - ✅ docs/architecture/adr/ directory created
1352
-
1353
- **Reference:**
1354
- - ✅ docs/reference/README.md ({line_count} lines)
1355
-
1356
- **Category READMEs:** 4 files
1357
- - ✅ docs/guides/README.md
1358
- - ✅ docs/api/README.md
1359
- - ✅ docs/architecture/README.md
1360
- - ✅ docs/reference/README.md
1361
-
1362
- **Project Context Used:**
1363
- - Type: {project_metadata.type}
1364
- - Framework: {project_metadata.framework}
1365
- - Architecture: {project_metadata.architecture}
1366
- - Dependencies: {major_deps_count} major dependencies documented
1367
- ```
1368
-
1369
- ---
1370
-
1371
- ### Phase 3: Scattered Documentation Migration
1372
-
1373
- **Goal:** Migrate scattered .md files into organized docs/ structure
1374
-
1375
- **CRITICAL: Only migrate orphaned documentation, preserve Trinity infrastructure**
1376
-
1377
- **Step 1: Review Migration Candidates**
1378
-
1379
- ```javascript
1380
- // From Phase 1 Step 4 - scattered_docs array
1381
-
1382
- migration_plan = []
1383
-
1384
- for each doc in scattered_docs:
1385
- // Verify file still exists and should be migrated
1386
- if exists(doc.file) and not is_excluded(doc.file):
1387
- migration_plan.push({
1388
- source: doc.file,
1389
- destination: doc.suggested_category + extract_filename(doc.file),
1390
- action: "MOVE"
1391
- })
1392
- ```
1393
-
1394
- **Step 2: Execute Migration**
1395
-
1396
- ```bash
1397
- migrated_files = []
1398
- migration_errors = []
1399
-
1400
- for each item in migration_plan:
1401
- try:
1402
- # Create destination directory if needed
1403
- ensure_directory_exists(item.destination)
1404
-
1405
- # Move file to new location
1406
- move_file(item.source, item.destination)
1407
-
1408
- migrated_files.push(item)
1409
- catch error:
1410
- migration_errors.push({item, error})
1411
- ```
1412
-
1413
- **Step 3: Update Internal Links (ENHANCEMENT 5 - partial)**
1414
-
1415
- ```bash
1416
- # After migration, update links in migrated files
1417
- for each migrated_file in migrated_files:
1418
- content = read(migrated_file.destination)
1419
-
1420
- # Update relative links that may have broken
1421
- updated_content = update_relative_links(content, migrated_file.source, migrated_file.destination)
1422
-
1423
- if updated_content != content:
1424
- write(migrated_file.destination, updated_content)
1425
- ```
1426
-
1427
- **Step 4: Update Category READMEs**
1428
-
1429
- ```bash
1430
- # Add migrated files to appropriate category READMEs
1431
- for each migrated_file in migrated_files:
1432
- category_readme = get_category_readme(migrated_file.destination)
1433
-
1434
- # Add link to migrated file in category README
1435
- append_to_section(category_readme, "Available {Category}", link_to_file)
1436
- ```
1437
-
1438
- **APO Output:**
1439
-
1440
- ```markdown
1441
- === PHASE 3: SCATTERED DOCUMENTATION MIGRATION ===
1442
-
1443
- **Migration Summary:**
1444
- - Files migrated: {migrated_files.length}
1445
- - Migration errors: {migration_errors.length}
1446
-
1447
- **Migrated Files:**
1448
- {for each migrated:}
1449
- - ✅ {source} → {destination}
1450
-
1451
- {if migration_errors.length > 0:}
1452
- **Migration Errors:**
1453
- {for each error:}
1454
- - ❌ {item.source}: {error.message}
1455
-
1456
- **Files NOT Migrated (Preserved):**
1457
- - Trinity infrastructure (trinity/**): {count} files
1458
- - CLAUDE.md files: {count} files
1459
- - Root standards (README, CHANGELOG, etc.): {count} files
1460
- - Technical source READMEs (src/README.md, etc.): {count} files
1461
-
1462
- **Link Updates:** {count} files with updated links
1463
-
1464
- **Category Updates:**
1465
- {for each category:}
1466
- - docs/{category}/README.md: Added {count} migrated files
1467
- ```
1468
-
1469
- ---
1470
-
1471
- ### Phase 4: Link Validation & Navigation Creation
1472
-
1473
- **Goal:** Validate all documentation links, fix broken links, and create comprehensive navigation
1474
-
1475
- **Step 1: Extract All Links from Documentation (ENHANCEMENT 5)**
1476
-
1477
- ```bash
1478
- all_docs_files = glob("docs/**/*.md")
1479
- all_links = []
1480
-
1481
- for each doc_file in all_docs_files:
1482
- content = read(doc_file)
1483
-
1484
- # Extract markdown links [text](path)
1485
- links = extract_markdown_links(content)
1486
-
1487
- for each link in links:
1488
- all_links.push({
1489
- source_file: doc_file,
1490
- link_text: link.text,
1491
- link_path: link.path,
1492
- line_number: link.line
1493
- })
1494
- ```
1495
-
1496
- **Step 2: Validate Links**
1497
-
1498
- ```bash
1499
- broken_links = []
1500
- valid_links = []
1501
-
1502
- for each link in all_links:
1503
- # Skip external URLs (http://, https://)
1504
- if is_external_url(link.link_path):
1505
- continue
1506
-
1507
- # Resolve relative path
1508
- resolved_path = resolve_path(link.source_file, link.link_path)
1509
-
1510
- # Check if linked file exists
1511
- if exists(resolved_path):
1512
- valid_links.push(link)
1513
- else:
1514
- broken_links.push({
1515
- link: link,
1516
- resolved_path: resolved_path,
1517
- error: "File not found"
1518
- })
1519
- ```
1520
-
1521
- **Step 3: Fix Broken Links**
1522
-
1523
- ```bash
1524
- fixed_links = []
1525
- unfixable_links = []
1526
-
1527
- for each broken_link in broken_links:
1528
- # Try to find the correct path
1529
- filename = extract_filename(broken_link.resolved_path)
1530
-
1531
- # Search for file in docs/
1532
- possible_matches = glob(f"docs/**/{filename}")
1533
-
1534
- if possible_matches.length === 1:
1535
- # Found unique match - fix the link
1536
- correct_path = calculate_relative_path(
1537
- broken_link.link.source_file,
1538
- possible_matches[0]
1539
- )
1540
-
1541
- # Update link in source file
1542
- update_link_in_file(
1543
- broken_link.link.source_file,
1544
- broken_link.link.link_path,
1545
- correct_path
1546
- )
1547
-
1548
- fixed_links.push({broken_link, correct_path})
1549
-
1550
- else if possible_matches.length > 1:
1551
- # Multiple matches - can't auto-fix
1552
- unfixable_links.push({
1553
- broken_link,
1554
- reason: "Multiple possible matches",
1555
- matches: possible_matches
1556
- })
1557
-
1558
- else:
1559
- # No matches - file doesn't exist
1560
- unfixable_links.push({
1561
- broken_link,
1562
- reason: "File not found in docs/"
1563
- })
1564
- ```
1565
-
1566
- **Step 4: Generate docs/README.md Navigation**
1567
-
1568
- ```markdown
1569
- ### docs/README.md
1570
-
1571
- # Documentation
1572
-
1573
- Comprehensive documentation for {{PROJECT_NAME}}.
1574
-
1575
- ## Documentation Structure
1576
-
1577
- This directory contains organized project documentation:
1578
-
1579
- - **[Guides](guides/)** - How-to guides and tutorials
1580
- - **[API](api/)** - API reference documentation
1581
- {if api_docs detected:}
1582
- - [{api_docs.type} Reference]({api_docs.entry}) - Auto-generated API documentation
1583
- - **[Architecture](architecture/)** - System architecture and design decisions
1584
- - **[Reference](reference/)** - Quick references and command guides
1585
-
1586
- ## Quick Start
1587
-
1588
- New to {{PROJECT_NAME}}? Start here:
1589
-
1590
- 1. **[Getting Started Guide](guides/getting-started.md)** - Installation and setup
1591
- {if framework-specific guide exists:}
1592
- 2. **[{Framework} Development](guides/{framework}-development.md)** - Framework-specific development guide
1593
- 3. **[Architecture Overview](architecture/overview.md)** - Understand the system design
1594
- {if API documentation exists:}
1595
- 4. **[API Documentation](api/)** - Explore available APIs
1596
-
1597
- ## Documentation Categories
1598
-
1599
- ### Guides
1600
-
1601
- {list actual guide files from docs/guides/, exclude README.md}
1602
- - [Getting Started](guides/getting-started.md) - Quick start for new users
1603
- {for each guide file:}
1604
- - [{title}]({path}) - {extract description from file}
1605
-
1606
- {if guides/ is empty or only has README:}
1607
- *No additional guides available yet. See [guides/README.md](guides/README.md) for planned guides.*
1608
-
1609
- ### API Documentation
1610
-
1611
- {if TypeDoc/Rustdoc/etc detected:}
1612
- **[{api_docs.type} Reference]({api_docs.entry})** - Auto-generated API documentation
1613
-
1614
- {list actual API doc files from docs/api/, exclude README.md}
1615
- {for each API doc:}
1616
- - [{title}]({path}) - {description}
1617
-
1618
- {if api/ has only README or TypeDoc:}
1619
- See [api/README.md](api/) for API overview and documentation links.
1620
-
1621
- ### Architecture
1622
-
1623
- {list actual architecture files from docs/architecture/, exclude README.md}
1624
- - [Architecture Overview](architecture/overview.md) - System design and technology stack
1625
-
1626
- {if ADR files exist:}
1627
- **Architecture Decision Records:**
1628
- {for each ADR:}
1629
- - [{ADR title}]({path}) - {decision summary}
1630
-
1631
- {if architecture diagrams exist in images/:}
1632
- **Architecture Diagrams:**
1633
- {for each diagram:}
1634
- - [{diagram name}]({path})
1635
-
1636
- ### Reference
1637
-
1638
- {list actual reference files from docs/reference/, exclude README.md}
1639
- - [Reference Documentation](reference/README.md) - CLI commands, environment variables, glossary
1640
-
1641
- ## Documentation Standards
1642
-
1643
- - All documentation is in Markdown format
1644
- - Images are stored in `images/` directory
1645
- - Each category has its own README for navigation
1646
- {if ADR directory exists:}
1647
- - Architecture decisions are documented using ADR format
1648
-
1649
- ## Contributing to Documentation
1650
-
1651
- {if CONTRIBUTING.md exists:}
1652
- See [CONTRIBUTING.md](../CONTRIBUTING.md) for documentation contribution guidelines.
1653
-
1654
- {else:}
1655
- To contribute to documentation:
1656
- 1. Follow the existing structure (guides/, api/, architecture/, reference/)
1657
- 2. Use clear, concise Markdown
1658
- 3. Include code examples where applicable
1659
- 4. Update category README files when adding new documentation
1660
- 5. Validate all links before submitting
1661
-
1662
- ## Documentation Index
1663
-
1664
- ### All Documentation Files
1665
-
1666
- {alphabetical index of all .md files in docs/, organized by category}
1667
-
1668
- **Guides ({count}):**
1669
- {for each guide, alphabetically:}
1670
- - [{title}]({path})
1671
-
1672
- **API Documentation ({count}):**
1673
- {for each API doc, alphabetically:}
1674
- - [{title}]({path})
1675
-
1676
- **Architecture ({count}):**
1677
- {for each architecture doc, alphabetically:}
1678
- - [{title}]({path})
1679
-
1680
- **Reference ({count}):**
1681
- {for each reference doc, alphabetically:}
1682
- - [{title}]({path})
1683
-
1684
- ---
1685
-
1686
- ***Last Updated**: {{CURRENT_DATE}}*
1687
- ```
1688
-
1689
- **Step 5: Build Complete Documentation Index**
1690
-
1691
- ```javascript
1692
- all_docs = []
1693
-
1694
- // Scan all subdirectories
1695
- for each category in ["guides", "api", "architecture", "reference"]:
1696
- files = glob(f"docs/{category}/**/*.md")
1697
- for each file in files:
1698
- if file != "README.md":
1699
- all_docs.push({
1700
- title: extract_title_from_file(file),
1701
- path: file,
1702
- category: category,
1703
- description: extract_description(file)
1704
- })
1705
-
1706
- // Sort alphabetically
1707
- all_docs.sort_by_title()
1708
- ```
1709
-
1710
- **APO Output:**
1711
-
1712
- ```markdown
1713
- === PHASE 4: LINK VALIDATION & NAVIGATION CREATION ===
1714
-
1715
- **Link Validation:**
1716
- - Total links found: {all_links.length}
1717
- - Valid links: {valid_links.length}
1718
- - Broken links: {broken_links.length}
1719
- - Fixed links: {fixed_links.length}
1720
- - Unfixable links: {unfixable_links.length}
1721
-
1722
- **Broken Links Fixed:**
1723
- {for each fixed_link:}
1724
- - ✅ {source_file}: {old_path} → {new_path}
1725
-
1726
- {if unfixable_links.length > 0:}
1727
- **Unfixable Links (Manual Review Required):**
1728
- {for each unfixable:}
1729
- - ⚠️ {source_file}:{line_number}: [{link_text}]({link_path})
1730
- - Reason: {reason}
1731
- {if multiple matches:}
1732
- - Possible matches: {list matches}
1733
-
1734
- **Navigation Creation:**
1735
- - ✅ docs/README.md created ({line_count} lines)
1736
-
1737
- **Documentation Index:**
1738
- - Total files indexed: {all_docs.length}
1739
- - Guides: {guides_count}
1740
- - API docs: {api_count}
1741
- - Architecture docs: {architecture_count}
1742
- - Reference docs: {reference_count}
1743
-
1744
- **Quick Links:** {count} essential documentation files highlighted
1745
- ```
1746
-
1747
- ---
1748
-
1749
- ### Phase 5: Organization Report & Coverage Metrics
1750
-
1751
- **APO Generates:** `trinity/reports/DOCS-ORGANIZATION-{date}.md`
1752
-
1753
- **Step 1: Calculate Documentation Coverage Metrics (ENHANCEMENT 9)**
1754
-
1755
- ```javascript
1756
- coverage_metrics = {
1757
- structure: 0,
1758
- content: 0,
1759
- navigation: 0,
1760
- total: 0
1761
- }
1762
-
1763
- // Structure score (30 points)
1764
- structure_score = 0
1765
- if exists("docs/guides/"): structure_score += 6
1766
- if exists("docs/api/"): structure_score += 6
1767
- if exists("docs/architecture/"): structure_score += 6
1768
- if exists("docs/reference/"): structure_score += 6
1769
- if exists("docs/images/"): structure_score += 6
1770
-
1771
- coverage_metrics.structure = structure_score
1772
-
1773
- // Content score (50 points)
1774
- content_score = 0
1775
-
1776
- // Guides content (15 points)
1777
- guides_files = glob("docs/guides/*.md", exclude="README.md")
1778
- if guides_files.length >= 1: content_score += 5 // Getting started exists
1779
- if guides_files.length >= 2: content_score += 5 // Framework guide exists
1780
- if guides_files.length >= 3: content_score += 5 // Additional guides
1781
-
1782
- // API documentation (15 points)
1783
- if api_docs detected or exists("docs/api/*.md"): content_score += 15
1784
-
1785
- // Architecture documentation (15 points)
1786
- if exists("docs/architecture/overview.md"): content_score += 10
1787
- if exists("docs/architecture/adr/*"): content_score += 5
1788
-
1789
- // Reference documentation (5 points)
1790
- if exists("docs/reference/README.md") and has_content: content_score += 5
1791
-
1792
- coverage_metrics.content = content_score
1793
-
1794
- // Navigation score (20 points)
1795
- navigation_score = 0
1796
- if exists("docs/README.md"): navigation_score += 10
1797
- if all category READMEs exist: navigation_score += 10
1798
-
1799
- coverage_metrics.navigation = navigation_score
1800
-
1801
- // Total coverage
1802
- coverage_metrics.total = structure_score + content_score + navigation_score
1803
-
1804
- // Grade
1805
- if coverage_metrics.total >= 90: grade = "A (Excellent)"
1806
- else if coverage_metrics.total >= 80: grade = "B (Good)"
1807
- else if coverage_metrics.total >= 70: grade = "C (Fair)"
1808
- else if coverage_metrics.total >= 60: grade = "D (Needs Improvement)"
1809
- else: grade = "F (Poor)"
1810
- ```
1811
-
1812
- **Step 2: Generate Actionable Recommendations for Empty Categories (ENHANCEMENT 7)**
1813
-
1814
- ```javascript
1815
- recommendations = []
1816
-
1817
- // Check guides/
1818
- guides_count = count_md_files("docs/guides/", exclude="README.md")
1819
- if guides_count === 0:
1820
- recommendations.push({
1821
- category: "guides",
1822
- priority: "HIGH",
1823
- items: [
1824
- "Create Getting Started guide with installation steps",
1825
- "Document common workflows and use cases",
1826
- "Add troubleshooting guide for common issues"
1827
- ]
1828
- })
1829
- else if guides_count < 3:
1830
- recommendations.push({
1831
- category: "guides",
1832
- priority: "MEDIUM",
1833
- items: [
1834
- "Add deployment guide",
1835
- "Create testing guide",
1836
- "Document advanced features"
1837
- ]
1838
- })
1839
-
1840
- // Check architecture/
1841
- arch_count = count_md_files("docs/architecture/", exclude="README.md")
1842
- if arch_count === 0 or not exists("docs/architecture/overview.md"):
1843
- recommendations.push({
1844
- category: "architecture",
1845
- priority: "HIGH",
1846
- items: [
1847
- "✅ AUTO-GENERATED: Architecture overview created",
1848
- "Add system architecture diagram to images/",
1849
- "Create component interaction diagram",
1850
- "Document architecture decision records (ADRs)"
1851
- ]
1852
- })
1853
-
1854
- // Check API documentation
1855
- if not api_docs and api_count === 0:
1856
- recommendations.push({
1857
- category: "api",
1858
- priority: "MEDIUM",
1859
- items: [
1860
- "Generate API documentation using TypeDoc/Rustdoc/Sphinx",
1861
- "Document API endpoints and request/response formats",
1862
- "Add API authentication and authorization guide"
1863
- ]
1864
- })
1865
-
1866
- // Check for duplicates
1867
- if duplicates.length > 0:
1868
- recommendations.push({
1869
- category: "quality",
1870
- priority: "MEDIUM",
1871
- items: [
1872
- f"Review {duplicates.length} potential duplicate documentation files",
1873
- "Consolidate overlapping content",
1874
- "Remove or rename duplicate files"
1875
- ]
1876
- })
1877
-
1878
- // Check for broken links
1879
- if unfixable_links.length > 0:
1880
- recommendations.push({
1881
- category: "quality",
1882
- priority: "HIGH",
1883
- items: [
1884
- f"Fix {unfixable_links.length} broken documentation links (see Phase 4 report)"
1885
- ]
1886
- })
1887
- ```
1888
-
1889
- **Required Report Structure:**
1890
-
1891
- ```markdown
1892
- # docs/ Organization Report
1893
-
1894
- **Project:** {{PROJECT_NAME}}
1895
- **Organization Date:** {date}
1896
- **Organizer:** APO (Documentation Specialist)
1897
- **Command:** /trinity-docs
1898
-
1899
- ---
1900
-
1901
- ## Executive Summary
1902
-
1903
- **docs/ Structure:** {✅ ORGANIZED | ⚠️ PARTIALLY ORGANIZED}
1904
- **Navigation:** {✅ COMPLETE | ⚠️ PARTIAL}
1905
- **Categories:** 5 categories (guides, api, architecture, reference, images)
1906
- **Content Created:** {count} files with seeded content
1907
- **Files Migrated:** {migrated_files.length} scattered docs organized
1908
- **Links Fixed:** {fixed_links.length} broken links repaired
1909
-
1910
- **Documentation Coverage:** {coverage_metrics.total}/100 - Grade: {grade}
1911
-
1912
- **COMMAND EXECUTION STATUS:** {✅ SUCCESS | ⚠️ PARTIAL SUCCESS}
1913
-
1914
- ---
1915
-
1916
- ## Documentation Coverage Breakdown
1917
-
1918
- **Overall Score:** {coverage_metrics.total}/100 ({grade})
1919
-
1920
- **Structure (30 points):** {structure_score}/30
1921
- - Directory hierarchy: {✅ COMPLETE | ⚠️ PARTIAL}
1922
- - guides/: {✅ | ❌}
1923
- - api/: {✅ | ❌}
1924
- - architecture/: {✅ | ❌}
1925
- - reference/: {✅ | ❌}
1926
- - images/: {✅ | ❌}
1927
-
1928
- **Content (50 points):** {content_score}/50
1929
- - Guides: {guides_score}/15 {✅ | ⚠️ | ❌}
1930
- - Getting started: {✅ CREATED | ❌ MISSING}
1931
- - Framework guide: {✅ CREATED | ❌ MISSING}
1932
- - Additional guides: {count}
1933
- - API Documentation: {api_score}/15 {✅ | ⚠️ | ❌}
1934
- - Auto-generated docs: {✅ INTEGRATED | ❌ NONE}
1935
- - Manual API docs: {count} files
1936
- - Architecture: {arch_score}/15 {✅ | ⚠️ | ❌}
1937
- - Overview: {✅ AUTO-GENERATED | ❌ MISSING}
1938
- - ADRs: {count} records
1939
- - Diagrams: {count} diagrams
1940
- - Reference: {ref_score}/5 {✅ | ❌}
1941
- - CLI/env reference: {✅ CREATED | ❌ MISSING}
1942
-
1943
- **Navigation (20 points):** {navigation_score}/20
1944
- - docs/README.md: {✅ CREATED | ❌ MISSING}
1945
- - Category READMEs: {count}/4
1946
- - Documentation index: {✅ COMPLETE | ⚠️ PARTIAL}
1947
-
1948
- ---
1949
-
1950
- ## Phase Execution Summary
1951
-
1952
- ### Phase 1: Discovery & Codebase Analysis
1953
- - **docs/ existed:** {✅ YES | ❌ NO (created)}
1954
- - **Files found in docs/:** {count}
1955
- - **Scattered docs found:** {scattered_docs.length} files
1956
- - **Structure score:** {structure_score}/100
1957
- - **Project type:** {project_metadata.type}
1958
- - **Framework:** {project_metadata.framework}
1959
- - **Architecture pattern:** {project_metadata.architecture}
1960
- - **Auto-generated API docs:** {✅ {api_docs.type} | ❌ None}
1961
- - **Duplicate docs:** {duplicates.length} potential duplicates
1962
-
1963
- **Tool Verification Report:**
1964
- - ✅ **Verified & Documented:** {list verified tools that will be documented}
1965
- - ❌ **Not Found (Skipped):** {list tools checked but not found}
1966
- - **Total Tools Verified:** {verified_count}
1967
- - **Tools Documented:** {documented_count}
1968
-
1969
- ### Phase 2: Directory Structure & Content Seeding
1970
- - **Directories created:** {created_dirs.length}
1971
- - **Content files created:** {count}
1972
- - Guides: {guides_created_count} ({getting-started, framework guide, etc.})
1973
- - API: {api_created_count}
1974
- - Architecture: {arch_created_count} (✅ AUTO-GENERATED overview)
1975
- - Reference: {ref_created_count}
1976
- - **Category READMEs:** 4 created with project-specific content
1977
-
1978
- ### Phase 3: Scattered Documentation Migration
1979
- - **Files migrated:** {migrated_files.length}
1980
- - **Migration errors:** {migration_errors.length}
1981
- - **Links updated:** {count} files
1982
- - **Files preserved:** {preserved_count} (Trinity infrastructure, CLAUDE.md, source READMEs)
1983
-
1984
- ### Phase 4: Link Validation & Navigation
1985
- - **docs/README.md:** ✅ CREATED ({line_count} lines)
1986
- - **Total links validated:** {all_links.length}
1987
- - **Broken links found:** {broken_links.length}
1988
- - **Links fixed:** {fixed_links.length}
1989
- - **Unfixable links:** {unfixable_links.length}
1990
- - **Files indexed:** {all_docs.length}
1991
-
1992
- ### Phase 4.5: Trinity Reference Sanitization
1993
- - **Files scanned:** {all_docs.length}
1994
- - **Trinity references found:** {trinity_references.length}
1995
- - **Auto-fixed violations:** {violations_fixed.length}
1996
- - **Manual review required:** {violations_remaining.length}
1997
-
1998
- **Validation:** {✅ PASS | ❌ FAIL}
1999
- {if PASS:}
2000
- - ✅ Zero Trinity references in docs/ directory
2001
- {if FAIL:}
2002
- - ❌ {violations_remaining.length} Trinity references require manual removal
2003
-
2004
- {if violations_remaining.length > 0:}
2005
- **Violations Requiring Manual Removal:**
2006
- {for each violation:}
2007
- - ⚠️ **{violation.file}:{violation.line}**
2008
- - Pattern: `{violation.pattern}`
2009
- - Context: {violation.context}
2010
- - **Action Required:** Remove Trinity reference manually
2011
-
2012
- **Rule 1 Reminder:**
2013
- Trinity Method is a development tool, not a project feature. User-facing documentation
2014
- must focus exclusively on the project itself, not the methodology used to create it.
2015
-
2016
- ---
2017
-
2018
- ## Rule 1 Compliance (Trinity-Free Documentation)
2019
-
2020
- **Verification:** Scanned all docs/ files for Trinity Method references
2021
-
2022
- **Scan Results:**
2023
- - Files scanned: {all_docs.length}
2024
- - Trinity references found: {trinity_references.length}
2025
- - Auto-fixed: {violations_fixed.length}
2026
- - Manual review required: {violations_remaining.length}
2027
-
2028
- {if violations_remaining.length === 0:}
2029
- **✅ PASS: Zero Trinity references in user-facing documentation**
2030
-
2031
- All generated documentation focuses exclusively on the project's code, features, and
2032
- usage. No references to Trinity Method, Trinity agents, or Trinity infrastructure.
2033
-
2034
- {else:}
2035
- **❌ FAIL: Trinity references present in documentation**
2036
-
2037
- **Violations Requiring Manual Removal:**
2038
- {for each violation:}
2039
- - ⚠️ **{file}:{line}**
2040
- - Pattern: `{pattern}`
2041
- - Context: {context}
2042
- - **Action Required:** Remove Trinity reference manually
2043
-
2044
- **Rule 1 Reminder:**
2045
- Trinity Method is a development tool, not a project feature. User-facing documentation
2046
- must focus exclusively on the project itself, not the methodology used to create it.
2047
-
2048
- ---
2049
-
2050
- ## Directory Structure
2051
-
2052
- **Before:**
2053
- ```
2054
- {show actual before state from Phase 1}
2055
- ```
2056
-
2057
- **After:**
2058
- ```
2059
- docs/
2060
- ├── README.md (navigation - {line_count} lines)
2061
- ├── guides/
2062
- │ ├── README.md
2063
- │ ├── getting-started.md (✅ CREATED - {line_count} lines)
2064
- {if framework guide created:}
2065
- │ ├── {framework}-development.md (✅ CREATED - {line_count} lines)
2066
- {for each migrated guide:}
2067
- │ └── {file} (migrated from {original_location})
2068
- ├── api/
2069
- │ ├── README.md (seeded with {api_docs.type or "project context"})
2070
- {if TypeDoc/etc:}
2071
- │ ├── index.html ({api_docs.type})
2072
- │ └── modules.html ({api_docs.type})
2073
- {for each API doc file:}
2074
- │ └── {file}
2075
- ├── architecture/
2076
- │ ├── README.md
2077
- │ ├── overview.md (✅ AUTO-GENERATED - {line_count} lines)
2078
- {if ADR directory:}
2079
- │ └── adr/
2080
- {for each architecture file:}
2081
- │ └── {file}
2082
- ├── reference/
2083
- │ ├── README.md (seeded with CLI commands, env vars)
2084
- {for each reference file:}
2085
- │ └── {file}
2086
- └── images/
2087
- {for each image:}
2088
- └── {file}
2089
- ```
2090
-
2091
- ---
2092
-
2093
- ## Files Created
2094
-
2095
- **Seeded Content ({count} files):**
2096
-
2097
- **Guides:**
2098
- - ✅ **getting-started.md** ({line_count} lines) - Installation, setup, project structure
2099
- {if framework guide:}
2100
- - ✅ **{framework}-development.md** ({line_count} lines) - Framework-specific development guide
2101
-
2102
- **API Documentation:**
2103
- - ✅ **api/README.md** ({line_count} lines) - Seeded with {api_docs.type or "project endpoints"}
2104
-
2105
- **Architecture:**
2106
- - ✅ **architecture/overview.md** ({line_count} lines) - AUTO-GENERATED from codebase analysis
2107
- - Technology stack: {tech_stack}
2108
- - Architecture pattern: {architecture}
2109
- - Directory structure: Actual src/ layout
2110
- - Entry points: {entry_points}
2111
- - Configuration: {config_files}
2112
-
2113
- **Reference:**
2114
- - ✅ **reference/README.md** ({line_count} lines) - CLI commands, environment variables
2115
-
2116
- **Category READMEs (4 files):**
2117
- - ✅ guides/README.md - Lists all available guides
2118
- - ✅ api/README.md - API overview and documentation links
2119
- - ✅ architecture/README.md - Architecture docs and ADRs
2120
- - ✅ reference/README.md - Quick reference materials
2121
-
2122
- ---
2123
-
2124
- ## Files Migrated
2125
-
2126
- {if migrated_files.length > 0:}
2127
- **Scattered Documentation Organized ({migrated_files.length} files):**
2128
-
2129
- {for each migrated file:}
2130
- - ✅ `{source}` → `{destination}`
2131
-
2132
- **Files Preserved (NOT migrated):**
2133
- - Trinity infrastructure: `trinity/**` ({count} files)
2134
- - AI context files: `**/CLAUDE.md` ({count} files)
2135
- - Root standards: `README.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, etc.
2136
- - Technical source READMEs: `src/README.md`, `tests/README.md`, etc.
2137
-
2138
- {else:}
2139
- **No scattered documentation found** - All documentation was already in docs/ or properly located.
2140
-
2141
- ---
2142
-
2143
- ## Navigation Structure
2144
-
2145
- **docs/README.md includes:**
2146
- - ✅ Documentation structure overview
2147
- - ✅ Quick start guide (links to getting-started.md)
2148
- - ✅ Complete documentation index by category
2149
- - ✅ Quick links to essential documentation
2150
- {if api_docs:}
2151
- - ✅ Link to {api_docs.type} auto-generated API reference
2152
- - ✅ Documentation standards
2153
- - ✅ Contributing guidelines
2154
-
2155
- **Category Navigation:**
2156
- - ✅ guides/README.md: {guides_count} guides listed
2157
- - ✅ api/README.md: API documentation overview
2158
- - ✅ architecture/README.md: Architecture docs and ADRs
2159
- - ✅ reference/README.md: CLI commands, env vars, glossary
2160
-
2161
- ---
2162
-
2163
- ## Link Validation Results
2164
-
2165
- **Total Links Validated:** {all_links.length}
2166
- - Valid links: {valid_links.length} ✅
2167
- - Broken links found: {broken_links.length} ❌
2168
- - Links auto-fixed: {fixed_links.length} ✅
2169
- - Links requiring manual review: {unfixable_links.length} ⚠️
2170
-
2171
- {if fixed_links.length > 0:}
2172
- **Auto-Fixed Links:**
2173
- {for each fixed_link:}
2174
- - ✅ {source_file}:{line_number}
2175
- - Old: `{old_path}` (broken)
2176
- - New: `{new_path}` (fixed)
2177
-
2178
- {if unfixable_links.length > 0:}
2179
- **Links Requiring Manual Review:**
2180
- {for each unfixable:}
2181
- - ⚠️ {source_file}:{line_number}: [{link_text}]({link_path})
2182
- - Issue: {reason}
2183
- {if multiple matches:}
2184
- - Possible matches: {list matches}
2185
- - **Action Required:** Determine correct file and update link manually
2186
-
2187
- ---
2188
-
2189
- ## Project Context Used
2190
-
2191
- **Codebase Analysis:**
2192
- - **Project Type:** {project_metadata.type}
2193
- - **Framework:** {project_metadata.framework}
2194
- - **Version:** {project_metadata.version}
2195
- - **Architecture Pattern:** {project_metadata.architecture}
2196
- - **Entry Point:** {project_metadata.entry_point}
2197
- - **Major Dependencies:** {major_deps_count} documented
2198
-
2199
- **Content Seeding:**
2200
- - Getting Started guide: Framework-specific installation instructions
2201
- - Architecture overview: Actual directory structure from `src/`
2202
- - API documentation: {api_docs.type or "Endpoints detected"} from codebase
2203
- - Reference: CLI commands from package.json scripts
2204
- - Reference: Environment variables from .env.example
2205
-
2206
- ---
2207
-
2208
- ## Duplicate Documentation Detected
2209
-
2210
- {if duplicates.length > 0:}
2211
- **Potential Duplicates Found:** {duplicates.length} cases
2212
-
2213
- {for each duplicate:}
2214
- - ⚠️ **{file1}** ↔ **{file2}**
2215
- - Similarity: {similarity_score}%
2216
- - Type: {title_similarity or content_similarity}
2217
- - **Recommendation:** Review and consolidate or clarify differences
2218
-
2219
- {else:}
2220
- **No duplicate documentation detected** ✅
2221
-
2222
- ---
2223
-
2224
- ## Completion Status
2225
-
2226
- **Required Elements:**
2227
- - ✅ docs/ directory exists
2228
- - ✅ Hierarchical structure (guides/, api/, architecture/, reference/, images/)
2229
- - ✅ Seeded content in all categories
2230
- - ✅ Auto-generated architecture overview
2231
- - ✅ docs/README.md navigation
2232
- - ✅ Category READMEs with actual content listings
2233
- - ✅ Scattered documentation migrated ({migrated_files.length} files)
2234
- - ✅ Documentation links validated ({fixed_links.length} fixed)
2235
- {if api_docs:}
2236
- - ✅ Auto-generated API docs integrated ({api_docs.type})
2237
-
2238
- **Documentation Coverage:** {coverage_metrics.total}/100 ({grade})
2239
-
2240
- {if coverage_metrics.total >= 70:}
2241
- **SUCCESS Criteria:** All required elements present ✅
2242
-
2243
- {else:}
2244
- **PARTIAL SUCCESS:** Core structure complete, content needs expansion ⚠️
2245
-
2246
- ---
2247
-
2248
- ## Recommendations
2249
-
2250
- {if recommendations.length > 0:}
2251
-
2252
- {for each category_recommendation in recommendations:}
2253
- ### {category_recommendation.category} - Priority: {priority}
2254
-
2255
- {for each item in category_recommendation.items:}
2256
- - {item}
2257
-
2258
- {else:}
2259
- **No recommendations** - Documentation is comprehensive ✅
2260
-
2261
- ---
2262
-
2263
- ## Next Steps
2264
-
2265
- ### Immediate Actions
2266
-
2267
- {if unfixable_links.length > 0:}
2268
- 1. **Fix Broken Links** ({unfixable_links.length} links)
2269
- - Review links requiring manual attention (see Link Validation Results)
2270
-
2271
- {if duplicates.length > 0:}
2272
- 2. **Review Duplicate Documentation** ({duplicates.length} cases)
2273
- - Consolidate or clarify differences between similar files
2274
-
2275
- {if guides_count < 3:}
2276
- 3. **Expand Guides**
2277
- - Add deployment guide
2278
- - Create testing guide
2279
- - Document troubleshooting steps
2280
-
2281
- {if not api_docs and framework matches API framework:}
2282
- 4. **Generate API Documentation**
2283
- - Run TypeDoc/Rustdoc/Sphinx to generate API reference
2284
- - Document API endpoints and authentication
2285
-
2286
- ### Future Enhancements
2287
-
2288
- {if not exists("docs/architecture/adr/"):}
2289
- - **Architecture Decision Records**
2290
- - Start documenting architectural decisions using ADR format
2291
- - Create `docs/architecture/adr/` directory
2292
-
2293
- {if not has_architecture_diagrams:}
2294
- - **Architecture Diagrams**
2295
- - Create system architecture diagram
2296
- - Add component interaction diagram
2297
- - Document deployment architecture
2298
-
2299
- - **Advanced Guides**
2300
- - Performance optimization guide
2301
- - Security best practices
2302
- - Debugging guide
2303
-
2304
- ---
2305
-
2306
- **Report Generated:** {timestamp}
2307
- **Report Location:** trinity/reports/DOCS-ORGANIZATION-{date}.md
2308
-
2309
- **Documentation Status:** {✅ Production-Ready | ⚠️ Needs Content Expansion | ❌ Incomplete}
2310
- ```
2311
-
2312
- ---
2313
-
2314
- ## Phase 4.5: Trinity Reference Sanitization
2315
-
2316
- **CRITICAL: Remove all Trinity Method references from generated documentation**
2317
-
2318
- **Goal:** Ensure zero Trinity references in user-facing docs/ directory
2319
-
2320
- **Step 1: Scan Generated Documentation**
2321
-
2322
- ```javascript
2323
- // Search all generated docs for Trinity references
2324
- trinity_references = []
2325
-
2326
- all_docs = glob("docs/**/*.md")
2327
-
2328
- for each doc in all_docs:
2329
- content = read(doc)
2330
-
2331
- // Search for Trinity patterns
2332
- patterns = [
2333
- "Trinity Method",
2334
- "trinity/",
2335
- ".claude/",
2336
- "APO", "MON", "ROR", "KIL", "BAS", "DRA", "URO", "EUS", "TRA",
2337
- "/trinity-",
2338
- "CLAUDE.md",
2339
- "Trinity infrastructure"
2340
- ]
2341
-
2342
- for each pattern in patterns:
2343
- if content.includes(pattern):
2344
- matches = find_all_matches(content, pattern)
2345
- for each match in matches:
2346
- trinity_references.push({
2347
- file: doc,
2348
- pattern: pattern,
2349
- line: match.line,
2350
- context: match.context
2351
- })
2352
- ```
2353
-
2354
- **Step 2: Remove Trinity References**
2355
-
2356
- ```javascript
2357
- violations_fixed = []
2358
- violations_remaining = []
2359
-
2360
- for each reference in trinity_references:
2361
- // Attempt automatic fix
2362
- fixed = attempt_fix(reference)
2363
-
2364
- if fixed:
2365
- violations_fixed.push(reference)
2366
- else:
2367
- // Flag for manual review
2368
- violations_remaining.push(reference)
2369
-
2370
- // Common fixes:
2371
- function attempt_fix(reference):
2372
- content = read(reference.file)
2373
-
2374
- // Fix 1: Remove Trinity report links
2375
- if reference.pattern.includes("trinity/reports/"):
2376
- content = remove_line_containing(content, "trinity/reports/")
2377
- write(reference.file, content)
2378
- return true
2379
-
2380
- // Fix 2: Remove Trinity glossary entries
2381
- if reference.file.endsWith("glossary.md") and reference.pattern == "Trinity Method":
2382
- // Check if entire section is about Trinity
2383
- section = extract_section(content, reference.line)
2384
- if section_is_about_trinity(section):
2385
- content = remove_section(content, section)
2386
- write(reference.file, content)
2387
- return true
2388
-
2389
- // Fix 3: Remove Trinity agent mentions
2390
- if reference.pattern in ["APO", "MON", "ROR", "KIL", "BAS"]:
2391
- // Only remove if in context of Trinity Method (not project code)
2392
- if context_is_methodology(reference.context):
2393
- content = remove_sentence_containing(content, reference.pattern)
2394
- write(reference.file, content)
2395
- return true
2396
-
2397
- // Cannot auto-fix
2398
- return false
2399
- ```
2400
-
2401
- **Step 3: Validate Zero Trinity References**
2402
-
2403
- ```javascript
2404
- // Re-scan after fixes
2405
- final_scan = scan_for_trinity_references("docs/")
2406
-
2407
- if final_scan.length > 0:
2408
- ERROR: "❌ Trinity references still present in docs/ after sanitization"
2409
- LOG: "Violations requiring manual review: {final_scan.length}"
2410
- for each violation in final_scan:
2411
- LOG: " - {violation.file}:{violation.line}: {violation.pattern}"
2412
- ```
2413
-
2414
- **APO Output:**
2415
-
2416
- ```markdown
2417
- === PHASE 4.5: TRINITY REFERENCE SANITIZATION ===
2418
-
2419
- **Scan Results:**
2420
- - Total Trinity references found: {trinity_references.length}
2421
- - Auto-fixed: {violations_fixed.length}
2422
- - Manual review required: {violations_remaining.length}
2423
-
2424
- **Auto-Fixed Violations:**
2425
- {for each fixed:}
2426
- - ✅ {file}:{line}: Removed "{pattern}"
2427
-
2428
- {if violations_remaining.length > 0:}
2429
- **Manual Review Required:**
2430
- {for each violation:}
2431
- - ⚠️ {file}:{line}: "{pattern}" in context: {context}
2432
- - **Action Required:** Manually review and remove Trinity reference
2433
-
2434
- **Validation:** {✅ PASS | ❌ FAIL}
2435
- {if PASS:}
2436
- - ✅ Zero Trinity references in docs/ directory
2437
- {if FAIL:}
2438
- - ❌ {violations_remaining.length} Trinity references require manual removal
2439
- ```
2440
-
2441
- ---
2442
-
2443
- **APO Output:**
2444
-
2445
- ```markdown
2446
- === PHASE 5: ORGANIZATION REPORT ===
2447
-
2448
- **Report Generated:** trinity/reports/DOCS-ORGANIZATION-{date}.md
2449
-
2450
- **Documentation Coverage Score:** {coverage_metrics.total}/100
2451
- - Grade: {grade}
2452
- - Structure: {structure_score}/30
2453
- - Content: {content_score}/50
2454
- - Navigation: {navigation_score}/20
2455
-
2456
- **Status:** {✅ SUCCESS | ⚠️ PARTIAL SUCCESS}
2457
-
2458
- **Key Achievements:**
2459
- - ✅ {created_dirs.length} directories created
2460
- - ✅ {content_files_created} files created with seeded content
2461
- - ✅ Architecture overview auto-generated ({line_count} lines)
2462
- - ✅ {migrated_files.length} scattered docs migrated
2463
- - ✅ {fixed_links.length} broken links fixed
2464
- - ✅ Complete navigation structure
2465
-
2466
- {if recommendations.length > 0:}
2467
- **Recommendations:** {recommendations.length} categories
2468
- - {list priority recommendations}
2469
-
2470
- **Report Location:** trinity/reports/DOCS-ORGANIZATION-{date}.md
2471
- ```
2472
-
2473
- ---
2474
-
2475
- ## Success Criteria
2476
-
2477
- **Command succeeds when:**
2478
-
2479
- 1. **docs/ Structure:** Hierarchical directories exist (guides/, api/, architecture/, reference/, images/)
2480
- 2. **Seeded Content:** Initial documentation created based on project type
2481
- 3. **Architecture Overview:** Auto-generated from codebase analysis
2482
- 4. **Navigation:** docs/README.md exists with complete index
2483
- 5. **Category READMEs:** Each category directory has README.md listing actual files
2484
- 6. **Migration:** Scattered documentation organized (if any found)
2485
- 7. **Link Validation:** Documentation links validated and fixed where possible
2486
- 8. **All Phases Complete:** 5/5 phases executed
2487
-
2488
- **Status Determination:**
2489
-
2490
- **✅ SUCCESS (Coverage ≥ 70/100):**
2491
- - All required structure created
2492
- - Content seeded in all categories
2493
- - Architecture overview auto-generated
2494
- - Navigation complete
2495
- - Documentation coverage ≥ 70%
2496
-
2497
- **⚠️ PARTIAL SUCCESS (Coverage 40-69/100):**
2498
- - Structure created
2499
- - Some content seeded
2500
- - Navigation exists
2501
- - Manual content expansion needed
2502
-
2503
- **❌ NEEDS ATTENTION (Coverage < 40/100):**
2504
- - Structural issues remain
2505
- - Minimal content created
2506
- - Re-run command or manual intervention needed
2507
-
2508
- ---
2509
-
2510
- ## Post-Execution Checklist
2511
-
2512
- **After `/trinity-docs` completes, verify:**
2513
-
2514
- 1. ✅ Check `trinity/reports/DOCS-ORGANIZATION-{date}.md` for full report
2515
- 2. ✅ Verify docs/README.md exists and navigation works
2516
- 3. ✅ Check docs/guides/getting-started.md was created
2517
- 4. ✅ Verify docs/architecture/overview.md was auto-generated
2518
- 5. ✅ Check all category directories exist with READMEs
2519
- 6. ✅ Review documentation coverage score (target: ≥70/100)
2520
- 7. ✅ Review recommendations section for next steps
2521
- 8. ✅ Fix any unfixable broken links (if reported)
2522
- 9. ✅ Review duplicate documentation (if reported)
2523
- 10. ✅ Check "COMMAND EXECUTION STATUS" = "✅ SUCCESS"
2524
-
2525
- ---
2526
-
2527
- ## Framework-Specific Content Examples
2528
-
2529
- ### Node.js/Express Projects
2530
-
2531
- **Guides Created:**
2532
- - `getting-started.md`: npm install, project structure, npm run dev
2533
- - `api-development.md`: Route creation, middleware, error handling
2534
-
2535
- **Architecture:**
2536
- - Auto-detects Express routes, middleware patterns
2537
- - Documents dependencies from package.json
2538
-
2539
- **Reference:**
2540
- - CLI commands from package.json scripts
2541
- - Environment variables from .env.example
2542
-
2543
- ### Python/Django Projects
2544
-
2545
- **Guides Created:**
2546
- - `getting-started.md`: pip install, virtual env, python manage.py runserver
2547
- - `django-development.md`: App creation, models, migrations, admin
2548
-
2549
- **Architecture:**
2550
- - Auto-detects Django apps, settings structure
2551
- - Documents dependencies from requirements.txt or pyproject.toml
2552
-
2553
- ### Rust Projects
2554
-
2555
- **Guides Created:**
2556
- - `getting-started.md`: cargo build, cargo run
2557
- - Crate-specific development guide
2558
-
2559
- **Architecture:**
2560
- - Auto-detects from Cargo.toml
2561
- - Documents crate dependencies
2562
-
2563
- ### React Projects
2564
-
2565
- **Guides Created:**
2566
- - `getting-started.md`: npm install, npm start
2567
- - `component-development.md`: Component patterns, state management
2568
-
2569
- **Architecture:**
2570
- - Auto-detects React components, hooks, context
2571
- - Documents frontend architecture
2572
-
2573
- ---
2574
-
2575
- **Command Specification Version:** 3.0.0
2576
- **Last Updated**: {{CURRENT_DATE}}
2577
- **Enhancements:** Codebase analysis, content seeding, migration, auto-generation, link validation, coverage metrics, framework-specific content, duplicate detection, TypeDoc integration, actionable recommendations