# thieung/agentkit-helper architecture

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

- Interactive diagram: https://gitdiagram.com/thieung/agentkit-helper
- Repository: https://github.com/thieung/agentkit-helper

## Overview

#### Purpose and execution entry points
AgentKit Helper is a Node.js 20.12+ terminal UI and CLI wrapper for the external `ak` CLI. It guides Kit install/update choices, renders the resulting official command, and executes it. Package execution starts at `bin/agentkit-helper.mjs`; command-line parsing and dispatch are centered in `lib/args.mjs` and `lib/commands.mjs`.

#### CLI/TUI orchestration
The application supports interactive selection plus explicit commands such as install, update, update-all, and self-update. `lib/commands.mjs` maps validated user intent to command workflows, while `lib/navigation.mjs` and `lib/prompts.mjs` implement multi-step terminal interaction, selection, confirmation, and back-navigation. `lib/i18n.mjs` supplies localized UI text.

#### Input normalization and policy boundaries
Arguments, defaults, supported kits/runtimes, channels, project/global scope, and dry-run behavior are normalized before execution. `lib/args.mjs`, `lib/config.mjs`, and `lib/pi-profiles.mjs` define these boundaries. The helper owns command construction and consent UX; AgentKit’s `ak` process remains responsible for Kit verification, ownership, snapshots, and runtime-specific files.

#### Project and installation discovery
The helper determines whether the current location is a valid project target, avoids unsafe locations such as filesystem root or the user home directory, and discovers existing installs for update-oriented flows. This is handled by `lib/project.mjs` and `lib/discovery.mjs`. Project paths and global/runtime scopes feed the same later command-generation path.

#### External process execution
`lib/runner.mjs` is the system boundary for invoking `ak`, including platform-oriented command handling and output/status propagation. The application first detects the required binary, then runs generated commands. Node.js is the primary runtime; `ak` is the required external service/CLI dependency. Portable Node execution targets macOS and Linux, while native Windows PowerShell support is experimental.

#### Safety and update behavior
Global installation is intentionally two-phase: run without `--force`, surface collisions or drift, then retry with force only after explicit opt-in. Global update preserves user changes and never forces replacement. Command preview/dry-run behavior is routed through the command and runner layers: `lib/commands.mjs` and `lib/runner.mjs`.

#### Auxiliary integrations and distribution
Self-updating the signed `ak` binary is a distinct workflow in `lib/self-update.mjs`. GitHub issue integration is isolated in `lib/github-issue.mjs`, keeping remote issue/reporting concerns out of installation execution. The package is distributed through npm with executable wiring in `bin/agentkit-helper.mjs`; CI is defined in `.github/workflows/ci.yml`.

Main entry points: [`lib/commands.mjs`](https://github.com/thieung/agentkit-helper/blob/main/lib/commands.mjs) (Command workflows), [`lib/runner.mjs`](https://github.com/thieung/agentkit-helper/blob/main/lib/runner.mjs) (ak process runner), [`bin/agentkit-helper.mjs`](https://github.com/thieung/agentkit-helper/blob/main/bin/agentkit-helper.mjs) (Executable entry), [`lib/args.mjs`](https://github.com/thieung/agentkit-helper/blob/main/lib/args.mjs) (Argument parsing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI Entry"]
  node_bin["Executable entry<br/>Node CLI"]
  node_args["Argument parsing<br/>CLI parser<br/>[args.mjs]"]
end

subgraph group_interaction["Interaction &amp; Policy"]
  node_commands["Command workflows<br/>orchestrator<br/>[commands.mjs]"]
  node_navigation["Terminal navigation<br/>TUI flow<br/>[navigation.mjs]"]
  node_prompts["Prompts &amp; consent<br/>TUI input<br/>[prompts.mjs]"]
  node_i18n["Localized UI text<br/>i18n<br/>[i18n.mjs]"]
  node_config["Install policy config<br/>[config.mjs]"]
  node_profiles["PI profiles<br/>profile policy<br/>[pi-profiles.mjs]"]
end

subgraph group_targeting["Target Discovery"]
  node_project["Project validation<br/>target guard<br/>[project.mjs]"]
  node_discovery["Installation discovery<br/>scanner<br/>[discovery.mjs]"]
end

subgraph group_execution["Command Execution"]
  node_runner{{"ak process runner<br/>process boundary<br/>[runner.mjs]"}}
  node_ak["External ak CLI<br/>external dependency"]
end

subgraph group_integrations["Auxiliary Workflows"]
  node_selfupdate["ak self-update<br/>update workflow<br/>[self-update.mjs]"]
  node_github["GitHub issue integration<br/>remote integration<br/>[github-issue.mjs]"]
  node_ci["CI pipeline<br/>automation<br/>[ci.yml]"]
end

node_bin -->|"starts"| node_args
node_args -->|"validated intent"| node_commands
node_commands -->|"interactive flow"| node_navigation
node_navigation -->|"selection and confirmation"| node_prompts
node_prompts -->|"UI text"| node_i18n
node_commands -->|"normalizes policy"| node_config
node_commands -->|"applies profiles"| node_profiles
node_commands -->|"validates project scope"| node_project
node_commands -->|"finds existing installs"| node_discovery
node_commands -->|"previews or executes ak command"| node_runner
node_runner -->|"detects and invokes"| node_ak
node_commands -->|"routes self-update"| node_selfupdate
node_selfupdate -->|"runs update process"| node_runner
node_commands -.->|"routes issue reporting"| node_github
node_ci -.->|"validates package entry"| node_bin

click node_bin "https://github.com/thieung/agentkit-helper/blob/main/bin/agentkit-helper.mjs"
click node_args "https://github.com/thieung/agentkit-helper/blob/main/lib/args.mjs"
click node_commands "https://github.com/thieung/agentkit-helper/blob/main/lib/commands.mjs"
click node_navigation "https://github.com/thieung/agentkit-helper/blob/main/lib/navigation.mjs"
click node_prompts "https://github.com/thieung/agentkit-helper/blob/main/lib/prompts.mjs"
click node_i18n "https://github.com/thieung/agentkit-helper/blob/main/lib/i18n.mjs"
click node_config "https://github.com/thieung/agentkit-helper/blob/main/lib/config.mjs"
click node_profiles "https://github.com/thieung/agentkit-helper/blob/main/lib/pi-profiles.mjs"
click node_project "https://github.com/thieung/agentkit-helper/blob/main/lib/project.mjs"
click node_discovery "https://github.com/thieung/agentkit-helper/blob/main/lib/discovery.mjs"
click node_runner "https://github.com/thieung/agentkit-helper/blob/main/lib/runner.mjs"
click node_selfupdate "https://github.com/thieung/agentkit-helper/blob/main/lib/self-update.mjs"
click node_github "https://github.com/thieung/agentkit-helper/blob/main/lib/github-issue.mjs"
click node_ci "https://github.com/thieung/agentkit-helper/blob/main/.github/workflows/ci.yml"

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_bin,node_args toneBlue
class node_commands,node_navigation,node_prompts,node_i18n,node_config,node_profiles toneAmber
class node_project,node_discovery toneMint
class node_runner,node_ak toneRose
class node_selfupdate,node_github,node_ci toneIndigo
```

## Components

### CLI Entry

- [Executable entry](https://github.com/thieung/agentkit-helper/blob/main/bin/agentkit-helper.mjs): Node CLI · npm executable entry point. · `bin/agentkit-helper.mjs`
- [Argument parsing](https://github.com/thieung/agentkit-helper/blob/main/lib/args.mjs): CLI parser · Normalizes command-line intent and defaults. · `lib/args.mjs`

### Interaction & Policy

- [Command workflows](https://github.com/thieung/agentkit-helper/blob/main/lib/commands.mjs): orchestrator · Maps validated intent to install and update flows. · `lib/commands.mjs`
- [Terminal navigation](https://github.com/thieung/agentkit-helper/blob/main/lib/navigation.mjs): TUI flow · Provides multi-step selection and back-navigation. · `lib/navigation.mjs`
- [Prompts & consent](https://github.com/thieung/agentkit-helper/blob/main/lib/prompts.mjs): TUI input · Collects selections and explicit confirmations. · `lib/prompts.mjs`
- [Localized UI text](https://github.com/thieung/agentkit-helper/blob/main/lib/i18n.mjs): i18n · `lib/i18n.mjs`
- [Install policy config](https://github.com/thieung/agentkit-helper/blob/main/lib/config.mjs): policy · Defines supported kits, runtimes, channels, and scopes. · `lib/config.mjs`
- [PI profiles](https://github.com/thieung/agentkit-helper/blob/main/lib/pi-profiles.mjs): profile policy · `lib/pi-profiles.mjs`

### Target Discovery

- [Project validation](https://github.com/thieung/agentkit-helper/blob/main/lib/project.mjs): target guard · Rejects unsafe locations and validates project targets. · `lib/project.mjs`
- [Installation discovery](https://github.com/thieung/agentkit-helper/blob/main/lib/discovery.mjs): scanner · Finds existing installs for update-oriented flows. · `lib/discovery.mjs`

### Command Execution

- [ak process runner](https://github.com/thieung/agentkit-helper/blob/main/lib/runner.mjs): process boundary · Detects and invokes ak with platform-aware status propagation. · `lib/runner.mjs`
- **External ak CLI**: external dependency · Verifies Kits and manages ownership, snapshots, and runtime files.

### Auxiliary Workflows

- [ak self-update](https://github.com/thieung/agentkit-helper/blob/main/lib/self-update.mjs): update workflow · Updates the signed ak binary. · `lib/self-update.mjs`
- [GitHub issue integration](https://github.com/thieung/agentkit-helper/blob/main/lib/github-issue.mjs): remote integration · Keeps issue reporting separate from installation execution. · `lib/github-issue.mjs`
- [CI pipeline](https://github.com/thieung/agentkit-helper/blob/main/.github/workflows/ci.yml): automation · `.github/workflows/ci.yml`

## Connections

- Executable entry → Argument parsing: starts
- Argument parsing → Command workflows: validated intent
- Command workflows → Terminal navigation: interactive flow
- Terminal navigation → Prompts & consent: selection and confirmation
- Prompts & consent → Localized UI text: UI text
- Command workflows → Install policy config: normalizes policy
- Command workflows → PI profiles: applies profiles
- Command workflows → Project validation: validates project scope
- Command workflows → Installation discovery: finds existing installs
- Command workflows → ak process runner: previews or executes ak command
- ak process runner → External ak CLI: detects and invokes
- Command workflows → ak self-update: routes self-update
- ak self-update → ak process runner: runs update process
- Command workflows → GitHub issue integration: routes issue reporting
- CI pipeline → Executable entry: validates package entry
