{"record":{"id":"f131366318a9d26a","repo":"BigPizzaV3/CodexPlusPlus","slug":"manifest-capabilities-safe-css","errorCode":null,"errorMessage":"manifest.capabilities 无效或缺少 safe-css 能力","messagePattern":"manifest\\.capabilities 无效或缺少 safe-css 能力","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":948,"sourceCode":"            .platforms\n            .iter()\n            .any(|item| !matches!(item.as_str(), \"macos\" | \"windows\"))\n    {\n        bail!(\"manifest.platforms 无效\");\n    }\n    if !manifest.platforms.iter().any(|item| item == platform) {\n        bail!(\"主题包不支持当前平台：{platform}\");\n    }\n    if manifest.capabilities.is_empty()\n        || manifest.capabilities.len() > 3\n        || has_duplicates(&manifest.capabilities)\n        || manifest\n            .capabilities\n            .iter()\n            .any(|item| !matches!(item.as_str(), \"background\" | \"tokens\" | \"safe-css\"))\n        || !manifest.capabilities.iter().any(|item| item == \"safe-css\")\n    {\n        bail!(\"manifest.capabilities 无效或缺少 safe-css 能力\");\n    }\n    if !safe_manifest_text(&manifest.publisher.display_name, 1, 80, false)\n        || manifest.publisher.id.is_empty()\n        || manifest.publisher.id.len() > 64\n        || !manifest\n            .publisher\n            .id\n            .bytes()\n            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-'))\n        || manifest.license.is_empty()\n        || manifest.license.len() > 64\n        || !manifest.license.bytes().enumerate().all(|(index, byte)| {\n            byte.is_ascii_alphanumeric()\n                || (index > 0 && matches!(byte, b' ' | b'.' | b'+' | b'(' | b')' | b'-'))\n        })\n        || !safe_manifest_text(&manifest.provenance.summary, 1, 500, true)\n    {\n        bail!(\"manifest 发布者、许可证或来源说明为空\");","sourceCodeStart":930,"sourceCodeEnd":966,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L930-L966","documentation":"validate_manifest rejects the package when manifest.capabilities is empty, exceeds 3 entries, contains duplicates, lists any capability other than \"background\" | \"tokens\" | \"safe-css\", or omits the mandatory \"safe-css\" capability. The library requires every theme to declare it only injects safe CSS, plus optional background/tokens features. Thrown during validate_and_read_package.","triggerScenarios":"validate_and_read_package reads a manifest whose capabilities array is [], has more than 3 entries, duplicates an entry, contains unknown values (e.g. \"fonts\", \"js\"), or lacks \"safe-css\" even when other valid capabilities are present.","commonSituations":"Old templates that predate the mandatory safe-css requirement; authors adding invented capability names; copying capability lists between packages incorrectly.","solutions":["Add \"safe-css\" to manifest.capabilities (it is mandatory)","Limit capabilities to the allowed values: \"background\", \"tokens\", \"safe-css\"","Remove duplicates and keep the list at 3 entries or fewer","Remove unknown capability names or map them to supported ones","Re-validate the package"],"exampleFix":"// before (manifest.json)\n\"capabilities\": [\"background\"]\n// after\n\"capabilities\": [\"background\", \"safe-css\"]","handlingStrategy":"validation","validationCode":"fn caps_ok(caps: &[String]) -> bool {\n    !caps.is_empty() && caps.len() <= 3\n        && caps.iter().all(|c| matches!(c.as_str(), \"background\" | \"tokens\" | \"safe-css\"))\n        && caps.iter().any(|c| c == \"safe-css\")\n}\nif !caps_ok(&manifest.capabilities) { /* fix before calling */ }","typeGuard":"fn has_safe_css(caps: &[String]) -> bool {\n    caps.iter().any(|c| c == \"safe-css\")\n        && caps.iter().all(|c| matches!(c.as_str(), \"background\" | \"tokens\" | \"safe-css\"))\n}","tryCatchPattern":"match validate_and_read_package(&path, platform) {\n    Err(e) if e.to_string().contains(\"safe-css\") => {\n        eprintln!(\"package rejected: capabilities invalid or missing safe-css\");\n    }\n    other => other?,\n}","preventionTips":["Always include \"safe-css\" in every manifest you author","Whitelist-only capability vocabulary; never invent names","Check caps against a constant array in packaging scripts"],"tags":["manifest","capabilities","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}