- 吸收来自 hose-sealai-bridge 仓库的近期协作与开发规范演进 - 增强 Git Hooks 防护体系: - .githooks/pre-commit:拦截主干分支 (main/master) 直接提交,校验分支全小写与设备前缀,拦截 >15MB 单文件与 Windows 非法字符/保留设备名 - .githooks/pre-push:拦截向远端推送含大写字母的分支名 - .githooks/branch-guard.sh:增加大写字符强校验 - .githooks/setup.sh & setup.ps1:跨平台一键配置 hooksPath、autocrlf 与 symlinks - 跨平台与敏感文件防护: - 新增 .gitattributes 固化 LF 换行符(防止 Windows 下 CRLF 篡改 Shell 脚本) - 更新 .gitignore 增加 .env、*.pem、*.key 及 .drafts/* 忽略 - 确立 Markdown 实体先行标准 (Markdown-First): - 设立 .drafts/ 目录作为草稿落盘规范 - 新增项目级 Skill .agents/skills/repo-gh/SKILL.md - 新增 .agents/rules/windows-development.md - 更新 .agents/rules/issue-pr-workflow.md、.agents/rules/branch-naming.md、.agents/README.md 与 AGENTS.md
78 lines
6.3 KiB
Markdown
78 lines
6.3 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
|
|
├── skills/ # Project-level skills
|
|
│ └── repo-gh/ # GitHub CLI & Git Markdown-First operations
|
|
└── rules/ # Modular, domain-specific rule definitions
|
|
├── branch-naming.md # Device branch prefix & strictly lowercase branch naming
|
|
├── windows-development.md # Windows cross-platform rules, longpaths, LF & symlinks
|
|
├── 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
|
|
├── security-posture.md # Security tradeoffs & accepted risk boundaries
|
|
├── workspace-hygiene.md # Branch/worktree hygiene & release delta review
|
|
└── skill-documentation.md # Skill documentation layering & deterministic wrench boundary
|
|
```
|
|
|
|
---
|
|
|
|
## 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/branch-naming.md`](./rules/branch-naming.md) | Whole Repo / Git | 本设备创建分支的命名规范(设备前缀,如 `mac15/`)、必须且只能全小写。 |
|
|
| [`rules/windows-development.md`](./rules/windows-development.md) | Whole Repo / Cross-Platform | Windows 开发环境协作避坑:Hooks 激活、全小写分支、长路径、LF 换行、软链接与大文件/保留字拦截。 |
|
|
| [`rules/issue-pr-workflow.md`](./rules/issue-pr-workflow.md) | Whole Repo / Workflow | GitHub Issue 调研、方案汇报、PR 提交流程,Markdown 实体先行驱动(`.drafts/`),严格杜绝未授权提前发版。 |
|
|
| [`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 防重放校验。 |
|
|
| [`rules/security-posture.md`](./rules/security-posture.md) | Security / Governance | 研发易用性优先的安全边界与妥协项记录。 |
|
|
| [`rules/workspace-hygiene.md`](./rules/workspace-hygiene.md) | Git / Workspace | 工作区分支/Worktree 定期清理与发版差异回溯。 |
|
|
| [`rules/skill-documentation.md`](./rules/skill-documentation.md) | Skill Docs | Skill 文档分层架构与确定性扳手边界。 |
|
|
|
|
---
|
|
|
|
## 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. Use `.drafts/` for multi-line commit and PR bodies (see `.agents/skills/repo-gh/SKILL.md`).
|
|
- **Branch Naming & Windows Compatibility**: Always verify branch names are strictly lowercase with the configured device prefix (`.agents/rules/branch-naming.md`). Refer to [`rules/windows-development.md`](./rules/windows-development.md) for cross-platform compatibility guidelines.
|
|
- **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).
|