# Agent Customizations & Modular Rules Policy This directory (`.agents/`) maintains modular configuration, skills, and guidelines for AI coding assistants working in the `hose-use` repository. --- ## 1. Directory Structure ``` .agents/ ├── README.md # This document: architecture & trigger policy ├── skills.json # Declarative skill path and exclusion filters ├── skills/ # Project-scoped Agent skills │ └── repo-gh/SKILL.md # Markdown 实体文件驱动 GitHub CLI 与 Git 操作规范 └── rules/ # Modular, domain-specific rule definitions (trigger: "manual") ├── production-safety.md # 生产环境安全红线、免读源码与写操作防护原则 ├── cli-protocol.md # CLI stdout/stderr stream contract & exit codes ├── tenant-and-credential.md # 多租户凭据管理、协助链接与单据检索最佳实践 ├── testing-and-dev-hygiene.md # 单元测试规范、非交互环境防护与发布流程 ├── typescript-style.md # ESM, explicit .js imports, and TypeScript styles └── windows-development.md # Windows 跨平台协作、全小写分支、LF换行与大文件拦截守则 ``` --- ## 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 (``), consuming substantial context 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 by the user or agent. 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 & Skills Inventory ### Rules (`.agents/rules/`) | Rule File | Domain / Scope | Key Responsibilities | | :--- | :--- | :--- | | [`rules/production-safety.md`](./rules/production-safety.md) | 全局行为 | **生产安全最高红线**、严禁私自翻阅源码配置 (Zero Source-Reading)、两阶段确认写保护。 | | [`rules/tenant-and-credential.md`](./rules/tenant-and-credential.md) | 凭证与单据 | 同等凭据原则、协助链接导入与 `--overwrite` 保护、个人单据 (`task submitted` / `bill list --mine`) 快速通道。 | | [`rules/cli-protocol.md`](./rules/cli-protocol.md) | `src/cli/**/*.ts` | 严格 `stdout` JSON vs `stderr` 诊断输出契约、200KB 大报文防爆拦截、退出码规范。 | | [`rules/testing-and-dev-hygiene.md`](./rules/testing-and-dev-hygiene.md) | 测试与流程 | `bun:test` 规范、测试环境禁止阻塞交互输入、`bun run check` + `bun test` 门禁与发布更新规范。 | | [`rules/typescript-style.md`](./rules/typescript-style.md) | `src/**/*.ts` | ES Modules、强制携带 `.js` 后缀、Zod 运行时校验与代码规范。 | | [`rules/windows-development.md`](./rules/windows-development.md) | 全局 / 跨平台 | Windows 跨平台协作、全小写分支强校验、换行符 LF、符号链接开启与大文件/保留字拦截守则。 | ### Skills (`.agents/skills/`) | Skill Directory | Target Tool | Key Responsibilities | | :--- | :--- | :--- | | [`skills/repo-gh/`](./skills/repo-gh/SKILL.md) | `gh` / `git` | **Markdown 实体先行(Markdown-First)**、`.drafts/` 隐藏草稿驱动、杜绝内联长文本、统一简体中文规范。 | --- ## 4. Usage Instructions for AI Agents - **Production Operations**: Always consult [`rules/production-safety.md`](./rules/production-safety.md) and [`rules/tenant-and-credential.md`](./rules/tenant-and-credential.md) before interacting with configured enterprise tenants. - **Git & GitHub Operations**: Always consult [`skills/repo-gh/SKILL.md`](./skills/repo-gh/SKILL.md) and [`rules/windows-development.md`](./rules/windows-development.md) for branch naming, commits, PR creation, and issue management. - **CLI Development**: When adding or refactoring CLI commands under `src/cli/`, consult [`rules/cli-protocol.md`](./rules/cli-protocol.md). - **Writing Tests**: When creating or modifying tests, consult [`rules/testing-and-dev-hygiene.md`](./rules/testing-and-dev-hygiene.md). - **TypeScript & Modules**: When adding new TypeScript files or resolving local imports, refer to [`rules/typescript-style.md`](./rules/typescript-style.md).