mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-31 01:36:45 +00:00
Unify inventory provenance for generic parsers
Expose a stable source object on agent and skill inventory entries with the same id/label/detail_label keys while preserving skill origin for compatibility.\n\nConstraint: ROADMAP #702 scope only; keep existing skills origin field for compatibility.\nRejected: Rename agent source to origin | would break existing agents consumers and still require per-resource branching during migration.\nConfidence: high\nScope-risk: narrow\nDirective: Future inventory resources should expose provenance through source.id, source.label, and source.detail_label.\nTested: cargo fmt --manifest-path rust/Cargo.toml --all -- --check; cargo test --manifest-path rust/Cargo.toml -p commands renders_skills_reports_as_json -- --nocapture; cargo test --manifest-path rust/Cargo.toml -p rusty-claude-cli --test output_format_contract -- --nocapture; cargo build --manifest-path rust/Cargo.toml --workspace --locked; git diff --check\nNot-tested: full cargo test --manifest-path rust/Cargo.toml --workspace
This commit is contained in:
@@ -4125,9 +4125,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,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4161,7 +4169,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),
|
||||
@@ -5464,7 +5472,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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user