From 3493801b302e6a1957c61b710d17897b719a5da5 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Tue, 24 Nov 2026 21:53:37 +0530 Subject: Add Lua addon system and full coding toolset to Solo engine - src/agentux/addons.py: sandboxed LuaJIT addon manager with seven lifecycle hooks (on_start, on_prompt, on_system_prompt, on_tool_call, on_tool_result, on_answer, on_event). Addons load from ~/.agentux/addons/ or /.agentux/addons/. - src/agentux/solo_engine.py: Solo now gets the full workspace toolset (filesystem, shell, git, project, search, outline_symbols, todo, view_image, repomap, checkpoint) plus shadow checkpointing, so it can read, edit, run, and test code rather than only researching. - src/agentux/agent.py: wires AddonManager into the agent lifecycle. - tests/test_addons.py: 22 tests for loading, hooks, sandbox isolation, and agent integration. - tests/test_solo_engine.py: 6 tests for Solo's coding tools and checkpointing. 547 tests pass. Co-Authored-By: Claude Code --- tests/test_solo_engine.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'tests/test_solo_engine.py') diff --git a/tests/test_solo_engine.py b/tests/test_solo_engine.py index ac87488..ad45fef 100644 --- a/tests/test_solo_engine.py +++ b/tests/test_solo_engine.py @@ -100,6 +100,7 @@ class StubWebSearch: def make_engine(tmp_path, provider, web=None, **kwargs): knowledge = KnowledgeStore(path=str(tmp_path / "knowledge.db")) + kwargs.setdefault("project", str(tmp_path)) engine = SoloEngine(provider, knowledge, web_search=web, **kwargs) return engine, knowledge @@ -397,6 +398,104 @@ async def test_engine_handles_non_question_without_research(tmp_path): knowledge.close() +# ---------------------------------------------------------------------- +# Coding tools & shadow checkpointing +# ---------------------------------------------------------------------- +async def test_solo_has_coding_tools(tmp_path): + """Solo is a coding agent: it gets the same workspace tools as the main + agent, not just research and knowledge tools.""" + engine, knowledge = make_engine(tmp_path, ScriptedProvider([])) + names = {t.name for t in engine.registry.list_tools()} + for expected in ("filesystem", "shell", "project", "search", "outline_symbols", + "git", "todo", "view_image", "repomap", "checkpoint"): + assert expected in names, f"Solo is missing the {expected} tool" + knowledge.close() + + +async def test_solo_can_read_and_edit_files(tmp_path): + """Solo can inspect and modify the workspace, not just look things up.""" + (tmp_path / "hello.txt").write_text("original") + provider = ScriptedProvider([ + tool_call("filesystem", operation="read", path="hello.txt"), + tool_call("filesystem", operation="write", path="hello.txt", content="changed"), + Message(role="assistant", content="Done."), + ]) + engine, knowledge = make_engine(tmp_path, provider) + result = await engine.run("read and modify hello.txt") + + assert result.answer + assert (tmp_path / "hello.txt").read_text() == "changed" + knowledge.close() + + +async def test_solo_captures_shadow_checkpoints(tmp_path): + """Every mutating filesystem call is preceded by a shadow snapshot, so + Solo changes are reversible the same way the main agent's are.""" + (tmp_path / "hello.txt").write_text("original") + provider = ScriptedProvider([ + tool_call("filesystem", operation="write", path="hello.txt", content="changed"), + Message(role="assistant", content="Done."), + ]) + engine, knowledge = make_engine(tmp_path, provider) + await engine.run("modify hello.txt") + + checkpoints = engine._checkpoint_manager.list_checkpoints() + assert len(checkpoints) == 1 + assert checkpoints[0].description.startswith("Before write on hello.txt") + knowledge.close() + + +async def test_solo_rollback_restores_files(tmp_path): + """The checkpoint lets Solo undo its own edits.""" + (tmp_path / "hello.txt").write_text("original") + provider = ScriptedProvider([ + tool_call("filesystem", operation="write", path="hello.txt", content="changed"), + Message(role="assistant", content="Done."), + ]) + engine, knowledge = make_engine(tmp_path, provider) + await engine.run("modify hello.txt") + assert (tmp_path / "hello.txt").read_text() == "changed" + + ok, _msg = engine._checkpoint_manager.rollback() + assert ok is True + assert (tmp_path / "hello.txt").read_text() == "original" + knowledge.close() + + +async def test_solo_runs_shell_commands(tmp_path): + """Solo can execute workspace commands, not just read files.""" + provider = ScriptedProvider([ + tool_call("shell", command="echo hello"), + Message(role="assistant", content="Done."), + ]) + engine, knowledge = make_engine(tmp_path, provider) + result = await engine.run("run a command") + + assert result.answer + knowledge.close() + + +async def test_solo_uses_git_tool(tmp_path): + """Solo can inspect git state the same way the main agent can.""" + import subprocess + subprocess.run(["git", "init"], cwd=tmp_path, capture_output=True) + subprocess.run(["git", "config", "user.email", "t@t.t"], cwd=tmp_path, capture_output=True) + subprocess.run(["git", "config", "user.name", "t"], cwd=tmp_path, capture_output=True) + (tmp_path / "f.txt").write_text("x") + subprocess.run(["git", "add", "."], cwd=tmp_path, capture_output=True) + subprocess.run(["git", "commit", "-m", "init"], cwd=tmp_path, capture_output=True) + + provider = ScriptedProvider([ + tool_call("git", action="status"), + Message(role="assistant", content="Clean."), + ]) + engine, knowledge = make_engine(tmp_path, provider) + result = await engine.run("check git status") + + assert result.answer + knowledge.close() + + # ---------------------------------------------------------------------- # Knowledge store unit tests # ---------------------------------------------------------------------- -- cgit v1.2.3