runner.ts statically imported all 28 command modules, so `seal-use version` paid for exceljs, archiver and the embedded skill bundle on every run: measured 175ms against a 7ms bare-bun baseline. Dispatch branches now load their handler with await import() on demand, and compareSemVer/isNewerVersion move to a tiny core/semver.ts so the version path no longer drags in the 1200-line updater. selectCorp and createSealClient follow the same pattern. Measured after: version 37-45ms, help 40ms, corps list 40ms. The performance contract in cli-protocol.md is updated from an aspirational <10ms to a measured <50ms with the numbers. update.ts's service-restart finally block is also restructured: throwing from finally swallowed the original update error, and the previous catch/branch hid a restart failure behind a log line. the dead `args` parameter of handleMcpCommand goes with its caller here, so the signature change and the call site land together.
Agent Customizations & Modular Rules Policy
This directory (.agents/) maintains modular configuration, skills, and guidelines for AI coding assistants working in the seal-use repository.
1. Directory Structure
.agents/
├── README.md # This document: architecture & trigger policy
├── skills.json # Declarative skill path and exclusion filters
└── rules/ # Modular, domain-specific rule definitions
├── issue-pr-workflow.md # Issue triage, PR workflow & strictly no premature release
├── cli-protocol.md # CLI stdout/stderr dual-stream contract, exit codes & SWR
├── testing.md # Unit/integration testing conventions (bun:test) & test hygiene
├── typescript-style.md # ESM, explicit .js imports, and TypeScript styles
├── staging-simulation.md # Rule remediation lifecycle, test sync & sandbox regression
└── material-pack-policy.md # Webhook material pack structure, Excel injection & attachment policy
2. Trigger Strategy & Context Budget Management
Why trigger: "manual"?
In Antigravity (agy), rule files located in .agents/rules/*.md support YAML frontmatter:
---
description: "..."
globs: "src/..."
trigger: "manual"
---
- Token Economy: If set to
trigger: "always_on", every turn of the conversation unconditionally injects all rules into the system prompt (<user_rules>), consuming substantial tokens on every request regardless of task relevance. - On-Demand Activation: Setting
trigger: "manual"prevents automatic background injection into the prompt budget. The rules remain available on-demand when explicitly referenced or requested. - Cross-Agent Neutrality: Non-agy agents (e.g. OpenAI Codex, Claude Code, Cursor, generic LLMs) do not recognize
agy's private frontmatter triggers. Storing modular guidelines as plain Markdown with a manual trigger ensures they function as clean, standalone reference docs that any agent can read on demand via standard file reading tools without unexpected prompt pollution.
3. Modular Rules Inventory
| Rule File | Domain / Scope | Key Responsibilities |
|---|---|---|
rules/issue-pr-workflow.md |
Whole Repo / Workflow | GitHub Issue 调研、方案汇报、PR 提交流程,Pre-Push 产物同步校验,严格杜绝未授权提前发版。 |
rules/cli-protocol.md |
src/cli/**/*.ts |
严格 stdout JSON vs stderr 诊断指引协议、退出码规范(0, 1, 2, 10)、SWR 异步缓存与 --dry-run 预览防线。 |
rules/testing.md |
src/**/*.test.ts |
测试运行器 (bun:test)、同目录就近原则、环境变量/临时目录彻底隔离与网络 Mock 规范。 |
rules/typescript-style.md |
src/**/*.ts |
ES modules、强制本地 .js 扩展名、Zod 输入校验与领域类型安全。 |
rules/staging-simulation.md |
src/domains/seal/** |
生产规则安全演进闭环(草稿 -> sync-test -> test regression -> 用户批准)、业务编号脱敏红线。 |
rules/material-pack-policy.md |
src/domains/seal/material-pack/** |
Webhook 材料包结构、单据附件目录双向隔离匹配、附件尺寸/后缀安全策略与 HMAC 防重放校验。 |
4. Usage Instructions for AI Agents
- General Tasks & Issue Resolution: Follow
rules/issue-pr-workflow.mdand the project rootAGENTS.md. When solving GitHub issues: analyze -> report -> solve -> PR, never trigger release bump or tags without explicit instructions. - CLI Development: When adding or refactoring CLI commands under
src/cli/, readrules/cli-protocol.mdbefore writing output streams. - Writing Tests: When creating or modifying tests, read
rules/testing.md. - TypeScript & Modules: When adding new TypeScript files or resolving local imports, refer to
rules/typescript-style.md. - Rule Remediation & Staging: When modifying approval rules or syncing between production and test enterprises, refer to
rules/staging-simulation.md. - Webhook Material Packs: When exporting, previewing, or validating Webhook attachment bundles, refer to
rules/material-pack-policy.md.