# singhsanket143/windows-powershell-cli-agent---gpt---langgraph architecture

> Architecture diagram of the GitHub repository singhsanket143/windows-powershell-cli-agent---gpt---langgraph, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph
- Repository: https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph

## Overview

WinCliAgent turns a user's natural-language request into a Windows CLI command, screens it, optionally pauses for confirmation, and—if allowed—runs it and displays the result. The CLI owns interaction and resume behavior; the LangGraph definition owns stage dispatch, while node functions call the LLM, safety screen, and executor. Shared state carries the prompt, command, safety decision, and execution output. The README documents PowerShell compatibility across Windows and Docker; execution details are shown in the executor excerpt.

Main entry points: [`agent/nodes.py`](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/nodes.py) (Workflow nodes), [`main.py`](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/main.py) (CLI entry), [`agent/graph.py`](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/graph.py) (Graph orchestration), [`agent/state.py`](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/state.py) (Shared state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI interaction"]
  node_entry["CLI entry<br/>[main.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_graph["Graph orchestration<br/>[graph.py]"]
  node_state["Shared state<br/>[state.py]"]
  node_nodes["Workflow nodes<br/>[nodes.py]"]
end

subgraph group_services["Command services"]
  node_llm["Command generation<br/>[llm.py]"]
  node_safety["Safety screen<br/>[safety.py]"]
  node_executor["Command executor<br/>[executor.py]"]
end

node_user(("User"))
node_openai{{"OpenAI API"}}
node_shell{{"PowerShell or native shell"}}

node_user -->|"submits request"| node_entry
node_entry -->|"invokes and resumes"| node_graph
node_entry -->|"reads results"| node_state
node_entry -->|"shows command and output"| node_user
node_graph -->|"registers and dispatches"| node_nodes
node_graph -->|"configures graph state"| node_state
node_nodes -->|"reads and updates"| node_state
node_nodes -->|"generates command"| node_llm
node_llm -->|"requests completion"| node_openai
node_nodes -->|"screens command"| node_safety
node_nodes -->|"runs approved command"| node_executor
node_executor -->|"executes command"| node_shell

click node_entry "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/main.py"
click node_graph "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/graph.py"
click node_state "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/state.py"
click node_nodes "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/nodes.py"
click node_llm "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/llm.py"
click node_safety "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/safety.py"
click node_executor "https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/executor.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_user toneBlue
class node_graph,node_state,node_nodes toneAmber
class node_llm,node_safety,node_executor,node_openai toneMint
class node_shell toneIndigo
```

## Components

### CLI interaction

- [CLI entry](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/main.py): `main.py`

### Agent workflow

- [Graph orchestration](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/graph.py): `agent/graph.py`
- [Shared state](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/state.py): `agent/state.py`
- [Workflow nodes](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/nodes.py): `agent/nodes.py`

### Command services

- [Command generation](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/llm.py): `agent/llm.py`
- [Safety screen](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/safety.py): `agent/safety.py`
- [Command executor](https://github.com/singhsanket143/windows-powershell-cli-agent---gpt---langgraph/blob/main/agent/executor.py): `agent/executor.py`

### Other components

- **User**
- **OpenAI API**
- **PowerShell or native shell**

## Connections

- User → CLI entry: submits request (evidence: `README.md`)
- CLI entry → Graph orchestration: invokes and resumes (evidence: `main.py`)
- CLI entry → Shared state: reads results (evidence: `main.py`)
- CLI entry → User: shows command and output (evidence: `main.py`)
- Graph orchestration → Workflow nodes: registers and dispatches (evidence: `agent/graph.py`)
- Graph orchestration → Shared state: configures graph state (evidence: `agent/graph.py`)
- Workflow nodes → Shared state: reads and updates (evidence: `agent/nodes.py`)
- Workflow nodes → Command generation: generates command (evidence: `agent/nodes.py`)
- Command generation → OpenAI API: requests completion (evidence: `agent/llm.py`)
- Workflow nodes → Safety screen: screens command (evidence: `agent/nodes.py`)
- Workflow nodes → Command executor: runs approved command (evidence: `agent/nodes.py`)
- Command executor → PowerShell or native shell: executes command (evidence: `agent/executor.py`)
