feat(automation): select op — target entities by handle/type/layer

Add a select op that sets the document selection (by hex handles from
query, or by type/layer, or clear). Selection drives modify commands, so
an agent can query → select → run("ERASE") to act on specific entities.
Completes the modify half of the act/observe loop. ocs.py gains select().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-17 21:27:26 +03:00
commit c78bc62056
3 changed files with 65 additions and 0 deletions

View file

@ -79,6 +79,19 @@ class Ocs:
"""List entities (handle, type, layer, geometry), optionally filtered."""
return self._send(op="query", type=type, layer=layer, limit=limit)
def select(
self,
handles: Optional[list[str]] = None,
type: Optional[str] = None,
layer: Optional[str] = None,
clear: bool = False,
) -> dict[str, Any]:
"""Set the selection by handle, type, or layer (a following selection
command like ``run("ERASE")`` then acts on it). `clear=True` deselects."""
return self._send(
op="select", handles=handles, type=type, layer=layer, clear=clear
)
def save(self, path: Optional[str] = None) -> dict[str, Any]:
"""Write the document (defaults to the opened/last-saved path)."""
return self._send(op="save", path=path)