test_all_builtin_tools
import asyncio
from builtin.tools.registry import execute_builtin_tool
async def main():
print("--- Starting Built-in Tool Integration Test ---")
test_dir = "test_skill_workspace"
test_file = f"{test_dir}/test_file.txt"
# 0. Cleanup from previous runs
print("\n[Phase 0: Cleanup]")
cleanup_result = await execute_builtin_tool("bash", {"command": f"rm -rf {test_dir}"})
print(f"Cleanup result: {cleanup_result}")
# 1. Test list_dir
print("\n[Phase 1: Testing list_dir]")
list_result = await execute_builtin_tool("list_dir", {"path": "."})
print(f"list_dir result:\n{list_result}")
assert "test_skills" in list_result, "list_dir failed to find test_skills dir"
# 2. Test file_create
print("\n[Phase 2: Testing file_create]")
create_content = "Hello, World!\nThis is a test file."
create_result = await execute_builtin_tool("file_create", {"path": test_file, "content": create_content})
print(f"file_create result: {create_result}")
assert "SUCCESS" in create_result, "file_create failed"
# 3. Test read_file
print("\n[Phase 3: Testing read_file]")
read_result = await execute_builtin_tool("read_file", {"path": test_file})
print(f"read_file result:\n{read_result}")
assert "Hello, World!" in read_result, "read_file failed to read content"
# 4. Test edit_file_by_lines
print("\n[Phase 4: Testing edit_file_by_lines]")
edit_content = "Hello, Memento-S!\nThis is an edited line."
edit_result = await execute_builtin_tool("edit_file_by_lines", {"path": test_file, "start_line": 1, "end_line": 2, "new_content": edit_content})
print(f"edit_file_by_lines result:\n{edit_result}")
assert "SUCCESS" in edit_result and ">>" in edit_result, "edit_file_by_lines failed"
# 5. Verify edit with read_file again
print("\n[Phase 5: Verifying edit with read_file]")
verify_read_result = await execute_builtin_tool("read_file", {"path": test_file})
print(f"verify_read_result:\n{verify_read_result}")
assert "Hello, Memento-S!" in verify_read_result, "File content was not edited correctly"
# 6. Test search_grep
print("\n[Phase 6: Testing search_grep]")
grep_result = await execute_builtin_tool("search_grep", {"pattern": "Memento-S", "dir_path": test_dir})
print(f"search_grep result:\n{grep_result}")
assert "test_file.txt:1" in grep_result, "search_grep failed to find pattern"
# 7. Test bash
print("\n[Phase 7: Testing bash]")
bash_result = await execute_builtin_tool("bash", {"command": "echo 'Hello from bash'"})
print(f"bash result: {bash_result}")
assert "Hello from bash" in bash_result, "bash tool failed"
# 8. Test fetch_webpage
print("\n[Phase 8: Testing fetch_webpage]")
web_result = await execute_builtin_tool("fetch_webpage", {"url": "http://example.com"})
print(f"fetch_webpage result (first 100 chars): {web_result[:100]}...")
assert "Example Domain" in web_result, "fetch_webpage failed"
print("\n--- Test Completed Successfully ---")
if __name__ == "__main__":
asyncio.run(main())
More from memento-teams/memento-skills
filesystem
Direct filesystem operations (read, write, edit, list, search files). Use for any file manipulation tasks.
12docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of \"Word doc\", \"word document\", \".docx\", or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a \"report\", \"memo\", \"letter\", \"template\", or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
9web-search
Web search and content fetching. Use when the user needs to search the web for information or fetch content from URLs.
9skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
9pptx
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.
8pdf
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.
8