# fisherk2/codice-opencode architecture

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

- Interactive diagram: https://gitdiagram.com/fisherk2/codice-opencode
- Repository: https://github.com/fisherk2/codice-opencode

## Overview

Códice is a CLI installer and updater for an OpenCode spec-driven development workspace. The principal workflow is to select an installation mode and content packs, classify template files, stage and atomically apply them, then perform shared post-install setup; update mode also checks workspace version state and can consult GitHub. The README documents the delivered skills, commands, agents, and technical references. Some template capabilities are represented at the template-directory level because their source files are not in the supplied tree excerpt; links are limited to source-index or README evidence.

Main entry points: [`src/application/use-cases/InstallUseCaseBase.ts`](https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/InstallUseCaseBase.ts) (Clean and project install), [`src/application/use-cases/UpdateWorkspaceUseCase.ts`](https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/UpdateWorkspaceUseCase.ts) (Workspace update), [`src/domain/services/FileMergeEngine.ts`](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/services/FileMergeEngine.ts) (Merge engine), [`src/cli/main.ts`](https://github.com/fisherk2/codice-opencode/blob/main/src/cli/main.ts) (Installer CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and interaction"]
  node_cli["Installer CLI<br/>[main.ts]"]
  node_prompt["Interactive prompts<br/>[IUserPrompt.ts]"]
end

subgraph group_application["Install workflows"]
  node_install["Clean and project install"]
  node_update["Workspace update"]
  node_postinstall["Post-install setup<br/>[postInstall.ts]"]
end

subgraph group_domain["Rules and merging"]
  node_manifest["Template rule manifest"]
  node_file_rule["File classification rules<br/>[FileRule.ts]"]
  node_merge["Merge engine<br/>[FileMergeEngine.ts]"]
  node_stage_plan["Stage planning<br/>[stagePlanner.ts]"]
  node_workspace_version["Workspace version state"]
end

subgraph group_runtime["Adapters and workspace"]
  node_filesystem["Bun filesystem<br/>[BunFileSystem.ts]"]
  node_stager["Atomic staging<br/>[AtomicStager.ts]"]
  node_symlinks["Symlink creation"]
  node_github["GitHub release API"]
  node_workspace_assets["Workspace assets"]
end

node_developer(("Developer"))
node_opencode(("OpenCode runtime"))

node_developer -->|"runs"| node_cli
node_cli -->|"requests choices"| node_prompt
node_cli -->|"dispatches install"| node_install
node_cli -->|"dispatches update"| node_update
node_install -->|"selects rules"| node_manifest
node_install -->|"executes merge"| node_merge
node_install -->|"runs after merge"| node_postinstall
node_update -->|"selects rules"| node_manifest
node_update -->|"executes merge"| node_merge
node_update -->|"checks version"| node_workspace_version
node_update -->|"checks release"| node_github
node_manifest -->|"defines classifications"| node_file_rule
node_merge -->|"computes plan"| node_stage_plan
node_merge -->|"stages and commits"| node_stager
node_merge -.->|"queries files"| node_filesystem
node_postinstall -->|"creates links"| node_symlinks
node_postinstall -->|"writes version"| node_filesystem
node_install -->|"installs workspace"| node_workspace_assets
node_workspace_assets -->|"provides native content"| node_opencode

click node_cli "https://github.com/fisherk2/codice-opencode/blob/main/src/cli/main.ts"
click node_prompt "https://github.com/fisherk2/codice-opencode/blob/main/src/application/ports/IUserPrompt.ts"
click node_install "https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/InstallUseCaseBase.ts"
click node_update "https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/UpdateWorkspaceUseCase.ts"
click node_postinstall "https://github.com/fisherk2/codice-opencode/blob/main/src/application/postInstall.ts"
click node_manifest "https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/FileRuleManifest.ts"
click node_file_rule "https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/FileRule.ts"
click node_merge "https://github.com/fisherk2/codice-opencode/blob/main/src/domain/services/FileMergeEngine.ts"
click node_stage_plan "https://github.com/fisherk2/codice-opencode/blob/main/src/domain/services/stagePlanner.ts"
click node_workspace_version "https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/WorkspaceVersion.ts"
click node_filesystem "https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/BunFileSystem.ts"
click node_stager "https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/AtomicStager.ts"
click node_symlinks "https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/BunSymlinkCreator.ts"
click node_github "https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/GitHubRestClient.ts"
click node_workspace_assets "https://github.com/fisherk2/codice-opencode/tree/main/template"

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_prompt toneBlue
class node_install,node_update,node_postinstall toneAmber
class node_manifest,node_file_rule,node_merge,node_stage_plan,node_workspace_version toneMint
class node_filesystem,node_stager,node_symlinks,node_github,node_workspace_assets toneRose
class node_developer,node_opencode toneIndigo
```

## Components

### CLI and interaction

- [Installer CLI](https://github.com/fisherk2/codice-opencode/blob/main/src/cli/main.ts): `src/cli/main.ts`
- [Interactive prompts](https://github.com/fisherk2/codice-opencode/blob/main/src/application/ports/IUserPrompt.ts): `src/application/ports/IUserPrompt.ts`

### Install workflows

- [Clean and project install](https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/InstallUseCaseBase.ts): `src/application/use-cases/InstallUseCaseBase.ts`
- [Workspace update](https://github.com/fisherk2/codice-opencode/blob/main/src/application/use-cases/UpdateWorkspaceUseCase.ts): `src/application/use-cases/UpdateWorkspaceUseCase.ts`
- [Post-install setup](https://github.com/fisherk2/codice-opencode/blob/main/src/application/postInstall.ts): `src/application/postInstall.ts`

### Rules and merging

- [Template rule manifest](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/FileRuleManifest.ts): `src/domain/entities/FileRuleManifest.ts`
- [File classification rules](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/FileRule.ts): `src/domain/entities/FileRule.ts`
- [Merge engine](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/services/FileMergeEngine.ts): `src/domain/services/FileMergeEngine.ts`
- [Stage planning](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/services/stagePlanner.ts): `src/domain/services/stagePlanner.ts`
- [Workspace version state](https://github.com/fisherk2/codice-opencode/blob/main/src/domain/entities/WorkspaceVersion.ts): `src/domain/entities/WorkspaceVersion.ts`

### Adapters and workspace

- [Bun filesystem](https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/BunFileSystem.ts): `src/infrastructure/adapters/BunFileSystem.ts`
- [Atomic staging](https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/AtomicStager.ts): `src/infrastructure/adapters/AtomicStager.ts`
- [Symlink creation](https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/BunSymlinkCreator.ts): `src/infrastructure/adapters/BunSymlinkCreator.ts`
- [GitHub release API](https://github.com/fisherk2/codice-opencode/blob/main/src/infrastructure/adapters/GitHubRestClient.ts): `src/infrastructure/adapters/GitHubRestClient.ts`
- [Workspace assets](https://github.com/fisherk2/codice-opencode/tree/main/template): `template`

### Other components

- **Developer**
- **OpenCode runtime**

## Connections

- Developer → Installer CLI: runs
- Installer CLI → Interactive prompts: requests choices (evidence: `src/cli/main.ts`)
- Installer CLI → Clean and project install: dispatches install (evidence: `src/cli/main.ts`)
- Installer CLI → Workspace update: dispatches update (evidence: `src/cli/main.ts`)
- Clean and project install → Template rule manifest: selects rules (evidence: `src/application/use-cases/InstallUseCaseBase.ts`)
- Clean and project install → Merge engine: executes merge (evidence: `src/application/use-cases/InstallUseCaseBase.ts`)
- Clean and project install → Post-install setup: runs after merge (evidence: `src/application/use-cases/InstallUseCaseBase.ts`)
- Workspace update → Template rule manifest: selects rules (evidence: `src/application/use-cases/UpdateWorkspaceUseCase.ts`)
- Workspace update → Merge engine: executes merge (evidence: `src/application/use-cases/UpdateWorkspaceUseCase.ts`)
- Workspace update → Workspace version state: checks version (evidence: `src/application/use-cases/UpdateWorkspaceUseCase.ts`)
- Workspace update → GitHub release API: checks release (evidence: `src/application/use-cases/UpdateWorkspaceUseCase.ts`)
- Template rule manifest → File classification rules: defines classifications (evidence: `src/domain/entities/FileRuleManifest.ts`)
- Merge engine → Stage planning: computes plan (evidence: `src/domain/services/FileMergeEngine.ts`)
- Merge engine → Atomic staging: stages and commits (evidence: `src/domain/services/FileMergeEngine.ts`)
- Merge engine → Bun filesystem: queries files
- Post-install setup → Symlink creation: creates links (evidence: `src/application/postInstall.ts`)
- Post-install setup → Bun filesystem: writes version (evidence: `src/application/postInstall.ts`)
- Clean and project install → Workspace assets: installs workspace
- Workspace assets → OpenCode runtime: provides native content
