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
@@ -0,0 +1,60 @@
1
+ # Component Hierarchy Diagram Template
2
+
3
+ <!--
4
+ This template generates a Mermaid flowchart showing frontend component tree structure.
5
+
6
+ Variables:
7
+ - {{COMPONENT_GROUPS}}: Component definitions and relationships
8
+ - {{ROOT_COMPONENT}}: Root/App component name
9
+
10
+ Usage: Replace variables with actual component structure before writing to docs/images/
11
+
12
+ Example COMPONENT_GROUPS format (Mermaid flowchart syntax):
13
+ App[App]
14
+ Layout[Layout]
15
+ Header[Header]
16
+ Navigation[Navigation]
17
+ Content[Content]
18
+ HomePage[HomePage]
19
+ UserList[UserList]
20
+ UserCard[UserCard]
21
+
22
+ App --> Layout
23
+
24
+ Layout --> Header
25
+ Layout --> Content
26
+ Header --> Navigation
27
+ Content --> HomePage
28
+ HomePage --> UserList
29
+ UserList --> UserCard
30
+
31
+ -->
32
+
33
+ ```mermaid
34
+ flowchart TD
35
+ {{COMPONENT_GROUPS}}
36
+ ```
37
+
38
+ ## Description
39
+
40
+ This component hierarchy diagram illustrates the structure of the frontend application's component tree:
41
+
42
+ - **Root Component**: {{ROOT_COMPONENT}} (entry point)
43
+ - **Layout Components**: Structural components (headers, footers, navigation)
44
+ - **Page Components**: Top-level views and routes
45
+ - **Feature Components**: Reusable UI elements and widgets
46
+
47
+ **Understanding the Hierarchy:**
48
+
49
+ - Parent components pass props and context to children
50
+ - Data flows down the tree
51
+ - Events bubble up from children to parents
52
+ - Shared components may appear in multiple branches
53
+
54
+ **Benefits:**
55
+
56
+ - Understand component relationships and dependencies
57
+ - Plan component refactoring and extraction
58
+ - Identify opportunities for component reuse
59
+ - Visualize state management flow
60
+ - Plan testing strategy (test leaf components first)
@@ -0,0 +1,49 @@
1
+ # Database Entity-Relationship Diagram Template
2
+
3
+ <!--
4
+ This template generates a Mermaid ER diagram showing database schema structure.
5
+
6
+ Variables:
7
+ - {{ENTITIES}}: Entity definitions in Mermaid ER syntax
8
+ - {{RELATIONSHIPS}}: Relationship definitions between entities
9
+
10
+ Usage: Replace variables with actual schema structure before writing to docs/images/
11
+
12
+ Example ENTITIES format:
13
+ USER {
14
+ int id PK
15
+ string email UK
16
+ string password
17
+ datetime created_at
18
+ }
19
+ ORDER {
20
+ int id PK
21
+ int user_id FK
22
+ decimal total
23
+ string status
24
+ }
25
+
26
+ Example RELATIONSHIPS format:
27
+ USER ||--o{ ORDER : places
28
+ -->
29
+
30
+ ```mermaid
31
+ erDiagram
32
+ {{ENTITIES}}
33
+ {{RELATIONSHIPS}}
34
+ ```
35
+
36
+ ## Description
37
+
38
+ This entity-relationship diagram shows the database schema structure for the application, including:
39
+
40
+ - **Entities**: Tables/collections with their fields and types
41
+ - **Relationships**: How entities relate to each other (one-to-one, one-to-many, many-to-many)
42
+ - **Keys**: Primary keys (PK), foreign keys (FK), and unique keys (UK)
43
+
44
+ Understanding these relationships is essential for:
45
+
46
+ - Writing efficient queries
47
+ - Maintaining data integrity
48
+ - Planning schema migrations
49
+ - Optimizing database performance
@@ -0,0 +1,41 @@
1
+ # MVC Request Flow Diagram Template
2
+
3
+ <!--
4
+ This template generates a Mermaid sequence diagram showing the typical MVC request flow.
5
+
6
+ Variables:
7
+ - {{DATABASE}}: Database type (e.g., "PostgreSQL", "SQLite", "MongoDB")
8
+ - {{FRAMEWORK}}: Backend framework name (e.g., "Express", "Fastify", "Koa")
9
+
10
+ Usage: Replace variables with actual project values before writing to docs/images/
11
+ -->
12
+
13
+ ```mermaid
14
+ sequenceDiagram
15
+ participant Client
16
+ participant Routes
17
+ participant Controller
18
+ participant Service
19
+ participant {{DATABASE}}
20
+
21
+ Client->>Routes: HTTP Request
22
+ Routes->>Controller: Route Handler
23
+ Controller->>Service: Business Logic
24
+ Service->>{{DATABASE}}: Query Data
25
+ {{DATABASE}}-->>Service: Return Results
26
+ Service-->>Controller: Processed Data
27
+ Controller-->>Routes: Response Data
28
+ Routes-->>Client: HTTP Response
29
+ ```
30
+
31
+ ## Description
32
+
33
+ This diagram illustrates the typical request flow in an MVC (Model-View-Controller) architecture:
34
+
35
+ 1. **Client** sends an HTTP request to the {{FRAMEWORK}} server
36
+ 2. **Routes** match the request to the appropriate controller
37
+ 3. **Controller** delegates business logic to the service layer
38
+ 4. **Service** performs database operations via the {{DATABASE}} connection
39
+ 5. Response flows back through the layers to the client
40
+
41
+ This pattern ensures separation of concerns and maintainable code structure.
@@ -0,0 +1,166 @@
1
+ # Error Handling Protocol
2
+ **Category:** Processes
3
+ **Purpose:** 3-tier error handling system for trinity-docs command
4
+ **Used By:** JUNO, APO-1, APO-2, APO-3, Phase 3 Verification
5
+
6
+ ---
7
+
8
+ ## 3-Tier Error System
9
+
10
+ ### Tier 1: ABORT (Critical Errors)
11
+ **Action:** Stop command execution immediately, report failure
12
+ **Use when:** System cannot proceed, data corruption risk, user intervention required
13
+
14
+ **Examples:**
15
+ - JUNO report completely missing
16
+ - No package.json found (cannot detect framework)
17
+ - Component verification failed (fake component names detected)
18
+ - Template files missing (cannot read required templates)
19
+ - Write permission denied (cannot create documentation files)
20
+
21
+ **Log Format:**
22
+ ```
23
+ ❌ CRITICAL ERROR - ABORTING COMMAND
24
+ Agent: [AGENT_NAME]
25
+ Task: [TASK_NAME]
26
+ Error: [ERROR_DESCRIPTION]
27
+ Recommendation: [HOW_TO_FIX]
28
+ ```
29
+
30
+ ### Tier 2: WARN (Recoverable Issues)
31
+ **Action:** Log warning, activate fallback, continue execution
32
+ **Use when:** Data incomplete but work can continue, fallback mechanisms available
33
+
34
+ **Examples:**
35
+ - JUNO report incomplete (some variables missing)
36
+ - Optional template variables not found
37
+ - Framework detection partial (backend found, frontend unknown)
38
+ - Some environment variables missing
39
+ - API endpoints partially discovered
40
+
41
+ **Log Format:**
42
+ ```
43
+ ⚠️ WARNING - Using fallback mechanism
44
+ Agent: [AGENT_NAME]
45
+ Issue: [ISSUE_DESCRIPTION]
46
+ Fallback: [FALLBACK_ACTION_TAKEN]
47
+ Impact: [WHAT_WILL_BE_DIFFERENT]
48
+ ```
49
+
50
+ ### Tier 3: LOG (Informational)
51
+ **Action:** Log message only, continue normally
52
+ **Use when:** Normal process updates, optional data, FYI messages
53
+
54
+ **Examples:**
55
+ - Process milestones ("Reading JUNO report...")
56
+ - File creation confirmations ("Created mvc-flow.md")
57
+ - Discovery counts ("Found 15 components")
58
+ - Optional fields missing (non-critical)
59
+ - Performance metrics ("Execution time: 18s")
60
+
61
+ **Log Format:**
62
+ ```
63
+ ℹ️ INFO - [MESSAGE]
64
+ Agent: [AGENT_NAME]
65
+ Details: [ADDITIONAL_INFO]
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Error Handling by Agent
71
+
72
+ ### JUNO Errors
73
+
74
+ **Tier 1 (ABORT):**
75
+ - Cannot read package.json
76
+ - Cannot write audit report to global state
77
+ - All discovery methods failed (no data found)
78
+
79
+ **Tier 2 (WARN):**
80
+ - Some discovery methods returned no data
81
+ - Optional metadata missing
82
+ - Framework detection uncertain
83
+
84
+ **Tier 3 (LOG):**
85
+ - Discovery progress updates
86
+ - Variable extraction counts
87
+ - Report generation milestones
88
+
89
+ ### APO-1 Errors
90
+
91
+ **Tier 1 (ABORT):**
92
+ - Cannot read JUNO report from global state
93
+ - Component verification failed (fake components)
94
+ - Cannot write diagram files (permission denied)
95
+
96
+ **Tier 2 (WARN):**
97
+ - Database schema not found (skip database-er.md)
98
+ - No API endpoints discovered (skip api-endpoint-map.md)
99
+ - Mermaid syntax warning (diagram created but may have issues)
100
+
101
+ **Tier 3 (LOG):**
102
+ - Diagram generation progress
103
+ - File creation confirmations
104
+ - Fallback usage notifications
105
+
106
+ ### APO-2 Errors
107
+
108
+ **Tier 1 (ABORT):**
109
+ - Cannot read JUNO report from global state
110
+ - Cannot read guide templates from trinity/templates/documentation/
111
+ - Cannot write guide files (permission denied)
112
+
113
+ **Tier 2 (WARN):**
114
+ - Framework-specific examples unavailable (use generic examples)
115
+ - Test framework unknown (use generic test instructions)
116
+ - Deployment steps uncertain (use common deployment pattern)
117
+
118
+ **Tier 3 (LOG):**
119
+ - Guide generation progress
120
+ - File creation confirmations
121
+ - Template variable substitutions
122
+
123
+ ### APO-3 Errors
124
+
125
+ **Tier 1 (ABORT):**
126
+ - Cannot read JUNO report from global state
127
+ - Cannot write .env.example or README.md (permission denied)
128
+ - Security violation detected (real secrets in .env.example)
129
+
130
+ **Tier 2 (WARN):**
131
+ - No environment variables discovered (.env.example will be minimal)
132
+ - README.md doesn't exist (create new README with warning)
133
+ - Environment variable detection uncertain
134
+
135
+ **Tier 3 (LOG):**
136
+ - Configuration file generation progress
137
+ - Environment variable counts
138
+ - README update confirmations
139
+
140
+ ---
141
+
142
+ ## Fallback Activation
143
+
144
+ **When Tier 2 WARN occurs, activate fallback:**
145
+
146
+ ```javascript
147
+ if (juno_incomplete || data_missing) {
148
+ LOG: "⚠️ FALLBACK MODE ACTIVATED";
149
+ LOG: `Reason: ${fallback_reason}`;
150
+
151
+ // Use discovery templates directly
152
+ // See trinity/templates/discovery/ for patterns
153
+
154
+ // Mark fallback usage
155
+ fallback_used = true;
156
+ }
157
+ ```
158
+
159
+ **After fallback completes:**
160
+ ```javascript
161
+ if (fallback_used && task_complete) {
162
+ LOG: "✅ FALLBACK SUCCESS - Task completed using direct analysis";
163
+ }
164
+ ```
165
+
166
+ ---
@@ -0,0 +1,88 @@
1
+ # APO Fallback Mechanisms
2
+
3
+ When automated discovery fails, APO agents use these fallback procedures to generate documentation.
4
+
5
+ ## Framework Detection Fallback
6
+
7
+ **If automated framework detection fails:**
8
+
9
+ 1. Check `package.json` for framework dependencies:
10
+ - Express.js: `"express"` in dependencies
11
+ - NestJS: `"@nestjs/core"` in dependencies
12
+ - Next.js: `"next"` in dependencies
13
+ - React: `"react"` in dependencies
14
+
15
+ 2. Check file patterns:
16
+ - Django: `manage.py`, `settings.py`
17
+ - Flask: `app.py`, `@app.route` decorators
18
+ - Rails: `Gemfile`, `config/routes.rb`
19
+
20
+ 3. Manual fallback: Create generic architecture diagram with placeholder note:
21
+ ```
22
+ NOTE: Framework could not be auto-detected.
23
+ Update this diagram after manual framework identification.
24
+ ```
25
+
26
+ ## Component Discovery Fallback
27
+
28
+ **If component scanning finds no results:**
29
+
30
+ 1. Check common directory names: `src/`, `lib/`, `app/`, `server/`
31
+ 2. Search for file patterns: `*Controller.js`, `*Service.js`, `*Model.js`
32
+ 3. Fallback to directory-based documentation:
33
+ ```
34
+ Components organized by directory structure.
35
+ See subdirectory READMEs for details.
36
+ ```
37
+
38
+ ## Database Schema Fallback
39
+
40
+ **If schema files not found:**
41
+
42
+ 1. Check for migration files: `migrations/`, `db/migrate/`
43
+ 2. Search for ORM model files: `models/`, `entities/`
44
+ 3. Fallback to placeholder ER diagram:
45
+ ```
46
+ Database schema not detected in standard locations.
47
+ Generate schema from migration files or ORM models manually.
48
+ ```
49
+
50
+ ## API Endpoints Fallback
51
+
52
+ **If endpoint scanner finds no routes:**
53
+
54
+ 1. Search for route files: `routes/`, `controllers/`, `api/`
55
+ 2. Look for route decorators: `@Get`, `@Post`, `@app.route`
56
+ 3. Fallback to manual endpoint documentation:
57
+ ```
58
+ API endpoints not auto-detected.
59
+ Document endpoints in docs/api/ manually.
60
+ ```
61
+
62
+ ## Environment Variables Fallback
63
+
64
+ **If `.env.example` not found:**
65
+
66
+ 1. Search for `.env` files (do NOT read secrets)
67
+ 2. Check for config files: `config/`, `settings.py`, `application.yml`
68
+ 3. Generate minimal `.env.example`:
69
+ ```
70
+ # Environment Configuration
71
+ NODE_ENV=development
72
+ PORT=3000
73
+
74
+ # Add environment variables as discovered
75
+ ```
76
+
77
+ ## Quality Gate: Fallback Detection
78
+
79
+ APO agents must log when fallback mechanisms are used:
80
+
81
+ ```javascript
82
+ if (fallback_used) {
83
+ LOG: "⚠️ FALLBACK USED: {fallback_type}";
84
+ LOG: " Reason: {detection_failure_reason}";
85
+ LOG: " Action: {fallback_action_taken}";
86
+ LOG: " Manual review recommended for: {affected_documentation}";
87
+ }
88
+ ```