Skip to content

Commit 9d6e8b8

Browse files
committed
docs: document doctor plugin checks
1 parent f1e6177 commit 9d6e8b8

6 files changed

Lines changed: 38 additions & 4 deletions

File tree

src/commands/doctor-lint.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** CLI entrypoint for non-mutating doctor lint health checks. */
12
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
23
import { readConfigFileSnapshot } from "../config/config.js";
34
import { registerBundledHealthChecks } from "../flows/bundled-health-checks.js";
@@ -33,6 +34,12 @@ function detectMode(opts: DoctorLintCliOptions): "human" | "json" {
3334
return process.stdout.isTTY ? "human" : "json";
3435
}
3536

37+
/**
38+
* Runs registered doctor health checks in human or JSON mode and returns the lint exit code.
39+
*
40+
* Invalid config is reported before regular health checks because most checks need a parsed config
41+
* and workspace root.
42+
*/
3643
export async function runDoctorLintCli(
3744
runtime: RuntimeEnv,
3845
opts: DoctorLintCliOptions,

src/commands/doctor-memory-search.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Doctor diagnostics and repairs for memory search config, providers, and recall artifacts. */
12
import fsSync from "node:fs";
23
import {
34
findNormalizedProviderValue,
@@ -248,6 +249,7 @@ function buildDreamingArtifactIssueNote(audit: DreamingArtifactsAuditSummary): s
248249
].join("\n");
249250
}
250251

252+
/** Emits memory recall and dreaming artifact warnings for the active memory backend. */
251253
export async function noteMemoryRecallHealth(cfg: OpenClawConfig): Promise<void> {
252254
try {
253255
const context = await resolveRuntimeMemoryAuditContext(cfg);
@@ -279,6 +281,7 @@ export async function noteMemoryRecallHealth(cfg: OpenClawConfig): Promise<void>
279281
}
280282
}
281283

284+
/** Repairs fixable recall/dreaming artifacts after runtime repair confirmation. */
282285
export async function maybeRepairMemoryRecallHealth(params: {
283286
cfg: OpenClawConfig;
284287
prompter: DoctorPrompter;
@@ -390,10 +393,10 @@ function hasActiveAlternateMemoryPluginSlot(cfg: OpenClawConfig): boolean {
390393
}
391394

392395
/**
393-
* Check whether memory search has a usable embedding provider.
394-
* Runs as part of `openclaw doctor` — config-only checks where possible;
395-
* may spawn a short-lived probe process when `memory.backend=qmd` to verify
396-
* the configured `qmd` binary is available.
396+
* Checks whether memory search has a usable backend and embedding provider.
397+
*
398+
* Config-only checks are preferred, but QMD backends may spawn a short-lived probe process to
399+
* verify the configured binary from the agent workspace.
397400
*/
398401
export async function noteMemorySearchHealth(
399402
cfg: OpenClawConfig,

src/commands/doctor-platform-notes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Platform-specific doctor notes for macOS gateway launchd state and startup tuning. */
12
import { execFile } from "node:child_process";
23
import fs from "node:fs";
34
import os from "node:os";
@@ -18,6 +19,7 @@ function resolveHomeDir(): string {
1819
return process.env.HOME ?? os.homedir();
1920
}
2021

22+
/** Returns the macOS marker warning when LaunchAgent writes are locally disabled. */
2123
export function collectMacLaunchAgentOverrideWarning(deps?: {
2224
platform?: NodeJS.Platform;
2325
homeDir?: string;
@@ -42,13 +44,15 @@ export function collectMacLaunchAgentOverrideWarning(deps?: {
4244
].join("\n");
4345
}
4446

47+
/** Emits the macOS LaunchAgent override warning when present. */
4548
export async function noteMacLaunchAgentOverrides() {
4649
const warning = collectMacLaunchAgentOverrideWarning();
4750
if (warning) {
4851
note(warning, "Gateway (macOS)");
4952
}
5053
}
5154

55+
/** Returns a warning for stale OpenClaw updater launchd jobs left after interrupted updates. */
5256
export async function collectMacStaleOpenClawUpdateLaunchdJobsWarning(deps?: {
5357
platform?: NodeJS.Platform;
5458
findJobs?: typeof findStaleOpenClawUpdateLaunchdJobs;
@@ -80,6 +84,7 @@ export async function collectMacStaleOpenClawUpdateLaunchdJobsWarning(deps?: {
8084
].join("\n");
8185
}
8286

87+
/** Emits stale updater launchd job notes using the gateway service environment when available. */
8388
export async function noteMacStaleOpenClawUpdateLaunchdJobs(deps?: {
8489
platform?: NodeJS.Platform;
8590
findJobs?: typeof findStaleOpenClawUpdateLaunchdJobs;
@@ -122,6 +127,7 @@ function hasConfigGatewayCreds(cfg: OpenClawConfig): boolean {
122127
);
123128
}
124129

130+
/** Returns a warning for host-wide launchctl gateway auth env overrides. */
125131
export async function collectMacLaunchctlGatewayEnvOverrideWarning(
126132
cfg: OpenClawConfig,
127133
deps?: {
@@ -171,6 +177,7 @@ export async function collectMacLaunchctlGatewayEnvOverrideWarning(
171177
.join("\n");
172178
}
173179

180+
/** Emits macOS launchctl gateway auth override warnings. */
174181
export async function noteMacLaunchctlGatewayEnvOverrides(
175182
cfg: OpenClawConfig,
176183
deps?: {
@@ -200,6 +207,7 @@ async function resolveGatewayServiceEnvForPlatformNotes(deps?: {
200207
: baseEnv;
201208
}
202209

210+
/** Collects all macOS gateway platform warnings without emitting notes. */
203211
export async function collectMacGatewayPlatformWarnings(
204212
cfg: OpenClawConfig,
205213
deps?: {
@@ -246,6 +254,7 @@ function isTmpCompileCachePath(cachePath: string): boolean {
246254
);
247255
}
248256

257+
/** Emits startup tuning hints for low-power Linux hosts when env settings are suboptimal. */
249258
export function noteStartupOptimizationHints(
250259
env: NodeJS.ProcessEnv = process.env,
251260
deps?: {

src/commands/doctor-plugin-manifests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Doctor migration for legacy plugin manifest capability keys into contracts.* fields. */
12
import fs from "node:fs";
23
import path from "node:path";
34
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
@@ -90,6 +91,7 @@ function buildLegacyManifestContractMigration(params: {
9091
};
9192
}
9293

94+
/** Collects manifest rewrites needed to move legacy top-level capability keys under contracts. */
9395
export function collectLegacyPluginManifestContractMigrations(params?: {
9496
config?: OpenClawConfig;
9597
env?: NodeJS.ProcessEnv;
@@ -150,6 +152,7 @@ export function collectLegacyPluginManifestContractMigrations(params?: {
150152
return migrations.toSorted((left, right) => left.manifestPath.localeCompare(right.manifestPath));
151153
}
152154

155+
/** Prompts and rewrites legacy plugin manifest contract fields when doctor repair is enabled. */
153156
export async function maybeRepairLegacyPluginManifestContracts(params: {
154157
config?: OpenClawConfig;
155158
env?: NodeJS.ProcessEnv;

src/commands/doctor-plugin-registry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Doctor repairs for stale plugin registry entries, managed npm shadows, and peer links. */
12
import fs from "node:fs";
23
import path from "node:path";
34
import { isRecord } from "@openclaw/normalization-core/record-coerce";
@@ -246,6 +247,7 @@ function removeManagedNpmPackageLockDependency(params: {
246247
}
247248
}
248249

250+
/** Removes managed npm packages that shadow current bundled plugins when repair is enabled. */
249251
export function maybeRepairStaleManagedNpmBundledPlugins(
250252
params: PluginRegistryDoctorRepairParams,
251253
): boolean {
@@ -285,6 +287,7 @@ export function maybeRepairStaleManagedNpmBundledPlugins(
285287
return true;
286288
}
287289

290+
/** Removes local install records that shadow current bundled plugin sources. */
288291
export async function maybeRepairStaleLocalBundledPluginInstallRecords(
289292
params: PluginRegistryDoctorRepairParams,
290293
): Promise<string[]> {
@@ -315,6 +318,7 @@ export async function maybeRepairStaleLocalBundledPluginInstallRecords(
315318
return stale.map((record) => record.pluginId);
316319
}
317320

321+
/** Relinks managed npm plugin packages to the current OpenClaw host packages. */
318322
export async function maybeRepairManagedNpmOpenClawPeerLinks(
319323
params: PluginRegistryDoctorRepairParams,
320324
): Promise<boolean> {
@@ -382,6 +386,12 @@ async function loadInstallRecordsWithoutPluginIds(
382386
return records;
383387
}
384388

389+
/**
390+
* Runs plugin registry doctor repairs and refreshes the persisted plugin index when needed.
391+
*
392+
* Stale bundled shadows are removed before registry migration so the rebuilt index resolves the
393+
* current bundled source instead of an obsolete managed/local install record.
394+
*/
385395
export async function maybeRepairPluginRegistryState(
386396
params: PluginRegistryDoctorRepairParams,
387397
): Promise<OpenClawConfig> {

src/commands/doctor-post-upgrade.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** Post-upgrade validation probes for persisted plugin index and package extension entries. */
12
import crypto from "node:crypto";
23
import fsSync from "node:fs";
34
import fs from "node:fs/promises";
@@ -147,6 +148,7 @@ async function sha256OfFile(absPath: string): Promise<string | null> {
147148
}
148149
}
149150

151+
/** Runs post-upgrade plugin probes and returns structured findings for the caller to render. */
150152
export async function runPostUpgradeProbes(params: {
151153
installsPath?: string;
152154
stateDir?: string;

0 commit comments

Comments
 (0)