Browse Source

fix(install): resolve non-.md context paths like paths.json (closes #251)

resolve_component_path() was appending .md to all slash-containing context
IDs, so context:core/config/paths.json was looked up as paths.json.md and
returned empty, triggering the 'Could not find path' warning on install.

Now tries the .md path first (preserving existing behaviour for all markdown
context files), then falls back to the bare path for non-markdown files.
darrenhinde 5 months ago
parent
commit
a17a6b4863
1 changed files with 8 additions and 1 deletions
  1. 8 1
      install.sh

+ 8 - 1
install.sh

@@ -313,7 +313,14 @@ resolve_component_path() {
     registry_key=$(get_registry_key "$component_type")
 
     if [ "$component_type" = "context" ] && [[ "$component_id" == */* ]]; then
-        jq_exec "first(.components.contexts[]? | select(.path == \".opencode/context/${component_id}.md\") | .path)" "$TEMP_DIR/registry.json"
+        # Try .md extension first (most context files), then fall back to the
+        # path as-is for non-markdown files (e.g. paths.json). Fixes #251.
+        local result
+        result=$(jq_exec "first(.components.contexts[]? | select(.path == \".opencode/context/${component_id}.md\") | .path)" "$TEMP_DIR/registry.json")
+        if [ -z "$result" ] || [ "$result" = "null" ]; then
+            result=$(jq_exec "first(.components.contexts[]? | select(.path == \".opencode/context/${component_id}\") | .path)" "$TEMP_DIR/registry.json")
+        fi
+        echo "$result"
         return
     fi