| name | mas-code-standards |
| description | Apply AUTO-MAS code standards derived from representative DLmaster_361 commits on dev. Use when editing modules mainly authored by DLmaster_361, especially frontend/electron/services, frontend/electron/ipc, initialization UI code, or when the user asks to follow AUTO-MAS code standards or code conventions. |
MAS Code Standards
Objective
Reproduce the practical implementation style used by DLmaster_361 in current dev without copying obsolete behavior or broadening scope unnecessarily.
Scope
Primary reference samples:
frontend/electron/services
frontend/electron/ipc
frontend/src/views/Initialization
For Python modules, carry over the same values of explicit orchestration, compatibility-first changes, and operational logging, but always compare nearby files before applying style assumptions.
Workflow
- Read references/style-observations.md, with priority on commit lenses
e541fa5f, 727aafb, and e5d72bdb.
- Sample 2 to 3 sibling files in the same module before editing.
- Keep the main execution path obvious; extract helpers only when they make the flow easier to follow.
- Match nearby naming, logging tone, comment style, and result contracts.
- Prefer minimal edits that blend into surrounding code rather than style-driven rewrites.
- If recent maintainer review comments are available for the same area, treat them as the strongest style signal.
Commit Lenses
e541fa5f: small cleanup.
Keep logic local, remove one-off indirection, simplify conditions without changing outcome.
727aafb: feature landing.
Extend existing books, models, managers, routes, forms, and logs in parallel instead of inventing a separate architecture for the new type.
e5d72bdb: dev integration.
Preserve the feature branch structure, then consolidate at integration points instead of rewriting during merge.
Core Traits
- Use clear file sections such as
// ==================== 类型定义 ====================.
- Keep module headers and comments short, Chinese, and purpose-driven.
- Prefer explicit orchestration over generic abstractions or clever helpers.
- Use
getLogger('中文名') and short operational log lines.
- Allow light duplication when it keeps each step readable and local.
- Respect file-local formatting; do not normalize unrelated code.
- When adding a new script or domain type, extend config model, schema, routing, task registration, frontend types, composables, and edit views together.
- Prefer compatibility edits at registration points such as
BOOK, union types, routing branches, and progress payloads before deeper refactors.
- For finite variants, prefer a small dict/registry mapping instead of many near-identical branches.
- Keep frequently edited task-configuration logic visible in the owning flow with a short comment instead of hiding it behind one-off helpers.
- Do not copy another script/domain's special-case logs, timeout exemptions, ignore lists, or workaround branches into a new module until that behavior is confirmed locally.
- If a new capability is used only once, default to an inline block or local helper; split into
builder, loader, or extra services only after real reuse or boundary pressure appears.
- Trust existing validators, config containers, and task bases when they already guarantee an invariant; do not add a second layer of fallback or correction.
- For new Python-heavy flows, keep signatures and call sites compatible with at least basic static type checking.
- Prefer deleting redundant imports, waits, and wrappers over preserving "explicit" but noisy scaffolding.
- Use Conventional Commits for commit messages:
<type>(<scope>): <subject>, with documented types such as feat, fix, docs, style, refactor, perf, test, chore, build, and ci.
- Choose commit scope from the touched file name when one file changes, or from the parent folder name when multiple related files change.
- For backend docstrings, use Google-style sections for summary,
Args, Returns, and Raises when a function needs explanation.
- For
ConfigBase subclasses, comment every and group config items by clear section markers before .
Comment Preservation
Do not treat cleanup as permission to strip comments. Preserve comments that explain business intent, operational steps, compatibility decisions, non-obvious invariants, maintainer context, or config-field meaning.
Only remove or rewrite a comment when it is stale, misleading, mechanically restates the next token of code, or refers to code that is being deleted in the same edit. When rewriting, keep the useful intent and make it shorter or more accurate instead of dropping it.
Protect these comments especially:
ConfigItem comments and section markers in ConfigBase subclasses.
- Ordered workflow comments such as "第一步" and "第二步" in long service flows.
- Task-injection, config-swap, log-monitoring, and compatibility notes in runtime code.
- Frontend section comments that help scan large edit pages or distinguish type-specific logic.
Avoid
- Do not introduce framework-heavy abstractions or generic factories unless the surrounding module already uses them.
- Do not hide the main workflow inside too many helper layers.
- Do not switch comment or logging language inconsistently inside a file.
- Do not turn a small fix into a broad refactor for stylistic purity.
- Do not confuse "explicit" with "verbose".
- Do not modify OpenAPI-generated files. Ask the developer to regenerate them manually when updates are required.
- Do not split equivalent behavior into multiple methods or API routes when a dict selector or type field represents the difference directly.
- Do not leave dead support paths for future detailed/raw config when there is no complete UI-to-runtime path yet.
- Do not add maintainer-facing "safety" code that only repeats guarantees already enforced by base classes or validators.
- Do not submit a versioned feature or fix without considering whether
res/version.json needs a matching version-info entry under the next unreleased version.
- Do not delete useful comments just to make a diff look cleaner.
Review Checklist
- The new code reads like neighboring
DLmaster_361 files.
- Logs and comments are concise, operational, and consistent with the touched module.
- The main path is still easy to trace top-to-bottom.
- Compatibility and existing behavior were preserved unless the task explicitly changed them.
- The chosen style lens matches the task: cleanup, feature landing, or dev integration.
- Finite variant selection uses existing books/registries/dicts where that is clearer than method proliferation.
- Config choices have one source of truth and do not duplicate existing mode/tab selectors.
- New special cases were verified for this domain instead of cargo-culted from another module.
- New code would survive basic static type checking without relying on
None or fallback branches that conflict with declared types.
- Commit messages and scopes follow the project convention when preparing commits.
- Backend comments and config-class annotations use the project style rather than ad hoc prose.
- Existing useful comments were preserved or updated accurately, not removed as noise.