优化工具
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user