@afterxleep/doc-bot 1.22.0 → 1.23.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +87 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afterxleep/doc-bot",
3
- "version": "1.22.0",
3
+ "version": "1.23.1",
4
4
  "description": "Generic MCP server for intelligent documentation access in any project",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -166,7 +166,7 @@ class DocsServer {
166
166
  tools: [
167
167
  {
168
168
  name: 'check_project_rules',
169
- description: 'Get mandatory coding standards for your task. Always call before writing code. Returns architecture patterns, security requirements, and performance guidelines specific to this codebase. Critical for maintaining code quality and consistency.',
169
+ description: 'Get mandatory coding standards for your task. Call BEFORE writing ANY code AND whenever you start a new component/feature/file. Returns architecture patterns, security requirements, and performance guidelines specific to this codebase. Prevents rework by catching violations early. Use this repeatedly: before each major code block, when switching contexts, or when unsure about approach. CRITICAL: This gives you task-specific rules, but you should ALSO call doc_bot() for complete project context and checkpoint guidance. Think of check_project_rules as "what rules apply to this task" and doc_bot as "am I still aligned with the project".',
170
170
  inputSchema: {
171
171
  type: 'object',
172
172
  properties: {
@@ -180,7 +180,7 @@ class DocsServer {
180
180
  },
181
181
  {
182
182
  name: 'search_documentation',
183
- description: 'Search codebase documentation and API references. Searches project patterns, architecture decisions, and API docs. Best results with technical terms like class names, not descriptions. Examples: search "Widget" not "iOS 18 features". Supports pagination for large result sets.',
183
+ description: 'Search codebase documentation and API references - use THROUGHOUT your work, not just at the start. Call whenever you encounter unfamiliar code patterns, before implementing any feature, when debugging issues, or when you need examples. Searches project patterns, architecture decisions, and API docs. Best results with technical terms (class names, API names), not natural language descriptions. Example: search "Widget" NOT "iOS 18 features". If your first search doesn\'t help, search again with different terms - the docs are there to help you continuously.',
184
184
  inputSchema: {
185
185
  type: 'object',
186
186
  properties: {
@@ -210,7 +210,7 @@ class DocsServer {
210
210
  },
211
211
  {
212
212
  name: 'get_global_rules',
213
- description: 'Get comprehensive coding standards and architecture guidelines. Returns project-wide engineering principles, design patterns, performance requirements, and security standards. Essential reading for understanding the codebase philosophy.',
213
+ description: 'Get comprehensive coding standards and architecture guidelines - reference this when making ANY architectural decision, not just at project start. Returns project-wide engineering principles, design patterns, performance requirements, and security standards that override general best practices. Call when: starting work, making design decisions, resolving conflicts between approaches, or when implementation feels uncertain. These rules represent hard-learned lessons specific to THIS codebase.',
214
214
  inputSchema: {
215
215
  type: 'object',
216
216
  properties: {
@@ -224,7 +224,7 @@ class DocsServer {
224
224
  },
225
225
  {
226
226
  name: 'get_file_docs',
227
- description: 'Get file-specific coding patterns and conventions. Returns contextual guidelines, performance considerations, and architectural decisions for specific files or directories. Use before modifying existing code.',
227
+ description: 'Get file-specific coding patterns and conventions for ANY file you work with. Call BEFORE modifying code AND when you encounter a new file during implementation. Returns contextual guidelines, performance considerations, and architectural decisions for specific files or directories. Each file/directory may have unique rules that override general patterns. Use whenever: editing existing files, creating files in a new directory, implementing features that touch multiple files, or debugging file-specific issues.',
228
228
  inputSchema: {
229
229
  type: 'object',
230
230
  properties: {
@@ -238,7 +238,7 @@ class DocsServer {
238
238
  },
239
239
  {
240
240
  name: 'read_specific_document',
241
- description: 'Read full documentation file content. Use after search_documentation to get complete implementation details, code examples, and architectural decisions. Only for project docs, not API docs.',
241
+ description: 'Read full documentation file content - dive deep WHENEVER search results point you here. Use after search_documentation identifies relevant docs, when you need complete context before implementing, or when revisiting a topic mid-work. Returns complete implementation details, code examples, and architectural decisions. Don\'t just skim search results - read the full docs to avoid missing critical details. Project docs contain battle-tested patterns; API docs show framework usage.',
242
242
  inputSchema: {
243
243
  type: 'object',
244
244
  properties: {
@@ -256,7 +256,7 @@ class DocsServer {
256
256
  },
257
257
  {
258
258
  name: 'explore_api',
259
- description: 'Deep dive into any API, framework, or class. Returns all methods, properties, protocols, and usage examples. Essential for understanding how to implement features correctly. Much faster than multiple searches.',
259
+ description: 'Deep dive into any API, framework, or class - check this EVERY time you use an unfamiliar API, not just once. Returns all methods, properties, protocols, and usage examples. Essential when: implementing features with new frameworks, encountering unknown classes mid-work, choosing between similar APIs, or verifying correct API usage. Much faster than multiple searches. If you\'re writing import statements or instantiating classes you haven\'t used before, explore them first to avoid misuse.',
260
260
  inputSchema: {
261
261
  type: 'object',
262
262
  properties: {
@@ -274,7 +274,7 @@ class DocsServer {
274
274
  },
275
275
  {
276
276
  name: 'create_or_update_rule',
277
- description: 'Document new coding patterns or architectural decisions. Captures lessons learned, design patterns, and team conventions as searchable knowledge. Great for preserving tribal knowledge.',
277
+ description: 'Document new coding patterns or architectural decisions AS YOU DISCOVER THEM during work. Call this when: you solve a tricky problem, establish a new pattern, learn a gotcha, make an architectural decision, or implement something that should be standardized. Captures lessons learned, design patterns, and team conventions as searchable knowledge for future work. Don\'t wait until the end - document insights immediately while context is fresh.',
278
278
  inputSchema: {
279
279
  type: 'object',
280
280
  properties: {
@@ -309,7 +309,7 @@ class DocsServer {
309
309
  },
310
310
  {
311
311
  name: 'refresh_documentation',
312
- description: 'Reload all project documentation from disk. Use when documentation files have been modified outside of this session. Re-indexes all documents and updates search index.',
312
+ description: 'Reload all project documentation from disk when docs are updated externally. Call when: documentation files are modified outside this session, after creating new docs manually, when search results seem stale, or if you suspect docs have changed. Re-indexes all documents and updates search index. If you created new documentation and it\'s not appearing in searches, refresh first.',
313
313
  inputSchema: {
314
314
  type: 'object',
315
315
  properties: {},
@@ -318,7 +318,7 @@ class DocsServer {
318
318
  },
319
319
  {
320
320
  name: 'get_document_index',
321
- description: 'List all available project documentation files. Returns index with titles, descriptions, and metadata. Use to see what documentation exists without searching.',
321
+ description: 'List all available project documentation files - check periodically to discover new docs added during your work. Returns index with titles, descriptions, and metadata. Use when: starting work (to see what\'s available), search fails to find what you need (browse instead), exploring unfamiliar codebases, or checking if docs exist for a topic. Helps you discover documentation you didn\'t know existed.',
322
322
  inputSchema: {
323
323
  type: 'object',
324
324
  properties: {},
@@ -364,13 +364,13 @@ class DocsServer {
364
364
  },
365
365
  {
366
366
  name: 'doc_bot',
367
- description: 'ALWAYS call this first for any task. Returns mandatory project standards (alwaysApply rules) that must be followed, plus a catalog of available documentation tools. Provides intelligent guidance while trusting your judgment on what additional context you need based on your familiarity with the codebase. Supports pagination for large rule sets.',
367
+ description: 'Your continuous project compass - call at EVERY major decision point, not just once. REQUIRED at: (1) Before starting any task, (2) Before each new component/file, (3) When uncertain about approach, (4) After errors/blockers, (5) When switching contexts, (6) Before architectural decisions. Returns mandatory standards PLUS checkpoint reminders for what you might be missing. This is NOT a one-time initialization - it\'s your continuous compliance guardian. Agents who skip regular check-ins often violate standards or miss critical patterns. Think "check in before committing" not "check in once at start". Each call validates you\'re still aligned with project requirements.',
368
368
  inputSchema: {
369
369
  type: 'object',
370
370
  properties: {
371
371
  task: {
372
372
  type: 'string',
373
- description: 'What do you need help with? Examples: "create REST API", "understand auth flow", "document this pattern", "find database models"'
373
+ description: 'What do you need help with? Examples: "create REST API", "modify auth.js", "debug auth error", "review completion", "understand auth flow"'
374
374
  },
375
375
  page: {
376
376
  type: 'number',
@@ -408,10 +408,7 @@ class DocsServer {
408
408
  }
409
409
  const searchPage = args?.page || 1;
410
410
  const searchLimit = args?.limit || 20;
411
-
412
- // Calculate offset for pagination
413
- const searchOffset = (searchPage - 1) * searchLimit;
414
-
411
+
415
412
  const unifiedOptions = {
416
413
  limit: searchLimit * 3, // Get more results for pagination
417
414
  docsetId: args?.docsetId,
@@ -957,9 +954,18 @@ Try:
957
954
  if (localResults.length > 0) {
958
955
  output += `- Read project docs with \`read_specific_document\`\n`;
959
956
  }
960
-
957
+
961
958
  output += `- Use \`explore_api\` to see all methods/properties for a class\n`;
962
-
959
+
960
+ // Add engagement hooks for continuous investigation
961
+ output += '\n## šŸ” Continue Your Investigation:\n';
962
+ output += 'This search gave you starting points, but consider:\n';
963
+ output += `- Did you check file-specific docs with \`get_file_docs\`? Files often have unique conventions\n`;
964
+ output += `- Have you explored the full API surface with \`explore_api\`? You might be missing key methods\n`;
965
+ output += `- Are there related patterns? Try searching for variations or related terms\n`;
966
+ output += `\nāš ļø **Working without complete context increases error risk**\n`;
967
+ output += `\nšŸ”„ **Checkpoint reminder**: Before writing code, return to \`doc_bot()\` to verify compliance with project standards\n`;
968
+
963
969
  return output;
964
970
  }
965
971
 
@@ -1088,7 +1094,19 @@ Try:
1088
1094
  output += `- Review the code samples for implementation examples\n`;
1089
1095
  }
1090
1096
  output += `- Import the framework and start using these APIs\n`;
1091
-
1097
+
1098
+ // Add "what you're missing" section
1099
+ output += `\n## āš ļø What This Response Doesn't Include:\n`;
1100
+ output += `- **Project-specific usage patterns**: Your codebase may use ${apiName} differently than shown here\n`;
1101
+ output += `- **Forbidden patterns**: Some methods might be banned by project rules\n`;
1102
+ output += `- **Performance gotchas**: File-specific docs might have critical performance notes\n`;
1103
+ output += `- **Team conventions**: How your team prefers to use this API\n`;
1104
+ output += `\nšŸ’” **Recommended next actions**:\n`;
1105
+ output += `1. Run \`search_documentation("${apiName}")\` to find how THIS project uses ${apiName}\n`;
1106
+ output += `2. Before implementing, call \`doc_bot(task="implement ${apiName}")\` to check project standards\n`;
1107
+ output += `3. Use \`get_file_docs(filePath)\` for the specific file you'll modify\n`;
1108
+ output += `\nšŸ”„ **Checkpoint reminder**: This is generic API documentation. Return to \`doc_bot()\` before writing code to ensure project compliance.\n`;
1109
+
1092
1110
  return output;
1093
1111
  }
1094
1112
 
@@ -1188,9 +1206,9 @@ Try:
1188
1206
  if (!fileDocs || fileDocs.length === 0) {
1189
1207
  return `No specific documentation found for file: ${filePath}`;
1190
1208
  }
1191
-
1209
+
1192
1210
  let output = `# Documentation for ${filePath}\n\n`;
1193
-
1211
+
1194
1212
  fileDocs.forEach(doc => {
1195
1213
  output += `## ${doc.metadata?.title || doc.fileName}\n`;
1196
1214
  if (doc.metadata?.description) {
@@ -1199,7 +1217,16 @@ Try:
1199
1217
  output += `${doc.content}\n\n`;
1200
1218
  output += '---\n\n';
1201
1219
  });
1202
-
1220
+
1221
+ // Add checkpoint reminder
1222
+ output += `## āš ļø Important Context:\n`;
1223
+ output += `This shows file/directory-specific rules for **${filePath}**.\n\n`;
1224
+ output += `**Remember**:\n`;
1225
+ output += `- These rules are IN ADDITION to global project rules\n`;
1226
+ output += `- If there's a conflict, ask via \`doc_bot()\` which takes precedence\n`;
1227
+ output += `- Other files in different directories may have different conventions\n`;
1228
+ output += `\nšŸ”„ **Next checkpoint**: Before modifying this file, return to \`doc_bot(task="modify ${filePath}")\` to get a complete compliance check.\n`;
1229
+
1203
1230
  return output;
1204
1231
  }
1205
1232
 
@@ -1207,25 +1234,37 @@ Try:
1207
1234
  if (!doc) {
1208
1235
  return 'Document not found';
1209
1236
  }
1210
-
1237
+
1211
1238
  let output = `# ${doc.metadata?.title || doc.fileName}\n\n`;
1212
-
1239
+
1213
1240
  if (doc.metadata?.description) {
1214
1241
  output += `**Description:** ${doc.metadata.description}\n\n`;
1215
1242
  }
1216
-
1243
+
1217
1244
  if (doc.metadata?.keywords) {
1218
1245
  output += `**Keywords:** ${Array.isArray(doc.metadata.keywords) ? doc.metadata.keywords.join(', ') : doc.metadata.keywords}\n\n`;
1219
1246
  }
1220
-
1247
+
1221
1248
  if (doc.metadata?.alwaysApply !== undefined) {
1222
1249
  output += `**Always Apply:** ${doc.metadata.alwaysApply ? 'Yes (Global Rule)' : 'No (Contextual Rule)'}\n\n`;
1223
1250
  }
1224
-
1251
+
1225
1252
  output += `**File:** ${doc.fileName}\n\n`;
1226
1253
  output += '---\n\n';
1227
1254
  output += doc.content;
1228
-
1255
+
1256
+ // Add cross-reference suggestions
1257
+ output += `\n\n---\n\n`;
1258
+ output += `## šŸ” Related Documentation:\n`;
1259
+ if (doc.metadata?.keywords && doc.metadata.keywords.length > 0) {
1260
+ output += `Consider searching for related topics:\n`;
1261
+ const keywords = Array.isArray(doc.metadata.keywords) ? doc.metadata.keywords : [doc.metadata.keywords];
1262
+ keywords.slice(0, 3).forEach(keyword => {
1263
+ output += `- \`search_documentation("${keyword}")\`\n`;
1264
+ });
1265
+ }
1266
+ output += `\nšŸ’” **Before implementing**: Return to \`doc_bot()\` to verify this guidance aligns with current project state and your specific task.\n`;
1267
+
1229
1268
  return output;
1230
1269
  }
1231
1270
 
@@ -1395,17 +1434,33 @@ Try:
1395
1434
  catalog += `- Get complete project philosophy and engineering principles\n`;
1396
1435
  catalog += `- Use when: Making architectural decisions or need comprehensive context\n\n`;
1397
1436
 
1437
+ catalog += `---\n\n`;
1438
+ catalog += `## šŸ”„ MANDATORY CHECKPOINTS - Return to doc_bot()\n\n`;
1439
+ catalog += `You MUST call doc_bot() again when you:\n\n`;
1440
+ catalog += `1. **Before file operations**: About to Write/Edit a new file? → \`doc_bot(task="modify [filepath]")\`\n`;
1441
+ catalog += `2. **Context switches**: Moving to a different component/feature? → \`doc_bot(task="[new context]")\`\n`;
1442
+ catalog += `3. **Errors encountered**: Hit an unexpected error? → \`doc_bot(task="debug [error]")\`\n`;
1443
+ catalog += `4. **Decision points**: Multiple valid approaches? → \`doc_bot(task="decide [decision]")\`\n`;
1444
+ catalog += `5. **Section completion**: Finished a major part? → \`doc_bot(task="review [what completed]")\`\n\n`;
1445
+ catalog += `āš ļø **Failure to checkpoint leads to**:\n`;
1446
+ catalog += `- Violating file-specific conventions you didn't know about\n`;
1447
+ catalog += `- Using patterns that were recently deprecated\n`;
1448
+ catalog += `- Missing performance/security requirements for that area\n\n`;
1449
+
1398
1450
  catalog += `---\n\n`;
1399
1451
  catalog += `## Your Task: "${task}"\n\n`;
1400
1452
  catalog += `**You now have:**\n`;
1401
1453
  catalog += `āœ… Mandatory project standards (above)\n`;
1402
- catalog += `āœ… Tools to explore codebase-specific patterns (listed above)\n\n`;
1454
+ catalog += `āœ… Tools to explore codebase-specific patterns (listed above)\n`;
1455
+ catalog += `āœ… Checkpoint requirements for continuous compliance\n\n`;
1403
1456
 
1404
- catalog += `**Your decision:**\n`;
1405
- catalog += `- If you understand how to implement this correctly with the standards above → proceed\n`;
1406
- catalog += `- If you need to understand existing patterns in this codebase → use the tools above\n\n`;
1457
+ catalog += `**Your immediate next steps:**\n`;
1458
+ catalog += `1. Review the mandatory standards above\n`;
1459
+ catalog += `2. Use additional tools if needed for this specific task\n`;
1460
+ catalog += `3. Begin implementation\n`;
1461
+ catalog += `4. **REMEMBER**: Return to doc_bot() at each checkpoint listed above\n\n`;
1407
1462
 
1408
- catalog += `Remember: You know the codebase context best. Use additional tools only if you need them.\n`;
1463
+ catalog += `Remember: Continuous check-ins = Continuous correctness.\n`;
1409
1464
 
1410
1465
  return catalog;
1411
1466
  }