@afterxleep/doc-bot 1.21.0 → 1.23.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 +1 -1
- package/src/index.js +102 -63
package/package.json
CHANGED
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.
|
|
169
|
+
description: 'Get mandatory coding standards for your task. Call BEFORE writing 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.',
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
|
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,17 @@ class DocsServer {
|
|
|
364
364
|
},
|
|
365
365
|
{
|
|
366
366
|
name: 'doc_bot',
|
|
367
|
-
description: 'ALWAYS call this
|
|
367
|
+
description: 'ALWAYS call this FIRST for ANY task, AND consult again when switching contexts or starting new features. Returns mandatory project standards (alwaysApply rules) that must be followed, plus a catalog of documentation tools. This is your entry point - it tells you what rules are non-negotiable AND which other tools to use for deeper dives. Call whenever: beginning any task, switching to a different feature/component, facing uncertainty, or needing to verify compliance. Think of this as your "project compass" - use it repeatedly to stay aligned.',
|
|
368
368
|
inputSchema: {
|
|
369
369
|
type: 'object',
|
|
370
370
|
properties: {
|
|
371
371
|
task: {
|
|
372
372
|
type: 'string',
|
|
373
373
|
description: 'What do you need help with? Examples: "create REST API", "understand auth flow", "document this pattern", "find database models"'
|
|
374
|
+
},
|
|
375
|
+
page: {
|
|
376
|
+
type: 'number',
|
|
377
|
+
description: 'Page number for paginated results (default: 1). Use this when the response indicates more pages are available.'
|
|
374
378
|
}
|
|
375
379
|
},
|
|
376
380
|
required: ['task']
|
|
@@ -404,10 +408,7 @@ class DocsServer {
|
|
|
404
408
|
}
|
|
405
409
|
const searchPage = args?.page || 1;
|
|
406
410
|
const searchLimit = args?.limit || 20;
|
|
407
|
-
|
|
408
|
-
// Calculate offset for pagination
|
|
409
|
-
const searchOffset = (searchPage - 1) * searchLimit;
|
|
410
|
-
|
|
411
|
+
|
|
411
412
|
const unifiedOptions = {
|
|
412
413
|
limit: searchLimit * 3, // Get more results for pagination
|
|
413
414
|
docsetId: args?.docsetId,
|
|
@@ -702,11 +703,12 @@ class DocsServer {
|
|
|
702
703
|
|
|
703
704
|
case 'doc_bot': {
|
|
704
705
|
const assistantTask = args?.task || '';
|
|
706
|
+
const docBotPage = args?.page || 1;
|
|
705
707
|
const docBotMandatoryRules = await this.docService.getGlobalRules();
|
|
706
708
|
return {
|
|
707
709
|
content: [{
|
|
708
710
|
type: 'text',
|
|
709
|
-
text: this.getIntelligentGatekeeperResponse(assistantTask, docBotMandatoryRules)
|
|
711
|
+
text: this.getIntelligentGatekeeperResponse(assistantTask, docBotMandatoryRules, docBotPage)
|
|
710
712
|
}]
|
|
711
713
|
};
|
|
712
714
|
}
|
|
@@ -1249,13 +1251,13 @@ Try:
|
|
|
1249
1251
|
return output;
|
|
1250
1252
|
}
|
|
1251
1253
|
|
|
1252
|
-
getIntelligentGatekeeperResponse(task, mandatoryRules) {
|
|
1254
|
+
getIntelligentGatekeeperResponse(task, mandatoryRules, page = 1) {
|
|
1253
1255
|
// Check for administrative/management tasks first
|
|
1254
1256
|
const isDocsetManagement = /add.*docset|remove.*docset|list.*docset|install.*docset/i.test(task);
|
|
1255
1257
|
const isRuleManagement = /add.*rule|create.*rule|update.*rule|document.*pattern|capture.*pattern/i.test(task);
|
|
1256
1258
|
const isDocumentManagement = /refresh.*doc|reload.*doc|index.*doc|get.*index/i.test(task);
|
|
1257
1259
|
|
|
1258
|
-
// Handle administrative tasks with direct action guidance
|
|
1260
|
+
// Handle administrative tasks with direct action guidance (no pagination needed)
|
|
1259
1261
|
if (isDocsetManagement) {
|
|
1260
1262
|
let guidance = `# 📦 Docset Management\n\n`;
|
|
1261
1263
|
|
|
@@ -1308,64 +1310,101 @@ Try:
|
|
|
1308
1310
|
return guidance;
|
|
1309
1311
|
}
|
|
1310
1312
|
|
|
1311
|
-
// For coding/general tasks:
|
|
1312
|
-
|
|
1313
|
+
// For coding/general tasks: Use smart pagination for mandatory rules
|
|
1314
|
+
const TOKEN_LIMIT = 24000; // Keep under 25K with buffer for tool catalog
|
|
1315
|
+
const toolCatalog = this.getToolCatalog(task);
|
|
1316
|
+
const toolCatalogTokens = TokenEstimator.estimateTokens(toolCatalog);
|
|
1313
1317
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1318
|
+
// Reserve tokens for tool catalog and headers
|
|
1319
|
+
const availableTokensForRules = TOKEN_LIMIT - toolCatalogTokens - 500;
|
|
1320
|
+
|
|
1321
|
+
// Format rules with pagination
|
|
1322
|
+
const formatRuleContent = (rules) => {
|
|
1323
|
+
let content = `# Mandatory Project Standards\n\n`;
|
|
1324
|
+
|
|
1325
|
+
if (!rules || rules.length === 0) {
|
|
1326
|
+
content += `*No mandatory rules defined for this project.*\n\n`;
|
|
1327
|
+
} else {
|
|
1328
|
+
content += `These rules apply to ALL code in this project:\n\n`;
|
|
1329
|
+
rules.forEach((rule, index) => {
|
|
1330
|
+
content += `## ${index + 1}. ${rule.metadata?.title || rule.fileName}\n\n`;
|
|
1331
|
+
content += `${rule.content}\n\n`;
|
|
1332
|
+
if (index < rules.length - 1) {
|
|
1333
|
+
content += `---\n\n`;
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
return content;
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
// Use smart pagination service
|
|
1342
|
+
const paginatedResult = this.paginationService.smartPaginate(
|
|
1343
|
+
mandatoryRules || [],
|
|
1344
|
+
formatRuleContent,
|
|
1345
|
+
page,
|
|
1346
|
+
availableTokensForRules
|
|
1347
|
+
);
|
|
1348
|
+
|
|
1349
|
+
let response = paginatedResult.content;
|
|
1350
|
+
|
|
1351
|
+
// Add pagination info if there are multiple pages
|
|
1352
|
+
if (paginatedResult.hasMore) {
|
|
1353
|
+
response += `\n---\n\n`;
|
|
1354
|
+
response += `📄 **Page ${paginatedResult.page} of ${paginatedResult.totalPages}**\n\n`;
|
|
1355
|
+
response += `⚠️ **More mandatory rules available**: Call \`doc_bot(task: "${task}", page: ${paginatedResult.page + 1})\` to see the next page.\n\n`;
|
|
1356
|
+
response += `💡 You must review ALL pages before proceeding to ensure compliance with all project standards.\n\n`;
|
|
1325
1357
|
}
|
|
1326
1358
|
|
|
1327
|
-
|
|
1328
|
-
response +=
|
|
1329
|
-
response += `You have access to these tools for finding contextual information:\n\n`;
|
|
1359
|
+
// Add tool catalog
|
|
1360
|
+
response += toolCatalog;
|
|
1330
1361
|
|
|
1331
|
-
response
|
|
1332
|
-
|
|
1333
|
-
response += `- Use when: You need to understand how something is implemented in this codebase\n`;
|
|
1334
|
-
response += `- Examples: \`search_documentation("authentication")\`, \`search_documentation("validation")\`\n`;
|
|
1335
|
-
response += `- Tip: Use technical terms (class names, API names), not descriptions\n\n`;
|
|
1362
|
+
return response;
|
|
1363
|
+
}
|
|
1336
1364
|
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1365
|
+
getToolCatalog(task) {
|
|
1366
|
+
let catalog = `---\n\n`;
|
|
1367
|
+
catalog += `## Additional Documentation Tools Available\n\n`;
|
|
1368
|
+
catalog += `You have access to these tools for finding contextual information:\n\n`;
|
|
1341
1369
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1370
|
+
catalog += `**\`search_documentation(query)\`**\n`;
|
|
1371
|
+
catalog += `- Search project docs for patterns, examples, conventions\n`;
|
|
1372
|
+
catalog += `- Use when: You need to understand how something is implemented in this codebase\n`;
|
|
1373
|
+
catalog += `- Examples: \`search_documentation("authentication")\`, \`search_documentation("validation")\`\n`;
|
|
1374
|
+
catalog += `- Tip: Use technical terms (class names, API names), not descriptions\n\n`;
|
|
1346
1375
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1376
|
+
catalog += `**\`get_file_docs(filePath)\`**\n`;
|
|
1377
|
+
catalog += `- Get file-specific or directory-specific documentation\n`;
|
|
1378
|
+
catalog += `- Use when: Working with specific files and need conventions for that area\n`;
|
|
1379
|
+
catalog += `- Examples: \`get_file_docs("src/components/Auth.tsx")\`, \`get_file_docs("services/**")\`\n\n`;
|
|
1351
1380
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1381
|
+
catalog += `**\`explore_api(apiName)\`**\n`;
|
|
1382
|
+
catalog += `- Deep-dive into framework/API documentation (all methods, properties, examples)\n`;
|
|
1383
|
+
catalog += `- Use when: Using frameworks or APIs you're unfamiliar with\n`;
|
|
1384
|
+
catalog += `- Examples: \`explore_api("URLSession")\`, \`explore_api("React.Component")\`\n\n`;
|
|
1355
1385
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
response += `✅ Tools to explore codebase-specific patterns (listed above)\n\n`;
|
|
1386
|
+
catalog += `**\`read_specific_document(fileName)\`**\n`;
|
|
1387
|
+
catalog += `- Read full content of a specific documentation file\n`;
|
|
1388
|
+
catalog += `- Use when: Search results show a relevant doc and you need complete details\n`;
|
|
1389
|
+
catalog += `- Examples: \`read_specific_document("api-patterns.md")\`\n\n`;
|
|
1361
1390
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1391
|
+
catalog += `**\`get_global_rules()\`**\n`;
|
|
1392
|
+
catalog += `- Get complete project philosophy and engineering principles\n`;
|
|
1393
|
+
catalog += `- Use when: Making architectural decisions or need comprehensive context\n\n`;
|
|
1365
1394
|
|
|
1366
|
-
|
|
1395
|
+
catalog += `---\n\n`;
|
|
1396
|
+
catalog += `## Your Task: "${task}"\n\n`;
|
|
1397
|
+
catalog += `**You now have:**\n`;
|
|
1398
|
+
catalog += `✅ Mandatory project standards (above)\n`;
|
|
1399
|
+
catalog += `✅ Tools to explore codebase-specific patterns (listed above)\n\n`;
|
|
1367
1400
|
|
|
1368
|
-
|
|
1401
|
+
catalog += `**Your decision:**\n`;
|
|
1402
|
+
catalog += `- If you understand how to implement this correctly with the standards above → proceed\n`;
|
|
1403
|
+
catalog += `- If you need to understand existing patterns in this codebase → use the tools above\n\n`;
|
|
1404
|
+
|
|
1405
|
+
catalog += `Remember: You know the codebase context best. Use additional tools only if you need them.\n`;
|
|
1406
|
+
|
|
1407
|
+
return catalog;
|
|
1369
1408
|
}
|
|
1370
1409
|
|
|
1371
1410
|
async createOrUpdateRule({ fileName, title, description, keywords, alwaysApply, content }) {
|