Option C Tools
Loading...
Searching...
No Matches
oct.mcp.executor Namespace Reference

Classes

class  ToolExecutor

Functions

None _dbg (*args, **kwargs)
list[str] _build_argv_lint (dict args, Path project_root)
list[str] _build_argv_health (dict args, Path project_root)
list[str] _build_argv_skeleton (dict args, Path project_root)
list[str] _build_argv_deps (dict args, Path project_root)
list[str] _build_argv_test (dict args, Path project_root)
list[str] _build_argv_typecheck (dict args, Path project_root)
list[str] _build_argv_diag (dict args, Path project_root)
list[str] _build_argv_git_status (dict args, Path project_root)
list[str] _build_argv_git_check (dict args, Path project_root)
list[str] _build_argv_format (dict args, Path project_root)
list[str] _build_argv_docs (dict args, Path project_root)
list[str] _build_argv_export_source (dict args, Path project_root)
list[str] _build_argv_new (dict args, Path project_root)
list[str] _build_argv_scaffold (dict args, Path project_root)
list[str] _build_argv_clean (dict args, Path project_root)
list[str] _build_argv_install_hooks (dict args, Path project_root)
list[str] _build_argv_git_commit (dict args, Path project_root)
list[str] _build_argv_git_hooks_install (dict args, Path project_root)
list[str] _build_argv_git_init (dict args, Path project_root)
list[str] _build_argv_git_changelog (dict args, Path project_root)

Variables

dict _ARGV_BUILDERS

Detailed Description

Purpose
-------
Tool Executor (Layer 4, inner logic) for the ``oct-mcp`` six-layer
pipeline. Maps validated tool arguments to ``oct`` CLI argv lists and
delegates execution to :class:`oct.mcp.sandbox.SandboxExecutor`.

Responsibilities
----------------
- Provide one ``_build_argv_<tool>()`` function per Phase 5A tool that
  converts a validated Pydantic model to an ``["oct", subcommand, ...]``
  argv list.
- Provide :class:`ToolExecutor` which wires together the Pydantic model
  dict and the sandbox.
- Never import oct internals directly — always call the ``oct`` CLI as
  a subprocess (blueprint §5.5 isolation principle, design decision D3).

Diagnostics
-----------
Domain: MCP
Levels:
    L2 — lifecycle: tool execution
    L3 — argv details
    L4 — deep trace

Contracts
---------
- This module does not import ``click`` or the MCP SDK.
- ``_build_argv_*()`` functions accept a ``dict`` (from
  ``model.model_dump()``) and return a ``list[str]``. They never raise
  for valid validated input.
- :meth:`ToolExecutor.execute` never raises — it returns
  :class:`~oct.mcp.sandbox.SandboxResult` directly from the sandbox.

Function Documentation

◆ _build_argv_clean()

list[str] oct.mcp.executor._build_argv_clean ( dict args,
Path project_root )
protected
Build argv for ``oct clean``.

Definition at line 264 of file executor.py.

◆ _build_argv_deps()

list[str] oct.mcp.executor._build_argv_deps ( dict args,
Path project_root )
protected
Build argv for ``oct deps``.

OI-502: no longer emits ``--check``; that flag is not accepted by
the CLI. Pin auditing is instead available via ``--audit-pins`` (not
modelled here yet).

Definition at line 106 of file executor.py.

◆ _build_argv_diag()

list[str] oct.mcp.executor._build_argv_diag ( dict args,
Path project_root )
protected
Build argv for ``oct diag <subcommand>``.

OI-502: no longer emits ``--json``; no diag subcommand currently
accepts that flag (``validate-config`` may grow one via OI-534, at
which point this builder will conditionally re-emit it).

Definition at line 145 of file executor.py.

◆ _build_argv_docs()

list[str] oct.mcp.executor._build_argv_docs ( dict args,
Path project_root )
protected
Build argv for ``oct docs``.

Definition at line 210 of file executor.py.

◆ _build_argv_export_source()

list[str] oct.mcp.executor._build_argv_export_source ( dict args,
Path project_root )
protected
Build argv for ``oct export-source``.

Definition at line 226 of file executor.py.

◆ _build_argv_format()

list[str] oct.mcp.executor._build_argv_format ( dict args,
Path project_root )
protected
Build argv for ``oct format``.

Uses ``--dry-run`` unless ``apply=True`` AND ``confirm=True``.
The safety gate enforces this rule upstream; the argv builder also
checks ``_dry_run_override`` (set by execute_write()) as a redundant guard.

Definition at line 185 of file executor.py.

◆ _build_argv_git_changelog()

list[str] oct.mcp.executor._build_argv_git_changelog ( dict args,
Path project_root )
protected
Build argv for ``oct git changelog``.

Definition at line 318 of file executor.py.

◆ _build_argv_git_check()

list[str] oct.mcp.executor._build_argv_git_check ( dict args,
Path project_root )
protected
Build argv for ``oct git check``.

Definition at line 167 of file executor.py.

◆ _build_argv_git_commit()

list[str] oct.mcp.executor._build_argv_git_commit ( dict args,
Path project_root )
protected
Build argv for ``oct git commit``.

Note: ``--no-verify`` is intentionally omitted — bypassing hooks
is never permitted via MCP (design decision D-5B-6).

Definition at line 283 of file executor.py.

◆ _build_argv_git_hooks_install()

list[str] oct.mcp.executor._build_argv_git_hooks_install ( dict args,
Path project_root )
protected
Build argv for ``oct git hooks install``.

Definition at line 298 of file executor.py.

◆ _build_argv_git_init()

list[str] oct.mcp.executor._build_argv_git_init ( dict args,
Path project_root )
protected
Build argv for ``oct git init``.

Definition at line 306 of file executor.py.

◆ _build_argv_git_status()

list[str] oct.mcp.executor._build_argv_git_status ( dict args,
Path project_root )
protected
Build argv for ``oct git status``.

Definition at line 157 of file executor.py.

◆ _build_argv_health()

list[str] oct.mcp.executor._build_argv_health ( dict args,
Path project_root )
protected
Build argv for ``oct health``.

Definition at line 83 of file executor.py.

◆ _build_argv_install_hooks()

list[str] oct.mcp.executor._build_argv_install_hooks ( dict args,
Path project_root )
protected
Build argv for ``oct install-hooks`` (deprecated; calls git hooks install).

Definition at line 275 of file executor.py.

◆ _build_argv_lint()

list[str] oct.mcp.executor._build_argv_lint ( dict args,
Path project_root )
protected
Build argv for ``oct lint``.

Definition at line 63 of file executor.py.

◆ _build_argv_new()

list[str] oct.mcp.executor._build_argv_new ( dict args,
Path project_root )
protected
Build argv for ``oct new``.

Definition at line 240 of file executor.py.

◆ _build_argv_scaffold()

list[str] oct.mcp.executor._build_argv_scaffold ( dict args,
Path project_root )
protected
Build argv for ``oct scaffold``.

Definition at line 255 of file executor.py.

◆ _build_argv_skeleton()

list[str] oct.mcp.executor._build_argv_skeleton ( dict args,
Path project_root )
protected
Build argv for ``oct export-skeleton``.

OI-502: no longer emits ``--output-dir``; that flag is not accepted
by the CLI. The output destination is derived by the CLI from the
project root.

Definition at line 93 of file executor.py.

◆ _build_argv_test()

list[str] oct.mcp.executor._build_argv_test ( dict args,
Path project_root )
protected
Build argv for ``oct test``.

OI-502: no longer emits ``--jobs``; the CLI does not accept it and
the ``jobs`` field was removed from :class:`OctTestArgs`.

Definition at line 119 of file executor.py.

◆ _build_argv_typecheck()

list[str] oct.mcp.executor._build_argv_typecheck ( dict args,
Path project_root )
protected
Build argv for ``oct typecheck``.

Definition at line 135 of file executor.py.

◆ _dbg()

None oct.mcp.executor._dbg ( * args,
** kwargs )
protected

Definition at line 49 of file executor.py.

Here is the caller graph for this function:

Variable Documentation

◆ _ARGV_BUILDERS

dict oct.mcp.executor._ARGV_BUILDERS
protected
Initial value:
1= {
2 # Phase 5A — read-only
3 "oct_lint": _build_argv_lint,
4 "oct_health": _build_argv_health,
5 "oct_skeleton": _build_argv_skeleton,
6 "oct_deps": _build_argv_deps,
7 "oct_test": _build_argv_test,
8 "oct_typecheck": _build_argv_typecheck,
9 "oct_diag": _build_argv_diag,
10 "oct_git_status": _build_argv_git_status,
11 "oct_git_check": _build_argv_git_check,
12 # Phase 5B — write tools
13 "oct_format": _build_argv_format,
14 "oct_docs": _build_argv_docs,
15 "oct_export_source": _build_argv_export_source,
16 "oct_new": _build_argv_new,
17 "oct_scaffold": _build_argv_scaffold,
18 "oct_clean": _build_argv_clean,
19 "oct_install_hooks": _build_argv_install_hooks,
20 "oct_git_commit": _build_argv_git_commit,
21 "oct_git_hooks_install": _build_argv_git_hooks_install,
22 "oct_git_init": _build_argv_git_init,
23 "oct_git_changelog": _build_argv_git_changelog,
24}

Definition at line 338 of file executor.py.