2026-04-11 00:38:00 +02:00
|
|
|
import { tryLoadConfig } from '../config.js';
|
|
|
|
|
import { existsSync } from 'fs';
|
|
|
|
|
|
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
|
|
|
export interface DoctorOptions {
|
|
|
|
|
cwd?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 00:38:00 +02:00
|
|
|
/**
|
|
|
|
|
* Diagnose common setup issues.
|
|
|
|
|
*/
|
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
|
|
|
export async function doctorCommand(opts: DoctorOptions = {}): Promise<void> {
|
2026-04-11 00:38:00 +02:00
|
|
|
let ok = true;
|
|
|
|
|
console.log('\x1b[33mShade doctor\x1b[0m\n');
|
|
|
|
|
|
|
|
|
|
// 1. Config loadable?
|
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
|
|
|
const configResult = tryLoadConfig(opts.cwd);
|
2026-04-11 00:38:00 +02:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|