How mayur-panchal-2808/custom-cli works
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: agentRunner.js Agent Runner · pipeline.js Pipeline · configManager.js Config Manager · package.json package.json
Components 15
CLI Entry
Package entrypoints and local runners.
- index.js · Main CLI entrypoint.
index.js - practice-cli.js · Secondary local runner or experiment entrypoint.
practice-cli.js
Orchestration
Workflow coordination and agent execution.
- Pipeline · Top-level workflow coordinator.
core/pipeline.js - Agent Runner · Runs the agent sequence and manages handoffs.
core/agentRunner.js
Agents
Specialized planning, analysis, execution, and review roles.
Platform
Auth, config, and external AI provider integration.
- OpenRouter · External model API adapter and response handling.
services/openrouter.service.js - Auth Manager · Handles login and setup.
auth/authManager.js - Config Manager · Persists global and project settings.
config/configManager.js
Tools
Local filesystem and shell boundaries exposed to workflows.
- File Tool · Reads and writes project files.
tools/fileTool.js - Terminal Tool · Executes shell commands.
tools/terminalTool.js
Release
Packaging and automated publishing.
- package.json · CLI packaging and npm metadata.
package.json - Publish CI · Automated npm publish workflow.
.github/workflows/publish.yml
Connections 16
- 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.