Merge pull request #3103 from Yeachan-Heo/fix/issue-702-inventory-provenance

Fix #702 inventory provenance schema
This commit is contained in:
YeonGyu-Kim
2026-05-25 21:10:18 +09:00
committed by GitHub
2 changed files with 118 additions and 1 deletions

View File

@@ -4122,9 +4122,17 @@ fn definition_source_id(source: DefinitionSource) -> &'static str {
}
fn definition_source_json(source: DefinitionSource) -> Value {
definition_source_json_with_detail(source, None)
}
fn definition_source_json_with_detail(
source: DefinitionSource,
detail_label: Option<&'static str>,
) -> Value {
json!({
"id": definition_source_id(source),
"label": source.label(),
"detail_label": detail_label,
})
}
@@ -4158,7 +4166,7 @@ fn skill_summary_json(skill: &SkillSummary) -> Value {
json!({
"name": &skill.name,
"description": &skill.description,
"source": definition_source_json(skill.source),
"source": definition_source_json_with_detail(skill.source, skill.origin.detail_label()),
"origin": skill_origin_json(skill.origin),
"active": skill.shadowed_by.is_none(),
"shadowed_by": skill.shadowed_by.map(definition_source_json),
@@ -5461,7 +5469,18 @@ mod tests {
assert_eq!(report["summary"]["shadowed"], 1);
assert_eq!(report["skills"][0]["name"], "plan");
assert_eq!(report["skills"][0]["source"]["id"], "project_claw");
assert_eq!(report["skills"][0]["source"]["label"], "Project roots");
assert_eq!(
report["skills"][0]["source"]["detail_label"],
serde_json::Value::Null
);
assert_eq!(report["skills"][1]["name"], "deploy");
assert_eq!(report["skills"][1]["source"]["id"], "project_claw");
assert_eq!(report["skills"][1]["source"]["label"], "Project roots");
assert_eq!(
report["skills"][1]["source"]["detail_label"],
"legacy /commands"
);
assert_eq!(report["skills"][1]["origin"]["id"], "legacy_commands_dir");
assert_eq!(report["skills"][3]["shadowed_by"]["id"], "project_claw");