Browse Source

fix(install.sh): handle both singular and plural component type formats

The get_registry_key() function was always adding 's' to the type,
causing 'contexts' to become 'contextss' which doesn't exist in registry.json.

Now handles:
- Singular forms: context → contexts, agent → agents, skill → skills
- Plural forms: contexts → contexts (unchanged), agents → agents
- Config stays singular
- Fallback for any type ending in 's'

Fixes #257
darrenhinde 4 months ago
parent
commit
47ee5a6773
1 changed files with 11 additions and 1 deletions
  1. 11 1
      install.sh

+ 11 - 1
install.sh

@@ -323,9 +323,19 @@ resolve_component_path() {
 # Helper function to get the correct registry key for a component type
 get_registry_key() {
     local type=$1
-    # Most types are pluralized, but 'config' stays singular
+    # Handle both singular and plural forms
+    # Registry uses plural keys: agents, contexts, skills
     case "$type" in
         config) echo "config" ;;
+        # Already plural forms - use as-is
+        agents|contexts|skills) echo "$type" ;;
+        # Singular forms - pluralize them
+        agent) echo "agents" ;;
+        context) echo "contexts" ;;
+        skill) echo "skills" ;;
+        # Fallback: if already ends with 's', assume plural
+        *s) echo "$type" ;;
+        # Default: add 's' to make plural
         *) echo "${type}s" ;;
     esac
 }