contaigents
Version:
Modular AI Content Ecosystem with Audio Generation
48 lines (47 loc) ⢠1.95 kB
JavaScript
import { ToolManager } from '../services/tools/ToolManager.js';
import fs from 'fs/promises';
async function manualWriteTest() {
console.log('š§ Manual Write Test - Adding "hey sooraj2" to README.md\n');
try {
// Read current content
console.log('š Current README.md content:');
const currentContent = await fs.readFile('README.md', 'utf-8');
console.log('ā'.repeat(30));
console.log(currentContent);
console.log('ā'.repeat(30));
// Use ToolManager to add the new line
const toolManager = new ToolManager(process.cwd());
console.log('\nā” Executing write_file tool to add "hey sooraj2"...');
const result = await toolManager.executeTool({
tool_name: 'write_file',
parameters: {
operation_type: 'partial',
file_path: 'README.md',
content: currentContent + '\nhey sooraj2',
start_line: 1,
end_line: 4,
create_backup: true
}
});
console.log('Tool execution result:');
console.log('Success:', result.success);
console.log('Message:', result.message);
console.log('Error:', result.error);
// Read updated content
console.log('\nš Updated README.md content:');
const updatedContent = await fs.readFile('README.md', 'utf-8');
console.log('ā'.repeat(30));
console.log(updatedContent);
console.log('ā'.repeat(30));
console.log('\nā
Manual write test completed!');
console.log('The file should now contain "hey sooraj2" at the bottom.');
}
catch (error) {
console.error('ā Manual write test failed:', error);
}
}
// Run the test if this file is executed directly
if (import.meta.url === `file://${process.argv[1]}`) {
manualWriteTest().catch(console.error);
}
export { manualWriteTest };