diff --git a/.agents/skills/review-changes/SKILL.md b/.agents/skills/review-changes/SKILL.md new file mode 100644 index 000000000..25c047e11 --- /dev/null +++ b/.agents/skills/review-changes/SKILL.md @@ -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 | pr | ..] [--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 ` | `git diff origin/main...` | `git rev-parse ` | +| `pr ` | `gh pr view ` + `gh pr diff `; the PR body is the stated intent | `gh pr view --json headRefOid` | +| `..` | `git diff ...` | `git rev-parse ` | + +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 "; 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). diff --git a/.agents/skills/review-changes/references/code-review.md b/.agents/skills/review-changes/references/code-review.md new file mode 100644 index 000000000..6bac79448 --- /dev/null +++ b/.agents/skills/review-changes/references/code-review.md @@ -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. diff --git a/.agents/skills/review-changes/references/device-testing.md b/.agents/skills/review-changes/references/device-testing.md new file mode 100644 index 000000000..f1154c992 --- /dev/null +++ b/.agents/skills/review-changes/references/device-testing.md @@ -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 `; after adding/removing native iOS files run + `bundle exec pod install` in `apps/example/ios` first. +- Android build: `yarn example android --device `. +- 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 " — 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. diff --git a/.agents/skills/review-changes/references/parity.md b/.agents/skills/review-changes/references/parity.md new file mode 100644 index 000000000..07d17d78e --- /dev/null +++ b/.agents/skills/review-changes/references/parity.md @@ -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. diff --git a/.agents/skills/review-changes/references/report.md b/.agents/skills/review-changes/references/report.md new file mode 100644 index 000000000..bc4777bef --- /dev/null +++ b/.agents/skills/review-changes/references/report.md @@ -0,0 +1,33 @@ +# Final report + +Your final message, exactly this shape: + +``` +## Verdict: APPROVE | CHANGES_REQUESTED + +Target: +Intent: + +## Findings +1. [blocker|major|minor] path:line — what's wrong. Evidence / repro. Suggested fix. +(or "None") + +## Platform parity +| Behaviour | iOS | Android | Web | Notes | +| --- | --- | --- | --- | --- | +| | ✅ code+device | ❌ missing | ➖ n/a (compatibility.mdx) | ... | + +## Device testing +- / : intent reproduced yes/no + - edge case: → + - edge case: → +- Cross-platform comparison: same | differs: +- Screenshots: +- Logs: clean | + +## Static checks +- : pass | fail () +``` + +Keep findings ordered most severe first. Every `major`/`blocker` needs evidence: a file:line, a +failing command, or a device repro. diff --git a/.agents/skills/review-changes/references/static-checks.md b/.agents/skills/review-changes/references/static-checks.md new file mode 100644 index 000000000..f266c629d --- /dev/null +++ b/.agents/skills/review-changes/references/static-checks.md @@ -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. diff --git a/.claude/rules/argent.md b/.claude/rules/argent.md new file mode 100644 index 000000000..fda83f678 --- /dev/null +++ b/.claude/rules/argent.md @@ -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. + + +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`). + + diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 000000000..9256e4689 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "mcp__argent" + ] + } +} diff --git a/.claude/skills/review-changes b/.claude/skills/review-changes new file mode 120000 index 000000000..6561ae27e --- /dev/null +++ b/.claude/skills/review-changes @@ -0,0 +1 @@ +../../.agents/skills/review-changes \ No newline at end of file diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 000000000..d65a04c59 --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,261 @@ +developer_instructions = "# --- argent rules (managed by argent init — do not edit) ---\nArgent - general rules:\n\n- do not derive tap coordinates from screenshot pixels; use inspection tools that give coordinates\n- 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.\n- if tap fails twice, stop retrying and re-run a discovery tool\n- Prefer mcp-tool calls over raw commands like `xcrun` or `adb`; use them as fallback.\n- Interaction tools return screenshot and element tree automatically; an identical earlier tree is named by its tree id, not repeated.\n- prefer `launch-app` or `open-url` than tapping icons on home screen.\n- 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.\n- Load the matching `argent-*` skill before React Native build/debug, profiling, a physical phone, a Mac app or a TV.\n- 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.\n- Use the `await-ui-element` tool to block until the UI settles instead of polling using screenshot.\n- The `argent` CLI manages the toolkit: `argent --help` lists commands, `argent --version` shows the installed version.\n\n\nRun this check once per session. Do not re-probe before later calls.\nConfirm argent is available:\n\n1. Are `mcp__argent__*` tools in your tool list? If none, argent is not available.\n2. If unsure, run `command -v argent`. Non-zero exit = the CLI is not on PATH.\n\nIf argent IS available, ignore the rest of this block and follow this rule normally.\n\nIf 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.\nTell the user once, and ask if you should continue without argent:\n\n> 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`).\n\n\n# --- end argent rules ---" + +[mcp_servers.argent] +command = "argent" +args = [ "mcp" ] + +[mcp_servers.argent.tools.list-devices] +approval_mode = "approve" + +[mcp_servers.argent.tools.boot-device] +approval_mode = "approve" + +[mcp_servers.argent.tools.launch-app] +approval_mode = "approve" + +[mcp_servers.argent.tools.restart-app] +approval_mode = "approve" + +[mcp_servers.argent.tools.terminate-app] +approval_mode = "approve" + +[mcp_servers.argent.tools.reinstall-app] +approval_mode = "approve" + +[mcp_servers.argent.tools.settings-permissions] +approval_mode = "approve" + +[mcp_servers.argent.tools.open-url] +approval_mode = "approve" + +[mcp_servers.argent.tools.screenshot] +approval_mode = "approve" + +[mcp_servers.argent.tools.screenshot-diff] +approval_mode = "approve" + +[mcp_servers.argent.tools.screen-recording-start] +approval_mode = "approve" + +[mcp_servers.argent.tools.screen-recording-stop] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-tap] +approval_mode = "approve" + +[mcp_servers.argent.tools.chromium-tabs] +approval_mode = "approve" + +[mcp_servers.argent.tools.chromium-cookies] +approval_mode = "approve" + +[mcp_servers.argent.tools.chromium-storage] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-swipe] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-scroll] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-drag] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-custom] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-pinch] +approval_mode = "approve" + +[mcp_servers.argent.tools.gesture-rotate] +approval_mode = "approve" + +[mcp_servers.argent.tools.button] +approval_mode = "approve" + +[mcp_servers.argent.tools.keyboard] +approval_mode = "approve" + +[mcp_servers.argent.tools.paste] +approval_mode = "approve" + +[mcp_servers.argent.tools.file-panel] +approval_mode = "approve" + +[mcp_servers.argent.tools.menu-bar] +approval_mode = "approve" + +[mcp_servers.argent.tools.rotate] +approval_mode = "approve" + +[mcp_servers.argent.tools.shake] +approval_mode = "approve" + +[mcp_servers.argent.tools.fold] +approval_mode = "approve" + +[mcp_servers.argent.tools.tv-remote] +approval_mode = "approve" + +[mcp_servers.argent.tools.run-sequence] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-connect] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-status] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-evaluate] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-reload-metro] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-component-tree] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-inspect-element] +approval_mode = "approve" + +[mcp_servers.argent.tools.debugger-log-registry] +approval_mode = "approve" + +[mcp_servers.argent.tools.view-network-logs] +approval_mode = "approve" + +[mcp_servers.argent.tools.view-network-request-details] +approval_mode = "approve" + +[mcp_servers.argent.tools.describe] +approval_mode = "approve" + +[mcp_servers.argent.tools.ui-tree] +approval_mode = "approve" + +[mcp_servers.argent.tools.foreground-app] +approval_mode = "approve" + +[mcp_servers.argent.tools.fill] +approval_mode = "approve" + +[mcp_servers.argent.tools.await-ui-element] +approval_mode = "approve" + +[mcp_servers.argent.tools.await-screen-idle] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-start] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-stop] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-status] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-analyze] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-component-source] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-cpu-summary] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-renders] +approval_mode = "approve" + +[mcp_servers.argent.tools.react-profiler-fiber-tree] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-profiler-start] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-profiler-stop] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-profiler-analyze] +approval_mode = "approve" + +[mcp_servers.argent.tools.profiler-cpu-query] +approval_mode = "approve" + +[mcp_servers.argent.tools.profiler-commit-query] +approval_mode = "approve" + +[mcp_servers.argent.tools.profiler-stack-query] +approval_mode = "approve" + +[mcp_servers.argent.tools.profiler-combined-report] +approval_mode = "approve" + +[mcp_servers.argent.tools.profiler-load] +approval_mode = "approve" + +[mcp_servers.argent.tools.gather-workspace-data] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-devtools-status] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-network-logs] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-find-views] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-full-hierarchy] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-describe-screen] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-view-at-point] +approval_mode = "approve" + +[mcp_servers.argent.tools.native-user-interactable-view-at-point] +approval_mode = "approve" + +[mcp_servers.argent.tools.stop-simulator-server] +approval_mode = "approve" + +[mcp_servers.argent.tools.stop-all-simulator-servers] +approval_mode = "approve" + +[mcp_servers.argent.tools.stop-metro] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-start-recording] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-add-step] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-add-echo] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-add-script] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-finish-recording] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-read-prerequisite] +approval_mode = "approve" + +[mcp_servers.argent.tools.e2e-execute] +approval_mode = "approve" + +[mcp_servers.argent.tools.update-argent] +approval_mode = "approve" + +[mcp_servers.argent.tools.dismiss-update] +approval_mode = "approve" + +[mcp_servers.argent.tools.propose_variant] +approval_mode = "approve" + +[mcp_servers.argent.tools.await_user_selection] +approval_mode = "approve" + diff --git a/.cursor/mcp.json b/.cursor/mcp.json new file mode 100644 index 000000000..4cafbf05e --- /dev/null +++ b/.cursor/mcp.json @@ -0,0 +1,10 @@ +{ + "mcpServers": { + "argent": { + "command": "argent", + "args": [ + "mcp" + ] + } + } +} diff --git a/.cursor/rules/argent.mdc b/.cursor/rules/argent.mdc new file mode 100644 index 000000000..fda83f678 --- /dev/null +++ b/.cursor/rules/argent.mdc @@ -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. + + +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`). + + diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..b80aec42e --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,57 @@ +# Review instructions + +Condensed from `.agents/skills/review-changes/` (code review + parity stages; no device testing). +Keep the two in sync. Copilot reads only the first 4,000 characters — keep this file short. + +react-native-enriched ships one `EnrichedTextInput` / `EnrichedText` API on three +implementations: iOS (`ios/`), Android (`android/`), web (`src/web/`). Shared: TS API (`src/`), +HTML parser (`cpp/parser`). Lint, typecheck, tests and native formatting run in CI — don't +report what those catch. + +## Feature parity (most important) + +A change to one platform usually needs the same change on the others. For each behaviour the PR +touches, find its counterpart and check it behaves the same (defaults, edge cases, event +payloads, HTML output): + +- styles: `ios/styles/*Style.mm` ↔ `android/**/textinput/styles/*.kt` + `spans/` ↔ `src/web/formats/Enriched*.ts` +- HTML parsing: `ios/{html,inputHtml,textHtml}Parser/` ↔ `android/**/common/parser/` ↔ `src/web/htmlExtensions/`, `sanitization/`, `normalization/` (+ `cpp/parser`) +- props/commands/events: `ios/EnrichedTextInputView.mm` ↔ Android view manager + `events/` ↔ `src/web/EnrichedTextInput.tsx`, `nativeMappers/` + +Flag as a **parity gap** any platform that is missing the change or diverges, unless it is +listed in `docs/docs/misc/compatibility.mdx` / `known-limitations.md` or explained in the PR. A +bug fixed on one platform that still exists on another is a parity gap. An intentional but +undocumented difference: ask for a `compatibility.mdx` entry. + +## Correctness + +- Empty text; selection at start/end; collapsed vs ranged selection. +- Nested/overlapping styles; toggling a style across a boundary. +- Paragraph styles (lists, headings, blockquote, code block, checkbox, alignment) over several + paragraphs, and Enter/Backspace at their edges. +- Undo/redo; paste of plain text and HTML; IME/composition. +- Emoji / surrogate pairs: UTF-16 offsets (JS) vs native indices. +- iOS: UIKit work off the main thread, retain cycles in blocks/delegates, `NSRange` bounds, + `TARGET_OS_OSX` guards in shared code. +- Android: span flags, `SpannableStringBuilder` index math, watchers re-entering on their own + edits, UI-thread access. +- Events: payload matches `src/spec/*NativeComponent.ts`; nothing emitted after unmount. + +## HTML round trip + +`value` → native → `getHTML()` must give equivalent HTML. New/changed tags or attributes must be +handled by the parsers, the normalizer and web sanitization; attribute values must be escaped. + +## API surface + +New/changed props, commands or events must appear in `src/types.ts`, +`src/spec/*NativeComponent.ts`, default props, and `docs/docs/api-reference/`. Call out breaking +changes. Unit-testable logic needs tests (`src/web/__tests__`, `cpp/tests`). + +## How to comment + +- Severity prefix: **blocker** (crash, data loss, HTML corruption), **major** (wrong behaviour, + common edge case, parity gap), **minor** (rare edge case, missing test/docs). +- Point at the line, say what goes wrong and how to reproduce it, suggest a fix. For parity + gaps, name the counterpart file that needs the change. +- No style nits, no praise, no summaries of what the PR does. diff --git a/.gitignore b/.gitignore index 6f74f61b2..a907046cc 100644 --- a/.gitignore +++ b/.gitignore @@ -96,4 +96,10 @@ nitrogen/ .argent/artifacts/ # Claude skills -.claude/skills/*-internal.md \ No newline at end of file +.claude/skills/*-internal.md +# Argent skills are installed per machine (`argent init -y`), not committed +.agents/skills/argent-*/ +.claude/skills/argent-* +skills-lock.json +# Argent writes its Cursor rule as `argent.md`, which Cursor ignores; the committed copy is `argent.mdc` +.cursor/rules/argent.md diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 000000000..d12355e6f --- /dev/null +++ b/.mcp.json @@ -0,0 +1,11 @@ +{ + "mcpServers": { + "argent": { + "type": "stdio", + "command": "argent", + "args": [ + "mcp" + ] + } + } +} diff --git a/docs/docs/misc/contributing.md b/docs/docs/misc/contributing.md index 86e37b921..77827755a 100644 --- a/docs/docs/misc/contributing.md +++ b/docs/docs/misc/contributing.md @@ -283,6 +283,55 @@ is one of the most valuable ways to contribute. ::: +## AI coding agents + +The repository ships shared configuration for AI coding agents (Claude Code, +Codex, Cursor). It wires up [Argent](https://github.com/software-mansion/argent), +which lets agents drive the iOS simulator, Android emulator and web example +app, and a review skill that checks a change's code, feature parity between +iOS, Android and web, and tests it on devices. + +| What | Where | +| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| Argent MCP server | `.mcp.json` (Claude Code), `.codex/config.toml` (Codex), `.cursor/mcp.json` (Cursor) | +| Argent rules | `.claude/rules/`, `.cursor/rules/`, `developer_instructions` in `.codex/config.toml` | +| Argent skills | not committed: installed on your machine by `argent init` (see below) | +| Review skill | `.agents/skills/review-changes/` (symlinked into `.claude/skills/`), condensed for GitHub Copilot PR review in `.github/copilot-instructions.md` | + +To use it: + +1. Install Argent, then run `argent init -y` from the repo root. It installs + the skills into the repo, where they're gitignored: + + ```sh + npm i -g @swmansion/argent + argent init -y + ``` + +2. Approve the project's `argent` MCP server when your agent asks: + - **Claude Code** prompts on the first start in the repository. + - **Codex** reads `.codex/config.toml` only for trusted projects, so mark + the repository as trusted. + - **Cursor** lists it under _Settings → MCP_; enable it there. + +3. Ask the agent to review your change, or invoke the skill directly: + `/review-changes` in Claude Code, `$review-changes` in Codex. It accepts + `uncommitted` (default), `branch `, `pr ` or `..`, + plus `--platform ios|android|web` to limit device testing. + +Run `argent update` to update Argent and your skills. If it changes the +committed MCP configs or rules, include that in a separate `chore` commit. +Argent writes the Cursor rule as `.cursor/rules/argent.md`, which Cursor +ignores and git ignores too; copy any changes into the committed +`.cursor/rules/argent.mdc`. + +:::info + +When you change the review rules in `.agents/skills/review-changes/`, update +`.github/copilot-instructions.md` too. + +::: + ## Commit message convention We follow the