# moffycream/kiro-chat architecture

> Architecture diagram of the GitHub repository moffycream/kiro-chat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moffycream/kiro-chat
- Repository: https://github.com/moffycream/kiro-chat

## Overview

Kiro Chat is a VS Code sidebar extension for chatting with the Kiro CLI agent. The principal workflow sends a user message and selected or attached workspace context from the webview through the provider and session to Kiro over ACP, then displays the reply and usage data. Other documented capabilities include session history and rewind, model and account usage controls, project memory and instructions, setup, and reviewed file edits. Some subsystem paths and wiring are inferred only from the tree and README, so uncertain links are omitted.

Main entry points: [`src/chatViewProvider.ts`](https://github.com/moffycream/kiro-chat/blob/main/src/chatViewProvider.ts) (Chat provider), [`src/kiroSession.ts`](https://github.com/moffycream/kiro-chat/blob/main/src/kiroSession.ts) (Session manager), [`media/chat.js`](https://github.com/moffycream/kiro-chat/blob/main/media/chat.js) (Chat webview), [`src/acpClient.ts`](https://github.com/moffycream/kiro-chat/blob/main/src/acpClient.ts) (ACP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Chat interface"]
  node_webview["Chat webview<br/>[chat.js]"]
end

subgraph group_control["Extension orchestration"]
  node_provider["Chat provider"]
  node_extension["Extension activation<br/>[extension.ts]"]
  node_setup["CLI setup detection<br/>[setupWatcher.ts]"]
end

subgraph group_agent["Kiro sessions"]
  node_session["Session manager<br/>[kiroSession.ts]"]
  node_acp["ACP client<br/>[acpClient.ts]"]
  node_history["Session history<br/>[history.ts]"]
  node_usage["Usage and models<br/>[usage.ts]"]
  node_saved["Saved context reading<br/>[savedContext.ts]"]
  node_locks["Session lock checks<br/>[sessionLocks.ts]"]
  node_sessionstore[("Kiro session files")]
end

subgraph group_features["Context and edits"]
  node_workspace["Workspace context<br/>[context.ts]"]
  node_active["Active file context<br/>[activeFile.ts]"]
  node_prompt["Prompt blocks<br/>[promptBlocks.ts]"]
  node_modes["Chat and edit modes<br/>[chatModes.ts]"]
  node_instructions["User instructions<br/>[instructions.ts]"]
  node_memory["Project memory<br/>[memory.ts]"]
  node_review["Change review<br/>[changeReviewer.ts]"]
  node_diff["Review diff<br/>[lineDiff.ts]"]
end

node_user(("VS Code user"))
node_kiro["Kiro CLI"]

node_user -->|"uses"| node_webview
node_webview -->|"sends actions"| node_provider
node_provider -->|"posts updates"| node_webview
node_extension -->|"registers view"| node_provider
node_provider -->|"sends turns"| node_session
node_provider -->|"collects context"| node_workspace
node_provider -->|"adds active file"| node_active
node_provider -->|"builds message blocks"| node_prompt
node_provider -->|"reads mode options"| node_modes
node_provider -->|"reads instructions"| node_instructions
node_provider -->|"manages memory"| node_memory
node_provider -->|"manages history"| node_history
node_session -->|"sends RPC"| node_acp
node_acp -->|"spawns and communicates"| node_kiro
node_kiro -->|"returns RPC events"| node_acp
node_session -->|"tracks turn edits"| node_review
node_review -->|"builds and applies diffs"| node_diff
node_provider -->|"parses usage reports"| node_usage
node_session -->|"parses model details"| node_usage
node_session -->|"reads saved context"| node_saved
node_saved -->|"reads session metadata"| node_sessionstore
node_session -->|"checks stale locks"| node_locks
node_locks -->|"reads lock files"| node_sessionstore
node_provider -->|"checks CLI readiness"| node_setup
node_setup -->|"probes CLI"| node_kiro

click node_webview "https://github.com/moffycream/kiro-chat/blob/main/media/chat.js"
click node_provider "https://github.com/moffycream/kiro-chat/blob/main/src/chatViewProvider.ts"
click node_extension "https://github.com/moffycream/kiro-chat/blob/main/src/extension.ts"
click node_session "https://github.com/moffycream/kiro-chat/blob/main/src/kiroSession.ts"
click node_acp "https://github.com/moffycream/kiro-chat/blob/main/src/acpClient.ts"
click node_workspace "https://github.com/moffycream/kiro-chat/blob/main/src/context.ts"
click node_active "https://github.com/moffycream/kiro-chat/blob/main/src/activeFile.ts"
click node_prompt "https://github.com/moffycream/kiro-chat/blob/main/src/promptBlocks.ts"
click node_modes "https://github.com/moffycream/kiro-chat/blob/main/src/chatModes.ts"
click node_instructions "https://github.com/moffycream/kiro-chat/blob/main/src/instructions.ts"
click node_memory "https://github.com/moffycream/kiro-chat/blob/main/src/memory.ts"
click node_history "https://github.com/moffycream/kiro-chat/blob/main/src/history.ts"
click node_review "https://github.com/moffycream/kiro-chat/blob/main/src/changeReviewer.ts"
click node_diff "https://github.com/moffycream/kiro-chat/blob/main/src/lineDiff.ts"
click node_usage "https://github.com/moffycream/kiro-chat/blob/main/src/usage.ts"
click node_saved "https://github.com/moffycream/kiro-chat/blob/main/src/savedContext.ts"
click node_locks "https://github.com/moffycream/kiro-chat/blob/main/src/sessionLocks.ts"
click node_setup "https://github.com/moffycream/kiro-chat/blob/main/src/setupWatcher.ts"

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_webview,node_user toneBlue
class node_provider,node_extension,node_setup toneAmber
class node_session,node_acp,node_history,node_usage,node_saved,node_locks,node_sessionstore toneMint
class node_workspace,node_active,node_prompt,node_modes,node_instructions,node_memory,node_review,node_diff toneRose
class node_kiro toneIndigo
```

## Components

### Chat interface

- [Chat webview](https://github.com/moffycream/kiro-chat/blob/main/media/chat.js): `media/chat.js`

### Extension orchestration

- [Chat provider](https://github.com/moffycream/kiro-chat/blob/main/src/chatViewProvider.ts): `src/chatViewProvider.ts`
- [Extension activation](https://github.com/moffycream/kiro-chat/blob/main/src/extension.ts): `src/extension.ts`
- [CLI setup detection](https://github.com/moffycream/kiro-chat/blob/main/src/setupWatcher.ts): `src/setupWatcher.ts`

### Kiro sessions

- [Session manager](https://github.com/moffycream/kiro-chat/blob/main/src/kiroSession.ts): `src/kiroSession.ts`
- [ACP client](https://github.com/moffycream/kiro-chat/blob/main/src/acpClient.ts): `src/acpClient.ts`
- [Session history](https://github.com/moffycream/kiro-chat/blob/main/src/history.ts): `src/history.ts`
- [Usage and models](https://github.com/moffycream/kiro-chat/blob/main/src/usage.ts): `src/usage.ts`
- [Saved context reading](https://github.com/moffycream/kiro-chat/blob/main/src/savedContext.ts): `src/savedContext.ts`
- [Session lock checks](https://github.com/moffycream/kiro-chat/blob/main/src/sessionLocks.ts): `src/sessionLocks.ts`
- **Kiro session files**

### Context and edits

- [Workspace context](https://github.com/moffycream/kiro-chat/blob/main/src/context.ts): `src/context.ts`
- [Active file context](https://github.com/moffycream/kiro-chat/blob/main/src/activeFile.ts): `src/activeFile.ts`
- [Prompt blocks](https://github.com/moffycream/kiro-chat/blob/main/src/promptBlocks.ts): `src/promptBlocks.ts`
- [Chat and edit modes](https://github.com/moffycream/kiro-chat/blob/main/src/chatModes.ts): `src/chatModes.ts`
- [User instructions](https://github.com/moffycream/kiro-chat/blob/main/src/instructions.ts): `src/instructions.ts`
- [Project memory](https://github.com/moffycream/kiro-chat/blob/main/src/memory.ts): `src/memory.ts`
- [Change review](https://github.com/moffycream/kiro-chat/blob/main/src/changeReviewer.ts): `src/changeReviewer.ts`
- [Review diff](https://github.com/moffycream/kiro-chat/blob/main/src/lineDiff.ts): `src/lineDiff.ts`

### Other components

- **VS Code user**
- **Kiro CLI**

## Connections

- VS Code user → Chat webview: uses
- Chat webview → Chat provider: sends actions
- Chat provider → Chat webview: posts updates
- Extension activation → Chat provider: registers view
- Chat provider → Session manager: sends turns
- Chat provider → Workspace context: collects context
- Chat provider → Active file context: adds active file
- Chat provider → Prompt blocks: builds message blocks
- Chat provider → Chat and edit modes: reads mode options
- Chat provider → User instructions: reads instructions
- Chat provider → Project memory: manages memory
- Chat provider → Session history: manages history
- Session manager → ACP client: sends RPC
- ACP client → Kiro CLI: spawns and communicates
- Kiro CLI → ACP client: returns RPC events
- Session manager → Change review: tracks turn edits
- Change review → Review diff: builds and applies diffs
- Chat provider → Usage and models: parses usage reports
- Session manager → Usage and models: parses model details
- Session manager → Saved context reading: reads saved context
- Saved context reading → Kiro session files: reads session metadata
- Session manager → Session lock checks: checks stale locks
- Session lock checks → Kiro session files: reads lock files
- Chat provider → CLI setup detection: checks CLI readiness
- CLI setup detection → Kiro CLI: probes CLI
