claw-dashboard 2.1.0 → 2.2.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/CHANGELOG.md +29 -1
- package/docs/API.md +1 -2
- package/index.js +32 -42
- package/package.json +23 -12
- package/src/auto-save.js +11 -5
- package/src/cli/export-snapshot.js +3 -1
- package/src/cli/import-snapshot.js +3 -1
- package/src/config.js +9 -15
- package/src/errors.js +0 -9
- package/src/security.js +6 -2
- package/src/snapshot.js +73 -26
- package/src/web-server.js +7 -10
- package/src/widgets/builtin-widgets.js +0 -94
- package/src/widgets/index.js +0 -1
- package/.c8rc.json +0 -38
- package/.dockerignore +0 -68
- package/.github/dependabot.yml +0 -45
- package/.github/pull_request_template.md +0 -39
- package/.github/workflows/ci.yml +0 -147
- package/.github/workflows/release.yml +0 -40
- package/.github/workflows/security.yml +0 -84
- package/.husky/pre-commit +0 -1
- package/.planning/codebase/ARCHITECTURE.md +0 -206
- package/.planning/codebase/INTEGRATIONS.md +0 -150
- package/.planning/codebase/STACK.md +0 -122
- package/.planning/codebase/STRUCTURE.md +0 -201
- package/CONTRIBUTING.md +0 -378
- package/Dockerfile +0 -54
- package/FEATURES.md +0 -307
- package/TODO.md +0 -28
- package/ai.openclaw.dashboard.plist +0 -35
- package/build-cjs.js +0 -127
- package/cjs-shim.js +0 -13
- package/dist/clawdash +0 -1729
- package/dist/clawdash.meta.json +0 -2236
- package/dist/widgets.cjs +0 -6511
- package/docker-compose.yml +0 -67
- package/esbuild.config.js +0 -158
- package/eslint.config.js +0 -56
- package/examples/plugins/README.md +0 -122
- package/examples/plugins/api-status/index.js +0 -294
- package/examples/plugins/api-status/plugin.json +0 -19
- package/examples/plugins/hello-world/index.js +0 -104
- package/examples/plugins/hello-world/plugin.json +0 -15
- package/examples/plugins/system-metrics-chart/index.js +0 -339
- package/examples/plugins/system-metrics-chart/plugin.json +0 -18
- package/examples/plugins/weather-widget/index.js +0 -136
- package/examples/plugins/weather-widget/plugin.json +0 -19
- package/index.cjs +0 -23005
- package/jest.config.js +0 -11
- package/scripts/release.js +0 -595
- package/src/database.js +0 -734
- package/tests/alerts.test.js +0 -437
- package/tests/auto-save.test.js +0 -529
- package/tests/cache.test.js +0 -317
- package/tests/cli.test.js +0 -351
- package/tests/command-palette.test.js +0 -320
- package/tests/config-processor.test.js +0 -452
- package/tests/config-validator.test.js +0 -710
- package/tests/config-watcher.test.js +0 -594
- package/tests/config.test.js +0 -755
- package/tests/database.test.js +0 -438
- package/tests/errors.test.js +0 -189
- package/tests/example-plugins.test.js +0 -624
- package/tests/integration.test.js +0 -1321
- package/tests/loading-states.test.js +0 -300
- package/tests/manifest-validation-on-load.test.js +0 -671
- package/tests/performance-monitor.test.js +0 -190
- package/tests/plugin-api-rate-limit.test.js +0 -302
- package/tests/plugin-errors.test.js +0 -311
- package/tests/plugin-lifecycle-e2e.test.js +0 -1036
- package/tests/plugin-reload.test.js +0 -764
- package/tests/rate-limiter.test.js +0 -539
- package/tests/retry.test.js +0 -308
- package/tests/security.test.js +0 -411
- package/tests/settings-modal.test.js +0 -226
- package/tests/theme-selector.test.js +0 -57
- package/tests/utils.js +0 -242
- package/tests/utils.test.js +0 -317
- package/tests/validate-plugin-cli.test.js +0 -359
- package/tests/validation.test.js +0 -837
- package/tests/web-server.test.js +0 -646
- package/tests/widget-arrange-mode.test.js +0 -183
- package/tests/widget-config-hot-reload.test.js +0 -465
- package/tests/widget-dependency.test.js +0 -591
- package/tests/widget-error-boundary.test.js +0 -749
- package/tests/widget-error-isolation.test.js +0 -469
- package/tests/widget-integration.test.js +0 -1147
- package/tests/widget-refresh-intervals.test.js +0 -284
- package/tests/worker-pool.test.js +0 -522
|
@@ -1,201 +0,0 @@
|
|
|
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*
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,378 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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 []
|