The src/ directory contains a Python workspace that serves as a parity audit tool. It does not implement a working agent — instead, it tracks how much of the original TypeScript Claude Code surface has been ported to Rust.
The Python workspace:
- Loads JSON snapshots of the original TypeScript commands and tools (from
reference_data/) - Provides a CLI (
main.py) with 20+ subcommands for querying, routing, and simulating runtime behavior - Maps Python modules to their TypeScript counterparts via
parity_audit.py - Simulates runtime behavior —
PortRuntimecan route prompts, bootstrap sessions, and run multi-turn loops - Manages sessions —
QueryEnginePorthandles message submission, token tracking, compaction, and persistence
src/
├── main.py — CLI entrypoint (20+ subcommands)
├── runtime.py — PortRuntime: routing, session bootstrap, turn loops
├── query_engine.py — QueryEnginePort: message submission, streaming, compaction
├── models.py — Shared dataclasses (Subsystem, PortingModule, PermissionDenial)
├── permissions.py — ToolPermissionContext (deny lists, not escalation modes)
├── tools.py — Tool snapshot loading from JSON, filtering by permission
├── commands.py — Command snapshot loading from JSON
├── port_manifest.py — Python workspace manifest generation
├── parity_audit.py — Compare Python workspace against archived TS surface
├── context.py — PortContext: paths, file counts
├── transcript.py — TranscriptStore (append, compact, replay, flush)
├── session_store.py — StoredSession JSON persistence
├── execution_registry.py — MirroredCommand/MirroredTool execution wrappers
├── tool_pool.py — Assembles filtered tool pool
├── setup.py — WorkspaceSetup (platform, Python version)
├── system_init.py — Builds system init message
├── history.py — HistoryLog
├── bootstrap_graph.py — Bootstrap graph stages
├── command_graph.py — Command graph segmentation
├── remote_runtime.py — Remote/SSH/teleport mode simulation
├── direct_modes.py — Deep link and direct connect modes
├── reference_data/ — JSON snapshots of original TS surface
│ ├── tools_snapshot.json
│ ├── commands_snapshot.json
│ ├── archive_surface_snapshot.json
│ └── subsystems/ — Per-subsystem JSON (hooks.json, services.json, etc.)
└── <28 __init__.py stubs> — Placeholder packages for archived TS subsystems
The central orchestrator for the Python parity tracker:
route_prompt(prompt)— Fuzzy-matches user prompts against mirrored commands and toolsbootstrap_session(prompt)— Builds a fullRuntimeSessionwith context, routing, execution, and streamingrun_turn_loop(prompt, max_turns)— Multi-turn conversation loop with stop conditions
The session engine that tracks messages, usage, and compaction:
submit_message(prompt)— Process a message, track usage, returnTurnResultstream_submit_message(prompt)— Generator yieldingmessage_start,command_match,tool_match,message_delta,message_stopeventscompact_messages_if_needed()— Keeps only the last N messages (default:compact_after_turns=12)persist_session()— Saves session to.port_sessions/<id>.json
A different permission model than the Rust side — uses deny lists instead of escalation modes:
@dataclass(frozen=True)
class ToolPermissionContext:
deny_names: frozenset[str] = field(default_factory=frozenset)
deny_prefixes: tuple[str, ...] = ()
def blocks(self, tool_name: str) -> bool:
lowered = tool_name.lower()
return lowered in self.deny_names or any(
lowered.startswith(prefix) for prefix in self.deny_prefixes
)The Python workspace is a planning and tracking tool for the Rust implementation. It answers questions like:
- Which TypeScript commands have Rust equivalents?
- Which tools are missing from the Rust port?
- What runtime behaviors still need to be implemented?
The compat-harness Rust crate works with the Python workspace by extracting upstream manifests.
::: warning Important
The Python code does not make real API calls to Anthropic or execute real tools. It simulates runtime behavior using mirrored metadata from JSON snapshots. The actual working agent is the Rust implementation in rust/crates/.
:::
If you want to use claw-code as an agent, look at the Rust crates — specifically the claw binary in rusty-claude-cli.