From f2e9779b6a4f54cdbb529d18ddd6ce1bdd85790b Mon Sep 17 00:00:00 2001 From: melabidi Date: Tue, 1 Sep 2026 05:45:08 +0000 Subject: [PATCH] add example --- example.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 example.js diff --git a/example.js b/example.js new file mode 100644 index 0000000..aea01d3 --- /dev/null +++ b/example.js @@ -0,0 +1,36 @@ +// example.js +const LMStudioFileAgent = require('./agent'); + +async function example() { + const agent = new LMStudioFileAgent({ + workspaceDir: './my_project' + }); + + // Read a file + const content = await agent.readFile('example.js'); + console.log('File content:', content); + + // Create a new file + console.log(await agent.createFile('new_script.js', 'console.log("Hello World");', 'javascript')); + + // List directory + const items = await agent.listDirectory(); + console.log('Directory:', items); + + // Search for files + const files = await agent.searchFiles('*.js'); + console.log('JS files:', files); + + // Edit a file + console.log(await agent.editFile('new_script.js', 'Hello World', 'Hello Agent')); + + // Search content + const results = await agent.searchContent('console.log', '.'); + console.log('Search results:', results); + + // Process natural language request + const response = await agent.processRequest('Create a new JavaScript file called test.js with a main function'); + console.log('Agent response:', response); +} + +example().catch(console.error); \ No newline at end of file