Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions runtimes/opencode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ _runtime_repair_opencode_json_additive() {
runtime_generate_instructions() {
if [ "$DRY_RUN" = false ] && [ -f "$SITE_PATH/AGENTS.md" ]; then
log "Phase 8: AGENTS.md already exists — skipping (delete to regenerate)"
_opencode_symlink_claude_md
return
fi

Expand All @@ -387,6 +388,7 @@ runtime_generate_instructions() {
sync_homeboy_availability
if wp_cmd datamachine memory compose AGENTS.md 2>/dev/null; then
log "AGENTS.md composed from SectionRegistry"
_opencode_symlink_claude_md
return
fi
warn "Compose failed — falling back to static template"
Expand All @@ -407,8 +409,26 @@ runtime_generate_instructions() {

if [ "$DRY_RUN" = true ]; then
echo -e "${BLUE}[dry-run]${NC} Would generate AGENTS.md from template"
echo -e "${BLUE}[dry-run]${NC} Would symlink CLAUDE.md → AGENTS.md (Claude-model context)"
else
sed "s|{{WP_CLI_CMD}}|$wp_cli_display|g" "$agents_tmpl" > "$SITE_PATH/AGENTS.md"
_opencode_symlink_claude_md
fi
}

# Symlink CLAUDE.md → AGENTS.md so Claude-model opencode sessions inherit the
# same DM context. OpenCode globs ["AGENTS.md", "CLAUDE.md", "CONTEXT.md"] from
# cwd; Claude Code reads only CLAUDE.md. Relative target survives directory moves.
# Skipped when CLAUDE.md is a regular file (claude-code/studio-code runtimes
# manage their own template-based CLAUDE.md).
# See: Extra-Chill/wp-coding-agents#108
_opencode_symlink_claude_md() {
local agents_md="$SITE_PATH/AGENTS.md"
local claude_md="$SITE_PATH/CLAUDE.md"
[ -f "$agents_md" ] || return 0
if [ -L "$claude_md" ] || [ ! -e "$claude_md" ]; then
(cd "$SITE_PATH" && ln -sf AGENTS.md CLAUDE.md)
log "Symlinked CLAUDE.md → AGENTS.md (covers Claude-model opencode sessions)"
fi
}

Expand Down
19 changes: 19 additions & 0 deletions upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,12 @@ regenerate_agents_md() {

local AGENTS_MD="$SITE_PATH/AGENTS.md"
local BACKUP="$SITE_PATH/AGENTS.md.backup.$TIMESTAMP"
local CLAUDE_MD="$SITE_PATH/CLAUDE.md"

if [ "$DRY_RUN" = true ]; then
echo -e "${BLUE}[dry-run]${NC} Would backup $AGENTS_MD → $BACKUP"
echo -e "${BLUE}[dry-run]${NC} Would run: $WP_CMD datamachine memory compose AGENTS.md $WP_ROOT_FLAG"
echo -e "${BLUE}[dry-run]${NC} Would symlink $CLAUDE_MD → AGENTS.md (Claude-model context)"
return 0
fi

Expand Down Expand Up @@ -575,6 +577,23 @@ regenerate_agents_md() {
warn " Restored AGENTS.md from backup"
fi
fi

# Symlink CLAUDE.md → AGENTS.md so Claude-model sessions get the same DM context.
# OpenCode reads both filenames from the cwd glob (AGENTS.md, CLAUDE.md, CONTEXT.md),
# Claude Code reads only CLAUDE.md. Symlink keeps both runtimes covered without
# duplicating content or risking drift on AGENTS.md regeneration. Relative target
# ensures the symlink survives directory moves.
# See: Extra-Chill/wp-coding-agents#108
if [ -f "$AGENTS_MD" ]; then
# Skip if CLAUDE.md exists as a regular file (e.g. claude-code/studio-code runtimes
# generate their own CLAUDE.md from a template — don't clobber it).
if [ -L "$CLAUDE_MD" ] || [ ! -e "$CLAUDE_MD" ]; then
(cd "$SITE_PATH" && ln -sf AGENTS.md CLAUDE.md)
log " Symlinked CLAUDE.md → AGENTS.md (covers Claude-model opencode sessions)"
else
log " CLAUDE.md exists as a regular file — leaving it alone (runtime-managed)"
fi
fi
}

# ============================================================================
Expand Down
Loading