From 9443517d1cf2e49b1e559a8aef3b02aa231499d4 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Wed, 2 Dec 2026 17:50:30 +0800 Subject: [PATCH] docs: restore AGENTS.md and add PR evidence rules with a pr skill (#7498) Restore AGENTS.md (CLAUDE.md links to it) and the verify skill, and add a pr skill covering scope, checks to run, the evidence each kind of change needs and a UX consistency review against DESIGN.md and PRODUCT.md. The PR template lists evidence by change type, and the PR check also asks for screenshots or a recording when a PR changes UI files under src/, unless the description says "No visible change". --- .agents/skills/pr/SKILL.md | 129 ++++++++++++++++ .agents/skills/verify/SKILL.md | 59 +++++++ .claude/skills/pr | 1 + .claude/skills/verify | 1 + .github/pull_request_template.md | 19 ++- .github/workflows/pr-check.yml | 22 ++- .gitignore | 11 +- AGENTS.md | 197 ++++++++++++++++++++++++ CLAUDE.md | 1 + CONTRIBUTING.md | 10 +- docs/en/contribute/testing/unit-e2e.mdx | 2 +- docs/en/contribute/workflow.mdx | 6 +- docs/zh/contribute/testing/unit-e2e.mdx | 2 +- docs/zh/contribute/workflow.mdx | 6 +- 14 files changed, 444 insertions(+), 22 deletions(-) create mode 100644 .agents/skills/pr/SKILL.md create mode 100644 .agents/skills/verify/SKILL.md create mode 120000 .claude/skills/pr create mode 120000 .claude/skills/verify create mode 100644 AGENTS.md create mode 120000 CLAUDE.md diff --git a/.agents/skills/pr/SKILL.md b/.agents/skills/pr/SKILL.md new file mode 100644 index 0000000000..2b57f8251b --- /dev/null +++ b/.agents/skills/pr/SKILL.md @@ -0,0 +1,129 @@ +--- +name: pr +description: Prepare and open an OpenIDEA pull request that a maintainer can accept from its description — scope check, the checks CI runs, evidence chosen by the kind of change, UX consistency review, and a filled-in template. Use before opening or updating a PR ("提 pr", "open a PR", "写 PR 描述", "准备验收证据"). +--- + +# Open a pull request with evidence + +A reviewer should be able to accept the PR from its description: what changed, why, and proof +that it works and didn't break its neighbours. Evidence is the part people skip; it is required. + +## 1. Scope + +- One problem per PR. If the description needs more than 2–4 sentences, split it. +- `Closes #` when it resolves an issue. Read the issue's comments first: a maintainer may + already have decided how it should behave. +- The diff contains only what the problem needs: no drive-by refactors, formatting of untouched + files, generated files you didn't need to regenerate, or local IDE state (`.openidea/`). +- A product decision you can't make (layout or navigation restructure, a changed default, an + unclear expected behaviour) → ask in the issue, label `needs-decision`, stop. +- Title in Conventional Commits, written as the commit you want on `main`: + `fix(editor): keep the caret visible after folding`. It describes the change, not the + process; no references to screenshots, other products or "parity". + +## 2. Checks + +Run what CI runs for the parts you touched (`AGENTS.md` § Before opening a PR). Run long checks +one at a time. Paste the command and its result line (`test result: ok. 412 passed`, +`Tests 87 passed`), not "tests pass". + +Easy to miss: + +| You touched | Also run | +| --------------------------------------------------------------- | ------------------------------------------------------------------------------------ | +| Any `.ts`/`.tsx`, including tests | `pnpm typecheck` | +| A feature's UI | every spec under `e2e/` whose name contains the feature | +| New regex in frontend code | `pnpm vitest run src/platform/webkitCompatibility.test.ts` | +| Text catalog keys | `pnpm vitest run src/platform/locales/textCatalog.test.ts src/platform/i18n.test.ts` | +| `tokens.css` | `pnpm gen:theme-docs`, then the full `pnpm test` | +| Moved or removed exports | `pnpm knip` | +| A `pub fn` signature | `cargo test -p ` (all targets), or workspace clippy | +| A new crate dependency, or imports in files the smoke runs load | `pnpm vitest run scripts/smoke-paths.test.ts` | +| IPC types | `pnpm gen:bindings`, commit `src/bindings.ts` | +| `wit/` or the plugin SDK | `plugins/build.sh`, commit the rebuilt `dist/` | + +## 3. Evidence + +Pick every row that applies. Evidence must come from the final commit of the branch; re-take it +after review changes that affect it. + +| Change | Evidence | +| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Bug fix | A test that fails on `main` and passes on the branch (name it), or exact steps from a fresh start with the before/after result | +| Visible UI | `before.png` / `after.png` at the same state and window size. Every theme the change touches (at least Islands Light and Islands Dark when colours, borders or icons change). The narrow case when width matters | +| Interaction: multi-step, drag and drop, keyboard, focus, animation | A short recording (GIF/MP4), or numbered screenshots of each step | +| Keyboard shortcut or action | Where it appears (Find Action, menu, keymap settings) and that it doesn't clash in the default keymaps | +| Code intelligence / language support | Which `fixtures/` project, `cargo test -p ide-host --test language_smoke -- --ignored --exact ` output; for Java, `pnpm eval --only ` numbers before/after | +| Run / debug | `pnpm smoke smoke/run.test.ts -t ` or `smoke/debug.test.ts`, plus a screenshot of the Run/Debug tool window | +| Performance | Before/after numbers on the same machine and build type (`pnpm perf`, `pnpm perf:rust`, or the exact measurement), and evidence the results are identical: a fast path must return the same results or fall back | +| Windows / Linux only | The platform's CI job, and a screenshot or log from a real machine. Say plainly if you couldn't run it on that platform | +| Backend / IPC | Test output; logs for behaviour tests can't reach | +| Remote development / containers / WSL | The flow against a real `openidea-server` host or container, with a screenshot or log | +| Plugin API / `wit/` | A sample plugin exercising the change, and the rebuilt `dist/` | +| Settings / persisted data / migrations | Start from data written by the previous release and show it still loads and behaves the same | +| Security fix | A test for the attack case. Describe the class of problem only; follow `SECURITY.md` for anything not yet public | +| Copy, docs, pure refactor | The commands run, and "No visible change" / "no behaviour change" stated | + +Also state what else the change could affect (other languages, platforms, entry points such as +menu / context menu / shortcut, other themes) and how you checked each. + +How to capture: + +- Use the `verify` skill to drive the app and take screenshots. Before: on `main` (or with the + fix reverted). After: on the branch, same state and window size. +- Crop to the relevant area when the window is large, but keep enough context to locate it. +- Drag screenshots and recordings into the PR description on GitHub. Never commit them. +- No real credentials, tokens, private repository names or personal paths in screenshots or logs. + +## 4. UX consistency + +For any change users can see, review it against `DESIGN.md`, `PRODUCT.md` and +`docs/en/contribute/guidelines/ui.mdx` before taking the "after" screenshots: + +- Tokens only; spacing on the `--space-*` scale; icons from `src/ui/icons.tsx`; no emoji. +- Built from `src/ui/` primitives and workbench contributions; it looks like its neighbours + (same row height, font size, padding, hover/selection, empty state) rather than new. +- Same action, same name, place and shortcut as elsewhere in the IDE. +- Keyboard reachable, visible focus, focus returns sensibly; `aria-label` on icon buttons. +- Every new string in `en.json` and `zh.json`; long translations don't break the layout. +- Light and dark, default and narrow widths all look right. +- The Impeccable design skills can help critique and polish; they read `DESIGN.md`, + `PRODUCT.md` and `.impeccable/`. + +A layout or navigation restructure needs a maintainer decision first (§ 1). + +## 5. Description + +Fill in `.github/pull_request_template.md`; keep it short and plain: + +```markdown +Closes #123 + +## What and why + + + +## How it was verified + +- [x] Bug fix: `pnpm vitest run src/features/editor/folding.test.ts` — the new + `keeps caret visible after fold` fails on main, passes here (12 passed) +- [x] Visible UI: before / after (Islands Light, Islands Dark) + +- `pnpm typecheck`, `pnpm lint`, `pnpm e2e e2e/editor-folding.spec.ts` — all pass +- Also affected: folding from the gutter and from ⌘- — both checked in the app + +## Review focus + + +``` + +The `PR check` workflow labels the PR `needs-info` when **How it was verified** is empty, or when +the PR changes UI files and the section has no screenshot or recording and doesn't say +"No visible change". + +## 6. Before you push + +- Re-read the diff as the reviewer: anything unrelated, debug output, commented-out code, + leftover TODOs? +- Rebased on current `main`; checks re-run if the rebase changed anything they cover. +- Open as draft while evidence is missing; mark ready once it's in. diff --git a/.agents/skills/verify/SKILL.md b/.agents/skills/verify/SKILL.md new file mode 100644 index 0000000000..94e7c37a8e --- /dev/null +++ b/.agents/skills/verify/SKILL.md @@ -0,0 +1,59 @@ +--- +name: verify +description: Build, launch and drive the OpenIDEA desktop app through the Tauri MCP bridge to verify a change at runtime. +--- + +# Verify OpenIDEA in the running app + +## Launch + +- Run the app from the worktree that holds the change: `pnpm tauri dev` in the background, logging + into your task's scratch subdirectory. Use `pnpm dev:app` instead when your checks call + `window.__TAURI__` from `execute_js`. The wrapper gives each worktree its own app identity, data, + settings and Vite port, so other worktrees and the installed app don't interfere. If it reports a + session already running for this worktree, reuse that one. +- Once the app is up, `pnpm dev:status` lists this worktree's MCP bridges. Pass the reported + `appIdentifier` (the port) on every `mcp__tauri__*` call. The MCP server is shared between + sessions: never `driver_session stop` without an `appIdentifier`, and re-check `document.title` / + `location.href` before acting if anything looks off. +- Make sure the binary contains the change: a session already running for this worktree may be an + older build. Restart it after Rust changes; frontend changes reload through Vite. +- After the app restarts, `driver_session start` again for your port (a stale session says "Already connected"). +- If the `pnpm tauri dev` process exits while the app window stays open, Vite is gone and any webview + reload shows an empty `#root`. Stop that app and start the session again. +- Stop everything you started when done and nothing else; never use process-name kills. + +## Driving + +- `manage_window focus` before screenshots / timing-sensitive steps: a background window throttles timers + (debounced LSP / VCS refreshes stall, `setTimeout` promises in `execute_js` time out) and native + screenshots come back black. +- Settings is a separate native window `settings-main`; pass `windowId`, focus it before screenshotting. +- CodeMirror / xterm ignore MCP `type`. Focus the element, then `document.execCommand('insertText', false, text)`. + For xterm Enter, dispatch a `keydown` (`key: 'Enter', keyCode: 13`) on `.xterm-helper-textarea`. +- MCP clicks arrive with `event.detail === 0`; CodeMirror treats them as line-select clicks. Set the caret + through the view instead: `document.querySelector('.cm-content').cmTile.view`. +- MCP `text` strategy can resolve to a hidden node; prefer coordinates (CSS px = image px × 0.9) or CSS selectors. +- CSS-module edits often trigger a full page reload in dev: dialogs close, Run sessions and terminal + scrollback reset, and each reload spawns a fresh shell. Re-open what you were testing. + +## Evidence + +- For UI or interaction changes, capture `before.png` (on `main` or with the fix reverted) and + `after.png` at the same state and window size, into your task's scratch subdirectory. Multi-step + flows: a numbered series (`after-1.png`, `after-2.png`, ...). When colours, borders or icons + change, take each in Islands Light and Islands Dark. The `pr` skill lists what evidence each + kind of change needs. +- Report the absolute paths; they go into the PR's **How it was verified** section and the triage + acceptance entry. Never commit screenshots to the feature branch. + +## Fixture + +`fixtures/` has sample projects (go-app, rust-app, ts-app, kotlin-gradle, polyglot). Copy one into +your scratch directory before editing it, and don't commit the IDE state it creates (`.openidea/`). + +## Flows worth driving + +⌘⇧O Goto File · ⌘⇧F Find in Files (preview scroll + highlight) · ⌘⇧A Find Action · editor edit/undo/autosave · +Terminal (Unicode, venv) · Commit view at the default narrow width · Problems · Run → Stop · Project view +New / Delete (nested `a/b.txt` names) · ⌘, Settings search (+ Keymap filter) · Git Log on a repo without commits. diff --git a/.claude/skills/pr b/.claude/skills/pr new file mode 120000 index 0000000000..8ea58ab6a8 --- /dev/null +++ b/.claude/skills/pr @@ -0,0 +1 @@ +../../.agents/skills/pr \ No newline at end of file diff --git a/.claude/skills/verify b/.claude/skills/verify new file mode 120000 index 0000000000..326bc3f852 --- /dev/null +++ b/.claude/skills/verify @@ -0,0 +1 @@ +../../.agents/skills/verify \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 4fb67fbfe4..67e08f1d5c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,11 +7,20 @@ ## How it was verified - + ## Review focus diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index d68293498d..e210c90363 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -1,9 +1,9 @@ name: PR check on: # pull_request_target so the check can label PRs from forks. It never checks out - # or runs PR code: it only reads the PR title and description. + # or runs PR code: it only reads the PR title, description and changed file names. pull_request_target: - types: [opened, edited, reopened, ready_for_review] + types: [opened, edited, reopened, ready_for_review, synchronize] permissions: issues: write @@ -34,6 +34,24 @@ jobs: const { owner, repo } = context.repo; const issue_number = pr.number; + + if (verified && verified[1].trim()) { + const section = verified[1]; + const hasMedia = + /!\[[^\]]*\]\(| f.status !== 'removed') + .map(f => f.filename) + .filter(name => /^src\/.*\.(tsx|css)$/.test(name) && !/\.(test|spec)\.tsx$/.test(name)); + if (ui.length) { + const shown = ui.slice(0, 3).map(n => `\`${n}\``).join(', ') + (ui.length > 3 ? ', …' : ''); + problems.push(`This PR changes UI files (${shown}). Add before/after screenshots, or a recording for interactions, to **How it was verified**; if nothing users see changed, write "No visible change" and say what you checked.`); + } + } + } const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number }); const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER)); const labeled = pr.labels.some(l => l.name === LABEL); diff --git a/.gitignore b/.gitignore index 2e1ada6632..40c65d256d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,12 +33,13 @@ target/ test-results/ playwright-report/ -# Local AI agent files -AGENTS.md -CLAUDE.md +# Local AI agent files. Shared skills live in .agents/skills; .claude/skills links to them. CLAUDE.local.md -.agents/ -.claude/ +.claude/* +!.claude/skills/ +.claude/skills/* +!.claude/skills/pr +!.claude/skills/verify # Local reference screenshots pycharm-screenshots/ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..98a76bb279 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,197 @@ +# OpenIDEA — contributor guide + +Rust + Tauri 2 desktop IDE with full-featured, multi-language code intelligence. +Visual style: rounded content islands on a grey frame, low-contrast greys, one cool accent; +Islands Light is the default theme. `src/styles/tokens.css` is the source of truth for colours +and metrics; `DESIGN.md` and `PRODUCT.md` describe the design system and who the product is for. + +## Layout + +- `crates/ide-*` — backend crates; one domain each. Depend on `ide-core` for shared + types; never reach into another crate's internals. +- `src-tauri/` — glue only: `state.rs` (AppState / Project), `commands/.rs` + (desktop-only commands; the adapters of `ide-host` commands are derived), `events.rs`. + No domain logic here. +- `src/bindings.ts` — generated by tauri-specta (`pnpm gen:bindings`). Never edit. +- `src/platform/` — ipc (`call`, `onIdeEvent`, `nextRequestId`), actions registry, + keymap + dispatcher, context keys / `when` clauses, project store. +- `src/workbench/contributions.ts` — extension points (tool windows, status items, + overlays, editor kinds) and cross-feature services (editor, tool windows, notifications). +- `src/ui/` — design-system primitives. `src/features//` — one feature each, + exporting `activate()` registered in `src/features/index.ts`. +- `languages/.toml` — language definitions (detection, comments, LSP, DAP). +- `crates/ide-host` — the `openidea-server` binary for remote development and the + `openidea-plugin` CLI (plugin starter templates live in its `templates.rs`). +- `wit/` — plugin interface definitions; `plugins/` — sample and bundled plugins. + Plugin docs: `plugins/README.md`, `plugins/themes.md`. +- `java/` — JDT LS extension bundles (`java-usages`, `kotlin-bridge`) and the patched + Lombok agent, embedded into the app by `ide-sdk` / `ide-tools`. +- `e2e/` — Playwright UI tests (`pnpm e2e`). `evals/` — code-intelligence evals (`pnpm eval`). + `fixtures/` — sample projects per language for manual and automated testing. +- `docs/` — the Mintlify documentation site (`docs.json` navigation, `en/` and `zh/` pages); + preview with `npx mint dev` in `docs/`. + +## Rules + +- IPC coordinates: 0-based lines, **UTF-16** columns/offsets everywhere (`ide-core::text`). +- Every command returns `IdeResult`; convert internal errors at the crate edge. +- Declare a command once, on its implementation: `#[command(trust = …)]` in `ide-host::ops` + plus its module's `domain!` list (Tauri adapter, server handler and bindings are derived); + desktop-only commands use `#[desktop_command(trust = …)]` and `desktop_domain!`. +- Streaming → `tauri::ipc::Channel`; cancellable → UI-allocated `RequestId` + + `cancel_request`. Backend → UI notifications → `IdeEvent` via `EventSink`. +- Long work never blocks the UI thread or a Tauri command thread: use + `spawn_blocking`/rayon, honour `CancellationToken`. +- Frontend features never import each other; communicate via actions, contributions + and services. All user-invocable behaviour is an action with a stable id; default + shortcuts live in `src/platform/keymaps/`. +- Styling: CSS Modules + tokens only (no hex literals in components). Inline SVG + icons from `src/ui/icons.tsx`, never emoji. Real `