From faf13b9a08647c29580c995711b8766debcd1f5d Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Wed, 6 May 2026 02:25:15 +0800 Subject: [PATCH] chore(AGENTS.md): updated --- AGENTS.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ef1d2aa18..1a526c6c8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -144,13 +144,14 @@ Concise but detailed reference for contributors working across the `moeru-ai/air ## Naming & Comments -- File names: kebab-case. +- File names: camelCase. - Prefer names that rely on the module boundary for context instead of repeating package, product, protocol, or transport prefixes inside every symbol. A well-named module should let exported functions use short action-first names; repeat the larger context only when the symbol crosses a boundary where that context is no longer obvious. - Name functions after the domain operation they perform, not after the implementation layer that happens to contain them. This keeps call sites readable after refactors and avoids names becoming stale when code moves between files. - Avoid names that encode multiple layers of ownership into one symbol. If a name needs several qualifiers to be understandable, reconsider the module boundary or introduce a clearer local concept. - Use nouns for resolved domain concepts and verbs for transformations or side effects. When a function derives a policy/configuration from an event or request, name the domain result explicitly so callers understand what decision is being made. -- Avoid classes unless extending runtime/browser APIs; FP + DI is easier to test/mock. -- Add clear, concise comments for utils, math, OS-interaction, algorithm, shared, and architectural functions that explain what the function does. +- Prefer classes for runtime/browser APIs and substantial business modules when the class owns state, lifecycle, or a stable domain boundary. Prefer FP for pure transformations and local helpers. +- Use dependency injection only at real external boundaries: database, model runtime, queue, Redis/cache, filesystem, network, clock, environment, and feature gates. Do not introduce `Dependencies`/`Deps` objects for internal functions that only call sibling helpers or forward parameters. +- Add clear, concise comments for utils, math, OS-interaction, algorithm, shared, and architectural functions that explain non-obvious intent, invariants, constraints, or why the code is needed. - When using a workaround, add a `// NOTICE:` comment explaining why, the root cause, and any source context. If validated via `node_modules` inspection or external sources (e.g., GitHub), include relevant line references and links in code-formatted text. - When moving/refactoring/fixing/updating code, keep existing comments intact and move them with the code. If a comment is truly unnecessary, replace it with a comment stating it previously described X and why it was removed. - Avoid stubby/hacky scaffolding; prefer small refactors that leave code cleaner. @@ -159,15 +160,25 @@ Concise but detailed reference for contributors working across the `moeru-ai/air - `// REVIEW:` concerns/needs another eye - `// NOTICE:` magic numbers, hacks, important context, external references/links +## Module Design + +- Prefer deep modules over shallow modules. A module should hide a meaningful decision: policy, persistence boundary, protocol/schema contract, scheduling semantics, model prompt contract, domain invariant, or lifecycle concern. +- Do not split by execution order alone. Files named like `collector`, `planner`, `executor`, `deps`, or `utils` are acceptable only when each owns a distinct stable responsibility and can be understood without reading all sibling files. +- Keep cohesive domain flows together until there is proven pressure to split. A 200-400 line cohesive module is preferable to several shallow modules that pass the same context/options through each other. +- Before creating a new `createXService` or `XDependencies`, verify that `X` adds policy, validation, state, retry/error handling, IO boundary, or a reusable abstraction. If not, keep it as a private helper or inline it. +- Avoid pass-through services such as `createXService({ yService })` when `X` adds no meaningful policy, validation, state, or abstraction. +- Test through stable public behavior. Do not create new exports, dependency bags, or wrapper services only to make private implementation details mockable. +- Prompt text, model-facing schemas, and prompt rendering helpers belong in `packages/prompts` when they are reused, model-facing contracts, or require prompt tests/evals. Server files should wire runtime dependencies and call prompt builders instead of inlining large prompts. + ## PR / Workflow Tips -- Rebase pulls; branch naming `username/feat/short-name`; clear commit messages (gitmoji optional). +- Rebase pulls; branch naming `username/feat/short-name`; clear commit messages (gitmoji is required). - Summarize changes, how tested (commands), and follow-ups. - Improve legacy you touch; avoid one-off patterns. -- Keep changes scoped; use workspace filters (`pnpm -F