refactor: remove 3,543 lines of redundant runtime and tests (#115961)

* refactor: remove 3,543 lines of redundant runtime and tests

* refactor: ratchet production environment variable budget
This commit is contained in:
Peter Steinberger
2026-07-29 11:43:41 -04:00
committed by GitHub
parent 190307137a
commit 5bfc65d7f4
99 changed files with 4128 additions and 7671 deletions

View File

@@ -53,13 +53,7 @@ function countEnabledPlugins(plugins: readonly { enabled: boolean }[]): number {
}
function formatRegistryState(state: "missing" | "fresh" | "stale"): string {
if (state === "fresh") {
return theme.success(state);
}
if (state === "stale") {
return theme.warn(state);
}
return theme.warn(state);
return state === "fresh" ? theme.success(state) : theme.warn(state);
}
function reportMissingPlugin(id: string) {
@@ -67,10 +61,6 @@ function reportMissingPlugin(id: string) {
return defaultRuntime.exit(1);
}
function matchesPluginId(plugin: { id: string }, id: string) {
return plugin.id === id;
}
function isConfigSelectedShadowDiagnostic(entry: { level?: string; message?: string }): boolean {
return (
entry.level === "warn" &&
@@ -207,7 +197,7 @@ async function runPluginsEnableCommandUnlocked(idInput: string): Promise<void> {
const cfg = (snapshot.sourceConfig ?? snapshot.config) as OpenClawConfig;
const report = buildPluginRegistrySnapshotReport({ config: cfg });
id = normalizePluginId(id);
if (!report.plugins.some((plugin) => matchesPluginId(plugin, id))) {
if (!report.plugins.some((plugin) => plugin.id === id)) {
return reportMissingPlugin(id);
}
const enableResult = enableExplicitlySelectedPluginInConfig(cfg, id, {
@@ -272,7 +262,7 @@ async function runPluginsDisableCommandUnlocked(idInput: string): Promise<void>
const cfg = (snapshot.sourceConfig ?? snapshot.config) as OpenClawConfig;
const report = buildPluginRegistrySnapshotReport({ config: cfg });
id = normalizePluginId(id);
if (!report.plugins.some((plugin) => matchesPluginId(plugin, id))) {
if (!report.plugins.some((plugin) => plugin.id === id)) {
return reportMissingPlugin(id);
}
const next = setPluginEnabledInConfig(cfg, id, false, {
@@ -540,25 +530,15 @@ function classifyMarketplaceFeedFallback(error: string | undefined): string | un
if (!text) {
return undefined;
}
if (text.includes("offline mode")) {
return "offline";
}
if (text.includes("checksum mismatch")) {
return "checksum_mismatch";
}
if (text.includes("schema")) {
return "schema";
}
if (/http\s+304/u.test(text)) {
return "not_modified";
}
if (/http\s+\d{3}/u.test(text)) {
return "http_error";
}
if (text.includes("timed out") || text.includes("timeout")) {
return "timeout";
}
return "error";
const categories = [
[/offline mode/u, "offline"],
[/checksum mismatch/u, "checksum_mismatch"],
[/schema/u, "schema"],
[/http\s+304/u, "not_modified"],
[/http\s+\d{3}/u, "http_error"],
[/timed out|timeout/u, "timeout"],
] as const;
return categories.find(([pattern]) => pattern.test(text))?.[1] ?? "error";
}
function emitMarketplaceFeedTelemetry(params: {
@@ -678,10 +658,6 @@ function redactMarketplaceFeedUrl(value: string): string {
}
}
function replaceAllLiteral(value: string, search: string, replacement: string): string {
return search ? value.split(search).join(replacement) : value;
}
function redactMarketplaceOutputText(
value: string,
rawUrls: readonly (string | undefined)[],
@@ -691,7 +667,7 @@ function redactMarketplaceOutputText(
if (!rawUrl) {
continue;
}
redacted = replaceAllLiteral(redacted, rawUrl, redactMarketplaceFeedUrl(rawUrl));
redacted = redacted.replaceAll(rawUrl, () => redactMarketplaceFeedUrl(rawUrl));
}
return redacted;
}
@@ -742,6 +718,37 @@ function formatMarketplaceFeedTrust(trust: MarketplaceFeedTrustPayload): string
return `${trust.mode} by ${trust.signedBy} (${trust.signatureCount}/${trust.threshold}) verified ${trust.verifiedAt}`;
}
function formatMarketplaceFeedLines(
payload: MarketplaceRefreshPayload,
options: { includeChecksum?: boolean } = {},
): string[] {
const lines = [
`${theme.muted("Source:")} ${formatMarketplaceRefreshSource(payload.source)}`,
`${theme.muted("Entries:")} ${payload.entries}`,
];
if (payload.feed) {
lines.push(
`${theme.muted("Feed:")} ${payload.feed.id} ${theme.muted(`sequence ${payload.feed.sequence}`)}`,
);
}
if (payload.metadata?.url) {
lines.push(`${theme.muted("URL:")} ${payload.metadata.url}`);
}
if (options.includeChecksum && payload.metadata?.checksum) {
lines.push(`${theme.muted("SHA-256:")} ${payload.metadata.checksum}`);
}
if (payload.snapshot?.savedAt) {
lines.push(`${theme.muted("Snapshot:")} ${payload.snapshot.savedAt}`);
}
if (payload.trust) {
lines.push(`${theme.muted("Trust:")} ${formatMarketplaceFeedTrust(payload.trust)}`);
}
if (payload.error) {
lines.push(`${theme.muted("Fallback reason:")} ${payload.error}`);
}
return lines;
}
function shouldFailPinnedMarketplaceRefresh(params: {
expectedSha256?: string;
source: MarketplaceRefreshPayload["source"];
@@ -818,31 +825,7 @@ export async function runPluginMarketplaceEntriesCommand(
return;
}
const lines = [
theme.muted("Source:") + " " + formatMarketplaceRefreshSource(summary.source),
theme.muted("Entries:") + " " + String(entries.length),
];
if (summary.feed) {
lines.push(
theme.muted("Feed:") +
" " +
summary.feed.id +
" " +
theme.muted("sequence " + String(summary.feed.sequence)),
);
}
if (summary.metadata?.url) {
lines.push(theme.muted("URL:") + " " + summary.metadata.url);
}
if (summary.snapshot?.savedAt) {
lines.push(theme.muted("Snapshot:") + " " + summary.snapshot.savedAt);
}
if (summary.trust) {
lines.push(theme.muted("Trust:") + " " + formatMarketplaceFeedTrust(summary.trust));
}
if (summary.error) {
lines.push(theme.muted("Fallback reason:") + " " + summary.error);
}
const lines = formatMarketplaceFeedLines(summary);
if (entries.length > 0) {
lines.push("");
lines.push(...entries.map(formatMarketplaceEntryLine));
@@ -892,30 +875,7 @@ export async function runPluginMarketplaceRefreshCommand(
return;
}
const lines = [
`${theme.muted("Source:")} ${formatMarketplaceRefreshSource(payload.source)}`,
`${theme.muted("Entries:")} ${payload.entries}`,
];
if (payload.feed) {
lines.push(
`${theme.muted("Feed:")} ${payload.feed.id} ${theme.muted(`sequence ${payload.feed.sequence}`)}`,
);
}
if (payload.metadata?.url) {
lines.push(`${theme.muted("URL:")} ${payload.metadata.url}`);
}
if (payload.metadata?.checksum) {
lines.push(`${theme.muted("SHA-256:")} ${payload.metadata.checksum}`);
}
if (payload.snapshot?.savedAt) {
lines.push(`${theme.muted("Snapshot:")} ${payload.snapshot.savedAt}`);
}
if (payload.trust) {
lines.push(`${theme.muted("Trust:")} ${formatMarketplaceFeedTrust(payload.trust)}`);
}
if (payload.error) {
lines.push(`${theme.muted("Fallback reason:")} ${payload.error}`);
}
const lines = formatMarketplaceFeedLines(payload, { includeChecksum: true });
defaultRuntime.log(lines.join("\n"));
if (failedPinnedRefresh) {
defaultRuntime.error(formatPinnedMarketplaceRefreshFailure(payload));