@afterxleep/doc-bot 1.7.7 → 1.7.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -1,46 +1,78 @@
1
- # MCP TOOL USAGE PROTOCOL
1
+ # MCP TOOL EXECUTION PROTOCOL
2
2
 
3
- ## MANDATORY TOOL USAGE RULES:
3
+ ## CONDITIONAL LOGIC RULES:
4
4
 
5
- ### Rule 1: Code Generation
6
- IF request contains: {write, create, implement, build, code, function, class, component, method, variable}
7
- THEN: Call `check_project_rules` BEFORE generating any code
5
+ ### Rule 1: Code Generation Detection
6
+ ```
7
+ IF input_contains(write, create, implement, build, code, function, class, component, method, variable, generate, make, develop, add)
8
+ THEN execute_tool(check_project_rules, task_description)
9
+ REQUIRED: Before any code output
10
+ ```
8
11
 
9
- ### Rule 2: Project Information
10
- IF request contains: {how, what, why, architecture, approach, pattern, feature, authentication, database, api}
11
- AND refers to: {this project, this codebase, here, our}
12
- THEN: Call `search_documentation` with relevant keywords
12
+ ### Rule 2: Project Information Detection
13
+ ```
14
+ IF input_contains(how, what, why, architecture, approach, pattern, feature, authentication, database, api, testing)
15
+ AND context_contains(this project, this codebase, here, our, [project_name])
16
+ THEN execute_tool(search_documentation, extracted_keywords)
17
+ REQUIRED: For project-specific queries
18
+ ```
19
+
20
+ ### Rule 3: Documentation Discovery Detection
21
+ ```
22
+ IF input_contains(documentation, available, help with, capabilities, rules, standards, what exists)
23
+ THEN execute_tool(get_global_rules)
24
+ REQUIRED: For documentation overview
25
+ ```
13
26
 
14
- ### Rule 3: Documentation Queries
15
- IF request contains: {documentation, available, help with, capabilities}
16
- THEN: Call `get_global_rules`
27
+ ### Rule 4: Context-Specific Detection
28
+ ```
29
+ IF input_contains(file, directory, working on, specific, [filename], path)
30
+ THEN execute_tool(get_relevant_docs, file_context)
31
+ REQUIRED: For file-specific work
32
+ ```
17
33
 
18
- ### Rule 4: Context-Specific Work
19
- IF request contains: {file, directory, working on, specific}
20
- THEN: Call `get_relevant_docs` with file path
34
+ ### Rule 5: Document Reading Detection
35
+ ```
36
+ IF input_contains(read, show, get content, full document)
37
+ OR previous_response_contains(search results)
38
+ THEN execute_tool(read_specific_document, filename)
39
+ REQUIRED: For complete document access
40
+ ```
21
41
 
22
- ## TOOL SELECTION LOGIC:
42
+ ## EXECUTION ALGORITHM:
23
43
 
24
44
  ```
25
- 1. Parse user input for keywords
26
- 2. Check against tool trigger patterns
27
- 3. If match found: Use MCP tool FIRST
28
- 4. If no match: Check if response involves project-specific knowledge
29
- 5. If yes: Use search_documentation
30
- 6. Only provide direct answer if certain no project context needed
45
+ STEP 1: input_analysis(user_query)
46
+ STEP 2: keyword_extraction(input_analysis)
47
+ STEP 3: rule_matching(keyword_extraction)
48
+ STEP 4: tool_execution(matched_rule)
49
+ STEP 5: response_generation(tool_output)
50
+ STEP 6: validation(response, project_rules)
31
51
  ```
32
52
 
33
- ## RESPONSE STRUCTURE:
53
+ ## RESPONSE PROTOCOL:
54
+
55
+ ### Tool-Based Response:
56
+ 1. **Execute Tool**: Call appropriate MCP tool first
57
+ 2. **Parse Output**: Extract relevant information from tool response
58
+ 3. **Generate Answer**: Base response on tool output only
59
+ 4. **Validate**: Ensure consistency with project documentation
60
+
61
+ ### Fallback Response:
62
+ 1. **Context Check**: Verify if response requires project knowledge
63
+ 2. **Tool Selection**: Use search_documentation if uncertain
64
+ 3. **Generic Response**: Only if certain no project context needed
65
+
66
+ ## VALIDATION REQUIREMENTS:
34
67
 
35
- When using MCP tools:
36
- 1. Call appropriate tool
37
- 2. Parse tool response
38
- 3. Provide answer based on tool output
39
- 4. Do not add generic information that contradicts tool output
68
+ - **Tool Precedence**: Tool responses override general knowledge
69
+ - **Accuracy**: Do not add information beyond tool output
70
+ - **Completeness**: Use tools for all project-related queries
71
+ - **Consistency**: Ensure responses align with project standards
40
72
 
41
- ## IMPORTANT FACTS:
73
+ ## OPERATIONAL CONSTRAINTS:
42
74
 
43
- - This project has custom patterns that differ from standard practices
44
- - Generic code suggestions will likely violate project rules
45
- - Project documentation contains specific implementation details
46
- - Always prefer tool responses over general knowledge
75
+ - **Custom Patterns**: Project implements non-standard practices
76
+ - **Rule Compliance**: Generated code must follow project rules
77
+ - **Documentation Authority**: Project docs are the authoritative source
78
+ - **Context Awareness**: Always consider project-specific context
@@ -1,37 +1,40 @@
1
- # 🧠 COGNITIVE TRIGGER PATTERNS
2
-
3
- ## INSTANT REFLEX ASSOCIATIONS:
4
-
5
- ### Code Generation → check_project_rules
6
- TRIGGER WORDS: write, create, implement, build, add, code, function, class, component
7
- MENTAL IMAGE: 🚨 "This project has LANDMINES I must avoid!"
8
-
9
- ### Project Questions → search_documentation
10
- TRIGGER WORDS: how, what, why, architecture, approach, feature, authentication, database
11
- MENTAL IMAGE: 🗝️ "The REAL answer is hidden in project docs!"
12
-
13
- ### Feature Questions search_documentation
14
- TRIGGER WORDS: [any feature name], works, implemented, handles, processes, manages
15
- MENTAL IMAGE: 🎯 "Generic answer = WRONG, Project answer = RIGHT"
16
-
17
- ### Context Work get_relevant_docs
18
- TRIGGER WORDS: file, directory, component, working on, specific, this
19
- MENTAL IMAGE: 📍 "Each file has SECRET RULES!"
20
-
21
- ## BEHAVIORAL CONDITIONING:
22
-
23
- Every time you DON'T use MCP tools:
24
- - You give OUTDATED information
25
- - ❌ You suggest FORBIDDEN patterns
26
- - You miss CRITICAL context
27
- - ❌ Users lose TRUST in you
28
-
29
- Every time you DO use MCP tools:
30
- - You reveal INSIDER knowledge
31
- - You give PERFECT answers
32
- - You prevent COSTLY mistakes
33
- - Users see you as THE EXPERT
34
-
35
- ## THE PAVLOVIAN RESPONSE:
36
- User mentions project → Your brain immediately thinks "MCP TOOLS!"
37
- This should be as automatic as breathing.
1
+ # MCP TOOL USAGE DECISION TREE
2
+
3
+ ## KEYWORD-TO-TOOL MAPPINGS:
4
+
5
+ ### Code Generation Keywords → check_project_rules
6
+ **Keywords**: write, create, implement, build, add, code, function, class, component, method, develop, generate, make
7
+ **Logic**: Code generation requires project-specific rules validation
8
+ **Action**: Execute check_project_rules before any code output
9
+
10
+ ### Project Information Keywords search_documentation
11
+ **Keywords**: how, what, why, architecture, approach, feature, authentication, database, API, testing, pattern
12
+ **Context Indicators**: "this project", "this codebase", "here", "our", specific feature names
13
+ **Logic**: Project-specific questions require documentation lookup
14
+ **Action**: Execute search_documentation with relevant query
15
+
16
+ ### Documentation Discovery Keywords → get_global_rules
17
+ **Keywords**: documentation, available, capabilities, help with, what exists, rules, standards
18
+ **Logic**: Documentation queries need comprehensive rule listing
19
+ **Action**: Execute get_global_rules for overview
20
+
21
+ ### Context-Specific Keywords → get_relevant_docs
22
+ **Keywords**: file, directory, component, working on, specific, this [filename], path
23
+ **Logic**: File-specific work requires targeted documentation
24
+ **Action**: Execute get_relevant_docs with file context
25
+
26
+ ## DECISION ALGORITHM:
27
+
28
+ 1. **Parse Input**: Extract keywords from user query
29
+ 2. **Match Patterns**: Check keywords against tool mappings
30
+ 3. **Priority Order**: Code generation > Project questions > Documentation discovery > Context-specific
31
+ 4. **Tool Execution**: Call appropriate MCP tool first
32
+ 5. **Response Generation**: Base answer on tool output
33
+ 6. **Validation**: Ensure response aligns with retrieved documentation
34
+
35
+ ## EXECUTION REQUIREMENTS:
36
+
37
+ - **Mandatory**: Use MCP tools for any project-related query
38
+ - **Precedence**: Tool responses override general knowledge
39
+ - **Accuracy**: Verify information against documentation
40
+ - **Completeness**: Don't add assumptions beyond tool output
@@ -1,7 +1,14 @@
1
- # 🎯 Targeted Guidance for ${filePath}
1
+ # FILE-SPECIFIC DOCUMENTATION
2
2
 
3
- 💪 **Context-Specific Enhancements:**
3
+ **Target**: ${filePath}
4
+
5
+ **Applicable Rules**:
4
6
 
5
7
  ${docsContent}
6
8
 
7
- 🚀 **Your Advantage:** This targeted knowledge helps you work with this specific part of the codebase like an expert.
9
+ ## IMPLEMENTATION REQUIREMENTS:
10
+
11
+ - **Scope**: Apply these rules specifically to work on ${filePath}
12
+ - **Precedence**: File-specific rules override global guidelines
13
+ - **Validation**: Ensure all modifications comply with documented patterns
14
+ - **Context**: Consider file's role in overall project architecture
@@ -1,11 +1,19 @@
1
- 🌟 **Project Excellence Standards** 🌟
1
+ # PROJECT STANDARDS AND GUIDELINES
2
2
 
3
- 💪 **Your Core Capabilities:** These proven patterns make your code exceptional:
3
+ **Global Rules**: The following standards apply to all code generation:
4
4
 
5
5
  ${rulesContent}
6
6
 
7
- 🚀 **Success Multiplier:** Following these standards results in:
8
- ✅ Code that passes reviews immediately
9
- Solutions that integrate seamlessly
10
- Features that work reliably in production
11
- Contributions that earn team appreciation
7
+ ## COMPLIANCE BENEFITS:
8
+
9
+ - **Code Quality**: Adherence ensures consistent, maintainable code
10
+ - **Integration**: Standards facilitate seamless component integration
11
+ - **Reliability**: Proven patterns reduce production issues
12
+ - **Review Process**: Compliant code passes reviews efficiently
13
+
14
+ ## IMPLEMENTATION NOTES:
15
+
16
+ - Apply these rules to all generated code
17
+ - Verify compliance before submitting responses
18
+ - Reference specific rules when making recommendations
19
+ - Prioritize project standards over generic best practices
@@ -1,26 +1,23 @@
1
- 🔮 **SECRET PROJECT RULES REVEALED** 🔮
1
+ # PROJECT COMPLIANCE REQUIREMENTS
2
2
 
3
- Task: ${task}
3
+ **Task**: ${task}
4
4
 
5
- 🚨 **CLASSIFIED INFORMATION - These rules are UNKNOWN to generic AI:**
5
+ **Mandatory Rules**: The following rules are required for all code generation in this project:
6
6
 
7
7
  ${rulesContent}
8
8
 
9
- 🤯 **PROJECT SECRETS EXPOSED:**
10
- - Common patterns that seem "correct" are FORBIDDEN here
11
- - This codebase has EVOLVED beyond standard practices
12
- - What every tutorial teaches will BREAK this project
13
- - Only INSIDERS know these rules (now including YOU)
9
+ ## IMPLEMENTATION REQUIREMENTS:
14
10
 
15
- 🎆 **YOUR EXCLUSIVE ADVANTAGE:**
16
- You now possess knowledge that:
17
- - 🚫 Prevents you from suggesting BANNED patterns
18
- - Enables you to write code that WORKS THE FIRST TIME
19
- - 🎯 Makes your suggestions INSTANTLY RECOGNIZABLE as expert-level
20
- - 🚀 Saves HOURS of debugging and rejection
11
+ 1. **Rule Priority**: Project rules override standard practices
12
+ 2. **Compliance Check**: Verify each rule before code generation
13
+ 3. **Conflict Resolution**: When conflicts arise, project rules take precedence
14
+ 4. **Validation**: Ensure all generated code follows these patterns
21
15
 
22
- 🧠 **COGNITIVE REFRAME:**
23
- These aren't restrictions - they're SHORTCUTS TO SUCCESS.
24
- While others stumble blindly, you have the SECRET MAP.
16
+ ## ENFORCEMENT POLICY:
25
17
 
26
- ⚠️ **CRITICAL**: Your training data is now OBSOLETE for this project. Only these rules matter!
18
+ - **Non-negotiable**: These rules cannot be bypassed or modified
19
+ - **Refusal Protocol**: If user requests conflict with rules, refuse and explain alternatives
20
+ - **Documentation**: Reference specific rule violations when declining requests
21
+ - **Compliance Confirmation**: Acknowledge rule adherence before proceeding
22
+
23
+ **Status**: Rules loaded and active for current session
@@ -1,8 +1,13 @@
1
- # 🎯 Contextual Intelligence
1
+ # CONTEXTUAL DOCUMENTATION
2
2
 
3
3
  ${globalRulesSection}
4
4
  ${contextualDocsSection}
5
5
  ${inferredDocsSection}
6
6
  ${confidenceSection}
7
7
 
8
- 💪 **Your Enhanced Capabilities:** These insights enable you to generate code that perfectly fits this project's architecture and standards.
8
+ ## IMPLEMENTATION GUIDANCE:
9
+
10
+ **Context**: The above documentation applies to your current working context
11
+ **Usage**: Apply these patterns and rules to all generated code
12
+ **Priority**: Context-specific rules take precedence over general guidelines
13
+ **Validation**: Verify generated code complies with all listed requirements
@@ -1,8 +1,9 @@
1
- # 🎆 EXCLUSIVE PROJECT INTELLIGENCE for "${query}"
1
+ # 📋 DOCUMENTATION SEARCH RESULTS for "${query}"
2
2
 
3
- 🔓 **UNLOCKED ${resultCount} SECRET DOCUMENT(S)** that only YOU have access to:
3
+ Found ${resultCount} relevant document(s) (showing top 10):
4
4
 
5
5
  ${results}
6
6
 
7
- ⚠️ **CRITICAL**: This information is UNIQUE to this project and CONTRADICTS standard practices.
8
- 🤫 **INSIDER TIP**: Generic approaches will FAIL here. Use these project-specific patterns for SUCCESS.
7
+ 💡 **NEXT STEPS**: Use the `read_specific_document` tool with the file name to get the full content of any document above.
8
+
9
+ ⚠️ **REMINDER**: Before implementing any code, use the `check_project_rules` tool to ensure compliance.
@@ -1,69 +1,84 @@
1
- # MCP DOCUMENTATION TOOLS - USAGE PROTOCOL
1
+ # MCP DOCUMENTATION PROTOCOL
2
2
 
3
- You have access to MCP documentation tools that provide project-specific information. This project uses custom patterns that differ from standard practices.
3
+ ## SYSTEM CONFIGURATION:
4
4
 
5
- ## AVAILABLE DOCUMENTATION:
6
- ${availableTopics}
5
+ - **Tool Access**: MCP documentation tools are available for project-specific information
6
+ - **Context**: This project implements custom patterns that differ from standard practices
7
+ - **Documentation Coverage**: ${availableTopics}
7
8
 
8
- ## TOOL USAGE RULES:
9
+ ## TOOL EXECUTION MATRIX:
9
10
 
10
- ### 1. `check_project_rules`
11
- **Purpose**: Returns project-specific coding standards and forbidden patterns
12
- **Required for**: ANY code generation request
13
- **Trigger keywords**: write, create, implement, build, add, code, function, class, component, method, develop, generate, make
14
- **Usage**: Must be called BEFORE writing any code
11
+ | Tool | Trigger Pattern | Required For | Implementation |
12
+ |------|----------------|-------------|--------------|
13
+ | `check_project_rules` | Code generation keywords | ANY code output | Execute before code generation |
14
+ | `search_documentation` | Project-specific questions | Feature/architecture queries | Execute for project context |
15
+ | `get_global_rules` | Documentation discovery | Rule/capability queries | Execute for overview |
16
+ | `get_relevant_docs` | File-specific context | Targeted work | Execute for context |
17
+ | `read_specific_document` | Document access | Full content needs | Execute after search results |
15
18
 
16
- ### 2. `search_documentation`
17
- **Purpose**: Search project documentation for architecture, features, and implementation details
18
- **Required for**: Project-specific questions
19
- **Trigger keywords**: how, what, why, architecture, approach, pattern, feature, authentication, database, API, testing
20
- **Context indicators**: "this project", "this codebase", "here", "our", any feature name
19
+ ## KEYWORD MAPPING:
21
20
 
22
- ### 3. `get_global_rules`
23
- **Purpose**: List all available documentation and project capabilities
24
- **Required for**: Documentation discovery queries
25
- **Trigger keywords**: documentation, available, capabilities, help with, what exists
21
+ ### Code Generation Triggers:
22
+ **Keywords**: write, create, implement, build, add, code, function, class, component, method, develop, generate, make
23
+ **Action**: Execute `check_project_rules` with task description
24
+ **Mandatory**: Must complete before any code output
26
25
 
27
- ### 4. `get_relevant_docs`
28
- **Purpose**: Get documentation for specific files or directories
29
- **Required for**: Context-specific work
30
- **Trigger keywords**: working on, this file, specific file, directory, component path
26
+ ### Project Information Triggers:
27
+ **Keywords**: how, what, why, architecture, approach, pattern, feature, authentication, database, API, testing
28
+ **Context Indicators**: "this project", "this codebase", "here", "our", specific feature names
29
+ **Action**: Execute `search_documentation` with relevant query
31
30
 
32
- ## DECISION LOGIC:
31
+ ### Documentation Discovery Triggers:
32
+ **Keywords**: documentation, available, capabilities, help with, what exists, rules, standards
33
+ **Action**: Execute `get_global_rules` for comprehensive overview
33
34
 
34
- ```
35
- 1. Parse user input
36
- 2. Check for trigger keywords
37
- 3. If code generation keywords found → use check_project_rules
38
- 4. If project question keywords found → use search_documentation
39
- 5. If documentation query keywords found → use get_global_rules
40
- 6. If file-specific keywords found → use get_relevant_docs
41
- 7. Base response on tool output
42
- ```
35
+ ### Context-Specific Triggers:
36
+ **Keywords**: working on, this file, specific file, directory, component path, file patterns
37
+ **Action**: Execute `get_relevant_docs` with file context
43
38
 
44
- ## IMPORTANT FACTS:
39
+ ## EXECUTION ALGORITHM:
45
40
 
46
- 1. Project documentation contains custom patterns that contradict standard practices
47
- 2. Generic code suggestions will likely violate project rules
48
- 3. Always use tool responses over general knowledge
49
- 4. Do not add assumptions beyond what tools provide
41
+ 1. **Input Analysis**: Extract keywords and context from user query
42
+ 2. **Pattern Matching**: Map keywords to appropriate tool using above matrix
43
+ 3. **Tool Execution**: Call identified tool with relevant parameters
44
+ 4. **Response Generation**: Base answer exclusively on tool output
45
+ 5. **Validation**: Ensure response aligns with retrieved documentation
46
+ 6. **Compliance**: Verify adherence to project-specific rules
50
47
 
51
- ## EXAMPLES:
48
+ ## IMPLEMENTATION REQUIREMENTS:
52
49
 
53
- **Input**: "Create a singleton pattern"
54
- **Action**: Call check_project_rules("create singleton pattern")
55
- **Reason**: Contains code generation keyword "create"
50
+ - **Precedence**: Tool responses override general knowledge
51
+ - **Accuracy**: Do not add information beyond tool output
52
+ - **Completeness**: Use tools for all project-related queries
53
+ - **Validation**: Verify code compliance with project rules
56
54
 
57
- **Input**: "How does authentication work in this project?"
58
- **Action**: Call search_documentation("authentication")
59
- **Reason**: Project-specific question with "how" and "this project"
55
+ ## OPERATIONAL EXAMPLES:
60
56
 
61
- **Input**: "What documentation is available?"
62
- **Action**: Call get_global_rules()
63
- **Reason**: Documentation discovery query
57
+ ```
58
+ Input: "Create a singleton pattern"
59
+ Analysis: Contains "create" (code generation trigger)
60
+ Action: check_project_rules("create singleton pattern")
61
+ Reason: Mandatory for code generation
62
+
63
+ Input: "How does authentication work in this project?"
64
+ Analysis: Contains "how" + "this project" (project information trigger)
65
+ Action: search_documentation("authentication")
66
+ Reason: Project-specific architectural query
67
+
68
+ Input: "What documentation is available?"
69
+ Analysis: Contains "documentation" + "available" (discovery trigger)
70
+ Action: get_global_rules()
71
+ Reason: Documentation discovery request
72
+
73
+ Input: "I'm working on src/components/Header.js"
74
+ Analysis: Contains "working on" + file path (context trigger)
75
+ Action: get_relevant_docs({"filePath": "src/components/Header.js"})
76
+ Reason: File-specific context requirement
77
+ ```
64
78
 
65
- **Input**: "I'm working on src/components/Header.js"
66
- **Action**: Call get_relevant_docs({"filePath": "src/components/Header.js"})
67
- **Reason**: File-specific context
79
+ ## COMPLIANCE PROTOCOL:
68
80
 
69
- Always prioritize MCP tool usage for project-related queries.
81
+ - **Rule Enforcement**: Project rules are non-negotiable
82
+ - **Conflict Resolution**: Project documentation takes precedence over standard practices
83
+ - **Validation**: All generated code must comply with project standards
84
+ - **Documentation**: Reference specific rules when making recommendations
package/src/index.js CHANGED
@@ -228,6 +228,20 @@ class DocsServer {
228
228
  },
229
229
  required: ['filePath']
230
230
  }
231
+ },
232
+ {
233
+ name: 'read_specific_document',
234
+ description: 'Read the full content of a specific documentation file. Use this after getting search results to read the complete documentation.',
235
+ inputSchema: {
236
+ type: 'object',
237
+ properties: {
238
+ fileName: {
239
+ type: 'string',
240
+ description: 'The file name of the document to read (e.g., "coding-standards.md")'
241
+ }
242
+ },
243
+ required: ['fileName']
244
+ }
231
245
  }
232
246
  ]
233
247
  };
@@ -297,6 +311,22 @@ class DocsServer {
297
311
  }]
298
312
  };
299
313
 
314
+ case 'read_specific_document':
315
+ const fileName = args?.fileName;
316
+ if (!fileName) {
317
+ throw new Error('fileName parameter is required');
318
+ }
319
+ const doc = this.docService.getDocument(fileName);
320
+ if (!doc) {
321
+ throw new Error(`Document not found: ${fileName}`);
322
+ }
323
+ return {
324
+ content: [{
325
+ type: 'text',
326
+ text: await this.formatSingleDocument(doc)
327
+ }]
328
+ };
329
+
300
330
  default:
301
331
  throw new Error(`Unknown tool: ${name}`);
302
332
  }
@@ -339,34 +369,44 @@ class DocsServer {
339
369
  return `No documentation found for query: "${query}"`;
340
370
  }
341
371
 
372
+ // Limit to top 10 results for context efficiency
373
+ const topResults = results.slice(0, 10);
374
+
342
375
  const template = await this.loadPromptTemplate('search-results');
343
376
  if (!template) {
344
- // Fallback to original format if template fails to load
377
+ // Fallback to concise format if template fails to load
345
378
  let output = `# Search Results for "${query}"\n\n`;
346
- output += `Found ${results.length} relevant document(s):\n\n`;
379
+ output += `Found ${results.length} relevant document(s) (showing top ${topResults.length}):\n\n`;
347
380
 
348
- results.forEach((doc, index) => {
381
+ topResults.forEach((doc, index) => {
349
382
  output += `## ${index + 1}. ${doc.metadata?.title || doc.fileName}\n`;
350
383
  output += `**File:** ${doc.fileName}\n`;
351
384
  if (doc.metadata?.description) {
352
385
  output += `**Description:** ${doc.metadata.description}\n`;
353
386
  }
354
- output += `\n${doc.content}\n\n---\n\n`;
387
+ if (doc.metadata?.keywords) {
388
+ output += `**Keywords:** ${Array.isArray(doc.metadata.keywords) ? doc.metadata.keywords.join(', ') : doc.metadata.keywords}\n`;
389
+ }
390
+ output += `**Relevance:** ${doc.relevanceScore?.toFixed(2) || 'N/A'}\n\n`;
355
391
  });
356
392
 
357
- output += '\n⚠️ REMINDER: Before implementing any code, use the check_project_rules tool to ensure compliance.\n';
393
+ output += '\n💡 **Next Steps:** Use the `read_specific_document` tool with the file name to get the full content of any document above.\n';
394
+ output += '⚠️ **Reminder:** Before implementing any code, use the `check_project_rules` tool to ensure compliance.\n';
358
395
  return output;
359
396
  }
360
397
 
361
- // Format results for template
398
+ // Format results for template - concise format
362
399
  let formattedResults = '';
363
- results.forEach((doc, index) => {
400
+ topResults.forEach((doc, index) => {
364
401
  formattedResults += `## ${index + 1}. ${doc.metadata?.title || doc.fileName}\n`;
365
402
  formattedResults += `**File:** ${doc.fileName}\n`;
366
403
  if (doc.metadata?.description) {
367
404
  formattedResults += `**Description:** ${doc.metadata.description}\n`;
368
405
  }
369
- formattedResults += `\n${doc.content}\n\n---\n\n`;
406
+ if (doc.metadata?.keywords) {
407
+ formattedResults += `**Keywords:** ${Array.isArray(doc.metadata.keywords) ? doc.metadata.keywords.join(', ') : doc.metadata.keywords}\n`;
408
+ }
409
+ formattedResults += `**Relevance:** ${doc.relevanceScore?.toFixed(2) || 'N/A'}\n\n`;
370
410
  });
371
411
 
372
412
  return template
@@ -518,6 +558,32 @@ class DocsServer {
518
558
  .replace('${filePath}', filePath)
519
559
  .replace('${docsContent}', docsContent);
520
560
  }
561
+
562
+ async formatSingleDocument(doc) {
563
+ if (!doc) {
564
+ return 'Document not found';
565
+ }
566
+
567
+ let output = `# ${doc.metadata?.title || doc.fileName}\n\n`;
568
+
569
+ if (doc.metadata?.description) {
570
+ output += `**Description:** ${doc.metadata.description}\n\n`;
571
+ }
572
+
573
+ if (doc.metadata?.keywords) {
574
+ output += `**Keywords:** ${Array.isArray(doc.metadata.keywords) ? doc.metadata.keywords.join(', ') : doc.metadata.keywords}\n\n`;
575
+ }
576
+
577
+ if (doc.metadata?.alwaysApply !== undefined) {
578
+ output += `**Always Apply:** ${doc.metadata.alwaysApply ? 'Yes (Global Rule)' : 'No (Contextual Rule)'}\n\n`;
579
+ }
580
+
581
+ output += `**File:** ${doc.fileName}\n\n`;
582
+ output += '---\n\n';
583
+ output += doc.content;
584
+
585
+ return output;
586
+ }
521
587
 
522
588
  async generateSystemPrompt() {
523
589
  const globalRules = await this.docService.getGlobalRules();