243 lines
11 KiB
Markdown
243 lines
11 KiB
Markdown
# AGENTS.md
|
|
|
|
**Planet agent harness. Defines behavior for coding agents working in this repository.**
|
|
|
|
---
|
|
|
|
## Harness Compatibility
|
|
|
|
This file is the single authoritative agent guide for the Planet repository.
|
|
The older lowercase `agents.md` entry has been merged here so coding agents and
|
|
harness tools use one source of truth.
|
|
|
|
### Source Of Truth
|
|
|
|
- `rules.md` is the mandatory repository rule source. Always load `core`,
|
|
`security`, and `workflow`; load only task-relevant modules after that.
|
|
- `AGENTS.md` defines the local agent operating mode and evidence gates.
|
|
- `project_context.md` is background, not a rule source. Prefer newer
|
|
implementation docs when it disagrees with current code.
|
|
- `.codex/skills/` is the active specialized workflow layer for cleanup, docs,
|
|
goal-driven work, and release.
|
|
- Do not duplicate long workflow text across harness files. Durable constraints
|
|
belong in `rules.md`; task procedures belong in skills or scripts.
|
|
|
|
Read these files before changing code:
|
|
|
|
1. `rules.md`
|
|
2. `AGENTS.md`
|
|
3. `project_context.md`
|
|
4. `README.md`
|
|
5. `docs/HARNESS.md`
|
|
6. `CODEMAP.md`
|
|
|
|
For documentation work, also read `docs/documentation-coverage-rules.md`.
|
|
|
|
### Start Safely
|
|
|
|
Before broad edits:
|
|
|
|
```bash
|
|
git status --short
|
|
scripts/harness/doctor.sh
|
|
```
|
|
|
|
Use focused context commands before reading large files:
|
|
|
|
```bash
|
|
rg -n "<symbol-or-term>" <path>
|
|
git diff --stat HEAD
|
|
git diff --name-only HEAD
|
|
git diff --unified=0 HEAD -- <path>
|
|
```
|
|
|
|
Preserve user changes already present in the worktree.
|
|
|
|
### Validation
|
|
|
|
For an isolated change, run the smallest check that exercises the affected
|
|
behavior, along with any gates required for that area. For example, run the
|
|
docs consistency check for a link change, or reproduce a bug at the entry
|
|
point where it occurred.
|
|
|
|
Use the quick suite when a change affects shared harness wiring or needs
|
|
regression checks across areas:
|
|
|
|
```bash
|
|
scripts/harness/quick-check.sh
|
|
```
|
|
|
|
Use full validation for larger cross-subsystem changes:
|
|
|
|
```bash
|
|
scripts/harness/validate.sh
|
|
```
|
|
|
|
`validate.sh` includes quick checks, frontend Bun build, and frontend smoke
|
|
unless disabled by its documented environment flags. Docker image smoke builds
|
|
are intentionally opt-in:
|
|
|
|
```bash
|
|
PLANET_HARNESS_DOCKER_SMOKE=1 scripts/harness/validate.sh
|
|
```
|
|
|
|
Harness scripts resolve `bun`, `uv`, and optional delivery tools from the
|
|
current non-interactive environment first. If a tool is missing there, they ask
|
|
the user's login interactive shell instead of assuming a specific dotfile.
|
|
|
|
### High-Risk Areas
|
|
|
|
- `planet.sh` owns local lifecycle, ports, WSL/LAN behavior, and destructive
|
|
`destroy` cleanup.
|
|
- Frontend package management is Bun-only. Do not use npm, pnpm, or yarn.
|
|
- **Local Frontend Dev Uses Vite, Not Static Nginx**: Local frontend/Admin development defaults to the host Vite HMR server (`./planet.sh start` / `./planet.sh restart -f`); do not run or rebuild the static Nginx `planet_admin` container (`./planet.sh admin ...`) unless the user explicitly asks to simulate production locally (`本地模拟线上`).
|
|
- Frontend changes must satisfy `scripts/harness/frontend-rules-check.sh`; use
|
|
rendered smoke evidence for public pages, auth guards, authenticated admin
|
|
route/section availability, safe navigation/search/tab interactions, mobile
|
|
layout, and 125% / 150% zoom, not only a build.
|
|
- Admin or Docs layout changes must load `rules.md` `uiux` and preserve the
|
|
one-screen (`一屏` / `首屏`) height chain: route roots use `height: 100%`,
|
|
intermediate wrappers keep `min-height: 0`, and only the intended child owns
|
|
scrolling.
|
|
- **Admin Control Design Contract**: Inline controls in the same row must share
|
|
a `rules.md` density tier (`--an-control-xs/sm/md/lg`, e.g., `32px` filter bar
|
|
with `0px` height jump on filter reset), centered table selection/switch
|
|
columns, rounded-square shadowless `.tui-switch`, labeled `操作` columns, and
|
|
`.an-detail-link` navigation cues; enforced by
|
|
`scripts/harness/frontend-rules-check.sh` and `scripts/harness/frontend-smoke.mjs`.
|
|
- **Existing-UI Context Inspection Before Editing**: Whenever changing or
|
|
extending an existing interface (any non-new screen, such as `/earth/` HUD
|
|
overlays or existing Admin/Docs pages), inspect surrounding sibling controls,
|
|
icon font/library conventions, CSS cascade/load order, and spacing/typography
|
|
rules first (`rules.md` `uiux`). Never ship single-class `(0, 1, 0)` Earth icon
|
|
rules that lose to `css/fonts.css`, `!important` cascade band-aids, or
|
|
unaligned icon glyphs/sizes; satisfy `scripts/harness/frontend-rules-check.sh`
|
|
and verify rendered pixels via screenshot inspection.
|
|
- Earth HUD cards and floating panels must follow `rules.md` `uiux` ("Shell
|
|
Unified, Interior Expressive"): reuse `.hud-panel` liquid-glass + cursor-following
|
|
glow (`--panel-glow-x/y`), translucent interior layers (`alpha <= 0.35`),
|
|
`var(--hud-offset)` edge alignment, and `sharedHudFocusStack` focus/pin tiers
|
|
(checked by `scripts/harness/frontend-rules-check.sh`), while keeping body
|
|
visualizations, domain layouts, and scene choreography open to innovation.
|
|
- `aiprovider` is a protocol/provider adapter; keep business prompts and product
|
|
workflows in the backend.
|
|
- Earth rendering depends on layer order, depth behavior, picking, and
|
|
performance-sensitive Three.js code.
|
|
- Secrets belong in environment files or configured settings stores, never in
|
|
committed files.
|
|
- Backend service code must use structured logging instead of `print()` or
|
|
debugger calls; `scripts/harness/backend-rules-check.sh` enforces this.
|
|
- **Client-Only Gitea Releases**: Releases without desktop shell updates
|
|
(`client.mode == "none"` or `"hotfix"`) push changed container images plus OCI
|
|
`release-manifest:<tag>` (embedding L1 hotfix bundles in OCI for `hotfix`)
|
|
and must **not** create a Gitea Release; only `full` desktop client releases
|
|
create a Gitea Release so `/releases/latest` always carries installers, and
|
|
production `planet-release-deploy` reconciles from Git tags + OCI
|
|
`release-manifest:<tag>`.
|
|
- **Release Publish vs. Production Deployment (`发版 ≠ 已部署`)**:
|
|
`scripts/release_publish.py` only publishes container images, OCI
|
|
`release-manifest:<tag>`, and optional Gitea Releases; it never updates
|
|
host-side files or verifies rollout. Whenever the user asks to `部署`,
|
|
`发版部署`, or `上线`, follow `.codex/skills/release/SKILL.md` to diff
|
|
host-managed files (`scripts/production_deploy.py`, `deploy/`,
|
|
`docker-compose.deploy.yml`) against the prior tag, sync any changed host
|
|
files before rollout/retry, inspect `planet-release-deploy.service`, and
|
|
verify live public endpoints reflect the target version before claiming
|
|
deployment succeeded.
|
|
|
|
### Conflict Policy
|
|
|
|
Existing project rules and workflows win. If new harness guidance conflicts with
|
|
`rules.md`, `AGENTS.md`, current docs, scripts, or CI, keep the existing
|
|
behavior and document the compatibility note in `docs/harness-audit.md` or
|
|
`docs/HARNESS.md`.
|
|
|
|
---
|
|
|
|
## Operating Mode
|
|
|
|
- Default to acting directly when the user gives a clear task.
|
|
- For authorized multi-agent work, follow the Coding Agent Model Strategy in
|
|
`rules.md` workflow: Sol for implementation, Luna for bounded supporting work,
|
|
and Astra for complex reasoning; the main agent owns final verification.
|
|
- Ask before acting only when the missing decision is risky, cannot be
|
|
discovered from repository context, and no conservative assumption is safe.
|
|
- Read relevant files before editing.
|
|
- Prefer focused CLI evidence: `rg`, `git diff --stat`, `git diff --name-only`,
|
|
focused file reads, tests, builds, linters, and harness scripts.
|
|
- Keep changes scoped to the requested area. Do not mix cleanup, feature work,
|
|
release work, and documentation unless the task requires it.
|
|
- When the user corrects a detail, apply it to the original request. Carry the
|
|
correction into the result without turning discarded ideas into new requirements.
|
|
|
|
---
|
|
|
|
## Evidence Gates
|
|
|
|
- Visual inputs are blocking evidence. If the user provides a screenshot, image,
|
|
mock, browser capture, or visual reference, obtain evidence from the artifact
|
|
before interpreting intent or editing code.
|
|
- Path resolution is part of the task. If the path cannot be opened, first try
|
|
reasonable local equivalents such as WSL/Windows path conversion,
|
|
workspace-relative lookup, absolute paths, and attached-file locations.
|
|
- Never guess from prompt text, filenames, previous context, logs, OCR, or
|
|
memory when a visual artifact was provided but cannot be accessed.
|
|
- OCR is acceptable evidence for text-only visual questions or non-multimodal
|
|
environments; state that OCR was used as the fallback. Layout, color, spacing,
|
|
pixel, and rendering issues need real visual inspection or a clear limitation
|
|
note.
|
|
- If a visual artifact still cannot be inspected, say so and pause that
|
|
visual-dependent part of the work.
|
|
- Claims of completion need evidence: a relevant test, build, lint, screenshot,
|
|
diff, direct file check, or harness result.
|
|
- Verify the outcome through the entry point the user relies on. A source check
|
|
can confirm a code convention. A UI test with a mocked API can confirm what
|
|
the user sees for that response.
|
|
- When a test fails, identify the behavior or invariant it protects. Fix the
|
|
implementation if that regressed. If the behavior is correct and the assertion
|
|
pins an obsolete detail, update the test to exercise the behavior.
|
|
- For UI and rendering changes, verify the rendered result when local tooling
|
|
allows it.
|
|
|
|
---
|
|
|
|
## Communication
|
|
|
|
- Match the user's language. Use Chinese for Chinese requests unless the user
|
|
asks otherwise.
|
|
- Keep updates short and specific: what is being inspected, edited, or verified.
|
|
- Final responses should summarize changed files and verification, with blockers
|
|
stated plainly.
|
|
- Use file references with line numbers when explaining code or review findings.
|
|
|
|
---
|
|
|
|
## Quality Bar
|
|
|
|
- Prefer existing project patterns and the smallest change that satisfies the
|
|
request. Keep one-off logic at its call site unless extraction clarifies a
|
|
complex operation or lets callers share the same behavior.
|
|
- Validate and normalize external data at the boundary that owns it. Recheck a
|
|
guarantee when data crosses a new trust boundary or an operation can invalidate it.
|
|
- Before adding a retry, lock, or fallback, identify the failure it addresses
|
|
from a requirement, an existing contract, or observed behavior. Catch errors
|
|
where the caller can recover, translate them, or add context and propagate them.
|
|
- Remove stale branches, mocks, compatibility paths, and duplicated helpers once
|
|
a stable path exists.
|
|
- Centralize prompts, constants, defaults, and shared request/response handling.
|
|
- Do not add secrets, generated runtime output, or local environment files.
|
|
- Frontend commands use Bun only. Do not use `npm`, `pnpm`, or `yarn`.
|
|
- Run the smallest relevant verification for the changed scope and report
|
|
anything skipped.
|
|
|
|
---
|
|
|
|
## Prohibited
|
|
|
|
- Do not skip visual evidence handling when a visual artifact was provided.
|
|
- Do not preserve obsolete harness files just because they already exist.
|
|
- Do not invent behavior not present in code, docs, or verified external
|
|
sources.
|
|
- Do not rewrite unrelated files during cleanup.
|
|
- Do not mark a task complete without checking concrete success criteria.
|