@afterxleep/doc-bot 1.20.0 → 1.21.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 +93 -140
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -364,7 +364,7 @@ class DocsServer {
|
|
|
364
364
|
},
|
|
365
365
|
{
|
|
366
366
|
name: 'doc_bot',
|
|
367
|
-
description: '
|
|
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.',
|
|
368
368
|
inputSchema: {
|
|
369
369
|
type: 'object',
|
|
370
370
|
properties: {
|
|
@@ -700,14 +700,16 @@ class DocsServer {
|
|
|
700
700
|
}]
|
|
701
701
|
};
|
|
702
702
|
|
|
703
|
-
case 'doc_bot':
|
|
703
|
+
case 'doc_bot': {
|
|
704
704
|
const assistantTask = args?.task || '';
|
|
705
|
+
const docBotMandatoryRules = await this.docService.getGlobalRules();
|
|
705
706
|
return {
|
|
706
707
|
content: [{
|
|
707
708
|
type: 'text',
|
|
708
|
-
text: this.
|
|
709
|
+
text: this.getIntelligentGatekeeperResponse(assistantTask, docBotMandatoryRules)
|
|
709
710
|
}]
|
|
710
711
|
};
|
|
712
|
+
}
|
|
711
713
|
|
|
712
714
|
default:
|
|
713
715
|
throw new Error(`Unknown tool: ${name}`);
|
|
@@ -1247,172 +1249,123 @@ Try:
|
|
|
1247
1249
|
return output;
|
|
1248
1250
|
}
|
|
1249
1251
|
|
|
1250
|
-
|
|
1251
|
-
// This is the intelligent guidance that replaces the complex AGENT_INTEGRATION_RULE
|
|
1252
|
-
const taskLower = task.toLowerCase();
|
|
1253
|
-
|
|
1254
|
-
let guidance = `# 🤖 DOC-BOT INTELLIGENT ASSISTANT\n\n`;
|
|
1255
|
-
guidance += `**Your Request**: ${task}\n\n`;
|
|
1256
|
-
|
|
1252
|
+
getIntelligentGatekeeperResponse(task, mandatoryRules) {
|
|
1257
1253
|
// Check for administrative/management tasks first
|
|
1258
1254
|
const isDocsetManagement = /add.*docset|remove.*docset|list.*docset|install.*docset/i.test(task);
|
|
1259
1255
|
const isRuleManagement = /add.*rule|create.*rule|update.*rule|document.*pattern|capture.*pattern/i.test(task);
|
|
1260
1256
|
const isDocumentManagement = /refresh.*doc|reload.*doc|index.*doc|get.*index/i.test(task);
|
|
1261
|
-
|
|
1262
|
-
// Handle administrative tasks
|
|
1257
|
+
|
|
1258
|
+
// Handle administrative tasks with direct action guidance
|
|
1263
1259
|
if (isDocsetManagement) {
|
|
1264
|
-
guidance
|
|
1265
|
-
|
|
1266
|
-
|
|
1260
|
+
let guidance = `# 📦 Docset Management\n\n`;
|
|
1261
|
+
|
|
1267
1262
|
if (/list/i.test(task)) {
|
|
1268
|
-
guidance +=
|
|
1263
|
+
guidance += `**Action**: \`list_docsets()\`\n\n`;
|
|
1264
|
+
guidance += `Shows all installed documentation sets with their IDs and metadata.\n`;
|
|
1269
1265
|
} else if (/add|install/i.test(task)) {
|
|
1270
|
-
guidance +=
|
|
1271
|
-
guidance +=
|
|
1266
|
+
guidance += `**Action**: \`add_docset(source: "path or URL")\`\n\n`;
|
|
1267
|
+
guidance += `**Examples**:\n`;
|
|
1272
1268
|
guidance += `- Local: \`add_docset(source: "/Downloads/Swift.docset")\`\n`;
|
|
1273
|
-
guidance += `- URL: \`add_docset(source: "https://example.com/React.docset.tgz")\`\n
|
|
1269
|
+
guidance += `- URL: \`add_docset(source: "https://example.com/React.docset.tgz")\`\n`;
|
|
1274
1270
|
} else if (/remove/i.test(task)) {
|
|
1275
|
-
guidance +=
|
|
1276
|
-
guidance += `
|
|
1271
|
+
guidance += `**Steps**:\n`;
|
|
1272
|
+
guidance += `1. \`list_docsets()\` - Get the docset ID\n`;
|
|
1273
|
+
guidance += `2. \`remove_docset(docsetId: "id-from-step-1")\`\n`;
|
|
1277
1274
|
}
|
|
1278
|
-
|
|
1279
|
-
guidance += `💡 **Note**: This is an administrative task - no documentation search needed.\n`;
|
|
1275
|
+
|
|
1280
1276
|
return guidance;
|
|
1281
1277
|
}
|
|
1282
|
-
|
|
1278
|
+
|
|
1283
1279
|
if (isRuleManagement) {
|
|
1284
|
-
guidance
|
|
1285
|
-
guidance += `**
|
|
1286
|
-
guidance +=
|
|
1280
|
+
let guidance = `# 📝 Rule/Pattern Management\n\n`;
|
|
1281
|
+
guidance += `**Action**: \`create_or_update_rule(...)\`\n\n`;
|
|
1282
|
+
guidance += `**Parameters**:\n`;
|
|
1287
1283
|
guidance += `\`\`\`javascript\n`;
|
|
1288
1284
|
guidance += `{\n`;
|
|
1289
1285
|
guidance += ` fileName: "descriptive-name.md",\n`;
|
|
1290
|
-
guidance += ` title: "Clear title for the rule
|
|
1286
|
+
guidance += ` title: "Clear title for the rule",\n`;
|
|
1291
1287
|
guidance += ` content: "Full markdown documentation",\n`;
|
|
1292
|
-
guidance += ` alwaysApply: true
|
|
1293
|
-
guidance += `
|
|
1288
|
+
guidance += ` alwaysApply: true, // true = mandatory (like CLAUDE.md)\n`;
|
|
1289
|
+
guidance += ` // false = contextual (found via search)\n`;
|
|
1290
|
+
guidance += ` keywords: ["search", "terms"],\n`;
|
|
1294
1291
|
guidance += ` description: "Brief summary" // optional\n`;
|
|
1295
1292
|
guidance += `}\n`;
|
|
1296
|
-
guidance += `\`\`\`\n
|
|
1297
|
-
guidance += `💡 **Note**: This captures project knowledge permanently - no search needed.\n`;
|
|
1293
|
+
guidance += `\`\`\`\n`;
|
|
1298
1294
|
return guidance;
|
|
1299
1295
|
}
|
|
1300
|
-
|
|
1296
|
+
|
|
1301
1297
|
if (isDocumentManagement) {
|
|
1302
|
-
guidance
|
|
1303
|
-
|
|
1304
|
-
|
|
1298
|
+
let guidance = `# 🔄 Documentation Management\n\n`;
|
|
1299
|
+
|
|
1305
1300
|
if (/refresh|reload/i.test(task)) {
|
|
1306
|
-
guidance +=
|
|
1301
|
+
guidance += `**Action**: \`refresh_documentation()\`\n\n`;
|
|
1302
|
+
guidance += `Reloads all documentation from disk and rebuilds search indexes.\n`;
|
|
1307
1303
|
} else {
|
|
1308
|
-
guidance +=
|
|
1304
|
+
guidance += `**Action**: \`get_document_index()\`\n\n`;
|
|
1305
|
+
guidance += `Lists all available documentation files with metadata.\n`;
|
|
1309
1306
|
}
|
|
1310
|
-
|
|
1311
|
-
guidance += `💡 **Note**: This is an administrative task - direct execution only.\n`;
|
|
1307
|
+
|
|
1312
1308
|
return guidance;
|
|
1313
1309
|
}
|
|
1314
|
-
|
|
1315
|
-
//
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
guidance += `**MANDATORY Steps (in order)**:\n`;
|
|
1321
|
-
guidance += `1. ⚡ FIRST: \`check_project_rules("${task}")\` - Get critical coding standards\n`;
|
|
1322
|
-
guidance += `2. 🔍 SEARCH for existing patterns:\n`;
|
|
1323
|
-
|
|
1324
|
-
// Extract likely search terms
|
|
1325
|
-
const searchTerms = this.extractSearchTerms(task);
|
|
1326
|
-
searchTerms.forEach(term => {
|
|
1327
|
-
guidance += ` - \`search_documentation("${term}")\`\n`;
|
|
1328
|
-
});
|
|
1329
|
-
|
|
1330
|
-
guidance += `3. 📚 EXPLORE: If APIs found, use \`explore_api()\` for complete details\n`;
|
|
1331
|
-
guidance += `4. ✅ IMPLEMENT: Generate code following ALL discovered patterns\n\n`;
|
|
1332
|
-
guidance += `⚠️ **CRITICAL**: Never skip step 1 - project rules are mandatory!\n\n`;
|
|
1333
|
-
} else if (taskLower.includes('how') || taskLower.includes('what') || taskLower.includes('why') ||
|
|
1334
|
-
taskLower.includes('understand') || taskLower.includes('explain') || taskLower.includes('architecture')) {
|
|
1335
|
-
guidance += `## 🔍 KNOWLEDGE/UNDERSTANDING TASK DETECTED\n\n`;
|
|
1336
|
-
guidance += `**Recommended Flow**:\n`;
|
|
1337
|
-
guidance += `1. 📖 START with searches for technical terms:\n`;
|
|
1338
|
-
|
|
1339
|
-
const searchTerms = this.extractSearchTerms(task);
|
|
1340
|
-
searchTerms.forEach(term => {
|
|
1341
|
-
guidance += ` - \`search_documentation("${term}")\`\n`;
|
|
1342
|
-
});
|
|
1343
|
-
|
|
1344
|
-
guidance += `2. 📋 CONTEXT: \`get_global_rules()\` for project philosophy\n`;
|
|
1345
|
-
guidance += `3. 📄 DETAILS: Use \`read_specific_document()\` on relevant results\n`;
|
|
1346
|
-
guidance += `4. 🔬 DEEP DIVE: \`explore_api()\` for framework/class details\n\n`;
|
|
1347
|
-
} else if (taskLower.includes('document') || taskLower.includes('capture') || taskLower.includes('learned') ||
|
|
1348
|
-
taskLower.includes('pattern') || taskLower.includes('convention')) {
|
|
1349
|
-
guidance += `## 📝 DOCUMENTATION TASK DETECTED\n\n`;
|
|
1350
|
-
guidance += `**To capture new knowledge**:\n`;
|
|
1351
|
-
guidance += `Use \`create_or_update_rule()\` with:\n`;
|
|
1352
|
-
guidance += `- fileName: descriptive-name.md\n`;
|
|
1353
|
-
guidance += `- title: Clear, searchable title\n`;
|
|
1354
|
-
guidance += `- content: Full markdown documentation\n`;
|
|
1355
|
-
guidance += `- alwaysApply: true/false (is this a global rule?)\n\n`;
|
|
1356
|
-
} else if (taskLower.includes('file') || taskLower.includes('working on') || taskLower.includes('modify')) {
|
|
1357
|
-
guidance += `## 📁 FILE-SPECIFIC TASK DETECTED\n\n`;
|
|
1358
|
-
guidance += `**File Context Flow**:\n`;
|
|
1359
|
-
guidance += `1. 📂 GET CONTEXT: \`get_file_docs("${task}")\` for file-specific patterns\n`;
|
|
1360
|
-
guidance += `2. 🔍 SEARCH: Look for related components/patterns\n`;
|
|
1361
|
-
guidance += `3. ✅ CHECK: \`check_project_rules()\` before modifications\n\n`;
|
|
1310
|
+
|
|
1311
|
+
// For coding/general tasks: Return mandatory rules + tool catalog
|
|
1312
|
+
let response = `# Mandatory Project Standards\n\n`;
|
|
1313
|
+
|
|
1314
|
+
if (!mandatoryRules || mandatoryRules.length === 0) {
|
|
1315
|
+
response += `*No mandatory rules defined for this project.*\n\n`;
|
|
1362
1316
|
} else {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1317
|
+
response += `These rules apply to ALL code in this project:\n\n`;
|
|
1318
|
+
mandatoryRules.forEach((rule, index) => {
|
|
1319
|
+
response += `## ${index + 1}. ${rule.metadata?.title || rule.fileName}\n\n`;
|
|
1320
|
+
response += `${rule.content}\n\n`;
|
|
1321
|
+
if (index < mandatoryRules.length - 1) {
|
|
1322
|
+
response += `---\n\n`;
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1369
1325
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
// Remove duplicates and limit to 3-4 terms
|
|
1415
|
-
return [...new Set(terms)].slice(0, 4);
|
|
1326
|
+
|
|
1327
|
+
response += `---\n\n`;
|
|
1328
|
+
response += `## Additional Documentation Tools Available\n\n`;
|
|
1329
|
+
response += `You have access to these tools for finding contextual information:\n\n`;
|
|
1330
|
+
|
|
1331
|
+
response += `**\`search_documentation(query)\`**\n`;
|
|
1332
|
+
response += `- Search project docs for patterns, examples, conventions\n`;
|
|
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`;
|
|
1336
|
+
|
|
1337
|
+
response += `**\`get_file_docs(filePath)\`**\n`;
|
|
1338
|
+
response += `- Get file-specific or directory-specific documentation\n`;
|
|
1339
|
+
response += `- Use when: Working with specific files and need conventions for that area\n`;
|
|
1340
|
+
response += `- Examples: \`get_file_docs("src/components/Auth.tsx")\`, \`get_file_docs("services/**")\`\n\n`;
|
|
1341
|
+
|
|
1342
|
+
response += `**\`explore_api(apiName)\`**\n`;
|
|
1343
|
+
response += `- Deep-dive into framework/API documentation (all methods, properties, examples)\n`;
|
|
1344
|
+
response += `- Use when: Using frameworks or APIs you're unfamiliar with\n`;
|
|
1345
|
+
response += `- Examples: \`explore_api("URLSession")\`, \`explore_api("React.Component")\`\n\n`;
|
|
1346
|
+
|
|
1347
|
+
response += `**\`read_specific_document(fileName)\`**\n`;
|
|
1348
|
+
response += `- Read full content of a specific documentation file\n`;
|
|
1349
|
+
response += `- Use when: Search results show a relevant doc and you need complete details\n`;
|
|
1350
|
+
response += `- Examples: \`read_specific_document("api-patterns.md")\`\n\n`;
|
|
1351
|
+
|
|
1352
|
+
response += `**\`get_global_rules()\`**\n`;
|
|
1353
|
+
response += `- Get complete project philosophy and engineering principles\n`;
|
|
1354
|
+
response += `- Use when: Making architectural decisions or need comprehensive context\n\n`;
|
|
1355
|
+
|
|
1356
|
+
response += `---\n\n`;
|
|
1357
|
+
response += `## Your Task: "${task}"\n\n`;
|
|
1358
|
+
response += `**You now have:**\n`;
|
|
1359
|
+
response += `✅ Mandatory project standards (above)\n`;
|
|
1360
|
+
response += `✅ Tools to explore codebase-specific patterns (listed above)\n\n`;
|
|
1361
|
+
|
|
1362
|
+
response += `**Your decision:**\n`;
|
|
1363
|
+
response += `- If you understand how to implement this correctly with the standards above → proceed\n`;
|
|
1364
|
+
response += `- If you need to understand existing patterns in this codebase → use the tools above\n\n`;
|
|
1365
|
+
|
|
1366
|
+
response += `Remember: You know the codebase context best. Use additional tools only if you need them.\n`;
|
|
1367
|
+
|
|
1368
|
+
return response;
|
|
1416
1369
|
}
|
|
1417
1370
|
|
|
1418
1371
|
async createOrUpdateRule({ fileName, title, description, keywords, alwaysApply, content }) {
|