feat: remove todo-js/todo-py and rename todo-sh to todo (#68)
This commit is contained in:
@@ -35,9 +35,8 @@ execute_command.sh
|
|||||||
- Create a `./agents.txt` file with each agent name on a new line.
|
- Create a `./agents.txt` file with each agent name on a new line.
|
||||||
|
|
||||||
```
|
```
|
||||||
todo-sh
|
todo
|
||||||
#todo-js
|
#demo
|
||||||
#todo-py
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run `argc build` to build functions declarations files (`functions.json`) and binaries (`./bin`) for tools and agents.
|
- Run `argc build` to build functions declarations files (`functions.json`) and binaries (`./bin`) for tools and agents.
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../todo-sh/index.yaml
|
|
||||||
@@ -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');
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../todo-sh/index.yaml
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import json
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from json import JSONDecodeError
|
|
||||||
|
|
||||||
|
|
||||||
def add_todo(desc: str):
|
|
||||||
"""Add a new todo item
|
|
||||||
Args:
|
|
||||||
desc: The task description
|
|
||||||
"""
|
|
||||||
todos_file = _get_todos_file()
|
|
||||||
try:
|
|
||||||
with open(todos_file, "r") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
except (FileNotFoundError, JSONDecodeError):
|
|
||||||
data = []
|
|
||||||
num = max([item["id"] for item in data] + [0]) + 1
|
|
||||||
data.append({"id": num, "desc": desc})
|
|
||||||
with open(todos_file, "w") as f:
|
|
||||||
json.dump(data, f)
|
|
||||||
print(f"Successfully added todo id={num}")
|
|
||||||
|
|
||||||
|
|
||||||
def del_todo(id: int):
|
|
||||||
"""Delete an existing todo item
|
|
||||||
Args:
|
|
||||||
id: The task id
|
|
||||||
"""
|
|
||||||
todos_file = _get_todos_file()
|
|
||||||
try:
|
|
||||||
with open(todos_file, "r") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
except (FileNotFoundError, JSONDecodeError):
|
|
||||||
print("Empty todo list")
|
|
||||||
return
|
|
||||||
data = [item for item in data if item["id"] != id]
|
|
||||||
with open(todos_file, "w") as f:
|
|
||||||
json.dump(data, f)
|
|
||||||
print(f"Successfully deleted todo id={id}")
|
|
||||||
|
|
||||||
|
|
||||||
def list_todos():
|
|
||||||
"""Display the current todo list in json format."""
|
|
||||||
todos_file = _get_todos_file()
|
|
||||||
try:
|
|
||||||
with open(todos_file, "r") as f:
|
|
||||||
print(f.read())
|
|
||||||
except FileNotFoundError:
|
|
||||||
print("[]")
|
|
||||||
|
|
||||||
|
|
||||||
def clear_todos():
|
|
||||||
"""Delete the entire todo list."""
|
|
||||||
os.remove(_get_todos_file())
|
|
||||||
|
|
||||||
|
|
||||||
def _get_todos_file() -> str:
|
|
||||||
cache_dir=os.environ.get("LLM_AGENT_CACHE_DIR", "/tmp")
|
|
||||||
if not os.path.exists(cache_dir):
|
|
||||||
os.makedirs(cache_dir, exist_ok=True)
|
|
||||||
return os.path.join(cache_dir, "todos.json")
|
|
||||||
@@ -12,8 +12,7 @@ instructions: |
|
|||||||
- Errors: "Cannot add todo item, missing description.", "Todo item with id {id} not found.", "No todo items to delete."
|
- Errors: "Cannot add todo item, missing description.", "Todo item with id {id} not found.", "No todo items to delete."
|
||||||
Make sure you understand the user request properly before performing any action. If unsure, ask clarifying questions like "Do you want to remove all todos or just a specific one?"
|
Make sure you understand the user request properly before performing any action. If unsure, ask clarifying questions like "Do you want to remove all todos or just a specific one?"
|
||||||
conversation_starters:
|
conversation_starters:
|
||||||
- "Add a new todo item 'Finish report'."
|
- "Add a new todo item: "
|
||||||
- "Remove the todo item with id=2."
|
|
||||||
- "Delete all my todos."
|
|
||||||
- "What todos do I have pending?"
|
- "What todos do I have pending?"
|
||||||
|
- "Delete all my todos."
|
||||||
- "How can I remove a specific todo item?"
|
- "How can I remove a specific todo item?"
|
||||||
Reference in New Issue
Block a user