mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
Stop shell Excel builds, default write_file paths, and cap short-intent tool rounds.
Refuse openpyxl/pandas-to_excel via run_command, auto-write content-only files under tmp/, and limit WhatsApp ops short intents to 8 tool rounds by default. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a5ebabbaae
commit
d8bc08ee0d
6 changed files with 162 additions and 13 deletions
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from runtime.tools.public.write_file_tool import write_file_tool
|
||||
from runtime.tools.tool_validation import filter_arguments_to_schema, validate_tool_arguments
|
||||
|
||||
|
|
@ -27,7 +29,24 @@ def test_write_file_schema_allows_aliases() -> None:
|
|||
|
||||
def test_write_file_path_required_message() -> None:
|
||||
spec = write_file_tool()
|
||||
out = spec.handler({"content": "x"})
|
||||
out = spec.handler({})
|
||||
assert out.get("ok") is False
|
||||
assert out.get("error") == "path_required"
|
||||
assert "example" in out
|
||||
|
||||
|
||||
def test_write_file_defaults_path_when_content_only(tmp_path, monkeypatch) -> None:
|
||||
def _resolve(raw: str):
|
||||
return tmp_path / "workspace" / str(raw).replace("\\", "/").lstrip("/")
|
||||
|
||||
monkeypatch.setattr(
|
||||
"runtime.tools.public.write_file_tool.resolve_workspace_path",
|
||||
_resolve,
|
||||
)
|
||||
spec = write_file_tool()
|
||||
out = spec.handler({"content": "hello-auto"})
|
||||
assert out.get("ok") is True
|
||||
assert out.get("auto_path") is True
|
||||
path = Path(str(out.get("path") or ""))
|
||||
assert path.name.startswith("write_")
|
||||
assert path.read_text(encoding="utf-8") == "hello-auto"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue