Skip to content

Commit 134448b

Browse files
authored
docs: add agent guidance (#9)
1 parent cbd4aaa commit 134448b

4 files changed

Lines changed: 92 additions & 3 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
"pcss",
4848
"postcss"
4949
]
50-
}
50+
}

‎AGENTS.md‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# AGENTS.md
2+
3+
Guidance for coding agents working in this repository.
4+
5+
## Project Summary
6+
7+
`css-diff-devtools` is a WXT browser extension that adds a `CSS-Diff` sidebar to the DevTools Elements panel. Users select two DOM elements, and the extension compares their computed CSS properties across the current tab and synchronized browser windows/tabs.
8+
9+
## Stack
10+
11+
- Package manager: `pnpm` (`packageManager` is `pnpm@9.14.1`).
12+
- Extension framework: WXT.
13+
- UI: Vue 3 single-file components with Element Plus and Tailwind CSS.
14+
- Localization: WXT/browser `i18n` messages under `public/_locales`.
15+
- Language: TypeScript with Vue type checking through `vue-tsc`.
16+
- Formatting and linting: ESLint 9 with `@antfu/eslint-config`; Prettier is intentionally disabled in VS Code.
17+
- Browser target: Chrome by default, with Firefox and Edge build scripts available.
18+
19+
## Repository Layout
20+
21+
-`entrypoints/content.ts`: content script that relays messages from inspected pages to the DevTools page.
22+
-`entrypoints/devtools/main.ts`: registers the DevTools Elements sidebar pane.
23+
-`entrypoints/devtools-panel/`: Vue app rendered inside the DevTools sidebar.
24+
-`entrypoints/devtools-panel/hooks/useDevToolsPanel.ts`: main selection, comparison, filtering, table styling, and copy-to-clipboard logic.
25+
-`entrypoints/devtools-panel/message.ts`: broadcasts selected element data to other browser windows/tabs.
26+
-`entrypoints/devtools-panel/utils/`: shared formatting and array helpers.
27+
-`entrypoints/devtools-panel/lang.ts`: typed wrapper around `browser.i18n.getMessage`.
28+
-`public/_locales/en/messages.json`: English extension and panel messages.
29+
-`public/_locales/zh_CN/messages.json`: Simplified Chinese extension and panel messages.
30+
-`assets/main.css`: Tailwind layers and small global Element Plus table overrides.
31+
-`public/icon/`: extension icons.
32+
-`.github/renovate.json5`: dependency update policy.
33+
34+
Do not edit generated build output such as `.wxt`, `.output`, or packaged zip artifacts.
35+
36+
## Common Commands
37+
38+
- Install dependencies: `pnpm install --frozen-lockfile`
39+
- Start Chrome development build: `pnpm dev`
40+
- Start Firefox development build: `pnpm dev:firefox`
41+
- Start Edge development build: `pnpm dev:edge`
42+
- Type-check: `pnpm compile`
43+
- Build all browser targets: `pnpm build`
44+
- Build one target: `pnpm build:chrome`, `pnpm build:firefox`, or `pnpm build:edge`
45+
- Package all targets: `pnpm zip`
46+
- Generate changelog: `pnpm changelog`
47+
- ESLint format/fix: `pnpm exec eslint . --fix`
48+
- Regenerate WXT types: `pnpm exec wxt prepare`
49+
50+
There is no dedicated `lint` or `format` script in `package.json`; use ESLint directly through `pnpm exec`.
51+
52+
## Required Agent Workflow
53+
54+
1. Before changing files, inspect the current git status and avoid overwriting unrelated user changes.
55+
2. Keep changes scoped to the requested behavior or documentation.
56+
3. After every code generation or code-modifying task, run ESLint format/fix:
57+
58+
```sh
59+
pnpm exec eslint . --fix
60+
```
61+
62+
4. Run the most relevant verification command before claiming completion. For TypeScript or Vue changes, run `pnpm compile`; for extension packaging, locale, or manifest changes, run `pnpm exec wxt prepare` first and then the appropriate `pnpm build:*` command.
63+
5. Review `git diff` before staging, and stage only files that belong to the requested change.
64+
65+
## Coding Conventions
66+
67+
- Follow the existing Antfu ESLint style and let ESLint handle import ordering, spacing, semicolons, and stylistic fixes.
68+
- Prefer TypeScript types and local domain types from `entrypoints/devtools-panel/types.ts`.
69+
- Keep Vue component state and browser interaction logic in composables such as `useDevToolsPanel`.
70+
- Keep pure data helpers in `entrypoints/devtools-panel/utils/`.
71+
- Preserve the existing i18n structure by updating both `public/_locales/en/messages.json` and `public/_locales/zh_CN/messages.json` when adding user-visible strings.
72+
- Use Element Plus components consistently with the existing DevTools panel UI.
73+
- Use Tailwind utility classes for layout and small style adjustments.
74+
- The existing code relies on WXT/browser extension globals such as `browser`; do not replace them with unrelated APIs without a compatibility reason.
75+
76+
## Extension Behavior Notes
77+
78+
- The DevTools sidebar is created with `browser.devtools.panels.elements.createSidebarPane`.
79+
- Element selection is driven by `browser.devtools.panels.elements.onSelectionChanged` and `browser.devtools.inspectedWindow.eval`.
80+
- Computed styles are normalized by `formatStyle` before comparison.
81+
- Selected elements are compared as `left` and `right`; a third selection is ignored until the current selection is cleared.
82+
- Cross-window/tab synchronization is handled by broadcasting through `browser.tabs.sendMessage`.
83+
- Table rows use color classes to distinguish changed and unchanged CSS properties, and clicking a value cell copies `property: value;`.
84+
85+
## Pull Request Expectations
86+
87+
- Use concise Conventional Commits style for commits and PR titles.
88+
- Include what changed, why it changed, and which verification commands were run.
89+
- Do not include generated output, dependency churn, or unrelated formatting changes unless the request explicitly requires them.

‎postcss.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export default {
33
tailwindcss: {},
44
autoprefixer: {},
55
},
6-
};
6+
}

‎tailwind.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export default {
55
extend: {},
66
},
77
plugins: [],
8-
};
8+
}

0 commit comments

Comments
 (0)