aboutsummaryrefslogtreecommitdiffstats
path: root/agents/todo-js/tools.js
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-09 21:28:35 +0800
committerGitHub <noreply@github.com>2024-07-09 21:28:35 +0800
commit48cb8381eae03aa45b34fa79f4e0037f6a5c0225 (patch)
tree88a4c333013ad92a0bd99d0b59feae9231f15243 /agents/todo-js/tools.js
parent02e335c99526fe52dee0d0a016aee6bf62d874c2 (diff)
downloadllm-functions-docker-48cb8381eae03aa45b34fa79f4e0037f6a5c0225.tar.gz
feat: remove todo-js/todo-py and rename todo-sh to todo (#68)
Diffstat (limited to 'agents/todo-js/tools.js')
-rw-r--r--agents/todo-js/tools.js68
1 files changed, 0 insertions, 68 deletions
diff --git a/agents/todo-js/tools.js b/agents/todo-js/tools.js
deleted file mode 100644
index cef4c8f..0000000
--- a/agents/todo-js/tools.js
+++ /dev/null
@@ -1,68 +0,0 @@
-const fs = require('fs');
-const path = require('path');
-
-/**
- * Add a new todo item
- * @typedef {Object} AddTodoArgs
- * @property {string} desc - The task description
- * @param {AddTodoArgs} args
- */
-exports.add_todo = function addTodo(args) {
- const todosFile = _getTodosFile();
- if (fs.existsSync(todosFile)) {
- const num = JSON.parse(fs.readFileSync(todosFile)).reduce((max, item) => Math.max(max, item.id), 0) + 1;
- const data = fs.readFileSync(todosFile);
- fs.writeFileSync(todosFile, JSON.stringify([...JSON.parse(data), { id: num, desc: args.desc }]));
- console.log(`Successfully added todo id=${num}`);
- } else {
- fs.writeFileSync(todosFile, JSON.stringify([{ id: 1, desc: args.desc }]));
- console.log('Successfully added todo id=1');
- }
-}
-
-/**
- * Delete an existing todo item
- * @typedef {Object} DelTodoArgs
- * @property {number} id - The task id
- * @param {DelTodoArgs} args
- */
-exports.del_todo = function delTodo(args) {
- const todosFile = _getTodosFile();
- if (fs.existsSync(todosFile)) {
- const data = fs.readFileSync(todosFile);
- const newData = JSON.parse(data).filter(item => item.id !== args.id);
- fs.writeFileSync(todosFile, JSON.stringify(newData));
- console.log(`Successfully deleted todo id=${args.id}`);
- } else {
- console.log('Empty todo list');
- }
-}
-
-/**
- * Display the current todo list in json format.
- */
-exports.list_todos = function listTodos() {
- const todosFile = _getTodosFile();
- if (fs.existsSync(todosFile)) {
- console.log(fs.readFileSync(todosFile, "utf8"));
- } else {
- console.log("[]");
- }
-}
-
-/**
- * Delete the entire todo list.
- */
-exports.clear_todos = function clearTodos() {
- const todosFile = _getTodosFile();
- fs.unlinkSync(todosFile)
- console.log("Successfully deleted entry todo list");
-}
-
-function _getTodosFile() {
- const cacheDir = process.env.LLM_AGENT_CACHE_DIR || '/tmp';
- if (!fs.existsSync(cacheDir)) {
- fs.mkdirSync(cacheDir, { recursive: true });
- }
- return path.join(cacheDir, 'todos.json');
-}