检查器修改模式(会话级范围的)
规则建立有状态、会话级范围的检查器修改模式,用于共同维护 React 组件及其对应的隔离开发检查器,而不会发生跨会话污染。
登录即可访问此规则
使用您的 Google 开发者资料登录,即可查看和复制“Build It!”系列中使用的完整规则。
必须提供开发者资料
您不符合创建开发者资料的条件。请通知您的 Workspace 管理员启用此功能。
创建开发者资料
创建免费的 Google 开发者资料,解锁所有 Build It! 技能、规则、提示和工件。
加入 Builder Central 即可解锁
一键领取免费的 Builder 会员徽章,解锁所有 Build It! 技能、规则、提示和工件。
会话级范围的检查器修改模式的运作方式
在打开组件检查器的情况下迭代界面组件时,您希望组件修改在同一轮中更新匹配的检查器视图,而不会在未来的会话中永久强制执行检查器修改。此规则使用对话范围的标记文件解决了该问题:
- 每个新对话默认关闭:全新对话会在正常模式下启动,因此常规修改只会影响您明确要求的文件。
- 进入检查器编辑模式:说出“进入检查器编辑模式”(或“开启检查器模式”)。代理会在
<appDataDir>/brain/<conversation-id>/inspector-mode.active处创建一个会话级范围的标记文件,读取src/dev/registry.ts,并列出此会话涵盖的每个已注册组件。 - 自动协同维护:启用后,您对已注册组件请求的任何更改都会先更新该组件,然后立即使用组件检查器更新程序工作流同步其匹配的
src/dev/inspectors/[ComponentName]Inspector.tsx,运行npx tsc --noEmit,并使用确认条状标签标记响应。 - 随时干净利落地退出:说出“退出检查器修改模式”即可移除标记文件,并返回到正常的单目标修改模式。在一个会话中开启该模式绝不会影响并行会话或未来会话。
如何在 Google Antigravity 中安装
将此规则与第 9 集的两个组件检查器技能一起放入 Google Antigravity 工作区:
检查器修改模式规则定义
将此完整规则定义复制到工作区中,并命名为 inspector-editing-mode.md。
inspector-editing-mode.md (.agents/rules/inspector-editing-mode.md)
# Inspector Editing Mode (Session-Scoped)
This rule establishes a stateful, session-scoped **Inspector Editing Mode** for co-maintaining React components and their corresponding isolated development inspectors (`src/dev/inspectors/[ComponentName]Inspector.tsx`).
---
## 1. Scope & Isolation Model
* **Session-Scoped**: The on/off state of this mode is strictly scoped to the current conversation session (`<conversation-id>`).
* **Default State**: Every new conversation session begins with Inspector Editing Mode **OFF** by default.
* **State Marker**:
- Activation is tracked at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
- If this file exists for the active session's conversation ID, Inspector Editing Mode is **ON**.
- If this file does NOT exist, Inspector Editing Mode is **OFF**.
* **Zero Cross-Session Contamination**: Turning this mode on in one conversation has no effect on any other parallel or future conversation sessions.
---
## 2. Trigger Commands & State Transitions
### A. Entering Inspector Mode
* **Trigger Phrases**:
- *"Enter inspector editing mode"*
- *"Start inspector editing mode"*
- *"Turn on inspector mode"*
- *"Inspector mode on"*
* **Agent Action**:
1. Create the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
2. Read `src/dev/registry.ts` to identify all currently registered components.
3. Respond confirming:
- Inspector Editing Mode is now **ACTIVE** for this session.
- Any subsequent changes to registered components will automatically update both the component and its dev inspector.
- List the currently registered components covered by this mode.
### B. Exiting Inspector Mode
* **Trigger Phrases**:
- *"Exit inspector editing mode"*
- *"Stop inspector editing mode"*
- *"Turn off inspector mode"*
- *"Inspector mode off"*
* **Agent Action**:
1. Remove the marker file at `<appDataDir>/brain/<conversation-id>/inspector-mode.active` if present.
2. Respond confirming that Inspector Editing Mode is now **DEACTIVATED** for this session and normal single-target editing has resumed.
### C. Status Query
* **Trigger Phrases**:
- *"Is inspector mode active?"*
- *"Inspector mode status"*
- *"What mode am I in?"*
* **Agent Action**:
- Check for the existence of `<appDataDir>/brain/<conversation-id>/inspector-mode.active`.
- Report whether the current session is in **Inspector Mode** or **Normal Mode**.
---
## 3. Co-Maintenance Behavior While Mode is ACTIVE
Whenever the user requests changes, fixes, or refactors to ANY component registered in `src/dev/registry.ts`:
1. **Step 1: Update the Core Component**
- Apply the requested code changes, props modifications, or behavioral logic in `src/components/.../[ComponentName].tsx` (or `src/views/.../[ComponentName].tsx`).
- Update any relevant unit tests in `scripts/` or `__tests__/`.
2. **Step 2: Automatically Synchronize the Dev Inspector**
- Locate the matching inspector at `src/dev/inspectors/[ComponentName]Inspector.tsx`.
- Apply the `component-inspector-updater` workflow:
- **Props & State**: Reconcile any new, altered, or deleted props into the *Editable State* or *Props State* categories.
- **Computed State**: Update derived `useMemo` metrics if underlying rules or formulas changed.
- **Test Verification Cards**: Synchronize the plain-English test fixtures at the bottom of the inspector with the new behavior, updating click handlers so `[Load Test Fixture]` accurately reflects the new state.
- **Preserve Custom Presets**: Keep all existing scenario presets (e.g. week overhauls, superset pairs, edge cases) intact, adapting their shapes to new prop signatures.
- **Advance Timestamp Chip**: Advance `const GENERATED_AT = 'YYYY-MM-DD HH:MM [TIMEZONE]';` to the current local timestamp.
- **No Auto-Scroll**: Ensure all internal scrolling is scoped strictly to element containers (`containerRef.current.scrollTop = containerRef.current.scrollHeight`) with zero page-level scrolling.
3. **Step 3: Verify Types**
- Run `npx tsc --noEmit` to ensure type alignment between the component and its inspector.
- **DO NOT** run raw `npm run build` while a local dev server is active to prevent wiping out `.next/` chunk manifests.
4. **Step 4: Badge Confirmation in Response**
- Include an explicit status chip in your response header or summary:
`[Inspector Mode: Synced <ComponentName> & Dev Inspector]`
---
## 4. Behavior While Mode is INACTIVE (Default)
* When the mode is OFF, the agent performs only the exact requested file modifications.
* Do NOT edit `src/dev/inspectors/` unless the user explicitly requests an inspector update or instructs the agent to create a brand new inspector route.