惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
D
Docker
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
GbyAI
GbyAI
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
M
MIT News - Artificial intelligence
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
B
Blog RSS Feed
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale
Vercel News
Vercel News
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
U
Unit 42

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(plugins): add doctor registry repair · openclaw/openc...
vincentkoc · 2026-04-26 · via Recent Commits to openclaw:main

@@ -0,0 +1,158 @@

1+

import { formatCliCommand } from "../cli/command-format.js";

2+

import type { OpenClawConfig } from "../config/types.openclaw.js";

3+

import type { PluginInstallRecord } from "../config/types.plugins.js";

4+

import {

5+

readPersistedPluginInstallLedger,

6+

resolvePluginInstallLedgerStorePath,

7+

withoutPluginInstallRecords,

8+

writePersistedPluginInstallLedger,

9+

type PluginInstallLedgerStoreOptions,

10+

} from "../plugins/install-ledger-store.js";

11+

import { refreshPluginRegistry } from "../plugins/plugin-registry.js";

12+

import { note } from "../terminal/note.js";

13+

import { shortenHomePath } from "../utils.js";

14+

import type { DoctorPrompter } from "./doctor-prompter.js";

15+

import {

16+

DISABLE_PLUGIN_REGISTRY_MIGRATION_ENV,

17+

migratePluginRegistryForInstall,

18+

preflightPluginRegistryInstallMigration,

19+

type PluginRegistryInstallMigrationParams,

20+

} from "./doctor/shared/plugin-registry-migration.js";

21+22+

type PluginRegistryDoctorRepairParams = Omit<PluginRegistryInstallMigrationParams, "config"> &

23+

PluginInstallLedgerStoreOptions & {

24+

config: OpenClawConfig;

25+

prompter: Pick<DoctorPrompter, "shouldRepair">;

26+

};

27+28+

type LegacyInstallLedgerMigrationResult = {

29+

config: OpenClawConfig;

30+

migrated: boolean;

31+

recordCount: number;

32+

};

33+34+

function countRecords(records: Record<string, unknown> | undefined): number {

35+

return Object.keys(records ?? {}).length;

36+

}

37+38+

function mergeInstallRecords(

39+

legacyRecords: Record<string, PluginInstallRecord>,

40+

ledgerRecords: Record<string, PluginInstallRecord> | undefined,

41+

): Record<string, PluginInstallRecord> {

42+

return {

43+

...legacyRecords,

44+

...(ledgerRecords ?? {}),

45+

};

46+

}

47+48+

async function maybeMigrateLegacyInstallLedger(

49+

params: PluginRegistryDoctorRepairParams,

50+

): Promise<LegacyInstallLedgerMigrationResult> {

51+

const legacyRecords = params.config.plugins?.installs;

52+

const legacyCount = countRecords(legacyRecords);

53+

if (!legacyRecords || legacyCount === 0) {

54+

return {

55+

config: params.config,

56+

migrated: false,

57+

recordCount: 0,

58+

};

59+

}

60+61+

const ledgerPath = resolvePluginInstallLedgerStorePath(params);

62+

if (!params.prompter.shouldRepair) {

63+

note(

64+

[

65+

`Legacy plugin install records still live in config at \`plugins.installs\`.`,

66+

`Repair with ${formatCliCommand("openclaw doctor --fix")} to move them to ${shortenHomePath(ledgerPath)} and remove the config copy.`,

67+

].join("\n"),

68+

"Plugin registry",

69+

);

70+

return {

71+

config: params.config,

72+

migrated: false,

73+

recordCount: legacyCount,

74+

};

75+

}

76+77+

const existingLedger = await readPersistedPluginInstallLedger(params);

78+

const nextRecords = mergeInstallRecords(legacyRecords, existingLedger?.records);

79+

await writePersistedPluginInstallLedger(nextRecords, params);

80+

const nextConfig = withoutPluginInstallRecords(params.config);

81+

note(

82+

[

83+

`Moved ${legacyCount} legacy plugin install record${legacyCount === 1 ? "" : "s"} from config to ${shortenHomePath(ledgerPath)}.`,

84+

"Removed the legacy `plugins.installs` config copy.",

85+

].join("\n"),

86+

"Plugin registry",

87+

);

88+

return {

89+

config: nextConfig,

90+

migrated: true,

91+

recordCount: legacyCount,

92+

};

93+

}

94+95+

export async function maybeRepairPluginRegistryState(

96+

params: PluginRegistryDoctorRepairParams,

97+

): Promise<OpenClawConfig> {

98+

let nextConfig = params.config;

99+

const ledgerMigration = await maybeMigrateLegacyInstallLedger(params);

100+

nextConfig = ledgerMigration.config;

101+102+

const migrationParams = {

103+

...params,

104+

config: nextConfig,

105+

};

106+

const preflight = preflightPluginRegistryInstallMigration(migrationParams);

107+

for (const warning of preflight.deprecationWarnings) {

108+

note(warning, "Plugin registry");

109+

}

110+

if (preflight.action === "disabled") {

111+

note(

112+

`${DISABLE_PLUGIN_REGISTRY_MIGRATION_ENV} is set; skipping plugin registry repair.`,

113+

"Plugin registry",

114+

);

115+

return nextConfig;

116+

}

117+118+

if (!params.prompter.shouldRepair) {

119+

if (preflight.action === "migrate") {

120+

note(

121+

[

122+

"Persisted plugin registry is missing or stale.",

123+

`Repair with ${formatCliCommand("openclaw doctor --fix")} to rebuild ${shortenHomePath(preflight.filePath)} from enabled plugins.`,

124+

].join("\n"),

125+

"Plugin registry",

126+

);

127+

}

128+

return nextConfig;

129+

}

130+131+

if (preflight.action === "migrate") {

132+

const result = await migratePluginRegistryForInstall(migrationParams);

133+

if (result.migrated) {

134+

const total = result.current.plugins.length;

135+

const enabled = result.current.plugins.filter((plugin) => plugin.enabled).length;

136+

note(

137+

`Plugin registry rebuilt: ${enabled}/${total} enabled plugins indexed.`,

138+

"Plugin registry",

139+

);

140+

}

141+

return nextConfig;

142+

}

143+144+

if (ledgerMigration.migrated) {

145+

const index = await refreshPluginRegistry({

146+

...migrationParams,

147+

reason: "migration",

148+

});

149+

const total = index.plugins.length;

150+

const enabled = index.plugins.filter((plugin) => plugin.enabled).length;

151+

note(

152+

`Plugin registry refreshed: ${enabled}/${total} enabled plugins indexed.`,

153+

"Plugin registry",

154+

);

155+

}

156+157+

return nextConfig;

158+

}