Derive a name from a file path relative to the base directory.
(path: &Path, base_dir: &Path, strip_prefixes: &[&str])
| 1116 | |
| 1117 | /// Derive a name from a file path relative to the base directory. |
| 1118 | fn derive_name_from_path(path: &Path, base_dir: &Path, strip_prefixes: &[&str]) -> String { |
| 1119 | let rel = path |
| 1120 | .strip_prefix(base_dir) |
| 1121 | .unwrap_or(path) |
| 1122 | .to_string_lossy() |
| 1123 | .to_string(); |
| 1124 | |
| 1125 | // Strip known directory prefixes |
| 1126 | let mut name = rel.as_str(); |
| 1127 | for prefix in strip_prefixes { |
| 1128 | let with_sep = format!("{}/", prefix); |
| 1129 | if let Some(stripped) = name.strip_prefix(&with_sep) { |
| 1130 | name = stripped; |
| 1131 | break; |
| 1132 | } |
| 1133 | // Also try .opencode/ prefix |
| 1134 | let with_opencode = format!(".opencode/{}/", prefix); |
| 1135 | if let Some(stripped) = name.strip_prefix(&with_opencode) { |
| 1136 | name = stripped; |
| 1137 | break; |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | // Remove .md extension |
| 1142 | name.strip_suffix(".md").unwrap_or(name).to_string() |
| 1143 | } |
| 1144 | |
| 1145 | /// Merge one AgentConfig into another (simple field-level merge). |
| 1146 | fn merge_agent_config(target: &mut AgentConfig, source: AgentConfig) { |
no test coverage detected