@hailer/mcp 0.0.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.
- package/.claude/commands/tool-builder.md +37 -0
- package/.claude/commands/ws-pull.md +44 -0
- package/.claude/settings.json +8 -0
- package/.claude/settings.local.json +49 -0
- package/.claude/skills/activity-api/SKILL.md +96 -0
- package/.claude/skills/activity-api/references/activity-endpoints.md +845 -0
- package/.claude/skills/add-app-member-skill/SKILL.md +977 -0
- package/.claude/skills/agent-building/SKILL.md +243 -0
- package/.claude/skills/agent-building/references/architecture-patterns.md +446 -0
- package/.claude/skills/agent-building/references/code-examples.md +587 -0
- package/.claude/skills/agent-building/references/implementation-guide.md +619 -0
- package/.claude/skills/app-api/SKILL.md +219 -0
- package/.claude/skills/app-api/references/app-endpoints.md +759 -0
- package/.claude/skills/building-hailer-apps-skill/SKILL.md +548 -0
- package/.claude/skills/create-app-skill/SKILL.md +1101 -0
- package/.claude/skills/create-insight-skill/SKILL.md +1317 -0
- package/.claude/skills/get-insight-data-skill/SKILL.md +1053 -0
- package/.claude/skills/hailer-api/SKILL.md +283 -0
- package/.claude/skills/hailer-api/references/activities.md +620 -0
- package/.claude/skills/hailer-api/references/authentication.md +216 -0
- package/.claude/skills/hailer-api/references/datasets.md +437 -0
- package/.claude/skills/hailer-api/references/files.md +301 -0
- package/.claude/skills/hailer-api/references/insights.md +469 -0
- package/.claude/skills/hailer-api/references/workflows.md +720 -0
- package/.claude/skills/hailer-api/references/workspaces-users.md +445 -0
- package/.claude/skills/insight-api/SKILL.md +185 -0
- package/.claude/skills/insight-api/references/insight-endpoints.md +514 -0
- package/.claude/skills/install-workflow-skill/SKILL.md +1056 -0
- package/.claude/skills/list-apps-skill/SKILL.md +1010 -0
- package/.claude/skills/list-workflows-minimal-skill/SKILL.md +992 -0
- package/.claude/skills/local-first-skill/SKILL.md +570 -0
- package/.claude/skills/mcp-tools/SKILL.md +419 -0
- package/.claude/skills/mcp-tools/references/api-endpoints.md +499 -0
- package/.claude/skills/mcp-tools/references/data-structures.md +554 -0
- package/.claude/skills/mcp-tools/references/implementation-patterns.md +717 -0
- package/.claude/skills/preview-insight-skill/SKILL.md +1290 -0
- package/.claude/skills/publish-hailer-app-skill/SKILL.md +453 -0
- package/.claude/skills/remove-app-member-skill/SKILL.md +671 -0
- package/.claude/skills/remove-app-skill/SKILL.md +985 -0
- package/.claude/skills/remove-insight-skill/SKILL.md +1011 -0
- package/.claude/skills/remove-workflow-skill/SKILL.md +920 -0
- package/.claude/skills/scaffold-hailer-app-skill/SKILL.md +1034 -0
- package/.claude/skills/skill-testing/README.md +137 -0
- package/.claude/skills/skill-testing/SKILL.md +348 -0
- package/.claude/skills/skill-testing/references/test-patterns.md +705 -0
- package/.claude/skills/skill-testing/references/testing-guide.md +603 -0
- package/.claude/skills/skill-testing/references/validation-checklist.md +537 -0
- package/.claude/skills/tool-builder/SKILL.md +328 -0
- package/.claude/skills/update-app-skill/SKILL.md +970 -0
- package/.claude/skills/update-workflow-field-skill/SKILL.md +1098 -0
- package/.env.example +81 -0
- package/.mcp.json +13 -0
- package/README.md +297 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +74 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +5 -0
- package/dist/client/adaptive-documentation-bot.d.ts +108 -0
- package/dist/client/adaptive-documentation-bot.js +475 -0
- package/dist/client/adaptive-documentation-types.d.ts +66 -0
- package/dist/client/adaptive-documentation-types.js +9 -0
- package/dist/client/agent-activity-bot.d.ts +51 -0
- package/dist/client/agent-activity-bot.js +166 -0
- package/dist/client/agent-tracker.d.ts +499 -0
- package/dist/client/agent-tracker.js +659 -0
- package/dist/client/description-updater.d.ts +56 -0
- package/dist/client/description-updater.js +259 -0
- package/dist/client/log-parser.d.ts +72 -0
- package/dist/client/log-parser.js +387 -0
- package/dist/client/mcp-client.d.ts +50 -0
- package/dist/client/mcp-client.js +532 -0
- package/dist/client/message-processor.d.ts +35 -0
- package/dist/client/message-processor.js +352 -0
- package/dist/client/multi-bot-manager.d.ts +24 -0
- package/dist/client/multi-bot-manager.js +74 -0
- package/dist/client/providers/anthropic-provider.d.ts +19 -0
- package/dist/client/providers/anthropic-provider.js +631 -0
- package/dist/client/providers/llm-provider.d.ts +47 -0
- package/dist/client/providers/llm-provider.js +367 -0
- package/dist/client/providers/openai-provider.d.ts +23 -0
- package/dist/client/providers/openai-provider.js +621 -0
- package/dist/client/simple-llm-caller.d.ts +19 -0
- package/dist/client/simple-llm-caller.js +100 -0
- package/dist/client/skill-generator.d.ts +81 -0
- package/dist/client/skill-generator.js +386 -0
- package/dist/client/test-adaptive-bot.d.ts +9 -0
- package/dist/client/test-adaptive-bot.js +82 -0
- package/dist/client/token-pricing.d.ts +38 -0
- package/dist/client/token-pricing.js +127 -0
- package/dist/client/token-tracker.d.ts +232 -0
- package/dist/client/token-tracker.js +457 -0
- package/dist/client/token-usage-bot.d.ts +53 -0
- package/dist/client/token-usage-bot.js +153 -0
- package/dist/client/tool-executor.d.ts +69 -0
- package/dist/client/tool-executor.js +159 -0
- package/dist/client/tool-schema-loader.d.ts +60 -0
- package/dist/client/tool-schema-loader.js +178 -0
- package/dist/client/types.d.ts +69 -0
- package/dist/client/types.js +7 -0
- package/dist/config.d.ts +162 -0
- package/dist/config.js +296 -0
- package/dist/core.d.ts +26 -0
- package/dist/core.js +147 -0
- package/dist/lib/context-manager.d.ts +111 -0
- package/dist/lib/context-manager.js +431 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +277 -0
- package/dist/lib/materialize.d.ts +3 -0
- package/dist/lib/materialize.js +101 -0
- package/dist/lib/normalizedName.d.ts +7 -0
- package/dist/lib/normalizedName.js +48 -0
- package/dist/lib/prompt-length-manager.d.ts +81 -0
- package/dist/lib/prompt-length-manager.js +457 -0
- package/dist/lib/terminal-prompt.d.ts +9 -0
- package/dist/lib/terminal-prompt.js +108 -0
- package/dist/mcp/UserContextCache.d.ts +56 -0
- package/dist/mcp/UserContextCache.js +163 -0
- package/dist/mcp/auth.d.ts +2 -0
- package/dist/mcp/auth.js +29 -0
- package/dist/mcp/hailer-clients.d.ts +42 -0
- package/dist/mcp/hailer-clients.js +246 -0
- package/dist/mcp/signal-handler.d.ts +45 -0
- package/dist/mcp/signal-handler.js +317 -0
- package/dist/mcp/tool-registry.d.ts +100 -0
- package/dist/mcp/tool-registry.js +306 -0
- package/dist/mcp/tools/activity.d.ts +15 -0
- package/dist/mcp/tools/activity.js +955 -0
- package/dist/mcp/tools/app.d.ts +20 -0
- package/dist/mcp/tools/app.js +1488 -0
- package/dist/mcp/tools/discussion.d.ts +19 -0
- package/dist/mcp/tools/discussion.js +950 -0
- package/dist/mcp/tools/file.d.ts +15 -0
- package/dist/mcp/tools/file.js +119 -0
- package/dist/mcp/tools/insight.d.ts +17 -0
- package/dist/mcp/tools/insight.js +806 -0
- package/dist/mcp/tools/skill.d.ts +10 -0
- package/dist/mcp/tools/skill.js +279 -0
- package/dist/mcp/tools/user.d.ts +10 -0
- package/dist/mcp/tools/user.js +108 -0
- package/dist/mcp/tools/workflow-template.d.ts +19 -0
- package/dist/mcp/tools/workflow-template.js +822 -0
- package/dist/mcp/tools/workflow.d.ts +18 -0
- package/dist/mcp/tools/workflow.js +1362 -0
- package/dist/mcp/utils/api-errors.d.ts +45 -0
- package/dist/mcp/utils/api-errors.js +160 -0
- package/dist/mcp/utils/data-transformers.d.ts +102 -0
- package/dist/mcp/utils/data-transformers.js +194 -0
- package/dist/mcp/utils/file-upload.d.ts +33 -0
- package/dist/mcp/utils/file-upload.js +148 -0
- package/dist/mcp/utils/hailer-api-client.d.ts +120 -0
- package/dist/mcp/utils/hailer-api-client.js +323 -0
- package/dist/mcp/utils/index.d.ts +13 -0
- package/dist/mcp/utils/index.js +39 -0
- package/dist/mcp/utils/logger.d.ts +42 -0
- package/dist/mcp/utils/logger.js +103 -0
- package/dist/mcp/utils/types.d.ts +286 -0
- package/dist/mcp/utils/types.js +7 -0
- package/dist/mcp/workspace-cache.d.ts +42 -0
- package/dist/mcp/workspace-cache.js +97 -0
- package/dist/mcp-server.d.ts +42 -0
- package/dist/mcp-server.js +280 -0
- package/package.json +56 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Description Updater for Adaptive Documentation Bot
|
|
3
|
+
*
|
|
4
|
+
* Updates tool descriptions in source files based on error analysis.
|
|
5
|
+
* Modifies ReadTools.ts, WriteTools.ts, and PlaygroundTools.ts.
|
|
6
|
+
*/
|
|
7
|
+
import { Improvement } from './adaptive-documentation-types';
|
|
8
|
+
export declare class DescriptionUpdater {
|
|
9
|
+
private toolFiles;
|
|
10
|
+
private improvementHistory;
|
|
11
|
+
/**
|
|
12
|
+
* Update tool description in source file
|
|
13
|
+
*/
|
|
14
|
+
updateToolDescription(toolName: string, newDescription: string, reason: string, triggeredBy?: any): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Update parameter description in Zod schema
|
|
17
|
+
*/
|
|
18
|
+
updateParameterDescription(toolName: string, parameterName: string, newDescription: string, reason: string): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Find which file contains the given tool
|
|
21
|
+
*/
|
|
22
|
+
private findToolFile;
|
|
23
|
+
/**
|
|
24
|
+
* Extract current description for a tool
|
|
25
|
+
*/
|
|
26
|
+
private extractCurrentDescription;
|
|
27
|
+
/**
|
|
28
|
+
* Replace description in file content
|
|
29
|
+
*/
|
|
30
|
+
private replaceDescription;
|
|
31
|
+
/**
|
|
32
|
+
* Escape string for insertion into source code
|
|
33
|
+
*/
|
|
34
|
+
private escapeString;
|
|
35
|
+
/**
|
|
36
|
+
* Convert tool name to PascalCase for schema method name
|
|
37
|
+
*/
|
|
38
|
+
private toPascalCase;
|
|
39
|
+
/**
|
|
40
|
+
* Record improvement in history
|
|
41
|
+
*/
|
|
42
|
+
private recordImprovement;
|
|
43
|
+
/**
|
|
44
|
+
* Get improvement history for a specific tool
|
|
45
|
+
*/
|
|
46
|
+
getImprovementHistory(toolName?: string): Improvement[];
|
|
47
|
+
/**
|
|
48
|
+
* Get improvement statistics
|
|
49
|
+
*/
|
|
50
|
+
getStats(): {
|
|
51
|
+
totalImprovements: number;
|
|
52
|
+
byType: Record<string, number>;
|
|
53
|
+
byTool: Record<string, number>;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=description-updater.d.ts.map
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Description Updater for Adaptive Documentation Bot
|
|
4
|
+
*
|
|
5
|
+
* Updates tool descriptions in source files based on error analysis.
|
|
6
|
+
* Modifies ReadTools.ts, WriteTools.ts, and PlaygroundTools.ts.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.DescriptionUpdater = void 0;
|
|
43
|
+
const logger_1 = require("../lib/logger");
|
|
44
|
+
const fs = __importStar(require("fs/promises"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const logger = (0, logger_1.createLogger)({ component: 'DescriptionUpdater' });
|
|
47
|
+
class DescriptionUpdater {
|
|
48
|
+
toolFiles = [
|
|
49
|
+
path.join(process.cwd(), 'src/mcp/tools/ReadTools.ts'),
|
|
50
|
+
path.join(process.cwd(), 'src/mcp/tools/WriteTools.ts'),
|
|
51
|
+
path.join(process.cwd(), 'src/mcp/tools/PlaygroundTools.ts')
|
|
52
|
+
];
|
|
53
|
+
improvementHistory = [];
|
|
54
|
+
/**
|
|
55
|
+
* Update tool description in source file
|
|
56
|
+
*/
|
|
57
|
+
async updateToolDescription(toolName, newDescription, reason, triggeredBy) {
|
|
58
|
+
try {
|
|
59
|
+
// Find which file contains this tool
|
|
60
|
+
const toolFile = await this.findToolFile(toolName);
|
|
61
|
+
if (!toolFile) {
|
|
62
|
+
logger.warn('Tool file not found', { toolName });
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Read current file content
|
|
66
|
+
const oldContent = await fs.readFile(toolFile, 'utf-8');
|
|
67
|
+
const oldDescription = this.extractCurrentDescription(oldContent, toolName);
|
|
68
|
+
if (!oldDescription) {
|
|
69
|
+
logger.warn('Could not extract current description', { toolName, toolFile });
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
// Check if description actually changed
|
|
73
|
+
if (oldDescription === newDescription) {
|
|
74
|
+
logger.debug('Description unchanged, skipping update', { toolName });
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
// Update the description
|
|
78
|
+
const newContent = this.replaceDescription(oldContent, toolName, newDescription);
|
|
79
|
+
// Write back to file
|
|
80
|
+
await fs.writeFile(toolFile, newContent, 'utf-8');
|
|
81
|
+
logger.info('✅ Tool description updated', {
|
|
82
|
+
toolName,
|
|
83
|
+
file: path.basename(toolFile),
|
|
84
|
+
reason,
|
|
85
|
+
oldLength: oldDescription.length,
|
|
86
|
+
newLength: newDescription.length
|
|
87
|
+
});
|
|
88
|
+
// Record improvement
|
|
89
|
+
this.recordImprovement({
|
|
90
|
+
timestamp: Date.now(),
|
|
91
|
+
toolName,
|
|
92
|
+
type: 'description',
|
|
93
|
+
oldValue: oldDescription,
|
|
94
|
+
newValue: newDescription,
|
|
95
|
+
triggeredBy,
|
|
96
|
+
reason,
|
|
97
|
+
applied: true
|
|
98
|
+
});
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
logger.error('Failed to update tool description', error, { toolName });
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Update parameter description in Zod schema
|
|
108
|
+
*/
|
|
109
|
+
async updateParameterDescription(toolName, parameterName, newDescription, reason) {
|
|
110
|
+
try {
|
|
111
|
+
const toolFile = await this.findToolFile(toolName);
|
|
112
|
+
if (!toolFile) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const oldContent = await fs.readFile(toolFile, 'utf-8');
|
|
116
|
+
// Find the schema method for this tool
|
|
117
|
+
const schemaMethodMatch = oldContent.match(new RegExp(`private static get.*${this.toPascalCase(toolName)}Schema\\(\\)[\\s\\S]*?{([\\s\\S]*?)}\\s*\\}`, 'm'));
|
|
118
|
+
if (!schemaMethodMatch) {
|
|
119
|
+
logger.warn('Could not find schema method', { toolName });
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
// Replace parameter description
|
|
123
|
+
const paramPattern = new RegExp(`${parameterName}:\\s*z\\.[^.]+\\.describe\\(['"]([^'"]+)['"]\\)`, 'g');
|
|
124
|
+
const newContent = oldContent.replace(paramPattern, (match) => {
|
|
125
|
+
return match.replace(/\.describe\(['"]([^'"]+)['"]\)/, `.describe("${newDescription}")`);
|
|
126
|
+
});
|
|
127
|
+
if (newContent === oldContent) {
|
|
128
|
+
logger.debug('Parameter description unchanged', { toolName, parameterName });
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
await fs.writeFile(toolFile, newContent, 'utf-8');
|
|
132
|
+
logger.info('✅ Parameter description updated', {
|
|
133
|
+
toolName,
|
|
134
|
+
parameterName,
|
|
135
|
+
file: path.basename(toolFile),
|
|
136
|
+
reason
|
|
137
|
+
});
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
logger.error('Failed to update parameter description', error, { toolName, parameterName });
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Find which file contains the given tool
|
|
147
|
+
*/
|
|
148
|
+
async findToolFile(toolName) {
|
|
149
|
+
for (const file of this.toolFiles) {
|
|
150
|
+
try {
|
|
151
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
152
|
+
// Check if this file contains the tool definition
|
|
153
|
+
if (content.includes(`name: '${toolName}'`) ||
|
|
154
|
+
content.includes(`name: "${toolName}"`)) {
|
|
155
|
+
return file;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
// File doesn't exist or can't be read, continue
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Extract current description for a tool
|
|
167
|
+
*/
|
|
168
|
+
extractCurrentDescription(content, toolName) {
|
|
169
|
+
// Pattern 1: name: 'tool_name', description: 'description text'
|
|
170
|
+
const pattern1 = new RegExp(`name:\\s*['"]${toolName}['"],\\s*description:\\s*['"]([^'"]+)['"]`, 'm');
|
|
171
|
+
const match1 = content.match(pattern1);
|
|
172
|
+
if (match1) {
|
|
173
|
+
return match1[1];
|
|
174
|
+
}
|
|
175
|
+
// Pattern 2: Multi-line description with template literals
|
|
176
|
+
const pattern2 = new RegExp(`name:\\s*['"]${toolName}['"],\\s*description:\\s*\`([^\`]+)\``, 'm');
|
|
177
|
+
const match2 = content.match(pattern2);
|
|
178
|
+
if (match2) {
|
|
179
|
+
return match2[1];
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Replace description in file content
|
|
185
|
+
*/
|
|
186
|
+
replaceDescription(content, toolName, newDescription) {
|
|
187
|
+
// Escape special regex characters in tool name
|
|
188
|
+
const escapedToolName = toolName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
189
|
+
// Pattern 1: Single-quote strings (handles escaped quotes and nested double quotes)
|
|
190
|
+
// Matches: description: 'text with "nested" quotes and \'escaped\' quotes',
|
|
191
|
+
const pattern1 = new RegExp(`(name:\\s*['"]${escapedToolName}['"],\\s*description:\\s*)'((?:[^'\\\\]|\\\\.)*)'`, 'gm');
|
|
192
|
+
let newContent = content.replace(pattern1, `$1'${this.escapeString(newDescription)}'`);
|
|
193
|
+
// Pattern 2: Double-quote strings (handles escaped quotes and nested single quotes)
|
|
194
|
+
// Matches: description: "text with 'nested' quotes and \"escaped\" quotes"
|
|
195
|
+
const pattern2 = new RegExp(`(name:\\s*['"]${escapedToolName}['"],\\s*description:\\s*)"((?:[^"\\\\]|\\\\.)*)"`, 'gm');
|
|
196
|
+
newContent = newContent.replace(pattern2, `$1'${this.escapeString(newDescription)}'`);
|
|
197
|
+
// Pattern 3: Multi-line description with template literals
|
|
198
|
+
const pattern3 = new RegExp(`(name:\\s*['"]${escapedToolName}['"],\\s*description:\\s*)\`([^\`]+)\``, 'gm');
|
|
199
|
+
newContent = newContent.replace(pattern3, `$1'${this.escapeString(newDescription)}'`);
|
|
200
|
+
return newContent;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Escape string for insertion into source code
|
|
204
|
+
*/
|
|
205
|
+
escapeString(str) {
|
|
206
|
+
return str
|
|
207
|
+
.replace(/\\/g, '\\\\')
|
|
208
|
+
.replace(/'/g, "\\'")
|
|
209
|
+
.replace(/\n/g, '\\n')
|
|
210
|
+
.replace(/\r/g, '\\r')
|
|
211
|
+
.replace(/\t/g, '\\t');
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Convert tool name to PascalCase for schema method name
|
|
215
|
+
*/
|
|
216
|
+
toPascalCase(str) {
|
|
217
|
+
return str
|
|
218
|
+
.split('_')
|
|
219
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
220
|
+
.join('');
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Record improvement in history
|
|
224
|
+
*/
|
|
225
|
+
recordImprovement(improvement) {
|
|
226
|
+
this.improvementHistory.push(improvement);
|
|
227
|
+
// Keep only last 100 improvements
|
|
228
|
+
if (this.improvementHistory.length > 100) {
|
|
229
|
+
this.improvementHistory = this.improvementHistory.slice(-100);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get improvement history for a specific tool
|
|
234
|
+
*/
|
|
235
|
+
getImprovementHistory(toolName) {
|
|
236
|
+
if (toolName) {
|
|
237
|
+
return this.improvementHistory.filter(imp => imp.toolName === toolName);
|
|
238
|
+
}
|
|
239
|
+
return this.improvementHistory;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get improvement statistics
|
|
243
|
+
*/
|
|
244
|
+
getStats() {
|
|
245
|
+
const byType = {};
|
|
246
|
+
const byTool = {};
|
|
247
|
+
for (const improvement of this.improvementHistory) {
|
|
248
|
+
byType[improvement.type] = (byType[improvement.type] || 0) + 1;
|
|
249
|
+
byTool[improvement.toolName] = (byTool[improvement.toolName] || 0) + 1;
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
totalImprovements: this.improvementHistory.length,
|
|
253
|
+
byType,
|
|
254
|
+
byTool
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.DescriptionUpdater = DescriptionUpdater;
|
|
259
|
+
//# sourceMappingURL=description-updater.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Parser for Adaptive Documentation Bot
|
|
3
|
+
*
|
|
4
|
+
* Parses MCP server logs to extract tool call errors and LLM mistakes.
|
|
5
|
+
* Monitors both file-based logs and live log streams.
|
|
6
|
+
*/
|
|
7
|
+
import { ToolCallError } from './adaptive-documentation-types';
|
|
8
|
+
export declare class LogParser {
|
|
9
|
+
private logPath;
|
|
10
|
+
private statePath;
|
|
11
|
+
private lastReadPosition;
|
|
12
|
+
private lastProcessedTimestamp;
|
|
13
|
+
private seenErrors;
|
|
14
|
+
constructor(logPath?: string);
|
|
15
|
+
/**
|
|
16
|
+
* Parse recent logs for tool call errors
|
|
17
|
+
* Returns only new errors since last parse
|
|
18
|
+
*/
|
|
19
|
+
parseToolCallErrors(retries?: number): Promise<ToolCallError[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Parse a single log entry for error patterns
|
|
22
|
+
*/
|
|
23
|
+
private parseLogEntry;
|
|
24
|
+
/**
|
|
25
|
+
* Extract tool call error from JSON log entry
|
|
26
|
+
*/
|
|
27
|
+
private extractToolCallError;
|
|
28
|
+
/**
|
|
29
|
+
* Extract validation error
|
|
30
|
+
*/
|
|
31
|
+
private extractValidationError;
|
|
32
|
+
/**
|
|
33
|
+
* Extract parameter error
|
|
34
|
+
*/
|
|
35
|
+
private extractParameterError;
|
|
36
|
+
/**
|
|
37
|
+
* Extract tool name from error message
|
|
38
|
+
*/
|
|
39
|
+
private extractToolNameFromMessage;
|
|
40
|
+
/**
|
|
41
|
+
* Check if error is a duplicate
|
|
42
|
+
*/
|
|
43
|
+
private isDuplicate;
|
|
44
|
+
/**
|
|
45
|
+
* Generate unique signature for error deduplication
|
|
46
|
+
*/
|
|
47
|
+
private getErrorSignature;
|
|
48
|
+
/**
|
|
49
|
+
* Check if file exists
|
|
50
|
+
*/
|
|
51
|
+
private fileExists;
|
|
52
|
+
/**
|
|
53
|
+
* Reset parser state (useful for testing)
|
|
54
|
+
*/
|
|
55
|
+
reset(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get statistics about parsed errors
|
|
58
|
+
*/
|
|
59
|
+
getStats(): {
|
|
60
|
+
totalSeen: number;
|
|
61
|
+
uniqueErrors: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Load parser state from disk synchronously (called in constructor)
|
|
65
|
+
*/
|
|
66
|
+
private loadStateSync;
|
|
67
|
+
/**
|
|
68
|
+
* Save parser state to disk
|
|
69
|
+
*/
|
|
70
|
+
private saveState;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=log-parser.d.ts.map
|