# DvalinCode Architecture

Agentic coding CLI — TypeScript, zero runtime deps, provider-neutral

### Agent Engine

- • AgentLoop: 8-state turn-based state machine
- • AgentRunner: Tool-calling loop with maxIter guard
- • Session persistence in ~/.dvalincode/sessions/
- • Cross-session summary memory for context

### Provider Layer

- • ProviderAdapter interface for any LLM API
- • OpenAI-compatible: function_calling + @tool() text fallback
- • ProviderManager loads from env vars or config
- • Works with DeepSeek, OpenAI, Anthropic, etc.

### Tool System

- • 6 registered tools: read/write/execute
- • Zod-schematized inputs with runtime validation
- • Permission-gated: read/write/execute access levels
- • Diff preview on all write_file edits