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