fix(plugin): remediate ML-07 R2 findings

This commit is contained in:
2026-08-27 21:16:27 +08:00
parent 29cf322f1a
commit f0ac7d70d1
10 changed files with 381 additions and 29 deletions

View File

@@ -113,7 +113,10 @@ export interface CodingCapabilityRegistryPort {
export type CodingCapabilityRegistry = CodingCapabilityRegistryPort;
export interface CodingCapabilityRegistryOptions {
policyClient: Pick<{ getState(): PluginPolicyClientState }, 'getState'>;
policyClient: {
getState(): PluginPolicyClientState;
refresh(): Promise<void>;
};
getEnabledPluginIds?: (projectPath: string) => Promise<readonly string[]>;
projectPlugins?: {
getEnabledPluginIds(projectPath: string): Promise<readonly string[]>;
@@ -375,6 +378,21 @@ export class CodingCapabilityRegistryImpl implements CodingCapabilityRegistryPor
tools: [],
};
}
const hasAssignedServerPlugin = this.definitions.some((definition) => (
definition.requiresBackend
&& this.adaptersByPluginId.has(definition.id)
&& definition.skills.some(({ id }) => assigned.includes(id))
));
if (!hasAssignedServerPlugin) {
return {
catalogRevision: this.options.policyClient.getState().revision,
pluginIds: [],
effectiveSkillIds: effectiveCoreSkills,
skillEntries: effectiveCoreSkills.map((id) => ({ id, entryPath: `${id}/SKILL.md` })),
tools: [],
};
}
await this.options.policyClient.refresh();
const enabled = await this.enabledPluginIds(input.projectPath);
const state = this.options.policyClient.getState();
const pluginIds: string[] = [];