Bladeren bron

fix: improve auto-detect JSON escaping and add test components

- Fix quote escaping in auto-detect-components.sh using jq --arg
- Auto-detected and added 5 new components to registry:
  * agent:codebase-agent
  * command:commit-openagents
  * command:prompt-optimizer
  * command:test-new-command (test file)
  * context:subagent-template
  * context:orchestrator-template

All components available for individual installation.
Registry validation: 50/50 paths valid ✓
darrenhinde 8 maanden geleden
bovenliggende
commit
a29aedb7e5
3 gewijzigde bestanden met toevoegingen van 116 en 18 verwijderingen
  1. 26 0
      .opencode/command/test-new-command.md
  2. 71 1
      registry.json
  3. 19 17
      scripts/auto-detect-components.sh

+ 26 - 0
.opencode/command/test-new-command.md

@@ -0,0 +1,26 @@
+---
+description: "Test command to verify auto-detection and registry updates work correctly"
+---
+
+# Test New Command
+
+This is a test command created to verify that the auto-detection system works.
+
+## Usage
+
+```bash
+/test-new-command
+```
+
+## Features
+
+- Auto-detected by the system
+- Automatically added to registry
+- Validates the build system works
+
+## Testing
+
+This file should be:
+1. Detected by `auto-detect-components.sh`
+2. Added to registry.json automatically
+3. Validated by `validate-registry.sh`

+ 71 - 1
registry.json

@@ -69,6 +69,16 @@
           "subagent:command-creator"
         ],
         "category": "meta"
+      },
+      {
+        "id": "codebase-agent",
+        "name": "Codebase Agent",
+        "type": "agent",
+        "path": ".opencode/agent/codebase-agent.md",
+        "description": "description: \\\"Multi-language implementation agent for modular and functional development\\\"",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
       }
     ],
     "subagents": [
@@ -387,6 +397,36 @@
         ],
         "dependencies": [],
         "category": "standard"
+      },
+      {
+        "id": "commit-openagents",
+        "name": "Commit Openagents",
+        "type": "command",
+        "path": ".opencode/command/commit-openagents.md",
+        "description": "description: Smart commit command for opencode-agents repository with automatic validation and conventional commits",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
+      },
+      {
+        "id": "prompt-optimizer",
+        "name": "Prompt Optimizer",
+        "type": "command",
+        "path": ".opencode/command/prompt-engineering/prompt-optimizer.md",
+        "description": "description: \\\"Advanced prompt optimizer: Research patterns + token efficiency + semantic preservation. Achieves 30-50% token reduction with 100% meaning preserved.\\\"",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
+      },
+      {
+        "id": "test-new-command",
+        "name": "Test New Command",
+        "type": "command",
+        "path": ".opencode/command/test-new-command.md",
+        "description": "description: \\\"Test command to verify auto-detection and registry updates work correctly\\\"",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
       }
     ],
     "tools": [
@@ -620,6 +660,36 @@
         ],
         "dependencies": [],
         "category": "standard"
+      },
+      {
+        "id": "system-builder-guide",
+        "name": "System Builder Guide",
+        "type": "context",
+        "path": ".opencode/context/system-builder-templates/SYSTEM-BUILDER-GUIDE.md",
+        "description": "System Builder Guide",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
+      },
+      {
+        "id": "subagent-template",
+        "name": "Subagent Template",
+        "type": "context",
+        "path": ".opencode/context/system-builder-templates/subagent-template.md",
+        "description": "description: \\\"{specific_task_description}\\\"",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
+      },
+      {
+        "id": "orchestrator-template",
+        "name": "Orchestrator Template",
+        "type": "context",
+        "path": ".opencode/context/system-builder-templates/orchestrator-template.md",
+        "description": "description: \\\"{domain} orchestrator for {primary_purpose}\\\"",
+        "tags": [],
+        "dependencies": [],
+        "category": "standard"
       }
     ],
     "config": [
@@ -824,7 +894,7 @@
     }
   },
   "metadata": {
-    "lastUpdated": "2025-11-26",
+    "lastUpdated": "2025-11-27",
     "schemaVersion": "1.0.0"
   }
 }

+ 19 - 17
scripts/auto-detect-components.sh

@@ -190,27 +190,29 @@ add_component_to_registry() {
         description="Component: ${name}"
     fi
     
+    # Escape quotes and special characters in description
+    description=$(echo "$description" | sed 's/"/\\"/g' | sed "s/'/\\'/g")
+    
     # Get registry key (agents, subagents, commands, etc.)
     local registry_key=$(get_registry_key "$comp_type")
     
-    # Create component JSON
-    local component_json=$(cat <<EOF
-{
-  "id": "${id}",
-  "name": "${name}",
-  "type": "${comp_type}",
-  "path": "${path}",
-  "description": "${description}",
-  "tags": [],
-  "dependencies": [],
-  "category": "standard"
-}
-EOF
-)
-    
-    # Add to registry
+    # Use jq to properly construct JSON (avoids escaping issues)
     local temp_file="${REGISTRY_FILE}.tmp"
-    jq ".components.${registry_key} += [${component_json}]" "$REGISTRY_FILE" > "$temp_file"
+    jq --arg id "$id" \
+       --arg name "$name" \
+       --arg type "$comp_type" \
+       --arg path "$path" \
+       --arg desc "$description" \
+       ".components.${registry_key} += [{
+         \"id\": \$id,
+         \"name\": \$name,
+         \"type\": \$type,
+         \"path\": \$path,
+         \"description\": \$desc,
+         \"tags\": [],
+         \"dependencies\": [],
+         \"category\": \"standard\"
+       }]" "$REGISTRY_FILE" > "$temp_file"
     
     if [ $? -eq 0 ]; then
         mv "$temp_file" "$REGISTRY_FILE"