返回 CodeWhale
AGENTS.md
根目录 / AGENTS.md
1 # Working on the Codewhale Engine
2
3 The Engine owns agent turns, model requests and sessions. Start with the
4 [architecture](docs/ARCHITECTURE.md) and the nearest scoped `AGENTS.md` for
5 the files you are changing. [CONTRIBUTING.md](CONTRIBUTING.md) covers local
6 setup, issue and patch submission, and maintainer responsibilities.
7
8 ## Working rules
9
10 - Trace the user-facing behavior to its owner and check existing callers before
11 choosing an implementation. Reuse an existing path when it fits. Preserve
12 trust-boundary checks, accessibility, data integrity and external compatibility.
13 - Maintainers work in a short-lived worktree from current `origin/main`. Check
14 `git status` and `git worktree list` for overlapping work. Coordinate with
15 active writers, preserve local changes and stage only your paths or hunks.
16 Keep credentials, private infrastructure details and build output out of Git.
17 - For a local-only task keep source, diffs and checks offline. Report any
18 verification that requires external access. Follow the repository's
19 [security reporting route](.github/SECURITY.md) for confidential findings.
20 - Implement first, then run existing checks. Add a regression test for a bug or
21 component contract when existing coverage misses it. Put rationale in the
22 commit message. Add no new code comments and correct any made stale by the change.
23 - Public naming is **Codewhale**. Migrate compatibility identifiers, storage keys
24 and protocols explicitly. Providers and models remain first-class choices.
25
26 ## Current contracts
27
28 | When changing | Contract and owner |
29 | --- | --- |
30 | Agent turns and delegation | `Engine::run_turn` owns execution. The model-facing delegation tool is `agent`. Changes to turn ownership must update the [single-loop guard](crates/core/tests/single_turn_loop.rs). |
31 | Prompts and session context | [BASE_PROMPT](crates/engine/src/prompts/text.rs) is the sole base prompt. Keep the session-pinned system prompt and tool catalog stable. Append changing context as user-role history. See [prompt caching](docs/CACHE.md). |
32 | Logging and replay | Record every model-visible input as a session event so the request can be reconstructed. Live presentation must agree with the persisted record. |
33 | Configuration and async work | Report invalid configuration as soon as it can be resolved. Use async I/O on Tokio, or move blocking work to a blocking worker or dedicated thread. |
34 | Commands, providers and feature flags | Update the [feature registry](docs/features.toml) in the same change. Maintainers add release notes for user-visible changes under the [commit guidelines](CONTRIBUTING.md#commit-messages). |
35 | Existing behavior | Review the [behavioral guards](crates/engine/tests/behavioural_guards.rs). Change a guard with the promise it represents. The [triage guide](docs/ISSUE_TRIAGE.md) defines regressions. |
36
37 ## Claiming a test passed
38
39 Use `scripts/dev-test.sh <area-or-path> [filter]` to select a focused Rust
40 check. Confirm it ran the intended tests and report the actual counts, failures
41 and source revision. A filter can match zero tests and exit successfully.
42 Check the normal product entry point when the claim concerns visible behavior.
43 Record installed, provider and release results only when observed.
44 See [build performance](docs/BUILD_PERFORMANCE.md) and [pre-push verification](CONTRIBUTING.md#pre-push-verification).
45
46 ## Merging under a gate
47
48 Maintainers run the matching formatting, changelog, budget, and website-fact
49 checks (enforced automatically by `.github/workflows/main-landing.yml`), review
50 open findings, and verify the required CI on the exact candidate commit. A
51 required acceptance record must
52 show a pass. Resolve blocking findings before fast-forwarding `main`. If the
53 base moves, rebase, recheck what changed and qualify the new head. Preserve
54 shared history. Signing, publishing, tags, deployment and destructive cleanup
55 require separate authority. See [how contributions land](CONTRIBUTING.md#how-your-contribution-lands).
56
57 ## Landing other people's work
58
59 Use the [contribution process](CONTRIBUTING.md#how-your-contribution-lands)
60 for issues and PRs. Maintainers review the full patch before pushing or
61 dispatching it. Use `macos_runner=hosted` for the first run of external code.
62 PRs run no test suite. Integrate accepted changes and their regression proof
63 in a maintainer wave. Have someone who did not author the wave review it,
64 resolve their findings and run Linux, macOS and Windows CI on the exact commit.
65
66 - Account for each behavior and edge case as kept, adapted or left out. Share
67 adaptations and omissions before landing so the contributor can correct a
68 misunderstanding. Thank them for their specific work and link the landing
69 commit, its scope and its release status when closing.
70 - Keep the contributor as author when their diff lands. For an adapted design,
71 reproduction or prototype, use a final-block `Co-authored-by` trailer with
72 the GitHub-linked address in [.github/AUTHOR_MAP](.github/AUTHOR_MAP). Add
73 missing addresses and an `Integrated from #N by @handle` line per person.
74 - Use `Closes #N` only for fully delivered issues. For PRs use
75 `Integrated from PR #N by @handle` and `Refs #N`, then close by hand.
76 Maintainers decide how contributions are handled. Automation must never
77 close a submission, block or reject a contributor or their work, mark either
78 as unapproved, or execute untrusted PR code via `pull_request_target`.
79
79 lines MARKDOWN