# mayur-panchal-2808/custom-cli architecture

> Architecture diagram of the GitHub repository mayur-panchal-2808/custom-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mayur-panchal-2808/custom-cli
- Repository: https://github.com/mayur-panchal-2808/custom-cli

## Overview

1. **What this repo is**
   - `ai-genx-cli-pro` is a Node.js command-line application, not a web service.
   - The architecture is centered on an interactive terminal UX that routes the user into one of several AI workflows: chat, code generation, tool-calling, and code editing.

2. **Entry points and packaging**
   - `index.js` is the main package entry.
   - `practice-cli.js` appears to be a secondary local runner or experiment entrypoint.
   - `package.json` and `.github/workflows/publish.yml` indicate this is published as an npm CLI package, with CI-driven release automation.

3. **Top-level orchestration layer**
   - `core/pipeline.js` is the main workflow coordinator.
   - `core/agentRunner.js` likely executes a chosen sequence of agents and manages the handoff between planning, analysis, execution, and review.
   - This layer is the boundary between the interactive CLI and the AI workflow internals.

4. **Agent architecture**
   - The `agents/` folder contains four specialized roles:
     - `planner.agent.js` for decomposing a task into steps
     - `analyzer.agent.js` for understanding or inspecting input/context
     - `executor.agent.js` for producing the actionable output
     - `reviewer.agent.js` for checking or refining results
   - This suggests a multi-stage pipeline rather than a single prompt/response call, especially for code generation and editing modes.

5. **Model/provider integration**
   - `services/openrouter.service.js` is the external AI API adapter.
   - It likely encapsulates request formatting, model selection, and response handling for OpenRouter-backed models such as Claude, GPT-4o, and Llama as described in the README.
   - Provider selection is user-configurable, so the architecture separates model access from the CLI logic.

6. **Authentication and configuration**
   - `auth/authManager.js` handles secure login/setup.
   - `config/configManager.js` manages persisted settings, including the global config mentioned in the README and per-project `.env` support.
   - The config layer is the main state boundary: API keys, provider choice, and default model are stored and retrieved here rather than embedded in the app.

7. **Tooling boundary for “tool calling” and editing**
   - `tools/fileTool.js` and `tools/terminalTool.js` expose real-world actions to the AI workflow.
   - `fileTool` is the filesystem boundary for reading/writing project files.
   - `terminalTool` is the shell boundary for executing commands.
   - These tools are what make the “tool calling” and “code editing” modes materially different from plain chat.

8. **Primary data flow**
   - User interaction starts in the CLI, then flows into the core pipeline.
   - The pipeline selects agents and, when needed, invokes tools or the model service.
   - Results flow back through the runner to the terminal, often with review or confirmation before changes are applied.

9. **Mode-specific behavior**
   - The README’s four modes imply distinct orchestration paths:
     - Chat: direct conversational response with session context
     - Code generation: agent-led scaffolding across files
     - Tool calling: AI decides when to invoke file/terminal capabilities
     - Code editing: file-aware changes with review/diff before apply
   - The shared core still appears to be the same agent/service/tool stack, configured differently per mode.

10. **External/runtime boundaries**
   - Runtime is Node.js 18+.
   - External dependencies are mainly AI APIs plus the local filesystem and terminal.
   - There is no evidence of a backend server, database, or browser app; all stateful behavior is local to the machine and config files.

11. **Operational boundary and distribution**
   - The repo is designed for global installation via npm or execution with `npx`.
   - The GitHub Actions publish workflow suggests releases are automated, making npm the main distribution channel.
   - From an architecture perspective, this is a self-contained CLI with small, well-separated modules: config/auth, orchestration, agents, provider service, and tools.

Main entry points: [`core/agentRunner.js`](https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/agentRunner.js) (Agent Runner), [`core/pipeline.js`](https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/pipeline.js) (Pipeline), [`config/configManager.js`](https://github.com/mayur-panchal-2808/custom-cli/blob/main/config/configManager.js) (Config Manager), [`package.json`](https://github.com/mayur-panchal-2808/custom-cli/blob/main/package.json) (package.json)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI Entry"]
  node_index_js["index.js<br/>entrypoint<br/>[index.js]"]
  node_practice_cli_js["practice-cli.js<br/>runner<br/>[practice-cli.js]"]
end

subgraph group_core["Orchestration"]
  node_pipeline_js["Pipeline<br/>orchestrator<br/>[pipeline.js]"]
  node_agent_runner_js["Agent Runner<br/>orchestrator<br/>[agentRunner.js]"]
end

subgraph group_agents["Agents"]
  node_planner_agent_js["Planner<br/>agent<br/>[planner.agent.js]"]
  node_analyzer_agent_js["Analyzer<br/>agent<br/>[analyzer.agent.js]"]
  node_executor_agent_js["Executor<br/>agent<br/>[executor.agent.js]"]
  node_reviewer_agent_js["Reviewer<br/>agent<br/>[reviewer.agent.js]"]
end

subgraph group_platform["Platform"]
  node_openrouter_service_js["OpenRouter<br/>provider adapter"]
  node_auth_manager_js["Auth Manager<br/>[authManager.js]"]
  node_config_manager_js["Config Manager<br/>state<br/>[configManager.js]"]
end

subgraph group_tools["Tools"]
  node_file_tool_js["File Tool<br/>filesystem tool<br/>[fileTool.js]"]
  node_terminal_tool_js["Terminal Tool<br/>shell tool<br/>[terminalTool.js]"]
end

subgraph group_release["Release"]
  node_package_json["package.json<br/>package metadata<br/>[package.json]"]
  node_publish_workflow["Publish CI<br/>release workflow<br/>[publish.yml]"]
end

node_index_js -->|"starts"| node_pipeline_js
node_practice_cli_js -->|"runs"| node_pipeline_js
node_pipeline_js -->|"dispatches"| node_agent_runner_js
node_agent_runner_js -->|"plans"| node_planner_agent_js
node_agent_runner_js -->|"analyzes"| node_analyzer_agent_js
node_agent_runner_js -->|"executes"| node_executor_agent_js
node_agent_runner_js -->|"reviews"| node_reviewer_agent_js
node_agent_runner_js -->|"calls"| node_openrouter_service_js
node_agent_runner_js -->|"uses"| node_file_tool_js
node_agent_runner_js -->|"uses"| node_terminal_tool_js
node_auth_manager_js -->|"stores"| node_config_manager_js
node_pipeline_js -->|"checks auth"| node_auth_manager_js
node_pipeline_js -->|"loads config"| node_config_manager_js
node_config_manager_js -->|"configures"| node_openrouter_service_js
node_package_json -->|"entry"| node_index_js
node_package_json -->|"publishes"| node_publish_workflow

click node_index_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/index.js"
click node_practice_cli_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/practice-cli.js"
click node_pipeline_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/pipeline.js"
click node_agent_runner_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/agentRunner.js"
click node_planner_agent_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/planner.agent.js"
click node_analyzer_agent_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/analyzer.agent.js"
click node_executor_agent_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/executor.agent.js"
click node_reviewer_agent_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/reviewer.agent.js"
click node_openrouter_service_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/services/openrouter.service.js"
click node_auth_manager_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/auth/authManager.js"
click node_config_manager_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/config/configManager.js"
click node_file_tool_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/tools/fileTool.js"
click node_terminal_tool_js "https://github.com/mayur-panchal-2808/custom-cli/blob/main/tools/terminalTool.js"
click node_package_json "https://github.com/mayur-panchal-2808/custom-cli/blob/main/package.json"
click node_publish_workflow "https://github.com/mayur-panchal-2808/custom-cli/blob/main/.github/workflows/publish.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_index_js,node_practice_cli_js toneBlue
class node_pipeline_js,node_agent_runner_js toneAmber
class node_planner_agent_js,node_analyzer_agent_js,node_executor_agent_js,node_reviewer_agent_js toneMint
class node_openrouter_service_js,node_auth_manager_js,node_config_manager_js toneRose
class node_file_tool_js,node_terminal_tool_js toneIndigo
class node_package_json,node_publish_workflow toneTeal
```

## Components

### CLI Entry

Package entrypoints and local runners.

- [index.js](https://github.com/mayur-panchal-2808/custom-cli/blob/main/index.js): entrypoint · Main CLI entrypoint. · `index.js`
- [practice-cli.js](https://github.com/mayur-panchal-2808/custom-cli/blob/main/practice-cli.js): runner · Secondary local runner or experiment entrypoint. · `practice-cli.js`

### Orchestration

Workflow coordination and agent execution.

- [Pipeline](https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/pipeline.js): orchestrator · Top-level workflow coordinator. · `core/pipeline.js`
- [Agent Runner](https://github.com/mayur-panchal-2808/custom-cli/blob/main/core/agentRunner.js): orchestrator · Runs the agent sequence and manages handoffs. · `core/agentRunner.js`

### Agents

Specialized planning, analysis, execution, and review roles.

- [Planner](https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/planner.agent.js): agent · Breaks tasks into steps. · `agents/planner.agent.js`
- [Analyzer](https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/analyzer.agent.js): agent · Inspects input and context. · `agents/analyzer.agent.js`
- [Executor](https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/executor.agent.js): agent · Produces actionable output. · `agents/executor.agent.js`
- [Reviewer](https://github.com/mayur-panchal-2808/custom-cli/blob/main/agents/reviewer.agent.js): agent · Checks and refines results. · `agents/reviewer.agent.js`

### Platform

Auth, config, and external AI provider integration.

- [OpenRouter](https://github.com/mayur-panchal-2808/custom-cli/blob/main/services/openrouter.service.js): provider adapter · External model API adapter and response handling. · `services/openrouter.service.js`
- [Auth Manager](https://github.com/mayur-panchal-2808/custom-cli/blob/main/auth/authManager.js): auth · Handles login and setup. · `auth/authManager.js`
- [Config Manager](https://github.com/mayur-panchal-2808/custom-cli/blob/main/config/configManager.js): state · Persists global and project settings. · `config/configManager.js`

### Tools

Local filesystem and shell boundaries exposed to workflows.

- [File Tool](https://github.com/mayur-panchal-2808/custom-cli/blob/main/tools/fileTool.js): filesystem tool · Reads and writes project files. · `tools/fileTool.js`
- [Terminal Tool](https://github.com/mayur-panchal-2808/custom-cli/blob/main/tools/terminalTool.js): shell tool · Executes shell commands. · `tools/terminalTool.js`

### Release

Packaging and automated publishing.

- [package.json](https://github.com/mayur-panchal-2808/custom-cli/blob/main/package.json): package metadata · CLI packaging and npm metadata. · `package.json`
- [Publish CI](https://github.com/mayur-panchal-2808/custom-cli/blob/main/.github/workflows/publish.yml): release workflow · Automated npm publish workflow. · `.github/workflows/publish.yml`

## Connections

- index.js → Pipeline: starts · Main CLI hands off to orchestration.
- practice-cli.js → Pipeline: runs · Secondary runner also enters the shared pipeline.
- Pipeline → Agent Runner: dispatches · Pipeline selects and coordinates agent execution.
- Agent Runner → Planner: plans · Task decomposition stage.
- Agent Runner → Analyzer: analyzes · Context inspection stage.
- Agent Runner → Executor: executes · Action-producing stage.
- Agent Runner → Reviewer: reviews · Validation and refinement stage.
- Agent Runner → OpenRouter: calls · Agents use the model provider adapter for AI responses.
- Agent Runner → File Tool: uses · Workflow can read or modify files.
- Agent Runner → Terminal Tool: uses · Workflow can execute shell actions.
- Auth Manager → Config Manager: stores · Auth state and credentials are persisted through config management.
- Pipeline → Auth Manager: checks auth · CLI workflow depends on setup/login state.
- Pipeline → Config Manager: loads config · Workflow reads provider and default settings.
- Config Manager → OpenRouter: configures · Provider/model selection feeds the AI adapter.
- package.json → index.js: entry · Package metadata points to the main CLI entrypoint.
- package.json → Publish CI: publishes · Release automation is tied to npm distribution.
