# songf0140/starrylin architecture

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

- Interactive diagram: https://gitdiagram.com/songf0140/starrylin
- Repository: https://github.com/songf0140/starrylin

## Overview

Pi is an extensible coding-agent harness. A user starts it interactively or in an automated mode; the agent processes a task through its session runtime and tools, using configured models, then presents or emits the result. The repository also documents RPC and SDK usage, plus extensions, skills, prompt templates, and themes. The map combines those documented capabilities with sampled entry-point references; several subsystem internals were not sampled, so their connections are omitted rather than inferred.

Main entry points: [`packages/coding-agent/src/main.ts`](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/main.ts) (CLI entry), [`packages/coding-agent/src/core/model-runtime.ts`](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/model-runtime.ts) (Model runtime), [`packages/coding-agent/src/modes/interactive/interactive-mode.ts`](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/interactive/interactive-mode.ts) (Interactive UI), [`packages/coding-agent/src/core/agent-session.ts`](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/agent-session.ts) (Agent session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and interaction"]
  node_entry["CLI entry<br/>[main.ts]"]
  node_interactive["Interactive UI"]
  node_automation["Print and JSON modes"]
  node_rpc["RPC mode<br/>[rpc-client.ts]"]
end

subgraph group_runtime["Agent runtime"]
  node_session["Agent session<br/>[agent-session.ts]"]
  node_tools["Built-in tools"]
  node_sessions["Session management<br/>[session-manager.ts]"]
  node_sdk["TypeScript SDK<br/>[sdk.ts]"]
  node_settings[("Settings")]
end

subgraph group_custom["Customization"]
  node_extensions["Extensions"]
  node_skills["Skills<br/>[skills.ts]"]
  node_prompts["Prompt templates"]
  node_themes["Themes"]
end

subgraph group_models["Models and credentials"]
  node_modelruntime["Model runtime<br/>[model-runtime.ts]"]
  node_resolver["Model resolver<br/>[model-resolver.ts]"]
  node_auth[("Credential storage<br/>[auth-storage.ts]")]
  node_ai["Provider API"]
end

node_user(("User or caller"))
node_result["Agent result"]

node_user -->|"starts"| node_entry
node_entry -->|"runs interactively"| node_interactive
node_entry -->|"runs automated"| node_automation
node_entry -->|"offers RPC"| node_rpc
node_entry -->|"initializes"| node_session
node_interactive -.->|"presents"| node_result
node_automation -->|"emits"| node_result
node_rpc -.->|"returns"| node_result
node_session -.->|"invokes"| node_tools
node_entry -->|"uses"| node_sessions
node_entry -->|"exposes"| node_sdk
node_entry -.->|"loads"| node_extensions
node_entry -->|"supports"| node_skills
node_entry -->|"supports"| node_prompts
node_interactive -.->|"uses"| node_themes
node_session -.->|"requests models"| node_modelruntime
node_modelruntime -.->|"resolves"| node_resolver
node_modelruntime -.->|"reads credentials"| node_auth
node_modelruntime -.->|"calls providers"| node_ai
node_entry -.->|"configures"| node_settings

click node_entry "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/main.ts"
click node_interactive "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/interactive/interactive-mode.ts"
click node_automation "https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/cli"
click node_rpc "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/rpc/rpc-client.ts"
click node_session "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/agent-session.ts"
click node_tools "https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/core/tools"
click node_sessions "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/session-manager.ts"
click node_sdk "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/sdk.ts"
click node_extensions "https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/core/extensions"
click node_skills "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/skills.ts"
click node_prompts "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/prompt-templates.ts"
click node_themes "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/interactive/theme/theme-controller.ts"
click node_modelruntime "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/model-runtime.ts"
click node_resolver "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/model-resolver.ts"
click node_auth "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/auth-storage.ts"
click node_ai "https://github.com/songf0140/starrylin/tree/main/packages/ai/src"
click node_settings "https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/settings-manager.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_entry,node_interactive,node_automation,node_rpc,node_user toneBlue
class node_session,node_tools,node_sessions,node_sdk,node_settings toneAmber
class node_extensions,node_skills,node_prompts,node_themes toneMint
class node_modelruntime,node_resolver,node_auth,node_ai toneRose
class node_result toneIndigo
```

## Components

### CLI and interaction

- [CLI entry](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/main.ts): `packages/coding-agent/src/main.ts`
- [Interactive UI](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/interactive/interactive-mode.ts): `packages/coding-agent/src/modes/interactive/interactive-mode.ts`
- [Print and JSON modes](https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/cli): `packages/coding-agent/src/cli`
- [RPC mode](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/rpc/rpc-client.ts): `packages/coding-agent/src/modes/rpc/rpc-client.ts`

### Agent runtime

- [Agent session](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/agent-session.ts): `packages/coding-agent/src/core/agent-session.ts`
- [Built-in tools](https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/core/tools): `packages/coding-agent/src/core/tools`
- [Session management](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/session-manager.ts): `packages/coding-agent/src/core/session-manager.ts`
- [TypeScript SDK](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/sdk.ts): `packages/coding-agent/src/core/sdk.ts`
- [Settings](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/settings-manager.ts): `packages/coding-agent/src/core/settings-manager.ts`

### Customization

- [Extensions](https://github.com/songf0140/starrylin/tree/main/packages/coding-agent/src/core/extensions): `packages/coding-agent/src/core/extensions`
- [Skills](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/skills.ts): `packages/coding-agent/src/core/skills.ts`
- [Prompt templates](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/prompt-templates.ts): `packages/coding-agent/src/core/prompt-templates.ts`
- [Themes](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/modes/interactive/theme/theme-controller.ts): `packages/coding-agent/src/modes/interactive/theme/theme-controller.ts`

### Models and credentials

- [Model runtime](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/model-runtime.ts): `packages/coding-agent/src/core/model-runtime.ts`
- [Model resolver](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/model-resolver.ts): `packages/coding-agent/src/core/model-resolver.ts`
- [Credential storage](https://github.com/songf0140/starrylin/blob/main/packages/coding-agent/src/core/auth-storage.ts): `packages/coding-agent/src/core/auth-storage.ts`
- [Provider API](https://github.com/songf0140/starrylin/tree/main/packages/ai/src): `packages/ai/src`

### Other components

- **User or caller**
- **Agent result**

## Connections

- User or caller → CLI entry: starts (evidence: `README.md`)
- CLI entry → Interactive UI: runs interactively (evidence: `README.md`)
- CLI entry → Print and JSON modes: runs automated (evidence: `README.md`)
- CLI entry → RPC mode: offers RPC (evidence: `README.md`)
- CLI entry → Agent session: initializes (evidence: `packages/coding-agent/src/main.ts`)
- Interactive UI → Agent result: presents
- Print and JSON modes → Agent result: emits (evidence: `README.md`)
- RPC mode → Agent result: returns
- Agent session → Built-in tools: invokes
- CLI entry → Session management: uses (evidence: `packages/coding-agent/src/main.ts`)
- CLI entry → TypeScript SDK: exposes (evidence: `README.md`)
- CLI entry → Extensions: loads (evidence: `packages/coding-agent/src/main.ts`)
- CLI entry → Skills: supports (evidence: `README.md`)
- CLI entry → Prompt templates: supports (evidence: `README.md`)
- Interactive UI → Themes: uses
- Agent session → Model runtime: requests models
- Model runtime → Model resolver: resolves
- Model runtime → Credential storage: reads credentials (evidence: `packages/coding-agent/src/core/model-runtime.ts`)
- Model runtime → Provider API: calls providers
- CLI entry → Settings: configures (evidence: `packages/coding-agent/src/main.ts`)
