clawkit-doctor 1.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/README.md +28 -0
- package/bin/index.js +118 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ClawKit Doctor
|
|
2
|
+
|
|
3
|
+
> Instant environment diagnostic tool for OpenClaw.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Simply run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx clawkit-doctor@latest
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
No installation required.
|
|
14
|
+
|
|
15
|
+
## What it checks
|
|
16
|
+
|
|
17
|
+
1. **Node.js Version**: Ensures you are running Node.js v18+.
|
|
18
|
+
2. **Config Directory**: Checks if `~/.openclaw` exists.
|
|
19
|
+
3. **Config File**: Checks if `clawhub.json` is present.
|
|
20
|
+
4. **Permissions**: Verifies write access to the config directory.
|
|
21
|
+
5. **Connectivity**: Checks if the local agent is running on port 3000.
|
|
22
|
+
|
|
23
|
+
## Publishing (For Maintainers)
|
|
24
|
+
|
|
25
|
+
To publish a new version:
|
|
26
|
+
|
|
27
|
+
1. Update the version in `package.json`.
|
|
28
|
+
2. Run `npm publish --access public`.
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
const ora = require('ora');
|
|
8
|
+
const http = require('http');
|
|
9
|
+
|
|
10
|
+
console.clear();
|
|
11
|
+
console.log(chalk.cyan.bold('\n🦞 ClawKit Doctor starting...\n'));
|
|
12
|
+
|
|
13
|
+
const steps = [
|
|
14
|
+
checkNodeVersion,
|
|
15
|
+
checkConfigDir,
|
|
16
|
+
checkConfigFile,
|
|
17
|
+
checkPermissions,
|
|
18
|
+
checkAgentConnection,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
async function run() {
|
|
22
|
+
for (const step of steps) {
|
|
23
|
+
await step();
|
|
24
|
+
}
|
|
25
|
+
console.log(chalk.cyan.bold('\n✅ Diagnosis Complete. Screenshot this if you need help!\n'));
|
|
26
|
+
console.log(chalk.gray('For more help, visit: https://getclawkit.com/docs\n'));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
run().catch(err => {
|
|
30
|
+
console.error(chalk.red('\n❌ Unexpected Error:'), err);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// --- Checks ---
|
|
35
|
+
|
|
36
|
+
async function checkNodeVersion() {
|
|
37
|
+
const spinner = ora('Checking Node.js version...').start();
|
|
38
|
+
const version = process.version;
|
|
39
|
+
const major = parseInt(version.substring(1).split('.')[0], 10);
|
|
40
|
+
|
|
41
|
+
if (major >= 18) {
|
|
42
|
+
spinner.succeed(chalk.green(`Node.js found: ${version}`));
|
|
43
|
+
} else {
|
|
44
|
+
spinner.fail(chalk.red(`Node.js ${version} is too old. Please install Node.js v18+.`));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function checkConfigDir() {
|
|
49
|
+
const spinner = ora('Checking Config Directory...').start();
|
|
50
|
+
const homeDir = os.homedir();
|
|
51
|
+
const configPath = path.join(homeDir, '.openclaw');
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await fs.promises.access(configPath);
|
|
55
|
+
spinner.succeed(chalk.green(`Config directory exists at: ${configPath}`));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
spinner.fail(chalk.red(`Config directory missing at ${configPath}. Run 'clawhub init' first.`));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function checkConfigFile() {
|
|
62
|
+
const spinner = ora('Checking Config File...').start();
|
|
63
|
+
const homeDir = os.homedir();
|
|
64
|
+
const configFilePath = path.join(homeDir, '.openclaw', 'clawhub.json');
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
await fs.promises.access(configFilePath);
|
|
68
|
+
spinner.succeed(chalk.green('Config file found (clawhub.json).'));
|
|
69
|
+
} catch (error) {
|
|
70
|
+
spinner.fail(chalk.yellow('Config file missing (clawhub.json). Use Config Generator to create one.'));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function checkPermissions() {
|
|
75
|
+
const spinner = ora('Checking Directory Permissions...').start();
|
|
76
|
+
const homeDir = os.homedir();
|
|
77
|
+
const configPath = path.join(homeDir, '.openclaw');
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
// Only check if dir exists
|
|
81
|
+
if (fs.existsSync(configPath)) {
|
|
82
|
+
await fs.promises.access(configPath, fs.constants.W_OK);
|
|
83
|
+
spinner.succeed(chalk.green('Write permission OK for ~/.openclaw'));
|
|
84
|
+
} else {
|
|
85
|
+
spinner.info(chalk.gray('Skipping permission check (directory missing).'));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
} catch (error) {
|
|
89
|
+
spinner.fail(chalk.red('No write permission for ~/.openclaw. Fix ownership with: sudo chown -R $(whoami) ~/.openclaw'));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function checkAgentConnection() {
|
|
94
|
+
const spinner = ora('Checking Local Agent (Port 3000)...').start();
|
|
95
|
+
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
const req = http.get('http://localhost:3000', (res) => {
|
|
98
|
+
spinner.succeed(chalk.green('Local Agent Port (3000) is OPEN.'));
|
|
99
|
+
resolve();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
req.on('error', (e) => {
|
|
103
|
+
if (e.code === 'ECONNREFUSED') {
|
|
104
|
+
spinner.info(chalk.gray('Port 3000 is free (Agent not running).'));
|
|
105
|
+
} else {
|
|
106
|
+
spinner.info(chalk.gray(`Network check skipped: ${e.message}`));
|
|
107
|
+
}
|
|
108
|
+
resolve();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
req.setTimeout(2000, () => {
|
|
112
|
+
message = 'Connection timed out';
|
|
113
|
+
req.destroy();
|
|
114
|
+
spinner.info(chalk.gray('Network check timed out.'));
|
|
115
|
+
resolve();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clawkit-doctor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Diagnostic tool for OpenClaw environment",
|
|
5
|
+
"main": "bin/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"clawkit-doctor": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"openclaw",
|
|
14
|
+
"diagnostic",
|
|
15
|
+
"doctor",
|
|
16
|
+
"cli"
|
|
17
|
+
],
|
|
18
|
+
"author": "OpenClaw Team",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"chalk": "^4.1.2",
|
|
22
|
+
"ora": "^5.4.1"
|
|
23
|
+
}
|
|
24
|
+
}
|