Files
seal-use/.agents
gitea ffb9820822 Add --dry-run mutation previews across remaining mutating commands
Close the AGENTS.md "Safety Guardrail & Mutation Preview" coverage gap:
every remote-mutating command now supports --dry-run returning
structured JSON with preview: true, without executing the mutation.

- Domain capabilities gain an optional dryRun param and preview
  handlers: sealUserCreate/ResetPassword/Delete/Activate/DelegationCreate,
  sealDelegationRevoke, sealApprovalRuleCreate/Update/Delete/
  VersionPublish, sealSimulationBatchClean, sealInsightRecordAnalyze.
  Previews reuse the shared mutationPreview() diff shape; reads (GET)
  are allowed to build the before/after, writes never fire.
- CLI wiring: users create/delegation/reset-password/delete, rules
  create/update/delete/publish, simulation delete, analytics analyze,
  auth link revoke pass dryRun; dry-run bypasses the --yes gate
  (webhook delete pattern); corps mark previews the local config tag
  change without writing it.
- Shared dryRunOption() helper in parser.ts; help registry documents
  --dry-run on all covered commands; cli-protocol.md §3 example list
  updated; cli.md and embedded skill regenerated.
- New src/cli/commands/dry-run-gates.test.ts pins the contract:
  preview JSON on stdout, zero mutating requests (GET-only where reads
  are needed), config untouched for local previews.

Local user-config writes (corps switch/rename, config mode/test-dir/
lint) stay outside this contract: they are reversible local edits with
no upstream effect.
2026-10-24 22:08:37 +08:00
..

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:

---
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 Whole Repo / Workflow GitHub Issue 调研、方案汇报、PR 提交流程,Pre-Push 产物同步校验,严格杜绝未授权提前发版。
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 防重放校验。

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.
  • 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.