Files
hose-use/.agents/README.md
gitea fbccc46b29 chore(infra): 引入跨平台开发规范、Git Hooks 门禁与 Windows 兼容性防护
- 新增版本控制的跨平台 Git Hooks (`.githooks/`):
  - `pre-commit`:拦截在主分支 (main/master) 直接提交;强制分支名全小写;拦截 >15MB 大文件;拦截 Windows 非法字符与系统保留设备名
  - `pre-push`:拦截直接向远程主分支推送代码,强制 GitHub PR 合并;拦截大写分支推送;兼容双远端镜像同步
  - `setup.sh` / `setup.ps1`:一键自动配置 core.hooksPath、core.autocrlf 与 core.symlinks
- 新增根目录 `.gitattributes`:固化 hooks 与 shell 脚本为 LF 换行符,规避 CRLF 异常
- 新增项目根目录 `.drafts/` 隐藏草稿目录并更新 `.gitignore`(忽略 .drafts/*,增加敏感私钥 *.pem, *.key 防护)
- 新增项目级 Agent Skill `.agents/skills/repo-gh/SKILL.md`:
  - 确立 Markdown 实体文件驱动铁律(--body-file / -F),杜绝命令行内联多行文本拼接
  - 统一 Issue、Commit、PR 的全流程简体中文规范
- 新增 `.agents/rules/windows-development.md`:《Windows 环境协作与开发守则》
- 新增 `.github/ISSUE_TEMPLATE/feature_request.yml` 与 `.github/pull_request_template.md` 模板
- 更新 `AGENTS.md` 与 `.agents/README.md`:对齐全小写分支与 Markdown-First 开发规范
2026-10-27 10:41:16 +08:00

4.9 KiB
Raw Permalink Blame History

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:

---
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 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 全局行为 生产安全最高红线、严禁私自翻阅源码配置 (Zero Source-Reading)、两阶段确认写保护。
rules/tenant-and-credential.md 凭证与单据 同等凭据原则、协助链接导入与 --overwrite 保护、个人单据 (task submitted / bill list --mine) 快速通道。
rules/cli-protocol.md src/cli/**/*.ts 严格 stdout JSON vs stderr 诊断输出契约、200KB 大报文防爆拦截、退出码规范。
rules/testing-and-dev-hygiene.md 测试与流程 bun:test 规范、测试环境禁止阻塞交互输入、bun run check + bun test 门禁与发布更新规范。
rules/typescript-style.md src/**/*.ts ES Modules、强制携带 .js 后缀、Zod 运行时校验与代码规范。
rules/windows-development.md 全局 / 跨平台 Windows 跨平台协作、全小写分支强校验、换行符 LF、符号链接开启与大文件/保留字拦截守则。

Skills (.agents/skills/)

Skill Directory Target Tool Key Responsibilities
skills/repo-gh/ gh / git Markdown 实体先行(Markdown-First)、.drafts/ 隐藏草稿驱动、杜绝内联长文本、统一简体中文规范。

4. Usage Instructions for AI Agents