# octoparse/octoparse-cli architecture

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

- Interactive diagram: https://gitdiagram.com/octoparse/octoparse-cli
- Repository: https://github.com/octoparse/octoparse-cli

## Overview

Octoparse CLI lets users authenticate, discover and manage extraction tasks, create task definitions from URLs, run tasks locally or in the cloud, and inspect or export results. The principal URL-to-task workflow moves from the detect command through browser/page analysis and optional agent-assisted planning to a saved task definition; the separate run workflow executes tasks and records local run state and artifacts. README-described capabilities such as user-browser setup, cloud operations, and data export are included. Some command implementations were not sampled, so their internal links are limited to documented behavior.

Main entry points: [`src/index.ts`](https://github.com/octoparse/octoparse-cli/blob/main/src/index.ts) (Command dispatch), [`src/commands/detect/command.ts`](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/command.ts) (URL detection command), [`src/commands/run.ts`](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/run.ts) (Local run command), [`src/commands/data.ts`](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/data.ts) (Data history and export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI interaction"]
  node_entry["Command dispatch<br/>[index.ts]"]
  node_task_commands["Task management<br/>[task.ts]"]
  node_browser_commands["Browser setup<br/>[browser.ts]"]
end

subgraph group_task_creation["Task creation"]
  node_detect_command["URL detection command<br/>[command.ts]"]
  node_page_detector["Page analysis<br/>[page-detector.ts]"]
  node_api_detector["API-list detection"]
  node_agent_context["Agent candidate context<br/>[agent-context.ts]"]
  node_agent_plan["Agent task planning<br/>[agent-plan.ts]"]
  node_agent_runner["Agent workflow<br/>[agent-runner.ts]"]
  node_task_persist["Task persistence<br/>[persist.ts]"]
end

subgraph group_execution["Extraction execution"]
  node_cloud_commands["Cloud task operations<br/>[cloud.ts]"]
  node_run_command["Local run command<br/>[run.ts]"]
  node_engine["Browser task runtime<br/>[engine-host.ts]"]
  node_user_browser["User browser lifecycle<br/>[user-browser.ts]"]
end

subgraph group_account_api["Account and API"]
  node_auth_command["Authentication commands<br/>[auth.ts]"]
  node_auth_runtime["Credential resolution<br/>[auth.ts]"]
  node_api["Octoparse API client<br/>[api-client.ts]"]
end

subgraph group_results["Run results"]
  node_local_commands["Local run controls<br/>[local.ts]"]
  node_artifacts["Run artifacts<br/>[artifacts.ts]"]
  node_data_commands["Data history and export<br/>[data.ts]"]
end

node_user(("CLI user"))
node_external_octoparse{{"Octoparse services"}}
node_target_site{{"Target website"}}

node_user -->|"invokes"| node_entry
node_entry -->|"dispatches"| node_auth_command
node_entry -->|"dispatches"| node_detect_command
node_entry -->|"dispatches"| node_run_command
node_entry -->|"dispatches"| node_task_commands
node_entry -->|"dispatches"| node_cloud_commands
node_entry -->|"dispatches"| node_data_commands
node_entry -->|"dispatches"| node_browser_commands
node_auth_command -->|"stores credentials"| node_auth_runtime
node_auth_command -->|"validates credentials"| node_api
node_auth_runtime -->|"refreshes OAuth"| node_external_octoparse
node_task_commands -.->|"lists and inspects"| node_api
node_detect_command -->|"analyzes pages"| node_page_detector
node_detect_command -->|"detects API lists"| node_api_detector
node_detect_command -->|"starts agent mode"| node_agent_runner
node_agent_runner -->|"builds context"| node_agent_context
node_agent_runner -->|"requests plan"| node_agent_plan
node_detect_command -->|"saves task"| node_task_persist
node_target_site -->|"provides URL"| node_detect_command
node_user -->|"starts extraction"| node_run_command
node_run_command -->|"runs browser task"| node_engine
node_run_command -->|"records run output"| node_artifacts
node_engine -->|"prepares profile"| node_user_browser
node_engine -->|"requests proxy and captcha"| node_external_octoparse
node_cloud_commands -->|"controls cloud runs"| node_external_octoparse
node_browser_commands -->|"manages profiles"| node_user_browser
node_user -->|"controls local run"| node_local_commands
node_local_commands -.->|"reads run history"| node_artifacts
node_user -->|"requests export"| node_data_commands
node_data_commands -.->|"fetches cloud data"| node_external_octoparse
node_data_commands -.->|"exports local data"| node_artifacts

click node_entry "https://github.com/octoparse/octoparse-cli/blob/main/src/index.ts"
click node_task_commands "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/task.ts"
click node_auth_command "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/auth.ts"
click node_auth_runtime "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/auth.ts"
click node_api "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/api-client.ts"
click node_cloud_commands "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/cloud.ts"
click node_detect_command "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/command.ts"
click node_page_detector "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/page-detector.ts"
click node_api_detector "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/api-list-detector.ts"
click node_agent_context "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/agent-context.ts"
click node_agent_plan "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/agent-plan.ts"
click node_agent_runner "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/agent-runner.ts"
click node_task_persist "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/persist.ts"
click node_run_command "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/run.ts"
click node_engine "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/engine-host.ts"
click node_user_browser "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/user-browser.ts"
click node_local_commands "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/local.ts"
click node_artifacts "https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/artifacts.ts"
click node_data_commands "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/data.ts"
click node_browser_commands "https://github.com/octoparse/octoparse-cli/blob/main/src/commands/browser.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_entry,node_task_commands,node_browser_commands,node_user toneBlue
class node_detect_command,node_page_detector,node_api_detector,node_agent_context,node_agent_plan,node_agent_runner,node_task_persist toneAmber
class node_cloud_commands,node_run_command,node_engine,node_user_browser toneMint
class node_auth_command,node_auth_runtime,node_api toneRose
class node_local_commands,node_artifacts,node_data_commands,node_external_octoparse,node_target_site toneIndigo
```

## Components

### CLI interaction

- [Command dispatch](https://github.com/octoparse/octoparse-cli/blob/main/src/index.ts): `src/index.ts`
- [Task management](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/task.ts): `src/commands/task.ts`
- [Browser setup](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/browser.ts): `src/commands/browser.ts`

### Task creation

- [URL detection command](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/command.ts): `src/commands/detect/command.ts`
- [Page analysis](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/page-detector.ts): `src/runtime/detector/page-detector.ts`
- [API-list detection](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/api-list-detector.ts): `src/runtime/detector/api-list-detector.ts`
- [Agent candidate context](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/agent-context.ts): `src/runtime/detector/agent-context.ts`
- [Agent task planning](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/detector/agent-plan.ts): `src/runtime/detector/agent-plan.ts`
- [Agent workflow](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/agent-runner.ts): `src/commands/detect/agent-runner.ts`
- [Task persistence](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/detect/persist.ts): `src/commands/detect/persist.ts`

### Extraction execution

- [Cloud task operations](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/cloud.ts): `src/commands/cloud.ts`
- [Local run command](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/run.ts): `src/commands/run.ts`
- [Browser task runtime](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/engine-host.ts): `src/runtime/engine-host.ts`
- [User browser lifecycle](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/user-browser.ts): `src/runtime/user-browser.ts`

### Account and API

- [Authentication commands](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/auth.ts): `src/commands/auth.ts`
- [Credential resolution](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/auth.ts): `src/runtime/auth.ts`
- [Octoparse API client](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/api-client.ts): `src/runtime/api-client.ts`

### Run results

- [Local run controls](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/local.ts): `src/commands/local.ts`
- [Run artifacts](https://github.com/octoparse/octoparse-cli/blob/main/src/runtime/artifacts.ts): `src/runtime/artifacts.ts`
- [Data history and export](https://github.com/octoparse/octoparse-cli/blob/main/src/commands/data.ts): `src/commands/data.ts`

### Other components

- **CLI user**
- **Octoparse services**
- **Target website**

## Connections

- CLI user → Command dispatch: invokes (evidence: `README.md`)
- Command dispatch → Authentication commands: dispatches (evidence: `src/index.ts`)
- Command dispatch → URL detection command: dispatches (evidence: `src/index.ts`)
- Command dispatch → Local run command: dispatches (evidence: `src/index.ts`)
- Command dispatch → Task management: dispatches (evidence: `src/index.ts`)
- Command dispatch → Cloud task operations: dispatches (evidence: `src/index.ts`)
- Command dispatch → Data history and export: dispatches (evidence: `src/index.ts`)
- Command dispatch → Browser setup: dispatches (evidence: `src/index.ts`)
- Authentication commands → Credential resolution: stores credentials (evidence: `src/commands/auth.ts`)
- Authentication commands → Octoparse API client: validates credentials (evidence: `src/commands/auth.ts`)
- Credential resolution → Octoparse services: refreshes OAuth (evidence: `src/runtime/auth.ts`)
- Task management → Octoparse API client: lists and inspects
- URL detection command → Page analysis: analyzes pages (evidence: `src/commands/detect/command.ts`)
- URL detection command → API-list detection: detects API lists (evidence: `src/commands/detect/command.ts`)
- URL detection command → Agent workflow: starts agent mode (evidence: `src/commands/detect/command.ts`)
- Agent workflow → Agent candidate context: builds context (evidence: `src/commands/detect/agent-runner.ts`)
- Agent workflow → Agent task planning: requests plan (evidence: `src/commands/detect/agent-runner.ts`)
- URL detection command → Task persistence: saves task (evidence: `README.md`)
- Target website → URL detection command: provides URL (evidence: `README.md`)
- CLI user → Local run command: starts extraction (evidence: `README.md`)
- Local run command → Browser task runtime: runs browser task (evidence: `src/commands/run.ts`)
- Local run command → Run artifacts: records run output (evidence: `src/commands/run.ts`)
- Browser task runtime → User browser lifecycle: prepares profile (evidence: `src/runtime/engine-host.ts`)
- Browser task runtime → Octoparse services: requests proxy and captcha (evidence: `src/runtime/engine-host.ts`)
- Cloud task operations → Octoparse services: controls cloud runs (evidence: `README.md`)
- Browser setup → User browser lifecycle: manages profiles (evidence: `src/commands/browser.ts`)
- CLI user → Local run controls: controls local run (evidence: `README.md`)
- Local run controls → Run artifacts: reads run history
- CLI user → Data history and export: requests export (evidence: `README.md`)
- Data history and export → Octoparse services: fetches cloud data
- Data history and export → Run artifacts: exports local data
