From dcc98db32c316806aaf524fc205d2556ec3f5113 Mon Sep 17 00:00:00 2001 From: David Chen Date: Sat, 13 Dec 2025 15:03:47 -0800 Subject: [PATCH] merge opencode config --- zsh/functions/_op_common.zsh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/zsh/functions/_op_common.zsh b/zsh/functions/_op_common.zsh index b3de0a3..269a57e 100644 --- a/zsh/functions/_op_common.zsh +++ b/zsh/functions/_op_common.zsh @@ -29,6 +29,30 @@ _op_run() { return 1 fi + # Merge project opencode.json if it exists + local project_config="" + local search_dir="$PWD" + while [ "$search_dir" != "/" ]; do + if [ -f "$search_dir/opencode.json" ]; then + project_config="$search_dir/opencode.json" + break + fi + if [ -d "$search_dir/.git" ]; then + break + fi + search_dir="${search_dir:h}" + done + + if [ -n "$project_config" ]; then + print -u2 "$tag: merging project config from $project_config" + local merged + if merged=$(jq -s '.[0] * .[1]' "$tmp_home/opencode.json" "$project_config" 2>/dev/null); then + printf '%s\n' "$merged" > "$tmp_home/opencode.json" + else + print -u2 "$tag: warning: failed to merge project config, using base only" + fi + fi + local base_agents="$base_home/AGENTS.md" if [ "$tag" = "se" ]; then local search_agents="$base_home/agent/search/AGENTS.md"