Files
ai-terminal-assistant/src/tools/load_description.ts
T
2025-12-10 17:11:46 +08:00

16 lines
474 B
TypeScript

import * as fs from 'fs';
import * as path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export function loadDescription(toolName: string): string {
const filePath = path.join(__dirname, 'descriptions', `${toolName}.txt`);
try {
return fs.readFileSync(filePath, 'utf-8').trim();
} catch {
throw new Error(`无法加载工具描述文件: ${filePath}`);
}
}