feat(agent): ship AI agent rules with npx init-agent installer - #386
Conversation
- agent/mieweb-ui.instructions.md: rules template (DataVis NITRO for all tables, component-first policy, import guidance) - agent/init-agent.mjs: mieweb-ui bin — writes .github/instructions/ file (VS Code Copilot applyTo) and idempotent marked block in AGENTS.md - package.json: bin entry, ship agent/ in files - eslint: config block for Node CLI scripts (scripts/, agent/) - README: AI Agent Rules section
There was a problem hiding this comment.
Pull request overview
This PR packages @mieweb/ui AI-agent guidance alongside the library and adds an npx-driven installer to copy those rules into locations agents commonly read in consumer repositories (.github/instructions/ and an AGENTS.md marked block).
Changes:
- Add an
agent/rules template (mieweb-ui.instructions.md) plus an installer CLI (agent/init-agent.mjs) exposed via a new packagebin. - Ensure the
agent/assets ship in the published package (filesupdate) and document usage in the repo README. - Add an ESLint config override intended for Node
.mjsscripts underscripts/andagent/.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new “AI Agent Rules” installer command and outputs. |
| package.json | Ships agent/ in the tarball and exposes the mieweb-ui bin that powers npx @mieweb/ui init-agent. |
| eslint.config.js | Adds a Node CLI scripts override (globals + console rule). |
| agent/README.md | Explains purpose of the agent/ folder and what each file does. |
| agent/mieweb-ui.instructions.md | Introduces the agent rules template (Copilot frontmatter + policy content). |
| agent/init-agent.mjs | Implements the installer: writes .github/instructions/... and updates/inserts the marked AGENTS.md block. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Deploying ui with
|
| Latest commit: |
14daa0b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ba3006dc.ui-6d0.pages.dev |
| Branch Preview URL: | https://feat-agent-instructions.ui-6d0.pages.dev |
…table rule - init-agent: search END marker after BEGIN so a stray END can't corrupt AGENTS.md - Rule 1 reframed: always propose DataVisNitroGrid first; Table allowed only when the human explicitly insists; scope Table in the catalog accordingly
- 2+ adjacent buttons must use ButtonGroup (no ad-hoc flex divs) - single buttons with long/dynamic labels also wrap in ButtonGroup so orientation=auto controls label ellipsis/stacking - add ButtonGroup to catalog Actions row; renumber later rules
…ng, a11y, i18n/RTL, forms, feedback, Tailwind setup, deprecations
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
agent/init-agent.mjs:57
- If
AGENTS.mdcontains a<!-- mieweb-ui:begin -->marker but is missing the matching<!-- mieweb-ui:end -->marker, the current logic falls into the append branch. On the next run,endmay match the END marker from the newly appended block, causing the refresh path to replace everything from the dangling BEGIN up to that END (potentially deleting unrelated content in between). Handle the “BEGIN without END” case explicitly to avoid corruption and repeated non-idempotent writes.
const start = current.indexOf(BEGIN);
const end = start === -1 ? -1 : current.indexOf(END, start + BEGIN.length);
let updated;
if (start !== -1 && end !== -1) {
updated = current.slice(0, start) + block + current.slice(end + END.length);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (2)
agent/mieweb-ui.instructions.md:35
- Rule 10 says to externalize all user-facing text (no hardcoded English strings in JSX), but this Rule 2 example uses hardcoded labels (Back/Cancel/Permanently delete this record). That inconsistency can cause agents to copy/paste non-i18n-safe examples. Add an explicit note in the example that string literals are placeholders and should be externalized per Rule 10.
// Multiple buttons
agent/mieweb-ui.instructions.md:67
- This code block includes hardcoded English strings (e.g., "Save", "Active") even though Rule 10 later states no hardcoded user-facing text in JSX. Adding a brief note here makes the examples consistent with the i18n rule and reduces the chance agents copy literals into real code.
// ❌ Violations
Summary
Ships AI agent rules with the
@mieweb/uipackage, plus a one-command installer that puts them where coding agents actually look. Goal: any agent working in a consumer repo uses DataVis NITRO for tables and reaches for@mieweb/uicomponents before inventing its own UI.Why an installer?
Agents don't read files inside
node_modules, so shipping an AGENTS.md in the tarball alone does nothing. The CLI copies the rules into the two places agents do read:.github/instructions/mieweb-ui.instructions.md— auto-applied by VS Code Copilot to**/*.{ts,tsx,js,jsx}viaapplyTofrontmatterAGENTS.md— the cross-tool convention read by Claude Code, Cursor, Codex, etc.Idempotent: rerunning refreshes the marked block in place, so consumers rerun after upgrading to pull new rules. Existing AGENTS.md content is preserved.
The rules (agent/mieweb-ui.instructions.md)
14 rules, with ❌/✅ violation examples where agents most often go wrong (sourced from lessons/component-policy.md):
DataVisNitroGridfirst;Tableonly if the human explicitly insists; AGGrid is deprecated; never hand-roll a gridorientation="auto"ellipsis control); icon-only buttons requirearia-labelModalHeader/Body/Footer,CardHeader/Content,Table*sub-componentsbg-primary-600,text-muted-foreground), chart CSS variablesThemeProvider+@mieweb/ui/brands, never global CSS resetsms-*/me-*) neverml-*/mr-*,IntlAPIsDateInput/DateRangePickernever rawtype="date"@sourcevs. TW3 preset + safelistChanges
agent/mieweb-ui.instructions.md— rules template (single source; the CLI derives both install targets from it)agent/init-agent.mjs— themieweb-uibin (plain Node, zero deps)agent/README.md— folder purpose + maintenance notepackage.json—binentry;agentadded tofiles(verified in tarball vianpm pack --dry-run)eslint.config.js— config block for Node CLI scripts (scripts/,agent/) with node globalsREADME.md— "AI Agent Rules" sectionTesting
.github/instructions/…andAGENTS.mdwith all 14 rules ✅AGENTS.md: appends block, preserves content ✅pnpm typecheck✅ ·pnpm lint✅ · prettier ✅Follow-ups (future PRs)
no-restricted-importson@mieweb/ui/ag-grid, raw<table>rule)list_components,get_component_docs)