feat: wire 10 new tools — file_read, file_write, glob, grep, web_fetch, task CRUD, send_message, schedule_cron
- 10 new JS tool classes in src/tools/ (clean, no framework deps) - tools/index.js: registry-based init with env toggles - bot/index.js: 16 tool definitions + 16 handlers (was 4) - Added glob npm dependency - Tools: bash, file_edit, file_read, file_write, glob, grep, web_search, web_fetch, git, task_create/update/list, send_message, schedule_cron, delegate_agent, run_skill
This commit is contained in:
22
src/tools/FileWriteTool.js
Normal file
22
src/tools/FileWriteTool.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { logger } from '../utils/logger.js';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
|
||||
export class FileWriteTool {
|
||||
constructor() {
|
||||
this.name = 'file_write';
|
||||
this.description = 'Write content to a file, creating parent directories as needed';
|
||||
}
|
||||
|
||||
async execute(args) {
|
||||
const { file_path, content } = args;
|
||||
try {
|
||||
const fullPath = path.resolve(file_path);
|
||||
await fs.ensureDir(path.dirname(fullPath));
|
||||
await fs.writeFile(fullPath, content, 'utf-8');
|
||||
return `✅ Written ${Buffer.byteLength(content)} bytes to ${fullPath}`;
|
||||
} catch (e) {
|
||||
return `❌ Write error: ${e.message}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user