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

* 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.

* fix(shellcheck): use read -ra for word-split array assignment (SC2206)

Replace local arr=($var) with read -ra arr <<< "$var" in
install-context.sh to satisfy ShellCheck SC2206 and unblock CI.
This commit is contained in:
Darren Hinde 2026-03-11 18:56:58 +00:00 committed by GitHub
parent 035dc59d33
commit 10682353e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View file

@ -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

View file

@ -72,7 +72,8 @@ check_dependencies() {
}
download_context() {
local categories=($1)
local categories
read -ra categories <<< "$1"
local temp_dir
temp_dir="$(mktemp -d)"
# shellcheck disable=SC2064
@ -113,7 +114,8 @@ download_context() {
write_manifest() {
local profile="$1"
local categories=($2)
local categories
read -ra categories <<< "$2"
local commit="$3"
local timestamp
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")