Files
gitea 666a12c676 Enforce README naming convention for subdirectories
The root keeps README.md; every subdirectory README must be <dir>.readme.md with leading dots stripped. Add a blocking governance checker with 12 tests, wire it into package scripts, CI, and pre-commit, and rename the existing subdirectory READMEs.
2026-11-19 16:26:37 +08:00

6.3 KiB

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/
├── 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:

---
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 Whole Repo / Git 本设备创建分支的命名规范(设备前缀,如 mac15/)、必须且只能全小写。
rules/windows-development.md Whole Repo / Cross-Platform Windows 开发环境协作避坑:Hooks 激活、全小写分支、长路径、LF 换行、软链接与大文件/保留字拦截。
rules/issue-pr-workflow.md Whole Repo / Workflow GitHub Issue 调研、方案汇报、PR 提交流程,Markdown 实体先行驱动(.drafts/),严格杜绝未授权提前发版。
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 防重放校验。
rules/security-posture.md Security / Governance 研发易用性优先的安全边界与妥协项记录。
rules/workspace-hygiene.md Git / Workspace 工作区分支/Worktree 定期清理与发版差异回溯。
rules/skill-documentation.md Skill Docs Skill 文档分层架构与确定性扳手边界。

4. Usage Instructions for AI Agents

  • General Tasks & Issue Resolution: Follow 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 for cross-platform compatibility guidelines.
  • CLI Development: When adding or refactoring CLI commands under src/cli/, read rules/cli-protocol.md before 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.