Triple-C marketplace: agents, skills, commands, hooks and plugins for all or individual containers #65

Merged
jknapp merged 48 commits from feat/marketplace into main 2026-09-27 23:43:27 +00:00
2 changed files with 50 additions and 5 deletions
Showing only changes of commit 7fb2190211 - Show all commits
+15 -3
View File
@@ -271,9 +271,16 @@ while read -r id; do
if grep -qxF "$id" "$R/new_ids"; then continue; fi
# Still selected but failed this run: keep the old files and record.
if in_manifest "$id"; then carry_forward "$id"; continue; fi
# Only an exact "<kind>:<key>" with a known kind names a path; anything
# else in state is dropped without deleting anything.
case "$id" in
agent:* | skill:* | command:* | hook:*)
kind=${id%%:*}
key=${id#*:}
if ! valid_key "$key" || ! path=$(item_path "$kind" "$key"); then
;;
*) kind="" key="" ;;
esac
if [ -z "$kind" ] || ! valid_key "$key" || ! path=$(item_path "$kind" "$key"); then
fail "$id: dropped an unrecognised record from the marketplace state"
continue
fi
@@ -330,7 +337,8 @@ if [ "$OLD_HOOKS" != "{}" ] || [ "$NEW_HOOKS" != "{}" ]; then
' "$R/current.json" >"$tmp" 2>/dev/null &&
jq -e 'type == "object"' "$tmp" >/dev/null 2>&1 &&
mv -f "$tmp" "$target"; then
chmod 600 "$target"
chmod 600 "$target" ||
fail "~/.claude/settings.json was updated but could not be made private (chmod 600)"
else
rm -f "$tmp"
HOOKS_FAILED=1
@@ -389,7 +397,11 @@ while read -r id; do
if in_manifest "$id"; then carry_forward "$id"; continue; fi
key=${id#plugin:}
slug=$(jq -r --arg id "$id" '.items[$id].slug // ""' "$STATE")
if valid_key "$key" && valid_slug "$slug" && claude_cmd plugin uninstall "$key@triple-c-$slug"; then
if ! valid_key "$key" || ! valid_slug "$slug"; then
fail "$id: dropped an unrecognised record from the marketplace state"
continue
fi
if claude_cmd plugin uninstall "$key@triple-c-$slug"; then
report removed "$id"
else
fail "$id: uninstall failed"
@@ -851,3 +851,36 @@ fn sync_settings_move_failure_is_reported_and_not_recorded() {
"{state}"
);
}
#[test]
fn sync_drops_state_records_without_a_kind_key_id() {
let Some(env) = env() else { return };
install_all(&env);
let claude = env.home.join(".claude");
let mine = [
claude.join("skills/skill/SKILL.md"),
claude.join("agents/agent.md"),
];
for p in &mine {
fs::create_dir_all(p.parent().unwrap()).unwrap();
fs::write(p, "mine\n").unwrap();
}
let state_path = claude.join("triple-c/marketplace/state.json");
let mut state = read_json(&state_path);
for bogus in ["skill", "agent", "widget:x", "agent:a:b", "plugin:a:b"] {
state["items"][bogus] = json!({ "commit": C1, "path": "/" });
}
fs::write(&state_path, state.to_string()).unwrap();
payload(&env, &[], empty_manifest());
let r = run(&env);
assert_eq!(sorted(r.removed.clone()).len(), 4, "{r:?}");
assert_eq!(r.errors.len(), 5, "{r:?}");
assert!(claude_log(&env).is_empty(), "{:?}", claude_log(&env));
for p in &mine {
assert_eq!(fs::read_to_string(p).unwrap(), "mine\n", "{}", p.display());
}
let state = read_json(&state_path);
assert_eq!(state["items"], json!({}), "bogus records dropped");
}