65 lines
4.5 KiB
Markdown
65 lines
4.5 KiB
Markdown
# 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:
|
|
|
|
```yaml
|
|
---
|
|
description: "..."
|
|
globs: "src/..."
|
|
trigger: "manual"
|
|
---
|
|
```
|
|
|
|
1. **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.
|
|
2. **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.
|
|
3. **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`](./rules/issue-pr-workflow.md) | Whole Repo / Workflow | GitHub Issue 调研、方案汇报、PR 提交流程,Pre-Push 产物同步校验,严格杜绝未授权提前发版。 |
|
|
| [`rules/cli-protocol.md`](./rules/cli-protocol.md) | `src/cli/**/*.ts` | 严格 `stdout` JSON vs `stderr` 诊断指引协议、退出码规范(0, 1, 2, 10)、SWR 异步缓存与 `--dry-run` 预览防线。 |
|
|
| [`rules/testing.md`](./rules/testing.md) | `src/**/*.test.ts` | 测试运行器 (`bun:test`)、同目录就近原则、环境变量/临时目录彻底隔离与网络 Mock 规范。 |
|
|
| [`rules/typescript-style.md`](./rules/typescript-style.md) | `src/**/*.ts` | ES modules、强制本地 `.js` 扩展名、Zod 输入校验与领域类型安全。 |
|
|
| [`rules/staging-simulation.md`](./rules/staging-simulation.md) | `src/domains/seal/**` | 生产规则安全演进闭环(草稿 -> sync-test -> test regression -> 用户批准)、业务编号脱敏红线。 |
|
|
| [`rules/material-pack-policy.md`](./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.md`](./rules/issue-pr-workflow.md) and the project root `AGENTS.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/`, read [`rules/cli-protocol.md`](./rules/cli-protocol.md) before writing output streams.
|
|
- **Writing Tests**: When creating or modifying tests, read [`rules/testing.md`](./rules/testing.md).
|
|
- **TypeScript & Modules**: When adding new TypeScript files or resolving local imports, refer to [`rules/typescript-style.md`](./rules/typescript-style.md).
|
|
- **Rule Remediation & Staging**: When modifying approval rules or syncing between production and test enterprises, refer to [`rules/staging-simulation.md`](./rules/staging-simulation.md).
|
|
- **Webhook Material Packs**: When exporting, previewing, or validating Webhook attachment bundles, refer to [`rules/material-pack-policy.md`](./rules/material-pack-policy.md).
|