eval_magic/adapters/
capabilities.rs1use std::io;
16use std::path::Path;
17
18use serde::{Deserialize, Serialize};
19
20use crate::core::ToolInvocation;
21
22use super::TranscriptSummary;
23use super::skill_shadow::PluginShadowReport;
24
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
28#[serde(rename_all = "kebab-case")]
29pub enum TranscriptParser {
30 ClaudeStreamJson,
32 CodexItems,
34 OpencodeEvents,
36}
37
38impl TranscriptParser {
39 pub(crate) fn parse(self, path: &Path) -> io::Result<Vec<ToolInvocation>> {
41 match self {
42 TranscriptParser::ClaudeStreamJson => {
43 super::claude_code::stream_json::parse_claude_stream_json(path)
44 }
45 TranscriptParser::CodexItems => super::codex::transcript::parse_codex_events(path),
46 TranscriptParser::OpencodeEvents => {
47 super::opencode::transcript::parse_opencode_events(path)
48 }
49 }
50 }
51
52 pub(crate) fn parse_full(self, path: &Path) -> io::Result<TranscriptSummary> {
54 match self {
55 TranscriptParser::ClaudeStreamJson => {
56 super::claude_code::stream_json::parse_claude_stream_json_full(path)
57 }
58 TranscriptParser::CodexItems => super::codex::transcript::parse_codex_events_full(path),
59 TranscriptParser::OpencodeEvents => {
60 super::opencode::transcript::parse_opencode_events_full(path)
61 }
62 }
63 }
64}
65
66#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
69#[serde(rename_all = "kebab-case")]
70pub enum SlugCapability {
71 Opencode,
73}
74
75impl SlugCapability {
76 pub(crate) fn staged_slug(
78 self,
79 prefix: &str,
80 iteration: u32,
81 condition: &str,
82 skill_name: &str,
83 ) -> String {
84 match self {
85 SlugCapability::Opencode => {
86 super::opencode::opencode_slug(prefix, iteration, condition, skill_name)
87 }
88 }
89 }
90}
91
92#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
94#[serde(rename_all = "kebab-case")]
95pub enum ShadowPreflight {
96 ClaudePlugins,
98 CodexSkills,
100 OpencodeSkills,
102}
103
104impl ShadowPreflight {
105 pub(crate) fn detect(
108 self,
109 scan_root: &Path,
110 staged_skill_names: &[&str],
111 ) -> Option<PluginShadowReport> {
112 match self {
113 ShadowPreflight::ClaudePlugins => super::claude_code::plugin_shadow::shadow_preflight(
114 &super::claude_code::plugin_shadow::config_dir_from_env(),
115 scan_root,
116 staged_skill_names,
117 ),
118 ShadowPreflight::CodexSkills => {
119 super::codex::skill_shadow::shadow_preflight(scan_root, staged_skill_names)
120 }
121 ShadowPreflight::OpencodeSkills => {
122 super::opencode::skill_shadow::shadow_preflight(scan_root, staged_skill_names)
123 }
124 }
125 }
126
127 pub(crate) fn format_banner(self, report: &PluginShadowReport) -> String {
129 match self {
130 ShadowPreflight::ClaudePlugins => super::skill_shadow::format_shadow_banner(report),
131 ShadowPreflight::CodexSkills => {
132 super::codex::skill_shadow::format_shadow_banner(report)
133 }
134 ShadowPreflight::OpencodeSkills => {
135 super::opencode::skill_shadow::format_shadow_banner(report)
136 }
137 }
138 }
139
140 pub(crate) fn validity_warnings(self, report: &PluginShadowReport) -> Vec<String> {
142 match self {
143 ShadowPreflight::ClaudePlugins => super::skill_shadow::shadow_validity_warnings(report),
144 ShadowPreflight::CodexSkills => {
145 super::codex::skill_shadow::shadow_validity_warnings(report)
146 }
147 ShadowPreflight::OpencodeSkills => {
148 super::opencode::skill_shadow::shadow_validity_warnings(report)
149 }
150 }
151 }
152}