fix(update): share parsed client activation with maintenance

This commit is contained in:
morluto
2026-10-13 12:46:05 +08:00
parent bb540826d6
commit b045df100e
3 changed files with 112 additions and 80 deletions
+12 -39
View File
@@ -1,19 +1,10 @@
import { z } from "zod";
import { PRODUCT_IDENTITY } from "../identity.js";
import { isOwnedClientRegistrationCommand } from "./ClientRegistrationIdentity.js";
import { readClientRegistrationStatuses } from "./ClientRegistrationStatus.js";
import {
clientServerForcedEnabled,
clientServerListedDisabled,
effectiveClientServer,
parseClientConfiguration,
} from "./ClientConfigurationDocument.js";
import { supportedClients } from "./SupportedClients.js";
import { readClientRegistrationInspections } from "./ClientRegistrationStatus.js";
import { existingSkillDestinations } from "./SetupSkill.js";
import type { SetupAction } from "./SetupTypes.js";
import type { Result } from "../domain/result.js";
import { readRegularFileText } from "./RegularFileRead.js";
import type { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
/** Existing REA integrations selected for maintenance, without discovering new targets. */
@@ -61,41 +52,23 @@ export const existingMaintenanceScope = async (
environment: Readonly<NodeJS.ProcessEnv>,
resources?: ArtifactResourceScope,
): Promise<MaintenanceScope> => {
const registrations = await readClientRegistrationStatuses(home, entryPoint, {
environment,
...(resources === undefined ? {} : { resources }),
});
const supported = supportedClients(home, process.platform, environment);
const registrations = await readClientRegistrationInspections(
home,
entryPoint,
{
environment,
...(resources === undefined ? {} : { resources }),
},
);
const clients: string[] = [];
for (const registration of registrations) {
for (const { status: registration, activation } of registrations) {
if (
activation !== "enabled" ||
(registration.state !== "aligned" && registration.state !== "stale") ||
!isOwnedClientRegistrationCommand(registration.command, entryPoint)
)
continue;
const client = supported.find(({ name }) => name === registration.client);
if (client === undefined) continue;
const parsed = parseClientConfiguration(
await readRegularFileText(
client.configPath,
resources === undefined ? {} : { resources },
),
client.format,
);
const enabled = z
.object({
enabled: z.boolean().optional(),
disabled: z.boolean().optional(),
})
.parse(effectiveClientServer(parsed, PRODUCT_IDENTITY.mcpServerKey));
// Root disable lists override enabled entries and OMP's force-on allowlist.
if (
(enabled.enabled !== false ||
clientServerForcedEnabled(parsed, PRODUCT_IDENTITY.mcpServerKey)) &&
enabled.disabled !== true &&
!clientServerListedDisabled(parsed, PRODUCT_IDENTITY.mcpServerKey)
)
clients.push(client.name);
clients.push(registration.client);
}
const skillDestinations = await existingSkillDestinations(
home,