Create a command context. Args: workspace_root: Root directory of the workspace conversation: Conversation object cost_tracker: Cost tracker object history: History log object cwd: Current working directory (defaults to workspace_root) config
(
workspace_root: str | Path,
conversation: Any = None,
cost_tracker: Any = None,
history: Any = None,
cwd: str | Path | None = None,
config: dict[str, Any] | None = None,
app_state_store: Any = None,
provider: Any = None,
ui: Any = None,
tool_context: Any = None,
)
| 288 | |
| 289 | |
| 290 | def create_command_context( |
| 291 | workspace_root: str | Path, |
| 292 | conversation: Any = None, |
| 293 | cost_tracker: Any = None, |
| 294 | history: Any = None, |
| 295 | cwd: str | Path | None = None, |
| 296 | config: dict[str, Any] | None = None, |
| 297 | app_state_store: Any = None, |
| 298 | provider: Any = None, |
| 299 | ui: Any = None, |
| 300 | tool_context: Any = None, |
| 301 | ) -> CommandContext: |
| 302 | """ |
| 303 | Create a command context. |
| 304 | |
| 305 | Args: |
| 306 | workspace_root: Root directory of the workspace |
| 307 | conversation: Conversation object |
| 308 | cost_tracker: Cost tracker object |
| 309 | history: History log object |
| 310 | cwd: Current working directory (defaults to workspace_root) |
| 311 | config: Optional configuration dict |
| 312 | app_state_store: Optional reactive AppState store. Commands that |
| 313 | mutate global session state (e.g. /advisor, /permissions) need |
| 314 | this. |
| 315 | provider: Optional active LLM provider. Commands that gate on |
| 316 | provider type (e.g. /advisor) need this. |
| 317 | ui: Optional ``UIHost`` interaction port. Interactive commands drive |
| 318 | it; when None the engine substitutes a ``NullUIHost``. |
| 319 | tool_context: Optional ``ToolContext``. Threaded onto the context so a |
| 320 | ``SkillPromptCommand`` can render via the same ``_run_markdown_skill`` |
| 321 | path the Skill tool uses (session id + gated shell-exec). When None, |
| 322 | skill prompts degrade to a headless render. |
| 323 | |
| 324 | Returns: |
| 325 | CommandContext instance |
| 326 | """ |
| 327 | root = Path(workspace_root).expanduser().resolve() |
| 328 | current = Path(cwd).expanduser().resolve() if cwd is not None else root |
| 329 | |
| 330 | return CommandContext( |
| 331 | workspace_root=root, |
| 332 | cwd=current, |
| 333 | conversation=conversation, |
| 334 | cost_tracker=cost_tracker, |
| 335 | history=history, |
| 336 | config=config or {}, |
| 337 | app_state_store=app_state_store, |
| 338 | provider=provider, |
| 339 | ui=ui, |
| 340 | tool_context=tool_context, |
| 341 | ) |