@afterxleep/doc-bot 1.17.0 → 1.19.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.
- package/package.json +7 -4
- package/src/__tests__/temp-docs-1756129972061/test.md +5 -0
- package/src/__tests__/temp-docs-1756129972071/test.md +5 -0
- package/src/__tests__/temp-docs-1756129972075/test.md +5 -0
- package/src/__tests__/temp-docs-1756129972077/test.md +5 -0
- package/src/__tests__/temp-docs-1756129972079/test.md +5 -0
- package/src/__tests__/temp-docs-1756130189361/test.md +5 -0
- package/src/__tests__/temp-docs-1756130189372/test.md +5 -0
- package/src/__tests__/temp-docs-1756130189375/test.md +5 -0
- package/src/__tests__/temp-docs-1756130189378/test.md +5 -0
- package/src/__tests__/temp-docs-1756130189379/test.md +5 -0
- package/src/__tests__/temp-docs-1756130271128/test.md +5 -0
- package/src/__tests__/temp-docs-1756130271139/test.md +5 -0
- package/src/__tests__/temp-docs-1756130271142/test.md +5 -0
- package/src/__tests__/temp-docs-1756130271145/test.md +5 -0
- package/src/__tests__/temp-docs-1756130271146/test.md +5 -0
- package/src/__tests__/temp-docs-1756130687030/test.md +5 -0
- package/src/__tests__/temp-docs-1756130687044/test.md +5 -0
- package/src/__tests__/temp-docs-1756130687048/test.md +5 -0
- package/src/__tests__/temp-docs-1756130687051/test.md +5 -0
- package/src/__tests__/temp-docs-1756130687053/test.md +5 -0
- package/src/__tests__/temp-docs-1756131694925/test.md +5 -0
- package/src/__tests__/temp-docs-1756131694937/test.md +5 -0
- package/src/__tests__/temp-docs-1756131694941/test.md +5 -0
- package/src/__tests__/temp-docs-1756131694944/test.md +5 -0
- package/src/__tests__/temp-docs-1756131694946/test.md +5 -0
- package/src/__tests__/temp-docs-1756133998710/test.md +5 -0
- package/src/__tests__/temp-docs-1756133998721/test.md +5 -0
- package/src/__tests__/temp-docs-1756133998724/test.md +5 -0
- package/src/__tests__/temp-docs-1756133998727/test.md +5 -0
- package/src/__tests__/temp-docs-1756133998729/test.md +5 -0
- package/src/__tests__/temp-docs-1756134345935/test.md +5 -0
- package/src/__tests__/temp-docs-1756134345948/test.md +5 -0
- package/src/__tests__/temp-docs-1756134345952/test.md +5 -0
- package/src/__tests__/temp-docs-1756134345954/test.md +5 -0
- package/src/__tests__/temp-docs-1756134345957/test.md +5 -0
- package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756129972079/2e443167/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756129972079/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756129972079/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130189379/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130189379/a4934c14/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130189379/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130271146/3f8acbb2/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130271146/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130271146/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130687053/6810e6bd/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756130687053/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756130687053/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756131694946/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756131694946/dd703046/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756131694946/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756133998729/9e061136/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756133998729/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756133998729/docsets.json +10 -0
- package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756134345957/03e730af/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Info.plist +10 -0
- package/src/__tests__/temp-docsets-1756134345957/Mock.docset/Contents/Resources/docSet.dsidx +0 -0
- package/src/__tests__/temp-docsets-1756134345957/docsets.json +10 -0
- package/src/index.js +269 -63
- package/src/services/DocumentationService.js +26 -1
- package/src/services/PaginationService.js +378 -0
- package/src/services/__tests__/PaginationService.integration.test.js +185 -0
- package/src/services/__tests__/PaginationService.test.js +398 -0
- package/src/utils/TokenEstimator.js +134 -0
- package/prompts/file-docs.md +0 -69
- package/prompts/global-rules.md +0 -142
- package/prompts/mandatory-rules.md +0 -90
- package/prompts/search-results.md +0 -59
- package/prompts/system-prompt.md +0 -270
- package/src/__tests__/docset-integration.test.js +0 -146
- package/src/services/__tests__/DocumentationService.test.js +0 -318
- package/src/services/__tests__/UnifiedSearchService.test.js +0 -302
- package/src/services/docset/__tests__/EnhancedDocsetDatabase.test.js +0 -324
package/prompts/global-rules.md
DELETED
|
@@ -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.
|
package/prompts/system-prompt.md
DELETED
|
@@ -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.
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { DocsServer } from '../index.js';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
import { dirname } from 'path';
|
|
6
|
-
import os from 'os';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
describe('DocsServer Docset Integration', () => {
|
|
12
|
-
let server;
|
|
13
|
-
let tempDocsPath;
|
|
14
|
-
let tempDocsetsPath;
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
// Create temporary directories
|
|
18
|
-
tempDocsPath = path.join(__dirname, 'temp-docs-' + Date.now());
|
|
19
|
-
tempDocsetsPath = path.join(__dirname, 'temp-docsets-' + Date.now());
|
|
20
|
-
|
|
21
|
-
await fs.ensureDir(tempDocsPath);
|
|
22
|
-
await fs.ensureDir(tempDocsetsPath);
|
|
23
|
-
|
|
24
|
-
// Create a simple test doc
|
|
25
|
-
await fs.writeFile(
|
|
26
|
-
path.join(tempDocsPath, 'test.md'),
|
|
27
|
-
'---\nalwaysApply: true\ntitle: Test Doc\n---\n# Test'
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
if (server) {
|
|
33
|
-
await server.close();
|
|
34
|
-
}
|
|
35
|
-
await fs.remove(tempDocsPath);
|
|
36
|
-
await fs.remove(tempDocsetsPath);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('Server initialization with docsets', () => {
|
|
40
|
-
it('should initialize with custom docsets path', async () => {
|
|
41
|
-
server = new DocsServer({
|
|
42
|
-
docsPath: tempDocsPath,
|
|
43
|
-
docsetsPath: tempDocsetsPath,
|
|
44
|
-
verbose: false
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
await server.start();
|
|
48
|
-
|
|
49
|
-
expect(server.docsetService).toBeDefined();
|
|
50
|
-
expect(server.docsetService.storagePath).toBe(tempDocsetsPath);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should use default docsets path when not provided', async () => {
|
|
54
|
-
server = new DocsServer({
|
|
55
|
-
docsPath: tempDocsPath,
|
|
56
|
-
verbose: false
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
await server.start();
|
|
60
|
-
|
|
61
|
-
const expectedPath = path.join(os.homedir(), 'Developer', 'DocSets');
|
|
62
|
-
expect(server.docsetService.storagePath).toBe(expectedPath);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('Docset service functionality', () => {
|
|
67
|
-
beforeEach(async () => {
|
|
68
|
-
server = new DocsServer({
|
|
69
|
-
docsPath: tempDocsPath,
|
|
70
|
-
docsetsPath: tempDocsetsPath,
|
|
71
|
-
verbose: false
|
|
72
|
-
});
|
|
73
|
-
await server.start();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('should have docset service initialized', () => {
|
|
77
|
-
expect(server.docsetService).toBeDefined();
|
|
78
|
-
expect(server.multiDocsetDatabase).toBeDefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should have empty docsets initially', async () => {
|
|
82
|
-
const docsets = await server.docsetService.listDocsets();
|
|
83
|
-
expect(docsets).toEqual([]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should handle docset operations', async () => {
|
|
87
|
-
// Create a mock docset
|
|
88
|
-
const mockDocsetPath = path.join(tempDocsetsPath, 'Mock.docset');
|
|
89
|
-
const contentsPath = path.join(mockDocsetPath, 'Contents');
|
|
90
|
-
const resourcesPath = path.join(contentsPath, 'Resources');
|
|
91
|
-
|
|
92
|
-
await fs.ensureDir(resourcesPath);
|
|
93
|
-
|
|
94
|
-
// Create Info.plist
|
|
95
|
-
const infoPlist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
96
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
97
|
-
<plist version="1.0">
|
|
98
|
-
<dict>
|
|
99
|
-
<key>CFBundleName</key>
|
|
100
|
-
<string>Mock Documentation</string>
|
|
101
|
-
<key>CFBundleIdentifier</key>
|
|
102
|
-
<string>mock.documentation</string>
|
|
103
|
-
</dict>
|
|
104
|
-
</plist>`;
|
|
105
|
-
await fs.writeFile(path.join(contentsPath, 'Info.plist'), infoPlist);
|
|
106
|
-
|
|
107
|
-
// Create SQLite database
|
|
108
|
-
const Database = (await import('better-sqlite3')).default;
|
|
109
|
-
const dbPath = path.join(resourcesPath, 'docSet.dsidx');
|
|
110
|
-
const db = new Database(dbPath);
|
|
111
|
-
db.exec(`
|
|
112
|
-
CREATE TABLE searchIndex(
|
|
113
|
-
id INTEGER PRIMARY KEY,
|
|
114
|
-
name TEXT,
|
|
115
|
-
type TEXT,
|
|
116
|
-
path TEXT
|
|
117
|
-
);
|
|
118
|
-
`);
|
|
119
|
-
db.prepare('INSERT INTO searchIndex (name, type, path) VALUES (?, ?, ?)')
|
|
120
|
-
.run('TestClass', 'Class', 'test.html');
|
|
121
|
-
db.close();
|
|
122
|
-
|
|
123
|
-
// Test adding docset
|
|
124
|
-
const docsetInfo = await server.docsetService.addDocset(mockDocsetPath);
|
|
125
|
-
expect(docsetInfo.name).toBe('Mock Documentation');
|
|
126
|
-
|
|
127
|
-
// Test listing docsets
|
|
128
|
-
const docsets = await server.docsetService.listDocsets();
|
|
129
|
-
expect(docsets).toHaveLength(1);
|
|
130
|
-
expect(docsets[0].name).toBe('Mock Documentation');
|
|
131
|
-
|
|
132
|
-
// Add to database for searching
|
|
133
|
-
server.multiDocsetDatabase.addDocset(docsetInfo);
|
|
134
|
-
|
|
135
|
-
// Test searching
|
|
136
|
-
const searchResults = server.multiDocsetDatabase.search('Test');
|
|
137
|
-
expect(searchResults).toHaveLength(1);
|
|
138
|
-
expect(searchResults[0].name).toBe('TestClass');
|
|
139
|
-
|
|
140
|
-
// Test removing docset
|
|
141
|
-
await server.docsetService.removeDocset(docsetInfo.id);
|
|
142
|
-
const finalDocsets = await server.docsetService.listDocsets();
|
|
143
|
-
expect(finalDocsets).toHaveLength(0);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
});
|