Developer & API
Companion is built to be extended from outside: a sibling plugin contributes context with one filter, a theme hides GiGi with another, and every ability routes through the owning plugin’s public services rather than its tables. This page covers the public contract as of the current release; signatures change only with a major-version bump.
Filters
gather_grove/companion/retrieved_context
The cross-plugin context seam. Runs on every chat turn so any active plugin can add a slice of “current studio context” to the system prompt. Items are sorted by priority (higher survives budget pressure), packed into an 8,000-token budget, and what was included is recorded in the audit log.
apply_filters( 'gather_grove/companion/retrieved_context', array $items, array $context ): array
$context carries surface (companion, chat or mcp), page_context and user_id. Each item is an array with content (required), priority (knowledge base = 100, recent activity = 50, bulk detail 40 and below), source (a stable id for the audit trail) and an optional label. Keep contributions small and PII-safe — the retriever does not sanitise them, and on the chat surface they reach anonymous visitors.
add_filter( 'gather_grove/companion/retrieved_context', function ( array $items, array $context ): array {
if ( 'companion' !== ( $context['surface'] ?? '' ) ) {
return $items;
}
$items[] = [
'source' => 'my-plugin/recent_activity',
'priority' => 45,
'label' => 'Recent activity',
'content' => "- 3 new enquiries this week",
];
return $items;
}, 10, 2 );
gather_grove/companion/gigi_should_render
Whether the GiGi bubble renders on the current public request. Runs during wp_enqueue_scripts / wp_footer, so every conditional tag is available; the wp-admin guard runs first and cannot be overridden.
apply_filters( 'gather_grove/companion/gigi_should_render', bool $render, array $settings ): bool
add_filter( 'gather_grove/companion/gigi_should_render', static function ( bool $render ): bool {
return is_page( 'demo' ) ? false : $render;
} );
gather_grove/companion/should_file_entry
Last word on whether a completed Forms submission is filed as a PDF to the member’s Documents. Runs after the studio’s opt-in list, so it can only narrow — returning true for a form nobody opted in has no effect.
apply_filters( 'gather_grove/companion/should_file_entry', bool $should, string $form_uuid, string $entry_uuid, array $context ): bool
gather_grove/companion/rate_limit
Adjusts the per-surface sliding-window limits (defaults: 30/min for companion, 10/min for chat).
Trusted proxy header
The per-IP visitor limiter reads REMOTE_ADDR unless Gather Grove Core’s gather_grove/trusted_proxy_header filter names the header your CDN or proxy sets; Core then reads the rightmost entry, the one the trusted proxy appended, so a caller cannot forge it.
Actions
gather_grove/companion/agreement_filed
do_action( 'gather_grove/companion/agreement_filed', int $document_id, int $client_id, string $entry_uuid, string $form_uuid ): void
Fires after a signed submission has been rendered and stored as a client document in Booking. $client_id is the member the document was filed to — on a family account usually the child, not the submitting guardian. Does not fire when nothing was filed.
Ability packs
Abilities are grouped into conditionally-registered packs, each with a ServiceProvider implementing AbilitiesPackInterface:
| Pack | Registers when | Abilities today |
|---|---|---|
gather-grove | Booking is active | list_classes, find_package_by_interest, lookup_client, find_client, suggest_class_description, summarize_recent_activity, create_class_draft, comp_session, issue_studio_credit |
forms | Forms is active | list_forms, analyze_submissions, find_submission_by_field, summarize_responses |
notion-sync | Sync for Notion is active | check_sync_status, find_synced_entry, trigger_sync |
core | always | search_content, get_content, list_menus, list_content, search_media, site_overview, create_draft, update_content_status |
elementor | elementor/loaded has fired | list_elementor_templates, describe_elementor_template, create_page_from_elementor_template, save_as_elementor_template, duplicate_elementor_template |
Ability ids are namespaced gather-grove/companion/<name>. The one rule that matters: an ability never touches $wpdb against tables it does not own — it calls the owning plugin’s service layer, and a convention test fails the build if the token appears under a pack directory. Inputs are schema-validated before execute() runs; results are small, structured and PII-free.
Per-surface toggles live under ability_toggles in the gg_companion_settings option, shaped [ ability_id => [ surface => bool ] ]. The chat surface has a hard floor no toggle can override: no write abilities and nothing requiring a capability beyond gg_use_companion.
Capabilities
| Capability | Grants | Default roles |
|---|---|---|
gg_use_companion | The admin copilot and its abilities | administrator, editor, gg_admin |
gg_manage_ai | Settings, provider configuration, Inbox | administrator, gg_admin |
REST
All routes live under the gather-grove/companion/v1 namespace. Admin routes require a logged-in user with the capability above and the standard wp_rest nonce; visitor routes use a signed session token and the rate limits on Safety & limits.
| Route | Purpose |
|---|---|
POST /chat | Admin copilot turn; streams Server-Sent Events, with a polling fallback. |
GET|POST|DELETE /threads, /threads/{uuid} | The current user’s threads only. |
POST /ability | Run one ability directly (slash commands and the launcher grid). |
GET|POST /abilities/toggles | Per-surface ability toggles. |
GET /bootstrap, /providers, /diagnostics | Panel bootstrap data, provider status, the diagnostics snapshot. |
POST /gigi/session | Mint a visitor session token (v2, bound to address and user agent). |
POST /gigi/chat | Visitor turn; streams SSE. Model is resolved server-side. |
POST /gigi/contact, /gigi/lead, /gigi/bug-report, /gigi/handoff | Inbox intake; 8 KB body cap, 5 MB screenshot cap. |
/mcp | Registered but disabled — returns 501. A Model Context Protocol server for external AI clients is planned, not shipped. |
Where to look in the repo
docs/HOOKS.md is the canonical hook reference with worked examples, docs/ABILITIES.md explains the pack architecture and the service-layer rule, and docs/SECURITY.md is the operational security summary. src/Abilities/, src/Rest/ and src/Security/ are the code behind this page.
Applies to Gather Grove Companion v1.0.5. Last synced October 15, 2026.