# lee-to/ai-factory architecture

> Architecture diagram of the GitHub repository lee-to/ai-factory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lee-to/ai-factory
- Repository: https://github.com/lee-to/ai-factory

## Overview

AI Factory is a CLI for configuring AI coding agents with skills, integrations, and agent-specific files. The main setup flow begins with `init`, gathers agent and skill choices, then installs and transforms assets, writes project configuration, and configures MCP servers. Update and upgrade maintain existing installations; extension commands manage add-on assets. The README also describes a broad bundled skill workflow. Source excerpts support many setup and extension relationships, but not the internal execution of individual skills.

Main entry points: [`src/cli/commands/init.ts`](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/init.ts) (Initialize project), [`src/core/installer.ts`](https://github.com/lee-to/ai-factory/blob/2.x/src/core/installer.ts) (Asset installer), [`src/cli/index.ts`](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/index.ts) (CLI router), [`src/cli/commands/upgrade.ts`](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/upgrade.ts) (Upgrade installation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and Setup"]
  node_cli["CLI router<br/>[index.ts]"]
  node_wizard["Setup prompts<br/>[prompts.ts]"]
  node_init["Initialize project<br/>[init.ts]"]
  node_update["Update installation<br/>[update.ts]"]
  node_upgrade["Upgrade installation<br/>[upgrade.ts]"]
  node_audit["Audit artifacts<br/>[audit-artifacts.ts]"]
  node_extensioncmd["Extension commands<br/>[extension.ts]"]
end

subgraph group_runtime["Agent Runtime"]
  node_config["Project configuration<br/>[config.ts]"]
  node_agents["Agent registry<br/>[agents.ts]"]
  node_transform["Agent transformers<br/>[transformer.ts]"]
  node_antigravity["Antigravity adapter<br/>[antigravity.ts]"]
end

subgraph group_assets["Skills and Migration"]
  node_installer["Asset installer<br/>[installer.ts]"]
  node_targets["Skill target resolver<br/>[skill-targets.ts]"]
  node_migration["Skill migration"]
  node_bundledskills["Bundled skills"]
end

subgraph group_extensions["Extensions and Integrations"]
  node_extensions["Extension resolver<br/>[extensions.ts]"]
  node_extensionops["Extension operations<br/>[extension-ops.ts]"]
  node_injections["Skill injections<br/>[injections.ts]"]
  node_mcp["MCP configuration<br/>[mcp.ts]"]
end

node_user(("Project developer"))
node_mcpservers{{"MCP servers"}}
node_filesystem[("Project files")]

node_user -->|"runs commands"| node_cli
node_cli -->|"routes init"| node_init
node_cli -->|"routes update"| node_update
node_cli -->|"routes upgrade"| node_upgrade
node_cli -->|"routes audit"| node_audit
node_cli -->|"routes extensions"| node_extensioncmd
node_init -->|"prompts choices"| node_wizard
node_init -->|"installs assets"| node_installer
node_init -->|"loads and saves"| node_config
node_init -->|"configures servers"| node_mcp
node_init -->|"resolves agents"| node_agents
node_init -->|"transforms assets"| node_transform
node_update -->|"loads settings"| node_config
node_update -->|"updates assets"| node_installer
node_upgrade -->|"recovers migration"| node_migration
node_upgrade -->|"renders assets"| node_installer
node_upgrade -->|"loads settings"| node_config
node_upgrade -->|"checks workflows"| node_antigravity
node_installer -->|"renders for targets"| node_targets
node_installer -->|"transforms content"| node_transform
node_installer -.->|"installs skills"| node_bundledskills
node_config -->|"resolves agent config"| node_agents
node_config -->|"loads extensions"| node_extensions
node_agents -->|"hydrates runtimes"| node_extensions
node_transform -->|"selects adapter"| node_antigravity
node_extensioncmd -->|"manages assets"| node_extensionops
node_extensioncmd -->|"loads manifests"| node_extensions
node_extensionops -->|"resolves destinations"| node_targets
node_extensionops -->|"applies injections"| node_injections
node_extensionops -->|"removes server entries"| node_mcp
node_extensions -.->|"reads extension data"| node_filesystem
node_mcp -->|"writes settings"| node_filesystem
node_mcp -->|"configures servers"| node_mcpservers
node_migration -->|"renders skill state"| node_installer
node_init -->|"prepares skill targets"| node_migration

click node_cli "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/index.ts"
click node_wizard "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/wizard/prompts.ts"
click node_init "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/init.ts"
click node_update "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/update.ts"
click node_upgrade "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/upgrade.ts"
click node_audit "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/audit-artifacts.ts"
click node_extensioncmd "https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/extension.ts"
click node_config "https://github.com/lee-to/ai-factory/blob/2.x/src/core/config.ts"
click node_agents "https://github.com/lee-to/ai-factory/blob/2.x/src/core/agents.ts"
click node_transform "https://github.com/lee-to/ai-factory/blob/2.x/src/core/transformer.ts"
click node_antigravity "https://github.com/lee-to/ai-factory/blob/2.x/src/core/transformers/antigravity.ts"
click node_installer "https://github.com/lee-to/ai-factory/blob/2.x/src/core/installer.ts"
click node_targets "https://github.com/lee-to/ai-factory/blob/2.x/src/core/skill-targets.ts"
click node_migration "https://github.com/lee-to/ai-factory/blob/2.x/src/core/skills-migration.ts"
click node_bundledskills "https://github.com/lee-to/ai-factory/tree/2.x/skills"
click node_extensions "https://github.com/lee-to/ai-factory/blob/2.x/src/core/extensions.ts"
click node_extensionops "https://github.com/lee-to/ai-factory/blob/2.x/src/core/extension-ops.ts"
click node_injections "https://github.com/lee-to/ai-factory/blob/2.x/src/core/injections.ts"
click node_mcp "https://github.com/lee-to/ai-factory/blob/2.x/src/core/mcp.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_cli,node_wizard,node_init,node_update,node_upgrade,node_audit,node_extensioncmd toneBlue
class node_config,node_agents,node_transform,node_antigravity,node_filesystem toneAmber
class node_installer,node_targets,node_migration,node_bundledskills,node_mcpservers toneMint
class node_extensions,node_extensionops,node_injections,node_mcp toneRose
class node_user toneIndigo
```

## Components

### CLI and Setup

- [CLI router](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/index.ts): `src/cli/index.ts`
- [Setup prompts](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/wizard/prompts.ts): `src/cli/wizard/prompts.ts`
- [Initialize project](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/init.ts): `src/cli/commands/init.ts`
- [Update installation](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/update.ts): `src/cli/commands/update.ts`
- [Upgrade installation](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/upgrade.ts): `src/cli/commands/upgrade.ts`
- [Audit artifacts](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/audit-artifacts.ts): `src/cli/commands/audit-artifacts.ts`
- [Extension commands](https://github.com/lee-to/ai-factory/blob/2.x/src/cli/commands/extension.ts): `src/cli/commands/extension.ts`

### Agent Runtime

- [Project configuration](https://github.com/lee-to/ai-factory/blob/2.x/src/core/config.ts): `src/core/config.ts`
- [Agent registry](https://github.com/lee-to/ai-factory/blob/2.x/src/core/agents.ts): `src/core/agents.ts`
- [Agent transformers](https://github.com/lee-to/ai-factory/blob/2.x/src/core/transformer.ts): `src/core/transformer.ts`
- [Antigravity adapter](https://github.com/lee-to/ai-factory/blob/2.x/src/core/transformers/antigravity.ts): `src/core/transformers/antigravity.ts`

### Skills and Migration

- [Asset installer](https://github.com/lee-to/ai-factory/blob/2.x/src/core/installer.ts): `src/core/installer.ts`
- [Skill target resolver](https://github.com/lee-to/ai-factory/blob/2.x/src/core/skill-targets.ts): `src/core/skill-targets.ts`
- [Skill migration](https://github.com/lee-to/ai-factory/blob/2.x/src/core/skills-migration.ts): `src/core/skills-migration.ts`
- [Bundled skills](https://github.com/lee-to/ai-factory/tree/2.x/skills): `skills`

### Extensions and Integrations

- [Extension resolver](https://github.com/lee-to/ai-factory/blob/2.x/src/core/extensions.ts): `src/core/extensions.ts`
- [Extension operations](https://github.com/lee-to/ai-factory/blob/2.x/src/core/extension-ops.ts): `src/core/extension-ops.ts`
- [Skill injections](https://github.com/lee-to/ai-factory/blob/2.x/src/core/injections.ts): `src/core/injections.ts`
- [MCP configuration](https://github.com/lee-to/ai-factory/blob/2.x/src/core/mcp.ts): `src/core/mcp.ts`

### Other components

- **Project developer**
- **MCP servers**
- **Project files**

## Connections

- Project developer → CLI router: runs commands (evidence: `README.md`)
- CLI router → Initialize project: routes init (evidence: `src/cli/index.ts`)
- CLI router → Update installation: routes update (evidence: `src/cli/index.ts`)
- CLI router → Upgrade installation: routes upgrade (evidence: `src/cli/index.ts`)
- CLI router → Audit artifacts: routes audit (evidence: `src/cli/index.ts`)
- CLI router → Extension commands: routes extensions (evidence: `src/cli/index.ts`)
- Initialize project → Setup prompts: prompts choices (evidence: `src/cli/commands/init.ts`)
- Initialize project → Asset installer: installs assets (evidence: `src/cli/commands/init.ts`)
- Initialize project → Project configuration: loads and saves (evidence: `src/cli/commands/init.ts`)
- Initialize project → MCP configuration: configures servers (evidence: `src/cli/commands/init.ts`)
- Initialize project → Agent registry: resolves agents (evidence: `src/cli/commands/init.ts`)
- Initialize project → Agent transformers: transforms assets (evidence: `src/cli/commands/init.ts`)
- Update installation → Project configuration: loads settings (evidence: `src/cli/commands/update.ts`)
- Update installation → Asset installer: updates assets (evidence: `src/cli/commands/update.ts`)
- Upgrade installation → Skill migration: recovers migration (evidence: `src/cli/commands/upgrade.ts`)
- Upgrade installation → Asset installer: renders assets (evidence: `src/cli/commands/upgrade.ts`)
- Upgrade installation → Project configuration: loads settings (evidence: `src/cli/commands/upgrade.ts`)
- Upgrade installation → Antigravity adapter: checks workflows (evidence: `src/cli/commands/upgrade.ts`)
- Asset installer → Skill target resolver: renders for targets (evidence: `src/core/installer.ts`)
- Asset installer → Agent transformers: transforms content (evidence: `src/core/installer.ts`)
- Asset installer → Bundled skills: installs skills (evidence: `README.md`)
- Project configuration → Agent registry: resolves agent config (evidence: `src/core/config.ts`)
- Project configuration → Extension resolver: loads extensions (evidence: `src/core/config.ts`)
- Agent registry → Extension resolver: hydrates runtimes (evidence: `src/core/agents.ts`)
- Agent transformers → Antigravity adapter: selects adapter (evidence: `src/core/transformer.ts`)
- Extension commands → Extension operations: manages assets (evidence: `src/cli/commands/extension.ts`)
- Extension commands → Extension resolver: loads manifests (evidence: `src/cli/commands/extension.ts`)
- Extension operations → Skill target resolver: resolves destinations (evidence: `src/core/extension-ops.ts`)
- Extension operations → Skill injections: applies injections (evidence: `src/core/extension-ops.ts`)
- Extension operations → MCP configuration: removes server entries (evidence: `src/core/extension-ops.ts`)
- Extension resolver → Project files: reads extension data
- MCP configuration → Project files: writes settings (evidence: `src/core/mcp.ts`)
- MCP configuration → MCP servers: configures servers (evidence: `README.md`)
- Skill migration → Asset installer: renders skill state (evidence: `src/core/skills-migration.ts`)
- Initialize project → Skill migration: prepares skill targets (evidence: `src/cli/commands/init.ts`)
