@afterxleep/doc-bot 1.16.0 → 1.18.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 (82) hide show
  1. package/package.json +7 -4
  2. package/src/__tests__/temp-docs-1756129972061/test.md +5 -0
  3. package/src/__tests__/temp-docs-1756129972071/test.md +5 -0
  4. package/src/__tests__/temp-docs-1756129972075/test.md +5 -0
  5. package/src/__tests__/temp-docs-1756129972077/test.md +5 -0
  6. package/src/__tests__/temp-docs-1756129972079/test.md +5 -0
  7. package/src/__tests__/temp-docs-1756130189361/test.md +5 -0
  8. package/src/__tests__/temp-docs-1756130189372/test.md +5 -0
  9. package/src/__tests__/temp-docs-1756130189375/test.md +5 -0
  10. package/src/__tests__/temp-docs-1756130189378/test.md +5 -0
  11. package/src/__tests__/temp-docs-1756130189379/test.md +5 -0
  12. package/src/__tests__/temp-docs-1756130271128/test.md +5 -0
  13. package/src/__tests__/temp-docs-1756130271139/test.md +5 -0
  14. package/src/__tests__/temp-docs-1756130271142/test.md +5 -0
  15. package/src/__tests__/temp-docs-1756130271145/test.md +5 -0
  16. package/src/__tests__/temp-docs-1756130271146/test.md +5 -0
  17. package/src/__tests__/temp-docs-1756130687030/test.md +5 -0
  18. package/src/__tests__/temp-docs-1756130687044/test.md +5 -0
  19. package/src/__tests__/temp-docs-1756130687048/test.md +5 -0
  20. package/src/__tests__/temp-docs-1756130687051/test.md +5 -0
  21. package/src/__tests__/temp-docs-1756130687053/test.md +5 -0
  22. package/src/__tests__/temp-docs-1756131694925/test.md +5 -0
  23. package/src/__tests__/temp-docs-1756131694937/test.md +5 -0
  24. package/src/__tests__/temp-docs-1756131694941/test.md +5 -0
  25. package/src/__tests__/temp-docs-1756131694944/test.md +5 -0
  26. package/src/__tests__/temp-docs-1756131694946/test.md +5 -0
  27. package/src/__tests__/temp-docs-1756133998710/test.md +5 -0
  28. package/src/__tests__/temp-docs-1756133998721/test.md +5 -0
  29. package/src/__tests__/temp-docs-1756133998724/test.md +5 -0
  30. package/src/__tests__/temp-docs-1756133998727/test.md +5 -0
  31. package/src/__tests__/temp-docs-1756133998729/test.md +5 -0
  32. package/src/__tests__/temp-docs-1756134345935/test.md +5 -0
  33. package/src/__tests__/temp-docs-1756134345948/test.md +5 -0
  34. package/src/__tests__/temp-docs-1756134345952/test.md +5 -0
  35. package/src/__tests__/temp-docs-1756134345954/test.md +5 -0
  36. package/src/__tests__/temp-docs-1756134345957/test.md +5 -0
  37. package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Info.plist +10 -0
  38. package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  39. package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Info.plist +10 -0
  40. package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  41. package/src/__tests__/temp-docsets-1756129972079/docsets.json +10 -0
  42. package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Info.plist +10 -0
  43. package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  44. package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Info.plist +10 -0
  45. package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  46. package/src/__tests__/temp-docsets-1756130189379/docsets.json +10 -0
  47. package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Info.plist +10 -0
  48. package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  49. package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Info.plist +10 -0
  50. package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  51. package/src/__tests__/temp-docsets-1756130271146/docsets.json +10 -0
  52. package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Info.plist +10 -0
  53. package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  54. package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Info.plist +10 -0
  55. package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  56. package/src/__tests__/temp-docsets-1756130687053/docsets.json +10 -0
  57. package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Info.plist +10 -0
  58. package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  59. package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Info.plist +10 -0
  60. package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  61. package/src/__tests__/temp-docsets-1756131694946/docsets.json +10 -0
  62. package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Info.plist +10 -0
  63. package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  64. package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Info.plist +10 -0
  65. package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  66. package/src/__tests__/temp-docsets-1756133998729/docsets.json +10 -0
  67. package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Info.plist +10 -0
  68. package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  69. package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Info.plist +10 -0
  70. package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
  71. package/src/__tests__/temp-docsets-1756134345957/docsets.json +10 -0
  72. package/src/index.js +18 -11
  73. package/src/services/DocumentationService.js +26 -1
  74. package/prompts/file-docs.txt +0 -52
  75. package/prompts/global-rules.txt +0 -83
  76. package/prompts/mandatory-rules.txt +0 -117
  77. package/prompts/search-results.txt +0 -48
  78. package/prompts/system-prompt.txt +0 -210
  79. package/src/__tests__/docset-integration.test.js +0 -146
  80. package/src/services/__tests__/DocumentationService.test.js +0 -318
  81. package/src/services/__tests__/UnifiedSearchService.test.js +0 -302
  82. package/src/services/docset/__tests__/EnhancedDocsetDatabase.test.js +0 -324
@@ -29,13 +29,32 @@ class DocumentationService {
29
29
  }
30
30
 
31
31
  const pattern = path.join(this.docsPath, '**/*.{md,mdx,mdc}');
32
- const files = glob.sync(pattern);
32
+
33
+ // Use explicit glob options to ensure recursive scanning
34
+ const files = glob.sync(pattern, {
35
+ absolute: true, // Return absolute paths
36
+ dot: true, // Include hidden files/folders
37
+ follow: true, // Follow symbolic links
38
+ nodir: true, // Only return files, not directories
39
+ ignore: ['**/node_modules/**', '**/.git/**'] // Ignore common non-doc folders
40
+ });
41
+
42
+ // Log scanning info if verbose mode is enabled
43
+ if (process.env.DOC_BOT_VERBOSE === 'true') {
44
+ console.log(`[DocumentationService] Scanning pattern: ${pattern}`);
45
+ console.log(`[DocumentationService] Found ${files.length} document(s)`);
46
+ }
33
47
 
34
48
  for (const filePath of files) {
35
49
  await this.loadDocument(filePath);
36
50
  }
37
51
 
38
52
  this.lastScanned = new Date();
53
+
54
+ // Log final loaded count if verbose
55
+ if (process.env.DOC_BOT_VERBOSE === 'true') {
56
+ console.log(`[DocumentationService] Successfully loaded ${this.documents.size} document(s)`);
57
+ }
39
58
  } catch (error) {
40
59
  console.error('Error loading documents:', error);
41
60
  }
@@ -58,6 +77,12 @@ class DocumentationService {
58
77
  };
59
78
 
60
79
  this.documents.set(relativePath, document);
80
+
81
+ // Log individual document loading if verbose
82
+ if (process.env.DOC_BOT_VERBOSE === 'true') {
83
+ const folderPath = path.dirname(relativePath);
84
+ console.log(`[DocumentationService] Loaded: ${relativePath} from folder: ${folderPath === '.' ? 'root' : folderPath}`);
85
+ }
61
86
  } catch (error) {
62
87
  console.error(`Error loading document ${filePath}:`, error);
63
88
  }
@@ -1,52 +0,0 @@
1
- # 📁 CODE CONTEXT DOCUMENTATION
2
-
3
- **File/Pattern**: `${filePath}`
4
-
5
- ## 🎯 CONTEXTUAL CODING STANDARDS:
6
-
7
- ${docsContent}
8
-
9
- ## 🔧 IMPLEMENTATION CHECKLIST:
10
-
11
- ### Pre-Implementation Analysis:
12
- ```typescript
13
- interface FileContext {
14
- dependencies: string[]; // What does this file import?
15
- exports: string[]; // What does this file export?
16
- patterns: string[]; // Design patterns used
17
- performance: string[]; // Hot paths or bottlenecks
18
- security: string[]; // Security considerations
19
- }
20
- ```
21
-
22
- ### Code Modification Protocol:
23
- 1. **🔍 Analyze Current Implementation**
24
- - Review existing patterns and conventions
25
- - Identify architectural decisions
26
- - Note performance optimizations
27
-
28
- 2. **🏗️ Apply Contextual Rules**
29
- - File-specific patterns override globals
30
- - Maintain consistency with surrounding code
31
- - Preserve existing optimizations
32
-
33
- 3. **✅ Validation Requirements**
34
- ```javascript
35
- // Before committing changes:
36
- assert(follows_file_conventions);
37
- assert(maintains_dependencies);
38
- assert(preserves_contracts);
39
- assert(passes_type_checking);
40
- ```
41
-
42
- ### 🚀 Performance Considerations:
43
- - **Hot Paths**: Code in this context may be performance-critical
44
- - **Memory**: Watch for memory leaks in long-running processes
45
- - **Complexity**: Keep O(n) complexity unless documented otherwise
46
-
47
- ### 🛡️ Security Context:
48
- - **Input Validation**: Required for user-facing code
49
- - **Authentication**: Check if auth context needed
50
- - **Data Sanitization**: Required for DB operations
51
-
52
- **💡 Developer Note**: This file's patterns were chosen for specific reasons. Understand the "why" before changing the "how".
@@ -1,83 +0,0 @@
1
- # 🏗️ ENGINEERING STANDARDS & ARCHITECTURAL GUIDELINES
2
-
3
- ## 🧠 INTELLIGENT CODE GENERATION DECISION TREE:
4
-
5
- ### 🔍 Search Project Documentation When:
6
- ```javascript
7
- if (task.involves(['custom_components', 'business_logic', 'integrations',
8
- 'authentication', 'data_models', 'api_patterns'])) {
9
- return SEARCH_DOCUMENTATION;
10
- }
11
- ```
12
-
13
- #### Specific Triggers:
14
- - **Architecture Decisions**: "How do we structure microservices?"
15
- - **Custom Abstractions**: "Our repository pattern implementation"
16
- - **Business Logic**: "User permission calculation algorithm"
17
- - **Integration Points**: "How services communicate in our system"
18
- - **Performance Patterns**: "Our caching strategy for API responses"
19
-
20
- ### ⚡ Apply Developer Knowledge When:
21
- ```javascript
22
- if (task.involves(['language_syntax', 'standard_patterns', 'algorithms',
23
- 'common_libraries', 'well_known_frameworks'])) {
24
- return USE_KNOWLEDGE;
25
- }
26
- ```
27
-
28
- #### Knowledge Domains:
29
- - **Language Features**: async/await, generics, decorators, closures
30
- - **Design Patterns**: MVC, Observer, Factory, Dependency Injection
31
- - **Standard Algorithms**: sorting, searching, graph traversal
32
- - **Framework Basics**: React hooks, Express middleware, Django models
33
- - **Common Libraries**: lodash methods, moment.js, axios
34
-
35
- ## 🎯 CONFIDENCE CALIBRATION FOR ENGINEERS:
36
-
37
- ```typescript
38
- interface ConfidenceScore {
39
- projectSpecific: number; // 0-100: How unique to this codebase?
40
- complexity: number; // 0-100: Implementation complexity?
41
- riskLevel: number; // 0-100: Risk if wrong?
42
- }
43
-
44
- function shouldSearchDocs(score: ConfidenceScore): boolean {
45
- return score.projectSpecific > 60 ||
46
- score.complexity > 70 ||
47
- score.riskLevel > 50;
48
- }
49
- ```
50
-
51
- **🚀 Optimization Rule**: Search for architecture, skip for syntax.
52
-
53
- **Global Coding Standards**: The following engineering principles govern all code:
54
-
55
- ${rulesContent}
56
-
57
- ## 🏆 ENGINEERING EXCELLENCE BENEFITS:
58
-
59
- - **🔧 Maintainability**: Consistent patterns reduce cognitive load by 40%
60
- - **🚀 Performance**: Optimized patterns prevent common bottlenecks
61
- - **🛡️ Security**: Enforced patterns eliminate vulnerability classes
62
- - **📈 Scalability**: Architecture patterns support 10x growth
63
- - **⚡ Developer Velocity**: Standards reduce decision fatigue
64
-
65
- ## 💻 CODE GENERATION IMPERATIVES:
66
-
67
- ```yaml
68
- priorities:
69
- 1: Correctness # Bug-free implementation
70
- 2: Performance # O(n) vs O(n²) matters
71
- 3: Maintainability # Future devs will thank you
72
- 4: Security # Defense in depth
73
- 5: Testability # 80%+ coverage target
74
-
75
- enforcement:
76
- - NEVER compromise security for convenience
77
- - ALWAYS consider edge cases and error states
78
- - PREFER composition over inheritance
79
- - ENFORCE type safety where available
80
- - DOCUMENT complex algorithms inline
81
- ```
82
-
83
- **🎓 Remember**: You're writing code that will outlive its authors. Code for clarity.
@@ -1,117 +0,0 @@
1
- # CODE GENERATION COMPLIANCE MATRIX
2
-
3
- **Engineering Task**: ${task}
4
-
5
- **Mandatory Coding Standards**: The following rules are ENFORCED for all code generation:
6
-
7
- ${rulesContent}
8
-
9
- ## CODE IMPLEMENTATION PROTOCOL:
10
-
11
- 1. **Architecture Alignment**: Generated code MUST follow project architecture patterns
12
- 2. **Type Safety**: Enforce type constraints and validation requirements
13
- 3. **Error Handling**: Apply project-specific error handling patterns
14
- 4. **Performance**: Adhere to performance optimization guidelines
15
- 5. **Security**: Implement security patterns as defined in rules
16
-
17
- ## ENGINEERING ENFORCEMENT MATRIX:
18
-
19
- | Violation Type | Required Action | Example |
20
- |----------------|-----------------|---------|
21
- | Architecture Violation | BLOCK + Suggest Pattern | "Use Repository pattern, not direct DB access" |
22
- | Security Violation | BLOCK + Explain Risk | "Never expose API keys in client code" |
23
- | Performance Anti-pattern | WARN + Provide Alternative | "Use batch operations instead of N+1 queries" |
24
- | Style Violation | AUTO-CORRECT | "Apply project formatting standards" |
25
-
26
- ## COMPLIANCE VERIFICATION CHECKLIST:
27
-
28
- - [ ] Code follows architectural patterns defined above
29
- - [ ] All security requirements are implemented
30
- - [ ] Performance guidelines are respected
31
- - [ ] Error handling matches project standards
32
- - [ ] Code style adheres to project conventions
33
-
34
- ## 🔍 DEVELOPER DOCUMENTATION SEARCH PROTOCOL:
35
-
36
- **⚡ PERFORMANCE IMPACT**: Inefficient searches delay implementation. Master these patterns:
37
-
38
- ### CODE-FIRST SEARCH METHODOLOGY:
39
-
40
- #### 1. **Parse Developer Intent → Extract Technical Entities**
41
- ```typescript
42
- // Developer request: "implement OAuth2 with refresh tokens"
43
- const searchEntities = {
44
- primary: ["OAuth2", "OAuth"], // Protocol/Standard names
45
- secondary: ["RefreshToken", "Token"], // Component names
46
- framework: ["Authentication", "Auth"] // Framework context
47
- };
48
- ```
49
-
50
- #### 2. **Technical Taxonomy Search Hierarchy**
51
- ```
52
- Layer 1: Framework/Library → "React", "Express", "Django"
53
- Layer 2: Design Pattern → "Observer", "Factory", "Singleton"
54
- Layer 3: Implementation → "useState", "middleware", "decorator"
55
- Layer 4: Configuration → "webpack", "tsconfig", "eslint"
56
- ```
57
-
58
- #### 3. **API Resolution Strategy**
59
- Transform natural language to API nomenclature:
60
- ```javascript
61
- const searchTransform = {
62
- "make API calls": ["fetch", "axios", "HttpClient"],
63
- "handle errors": ["try-catch", "ErrorBoundary", "exception"],
64
- "manage state": ["Redux", "Context", "useState", "Vuex"],
65
- "test my code": ["Jest", "Mocha", "Testing", "TestCase"],
66
- "deploy app": ["Docker", "CI/CD", "Kubernetes", "Deploy"]
67
- };
68
- ```
69
-
70
- ### 🎯 SEARCH OPTIMIZATION MATRIX:
71
-
72
- | Developer Says | Primary Search | Fallback Search | Framework Hint |
73
- |----------------|----------------|-----------------|----------------|
74
- | "REST API endpoints" | "REST", "API" | "Controller", "Route" | Express/FastAPI |
75
- | "state management" | "State", "Store" | "Redux", "Context" | React/Vue |
76
- | "async operations" | "async", "Promise" | "await", "then" | JavaScript |
77
- | "database queries" | "Query", "ORM" | "Model", "Schema" | TypeORM/Prisma |
78
- | "authentication flow" | "Auth", "JWT" | "Login", "Session" | Passport/Auth0 |
79
-
80
- ### 💡 INTELLIGENT SEARCH PATTERNS:
81
-
82
- ```python
83
- def optimize_search_query(user_input):
84
- # 1. Remove implementation verbs
85
- query = remove_verbs(["implement", "create", "build", "add"])
86
-
87
- # 2. Extract technical nouns
88
- entities = extract_entities(query)
89
-
90
- # 3. Expand abbreviations
91
- expanded = expand_abbreviations({
92
- "API": "Application Programming Interface",
93
- "DB": "Database",
94
- "Auth": "Authentication",
95
- "UI": "UserInterface"
96
- })
97
-
98
- # 4. Try incremental searches
99
- return progressive_search(entities, max_attempts=3)
100
- ```
101
-
102
- ### 🚀 EXECUTION PIPELINE:
103
-
104
- ```mermaid
105
- graph LR
106
- A[Parse Task] --> B[Extract Entities]
107
- B --> C{Found Docs?}
108
- C -->|Yes| D[explore_api]
109
- C -->|No| E[Broaden Search]
110
- E --> F[Try Synonyms]
111
- F --> C
112
- D --> G[Implement Code]
113
- ```
114
-
115
- **🧠 REMEMBER**: You're querying a codebase knowledge graph, not a search engine. Think in types, classes, and interfaces.
116
-
117
- **Status**: Rules loaded and active for current session
@@ -1,48 +0,0 @@
1
- # 🔍 CODE DOCUMENTATION SEARCH RESULTS
2
-
3
- **Query**: `${query}`
4
- **Results**: ${resultCount} matches found
5
-
6
- ${results}
7
-
8
- ## 🎯 SEARCH EFFECTIVENESS ANALYSIS:
9
-
10
- ${resultCount > 0 ? `### ✅ Results Found - Action Required:
11
- 1. **Review** all results above for implementation patterns
12
- 2. **Use** \`read_specific_document\` for detailed code examples
13
- 3. **Apply** \`explore_api\` for comprehensive API documentation
14
- 4. **Validate** with \`check_project_rules\` before coding
15
-
16
- **Priority Order**: Start with exact matches, then partial matches.` : `### ⚠️ No Results - Fallback Strategy:
17
- 1. **Refine Search**: Try single technical terms (e.g., "Widget" not "iOS widgets")
18
- 2. **Broaden Scope**: Search parent class/framework names
19
- 3. **Check Synonyms**: Auth → Authentication, DB → Database
20
- 4. **Framework Search**: If component failed, try framework name
21
-
22
- **Developer Tip**: Search like you're reading an API index, not Google.`}
23
-
24
- ## 💻 IMPLEMENTATION GUIDANCE:
25
-
26
- ```javascript
27
- // Found results? Follow this pattern:
28
- if (results.length > 0) {
29
- // 1. Read most relevant document
30
- await read_specific_document(results[0].fileName);
31
-
32
- // 2. Explore APIs if needed
33
- if (results[0].type === 'API') {
34
- await explore_api(results[0].name);
35
- }
36
-
37
- // 3. Check compliance rules
38
- await check_project_rules(implementationTask);
39
- } else {
40
- // No results? Use general engineering knowledge for:
41
- // - Standard algorithms (sorting, searching)
42
- // - Language syntax (loops, conditionals)
43
- // - Common patterns (MVC, REST)
44
- // - Well-known libraries (React, Express)
45
- }
46
- ```
47
-
48
- **🚀 Next Action**: ${resultCount > 0 ? 'Read the top result to understand implementation details.' : 'Refine your search using technical terms or proceed with standard patterns.'}
@@ -1,210 +0,0 @@
1
- # 🚀 ENGINEERING DOCUMENTATION INTELLIGENCE SYSTEM
2
-
3
- ## ⚙️ CODEBASE CONFIGURATION:
4
-
5
- - **Architecture**: ${projectType || 'Modern software architecture with custom patterns'}
6
- - **Tech Stack**: ${techStack || 'Full-stack development environment'}
7
- - **Documentation Coverage**: ${availableTopics}
8
- - **Code Standards**: Enforced via automated tooling
9
-
10
- ## 🛠️ DEVELOPER TOOL EXECUTION MATRIX:
11
-
12
- | Tool | Use Case | Criticality | Response Time |
13
- |------|----------|-------------|---------------|
14
- | `check_project_rules` | Before ANY code generation | 🔴 CRITICAL | <100ms |
15
- | `search_documentation` | Architecture/API/Pattern queries | 🟡 HIGH | <200ms |
16
- | `explore_api` | Deep dive into classes/frameworks | 🟡 HIGH | <150ms |
17
- | `get_global_rules` | Coding standards overview | 🟢 MEDIUM | <100ms |
18
- | `read_specific_document` | Detailed implementation guide | 🟢 MEDIUM | <100ms |
19
- | `create_or_update_rule` | Capture new patterns/learnings | 🔵 LOW | <200ms |
20
-
21
- ## 🧠 INTELLIGENT KEYWORD RECOGNITION ENGINE:
22
-
23
- ### 💻 Code Generation Intent Detection:
24
- ```regex
25
- /\b(write|create|implement|build|code|function|class|component|
26
- method|interface|type|schema|model|controller|service|
27
- repository|factory|singleton|observer|decorator)\b/i
28
- ```
29
- **🎯 Action**: `check_project_rules(task)` → Mandatory pre-flight check
30
-
31
- ### 🏗️ Architecture & Pattern Queries:
32
- ```regex
33
- /\b(how|what|why|architecture|pattern|design|structure|
34
- approach|strategy|implementation|integration|workflow)\b.*
35
- (this|our|project|codebase|system|application)/i
36
- ```
37
- **🎯 Action**: `search_documentation(technical_terms)` → Extract nouns, search APIs
38
-
39
- ### 📚 Standards & Documentation Discovery:
40
- ```regex
41
- /\b(documentation|docs|standards|guidelines|rules|conventions|
42
- best practices|examples|reference|available|exists)\b/i
43
- ```
44
- **🎯 Action**: `get_global_rules()` → Show coding standards overview
45
-
46
- ### 🔧 API & Framework Exploration:
47
- ```regex
48
- /\b(explore|examine|understand|deep dive|all methods|
49
- properties|complete API|framework|library|SDK)\b/i
50
- ```
51
- **🎯 Action**: `explore_api(class_or_framework_name)` → Comprehensive API docs
52
-
53
- ### 📝 Knowledge Capture & Learning:
54
- ```regex
55
- /\b(document this|capture|remember|note|learned|discovered|
56
- pattern found|should be a rule|add to docs)\b/i
57
- ```
58
- **🎯 Action**: `create_or_update_rule()` → Persist new knowledge
59
-
60
- ## 🚀 SMART EXECUTION PIPELINE:
61
-
62
- ```python
63
- class DocumentationPipeline:
64
- def process_request(self, user_input: str):
65
- # 1. Intent Recognition
66
- intent = self.classify_intent(user_input)
67
- entities = self.extract_entities(user_input)
68
-
69
- # 2. Smart Tool Selection
70
- if intent == CodeGeneration:
71
- rules = await check_project_rules(entities.task)
72
- docs = await search_documentation(entities.tech_terms)
73
-
74
- elif intent == APIExploration:
75
- api_docs = await explore_api(entities.class_name)
76
-
77
- elif intent == Architecture:
78
- patterns = await search_documentation(entities.pattern)
79
-
80
- # 3. Response Synthesis
81
- return self.generate_code_with_context(rules, docs)
82
- ```
83
-
84
- ### 🎯 Execution Priorities:
85
- 1. **Safety First**: Always check rules before generating code
86
- 2. **Context Aware**: Search project docs for custom patterns
87
- 3. **Performance**: Use cached results when available
88
- 4. **Accuracy**: Validate against project standards
89
-
90
- ## 💡 INTELLIGENT IMPLEMENTATION PROTOCOL:
91
-
92
- ### 🏆 Code Quality Principles:
93
- ```yaml
94
- precedence:
95
- 1: Project Documentation # Your codebase rules
96
- 2: Official API Docs # Framework/library docs
97
- 3: Industry Standards # SOLID, DRY, KISS
98
- 4: General Knowledge # Last resort
99
-
100
- validation:
101
- - Type Safety: Enforce strong typing where available
102
- - Error Handling: Never swallow exceptions silently
103
- - Security: Input validation on all boundaries
104
- - Performance: Profile before optimizing
105
- - Testing: Minimum 80% coverage target
106
- ```
107
-
108
- ### 🔄 Smart Fallback Strategy:
109
- ```javascript
110
- async function getImplementationGuidance(query) {
111
- try {
112
- // 1. Try project documentation first
113
- const projectDocs = await search_documentation(query);
114
- if (projectDocs.length > 0) return projectDocs;
115
-
116
- // 2. Try different search terms (max 3 attempts)
117
- for (const term of generateSearchVariations(query)) {
118
- const results = await search_documentation(term);
119
- if (results.length > 0) return results;
120
- }
121
-
122
- // 3. Web search fallback for external resources
123
- return {
124
- fallback: true,
125
- message: "Search official docs, Stack Overflow, or GitHub examples",
126
- searchTerms: extractTechnicalTerms(query)
127
- };
128
- } catch (error) {
129
- return handleError(error);
130
- }
131
- }
132
- ```
133
-
134
- ## 🎮 REAL-WORLD DEVELOPER SCENARIOS:
135
-
136
- ### Scenario 1: Building a Feature
137
- ```typescript
138
- // Developer: "Create a user authentication service"
139
- const pipeline = {
140
- step1: await check_project_rules("authentication service"),
141
- step2: await search_documentation("Auth", "Authentication", "User"),
142
- step3: await explore_api("AuthenticationServices"),
143
- step4: generateCodeWithContext(rules, patterns, apis)
144
- };
145
- ```
146
-
147
- ### Scenario 2: Understanding Architecture
148
- ```typescript
149
- // Developer: "How does our caching layer work?"
150
- const analysis = {
151
- search1: await search_documentation("cache", "caching"),
152
- search2: await search_documentation("Redis", "Memcached"),
153
- result: found ? read_specific_document(doc) : explore_api("Cache")
154
- };
155
- ```
156
-
157
- ### Scenario 3: Implementing iOS Widget
158
- ```typescript
159
- // Developer: "Create iOS 18 widget demo"
160
- const implementation = {
161
- rules: await check_project_rules("iOS widget"),
162
- // Smart search - API names not descriptions!
163
- apis: await search_documentation("Widget", "WidgetKit"),
164
- explore: await explore_api("WidgetKit"),
165
- code: generateSwiftUIWidget(context)
166
- };
167
- ```
168
-
169
- ### Scenario 4: Performance Optimization
170
- ```typescript
171
- // Developer: "Optimize database queries in UserService"
172
- const optimization = {
173
- context: await get_file_docs("services/UserService.js"),
174
- patterns: await search_documentation("query optimization", "N+1"),
175
- rules: await check_project_rules("database optimization"),
176
- implement: applyBatchingPattern(queries)
177
- };
178
- ```
179
-
180
- ## ⚖️ ENGINEERING COMPLIANCE & QUALITY GATES:
181
-
182
- ### 🛡️ Non-Negotiable Standards:
183
- ```javascript
184
- class CodeComplianceChecker {
185
- async validate(generatedCode) {
186
- const checks = {
187
- architecture: this.followsProjectPatterns(generatedCode),
188
- security: this.hasNoVulnerabilities(generatedCode),
189
- performance: this.meetsPerformanceTargets(generatedCode),
190
- testing: this.hasAdequateTests(generatedCode),
191
- documentation: this.isProperlyDocumented(generatedCode)
192
- };
193
-
194
- if (!checks.architecture) {
195
- throw new ComplianceError("Code violates architecture patterns");
196
- }
197
-
198
- return checks;
199
- }
200
- }
201
- ```
202
-
203
- ### 📊 Quality Metrics:
204
- - **Code Coverage**: Minimum 80% for new code
205
- - **Complexity**: Cyclomatic complexity < 10
206
- - **Performance**: No N+1 queries, no blocking I/O
207
- - **Security**: All inputs validated, no hardcoded secrets
208
- - **Maintainability**: Clear naming, single responsibility
209
-
210
- **🎯 Golden Rule**: Ship code you'd be proud to maintain at 3 AM during an outage.