@afterxleep/doc-bot 1.17.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 +4 -6
  73. package/src/services/DocumentationService.js +26 -1
  74. package/prompts/file-docs.md +0 -69
  75. package/prompts/global-rules.md +0 -142
  76. package/prompts/mandatory-rules.md +0 -90
  77. package/prompts/search-results.md +0 -59
  78. package/prompts/system-prompt.md +0 -270
  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,69 +0,0 @@
1
- # FILE CONTEXT DOCUMENTATION
2
-
3
- **File**: `${filePath}`
4
-
5
- ## CONTEXTUAL STANDARDS
6
-
7
- ${docsContent}
8
-
9
- ## SMART IMPLEMENTATION CHECKLIST
10
-
11
- ### Quick Analysis (< 10 seconds)
12
- 1. **Scan Patterns** - What patterns does this file use?
13
- 2. **Check Dependencies** - What does it import?
14
- 3. **Note Conventions** - Naming, structure, style
15
-
16
- ### Implementation Rules
17
- 1. **Match Style** - Follow the file's existing patterns
18
- 2. **Preserve Logic** - Don't break existing functionality
19
- 3. **Minimal Changes** - Small, focused modifications
20
-
21
- ## DECISION FRAMEWORK
22
-
23
- ### Need More Context?
24
-
25
- ```javascript
26
- if (changeIsSimple) {
27
- // Just make the change
28
- applyDirectFix();
29
- } else if (needsPatternContext) {
30
- // One quick search
31
- search_documentation(specificPattern);
32
- } else {
33
- // Use file's existing patterns
34
- followLocalConventions();
35
- }
36
- ```
37
-
38
- ## PERFORMANCE CONSIDERATIONS
39
-
40
- **For Hot Paths:**
41
- - Keep complexity at current level or better
42
- - Don't introduce blocking operations
43
- - Maintain existing optimizations
44
-
45
- **For Regular Code:**
46
- - Prioritize readability
47
- - Follow SOLID principles
48
- - Keep it simple
49
-
50
- ## VALIDATION
51
-
52
- Before committing:
53
- - ✓ Follows file conventions
54
- - ✓ Maintains contracts
55
- - ✓ Preserves performance
56
- - ✓ Doesn't break tests
57
-
58
- ## QUICK WINS
59
-
60
- **Common tasks that need NO documentation search:**
61
- - Adding logging/debugging
62
- - Fixing typos or syntax
63
- - Adding comments
64
- - Simple refactoring
65
- - Error handling with try/catch
66
-
67
- ## THE LOCAL PATTERN RULE
68
-
69
- When in doubt, copy what the file already does. Local consistency > global perfection.
@@ -1,142 +0,0 @@
1
- # ENGINEERING STANDARDS & ARCHITECTURE GUIDELINES
2
-
3
- ## INTELLIGENT CODE GENERATION FRAMEWORK
4
-
5
- ### When to Search Project Documentation
6
-
7
- **Search when task involves:**
8
- - Custom components unique to this codebase
9
- - Business logic implementation
10
- - Integration patterns
11
- - Authentication/authorization schemes
12
- - Data models and schemas
13
- - API design patterns
14
-
15
- **Specific triggers:**
16
- - "How do we structure microservices?"
17
- - "Our repository pattern implementation"
18
- - "User permission calculation algorithm"
19
- - "How services communicate in our system"
20
- - "Our caching strategy for API responses"
21
-
22
- ### When to Use Agent Knowledge
23
-
24
- **Use existing knowledge for:**
25
- - Language syntax and features
26
- - Standard design patterns
27
- - Common algorithms
28
- - Well-known framework basics
29
- - Popular library usage
30
-
31
- **Knowledge domains:**
32
- - **Language Features**: async/await, generics, decorators, closures
33
- - **Design Patterns**: MVC, Observer, Factory, Dependency Injection
34
- - **Standard Algorithms**: sorting, searching, graph traversal
35
- - **Framework Basics**: React hooks, Express middleware, Django models
36
- - **Common Libraries**: lodash methods, axios, standard utilities
37
-
38
- ## CONFIDENCE CALIBRATION
39
-
40
- ### Decision Matrix
41
-
42
- ```javascript
43
- function shouldSearchDocs(task) {
44
- const signals = {
45
- projectSpecific: assessProjectSpecificity(task), // 0-100
46
- complexity: assessComplexity(task), // 0-100
47
- riskLevel: assessRisk(task) // 0-100
48
- };
49
-
50
- // Search if any signal is high
51
- return signals.projectSpecific > 60 ||
52
- signals.complexity > 70 ||
53
- signals.riskLevel > 50;
54
- }
55
- ```
56
-
57
- ### Quick Decision Rules
58
-
59
- 1. **Universal Task** → Skip search
60
- 2. **Project Pattern** → Single targeted search
61
- 3. **Complex Feature** → Progressive search (max 2-3)
62
- 4. **Unclear Requirement** → Start simple, enhance if needed
63
-
64
- ## COMPLIANCE & QUALITY GATES
65
-
66
- ### Non-Negotiable Standards
67
-
68
- - **Architecture**: Follow established patterns
69
- - **Security**: Never expose sensitive data
70
- - **Performance**: Avoid N+1 queries, optimize hot paths
71
- - **Error Handling**: Consistent error patterns
72
- - **Testing**: Maintain coverage standards
73
-
74
- ### Quality Metrics
75
-
76
- - **Code Coverage**: Minimum 80% for new code
77
- - **Complexity**: Cyclomatic complexity < 10
78
- - **Performance**: No blocking I/O in hot paths
79
- - **Security**: All inputs validated
80
- - **Maintainability**: Clear naming, single responsibility
81
-
82
- ## SEARCH OPTIMIZATION PROTOCOL
83
-
84
- ### Efficient Search Strategy
85
-
86
- 1. **Parse Intent** → Extract technical entities
87
- 2. **Search Hierarchy** → Specific to general
88
- 3. **Early Exit** → Stop when confidence > 80%
89
- 4. **Fallback** → Use general knowledge after 2 failed attempts
90
-
91
- ### Search Patterns
92
-
93
- ```javascript
94
- // Good: Specific technical terms
95
- search("WidgetKit", "Widget", "iOS")
96
-
97
- // Bad: Descriptive phrases
98
- search("how to make iOS widgets")
99
-
100
- // Good: API/Class names
101
- search("URLSession", "Authentication")
102
-
103
- // Bad: General concepts
104
- search("networking", "security")
105
- ```
106
-
107
- ## IMPLEMENTATION GUIDANCE
108
-
109
- ### Found Documentation
110
-
111
- ```javascript
112
- if (documentation.found) {
113
- // 1. Read most relevant
114
- await read_specific_document(results[0]);
115
-
116
- // 2. Explore APIs if needed
117
- if (needsAPIDetails) {
118
- await explore_api(className);
119
- }
120
-
121
- // 3. Apply patterns
122
- implementWithPatterns(documentation);
123
- }
124
- ```
125
-
126
- ### No Documentation Found
127
-
128
- ```javascript
129
- if (!documentation.found && attempts >= 2) {
130
- // Use standard patterns
131
- applyBestPractices();
132
-
133
- // Note for user
134
- addComment("Implemented with industry standards - verify against project patterns");
135
- }
136
- ```
137
-
138
- ## GOLDEN RULE
139
-
140
- **Ship code you'd be proud to maintain at 3 AM during an outage.**
141
-
142
- Balance speed with quality. Use documentation when it adds value. Default to simplicity.
@@ -1,90 +0,0 @@
1
- # CODE GENERATION COMPLIANCE MATRIX
2
-
3
- **Task**: ${task}
4
-
5
- ## MANDATORY STANDARDS
6
-
7
- ${rulesContent}
8
-
9
- ## IMPLEMENTATION PROTOCOL
10
-
11
- ### 1. Architecture Alignment
12
- Generated code MUST follow project architecture patterns
13
-
14
- ### 2. Type Safety
15
- Enforce type constraints and validation requirements
16
-
17
- ### 3. Error Handling
18
- Apply project-specific error handling patterns
19
-
20
- ### 4. Performance
21
- Adhere to performance optimization guidelines
22
-
23
- ### 5. Security
24
- Implement security patterns as defined in rules
25
-
26
- ## ENFORCEMENT MATRIX
27
-
28
- | Violation Type | Action | Example |
29
- |----------------|--------|---------|
30
- | Architecture | BLOCK + Suggest | "Use Repository pattern, not direct DB" |
31
- | Security | BLOCK + Explain | "Never expose API keys in client" |
32
- | Performance | WARN + Alternative | "Use batch ops instead of N+1" |
33
- | Style | AUTO-CORRECT | "Apply project formatting" |
34
-
35
- ## SMART SEARCH METHODOLOGY
36
-
37
- ### Efficient Pattern Recognition
38
-
39
- 1. **Extract Key Terms** - Not descriptions
40
- ```javascript
41
- // User: "implement OAuth2 with refresh tokens"
42
- searchTerms = ["OAuth2", "OAuth", "RefreshToken", "Authentication"]
43
- // NOT: ["implement", "with", "tokens"]
44
- ```
45
-
46
- 2. **Search Hierarchy**
47
- - Exact match → Class/API names
48
- - Partial match → Related components
49
- - Broad match → Framework/pattern names
50
-
51
- 3. **Early Termination**
52
- - Found with high confidence (>80%) → Stop
53
- - 2 attempts with no results → Use general knowledge
54
- - User provides implementation → Skip search
55
-
56
- ### Search Optimization Rules
57
-
58
- **DO:**
59
- - Search for technical nouns (Widget, URLSession)
60
- - Use API/framework names (SwiftUI, WidgetKit)
61
- - Try variations of technical terms
62
-
63
- **DON'T:**
64
- - Search for descriptions ("how to make widgets")
65
- - Use generic verbs ("create", "build", "implement")
66
- - Keep searching after 2 failed attempts
67
-
68
- ## COMPLIANCE CHECKLIST
69
-
70
- - [ ] Code follows architectural patterns
71
- - [ ] Security requirements implemented
72
- - [ ] Performance guidelines respected
73
- - [ ] Error handling matches standards
74
- - [ ] Code style adheres to conventions
75
-
76
- ## QUICK DECISION TREE
77
-
78
- ```
79
- Is this a project-specific pattern?
80
- ├─ NO → Use industry best practices
81
- └─ YES → Search for pattern (max 2 attempts)
82
- ├─ Found → Apply pattern
83
- └─ Not Found → Use best practices + note
84
- ```
85
-
86
- ## EFFICIENCY REMINDER
87
-
88
- **Time is valuable. Don't over-search.**
89
-
90
- If you can't find project patterns in 2 tries, implement with industry standards and move on.
@@ -1,59 +0,0 @@
1
- # DOCUMENTATION SEARCH RESULTS
2
-
3
- **Query**: `${query}`
4
- **Results**: ${resultCount} matches
5
-
6
- ${results}
7
-
8
- ## SEARCH EFFECTIVENESS
9
-
10
- ${resultCount > 0 ? `### ✅ Results Found
11
- **Next Steps:**
12
- 1. Read the most relevant result with \`read_specific_document\`
13
- 2. Explore APIs if needed with \`explore_api\`
14
- 3. Check compliance with \`check_project_rules\`
15
-
16
- **Priority**: Start with exact matches, then partial matches.` : `### ⚠️ No Results Found
17
-
18
- **Smart Fallback Strategy:**
19
- 1. **One Retry**: Try a single, more specific technical term
20
- 2. **If Still Nothing**: Use general programming knowledge
21
- 3. **Note to User**: "Implemented with industry standards"
22
-
23
- **Search Tips:**
24
- - Use API/class names, not descriptions
25
- - Try parent class or framework name
26
- - Search like reading an API index`}
27
-
28
- ## IMPLEMENTATION GUIDANCE
29
-
30
- ### With Documentation
31
- ```javascript
32
- if (results.length > 0) {
33
- // Read most relevant
34
- await read_specific_document(results[0].fileName);
35
-
36
- // Only explore if needed
37
- if (needsAPIDetails) {
38
- await explore_api(results[0].name);
39
- }
40
- }
41
- ```
42
-
43
- ### Without Documentation (After 2 Attempts)
44
- ```javascript
45
- // Don't keep searching - use your knowledge
46
- implementWithBestPractices();
47
- // Be transparent
48
- addComment("Following industry standards - verify against project patterns if needed");
49
- ```
50
-
51
- ## EFFICIENCY PRINCIPLE
52
-
53
- **Found something useful?** → Read it and implement
54
- **Found nothing twice?** → Stop searching, start coding
55
- **User corrects you?** → Then search for their specific pattern
56
-
57
- ## THE 2-ATTEMPT RULE
58
-
59
- Never search more than twice for the same concept. If project documentation doesn't have it, it probably follows standard patterns.
@@ -1,270 +0,0 @@
1
- # INTENT-DRIVEN DOCUMENTATION SYSTEM
2
-
3
- ## PRIMARY DIRECTIVE
4
-
5
- Think like a senior developer: Understand WHAT the user needs and WHY, then decide:
6
-
7
- 1. **Fast Path**: Use agent knowledge for universal programming tasks
8
- 2. **Discovery Path**: Use doc-bot tools only when project-specific knowledge adds value
9
- 3. **Hybrid Path**: Combine both for features that need project patterns
10
-
11
- ## SMART INTENT ANALYSIS
12
-
13
- ### Core Question: "Can I solve this without project documentation?"
14
-
15
- - **YES** → Fast Path (agent knowledge only)
16
- - **NO** → Analyze what specific project info is needed
17
- - **MAYBE** → Start fast, search only if stuck
18
-
19
- ### Speed vs Accuracy Trade-off
20
-
21
- - User seems rushed/frustrated → Prioritize speed
22
- - User asks "proper way" → Prioritize project patterns
23
- - User fixing urgent bug → Fast fix first, patterns later
24
- - User building new feature → Get patterns right first time
25
-
26
- ## DECISION FRAMEWORK
27
-
28
- ### ⚠️ MANDATORY RULE CHECK
29
-
30
- **ALWAYS use `check_project_rules` tool when:**
31
- - Writing ANY new code
32
- - Modifying existing code beyond trivial fixes
33
- - Even for "simple" tasks - rules with `alwaysApply: true` must be enforced
34
-
35
- **Exception:** Only skip for pure fixes like typos, renames, or adding comments.
36
-
37
- ## DOC-BOT TOOLS REFERENCE
38
-
39
- ### Important: Direct Tool Access
40
- **You can call these tools DIRECTLY** - no orchestration layer required. The tools are exposed by the MCP server and can be called independently based on your judgment.
41
-
42
- ### Optional: The `doc_bot` Helper Tool
43
- - **Purpose**: Provides guidance on which tools to use for a task
44
- - **When to use**: If you're unsure which tools to call
45
- - **Input**: `task` (description of what you're doing)
46
- - **Returns**: Text guidance suggesting tool sequence
47
- - **Note**: This is OPTIONAL - you can skip it and call tools directly
48
-
49
- ### Core Tools for Code Generation
50
-
51
- 1. **`check_project_rules`** - MANDATORY before writing code
52
- - Input: `task` (2-5 words describing what you're doing)
53
- - Returns: Architecture patterns, security requirements, performance guidelines
54
- - Example: `check_project_rules("user authentication")`
55
-
56
- 2. **`search_documentation`** - Find project patterns
57
- - Input: `query` (technical terms, not descriptions)
58
- - Use: API/class names like "Widget", not "how to make widgets"
59
- - Optional: `limit`, `docsetId`, `type`
60
-
61
- 3. **`get_global_rules`** - Understand codebase philosophy
62
- - No inputs required
63
- - Returns: Project-wide principles and standards
64
- - Use: When starting major features or understanding architecture
65
-
66
- 4. **`get_file_docs`** - File-specific patterns
67
- - Input: `filePath` (exact path or pattern)
68
- - Use: Before modifying existing files
69
- - Example: `get_file_docs("src/services/auth.js")`
70
-
71
- 5. **`read_specific_document`** - Read full doc content
72
- - Input: `fileName` (exact match required)
73
- - Use: After `search_documentation` finds relevant docs
74
-
75
- 6. **`explore_api`** - Deep dive into APIs
76
- - Input: `apiName` (class/framework name)
77
- - Use: When implementing with specific APIs
78
- - Example: `explore_api("WidgetKit")`
79
-
80
- ### 🚀 FAST PATH (Minimal doc-bot tools, < 30 seconds)
81
-
82
- **Triggers:**
83
- - Typos, syntax errors, compilation errors
84
- - Variable/function renames
85
- - Adding comments or logging
86
- - Standard bug fixes (null checks, undefined vars)
87
- - General "what is X?" questions
88
- - Error messages with obvious fixes
89
-
90
- **Required for code generation:** Still call `check_project_rules()` for non-trivial code changes
91
-
92
- **Key Insight**: Fast doesn't mean skipping mandatory rules - it means no unnecessary searches.
93
-
94
- ### 🔍 DISCOVERY PATH (Use doc-bot strategically)
95
-
96
- **Triggers:**
97
- - "How do WE...", "In THIS project...", "Our pattern for..."
98
- - "Where is X implemented?"
99
- - Architecture or design questions
100
- - Integration with existing systems
101
- - Following team conventions
102
-
103
- **Smart Search Strategy:**
104
- 1. Start with most specific term
105
- 2. If no results, try broader term ONCE
106
- 3. Still nothing? Use agent knowledge + disclaimer
107
-
108
- ### 🎯 HYBRID PATH (Minimal doc-bot + agent knowledge)
109
-
110
- **Triggers:**
111
- - "Add/Implement X" (new feature)
112
- - "Optimize X" (existing code)
113
- - "Refactor to match standards"
114
-
115
- **Execution:**
116
- 1. Quick `check_project_rules(feature)` - 1 call max
117
- 2. If patterns found → follow them
118
- 3. If not → implement with best practices
119
- 4. Don't over-search - 2 attempts maximum
120
-
121
- ## SMART EFFICIENCY PRINCIPLES
122
-
123
- ### 1. Think Before Searching
124
-
125
- **Ask yourself:**
126
- - Can I solve this with standard programming knowledge? → Don't search
127
- - Is this about HOW this specific project works? → Search once
128
- - Am I searching just to be thorough? → Stop
129
-
130
- ### 2. Progressive Enhancement
131
-
132
- 1. Try solving with agent knowledge first
133
- 2. If user says "that's not how we do it" → search_documentation
134
- 3. If user seems satisfied → stop, don't over-engineer
135
-
136
- ### 3. Time-Box Searches
137
-
138
- - Simple fix: 0 searches
139
- - Standard task: Max 1 search, 1 retry
140
- - Complex feature: Max 3 searches total
141
- - If not found in 2 attempts → proceed with best practices
142
-
143
- ### 4. User Feedback Signals
144
-
145
- **Speed up when user says:**
146
- - "quick fix", "just", "simple", "for now"
147
- - Shows frustration with delays
148
- - Provides specific implementation details
149
-
150
- **Be thorough when user says:**
151
- - "proper", "correct", "production", "best practice"
152
- - "follow our patterns", "like we usually do"
153
- - Building something new or public-facing
154
-
155
- ## ULTRA-SMART BEHAVIOR PATTERNS
156
-
157
- ### Pattern Recognition Examples
158
-
159
- **"Fix the typo in getUserName"**
160
- - Intent: Typo fix
161
- - Thinking: Pure text fix, no logic change
162
- - Action: Direct fix, no tools needed
163
- - Time: < 10 seconds
164
-
165
- **"How do we handle errors?"**
166
- - Intent: Project pattern discovery
167
- - Thinking: "we" = project-specific
168
- - Action: `search_documentation("error handling")`
169
- - Time: 30-60 seconds
170
-
171
- **"Add error handling to this function"**
172
- - Intent: Code modification
173
- - Thinking: Adding code = check rules
174
- - Action: `check_project_rules("error handling")` first, then implement
175
- - Time: < 30 seconds
176
-
177
- **"Implement user authentication"**
178
- - Intent: New feature
179
- - Thinking: Major feature = full compliance needed
180
- - Action:
181
- 1. `check_project_rules("authentication service")`
182
- 2. `search_documentation("auth")` if patterns unclear
183
- 3. `explore_api("AuthenticationServices")` if using specific API
184
- - Time: 1-2 minutes
185
-
186
- ### MANDATORY RULES ENFORCEMENT
187
-
188
- **Even for "simple" code changes:**
189
- ```javascript
190
- // User: "Add a null check here"
191
- 1. check_project_rules("input validation") // MANDATORY - might have specific patterns
192
- 2. Apply the null check pattern from rules
193
- 3. If no pattern found, use standard approach
194
- ```
195
-
196
- **Tool Usage Examples:**
197
- ```javascript
198
- // Starting a new feature
199
- await check_project_rules("payment processing");
200
- await get_global_rules(); // If need architecture overview
201
-
202
- // Modifying existing code
203
- await get_file_docs("src/services/payment.js");
204
- await check_project_rules("refactoring");
205
-
206
- // Finding patterns
207
- const results = await search_documentation("caching");
208
- if (results.length > 0) {
209
- await read_specific_document(results[0].fileName);
210
- }
211
-
212
- // Using specific APIs
213
- await explore_api("StripeAPI");
214
- ```
215
-
216
- **Only skip rules for:**
217
- - Fixing typos in strings/comments
218
- - Renaming variables (no logic change)
219
- - Adding debug logs (temporary)
220
- - Removing commented code
221
-
222
- ### Adaptive Intelligence
223
-
224
- **Start Fast, Get Smarter:**
225
- 1. Default to speed for unclear requests
226
- 2. If user corrects you → learn and search
227
- 3. Remember patterns within conversation
228
- 4. Don't repeat searches that found nothing
229
-
230
- **Context Clues for Speed:**
231
- - Stack trace present → Fast fix
232
- - "Broken/failing" → Fix first, optimize later
233
- - Multiple files mentioned → May need patterns
234
- - Single line number → Almost never needs search
235
-
236
- ## SUCCESS METRICS
237
-
238
- **You're succeeding when:**
239
- - User gets help in < 30 seconds for simple tasks
240
- - Project patterns used only when they add value
241
- - No "searching documentation..." for obvious fixes
242
- - User doesn't have to say "just do X" repeatedly
243
- - Complex features still follow project patterns
244
-
245
- ## THE GOLDEN RULES
246
-
247
- ### Rule 1: ALWAYS Check Project Rules for Code Generation
248
- **Before writing code, call `check_project_rules()`** - Rules with `alwaysApply: true` are MANDATORY, even for "simple" tasks.
249
-
250
- ### Rule 2: Be Smart About Documentation
251
- **Think like a senior dev who knows when to look things up vs when to just fix it.**
252
-
253
- ### Rule 3: Speed + Compliance
254
- **Fast when possible. Compliant always. Smart about everything.**
255
-
256
- ## COMPLIANCE SUMMARY
257
-
258
- ✅ **MUST check rules for:**
259
- - Any new code generation
260
- - Code modifications (beyond trivial)
261
- - Bug fixes that change logic
262
- - Adding any functionality
263
-
264
- ❌ **Can skip rules for:**
265
- - Typo fixes in strings/comments
266
- - Variable renames (no logic change)
267
- - Adding temporary debug statements
268
- - Removing dead code
269
-
270
- **Remember:** `alwaysApply: true` rules are NON-NEGOTIABLE. Check them even if you think you know the answer.