Rename to Sitesearch, Add Vertex AI Search and AddSearch - #15
Open
khamer wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Rename package to imarc/craft-sitesearch (handle: sitesearch), replacing imarc/craft-googlecustomsearch - Provider adapters: Google Custom Search, Google Vertex AI Search (google/auth service account or ADC), AddSearch - Per-site provider selection in settings; all fields env-parseable - Unified result shape plus raw provider response - craft.siteSearch variable; craft.googlecustomsearch kept as deprecated alias - Install migration copies old googlecustomsearch settings - PHPUnit mapping tests for all three adapters Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR rebrands the plugin to Site Search (imarc/craft-sitesearch) and introduces a multi-provider adapter architecture to support Google Custom Search, Google Vertex AI Search (Discovery Engine), and AddSearch while keeping a unified template result shape (plus a new raw field).
Changes:
- Renames namespaces/handles/docs to
sitesearchand adds deprecated template-variable aliases for v3 (craft.googlecustomsearch/craft.googleCustomSearch). - Adds provider adapters (GCS, Vertex, AddSearch) and updates
SearchServiceto resolve the per-site provider and delegate requests. - Adds PHPUnit mapping tests + fixtures, plus docs/specs describing the multi-provider design and upgrade path.
Reviewed changes
Copilot reviewed 25 out of 30 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/fixtures/vertex-response.json | Adds a Vertex fixture used for adapter mapping tests. |
| tests/fixtures/gcs-response.json | Adds a GCS fixture used for adapter mapping tests. |
| tests/fixtures/addsearch-response.json | Adds an AddSearch fixture used for adapter mapping tests. |
| tests/AdapterMappingTest.php | Introduces unit tests validating unified result mapping for each provider. |
| src/variables/SearchVariable.php | Renames template variable namespace and keeps performSearch() entry point. |
| src/variables/LegacySearchVariable.php | Adds deprecated alias variable that logs deprecations for v3 templates. |
| src/translations/en/sitesearch.php | Adds new translation category for the renamed plugin. |
| src/translations/en/googlecustomsearch.php | Removes old translation file tied to the previous handle. |
| src/templates/settings.twig | Updates CP settings UI to select provider and show provider-specific fields. |
| src/services/SearchService.php | Delegates searches/connection tests to the resolved provider adapter. |
| src/Plugin.php | Rebrands plugin handle/namespace and wires new template variables + settings persistence. |
| src/models/Settings.php | Expands per-site settings schema to include provider + provider-specific credentials. |
| src/migrations/Install.php | Copies legacy googlecustomsearch project-config settings into sitesearch on install. |
| src/controllers/ConnectionController.php | Renames controller namespace/imports for the rebranded plugin. |
| src/config.php | Updates example config to config/sitesearch.php and documents all providers. |
| src/assetbundles/sitesearch/SitesearchAsset.php | Renames/relocates CP asset bundle for the new plugin handle. |
| src/assetbundles/sitesearch/dist/js/Sitesearch.js | Updates asset headers for the renamed plugin. |
| src/assetbundles/sitesearch/dist/img/Sitesearch-icon.svg | Adds an icon asset for the renamed plugin. |
| src/assetbundles/sitesearch/dist/css/Sitesearch.css | Updates asset headers for the renamed plugin. |
| src/adapters/VertexSearchAdapter.php | Adds Vertex AI Search adapter (auth + request + response mapping). |
| src/adapters/GoogleCustomSearchAdapter.php | Adds GCS adapter extracted from prior SearchService behavior. |
| src/adapters/AddSearchAdapter.php | Adds AddSearch adapter (request + response mapping). |
| src/adapters/AdapterInterface.php | Defines the adapter contract and unified-result expectations. |
| README.md | Rewrites docs for multi-provider setup and v3→v4 upgrade guidance. |
| phpunit.xml | Adds PHPUnit configuration for running the new unit tests. |
| docs/superpowers/specs/2026-07-07-sitesearch-multiprovider-design.md | Adds an internal design spec describing architecture and success criteria. |
| composer.json | Renames package + autoload namespace, adds google/auth, adds PHPUnit dev dependency. |
| CHANGELOG.md | Updates changelog for v4 rebrand and new providers. |
| .gitignore | Ignores PHPUnit result cache. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+82
to
+83
| 'image' => $result->pagemap->cse_image[0]->src ?? '', | ||
| 'thumbnail' => $result->pagemap->cse_thumbnail[0]->src ?? '', |
Comment on lines
75
to
+77
| public function performSearch($terms, $page, $per_page, $extra) | ||
| { | ||
| // Google only allows 10 results at a time | ||
| $per_page = ($per_page > 10) ? 10 : $per_page; | ||
|
|
||
| $params = [ | ||
| 'q' => $terms, | ||
| 'start' => (($page - 1) * $per_page) + 1, | ||
| 'num' => $per_page | ||
| ]; | ||
|
|
||
| if (sizeof($extra)) { | ||
| $params = array_merge($params, $extra); | ||
| } | ||
|
|
||
| $response = $this->request($params); | ||
| $response = $this->getAdapter()->search((string)$terms, (int)$page, (int)$per_page, $extra); |
| public function __construct(array $settings) | ||
| { | ||
| $this->projectId = $settings['projectId'] ?? ''; | ||
| $this->location = $settings['location'] ?: 'global'; |
Comment on lines
+80
to
+81
| $data = $result->document->derivedStructData ?? new \stdClass(); | ||
| $htmlSnippet = $data->snippets[0]->snippet ?? ''; |
Comment on lines
+88
to
+89
| 'image' => $data->pagemap->cse_image[0]->src ?? '', | ||
| 'thumbnail' => $data->pagemap->cse_thumbnail[0]->src ?? '', |
Comment on lines
+77
to
+78
| 'image' => $hit->images->main ?? '', | ||
| 'thumbnail' => $hit->images->capture ?? '', |
Comment on lines
55
to
+58
| "require-dev": { | ||
| "craftcms/rector": "dev-main" | ||
| "craftcms/rector": "dev-main", | ||
| "phpunit/phpunit": "^10.0" | ||
| }, |
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.
I've tested this locally with both AddSearch and Vertex AI - it works with both. This is meant to be transitional, and we'll likely remove GCSE entirely from the plugin in nearly 2027.