

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Agent Contribution Guidelines23Language: English | [简体中文](AGENTS-ZH.md)45This document defines the rules for AI agents (and the humans operating them)6working on this repository — whether you are contributing a pull request or7assisting a maintainer locally. It supplements, and never overrides,8[CONTRIBUTING.md](CONTRIBUTING.md) and the9[Compatibility Policy](COMPATIBILITY_POLICY.md).1011dio is one of the most depended-on packages in the Dart/Flutter ecosystem.12A single careless change can break tens of thousands of downstream projects.13Contributions here are not a playground: every change must be motivated,14tested, and compatible.1516## 1. Motivation first — no speculative changes1718**Do not invent work.** A change is only acceptable when it solves a problem19that actually exists.2021- Every non-trivial change must be traceable to a concrete motivation:22 a reproducible bug, an accepted issue/discussion, an RFC-style proposal,23 or an explicit maintainer request. "This seems useful" is not a motivation.24- Before implementing a feature, answer these questions in the issue or the25 PR description — if you cannot, do not open the PR:26 1. What cannot be done (or is done poorly) with the current dio?27 2. Who needs this, and in which real-world scenario?28 3. Why does it belong in dio itself, instead of an interceptor, an adapter,29 a transformer, or a separate package? dio is intentionally extensible;30 most needs are served by its extension points without core changes.31 4. What is the cost — API surface, maintenance burden, compatibility risk?32- One PR, one concern. Do not bundle several unrelated features or fixes33 into a single PR. Bundled "improvement packs" might be closed unreviewed.34- For any user-facing feature, open an issue for discussion **before**35 writing code, unless a maintainer has already asked for it. A bare36 `Closes #NNNN` is not the same as prior discussion: the referenced issue37 must show that maintainers have expressed interest or accepted the38 direction. Feature PRs without that grounding waste both your tokens and39 the maintainers' time, and might be closed.4041## 2. Tests are mandatory for logic changes4243Every behavioral change must be proven by tests.4445- Any change to logic requires new tests or adjustments to existing tests46 that fail without the change and pass with it. Bug fixes must include a47 regression test that reproduces the original report.48- CI reports coverage diffs on every PR. The published minimum threshold is49 low, but that is a floor, not a target: coverage of code you changed50 should not regress, and new logic (including error paths) should be51 covered by real assertions.52- Tests must be **effective and non-duplicated**:53 - Assert observable behavior, not implementation details.54 - Do not add tests that merely re-execute existing covered paths to55 inflate coverage numbers.56 - Search the existing suites first — extend an existing test group57 instead of creating a near-duplicate file.58- Put tests in the right place:59 - Package-specific behavior → `<package>/test/`.60 - Behavior that must hold across all adapters/platforms → the shared61 `dio_test` package.62- Run the checks locally before claiming they pass:6364```bash65 melos run format # or format:fix66 melos run analyze67 melos run test # or targeted: test:vm / test:web / test:flutter68```6970- Never state that tests pass without having run them. Never check a PR71 checklist item you have not actually done. Misreporting verification72 status may lead to the PR being closed.7374## 3. Compatibility is sacred — avoid breaking changes7576dio's public API is a contract with an enormous downstream. Treat every77public symbol as frozen unless a maintainer decides otherwise.7879- **Default to non-breaking.** Prefer additive changes: new optional named80 parameters with safe defaults, new classes, new extension points.81- Do not change public method signatures, remove/rename public symbols,82 change default behavior, or alter thrown exception types without going83 through a deprecation cycle. Breaking changes belong in major releases.84 As dio's own [CHANGELOG](dio/CHANGELOG.md) preamble states, unavoidable85 breaking changes may occasionally ship in minor releases — those still86 require maintainer sign-off in advance and an entry in the87 [Migration Guide](dio/doc/migration_guide.md).88- If an API must go away, deprecate first and keep it working:8990```dart91 @Deprecated('Use XXX instead. This will be removed in X.0.0')92```9394 Deprecations must state their replacement and the removal version, and95 are only removed in the next major release, together with an entry in96 the Migration Guide. Target the *next* major, not a version beyond that.97- Do not raise the minimum Dart/Flutter SDK constraint of any package98 unless required by the [Compatibility Policy](COMPATIBILITY_POLICY.md)99 or its listed exceptions. CI tests against the minimum supported SDK;100 do not use language/library features beyond a package's lower bound.101- Watch for **behavioral** breaking changes too: changing defaults, header102 normalization, redirect/error semantics, or timing/ordering of103 interceptors can break downstream even when signatures are untouched.104- If a breaking change is genuinely unavoidable, stop and raise it in an105 issue for maintainers to decide. Do not merge-request it unilaterally.106107### Extra scrutiny in security- and network-critical areas108109Some parts of dio have oversized blast radius when broken. Changes here110require extra care, and the PR description should explicitly call the111change out and @-mention a maintainer:112113- SSL / TLS handling and certificate pinning (`badCertificateCallback`,114 `SecurityContext`, adapters' `HttpClient` configuration).115- Redirect handling and cross-origin behavior (redirect policy, header116 forwarding, cookie leakage across redirects).117- Cookie management (`dio_cookie_manager`, domain / path matching).118- Header handling (`Authorization`, `Content-Type`, casing, duplicates).119- Timeout, cancellation, and connection pooling.120- The interceptor pipeline (ordering, error propagation, `next` /121 `resolve` / `reject` semantics).122- Request-body encoding: `FormData`, multipart streaming, encoding123 detection.124125Rule of thumb: if getting this wrong could leak credentials, hang a126request forever, or change data on the wire, treat it as sensitive.127128### Test certificates and keys129130Self-signed certificates and their private keys used only for local131test fixtures (TLS, ALPN, pinning, etc.) are **not real secrets** — but132committing static `.key`/`.crt` files still has costs: secret-scanner133noise, package-size bloat for published artifacts, and inconsistency134with this repo's convention of generating such fixtures at test time135(see `scripts/prepare_pinning_certs.sh`).136137- **Prefer generating certificates at test setup** (via `openssl` in138 a `setUp`/helper, or a setup script) over committing static files.139- **If a static fixture is unavoidable**, exclude it from the published140 package with both:141 - `false_secrets` in the package's `pubspec.yaml` (suppresses pub's142 leak-detection warning), and143 - a `.pubignore` **inside the fixture subdirectory** (e.g.144 `test/certificates/.pubignore`), never at the package root — a145 root-level `.pubignore` overrides the root `.gitignore` for the146 entire directory, silently re-including build artifacts and other147 git-ignored files in the published package.148149### Dependency changes150151Do not bundle drive-by dependency bumps into a feature/fix PR. When a152dependency change is itself the point of the PR:153154- State the reason in the description (security fix, required for a new155 feature, upstream deprecation, etc.). "Latest is greater" is not a156 reason.157- Verify the change under every supported SDK version declared in the158 affected `pubspec.yaml`. Do not raise the package's SDK lower bound159 just to accommodate the new dependency unless the160 [Compatibility Policy](COMPATIBILITY_POLICY.md) allows it.161- Prefer the narrowest constraint that solves the problem (patch >162 minor > major bump).163- Call out any new transitive dependencies — downstream users care about164 their lockfile.165- Use `⬆️ chore` (or `chore(deps)`) as the commit type.166167## 4. Understand before you change168169- Read the surrounding code and existing patterns before editing. Match170 the existing style, naming, and module boundaries.171- Fix root causes, not symptoms. When a symptom is reported, locate the172 actual defect before patching.173- Never guess an API — neither dio's internals nor third-party packages.174 Read the actual source and the package's own tests/examples when175 unsure. If `dart analyze` says a member does not exist, go back to the176 source instead of retrying variations. Dependency source locations:177178 | Platform | Default location |179 |---|---|180 | macOS / Linux | `~/.pub-cache/hosted/pub.dev/<package>-<version>/` |181 | Windows | `%LOCALAPPDATA%\Pub\Cache\hosted\pub.dev\<package>-<version>\` |182183 If the `PUB_CACHE` environment variable is set, use that location184 instead of the platform default.185- **Verify every external fact before writing it down.** Agents186 routinely hallucinate numbers and attach wrong labels to them — RFC187 numbers, issue/PR numbers, library/API version numbers, CVE188 identifiers, deprecation timelines, benchmark figures, attributed189 quotes, platform-behavior claims ("iOS X.Y and later…"). A wrong190 citation in a commit message, changelog, or doc comment is worse191 than no citation, because it misleads downstream readers and192 reviewers who trust it. Before writing any external fact:193 1. Look up the source and confirm it says what you claim. For RFCs,194 check `https://www.rfc-editor.org/rfc/rfcNNNN` (or195 `https://datatracker.ietf.org/doc/rfcNNNN/`) and confirm the196 title matches; for issues/PRs, open the link; for library197 versions, read the package's own changelog/source.198 2. Confirm any section anchor, version number, or quoted text you199 cite actually exists at that source.200 3. If you cannot verify the fact online, drop the citation and201 describe the observed behavior in your own words instead. Do not202 guess a number to make a statement look authoritative.203 This applies to commit messages, `CHANGELOG.md`, doc comments,204 README, and any prose in a PR description.205206## 5. Production quality only207208- No placeholder work: no `TODO`/`FIXME` left behind, no mocked or209 simplified logic presented as complete, no "will optimize later" code.210- Handle edge cases and error paths explicitly; never swallow errors211 silently.212- If you cannot finish something completely, say so explicitly and state213 the boundary — do not pretend it is done.214215## 6. When to stop and ask216217Agents default to "guess and proceed". Do not. Pause and check with the218operator (or open a discussion issue) when:219220- The task description is ambiguous and multiple reasonable interpretations221 would produce materially different implementations.222- Fixing the reported problem would require design changes that go beyond223 what was asked for.224- The right fix touches an area not obviously in scope (e.g., renaming a225 public API to fix an unrelated bug, or restructuring an interceptor226 pipeline to enable a small feature).227- You cannot reproduce the reported issue after a reasonable attempt.228- The request itself seems wrong (e.g., the "bug" is intended behavior, or229 the "feature" would violate a rule in this document).230231Do **not** stop to ask permission for routine mechanical steps: running232tests / format / analyze, staging files, opening a draft PR, or choices233that are already decided by this document (commit format, changelog,234attribution).235236## 7. Repository layout237238This is a [Melos](https://github.com/invertase/melos/tree/main/docs)239mono-repo:240241| Path | Package |242|---|---|243| `dio/` | The core package |244| `plugins/web_adapter/` | `dio_web_adapter` |245| `plugins/cookie_manager/` | `dio_cookie_manager` |246| `plugins/http2_adapter/` | `dio_http2_adapter` |247| `plugins/native_dio_adapter/` | `native_dio_adapter` |248| `plugins/compatibility_layer/` | `dio_compatibility_layer` |249| `dio_test/` | Shared test suites for all adapters |250| `example_dart/`, `example_flutter_app/` | Examples |251252Setup:253254```bash255dart pub global activate melos256melos bootstrap257```258259Each package versions and releases independently. Note that packages have260**different SDK lower bounds** (see each `pubspec.yaml`).261262## 8. Commits, changelog, and PR hygiene263264### 8.1 Branch naming265266Work on a feature branch named `category/ticket-id-or-short-description`:267268- `category` matches the Conventional type used in the commit:269 `feat`, `fix`, `perf`, `refactor`, `docs`, `test`, `chore`, `ci`,270 `style`.271- Use the tracked **ticket id** when one exists — the issue or PR272 number: `fix/2201`, `feat/2555`. Combining both is fine when it aids273 discoverability: `fix/2201-cookie-domain-match`.274- Otherwise use a **short description** — 2–5 kebab-case words that275 describe the change (`docs/agents-guidelines`,276 `feat/cors-preflight-warning`, `chore/bump-http2-3.0.0`).277278Rules:279280- Never work on `main` directly.281- One branch per PR; do not reuse a merged branch for a new change.282- Keep branch names ASCII, lowercase, and short.283284### 8.2 Commit message format — Gitmoji or Conventional285286Every commit uses **[gitmoji](https://gitmoji.dev)** at the front or a287**[Conventional Commits](https://www.conventionalcommits.org)** type288prefix. Emojis are chosen from the gitmoji specification — do not invent289new ones.290291```292<gitmoji> <Short imperative subject>293(or)294<type>[(<scope>)]: <short imperative subject>295296[optional body — wrap at ~72 chars]297298[optional footer, e.g. Closes #1234]299```300301Gitmoji commonly used in this repository (see `git log` for the full set).302**Pick one column — never both.** Each row maps a gitmoji to its303equivalent Conventional-type prefix; you use the emoji **or** the type,304not the two glued together. `🔧 chore: ...` is wrong.305306| Gitmoji | Conventional type | Use for |307|---|---|---|308| ✨ `:sparkles:` | `feat` | New user-facing feature |309| 🐛 `:bug:` | `fix` | Bug fix |310| ⚡️ `:zap:` | `perf` | Performance improvement |311| ♻️ `:recycle:` | `refactor` | Refactor with no behavior change |312| 📝 `:memo:` | `docs` | Documentation |313| ✅ `:white_check_mark:` | `test` | Tests only |314| 🚨 `:rotating_light:` | `fix` / `style` | Fix linter or analyzer warnings |315| 🥅 `:goal_net:` | `fix` / `refactor` | Catch errors / improve error handling |316| 🔧 `:wrench:` | `chore` | Config / tooling |317| 👷 `:construction_worker:` | `ci` | CI / workflow changes |318| 💚 `:green_heart:` | `ci` | Fix a failing CI job |319| ⬆️ `:arrow_up:` | `chore` | Bump a dependency |320| 🔥 `:fire:` | `chore` / `refactor` | Remove code or files |321| 🎨 `:art:` | `style` | Formatting / structure only |322| 🔖 `:bookmark:` | `chore(release)` | Release (**maintainers only**) |323324Rules:325326- Subject is an imperative English sentence. Do not append the PR number —327 GitHub adds `(#N)` automatically on squash-merge.328- Use scope when it clarifies (`fix(dio_web_adapter): ...`); omit when it329 would just repeat the file path.330- Position 0 is either the emoji or the Conventional prefix plus colon, then a space, then the subject.331- After a gitmoji the subject starts with a **capital letter**332 (`🐛 Allow ...`, `📝 Clarify ...`); after a Conventional prefix the333 subject stays lowercase (`docs: add ...`, `perf(dio): reduce ...`).334335Examples (adapted from actual repo history):336337```338🐛 Allow `callFollowingErrorInterceptor` when rejecting in `ErrorInterceptorHandler`339perf(dio): reduce `FormData.readAsBytes` memory usage for large payloads340docs: add agent contribution guidelines341```342343Do **not** combine the two styles:344345```346❌ 🔧 chore: group codeql-action updates (both gitmoji AND prefix)347✅ 🔧 Group codeql-action updates (gitmoji only, capitalized subject)348✅ chore: group codeql-action updates (Conventional only, lowercase subject)349```350351### 8.3 AI attribution — mandatory352353Transparency about AI involvement is required. Do not hide it, and do not354skip it "to keep the commit clean".355356- Add a `Co-Authored-By:` trailer for **every AI agent** that produced357 code, tests, or docs in the commit:358359```360 Co-Authored-By: Claude <noreply@anthropic.com>361 Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>362```363364 Use the identity the agent itself publishes (see its own docs / recent365 commits from that agent on GitHub). Multiple agents → multiple trailers.366- Also disclose in the PR description **which agent(s) were used and for367 what stage** — design, implementation, tests, or review. One line is368 enough, e.g.:369370 > *Implementation and tests by Devin; local review pass by GLM-5.2.*371372- AI attribution never shifts accountability. The human submitting the PR373 owns every line, must understand it, and must respond to review feedback374 substantively. "The AI wrote it" is not an answer to a review question.375376### 8.4 CHANGELOG and docs377378- Update the `CHANGELOG.md` of **every package you changed**, under379 `## Unreleased` (replace `*None.*`).380- One concise bullet per change, written for downstream users, not for381 reviewers.382- Do not bump version numbers — releases are handled by maintainers.383- When public APIs change, also update `README.md`, `README-ZH.md`, API384 doc comments, and any affected examples.385386### 8.5 Self-review your diff before every commit387388Always inspect what you are about to commit:389390```bash391git diff # unstaged392git diff --staged # staged393git diff <base-branch>...HEAD # full branch diff before opening/updating a PR394```395396Remove before committing:397398- Debug output (`print`, `debugPrint`, `console.log`, temporary logs).399- Commented-out code left from earlier attempts.400- Reformatting or import re-ordering of files that are not the subject401 of this change.402- Unrelated bumps in `pubspec.yaml` / `pubspec.lock`.403- Whitespace-only changes in unrelated files.404- Editor/OS junk (`.DS_Store`, `.idea/`, personal scratch files).405406If you cannot explain why a hunk is in the diff, it does not belong in407the commit. Never use `git add .` or `git add -A` — stage files by path.408409**Also re-read the commit message against the staged diff.** A message410carried over from a previous attempt, or auto-completed from an411unrelated commit, is easy to miss and lands verbatim in history. If the412message and the diff describe different work, one of them is wrong.413414### 8.6 Opening the PR415416- **Open as a draft PR** (`Create draft pull request`) when the change417 is large, exploratory, or when you want maintainer direction before418 polishing. Convert to Ready for Review once local checks pass and the419 description is complete.420- Reference the closing issue with `Closes #NNNN` in the description.421- Follow the AI attribution rules in §8.3: disclose which agent(s)422 contributed and at which stage.423- Write PR titles and bodies in English, in the same commit style as424 §8.2.425- Only tick a PR checklist item that is genuinely done. For items that426 do not apply, keep the box unchecked and add *(not applicable —427 reason)* next to it. Do not check "done" as a shortcut.428- **Describe verification honestly — no boilerplate "Test plan"429 checklist.** In prose, state what you actually confirmed and how, in430 one or two sentences:431432 > *Added 15 unit tests covering method / content-type / custom-header433 > combinations; `melos run test:vm` and `melos run analyze` clean.*434435 Do **not** paste a generic checklist — this is the anti-pattern this436 section is explicitly rejecting, even if your agent tooling suggests437 one by default:438439```440 ❌ ## Test plan441 - [ ] Tests pass442 - [ ] Feature works as expected443```444445 Mechanical prerequisites (`dart analyze`, `dart format`) are already446 covered by the PR template's top-level checklist — do not re-list them447 as "tests". Behavioral verification means checks that would fail if448 this change regressed.449450 If something that ought to be verified genuinely could not be — needs451 browser CI, a physical device, production load, and so on — list it452 under a short **Unverified** paragraph explaining why. Unverified453 items are known risks; this should stay rare, not become routine.454455### 8.7 Review iteration workflow456457After opening the PR:458459- **Address feedback with new commits appended to the branch**, not by460 squash-and-force-push. Maintainers rely on incremental history during461 review; squashing happens at merge time.462- **Avoid `git push --force` on a branch that already has review463 comments** — it detaches those comments from their code position. If a464 rebase is genuinely required (e.g., conflict resolution against465 `main`), leave a comment before pushing so reviewers know.466- **Do not close and reopen the PR** to reset review state, retry CI, or467 bypass a blocking review. Push a fix instead.468- **Design-level feedback is a conversation, not an instruction.** If a469 reviewer's suggestion changes the intent of the PR (not just its470 implementation), reply first and reach agreement before writing new471 code. Blindly applying a large suggestion is worse than discussing it.472- **Mark review threads resolved** only after you have addressed the473 point in code and left a reply explaining what changed — or after the474 reviewer explicitly says so. Do not silently resolve.475- **CI failures**: read the failing job's log, find the root cause, then476 push a fix. Never re-run CI hoping for a green run. If a test is477 genuinely flaky, say so in a comment — do not paper over it by478 disabling the test or adding retries.479480## 9. Patterns that may lead to closure481482Quick cross-reference — each pattern is a violation of the rules above.483PRs matching one or more of these may be closed without detailed review484at the maintainers' discretion.485486| Pattern | See |487|---|---|488| No motivation or prior maintainer discussion | §1 |489| Multiple unrelated changes bundled in one PR | §1 |490| Logic changes without effective, non-duplicated tests | §2 |491| Public-API break without maintainer sign-off | §3 |492| Sensitive-area change without maintainer notice | §3 |493| Drive-by dependency bump in a feature/fix PR | §3 |494| Guessed / hallucinated API usage | §4 |495| Unverified or wrong external factual reference | §4 |496| Drive-by refactors, formatting sweeps, unrelated `.gitignore` / CI edits | §4, §8.5 |497| Placeholder work (`TODO`/`FIXME`, mocked or simplified logic presented as complete) | §5 |498| Branch name not following `category/ticket-id-or-short-description` | §8.1 |499| Non-standard commit message format (missing gitmoji, wrong type, non-English) | §8.2 |500| Missing or hidden AI attribution | §8.3 |501| Debug output or commented-out code left in the diff | §8.5 |502| Falsely checked PR checklist items | §8.6 |503| Force-pushing or close/reopen to reset review state | §8.7 |504
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126k | AGENTS.md | testlint-formatstylearch+4 | 99/100 | 14 days ago | |
| duckdb/duckdbAGENTS.md · 40k | AGENTS.md | buildtestlint-formatstyle+8 | 96/100 | 11 days ago | |
| steipete/CodexBarAGENTS.md · 20k | AGENTS.md | buildteststylearch+4 | 93/100 | today | |
| duckduckgo/content-scope-scriptsinjected/AGENTS.md · 70 | AGENTS.md | buildteststylearch+2 | 92/100 | 14 days ago | |
| spacedriveapp/spacedrivecore/AGENTS.md · 39k | AGENTS.md | buildtestlint-formatstyle+2 | 89/100 | 14 days ago | |
| onevcat/KingfisherAGENTS.md · 24k | AGENTS.md | setupbuildtestlint-format+6 | 89/100 | 14 days ago | |
| envoyproxy/envoyAGENTS.md · 29k | AGENTS.md | setupbuildtestlint-format+7 | 88/100 | 13 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/cfug-dio-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.