Skip to content

feat: consolidate SiteContext into SITE.md with auto-refresh#875

Merged
chubes4 merged 1 commit intomainfrom
feature/871-consolidate-site-context
Mar 19, 2026
Merged

feat: consolidate SiteContext into SITE.md with auto-refresh#875
chubes4 merged 1 commit intomainfrom
feature/871-consolidate-site-context

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 19, 2026

Summary

  • Eliminates duplicate site context injection — AI calls were getting site info twice (SITE.md at priority 20 + SiteContextDirective JSON at priority 80). Now it's just SITE.md.
  • Enriches SITE.md with all the data SiteContext provided: post counts, taxonomy term counts, hierarchy, associations, language, timezone, permalinks — all as markdown tables.
  • Auto-refreshes SITE.md on disk when site structure changes (hooks: save_post, switch_theme, activated_plugin, etc.) with 60-second debounce.

Before → After

BEFORE (every AI call):
├── Priority 20: SITE.md (static, 22 lines, never refreshed)
└── Priority 80: SiteContextDirective JSON (live, auto-refreshed)
    ← DUPLICATE

AFTER (every AI call):
└── Priority 20: SITE.md (live, auto-refreshed, enriched with counts/details)
    ← SINGLE SOURCE OF TRUTH

Changes across 5 files

File What changed
migrations.php Enriched datamachine_get_site_scaffold_content() with post/taxonomy tables, language, timezone, permalinks. Added datamachine_regenerate_site_md() with debounce + custom content preservation. Added datamachine_register_site_md_invalidation() hook registration.
bootstrap.php Replaced SiteContext cache invalidation + SiteContextDirective include with datamachine_register_site_md_invalidation()
SiteContext.php Deprecated to no-op (class kept for backward compat)
SiteContextDirective.php Deprecated to no-op (class kept, not registered in directive chain)
data-machine.php Calls datamachine_regenerate_site_md() on activation + cleans up legacy transient

Sample enriched SITE.md output

# SITE

## Identity
- **name:** chubes.net
- **url:** https://chubes.net
- **theme:** Chubes
- **language:** en_US
- **timezone:** America/Chicago
- **permalinks:** /%postname%/
- **multisite:** false

## Post Types
| Label | Slug | Published | Type |
|-------|------|-----------|------|
| Posts | post | 42 | flat |
| Pages | page | 12 | hierarchical |
| Documentation | documentation | 28 | hierarchical |

## Taxonomies
| Label | Slug | Terms | Type | Post Types |
|-------|------|-------|------|------------|
| Categories | category | 8 | hierarchical | post |
| Tags | post_tag | 24 | flat | post |
| Projects | project | 5 | hierarchical | documentation |

## Active Plugins
- FluentSMTP
- DocSync
- Yoast SEO

Testing

  • All 5 files pass php -l syntax check
  • PHPUnit: 906 tests, same pass/fail as main (5 errors, 24 failures — all pre-existing)
  • site_context_enabled setting repurposed to control SITE.md auto-refresh
  • User-added content below <!-- CUSTOM --> marker is preserved across regenerations

Backward Compatibility

  • SiteContext class and SiteContextDirective class are deprecated, not deleted
  • Both return empty/no-op to avoid fatal errors in third-party code
  • datamachine_site_context and datamachine_site_context_directive filters no longer fire (no known consumers)
  • Will be fully removed in a future major version

Closes #871. Related: #872 (additional enrichment beyond SiteContext data).

SITE.md was meant to replace SiteContext but both systems remained,
injecting site context into every AI call twice (SITE.md at priority 20
as static markdown, SiteContextDirective at priority 80 as live JSON).

This consolidation:
- Enriches SITE.md scaffold with all SiteContext data: post counts per
  type, taxonomy term counts with hierarchy/associations, language,
  timezone, permalink structure — rendered as markdown tables
- Adds datamachine_regenerate_site_md() with 60-second debounce
  transient to auto-refresh SITE.md on structural changes (same hooks
  SiteContext used: save_post, switch_theme, activated_plugin, etc.)
- Preserves user-added content below <!-- CUSTOM --> marker
- Deprecates SiteContext class and SiteContextDirective to no-ops
  (kept for backward compat, will be removed in a future major version)
- Removes SiteContextDirective from the directive chain — no more
  duplicate site context in AI prompts
- Repurposes site_context_enabled setting to control SITE.md auto-refresh
- Cleans up legacy SiteContext transient on activation

Single source of truth: SITE.md, injected once via CoreMemoryFilesDirective.

Closes #871.
@github-actions
Copy link

github-actions bot commented Mar 19, 2026

Homeboy Results — data-machine

Lint

Failure Digest

Lint Failure Digest

Autofixability classification

  • Overall: human_needed
  • Autofix enabled: no
  • Autofix attempted this run: no
  • Human-needed failed commands:
    • lint
  • Failed commands with available automated fixes:
    • lint
  • Automated fixes are disabled for this step. Commands with available fix support in this run: lint

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

lint (changed files only)

Test

Failure Digest

Test Failure Digest

Autofixability classification

  • Overall: human_needed
  • Autofix enabled: no
  • Autofix attempted this run: no
  • Human-needed failed commands:
    • test
  • Failed commands with available automated fixes:
    • test
  • Automated fixes are disabled for this step. Commands with available fix support in this run: test

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

test (changed files only)

Audit

⚡ Scope: changed files only

audit (changed files only)

Tooling versions
  • Homeboy CLI: homeboy 0.81.1+b2a8c69b
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v1

Homeboy Action v1

@chubes4 chubes4 merged commit 9453cbc into main Mar 19, 2026
1 of 3 checks passed
@chubes4 chubes4 deleted the feature/871-consolidate-site-context branch March 19, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate SiteContext into SITE.md — remove duplicate site context system

1 participant