|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Repo Scope |
| 4 | + |
| 5 | +This repository contains the Agent Control plugin for OpenClaw. It is a TypeScript ESM project that ships source files directly; there is no separate build step in normal development. |
| 6 | + |
| 7 | +## Local Verification |
| 8 | + |
| 9 | +Run the full local verification stack before finishing non-trivial changes: |
| 10 | + |
| 11 | +```bash |
| 12 | +npm run lint |
| 13 | +npm run typecheck |
| 14 | +npm test |
| 15 | +``` |
| 16 | + |
| 17 | +When the change affects tests, coverage, or CI behavior, also run: |
| 18 | + |
| 19 | +```bash |
| 20 | +npm run coverage |
| 21 | +``` |
| 22 | + |
| 23 | +Coverage output is written to `coverage/`, including `coverage/lcov.info` for Codecov-compatible uploads. |
| 24 | + |
| 25 | +## Testing Conventions |
| 26 | + |
| 27 | +- Prefer behavioral tests over implementation-detail tests. |
| 28 | +- Write test names as concise behavioral summaries. |
| 29 | +- Express Given/When/Then structure as code comments inside the test body. |
| 30 | +- Make each Given/When/Then comment descriptive. Do not use placeholder comments like `// Given`, `// When`, or `// Then` by themselves. |
| 31 | +- Use Vitest for unit and integration-style tests. |
| 32 | +- Assert externally visible outcomes first: return values, registered hooks, emitted logs, blocked tool calls, resolved context, and client calls. |
| 33 | +- Mock boundary dependencies such as `agent-control`, session/context helpers, and runtime-loading edges when needed, but keep the assertions focused on plugin behavior. |
| 34 | +- When adding a new branch in plugin logic, add or update tests in the corresponding `test/*.test.ts` file. |
| 35 | + |
| 36 | +Examples of the preferred naming style: |
| 37 | + |
| 38 | +- `it("defaults to warn", () => { ... })` |
| 39 | +- `it("blocks the tool call when fail-closed sync fails", async () => { ... })` |
| 40 | + |
| 41 | +Examples of the preferred comment style: |
| 42 | + |
| 43 | +- `// Given no logging configuration is provided` |
| 44 | +- `// When the effective log level is resolved` |
| 45 | +- `// Then warn mode is selected by default` |
| 46 | + |
| 47 | +## Project Conventions |
| 48 | + |
| 49 | +- Keep imports ESM-compatible and include the `.ts` suffix for local TypeScript imports, matching the current codebase style. |
| 50 | +- This repo uses `oxlint` for linting and `tsc --noEmit` for semantic typechecking. `npm run lint` is not a substitute for `npm run typecheck`. |
| 51 | +- Preserve the plugin's quiet default behavior. New logs should fit the existing `logLevel` model: |
| 52 | + - `warn`: warnings, errors, and block events |
| 53 | + - `info`: important lifecycle events |
| 54 | + - `debug`: verbose diagnostics |
| 55 | + |
| 56 | +## When Changing Config or User-Facing Behavior |
| 57 | + |
| 58 | +Keep these files aligned when config shape or documented behavior changes: |
| 59 | + |
| 60 | +- `src/types.ts` |
| 61 | +- `openclaw.plugin.json` |
| 62 | +- `README.md` |
| 63 | +- relevant tests under `test/` |
| 64 | + |
| 65 | +If a change affects CI expectations or coverage behavior, also update: |
| 66 | + |
| 67 | +- `.github/workflows/lint.yml` |
| 68 | +- `package.json` |
| 69 | +- `vitest.config.ts` |
| 70 | + |
| 71 | +## CI Expectations |
| 72 | + |
| 73 | +The main GitHub Actions workflow is `.github/workflows/lint.yml`. Changes to scripts or coverage generation should keep local commands and CI steps in sync. |
0 commit comments