-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add algolia-migration skill for API client upgrades #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MarioAlexandruDan
wants to merge
47
commits into
main
Choose a base branch
from
feat/add-algolia-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
c493b39
feat: add algolia-migration skill for API client upgrades
MarioAlexandruDan 4b3e993
fix(algolia-migration): address pr-review findings
MarioAlexandruDan a8968b6
fix(algolia-migration): correct method signatures from source verific…
MarioAlexandruDan 9549dbf
fix(algolia-migration): correct Go helper method signatures
MarioAlexandruDan 1591e01
fix(algolia-migration): correct Java saveObjects overload in eval #6
MarioAlexandruDan 1e8149b
fix(algolia-migration): source-verified corrections across 6 language…
MarioAlexandruDan 9f696c9
fix(algolia-migration): final source-verified corrections
MarioAlexandruDan 33b6ae9
fix(algolia-migration): csharp.md method renames table uses Operation…
MarioAlexandruDan ef50196
fix(algolia-migration): source-verified corrections from final testin…
MarioAlexandruDan 8cf8dcc
fix(algolia-migration): source-verified option function names in go.md
MarioAlexandruDan da850a5
fix(algolia-migration): SKILL.md browse pattern varies by language
MarioAlexandruDan f5bc4f8
fix(algolia-migration): C# browse uses aggregator callback, not IEnum…
MarioAlexandruDan 5c4c2db
feat(algolia-migration): rewrite all 11 reference files from official…
MarioAlexandruDan 4b603c3
feat(algolia-migration): rewrite reference files from official upgrad…
MarioAlexandruDan f0ee057
Update .claude-plugin/marketplace.json
MarioAlexandruDan 3531196
Update skills/algolia-migration/SKILL.md
MarioAlexandruDan c0740e7
Update skills/algolia-migration/SKILL.md
MarioAlexandruDan 57dd946
Update skills/algolia-migration/SKILL.md
MarioAlexandruDan 888112d
Update skills/algolia-migration/SKILL.md
MarioAlexandruDan 3306fdf
Update skills/algolia-migration/SKILL.md
MarioAlexandruDan 09bd626
Update README.md
MarioAlexandruDan 635c40f
feat(algolia-migration): remove Kotlin and Dart from scope
MarioAlexandruDan cf050dd
feat(algolia-migration): remove dart.md (new client, no migration)
MarioAlexandruDan 82f119f
fix(algolia-migration): clean rendering artifacts from all reference …
MarioAlexandruDan bfa2225
Delete pr-review-26.md
MarioAlexandruDan cb9f2cf
fix(csharp): correct API signatures and code examples against v7 client
MarioAlexandruDan 09e5bd7
fix(go): correct API signatures, option names, and constants against …
MarioAlexandruDan 5a7ec20
fix(java): correct helper signatures, return types, and overloads aga…
MarioAlexandruDan 72a71d1
fix(javascript): replaceAllObjects scopes is optional, not required
MarioAlexandruDan 37cb451
docs(skill): note JS v5 accountCopyIndex exception in AccountClient s…
MarioAlexandruDan ae4aef6
fix(php): correct helper signatures, iterator usage, and transformati…
MarioAlexandruDan 36c64d1
fix(python): invalid syntax in v3 examples, scopes optional, correct …
MarioAlexandruDan 7ba5fe8
fix(ruby): browse block receives individual records, scopes optional,…
MarioAlexandruDan 29e919d
fix(scala): return types, browseParams name, required params, for-com…
MarioAlexandruDan 8d648db
fix(swift): instance methods not static, required browse params, save…
MarioAlexandruDan 9306933
fix(review): SaveObjectsAsync return type, scopes optional in SKILL.m…
MarioAlexandruDan 603fb88
fix(js): saveObjects returns BatchResponse[], use waitForTasks; fix e…
MarioAlexandruDan 6d73bae
fix(evals): Dart eval #11 should expect out-of-scope refusal, not wor…
MarioAlexandruDan 2b49b5e
fix(go,php): residual option names in transformation sections
MarioAlexandruDan cb9b836
feat(kotlin): add Kotlin v2→v3 migration reference
MarioAlexandruDan 13c8f20
feat(evals): add Kotlin v2→v3 eval at ID 8
MarioAlexandruDan 4f3f9a7
Merge branch 'main' into feat/add-algolia-migration
MarioAlexandruDan 04d9be9
docs(references): align migration references with docs-new upgrade gu…
MarioAlexandruDan 3b01aa4
Merge remote-tracking branch 'origin/main' into feat/add-algolia-migr…
MarioAlexandruDan ef8ddad
Merge remote-tracking branch 'origin/feat/add-algolia-migration' into…
MarioAlexandruDan 5daf44c
docs(references): regenerate all references from merged docs-new upgr…
MarioAlexandruDan a431a0c
fix: address Copilot review feedback on migration skill
MarioAlexandruDan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| --- | ||
| name: algolia-migration | ||
| description: >- | ||
| Migrate existing Algolia API client code to a newer major version. | ||
| Triggers on: upgrading algoliasearch, moving from initIndex to client methods, | ||
| fixing "initIndex is not a function", updating imports after a version bump, | ||
| handling breaking changes from v3→v4 or v4→v5, replacing .wait() chaining, | ||
| or any mention of "migrate Algolia client", "upgrade Algolia SDK", or a | ||
| specific old-to-new version (e.g. "Python v3 to v4", "JS v4 to v5"). | ||
| Covers JavaScript, Python, Go, PHP, Java, C#, Ruby, Kotlin, Scala, Swift. Dart is a new client and is excluded from scope. | ||
| Do NOT use for new project setup (use algolia-cli or algolia-mcp instead), | ||
| InstantSearch / frontend frameworks, analytics queries, or recommendations. | ||
| license: MIT | ||
| metadata: | ||
| author: algolia | ||
| version: "1.0" | ||
| --- | ||
|
|
||
| # Algolia API Client Migration | ||
|
|
||
| > This skill covers **API client upgrades** (backend and frontend search-only builds). | ||
| > For frontend search UI, see **instantsearch**. For index operations, see **algolia-cli**. | ||
|
|
||
| ## Supported migrations | ||
|
|
||
| | Language | Migration | Reference | | ||
| |------------|--------------|-----------| | ||
| | JavaScript | v4 → v5 | [references/javascript.md](references/javascript.md) | | ||
| | Python | v3 → v4 | [references/python.md](references/python.md) | | ||
| | Go | v3 → v4 | [references/go.md](references/go.md) | | ||
| | PHP | v3 → v4 | [references/php.md](references/php.md) | | ||
| | Java | v3 → v4 | [references/java.md](references/java.md) | | ||
| | C# | v6 → v7 | [references/csharp.md](references/csharp.md) | | ||
| | Ruby | v2 → v3 | [references/ruby.md](references/ruby.md) | | ||
| | Kotlin | v2 → v3 | [references/kotlin.md](references/kotlin.md) | | ||
| | Scala | v1 → v2 | [references/scala.md](references/scala.md) | | ||
| | Swift | v8 → v9 | [references/swift.md](references/swift.md) | | ||
|
|
||
| Open the matching reference file before writing any migration code. | ||
|
|
||
| ## Universal breaking changes | ||
|
|
||
| Every language migration shares the same set of architectural shifts. Understand these first; the reference files add language-specific syntax on top. | ||
|
|
||
| ### 1. `initIndex` is gone | ||
|
|
||
| The index object pattern is eliminated in every language. All methods moved to the **client** with `indexName` as an explicit parameter. | ||
|
|
||
| **The fix:** remove `initIndex` / `init_index` / `index(withName:)`, call the method on the client, pass `indexName`. | ||
|
|
||
| **Grep to find all affected call sites:** | ||
| ``` | ||
| grep -r "initIndex\|init_index\|InitIndex\|index(withName" . | ||
| ``` | ||
|
|
||
| ### 2. `.wait()` chaining is gone | ||
|
|
||
| Chained `.wait()` / `!` bang methods on task responses are replaced by dedicated wait helpers. | ||
|
|
||
| | Old | New | | ||
| |-----|-----| | ||
| | `index.saveObjects(records).wait()` | `client.waitForTask(...)` with the index name and task ID | | ||
| | `index.save_objects!(objects)` (Ruby) | `client.save_objects(index_name, objects, true)` | | ||
|
|
||
| Three helpers available in every language: `waitForTask`, `waitForAppTask`, `waitForApiKey`. The exact calling convention varies by language (e.g. JS v5 takes an options object, Python uses keyword arguments) — see the language reference for the precise signature. | ||
|
|
||
| ### 3. `copyIndex` / `moveIndex` → `operationIndex` | ||
|
|
||
| All index copy and move operations, including scoped copies (`copyRules`, `copySettings`, `copySynonyms`), consolidate into a single `operationIndex` call with `operation: "copy"` or `"move"` and an optional `scope` array. | ||
|
|
||
| ### 4. `objectID` is required in `saveObjects` | ||
|
|
||
| `autoGenerateObjectIDIfNotExist` is removed. Every object passed to `saveObjects` must include an explicit `objectID`. To let the API generate IDs, use `chunkedBatch` with `action: addObject`. | ||
|
|
||
| ### 5. `replaceAllObjects` — `scopes` is optional | ||
|
|
||
| The `safe` option is removed. The `scopes` parameter defaults to `["settings", "rules", "synonyms"]` in every language — you only need to pass it explicitly if you want a subset. | ||
|
|
||
| ### 6. Browse helpers change pattern | ||
|
|
||
| The old iterator/chained patterns are gone. The new pattern **varies by language** — check the reference file: | ||
|
|
||
| - **Aggregator callback** (JS, Python, Go, Ruby, Scala, Swift): pass an `aggregator` function that receives each page response | ||
| - **Iterable** (C#, Java): the helper returns an `IEnumerable<T>` / `Iterable<T>` — iterate with `foreach` or `.forEach()` | ||
| - **Iterable / foreach** (PHP): the method returns `ObjectIterator` — iterate with a for-each loop | ||
|
|
||
| ### 7. `AccountClient` is gone | ||
|
|
||
| Cross-application index copies now require composing helpers across two client instances manually: get settings from source, set on destination; browse + save for rules, synonyms, and objects. | ||
|
MarioAlexandruDan marked this conversation as resolved.
|
||
|
|
||
| JavaScript exception: v5 ships `client.accountCopyIndex({ sourceIndexName, destinationAppID, destinationApiKey, destinationIndexName, ... })` as a built-in. No manual composition needed, but the call signature differs from v4's `accountCopyIndex(srcIndex, destIndex)` — see references/javascript.md. | ||
|
|
||
| ### 8. Dedicated clients per API | ||
|
|
||
| Each API now has its own client class. If the code previously imported one monolithic client, update imports for `RecommendClient`, `AnalyticsClient`, `AbtestingClient`, etc. | ||
|
|
||
| ## Migration workflow | ||
|
|
||
| 1. **Detect language and version** from the project's package manifest (`package.json`, `go.mod`, `composer.json`, `pom.xml`, `Gemfile`, etc.). | ||
| 2. **Open the matching reference file** from the table above. | ||
| 3. **Grep for `initIndex`** (and language equivalents) to enumerate all call sites. | ||
| 4. **Update the install / dependency** first so the compiler/runtime flags all remaining issues. | ||
| 5. **Apply universal changes** (sections above) before language-specific ones. | ||
| 6. **Replace wait patterns** — search for `.wait()`, `waitTask`, `wait_task`, bang methods. | ||
| 7. **Verify** by running the existing test suite or a minimal integration test. | ||
|
|
||
| ## Direct Invocation | ||
|
|
||
| If the skill doesn't trigger automatically, invoke it directly: | ||
|
|
||
| - **`/algolia-migration`** — Load the full skill for any Algolia client upgrade task | ||
|
|
||
| This is useful when the request is brief (e.g., "update my Algolia imports") and the skill might not auto-trigger. | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.