Open
Conversation
Adds a server-side AI chat assistant (Do It For Me tier) that lets merchants ask questions about their store using a Bring Your Own Key Anthropic API key — no Claude Desktop or MCP setup required. Key pieces: - AnthropicClient: thin wp_remote_post wrapper for the Anthropic messages API, with constant-first key priority chain and a cheap validate_key() call on settings save. - DifmRestController: POST /hey-woo/v1/difm/chat endpoint that fetches a 1-hour-cached store context snapshot (revenue, orders, refunds, customers, top-10 products via existing analytics abilities) and injects it as JSON into the Claude system prompt so answers are grounded in real store data. - DifmAdminPage: WooCommerce submenu page (Hey Woo!) that enqueues the React chat UI via @wordpress/scripts / wp_enqueue_script(). - React chat UI (TypeScript + SCSS, webpack via @wordpress/scripts): full-height scrollable message history, typing indicator, inline error bar with Dismiss, Enter-to-send compose bar. - Settings: password field for the Anthropic API key with key validation on save and constant-override support. - Integration tests for AnthropicClient and DifmRestController. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@wordpress/scripts(webpack), rendering inside the standard WooCommerce admin chromeWhat's included
PHP
includes/difm/class-anthropic-client.php— thinwp_remote_postwrapper; constant-first key priority chain (HEY_WOO_ANTHROPIC_KEY>wp_options);validate_key()called on settings saveincludes/difm/class-difm-rest-controller.php—POST /hey-woo/v1/difm/chat+POST /hey-woo/v1/difm/key/validate; store context fetched and cached per-dayincludes/difm/class-difm-admin-page.php— WooCommerce submenu page that enqueues the React bundle viawp_enqueue_script()includes/settings/class-settings-page.php— new DIFM section withpasswordfield for the API keyTypeScript / React (
packages/today/src/)useChat.tshook — manages message history,sendingstate, and REST callsApp.tsx— chat layout: header, scrollablerole="log"message list, typing indicator, inline error barChatBubble,ChatInput,NoKey,Loading,Errorcomponentsstyle.scss— scoped chat styles (.hey-woo-page,.hey-woo-bubble,.hey-woo-typing-indicator, etc.)Tests
tests/integration/test-anthropic-client.php— key priority chain,validate_key()with mocked HTTPtests/integration/test-difm-rest-controller.php— route registration, permission checks,no_keyresponse, chat reply flowTest plan
./bin/check— 274 tests pass, PHPCS clean🤖 Generated with Claude Code