diff --git a/docs/PLUGIN.md b/docs/PLUGIN.md index 9faf3834..92bd97eb 100644 --- a/docs/PLUGIN.md +++ b/docs/PLUGIN.md @@ -848,7 +848,10 @@ open-vocabulary. On a repository you do not trust, leave micro-skills off (the d `PreToolUse` hook that prints `{}` makes agy deny the tool, so none is registered; `PostToolUse` carries no tool result and a matcher `"*"` never matches, so the results are read from the conversation's `transcript_full.jsonl` at the next `PreInvocation` and at `Stop`, where - every result of the previous model call is already written (`trace/antigravity.py`). There is no + every result of the previous model call is already written (`trace/antigravity.py`). The reader + also takes `write_file` and `edit_file` (with `Path`), the names reported from Antigravity + Desktop's transcripts, as Write and Edit; the plugin has not been run with Antigravity Desktop. + There is no prompt event and no `SessionEnd`: a prompt is the `PreInvocation` with `invocationNum` 0, and a conversation is folded by the next session start in its repository once its transcript has been quiet for ten minutes. Context goes back as `injectSteps`: a persistent `systemMessage` at diff --git a/tests/test_antigravity.py b/tests/test_antigravity.py index af0e07c5..40496ad3 100644 --- a/tests/test_antigravity.py +++ b/tests/test_antigravity.py @@ -229,6 +229,25 @@ def test_running_steps_system_rows_and_finish_do_not_shift_the_pairing(tp): assert [(i["args"]["command"], i["exit_code"]) for i in items] == [("ls", 0)] +def test_write_file_and_edit_file_read_as_write_and_edit(tp, tmp_path): + """`write_file` and `edit_file` (with `Path`), the names reported from Antigravity Desktop's + transcripts, read as Write and Edit, as agy's own file tools do.""" + t = Transcript(tp) + t.prompt("add a helper") + t.call([("write_file", {"Path": "/work/repo/src/helper.py"})], [("ok", {"type": "CODE_ACTION"})]) + t.call([("edit_file", {"Path": "/work/repo/src/helper.py"})], [("ok", {"type": "CODE_ACTION"})]) + items, _offset, _last = trace.antigravity_read(str(tp), offset=0, after=-1, final=True) + assert [(i["name"], i["args"], i["is_error"]) for i in items if i["kind"] == "tool"] == [ + ("Write", {"file_path": "/work/repo/src/helper.py"}, False), + ("Edit", {"file_path": "/work/repo/src/helper.py"}, False)] + work = tmp_path / "w" + work.mkdir() + path = Antigravity().mechanism_trace(str(tp), str(work)) + assert [(tool, args) for tool, args, _text, _ok in trace.load_trajectory(path)] == [ + ("Write", {"file_path": "/work/repo/src/helper.py"}), + ("Edit", {"file_path": "/work/repo/src/helper.py"})] + + # ---- agy's answer -------------------------------------------------------------------------- def test_render_answers_each_event_in_agys_terms(): host = Antigravity() diff --git a/tokeneconomizer/trace/antigravity.py b/tokeneconomizer/trace/antigravity.py index e99b68ec..6481b996 100644 --- a/tokeneconomizer/trace/antigravity.py +++ b/tokeneconomizer/trace/antigravity.py @@ -43,7 +43,9 @@ "run_command": ("Bash", {"command": ("CommandLine",)}), "view_file": ("Read", {"file_path": _FILE}), "read_file": ("Read", {"file_path": _FILE}), + "write_file": ("Write", {"file_path": _FILE}), "write_to_file": ("Write", {"file_path": _FILE}), + "edit_file": ("Edit", {"file_path": _FILE}), "replace_file_content": ("Edit", {"file_path": _FILE}), "multi_replace_file_content": ("Edit", {"file_path": _FILE}), "sed_file": ("Edit", {"file_path": _FILE}),