Files
Shade/packages/shade-cli/src/commands/doctor.ts
Sterister e6fdf31b49
Some checks failed
Test / test (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
release(v4.0.0): Shade GA — V3.x consolidation + audit prep
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire
format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers
byte-for-byte. The version bump is semantic: audit-cycle complete,
opt-in surface fully exposed, threat model refreshed for every new
surface.

Highlights:
- All 24 @shade/* packages bumped to 4.0.0 in lockstep.
- CHANGELOG 4.0.0 section is the canonical manifest of what landed.
- THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12
  Web-Worker boundary) + residual-risks table refreshed.
- OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox,
  bridge, observer, /metrics, /healthz, /ready.
- MIGRATION 0.3.x → 4.0 documented + smoke-tested against
  shade migrate-storage on a real SQLite DB.
- docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer.
- scripts/soak.ts harness for the GA-stable 2-week soak window.
- All V*.md plans archived under docs/archive/ with Status: Done.
- Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen
  non-realtime stack.

Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green.
Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports
  version 4.0.0 on /health.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 18:35:35 +02:00

75 lines
2.3 KiB
TypeScript

import { tryLoadConfig } from '../config.js';
import { existsSync } from 'fs';
export interface DoctorOptions {
cwd?: string;
}
/**
* Diagnose common setup issues.
*/
export async function doctorCommand(opts: DoctorOptions = {}): Promise<void> {
let ok = true;
console.log('\x1b[33mShade doctor\x1b[0m\n');
// 1. Config loadable?
const configResult = tryLoadConfig(opts.cwd);
if (configResult.ok) {
console.log(' \x1b[32m✓\x1b[0m Config loaded from .shaderc.json or env vars');
const config = configResult.config;
console.log(` prekeyServer: ${config.prekeyServer}`);
console.log(` storage: ${config.storage}`);
// 2. Storage path accessible?
if (config.storage.startsWith('sqlite:')) {
const path = config.storage.slice('sqlite:'.length);
const dir = path.substring(0, path.lastIndexOf('/')) || '.';
if (existsSync(dir)) {
console.log(` \x1b[32m✓\x1b[0m Storage directory exists: ${dir}`);
} else {
console.log(` \x1b[31m✗\x1b[0m Storage directory missing: ${dir}`);
ok = false;
}
}
// 3. Prekey server reachable?
try {
const res = await fetch(`${config.prekeyServer}/health`, {
signal: AbortSignal.timeout(5000),
});
if (res.ok) {
console.log(` \x1b[32m✓\x1b[0m Prekey server is reachable`);
} else {
console.log(` \x1b[31m✗\x1b[0m Prekey server returned HTTP ${res.status}`);
ok = false;
}
} catch (err) {
console.log(` \x1b[31m✗\x1b[0m Cannot reach prekey server: ${(err as Error).message}`);
ok = false;
}
// 4. Observer token set?
if (config.observerToken) {
if (config.observerToken.length >= 16) {
console.log(` \x1b[32m✓\x1b[0m Observer token is set and long enough`);
} else {
console.log(` \x1b[31m✗\x1b[0m Observer token must be at least 16 characters`);
ok = false;
}
} else {
console.log(` \x1b[90m○\x1b[0m Observer token not set (dashboard disabled)`);
}
} else {
console.log(` \x1b[31m✗\x1b[0m ${configResult.error}`);
ok = false;
}
console.log();
if (ok) {
console.log('\x1b[32mAll checks passed.\x1b[0m');
} else {
console.log('\x1b[31mSome checks failed. Fix the issues above and re-run.\x1b[0m');
process.exitCode = 1;
}
}