modify-jsi-features

Guides adding new methods to the JSI Runtime interface across JSI core, Hermes, and SynthTrace layers.

11.3k|852|Updated Oct 22, 2018
One-click install
npx skills add https://github.com/facebook/hermes --skill modify-jsi-features
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modify-jsi-features
Source: https://github.com/facebook/hermes/tree/main/.claude/skills/modify-jsi-features
Command: npx skills add https://github.com/facebook/hermes --skill modify-jsi-features

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding a new method to the JSI Runtime interface requires coordinated changes across more than a dozen files spanning JSI core, the Hermes implementation, and SynthTrace replay infrastructure, and missing any one of them causes build failures or broken trace replays.

Core Features & Use Cases

  • Complete File Checklist: Enumerates all 16 files to modify across JSI core (jsi.h, jsi.cpp, decorator.h), Hermes (hermes.cpp), and SynthTrace (records, parsing, replay).
  • Implementation Patterns: Provides code templates for default JavaScript-based implementations versus pure virtual methods, plus optimized Hermes VM implementations.
  • Testing Guidance: Covers JSI core tests, Hermes API tests, and SynthTrace serialization, parser, and replay tests with buck test commands.
  • Use Case: When asked to add a method like setPrototypeOf to the JSI Runtime, follow the step-by-step guide to update the interface, decorators, Hermes implementation, and SynthTrace support with correct conventions.

Quick Start

Add a new method called myNewMethod to the JSI Runtime interface with full Hermes and SynthTrace support.

Frequently Asked Questions about modify-jsi-features

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new method to the JSI Runtime interface?

Add a pure virtual declaration to IRuntime and an override declaration to Runtime in jsi.h, then provide a default implementation in jsi.cpp using JavaScript calls. Update decorator.h, the Hermes implementation in hermes.cpp, and SynthTrace files for tracing support.

What files must change when adding JSI functionality in Hermes?

Sixteen files across three layers: JSI core (jsi.h, jsi.cpp, jsi-inl.h, decorator.h, testlib.cpp), Hermes (hermes.cpp, APITest.cpp), and SynthTrace (SynthTrace.h/cpp, TracingRuntime.h/cpp, SynthTraceParser.cpp, TraceInterpreter.cpp, and three test files).

Should JSI methods be pure virtual or have default implementations?

Prefer a default implementation in jsi::Runtime that works via JavaScript calls, so runtimes like JSC and V8 work without modification. Use pure virtual only when a JavaScript-based default is not possible, since it forces every runtime to implement the method.

Is SynthTrace support required for new JSI methods in Hermes?

Yes, SynthTrace support is required for Hermes. It records and replays JSI interactions for debugging and testing, and without new record types, parsing, and replay logic, trace replays will fail.

How do I test new JSI Runtime methods?

Test at three levels: JSI core tests in testlib.cpp using a RuntimeDecorator, Hermes API tests in APITest.cpp, and SynthTrace tests covering serialization, parsing, and replay. Run them with buck test xplat/jsi:jsi and buck test xplat/static_h:HermesUnitTests.