claw-dashboard 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.c8rc.json +38 -0
- package/.dockerignore +68 -0
- package/.github/dependabot.yml +45 -0
- package/.github/pull_request_template.md +39 -0
- package/.github/workflows/ci.yml +147 -0
- package/.github/workflows/release.yml +40 -0
- package/.github/workflows/security.yml +84 -0
- package/.husky/pre-commit +1 -0
- package/.planning/codebase/ARCHITECTURE.md +206 -0
- package/.planning/codebase/INTEGRATIONS.md +150 -0
- package/.planning/codebase/STACK.md +122 -0
- package/.planning/codebase/STRUCTURE.md +201 -0
- package/CHANGELOG.md +293 -0
- package/CONTRIBUTING.md +378 -0
- package/Dockerfile +54 -0
- package/FEATURES.md +195 -21
- package/README.md +83 -6
- package/TODO.md +28 -0
- package/build-cjs.js +127 -0
- package/cjs-shim.js +13 -0
- package/dist/clawdash +1729 -0
- package/dist/clawdash.meta.json +2236 -0
- package/dist/widgets.cjs +6511 -0
- package/docker-compose.yml +67 -0
- package/docs/API.md +1050 -0
- package/docs/PLUGINS.md +1504 -0
- package/esbuild.config.js +158 -0
- package/eslint.config.js +56 -0
- package/examples/plugins/README.md +122 -0
- package/examples/plugins/api-status/index.js +294 -0
- package/examples/plugins/api-status/plugin.json +19 -0
- package/examples/plugins/hello-world/index.js +104 -0
- package/examples/plugins/hello-world/plugin.json +15 -0
- package/examples/plugins/system-metrics-chart/index.js +339 -0
- package/examples/plugins/system-metrics-chart/plugin.json +18 -0
- package/examples/plugins/weather-widget/index.js +136 -0
- package/examples/plugins/weather-widget/plugin.json +19 -0
- package/index.cjs +23005 -0
- package/index.js +5236 -566
- package/jest.config.js +11 -0
- package/man/clawdash.1 +276 -0
- package/package.json +54 -5
- package/schemas/plugin-manifest.json +128 -0
- package/scripts/release.js +595 -0
- package/src/alerts.js +693 -0
- package/src/auto-save.js +584 -0
- package/src/cache.js +390 -0
- package/src/checksum.js +146 -0
- package/src/cli/args.js +110 -0
- package/src/cli/export-schedule.js +423 -0
- package/src/cli/export-snapshot.js +138 -0
- package/src/cli/help.js +69 -0
- package/src/cli/import-snapshot.js +230 -0
- package/src/cli/index.js +14 -0
- package/src/cli/list-templates.js +69 -0
- package/src/cli/validate-config.js +76 -0
- package/src/cli/validate-plugin.js +187 -0
- package/src/cli/version.js +15 -0
- package/src/config-validator.js +586 -0
- package/src/config-watcher.js +401 -0
- package/src/config.js +684 -0
- package/src/container-detector.js +499 -0
- package/src/database.js +734 -0
- package/src/differential-render.js +327 -0
- package/src/errors.js +169 -0
- package/src/export-scheduler.js +581 -0
- package/src/gateway-manager.js +685 -0
- package/src/hints.js +371 -0
- package/src/loading-states.js +509 -0
- package/src/logger.js +185 -0
- package/src/memory-pressure.js +467 -0
- package/src/performance-monitor.js +374 -0
- package/src/plugin-errors.js +586 -0
- package/src/plugin-manifest-validator.js +219 -0
- package/src/plugin-reload.js +481 -0
- package/src/plugin-scaffold.js +1941 -0
- package/src/plugin-validator.js +284 -0
- package/src/retry.js +218 -0
- package/src/security.js +860 -0
- package/src/snapshot.js +372 -0
- package/src/splash.js +115 -0
- package/src/theme-selector.js +411 -0
- package/src/themes.js +874 -0
- package/src/transitions.js +534 -0
- package/src/types.d.ts +174 -0
- package/src/validation.js +926 -0
- package/src/web-server.js +885 -0
- package/src/widgets/builtin-widgets.js +1057 -0
- package/src/widgets/config-processor.js +401 -0
- package/src/widgets/dependency-resolver.js +596 -0
- package/src/widgets/index.js +79 -0
- package/src/widgets/plugin-api.js +845 -0
- package/src/widgets/widget-error-boundary.js +773 -0
- package/src/widgets/widget-error-isolation.js +551 -0
- package/src/widgets/widget-loader.js +1437 -0
- package/src/workers/system-worker.js +130 -0
- package/src/workers/worker-pool.js +633 -0
- package/tests/alerts.test.js +437 -0
- package/tests/auto-save.test.js +529 -0
- package/tests/cache.test.js +317 -0
- package/tests/cli.test.js +351 -0
- package/tests/command-palette.test.js +320 -0
- package/tests/config-processor.test.js +452 -0
- package/tests/config-validator.test.js +710 -0
- package/tests/config-watcher.test.js +594 -0
- package/tests/config.test.js +755 -0
- package/tests/database.test.js +438 -0
- package/tests/errors.test.js +189 -0
- package/tests/example-plugins.test.js +624 -0
- package/tests/integration.test.js +1321 -0
- package/tests/loading-states.test.js +300 -0
- package/tests/manifest-validation-on-load.test.js +671 -0
- package/tests/performance-monitor.test.js +190 -0
- package/tests/plugin-api-rate-limit.test.js +302 -0
- package/tests/plugin-errors.test.js +311 -0
- package/tests/plugin-lifecycle-e2e.test.js +1036 -0
- package/tests/plugin-reload.test.js +764 -0
- package/tests/rate-limiter.test.js +539 -0
- package/tests/retry.test.js +308 -0
- package/tests/security.test.js +411 -0
- package/tests/settings-modal.test.js +226 -0
- package/tests/theme-selector.test.js +57 -0
- package/tests/utils.js +242 -0
- package/tests/utils.test.js +317 -0
- package/tests/validate-plugin-cli.test.js +359 -0
- package/tests/validation.test.js +837 -0
- package/tests/web-server.test.js +646 -0
- package/tests/widget-arrange-mode.test.js +183 -0
- package/tests/widget-config-hot-reload.test.js +465 -0
- package/tests/widget-dependency.test.js +591 -0
- package/tests/widget-error-boundary.test.js +749 -0
- package/tests/widget-error-isolation.test.js +469 -0
- package/tests/widget-integration.test.js +1147 -0
- package/tests/widget-refresh-intervals.test.js +284 -0
- package/tests/worker-pool.test.js +522 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# External Integrations
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-02-28
|
|
4
|
+
|
|
5
|
+
## APIs & External Services
|
|
6
|
+
|
|
7
|
+
**OpenClaw Gateway (Primary Integration):**
|
|
8
|
+
- Default endpoint: localhost:18789
|
|
9
|
+
- Protocol: HTTPS with optional token authentication
|
|
10
|
+
- Endpoints queried:
|
|
11
|
+
- `/api/sessions` - Active session list
|
|
12
|
+
- `/api/agents` - Available agents
|
|
13
|
+
- `/api/logs` - Log entries
|
|
14
|
+
- File: `src/gateway-manager.js`
|
|
15
|
+
|
|
16
|
+
**System Information (systeminformation library):**
|
|
17
|
+
- CPU: load, usage, temperature
|
|
18
|
+
- Memory: total, used, free, swap
|
|
19
|
+
- GPU: NVIDIA (nvidia-smi), AMD (radeontop), Intel, WSL
|
|
20
|
+
- Network: interfaces, speed, stats
|
|
21
|
+
- Disk: filesystems, IO, usage
|
|
22
|
+
- OS: uptime, hostname, platform
|
|
23
|
+
- File: Uses `systeminformation` npm package
|
|
24
|
+
|
|
25
|
+
**No External Cloud Services:**
|
|
26
|
+
- No telemetry or analytics services
|
|
27
|
+
- No external logging services
|
|
28
|
+
- No cloud-based configuration
|
|
29
|
+
|
|
30
|
+
## Data Storage
|
|
31
|
+
|
|
32
|
+
**Local SQLite Database:**
|
|
33
|
+
- Library: sql.js (WebAssembly SQLite)
|
|
34
|
+
- Path: `~/.openclaw/dashboard-history.db`
|
|
35
|
+
- Tables: session_snapshots, cpu_metrics, memory_metrics, network_metrics
|
|
36
|
+
- File: `src/database.js`
|
|
37
|
+
|
|
38
|
+
**JSON Configuration:**
|
|
39
|
+
- Settings: `~/.openclaw/dashboard-settings.json`
|
|
40
|
+
- Persistent state across restarts
|
|
41
|
+
- File: `src/config.js`, `src/validation.js`
|
|
42
|
+
|
|
43
|
+
**File Storage:**
|
|
44
|
+
- Local filesystem only
|
|
45
|
+
- Export directory: `~/.openclaw/exports/`
|
|
46
|
+
- Plugin directory: `~/.openclaw/plugins/`
|
|
47
|
+
|
|
48
|
+
**Caching:**
|
|
49
|
+
- In-memory cache with TTL
|
|
50
|
+
- Categories: cpu, memory, gpu, network, disk, system, container
|
|
51
|
+
- File: `src/cache.js`
|
|
52
|
+
|
|
53
|
+
## Authentication & Identity
|
|
54
|
+
|
|
55
|
+
**Gateway Authentication:**
|
|
56
|
+
- Token-based (optional per endpoint)
|
|
57
|
+
- Header: Authorization Bearer token
|
|
58
|
+
- File: `src/gateway-manager.js`
|
|
59
|
+
|
|
60
|
+
**Web Interface Auth (Optional):**
|
|
61
|
+
- API key authentication (disabled by default)
|
|
62
|
+
- Key format: `cd_[a-zA-Z0-9]{32}`
|
|
63
|
+
- Max 10 keys, hashed in storage
|
|
64
|
+
- File: `src/web-server.js`
|
|
65
|
+
|
|
66
|
+
**File Permissions:**
|
|
67
|
+
- Settings/database: 0600 (owner read/write only)
|
|
68
|
+
- File: `src/security.js`
|
|
69
|
+
|
|
70
|
+
## Monitoring & Observability
|
|
71
|
+
|
|
72
|
+
**Error Tracking:**
|
|
73
|
+
- Custom error classes (DashboardError hierarchy)
|
|
74
|
+
- Centralized error handling in widgets
|
|
75
|
+
- Plugin error boundary with isolation
|
|
76
|
+
- File: `src/errors.js`, `src/plugin-errors.js`, `src/widgets/widget-error-boundary.js`
|
|
77
|
+
|
|
78
|
+
**Logging:**
|
|
79
|
+
- Local log file: `~/.openclaw/claw-dashboard.log`
|
|
80
|
+
- Logger: `src/logger.js`
|
|
81
|
+
- Levels: error, warn, info, debug
|
|
82
|
+
- Console output during development
|
|
83
|
+
|
|
84
|
+
**Performance Monitoring:**
|
|
85
|
+
- Worker pool metrics
|
|
86
|
+
- Memory pressure detection
|
|
87
|
+
- Widget render timing
|
|
88
|
+
- File: `src/performance-monitor.js`, `src/memory-pressure.js`
|
|
89
|
+
|
|
90
|
+
## Web Interface
|
|
91
|
+
|
|
92
|
+
**Embedded Web Server:**
|
|
93
|
+
- Disabled by default
|
|
94
|
+
- Port: 18790 (configurable)
|
|
95
|
+
- Rate limiting: 100 requests/minute per IP
|
|
96
|
+
- CORS: configurable (wildcard in development)
|
|
97
|
+
- Endpoints:
|
|
98
|
+
- GET /health
|
|
99
|
+
- GET /metrics
|
|
100
|
+
- GET /sessions
|
|
101
|
+
- GET /agents
|
|
102
|
+
- GET /logs
|
|
103
|
+
- GET /status
|
|
104
|
+
- File: `src/web-server.js`
|
|
105
|
+
|
|
106
|
+
## CI/CD & Deployment
|
|
107
|
+
|
|
108
|
+
**CI Pipeline:**
|
|
109
|
+
- GitHub Actions configured (`.github/workflows/`)
|
|
110
|
+
- Jest tests with coverage
|
|
111
|
+
- Docker support (Dockerfile, docker-compose.yml)
|
|
112
|
+
|
|
113
|
+
**Installation:**
|
|
114
|
+
- npm global install: `npm install -g claw-dashboard`
|
|
115
|
+
- Binary: `clawdash`
|
|
116
|
+
- Manual install script: `install.sh`
|
|
117
|
+
|
|
118
|
+
## Environment Configuration
|
|
119
|
+
|
|
120
|
+
**Required env vars:**
|
|
121
|
+
- None (all have defaults)
|
|
122
|
+
|
|
123
|
+
**Optional env vars:**
|
|
124
|
+
- `HOME` - Used for path expansion
|
|
125
|
+
- `DARK_MODE` - Theme override
|
|
126
|
+
- `THEME` - Theme override
|
|
127
|
+
- `COLORFGBG` - Terminal background detection
|
|
128
|
+
|
|
129
|
+
**Secrets location:**
|
|
130
|
+
- Settings file (~/.openclaw/dashboard-settings.json)
|
|
131
|
+
- Database file (~/.openclaw/dashboard-history.db)
|
|
132
|
+
- API keys hashed before storage
|
|
133
|
+
|
|
134
|
+
## Webhooks & Callbacks
|
|
135
|
+
|
|
136
|
+
**Incoming:**
|
|
137
|
+
- None
|
|
138
|
+
|
|
139
|
+
**Outgoing:**
|
|
140
|
+
- None
|
|
141
|
+
|
|
142
|
+
**Plugin System:**
|
|
143
|
+
- Plugins loaded from filesystem
|
|
144
|
+
- Hot-reload support via file watcher
|
|
145
|
+
- Extension points for custom functionality
|
|
146
|
+
- File: `src/widgets/widget-loader.js`, `src/widgets/plugin-api.js`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
*Integration audit: 2026-02-28*
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Technology Stack
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-02-28
|
|
4
|
+
|
|
5
|
+
## Languages
|
|
6
|
+
|
|
7
|
+
**Primary:**
|
|
8
|
+
- JavaScript (ES2022) - All source code
|
|
9
|
+
- TypeScript definitions (types.d.ts) - Type definitions for IDE support
|
|
10
|
+
|
|
11
|
+
## Runtime
|
|
12
|
+
|
|
13
|
+
**Environment:**
|
|
14
|
+
- Node.js >= 18 (required)
|
|
15
|
+
- ES Modules (`"type": "module"` in package.json)
|
|
16
|
+
|
|
17
|
+
**Package Manager:**
|
|
18
|
+
- npm (lockfile present: package-lock.json)
|
|
19
|
+
|
|
20
|
+
## Frameworks & Libraries
|
|
21
|
+
|
|
22
|
+
**Core Runtime:**
|
|
23
|
+
- `blessed` ^0.1.81 - Terminal UI framework (blessed curses-like library)
|
|
24
|
+
- `blessed-contrib` ^4.11.0 - Charts and widgets for blessed
|
|
25
|
+
- `chalk` ^5.3.0 - Terminal string styling
|
|
26
|
+
- `systeminformation` ^5.21.22 - System information gathering (CPU, memory, network, disk, GPU)
|
|
27
|
+
- `sql.js` ^1.14.0 - SQLite compiled to WebAssembly for in-process database
|
|
28
|
+
- `timeout-cli` ^0.3.2 - Command timeout utilities
|
|
29
|
+
|
|
30
|
+
**Build System:**
|
|
31
|
+
- `esbuild` ^0.25.12 - Fast bundler for CJS builds
|
|
32
|
+
- Dual-package: ESM (primary) + CJS (built via build-cjs.js)
|
|
33
|
+
|
|
34
|
+
**Testing:**
|
|
35
|
+
- `jest` ^30.2.0 - Test framework (run with --experimental-vm-modules)
|
|
36
|
+
- No additional assertion library (uses Jest built-in)
|
|
37
|
+
|
|
38
|
+
**Linting:**
|
|
39
|
+
- `eslint` ^10.0.2 - Linting with @eslint/js recommended config
|
|
40
|
+
- Uses flat config (eslint.config.js)
|
|
41
|
+
|
|
42
|
+
## Key Dependencies
|
|
43
|
+
|
|
44
|
+
**Critical:**
|
|
45
|
+
- `blessed` + `blessed-contrib` - Terminal UI framework (core dependency)
|
|
46
|
+
- `systeminformation` - All system metrics (CPU, memory, GPU, network, disk)
|
|
47
|
+
- `sql.js` - SQLite WASM for historical data persistence
|
|
48
|
+
|
|
49
|
+
**Infrastructure:**
|
|
50
|
+
- `chalk` - Terminal styling
|
|
51
|
+
- `worker_threads` (Node.js built-in) - Worker pool for heavy operations
|
|
52
|
+
- `https`/`http` (Node.js built-in) - Gateway API communication
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
56
|
+
**Environment:**
|
|
57
|
+
- Settings stored in: `~/.openclaw/dashboard-settings.json`
|
|
58
|
+
- Database stored in: `~/.openclaw/dashboard-history.db`
|
|
59
|
+
- Plugins loaded from: `~/.openclaw/plugins/`
|
|
60
|
+
- Log file: `~/.openclaw/claw-dashboard.log`
|
|
61
|
+
|
|
62
|
+
**Build:**
|
|
63
|
+
- esbuild.config.js - ESM build configuration
|
|
64
|
+
- build-cjs.js - CJS bundle generation (creates index.cjs, dist/widgets.cjs)
|
|
65
|
+
- cjs-shim.js - Provides import.meta.url polyfill for CJS
|
|
66
|
+
|
|
67
|
+
**Package Exports:**
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
".": {
|
|
71
|
+
"import": "./index.js",
|
|
72
|
+
"require": "./index.cjs"
|
|
73
|
+
},
|
|
74
|
+
"./widgets": {
|
|
75
|
+
"import": "./src/widgets/index.js",
|
|
76
|
+
"require": "./dist/widgets.cjs"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Platform Requirements
|
|
82
|
+
|
|
83
|
+
**Development:**
|
|
84
|
+
- Node.js >= 18
|
|
85
|
+
- npm for dependency management
|
|
86
|
+
- macOS/Linux/Windows (some system features macOS-specific)
|
|
87
|
+
|
|
88
|
+
**Production:**
|
|
89
|
+
- Node.js runtime
|
|
90
|
+
- No external services required (self-contained)
|
|
91
|
+
- Optional: OpenClaw gateway endpoint on localhost:18789
|
|
92
|
+
|
|
93
|
+
## Module System
|
|
94
|
+
|
|
95
|
+
**Primary:** ES Modules (ESM) with `.js` extension
|
|
96
|
+
**Dual Package:** CJS builds for compatibility
|
|
97
|
+
**Worker Threads:** Separate worker files in `src/workers/`
|
|
98
|
+
|
|
99
|
+
**Import Patterns:**
|
|
100
|
+
```javascript
|
|
101
|
+
// ESM imports throughout
|
|
102
|
+
import blessed from 'blessed';
|
|
103
|
+
import { BaseWidget } from './plugin-api.js';
|
|
104
|
+
import config, { DEFAULT_SETTINGS } from './config.js';
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Database
|
|
108
|
+
|
|
109
|
+
**Type:** SQLite via sql.js (WebAssembly)
|
|
110
|
+
**Location:** `~/.openclaw/dashboard-history.db`
|
|
111
|
+
**Tables:**
|
|
112
|
+
- `session_snapshots` - Agent session data
|
|
113
|
+
- `cpu_metrics` - CPU usage history
|
|
114
|
+
- `memory_metrics` - Memory usage history
|
|
115
|
+
- `network_metrics` - Network usage history
|
|
116
|
+
|
|
117
|
+
**Save Interval:** 30 seconds
|
|
118
|
+
**Cleanup Interval:** 1 hour (with retention policy)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
*Stack analysis: 2026-02-28*
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Codebase Structure
|
|
2
|
+
|
|
3
|
+
**Analysis Date:** 2026-02-28
|
|
4
|
+
|
|
5
|
+
## Directory Layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/Users/kdsmith/.openclaw/workspace/claw-dashboard/
|
|
9
|
+
├── index.js # Main entry point (blessed TUI)
|
|
10
|
+
├── index.cjs # CJS build output
|
|
11
|
+
├── src/ # Core source code
|
|
12
|
+
│ ├── widgets/ # Widget system (plugins + built-in)
|
|
13
|
+
│ ├── workers/ # Worker thread pool
|
|
14
|
+
│ ├── cli/ # CLI command handlers
|
|
15
|
+
│ ├── *.js # Core modules (config, themes, etc.)
|
|
16
|
+
├── tests/ # Jest test suites (375 tests)
|
|
17
|
+
├── examples/ # Example plugins
|
|
18
|
+
│ └── plugins/ # Widget plugin examples
|
|
19
|
+
├── docs/ # Documentation
|
|
20
|
+
├── schemas/ # JSON schemas
|
|
21
|
+
├── dist/ # CJS build output
|
|
22
|
+
├── scripts/ # Build/release scripts
|
|
23
|
+
├── man/ # Man pages
|
|
24
|
+
├── build-cjs.js # CJS build script
|
|
25
|
+
├── esbuild.config.js # ESM build config
|
|
26
|
+
├── jest.config.js # Test configuration
|
|
27
|
+
├── eslint.config.js # Lint configuration
|
|
28
|
+
├── package.json # Package manifest (ESM + CJS dual)
|
|
29
|
+
└── README.md, CHANGELOG.md # Documentation
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Directory Purposes
|
|
33
|
+
|
|
34
|
+
**`src/` - Core Source:**
|
|
35
|
+
- Purpose: All application logic
|
|
36
|
+
- Contains: 35 JavaScript modules, organized by function
|
|
37
|
+
- Key files:
|
|
38
|
+
- `index.js` - Main entry
|
|
39
|
+
- `config.js` - Centralized constants
|
|
40
|
+
- `themes.js` - Theme management
|
|
41
|
+
- `gateway-manager.js` - Gateway communication
|
|
42
|
+
- `database.js` - SQLite persistence
|
|
43
|
+
|
|
44
|
+
**`src/widgets/` - Widget System:**
|
|
45
|
+
- Purpose: Plugin architecture and built-in widgets
|
|
46
|
+
- Contains: 10 files, ~14k total lines
|
|
47
|
+
- Key files:
|
|
48
|
+
- `plugin-api.js` - BaseWidget and PluginAPI classes
|
|
49
|
+
- `widget-loader.js` - Lazy loading, hot-reload, registry
|
|
50
|
+
- `builtin-widgets.js` - 10 built-in widget classes
|
|
51
|
+
- `dependency-resolver.js` - Widget dependency resolution
|
|
52
|
+
- `widget-error-boundary.js` - Error isolation
|
|
53
|
+
- `config-processor.js` - Config with env interpolation
|
|
54
|
+
|
|
55
|
+
**`src/workers/` - Worker Pool:**
|
|
56
|
+
- Purpose: Thread pool for heavy system operations
|
|
57
|
+
- Contains: 2 files
|
|
58
|
+
- Files:
|
|
59
|
+
- `worker-pool.js` - Pool management (874 lines)
|
|
60
|
+
- `system-worker.js` - Worker thread code (3k lines)
|
|
61
|
+
|
|
62
|
+
**`src/cli/` - CLI Commands:**
|
|
63
|
+
- Purpose: Command-line argument parsing and commands
|
|
64
|
+
- Contains: 6 files
|
|
65
|
+
- Files:
|
|
66
|
+
- `index.js` - Centralized exports
|
|
67
|
+
- `args.js` - Argument parsing
|
|
68
|
+
- `help.js` - Help text
|
|
69
|
+
- `validate-plugin.js` - Plugin validation CLI
|
|
70
|
+
- `validate-config.js` - Config validation CLI
|
|
71
|
+
|
|
72
|
+
**`tests/` - Test Suites:**
|
|
73
|
+
- Purpose: Jest test coverage
|
|
74
|
+
- Contains: 32 test files, 375 total tests
|
|
75
|
+
- Key files:
|
|
76
|
+
- `integration.test.js` - Multi-module integration
|
|
77
|
+
- `widget-*.test.js` - Widget system tests
|
|
78
|
+
- `example-plugins.test.js` - Plugin tests
|
|
79
|
+
|
|
80
|
+
**`examples/plugins/` - Example Plugins:**
|
|
81
|
+
- Purpose: Reference implementations for plugin developers
|
|
82
|
+
- Contains: 4 example widgets
|
|
83
|
+
- Plugins:
|
|
84
|
+
- `hello-world/` - Minimal widget example
|
|
85
|
+
- `api-status/` - API polling widget
|
|
86
|
+
- `system-metrics-chart/` - Chart widget example
|
|
87
|
+
- `weather-widget/` - External API widget
|
|
88
|
+
|
|
89
|
+
**`docs/` - Documentation:**
|
|
90
|
+
- Purpose: User and developer documentation
|
|
91
|
+
- Contains: PLUGINS.md, API.md
|
|
92
|
+
|
|
93
|
+
**`schemas/` - JSON Schemas:**
|
|
94
|
+
- Purpose: Validation schemas
|
|
95
|
+
- Contains: Plugin manifest schema
|
|
96
|
+
|
|
97
|
+
## Key File Locations
|
|
98
|
+
|
|
99
|
+
**Entry Points:**
|
|
100
|
+
- `index.js` - Main application entry (blessed TUI)
|
|
101
|
+
- `src/workers/system-worker.js` - Worker thread entry
|
|
102
|
+
- `src/cli/index.js` - CLI exports
|
|
103
|
+
|
|
104
|
+
**Configuration:**
|
|
105
|
+
- `src/config.js` - Centralized constants and defaults
|
|
106
|
+
- `src/config-validator.js` - Runtime config validation
|
|
107
|
+
- `src/validation.js` - Input validation
|
|
108
|
+
- `jest.config.js` - Test config
|
|
109
|
+
- `eslint.config.js` - Lint config
|
|
110
|
+
|
|
111
|
+
**Core Logic:**
|
|
112
|
+
- `src/gateway-manager.js` - Gateway communication
|
|
113
|
+
- `src/database.js` - SQLite persistence
|
|
114
|
+
- `src/cache.js` - In-memory caching
|
|
115
|
+
- `src/themes.js` - Theme management
|
|
116
|
+
- `src/alerts.js` - Rate limiting and alerts
|
|
117
|
+
|
|
118
|
+
**Widget System:**
|
|
119
|
+
- `src/widgets/plugin-api.js` - BaseWidget, PluginAPI
|
|
120
|
+
- `src/widgets/widget-loader.js` - Lazy loading
|
|
121
|
+
- `src/widgets/builtin-widgets.js` - Built-in widgets
|
|
122
|
+
- `src/widgets/index.js` - Widget system exports
|
|
123
|
+
|
|
124
|
+
**Build System:**
|
|
125
|
+
- `build-cjs.js` - CJS bundle generation
|
|
126
|
+
- `esbuild.config.js` - ESM build configuration
|
|
127
|
+
- `cjs-shim.js` - import.meta.url polyfill
|
|
128
|
+
|
|
129
|
+
## Naming Conventions
|
|
130
|
+
|
|
131
|
+
**Files:**
|
|
132
|
+
- Kebab-case: `widget-loader.js`, `builtin-widgets.js`
|
|
133
|
+
- Extensions: `.js` for source, `.test.js` for tests
|
|
134
|
+
|
|
135
|
+
**Directories:**
|
|
136
|
+
- Kebab-case: `widget-error-boundary.js` directory would be `widget-error-boundary/`
|
|
137
|
+
- Singular nouns except workers/ (plural by convention)
|
|
138
|
+
|
|
139
|
+
**Classes:**
|
|
140
|
+
- PascalCase: `BaseWidget`, `WidgetLoader`, `PluginAPI`
|
|
141
|
+
- Suffix pattern: `*Widget`, `*Manager`, `*Error`
|
|
142
|
+
|
|
143
|
+
**Functions/Methods:**
|
|
144
|
+
- camelCase: `loadWidget()`, `getData()`, `validateConfig()`
|
|
145
|
+
- Async prefix: `async` keyword, not name
|
|
146
|
+
|
|
147
|
+
**Constants:**
|
|
148
|
+
- UPPER_SNAKE_CASE: `DEFAULT_SETTINGS`, `REFRESH_INTERVALS`
|
|
149
|
+
- Grouped in objects: `config.REFRESH_INTERVALS`
|
|
150
|
+
|
|
151
|
+
## Where to Add New Code
|
|
152
|
+
|
|
153
|
+
**New Widget:**
|
|
154
|
+
- Implementation: `src/widgets/builtin-widgets.js` (for built-in) OR `~/.openclaw/plugins/<name>/` (for plugin)
|
|
155
|
+
- Tests: `tests/<widget-name>.test.js`
|
|
156
|
+
|
|
157
|
+
**New Plugin:**
|
|
158
|
+
- Development: `examples/plugins/<name>/`
|
|
159
|
+
- Required files: `index.js`, `plugin.json`
|
|
160
|
+
- See `examples/plugins/hello-world/` for template
|
|
161
|
+
|
|
162
|
+
**New Service Module:**
|
|
163
|
+
- Implementation: `src/<module-name>.js`
|
|
164
|
+
- Tests: `tests/<module-name>.test.js`
|
|
165
|
+
- Export from: `src/widgets/index.js` if widget-related
|
|
166
|
+
|
|
167
|
+
**New CLI Command:**
|
|
168
|
+
- Handler: `src/cli/<command-name>.js`
|
|
169
|
+
- Export: `src/cli/index.js`
|
|
170
|
+
- Integration: `index.js` main CLI parsing
|
|
171
|
+
|
|
172
|
+
**New Worker Task:**
|
|
173
|
+
- Worker: `src/workers/system-worker.js` (add task handler)
|
|
174
|
+
- Pool: `src/workers/worker-pool.js` (add public method)
|
|
175
|
+
|
|
176
|
+
## Special Directories
|
|
177
|
+
|
|
178
|
+
**`dist/`:**
|
|
179
|
+
- Purpose: CJS build output
|
|
180
|
+
- Generated: Yes (by `npm run build:cjs`)
|
|
181
|
+
- Committed: Yes (for npm package)
|
|
182
|
+
- Contains: `widgets.cjs` for CJS consumers
|
|
183
|
+
|
|
184
|
+
**`node_modules/`:**
|
|
185
|
+
- Purpose: npm dependencies
|
|
186
|
+
- Generated: Yes
|
|
187
|
+
- Committed: No
|
|
188
|
+
|
|
189
|
+
**`coverage/`:**
|
|
190
|
+
- Purpose: Jest coverage reports
|
|
191
|
+
- Generated: Yes
|
|
192
|
+
- Committed: No
|
|
193
|
+
|
|
194
|
+
**`~/.openclaw/` (runtime):**
|
|
195
|
+
- Purpose: User data directory
|
|
196
|
+
- Created: At runtime if not exists
|
|
197
|
+
- Contains: settings, database, logs, plugins
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
*Structure analysis: 2026-02-28*
|