chore: made so cursor rules is downloaded on init#778
Conversation
WalkthroughUpdates add a standardized subgraph migration MDC to shared templates and tighten the repository-local migration MDC: stricter filename/structure requirements, mandatory Effect API usage for external calls, expanded environment-variable setup, and reinforced validation/checklist wording. Changes are documentation-only. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used🧠 Learnings (19)📚 Learning: 2025-08-11T08:42:57.311ZApplied to files:
📚 Learning: 2025-08-11T08:47:04.346ZApplied to files:
📚 Learning: 2025-08-11T08:49:57.399ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-08-11T08:49:57.399ZApplied to files:
📚 Learning: 2025-08-11T08:47:04.346ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-08-11T08:47:04.346ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-08-11T08:49:57.399ZApplied to files:
📚 Learning: 2025-09-04T14:42:53.500ZApplied to files:
📚 Learning: 2025-08-11T08:42:57.311ZApplied to files:
📚 Learning: 2025-08-11T08:42:57.311ZApplied to files:
📚 Learning: 2025-08-11T08:49:57.399ZApplied to files:
📚 Learning: 2025-08-11T08:42:57.311ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
.cursor/rules/subgraph-migration.mdc (4)
248-252: Missing backtick and punctuation in @derivedFrom sentenceClose the inline code and fix punctuation for clarity.
Apply this diff:
-**Envio requires explicit relationship definitions** via `@derivedFrom -- **But the arrays are virtual** - they exist only in the API, not in handlers +**Envio requires explicit relationship definitions** via `@derivedFrom` +- **But the arrays are virtual** — they exist only in the API, not in handlers
603-606: Incorrect TypeScript types and methods for BigDecimal example
BigInt(capitalized) is not a TS type (usebigint).divDecimalandBigDecimal.fromStringmirror TheGraph/AssemblyScript, not Envio TS BigDecimal usage.Replace with a TS-accurate example. For instance:
-export function convertEthToDecimal(eth: BigInt): BigDecimal { - // Only depends on constants and BigDecimal math - no entity or handler dependencies - return eth.divDecimal(BigDecimal.fromString('1000000000000000000')); -} +import { BigDecimal } from 'generated'; +const WEI_IN_ETH = new BigDecimal('1000000000000000000'); +export function convertEthToDecimal(wei: bigint): BigDecimal { + // Convert bigint to BigDecimal, then divide + return new BigDecimal(wei.toString()).div(WEI_IN_ETH); +}Please also align other BigDecimal usages to TS methods (e.g.,
div,multipliedBy, depending on the re-export). Based on learnings
1156-1180: Effect output schema mismatches returned value; null union likely incorrectThe example sets
output: S.union([S.string, null])yet returnssomething.json()(an object). Use an object schema or return a string, and useS.null()(or the correct null schema) instead ofnull.Apply one of:
- output: S.union([S.string, null]), + output: S.union([S.object({ $$$: S.unknown }), S.null()]), @@ - return something.json(); + return await something.json();Or if returning text:
- output: S.union([S.string, null]), + output: S.union([S.string, S.null()]), @@ - return something.json(); + return await something.text();Also consider adding a brief note on error status handling (non-2xx). Based on learnings
53-56: Update Node.js version requirement
Replace the “Node.js v20 only (no higher or lower versions)” bullet with “Node.js v22 or newer (tested on v22.x)” to match current HyperIndex prerequisites.
♻️ Duplicate comments (3)
codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc (3)
241-245: Repeat: StandardizewherevsgetWhereAPIPlease mirror the chosen API consistently here as well.
Also applies to: 861-865, 1812-1816
1156-1180: Repeat: Effect schema/return mismatch and null unionSame issue as the root MDC; please apply the same fix here to keep examples correct.
603-606: Repeat: BigDecimal example uses incorrect TS types/methodsSame correction applies here; align to TS BigDecimal usage and
bigint.
🧹 Nitpick comments (3)
.cursor/rules/subgraph-migration.mdc (2)
241-245: Inconsistent query API:wherevsgetWhereExamples alternate between
context.Entity.where...andcontext.Entity.getWhere.... Standardize on the correct API name used by the current Envio version to avoid confusion.Would you confirm the correct helper and update all examples to match? If helpful, I can submit a unified snippet once you confirm the API. Based on learnings
Also applies to: 861-865, 1812-1816
1071-1075: BigDecimal source ambiguity (generated vs external dependency)Doc says to install
bignumber.jsbut later importsBigDecimalfromgenerated. Clarify the single source of truth to prevent confusion.
- If
generatedre-exports the BigDecimal type, remove the install step.- If not, standardize imports on the chosen library and update examples accordingly. Based on learnings
Also applies to: 1586-1591
codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc (1)
1-1882: Add CI step to verify subgraph-migration.mdc sync
- In CI, run:
diff -u ".cursor/rules/subgraph-migration.mdc" "codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc"- Consolidate to a single source of truth for this MDC template to avoid duplication drift.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.cursor/rules/subgraph-migration.mdc(9 hunks)codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc(1 hunks)
🧰 Additional context used
🧠 Learnings (19)
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Always include HyperIndex documentation and the Uniswap v4 and Safe example indexers as context when working on the indexer
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:47:04.346Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/fuel_test/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:47:04.346Z
Learning: Always load and reference HyperIndex docs and example indexers during development (docs.envio.dev HyperIndex, Uniswap v4 indexer, Safe indexer)
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Include HyperIndex documentation and example indexers (Uniswap v4 and Safe) in the context during development
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: After every code change, run runtime tests using `TUI_OFF=true pnpm dev` and watch for errors before proceeding
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Once compilation succeeds, run: TUI_OFF=true pnpm dev to check for runtime errors
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:47:04.346Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/fuel_test/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:47:04.346Z
Learning: Once compilation is successful, run `TUI_OFF=true pnpm dev` to catch runtime errors
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/contract*.ts : Split handlers into contract-specific files (e.g., src/contract1.ts, src/contract2.ts, src/contract3.ts) as skeletons without business logic in Step 3
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/{utils,intervals}/*.ts : Create skeleton utility and interval files (utils/constants.ts, utils/helpers.ts, intervals/timeUpdates.ts) with TODOs referencing the original subgraph
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/EventHandlers.ts : Remove the original EventHandlers.ts file after moving handlers to contract-specific files
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/EventHandlers.ts : Clear boilerplate logic in EventHandlers.ts and replace handlers with empty skeletons with TODOs in Step 1
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/**/*.ts : Avoid hardcoded addresses/values; use constants from original subgraph (e.g., FACTORY_ADDRESS, ADDRESS_ZERO)
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:47:04.346Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/fuel_test/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:47:04.346Z
Learning: Applies to scenarios/fuel_test/**/*.ts : With preload enabled (handlers run twice), all external calls (e.g., fetch) MUST be implemented via the Envio Effect API (experimental_createEffect and context.effect)
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/effects/*.ts : Place external/RPC call logic in Effect API modules (experimental_createEffect) under src/effects, with schemas and error handling
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Applies to scenarios/test_codegen/**/*.ts : For any external call (e.g., fetch), wrap it in an Effect via experimental_createEffect and consume via context.effect
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-09-04T14:42:53.500Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: .cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-09-04T14:42:53.500Z
Learning: Applies to src/**/*.ts : Call external/RPC operations via context.effect(effectFn, input) within handlers; avoid direct RPC calls and .bind() patterns
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : All external calls must be made via the Envio Effect API when preload optimisations are enabled
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Use `context.effect` to consume effects from handlers rather than calling external services directly
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:49:57.399Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: scenarios/test_codegen/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:49:57.399Z
Learning: Applies to scenarios/test_codegen/**/*.ts : After changing any TypeScript files, run: pnpm tsc --noEmit to ensure successful compilation
Applied to files:
.cursor/rules/subgraph-migration.mdc
📚 Learning: 2025-08-11T08:42:57.311Z
Learnt from: CR
PR: enviodev/hyperindex#0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-08-11T08:42:57.311Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
Applied to files:
.cursor/rules/subgraph-migration.mdc
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (2)
.cursor/rules/subgraph-migration.mdc (1)
908-929: Step 7 addition is excellentEnumerating env vars and documenting
.env.examplewill prevent runtime misconfigurations. LGTM.Based on learnings
codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc (1)
908-929: Approve Step 7 in the template copy as wellGreat addition; ensures new projects document envs from day one.
| - [ ] **Stop the background process** after confirming it runs without errors | ||
| - [ ] **Only proceed to the next step** after confirming the indexer runs without errors | ||
|
|
||
| **Common Runtime Errors to Watch For:**s |
There was a problem hiding this comment.
Typo in heading
Remove the trailing "s" after the bolded heading.
Apply this diff:
-**Common Runtime Errors to Watch For:**s
+**Common Runtime Errors to Watch For:**📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| **Common Runtime Errors to Watch For:**s | |
| **Common Runtime Errors to Watch For:** |
🤖 Prompt for AI Agents
In .cursor/rules/subgraph-migration.mdc at line 88, the bolded heading "**Common
Runtime Errors to Watch For:**s" contains a stray trailing "s"; remove that
extra character so the heading reads "**Common Runtime Errors to Watch For:**".
Make the change in-place on that line only.
04ece9e to
9eff9cf
Compare
|
Cool @keenbeen32 👍🏼 I'm not fully familiar with the project but all good with these changes. Are these llm docs written in this repo or do they come from docs somewhere? Might be worth setting up a pipeline so that it gets updated here when anything changes if thats the case. |
|
@JonoPrest Thanks that's a good point. At the moment I'm just copying them across to whatever new migration I'm doing's repo, then updating them as I migrate and copying the updated version back. It's really not an ideal system though😂 Will look into setting something better up, shot for the thought! |
|
@JonoPrest Also do you mind approving the changes if you're happy to so I can complete the merge🙏 |
Sorry I thought I had 👍🏼 |
Updated subgraph-migration.mdc file to latest version and made so downloaded on init.
Summary by CodeRabbit