clawfix 0.1.0 → 0.2.1
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/bin/clawfix.js +79 -11
- package/package.json +1 -1
package/bin/clawfix.js
CHANGED
|
@@ -15,7 +15,14 @@ import { createHash } from 'node:crypto';
|
|
|
15
15
|
|
|
16
16
|
// --- Config ---
|
|
17
17
|
const API_URL = process.env.CLAWFIX_API || 'https://clawfix.dev';
|
|
18
|
-
const VERSION = '0.
|
|
18
|
+
const VERSION = '0.2.0';
|
|
19
|
+
|
|
20
|
+
// --- Flags ---
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const DRY_RUN = args.includes('--dry-run') || args.includes('-n');
|
|
23
|
+
const SHOW_DATA = args.includes('--show-data') || args.includes('-d');
|
|
24
|
+
const AUTO_SEND = process.env.CLAWFIX_AUTO === '1' || args.includes('--yes') || args.includes('-y');
|
|
25
|
+
const SHOW_HELP = args.includes('--help') || args.includes('-h');
|
|
19
26
|
|
|
20
27
|
// --- Colors ---
|
|
21
28
|
const c = {
|
|
@@ -77,8 +84,41 @@ function sanitizeConfig(config) {
|
|
|
77
84
|
|
|
78
85
|
// --- Main ---
|
|
79
86
|
async function main() {
|
|
87
|
+
if (SHOW_HELP) {
|
|
88
|
+
console.log(`
|
|
89
|
+
🦞 ClawFix v${VERSION} — AI-Powered OpenClaw Diagnostic
|
|
90
|
+
|
|
91
|
+
Usage: npx clawfix [options]
|
|
92
|
+
|
|
93
|
+
Options:
|
|
94
|
+
--dry-run, -n Scan locally only — shows what would be collected, sends nothing
|
|
95
|
+
--show-data, -d Display the full diagnostic payload before asking to send
|
|
96
|
+
--yes, -y Skip confirmation prompt and send automatically
|
|
97
|
+
--help, -h Show this help message
|
|
98
|
+
|
|
99
|
+
Environment:
|
|
100
|
+
CLAWFIX_API Override API URL (default: https://clawfix.dev)
|
|
101
|
+
CLAWFIX_AUTO=1 Same as --yes
|
|
102
|
+
|
|
103
|
+
Security:
|
|
104
|
+
• All API keys, tokens, and passwords are automatically redacted
|
|
105
|
+
• Your hostname is SHA-256 hashed (only first 8 chars sent)
|
|
106
|
+
• No file contents are read (only existence checks)
|
|
107
|
+
• Nothing is sent without your explicit approval (unless --yes)
|
|
108
|
+
• Source code: https://github.com/arcaboteth/clawfix
|
|
109
|
+
|
|
110
|
+
Examples:
|
|
111
|
+
npx clawfix # Interactive scan + optional AI analysis
|
|
112
|
+
npx clawfix --dry-run # See what data would be collected (sends nothing)
|
|
113
|
+
npx clawfix --show-data # Show full payload before asking to send
|
|
114
|
+
npx clawfix --yes # Auto-send for CI/scripting
|
|
115
|
+
`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
80
119
|
console.log('');
|
|
81
120
|
console.log(c.cyan(`🦞 ClawFix v${VERSION} — AI-Powered OpenClaw Diagnostic`));
|
|
121
|
+
if (DRY_RUN) console.log(c.yellow(' 🔍 DRY RUN MODE — nothing will be sent'));
|
|
82
122
|
console.log(c.cyan('━'.repeat(50)));
|
|
83
123
|
console.log('');
|
|
84
124
|
|
|
@@ -150,7 +190,10 @@ async function main() {
|
|
|
150
190
|
const gatewayPort = config?.gateway?.port || 18789;
|
|
151
191
|
const gatewayPid = run('pgrep -f "openclaw.*gateway"') || '';
|
|
152
192
|
|
|
153
|
-
|
|
193
|
+
// Extract the actual status line, not config warnings
|
|
194
|
+
const statusLine = gatewayStatus.split('\n').find(l => /runtime:|listening|running|stopped|not running/i.test(l))
|
|
195
|
+
|| gatewayStatus.split('\n')[0];
|
|
196
|
+
console.log(` Status: ${statusLine.trim()}`);
|
|
154
197
|
if (gatewayPid) console.log(` PID: ${gatewayPid}`);
|
|
155
198
|
console.log(` Port: ${gatewayPort}`);
|
|
156
199
|
|
|
@@ -256,7 +299,10 @@ async function main() {
|
|
|
256
299
|
|
|
257
300
|
const issues = [];
|
|
258
301
|
|
|
259
|
-
|
|
302
|
+
// Check actual gateway status — ignore config warnings in output
|
|
303
|
+
const gatewayRunning = /running.*pid|state active|listening/i.test(gatewayStatus);
|
|
304
|
+
const gatewayFailed = /not running|failed to start|stopped|inactive/i.test(gatewayStatus);
|
|
305
|
+
if (gatewayFailed || (!gatewayRunning && !/warning/i.test(gatewayStatus))) {
|
|
260
306
|
issues.push({ severity: 'critical', text: 'Gateway is not running' });
|
|
261
307
|
}
|
|
262
308
|
if (/EADDRINUSE/i.test(errorLogs)) {
|
|
@@ -335,10 +381,32 @@ async function main() {
|
|
|
335
381
|
},
|
|
336
382
|
};
|
|
337
383
|
|
|
384
|
+
// --- Show collected data ---
|
|
385
|
+
if (DRY_RUN || SHOW_DATA) {
|
|
386
|
+
console.log('');
|
|
387
|
+
console.log(c.bold('📦 Data that would be sent:'));
|
|
388
|
+
console.log(c.cyan('━'.repeat(50)));
|
|
389
|
+
console.log(JSON.stringify(diagnostic, null, 2));
|
|
390
|
+
console.log(c.cyan('━'.repeat(50)));
|
|
391
|
+
console.log('');
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (DRY_RUN) {
|
|
395
|
+
console.log(c.yellow('🔍 Dry run complete — nothing was sent.'));
|
|
396
|
+
console.log('');
|
|
397
|
+
console.log('To send this data for AI analysis:');
|
|
398
|
+
console.log(c.cyan(' npx clawfix'));
|
|
399
|
+
console.log('');
|
|
400
|
+
console.log(c.cyan('🦞 ClawFix — made by Arca (arcabot.eth)'));
|
|
401
|
+
console.log(c.cyan(' https://clawfix.dev | https://x.com/arcaboteth'));
|
|
402
|
+
console.log('');
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
|
|
338
406
|
// --- Send for AI analysis ---
|
|
339
407
|
if (issues.length === 0) {
|
|
340
408
|
console.log(c.green('Your OpenClaw is looking good! No fixes needed.'));
|
|
341
|
-
console.log(`If you're still having issues,
|
|
409
|
+
console.log(`If you're still having issues, run with --show-data to see what would be collected.`);
|
|
342
410
|
console.log('');
|
|
343
411
|
console.log(c.cyan(`🦞 ClawFix — made by Arca (arcabot.eth)`));
|
|
344
412
|
console.log(c.cyan(` https://clawfix.dev | https://x.com/arcaboteth`));
|
|
@@ -347,13 +415,13 @@ async function main() {
|
|
|
347
415
|
}
|
|
348
416
|
|
|
349
417
|
console.log(c.bold('Want AI-powered fixes? Send this diagnostic for analysis.'));
|
|
350
|
-
console.log('
|
|
418
|
+
console.log('');
|
|
419
|
+
console.log(c.dim('Data sent: OS, versions, OpenClaw config (secrets redacted), error logs'));
|
|
420
|
+
console.log(c.dim('NOT sent: API keys, file contents, chat history, real hostname'));
|
|
421
|
+
console.log(c.dim('Inspect first: npx clawfix --dry-run'));
|
|
351
422
|
console.log('');
|
|
352
423
|
|
|
353
|
-
|
|
354
|
-
const autoSend = process.env.CLAWFIX_AUTO === '1' || process.argv.includes('--yes') || process.argv.includes('-y');
|
|
355
|
-
|
|
356
|
-
let shouldSend = autoSend;
|
|
424
|
+
let shouldSend = AUTO_SEND;
|
|
357
425
|
if (!shouldSend) {
|
|
358
426
|
const readline = await import('node:readline');
|
|
359
427
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -366,8 +434,8 @@ async function main() {
|
|
|
366
434
|
|
|
367
435
|
if (!shouldSend) {
|
|
368
436
|
console.log('');
|
|
369
|
-
console.log('No problem!
|
|
370
|
-
console.log(c.cyan(
|
|
437
|
+
console.log('No problem! Review data first with:');
|
|
438
|
+
console.log(c.cyan(' npx clawfix --dry-run'));
|
|
371
439
|
console.log('');
|
|
372
440
|
return;
|
|
373
441
|
}
|