( plugin: LoadedPlugin, )
| 280 | * Used by PluginOptionsFlow to decide whether to show the prompt after enable. |
| 281 | */ |
| 282 | export function getUnconfiguredOptions( |
| 283 | plugin: LoadedPlugin, |
| 284 | ): PluginOptionSchema { |
| 285 | const manifestSchema = plugin.manifest.userConfig |
| 286 | if (!manifestSchema || Object.keys(manifestSchema).length === 0) { |
| 287 | return {} |
| 288 | } |
| 289 | |
| 290 | const saved = loadPluginOptions(getPluginStorageId(plugin)) |
| 291 | const validation = validateUserConfig(saved, manifestSchema) |
| 292 | if (validation.valid) { |
| 293 | return {} |
| 294 | } |
| 295 | |
| 296 | // Return only the fields that failed. validateUserConfig reports errors as |
| 297 | // strings keyed by title/key — simpler to just re-check each field here than |
| 298 | // parse error strings. |
| 299 | const unconfigured: PluginOptionSchema = {} |
| 300 | for (const [key, fieldSchema] of Object.entries(manifestSchema)) { |
| 301 | const single = validateUserConfig( |
| 302 | { [key]: saved[key] } as PluginOptionValues, |
| 303 | { [key]: fieldSchema }, |
| 304 | ) |
| 305 | if (!single.valid) { |
| 306 | unconfigured[key] = fieldSchema |
| 307 | } |
| 308 | } |
| 309 | return unconfigured |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Substitute ${CLAUDE_PLUGIN_ROOT} and ${CLAUDE_PLUGIN_DATA} with their paths. |
no test coverage detected