claw-dashboard 1.8.4 → 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 +5331 -512
- 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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [2.0.0] - 2026-02-28
|
|
11
|
+
|
|
12
|
+
### Major Features
|
|
13
|
+
|
|
14
|
+
#### Command Palette (Ctrl+K)
|
|
15
|
+
- Quick access to all dashboard commands via fuzzy search
|
|
16
|
+
- Keyboard shortcut discovery and command execution
|
|
17
|
+
- Categories for Navigation, Display, System, and Widgets
|
|
18
|
+
|
|
19
|
+
#### Widget System Overhaul
|
|
20
|
+
- **Drag-and-drop arrangement mode** - Press `w` to enter arrangement mode, use arrow keys to reorder widgets
|
|
21
|
+
- **Widget pinning** - Pin up to 4 favorite widgets to the top row with `Alt+1-9`
|
|
22
|
+
- **Widget size presets** - Resize any widget to small, medium, large, or wide
|
|
23
|
+
- **Improved widget navigation** - Tab/Shift+Tab to cycle focus between widgets
|
|
24
|
+
- **Enter key actions** - Show widget details or performance overlay when widget is focused
|
|
25
|
+
|
|
26
|
+
#### Dashboard Snapshots
|
|
27
|
+
- Export full dashboard state as shareable JSON files (`Ctrl+S`)
|
|
28
|
+
- Import snapshots to restore configurations (`Ctrl+O`)
|
|
29
|
+
- Includes widget visibility, sizes, positions, and settings
|
|
30
|
+
|
|
31
|
+
#### Auto-save System
|
|
32
|
+
- Automatic state persistence every 30 seconds
|
|
33
|
+
- Crash recovery with backup rotation (keeps last 5 backups)
|
|
34
|
+
- Restores session selection, search queries, favorites filter, and widget focus on restart
|
|
35
|
+
|
|
36
|
+
#### Export Scheduling
|
|
37
|
+
- Automated metric exports with cron-like scheduling
|
|
38
|
+
- Configurable format (JSON/CSV), directory, and retention
|
|
39
|
+
- Optional metrics inclusion and custom schedules
|
|
40
|
+
|
|
41
|
+
#### Plugin System
|
|
42
|
+
- Interactive plugin scaffolding CLI for creating new widgets
|
|
43
|
+
- Plugin hot-reload with `--watch` flag for development
|
|
44
|
+
- Plugin configuration UI in settings panel
|
|
45
|
+
- Manifest validation on load
|
|
46
|
+
- Pre-commit hooks with lint-staged for plugin development
|
|
47
|
+
|
|
48
|
+
#### Theme System Enhancements
|
|
49
|
+
- **Theme selector UI** - Interactive picker with live preview (`T` key)
|
|
50
|
+
- **Auto theme detection** - Syncs with system theme changes
|
|
51
|
+
- **Animated loading states** - Smooth transitions for splash screen
|
|
52
|
+
|
|
53
|
+
#### Performance & Monitoring
|
|
54
|
+
- **Performance metrics overlay** - Memory, CPU, and refresh rate stats (press `p`)
|
|
55
|
+
- **Worker thread pool** - Offloads heavy system info gathering for UI responsiveness
|
|
56
|
+
- **Memory pressure detection** - Monitors long-running session health
|
|
57
|
+
- **Graceful degradation** - Continues operating when system data fetching fails
|
|
58
|
+
|
|
59
|
+
#### Gateway Management
|
|
60
|
+
- **Multi-gateway support** - Connect to multiple OpenClaw endpoints
|
|
61
|
+
- **Auto-retry with exponential backoff** - Configurable retry logic
|
|
62
|
+
- **Gateway status widget** - Visual indicator of gateway health
|
|
63
|
+
- **Manual retry** - Press `G` to retry connection when offline
|
|
64
|
+
|
|
65
|
+
#### Error Handling
|
|
66
|
+
- **Widget error boundaries** - Isolates widget failures from dashboard
|
|
67
|
+
- **Error recovery UI** - Press `X` to retry failed widgets
|
|
68
|
+
- **Custom error classes** - Better error categorization and handling
|
|
69
|
+
- **Widget error isolation** - Failed widgets show retry button without crashing dashboard
|
|
70
|
+
|
|
71
|
+
### New Controls
|
|
72
|
+
|
|
73
|
+
| Key | Action |
|
|
74
|
+
|-----|--------|
|
|
75
|
+
| `Ctrl+K` | Open command palette |
|
|
76
|
+
| `w` | Enter widget arrangement mode |
|
|
77
|
+
| `Alt+1-9` | Pin/unpin widget to favorites |
|
|
78
|
+
| `T` | Open theme selector |
|
|
79
|
+
| `Ctrl+S` | Export dashboard snapshot |
|
|
80
|
+
| `Ctrl+O` | Import dashboard snapshot |
|
|
81
|
+
| `X` | Retry failed widgets |
|
|
82
|
+
| `Enter` | Show widget details (when focused) |
|
|
83
|
+
|
|
84
|
+
### Changed
|
|
85
|
+
- **Swapped hotkeys**: `p` now opens performance overlay, `P` (capital) pauses
|
|
86
|
+
- Improved settings panel with more options
|
|
87
|
+
- Enhanced footer with gateway status and performance metrics
|
|
88
|
+
- Better cross-platform GPU support (WSL2, Windows WMI, Linux nvidia-smi)
|
|
89
|
+
- Container environment detection (Docker, Kubernetes, WSL)
|
|
90
|
+
|
|
91
|
+
### Fixed
|
|
92
|
+
- Navigation crash during settings modal close (race condition)
|
|
93
|
+
- Worker timer leak in widget refresh intervals
|
|
94
|
+
- Session detail view color markup display
|
|
95
|
+
- Settings list refresh after changing refresh interval
|
|
96
|
+
- Modal state getting stuck when closing multiple modals quickly
|
|
97
|
+
- Performance overlay now properly captures input (q/Escape/p to close)
|
|
98
|
+
- Version check now non-blocking with configurable 12h interval
|
|
99
|
+
- Widget destroy errors with proper null checks
|
|
100
|
+
- Log level filter default to "all" instead of "error"
|
|
101
|
+
|
|
102
|
+
### Security
|
|
103
|
+
- Web server API key authentication
|
|
104
|
+
- Web server rate limiting and CORS configuration
|
|
105
|
+
- File path validation for export/import operations
|
|
106
|
+
- Gateway endpoint configuration validation
|
|
107
|
+
|
|
108
|
+
### Developer Features
|
|
109
|
+
- c8 code coverage reporting with threshold checks
|
|
110
|
+
- Enhanced CLI organization with modular handlers
|
|
111
|
+
- Plugin validator with verbose mode
|
|
112
|
+
- Pre-commit hooks for code quality
|
|
113
|
+
|
|
114
|
+
## [1.9.0] - 2025-02-06
|
|
115
|
+
|
|
116
|
+
### Added
|
|
117
|
+
- Dynamic widget reflow and show/hide functionality (keys 1-4)
|
|
118
|
+
- Session TPS (transactions per second) column
|
|
119
|
+
- Session count display in sessions header
|
|
120
|
+
- Data Health widget with data freshness tracking
|
|
121
|
+
- Sound notifications for alerts
|
|
122
|
+
- Auto-detect terminal theme on first run
|
|
123
|
+
- Vi-mode navigation (hjkl keys)
|
|
124
|
+
- Favorites/bookmarks feature for quick navigation
|
|
125
|
+
- Tooltip hints system for first-run users
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
- Improved session sorting options (recent, context size, idle time, CPU, memory)
|
|
129
|
+
- Enhanced UI with theme persistence
|
|
130
|
+
|
|
131
|
+
### Fixed
|
|
132
|
+
- Arrow key navigation for session pages
|
|
133
|
+
- Network interface change handling
|
|
134
|
+
- Stale session TPS cleanup
|
|
135
|
+
- Toggle search binding error
|
|
136
|
+
|
|
137
|
+
## [1.8.5] - 2025-02-04
|
|
138
|
+
|
|
139
|
+
### Added
|
|
140
|
+
- Widget toggle feature (press 1-4 to show/hide)
|
|
141
|
+
|
|
142
|
+
## [1.8.4] - 2025-02-04
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
- Session duration display in session list
|
|
146
|
+
|
|
147
|
+
## [1.8.2] - 2025-02-03
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
- TPS calculation using correct session data source
|
|
151
|
+
|
|
152
|
+
## [1.8.0] - 2025-02-03
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
- Dashboard export functionality (JSON, CSV, markdown)
|
|
156
|
+
- Logger module for file-based logging
|
|
157
|
+
- Session sorting by CPU, memory, and load average
|
|
158
|
+
|
|
159
|
+
### Changed
|
|
160
|
+
- Read sessions directly from sessions.json for improved reliability
|
|
161
|
+
|
|
162
|
+
### Removed
|
|
163
|
+
- Load average display feature (rejected due to cross-platform inconsistencies)
|
|
164
|
+
|
|
165
|
+
## [1.7.3] - 2025-02-02
|
|
166
|
+
|
|
167
|
+
### Changed
|
|
168
|
+
- Stale sessions now displayed in gray instead of red
|
|
169
|
+
|
|
170
|
+
## [1.7.2] - 2025-02-02
|
|
171
|
+
|
|
172
|
+
### Changed
|
|
173
|
+
- Clock widget now uses local timezone
|
|
174
|
+
|
|
175
|
+
## [1.7.1] - 2025-02-02
|
|
176
|
+
|
|
177
|
+
### Added
|
|
178
|
+
- Clock widget displaying current time
|
|
179
|
+
- Log level filtering and colorizing
|
|
180
|
+
|
|
181
|
+
## [1.7.0] - 2025-02-01
|
|
182
|
+
|
|
183
|
+
### Added
|
|
184
|
+
- Network traffic sparkline visualization
|
|
185
|
+
- Top Processes widget
|
|
186
|
+
|
|
187
|
+
## [1.6.0] - 2025-01-31
|
|
188
|
+
|
|
189
|
+
### Added
|
|
190
|
+
- SQLite persistence for metrics and sessions
|
|
191
|
+
- Cache module with TTL support
|
|
192
|
+
- Adaptive refresh rate based on system load
|
|
193
|
+
|
|
194
|
+
## [1.5.1] - 2025-01-30
|
|
195
|
+
|
|
196
|
+
### Fixed
|
|
197
|
+
- Session navigation bounds checking
|
|
198
|
+
- Race condition in settings management
|
|
199
|
+
|
|
200
|
+
## [1.5.0] - 2025-01-30
|
|
201
|
+
|
|
202
|
+
### Added
|
|
203
|
+
- Alerts system with configurable thresholds
|
|
204
|
+
- Retry logic with exponential backoff
|
|
205
|
+
- Validation module for input sanitization
|
|
206
|
+
|
|
207
|
+
## [1.4.1] - 2025-01-29
|
|
208
|
+
|
|
209
|
+
### Added
|
|
210
|
+
- Interactive settings panel
|
|
211
|
+
- Version display in header
|
|
212
|
+
- UI polish and refinements
|
|
213
|
+
|
|
214
|
+
## [1.4.0] - 2025-01-28
|
|
215
|
+
|
|
216
|
+
### Added
|
|
217
|
+
- Interactive settings panel with real-time updates
|
|
218
|
+
- Mouse support for navigation
|
|
219
|
+
- Session detail view
|
|
220
|
+
|
|
221
|
+
### Changed
|
|
222
|
+
- Enhanced theme system with 4 customizable themes
|
|
223
|
+
|
|
224
|
+
## [1.3.0] - 2025-01-27
|
|
225
|
+
|
|
226
|
+
### Added
|
|
227
|
+
- Theme system with customizable color schemes
|
|
228
|
+
- Session search functionality
|
|
229
|
+
- Pagination for large session lists
|
|
230
|
+
|
|
231
|
+
## [1.2.0] - 2025-01-26
|
|
232
|
+
|
|
233
|
+
### Added
|
|
234
|
+
- GPU monitoring (basic support)
|
|
235
|
+
- Disk usage visualization
|
|
236
|
+
- Network interface monitoring
|
|
237
|
+
|
|
238
|
+
## [1.1.0] - 2025-01-25
|
|
239
|
+
|
|
240
|
+
### Added
|
|
241
|
+
- Memory usage display with progress bars
|
|
242
|
+
- CPU utilization sparkline
|
|
243
|
+
- System information panel
|
|
244
|
+
|
|
245
|
+
## [1.0.0] - 2025-01-24
|
|
246
|
+
|
|
247
|
+
### Added
|
|
248
|
+
- Initial release of Claw Dashboard
|
|
249
|
+
- Real-time OpenClaw session monitoring
|
|
250
|
+
- Basic CPU and memory metrics
|
|
251
|
+
- Terminal-based UI using blessed
|
|
252
|
+
- Cross-platform support (macOS, Linux)
|
|
253
|
+
- Session list with status indicators
|
|
254
|
+
- Auto-refresh with configurable interval
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Version Format
|
|
259
|
+
|
|
260
|
+
Versions follow [Semantic Versioning](https://semver.org/):
|
|
261
|
+
|
|
262
|
+
- **MAJOR** - Incompatible API changes or major feature rewrites
|
|
263
|
+
- **MINOR** - New functionality (backward compatible)
|
|
264
|
+
- **PATCH** - Bug fixes and small improvements (backward compatible)
|
|
265
|
+
|
|
266
|
+
## Categories
|
|
267
|
+
|
|
268
|
+
- **Added** - New features
|
|
269
|
+
- **Changed** - Changes to existing functionality
|
|
270
|
+
- **Deprecated** - Soon-to-be removed features
|
|
271
|
+
- **Removed** - Removed features
|
|
272
|
+
- **Fixed** - Bug fixes
|
|
273
|
+
- **Security** - Security improvements
|
|
274
|
+
|
|
275
|
+
## Release Notes Template
|
|
276
|
+
|
|
277
|
+
When adding a new release, use this template:
|
|
278
|
+
|
|
279
|
+
```markdown
|
|
280
|
+
## [X.Y.Z] - YYYY-MM-DD
|
|
281
|
+
|
|
282
|
+
### Added
|
|
283
|
+
- New feature description
|
|
284
|
+
|
|
285
|
+
### Changed
|
|
286
|
+
- Change description
|
|
287
|
+
|
|
288
|
+
### Fixed
|
|
289
|
+
- Bug fix description
|
|
290
|
+
|
|
291
|
+
### Security
|
|
292
|
+
- Security improvement description
|
|
293
|
+
```
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# Contributing to Claw Dashboard
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Claw Dashboard! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Workflow](#development-workflow)
|
|
10
|
+
- [Coding Standards](#coding-standards)
|
|
11
|
+
- [Testing](#testing)
|
|
12
|
+
- [Submitting Changes](#submitting-changes)
|
|
13
|
+
- [Commit Message Guidelines](#commit-message-guidelines)
|
|
14
|
+
- [Release Process](#release-process)
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
This project adheres to a code of conduct that we expect all contributors to follow:
|
|
19
|
+
|
|
20
|
+
- Be respectful and inclusive in all interactions
|
|
21
|
+
- Welcome newcomers and help them learn
|
|
22
|
+
- Focus on constructive feedback
|
|
23
|
+
- Accept constructive criticism gracefully
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
### Prerequisites
|
|
28
|
+
|
|
29
|
+
- **Node.js** v18 or higher
|
|
30
|
+
- **npm** v9 or higher
|
|
31
|
+
- **OpenClaw** installed and configured (for full integration testing)
|
|
32
|
+
|
|
33
|
+
### Setup
|
|
34
|
+
|
|
35
|
+
1. Fork the repository on GitHub
|
|
36
|
+
2. Clone your fork locally:
|
|
37
|
+
```bash
|
|
38
|
+
git clone https://github.com/YOUR_USERNAME/claw-dashboard.git
|
|
39
|
+
cd claw-dashboard
|
|
40
|
+
```
|
|
41
|
+
3. Install dependencies:
|
|
42
|
+
```bash
|
|
43
|
+
npm install
|
|
44
|
+
```
|
|
45
|
+
4. Run the dashboard:
|
|
46
|
+
```bash
|
|
47
|
+
npm start
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Development Workflow
|
|
51
|
+
|
|
52
|
+
### Branch Naming
|
|
53
|
+
|
|
54
|
+
Use descriptive branch names with the following prefixes:
|
|
55
|
+
|
|
56
|
+
- `feature/` - New features
|
|
57
|
+
- `fix/` - Bug fixes
|
|
58
|
+
- `docs/` - Documentation changes
|
|
59
|
+
- `refactor/` - Code refactoring
|
|
60
|
+
- `test/` - Test additions or updates
|
|
61
|
+
|
|
62
|
+
Examples:
|
|
63
|
+
```
|
|
64
|
+
feature/add-custom-widgets
|
|
65
|
+
fix/memory-leak-on-refresh
|
|
66
|
+
docs/update-api-examples
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Making Changes
|
|
70
|
+
|
|
71
|
+
1. Create a new branch from `main`:
|
|
72
|
+
```bash
|
|
73
|
+
git checkout -b feature/your-feature-name
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2. Make your changes following the [coding standards](#coding-standards)
|
|
77
|
+
|
|
78
|
+
3. Test your changes:
|
|
79
|
+
```bash
|
|
80
|
+
npm test
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
4. Update documentation if needed (README.md, API.md, CHANGELOG.md)
|
|
84
|
+
|
|
85
|
+
## Coding Standards
|
|
86
|
+
|
|
87
|
+
### JavaScript Style
|
|
88
|
+
|
|
89
|
+
- Use ES modules (`import`/`export`)
|
|
90
|
+
- Use 2 spaces for indentation
|
|
91
|
+
- Use semicolons
|
|
92
|
+
- Prefer `const` and `let` over `var`
|
|
93
|
+
- Use camelCase for variables and functions
|
|
94
|
+
- Use PascalCase for classes
|
|
95
|
+
- Use UPPER_SNAKE_CASE for constants
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
```javascript
|
|
99
|
+
// Good
|
|
100
|
+
const MAX_RETRIES = 3;
|
|
101
|
+
|
|
102
|
+
export async function fetchData() {
|
|
103
|
+
const result = await getData();
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class DataFetcher {
|
|
108
|
+
constructor() {
|
|
109
|
+
this.cache = new Map();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Bad
|
|
114
|
+
var MAX_RETRIES = 3;
|
|
115
|
+
|
|
116
|
+
function fetch_data() {
|
|
117
|
+
let result = getData();
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Code Organization
|
|
123
|
+
|
|
124
|
+
- Place all source files in `src/`
|
|
125
|
+
- Group related functionality into modules
|
|
126
|
+
- Keep functions focused and small
|
|
127
|
+
- Export only what's necessary from modules
|
|
128
|
+
|
|
129
|
+
### Configuration
|
|
130
|
+
|
|
131
|
+
All magic numbers and configurable values should be centralized in `src/config.js`:
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
// In src/config.js
|
|
135
|
+
export const CACHE_TTL = {
|
|
136
|
+
CPU: 1000,
|
|
137
|
+
MEMORY: 1000,
|
|
138
|
+
GPU: 5000,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// In your module
|
|
142
|
+
import { CACHE_TTL } from './config.js';
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Error Handling
|
|
146
|
+
|
|
147
|
+
Use the custom error classes from `src/errors.js`:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
import { GatewayError, DataFetchError } from './errors.js';
|
|
151
|
+
import logger from './logger.js';
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
const data = await fetchData();
|
|
155
|
+
} catch (error) {
|
|
156
|
+
logger.error('Failed to fetch:', error.message);
|
|
157
|
+
throw new GatewayError('Fetch failed', { cause: error });
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Logging
|
|
162
|
+
|
|
163
|
+
Use the logger module instead of `console.log`:
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
import logger from './logger.js';
|
|
167
|
+
|
|
168
|
+
logger.debug('Debug info'); // Only shows with DEBUG=1
|
|
169
|
+
logger.info('General info');
|
|
170
|
+
logger.warn('Warning message');
|
|
171
|
+
logger.error('Error message');
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Testing
|
|
175
|
+
|
|
176
|
+
### Running Tests
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Run all tests
|
|
180
|
+
npm test
|
|
181
|
+
|
|
182
|
+
# Run tests with coverage
|
|
183
|
+
npm run test:coverage
|
|
184
|
+
|
|
185
|
+
# Run tests in watch mode
|
|
186
|
+
npm test -- --watch
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Writing Tests
|
|
190
|
+
|
|
191
|
+
Place test files in the `tests/` directory with the naming pattern `*.test.js`:
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
// tests/my-feature.test.js
|
|
195
|
+
import { describe, test, expect } from '@jest/globals';
|
|
196
|
+
import { myFunction } from '../src/my-module.js';
|
|
197
|
+
|
|
198
|
+
describe('myFunction', () => {
|
|
199
|
+
test('should return expected result', () => {
|
|
200
|
+
const result = myFunction('input');
|
|
201
|
+
expect(result).toBe('expected output');
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('should handle errors gracefully', async () => {
|
|
205
|
+
await expect(myFunction(null)).rejects.toThrow();
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Test Guidelines
|
|
211
|
+
|
|
212
|
+
- Write tests for new functionality
|
|
213
|
+
- Ensure all existing tests pass before submitting
|
|
214
|
+
- Aim for meaningful coverage, not just high percentages
|
|
215
|
+
- Test edge cases and error conditions
|
|
216
|
+
- Use descriptive test names that explain the behavior
|
|
217
|
+
|
|
218
|
+
## Submitting Changes
|
|
219
|
+
|
|
220
|
+
### Pull Request Process
|
|
221
|
+
|
|
222
|
+
1. Ensure your branch is up to date with `main`:
|
|
223
|
+
```bash
|
|
224
|
+
git fetch origin
|
|
225
|
+
git rebase origin/main
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
2. Run the full test suite:
|
|
229
|
+
```bash
|
|
230
|
+
npm test
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
3. Update the CHANGELOG.md if applicable
|
|
234
|
+
|
|
235
|
+
4. Push your branch:
|
|
236
|
+
```bash
|
|
237
|
+
git push origin feature/your-feature-name
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
5. Create a Pull Request on GitHub with:
|
|
241
|
+
- Clear title describing the change
|
|
242
|
+
- Detailed description explaining what and why
|
|
243
|
+
- Reference any related issues (e.g., "Fixes #123")
|
|
244
|
+
- Screenshots/gifs for UI changes
|
|
245
|
+
|
|
246
|
+
### PR Review Process
|
|
247
|
+
|
|
248
|
+
- All PRs require at least one review
|
|
249
|
+
- Address review feedback promptly
|
|
250
|
+
- Be open to suggestions and changes
|
|
251
|
+
- Squash commits if requested
|
|
252
|
+
|
|
253
|
+
## Commit Message Guidelines
|
|
254
|
+
|
|
255
|
+
We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification:
|
|
256
|
+
|
|
257
|
+
### Format
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
<type>: <description>
|
|
261
|
+
|
|
262
|
+
[optional body]
|
|
263
|
+
|
|
264
|
+
[optional footer(s)]
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Types
|
|
268
|
+
|
|
269
|
+
| Type | Description |
|
|
270
|
+
|------|-------------|
|
|
271
|
+
| `feat` | New feature |
|
|
272
|
+
| `fix` | Bug fix |
|
|
273
|
+
| `docs` | Documentation changes |
|
|
274
|
+
| `style` | Code style changes (formatting, semicolons, etc.) |
|
|
275
|
+
| `refactor` | Code refactoring |
|
|
276
|
+
| `test` | Test additions or updates |
|
|
277
|
+
| `chore` | Build process or auxiliary tool changes |
|
|
278
|
+
|
|
279
|
+
### Examples
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
feat: add session sorting by token usage
|
|
283
|
+
|
|
284
|
+
fix: resolve memory leak in widget refresh cycle
|
|
285
|
+
docs: update API documentation for gateway manager
|
|
286
|
+
refactor: extract cache logic into separate module
|
|
287
|
+
test: add unit tests for error classes
|
|
288
|
+
chore: update dependencies to latest versions
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Rules
|
|
292
|
+
|
|
293
|
+
- Use present tense ("add feature" not "added feature")
|
|
294
|
+
- Use imperative mood ("move cursor" not "moves cursor")
|
|
295
|
+
- Don't capitalize the first letter
|
|
296
|
+
- No period at the end
|
|
297
|
+
- Keep the first line under 72 characters
|
|
298
|
+
|
|
299
|
+
## Release Process
|
|
300
|
+
|
|
301
|
+
We use an automated release script that handles versioning, building, signing, and tagging.
|
|
302
|
+
|
|
303
|
+
### Prerequisites
|
|
304
|
+
|
|
305
|
+
- Node.js v18+ with npm
|
|
306
|
+
- GPG key configured (for signed releases)
|
|
307
|
+
- GitHub CLI (`gh`) installed (for GitHub releases)
|
|
308
|
+
|
|
309
|
+
### Quick Release
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Patch release (1.0.0 → 1.0.1)
|
|
313
|
+
npm run release
|
|
314
|
+
|
|
315
|
+
# Minor release (1.0.0 → 1.1.0)
|
|
316
|
+
npm run release minor
|
|
317
|
+
|
|
318
|
+
# Major release (1.0.0 → 2.0.0)
|
|
319
|
+
npm run release major
|
|
320
|
+
|
|
321
|
+
# With GPG signing
|
|
322
|
+
npm run release:sign
|
|
323
|
+
|
|
324
|
+
# With GitHub release creation
|
|
325
|
+
npm run release:github
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Manual Release Steps
|
|
329
|
+
|
|
330
|
+
If you prefer to release manually:
|
|
331
|
+
|
|
332
|
+
1. Update version in `package.json`
|
|
333
|
+
2. Update CHANGELOG.md with release date
|
|
334
|
+
3. Build the project: `npm run build`
|
|
335
|
+
4. Create a git tag: `git tag vX.Y.Z`
|
|
336
|
+
5. Push tags: `git push origin vX.Y.Z`
|
|
337
|
+
6. Create a GitHub release with release notes
|
|
338
|
+
|
|
339
|
+
### Release Script Features
|
|
340
|
+
|
|
341
|
+
The automated release script (`scripts/release.js`):
|
|
342
|
+
|
|
343
|
+
- **Validates** the working directory is clean
|
|
344
|
+
- **Bumps** version in package.json (patch/minor/major)
|
|
345
|
+
- **Updates** CHANGELOG.md with new release date
|
|
346
|
+
- **Builds** the project with ESBuild (creates `dist/clawdash`)
|
|
347
|
+
- **Signs** releases with GPG (optional, use `--sign`)
|
|
348
|
+
- **Creates** git commit and annotated tag
|
|
349
|
+
- **Publishes** GitHub release (optional, use `--github`)
|
|
350
|
+
|
|
351
|
+
### Build System
|
|
352
|
+
|
|
353
|
+
We use **ESBuild** for bundling:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
# Production build (minified)
|
|
357
|
+
npm run build
|
|
358
|
+
|
|
359
|
+
# Development build (with source maps)
|
|
360
|
+
npm run build:dev
|
|
361
|
+
|
|
362
|
+
# Analyze bundle size
|
|
363
|
+
npm run build -- --analyze
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
The build creates:
|
|
367
|
+
- `dist/clawdash` - Bundled, minified executable
|
|
368
|
+
- `dist/clawdash.meta.json` - Bundle analysis metadata
|
|
369
|
+
|
|
370
|
+
## Questions?
|
|
371
|
+
|
|
372
|
+
If you have questions or need help:
|
|
373
|
+
|
|
374
|
+
- Open an issue on GitHub
|
|
375
|
+
- Check existing issues and discussions
|
|
376
|
+
- Review the [API documentation](docs/API.md)
|
|
377
|
+
|
|
378
|
+
Thank you for contributing!
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Claw Dashboard - Production Docker Image
|
|
2
|
+
# Multi-stage build for optimized image size
|
|
3
|
+
|
|
4
|
+
# Stage 1: Dependencies
|
|
5
|
+
FROM node:20-alpine AS dependencies
|
|
6
|
+
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
|
|
9
|
+
# Copy package files
|
|
10
|
+
COPY package.json package-lock.json ./
|
|
11
|
+
|
|
12
|
+
# Install production dependencies only
|
|
13
|
+
RUN npm ci --omit=dev && npm cache clean --force
|
|
14
|
+
|
|
15
|
+
# Stage 2: Production
|
|
16
|
+
FROM node:20-alpine AS production
|
|
17
|
+
|
|
18
|
+
# Add metadata labels
|
|
19
|
+
LABEL maintainer="Kevin Smith <kevin@example.com>"
|
|
20
|
+
LABEL org.opencontainers.image.title="Claw Dashboard"
|
|
21
|
+
LABEL org.opencontainers.image.description="A beautiful console dashboard for monitoring OpenClaw instances"
|
|
22
|
+
LABEL org.opencontainers.image.source="https://github.com/spleck/claw-dashboard"
|
|
23
|
+
LABEL org.opencontainers.image.licenses="MIT"
|
|
24
|
+
|
|
25
|
+
# Create non-root user for security
|
|
26
|
+
RUN addgroup -g 1000 -S claw && \
|
|
27
|
+
adduser -u 1000 -S claw -G claw
|
|
28
|
+
|
|
29
|
+
WORKDIR /app
|
|
30
|
+
|
|
31
|
+
# Copy production dependencies from dependencies stage
|
|
32
|
+
COPY --from=dependencies /app/node_modules ./node_modules
|
|
33
|
+
|
|
34
|
+
# Copy application files
|
|
35
|
+
COPY --chown=claw:claw index.js ./
|
|
36
|
+
COPY --chown=claw:claw src ./src
|
|
37
|
+
|
|
38
|
+
# Switch to non-root user
|
|
39
|
+
USER claw
|
|
40
|
+
|
|
41
|
+
# Expose any potential web interface port (for future use)
|
|
42
|
+
EXPOSE 18790
|
|
43
|
+
|
|
44
|
+
# Set environment variables
|
|
45
|
+
ENV NODE_ENV=production
|
|
46
|
+
ENV TERM=xterm-256color
|
|
47
|
+
|
|
48
|
+
# Health check
|
|
49
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
50
|
+
CMD node -e "console.log('healthy')" || exit 1
|
|
51
|
+
|
|
52
|
+
# Run the dashboard
|
|
53
|
+
ENTRYPOINT ["node", "index.js"]
|
|
54
|
+
CMD []
|