Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .agents/skills/review-changes/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
name: review-changes
description: >
Review a change in react-native-enriched: validate the code (diff review + static checks),
check feature parity between iOS, Android and web, and test the change on devices with Argent.
Read-only, never edits code. Use when the user asks to review / validate / QA a change, a branch,
or a PR, or invokes the review-changes skill.
---

# Review changes

Agent-agnostic: works for any coding agent that supports Agent Skills (Codex, Claude Code, ...).
The **target** is whatever the user passed after the skill name (see step 0); none means
"uncommitted changes".

Usage: `review-changes [uncommitted | branch <name> | pr <number> | <base>..<head>] [--platform ios|android|web]`
(Claude Code: `/review-changes ...`, Codex: `$review-changes ...` or just ask for a review.)

This skill is the source of truth for review rules in this repo.
`.github/copilot-instructions.md` (GitHub Copilot PR review) is a condensed copy of stages 1
and 3 — when you change those rules, update it too.

Four stages, in order. Each has a reference file — read it when you reach that stage.

| # | Stage | Reference |
| --- | --- | --- |
| 1 | Code review | [references/code-review.md](references/code-review.md) |
| 2 | Static checks | [references/static-checks.md](references/static-checks.md) |
| 3 | Feature parity (iOS / Android / web) | [references/parity.md](references/parity.md) |
| 4 | Device testing with Argent | [references/device-testing.md](references/device-testing.md) |
| — | Final report | [references/report.md](references/report.md) |

## Ground rules

- **Read-only.** Don't edit source files; no `git add/commit/checkout/stash/reset/switch/push`, no
posting to GitHub unless the user asks. Build output, Metro and installing the example app are
fine; if a step (e.g. `pod install`) changes a tracked file, mention it in the report.
`git fetch` is fine. Never switch revisions yourself (see step 0).
- **Evidence over claims.** Commit messages, PR bodies and earlier agent reports describe intent;
verify them against the diff and the device.
- **Parity is part of correctness.** An undocumented divergence between iOS, Android and web is a
`major` finding even when each platform looks fine on its own.
- **No device, no approval** for UI-affecting changes.

## 0. Resolve the target

Run `git fetch origin` first and compare against `origin/main`, never local `main`: a stale local
`main` pulls unrelated commits into the diff.

| Argument | Diff | Revision to validate |
| --- | --- | --- |
| empty / `uncommitted` | `git diff HEAD` + untracked files from `git status`; if the tree is clean, `git diff origin/main...HEAD` | the working tree |
| `branch <name>` | `git diff origin/main...<name>` | `git rev-parse <name>` |
| `pr <number>` | `gh pr view <n>` + `gh pr diff <n>`; the PR body is the stated intent | `gh pr view <n> --json headRefOid` |
| `<base>..<head>` | `git diff <base>...<head>` | `git rev-parse <head>` |

Stages 1 and 3 work from the diff. Stages 2 and 4 run on whatever is checked out, so for every
target except `uncommitted`, before stage 2 confirm that `git rev-parse HEAD` equals the revision
to validate and `git status --porcelain` is empty. If not, stop and ask the user to check out that
revision in a clean tree; don't switch revisions yourself. If they decline, report stages 2 and 4
as "not run: checkout is not at <revision>"; the verdict can't be `APPROVE`.

`--platform` limits **device testing** only; code review and parity always cover every platform.

Before stage 1, write down in one or two sentences what the change is supposed to do. Everything
afterwards is checked against that intent.

## Severity

- `blocker` — crash, data loss, broken build/typecheck, HTML corruption.
- `major` — wrong behaviour, unhandled common edge case, undocumented parity gap, failing check.
- `minor` — rare edge case, missing test/docs, intentional-but-undocumented platform difference.

Don't report style nits that the linters already catch.

## Verdict

`APPROVE` only when there are no blocker/major findings, no undocumented parity gaps, and device
testing passed on every affected native platform. Minor findings may accompany an approve.
Otherwise `CHANGES_REQUESTED`. Format: [references/report.md](references/report.md).
43 changes: 43 additions & 0 deletions .agents/skills/review-changes/references/code-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Stage 1 — Code review

Read every changed hunk plus enough surrounding code to understand it. Check each item that the
diff could plausibly affect.

## Editor behaviour

- Empty text; selection at the very start / end; collapsed vs ranged selection.
- Nested and overlapping styles; toggling a style on/off across a boundary.
- Paragraph styles (lists, headings, blockquote, code block, checkbox, alignment) when the
selection spans several paragraphs, and when pressing Enter / Backspace at their edges.
- Undo / redo.
- Paste: plain text and HTML; pasting into a styled range.
- IME / composition input, autocorrect, dictation.
- Emoji and other surrogate pairs — UTF-16 offsets (JS) vs native indices.
- Very long text and fast typing (performance, debounced events).

## Native code

- iOS: main-thread-only UIKit work, retain cycles in blocks/delegates, `NSRange` bounds,
`TARGET_OS_OSX` guards if shared code is touched (macOS port).
- Android: span flags (`SPAN_EXCLUSIVE_EXCLUSIVE` etc.), `SpannableStringBuilder` index math,
watchers re-entering on their own edits, UI-thread access.
- Events: payload shape matches `src/spec/*NativeComponent.ts`; no emission after unmount.

## HTML round trip

- `value` → native → `getHTML()` returns equivalent HTML.
- New/changed tags or attributes are handled by the parser (`cpp/parser`, platform parsers),
the normalizer (`src/utils/normalizeHtmlStyle.ts`, `src/web/normalization/`) and web
sanitization (`src/web/sanitization/`).
- Attribute values are escaped.

## API surface

- New/changed prop, command or event is in `src/types.ts`, `src/spec/*NativeComponent.ts`,
default props (`src/utils/EnrichedTextInputDefaultProps.ts`) and
`docs/docs/api-reference/*`.
- Breaking changes are called out.

## Tests

- Logic that can be unit tested has tests: `src/web/__tests__`, `cpp/tests`, jest.
54 changes: 54 additions & 0 deletions .agents/skills/review-changes/references/device-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Stage 4 — Device testing with Argent

## Prerequisites

- Argent must be available: its MCP tools (`list-devices`, `gesture-tap`, ...) are exposed to
you, or `command -v argent` succeeds.
If it isn't, tell the user once:
> Argent isn't installed. Run `npx @swmansion/argent@latest init -y` to enable device testing.

Then finish stages 1–3 and return `CHANGES_REQUESTED` with a "device validation blocked"
finding for UI-affecting changes.
- Before the first device call, read the `argent-device-interact` and
`argent-react-native-app-workflow` skills (installed by `argent init` next to this skill), and
any project Argent rules your agent loaded (e.g. `.claude/rules/argent.md`).

## Project facts

- Example app: `apps/example`, bundle id / applicationId `swmansion.enriched.example`.
- Metro: `yarn example start` (port 8081). Start it in the background only if it isn't running.
- iOS build: `yarn example ios --udid <UDID>`; after adding/removing native iOS files run
`bundle exec pod install` in `apps/example/ios` first.
- Android build: `yarn example android --device <serial>`.
- Web example: `yarn example-web dev` (Vite).

## Procedure

1. `list-devices`; reuse booted devices. Test **every native platform the change can affect**
(iOS and Android unless `--platform` narrows it or the change is web-only). Boot a device if a
needed platform has none. Devices share Metro — test one platform at a time.
2. Make sure the installed build contains the change: native files changed → rebuild; JS-only →
`debugger-reload-metro`. If you can't tell, rebuild.
3. Per platform:
- reproduce the intended behaviour (for a bug fix: the original bug's steps, now fixed);
- at least **two edge cases of your own** aimed at the riskiest parts of the diff (pick from
[code-review.md](code-review.md));
- tap targets come from the accessibility tree / `debugger-component-tree`, never from
screenshot pixels;
- screenshot the key states; check `debugger-log-registry` for errors and warnings;
- where HTML output matters, read it (example app HTML preview, or `debugger-evaluate`)
instead of judging from pixels.
4. **Cross-platform comparison:** run the same scenario on each platform and compare the visible
result and the HTML. Differences go into the parity table ([parity.md](parity.md)).
5. Web: if `src/web/**` changed or the parity table says web must match, run the web example and
drive it through Argent's Chromium support when a CDP browser is available. Otherwise state
that web was checked statically only.
6. If a device can't be brought up, report "device validation blocked on <platform>" — don't
approve on static review alone.

## Cleanup

- Leave simulator servers running — the next task reuses them. Stop them
(`stop-all-simulator-servers` with `devices: [...]` naming only the devices you used) only if
the user asks to clean up or ends the session.
- Never stop a Metro the user started unless they ask.
42 changes: 42 additions & 0 deletions .agents/skills/review-changes/references/parity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Stage 3 — Feature parity (iOS / Android / web)

react-native-enriched ships the same `EnrichedTextInput` / `EnrichedText` API on three
implementations. A change on one is usually needed on the others. Shared pieces: TS API in
`src/`, HTML parser in `cpp/` (used by native).

## Where each feature lives

| Area | iOS | Android | Web |
| --- | --- | --- | --- |
| Input component | `ios/EnrichedTextInputView.mm`, `ios/enrichedInputTextView/`, `ios/inputAttributesManager/` | `android/.../enriched/textinput/` (view, `watchers/`, `events/`) | `src/web/EnrichedTextInput.tsx`, `src/web/pmPlugins/`, `src/web/tiptapWatchers/` |
| Text (read-only) component | `ios/EnrichedTextView.mm`, `ios/enrichedTextTextView/` | `android/.../enriched/text/` | `src/web/EnrichedText.tsx`, `EnrichedText.css` |
| Styles (bold, lists, headings, links, mentions, images, code, blockquote, checkbox, alignment, custom) | `ios/styles/*Style.mm` | `android/.../textinput/styles/*.kt`, `spans/`, `common/spans/` | `src/web/formats/Enriched*.ts`, `formatRules.ts` |
| HTML parse / serialize | `ios/htmlParser/`, `ios/inputHtmlParser/`, `ios/textHtmlParser/`, `cpp/parser` | `android/.../common/parser/`, `cpp/parser` | `src/web/htmlExtensions/`, `src/web/sanitization/`, `src/web/normalization/` |
| Props / events / commands | `ios/EnrichedTextInputView.mm` (`updateProps`, command handlers) | view manager + `events/` | `src/web/EnrichedTextInput.tsx`, `src/web/nativeMappers/` |
| Shared API | `src/types.ts`, `src/spec/*NativeComponent.ts`, `src/native/*.tsx`, `src/utils/` | same | same |

Paths are starting points — grep for the style/prop/command name across `ios/ android/ src/web/`
to find the real counterpart.

## Procedure

1. List the behaviours the change touches (a style, a prop, a command, an event, parsing of a
tag, keyboard handling, ...). One row each.
2. For each row and each platform, find the code that implements it **after** the change:
- changed in this diff → check it does the same thing as the other platforms (same defaults,
same edge-case handling, same emitted event payload and HTML output);
- not changed → read the existing code and decide whether it already behaves the same or now
diverges. A bug fixed on one platform is a parity gap if the same bug exists on another.
3. New/changed prop, command or event: it must be in `src/spec/*NativeComponent.ts` (native),
handled on iOS **and** Android, mapped on web (or intentionally no-op with a reason), typed in
`src/types.ts`, and documented in `docs/docs/api-reference/`.
4. Mark each cell:
- ✅ `code` (verified by reading) / ✅ `code+device` (also confirmed with Argent)
- ❌ missing or behaves differently — say how
- ➖ n/a — not meaningful on that platform; cite the entry in
`docs/docs/misc/compatibility.mdx` or `known-limitations.md` if it's a known gap
- ❓ couldn't determine — explain; treat as a finding to resolve, not a pass
5. Severity: undocumented ❌ → `major` "parity gap"; intentional but undocumented ➖ → `minor`
(add to `compatibility.mdx`); ❓ → `minor` unless it hides a likely bug.
6. Note macOS (`react-native-macos`, in-progress port) only if the diff touches shared iOS code
guarded by `TARGET_OS_OSX` / `RCT_*` platform macros.
33 changes: 33 additions & 0 deletions .agents/skills/review-changes/references/report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Final report

Your final message, exactly this shape:

```
## Verdict: APPROVE | CHANGES_REQUESTED

Target: <what was reviewed>
Intent: <one sentence>

## Findings
1. [blocker|major|minor] path:line — what's wrong. Evidence / repro. Suggested fix.
(or "None")

## Platform parity
| Behaviour | iOS | Android | Web | Notes |
| --- | --- | --- | --- | --- |
| <behaviour> | ✅ code+device | ❌ missing | ➖ n/a (compatibility.mdx) | ... |

## Device testing
- <platform> / <device>: intent reproduced yes/no
- edge case: <case> → <result>
- edge case: <case> → <result>
- Cross-platform comparison: same | differs: <how>
- Screenshots: <paths>
- Logs: clean | <errors>

## Static checks
- <command>: pass | fail (<first error>)
```

Keep findings ordered most severe first. Every `major`/`blocker` needs evidence: a file:line, a
failing command, or a device repro.
16 changes: 16 additions & 0 deletions .agents/skills/review-changes/references/static-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stage 2 — Static checks

Run the checks that match the touched files (all of them if unsure). Run slow ones in the
background. Report each as pass / fail, quoting the first error verbatim.

| Touched | Command |
| --- | --- |
| anything | `yarn typecheck`, `yarn lint`, `yarn test` |
| `ios/**` (`.h`, `.m`, `.mm`) | `yarn lint-clang:ios` |
| `android/**` (`.kt`, `.java`) | `yarn lint:android` |
| `android/**` (`.h`, `.cpp`) | `yarn lint-clang:android` |
| `cpp/**` | `yarn lint-clang`; build and run `cpp/tests` if the parser changed |
| `docs/**` | `yarn typecheck:docs` |

A failing check is a `major` finding (a `blocker` if it is a typecheck/build failure). Don't run
`*:fix` variants — they modify the tree.
34 changes: 34 additions & 0 deletions .claude/rules/argent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
description: Always-on Argent rules for driving, testing and profiling apps on simulators, emulators, phones, TVs and Chromium
alwaysApply: true
---

Argent - general rules:

- do not derive tap coordinates from screenshot pixels; use inspection tools that give coordinates
- use the platform the user named; otherwise prefer a device `list-devices` shows already running, and don't default to iOS; in a single-platform project boot that platform.
- if tap fails twice, stop retrying and re-run a discovery tool
- Prefer mcp-tool calls over raw commands like `xcrun` or `adb`; use them as fallback.
- Interaction tools return screenshot and element tree automatically; an identical earlier tree is named by its tree id, not repeated.
- prefer `launch-app` or `open-url` than tapping icons on home screen.
- If a task can require a saved e2e test, load `argent-create-e2e` (`argent-qa-e2e` for acceptance tests) before the first launch or in-app action; recording is not retroactive.
- Load the matching `argent-*` skill before React Native build/debug, profiling, a physical phone, a Mac app or a TV.
- Do not stop simulator servers when a task finishes: the next task reuses them. Call `stop-all-simulator-servers` when the user asks to clean up or ends the session, or when a skill tells you to recycle a device's services, with devices this session used. One tool-server is shared by every other agent, so unscoped call tears down their devices too. Never stop a Metro the user started unless they ask.
- Use the `await-ui-element` tool to block until the UI settles instead of polling using screenshot.
- The `argent` CLI manages the toolkit: `argent --help` lists commands, `argent --version` shows the installed version.

<availability_check>
Run this check once per session. Do not re-probe before later calls.
Confirm argent is available:

1. Are `mcp__argent__*` tools in your tool list? If none, argent is not available.
2. If unsure, run `command -v argent`. Non-zero exit = the CLI is not on PATH.

If argent IS available, ignore the rest of this block and follow this rule normally.

If argent is ABSENT, treat it as an expected state, not an error to retry. Do not call `mcp__argent__*` tools, do not run `argent` commands, do not attempt any argent workflow.
Tell the user once, and ask if you should continue without argent:

> Argent isn't installed in this environment. To enable the mobile/Chromium tooling this repo is configured for, run `npx @swmansion/argent@latest init -y` (or `npm i -g @swmansion/argent@latest && argent init -y`).

</availability_check>
7 changes: 7 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"mcp__argent"
]
}
}
1 change: 1 addition & 0 deletions .claude/skills/review-changes
Loading
Loading