feat(ci): add GitHub Actions workflow for test directory

- nanobot/channels/matrix.py: Add keyword-only parameters restrict_to_workspace/workspace to MatrixChannel.__init__ and assign them to _restrict_to_workspace/_workspace with proper type conversion and path resolution
- tests/test_commands.py: Add _strip_ansi() function to remove ANSI escape codes, use regex assertions for --workspace/--config parameters to allow 1 or 2 dashes
This commit is contained in:
Jiajun Xie
2026-03-12 21:54:22 +08:00
parent 95c741db62
commit ec6e099393
3 changed files with 56 additions and 7 deletions
+12 -3
View File
@@ -149,13 +149,22 @@ class MatrixChannel(BaseChannel):
name = "matrix"
display_name = "Matrix"
def __init__(self, config: Any, bus: MessageBus):
def __init__(
self,
config: Any,
bus: MessageBus,
*,
restrict_to_workspace: bool = False,
workspace: str | Path | None = None,
):
super().__init__(config, bus)
self.client: AsyncClient | None = None
self._sync_task: asyncio.Task | None = None
self._typing_tasks: dict[str, asyncio.Task] = {}
self._restrict_to_workspace = False
self._workspace: Path | None = None
self._restrict_to_workspace = bool(restrict_to_workspace)
self._workspace = (
Path(workspace).expanduser().resolve(strict=False) if workspace is not None else None
)
self._server_upload_limit_bytes: int | None = None
self._server_upload_limit_checked = False