给 Python 包写 AGENTS.md:导入路径,不是 Next 路由
在 Cursor 里维护 Python 包(pyproject / src 布局)的工程师。路径:AGENTS.md
不是 Roo / Cline 模版。本站不托管安装包。订哪档去 /compare。
把 AGENTS.md 放到仓库根目录。这是 Python 包的 Cursor 根契约:Agent 按导入路径改模块,不是按 Next.js 的 app/page.tsx 加路由。
先投下这份文件,再去 /compare 决定订哪档。本页不是 Roo / Cline / Continue / ChatGPT 模版;不要改成 .roo 或 .clinerules。本站不托管 Cursor 安装包,装桌面走 /downloads。
AGENTS.md# AGENTS.md
This repository is a Python package. Read this file before editing.
This is not a Next.js App Router app. Do not add `app/page.tsx`, `src/app/`, `pages/`, `next/link`, or `generateStaticParams`.
## Layout
- Package code lives in `src/<import_name>/` (src layout) or in the top-level package directory already named in `pyproject.toml`. Honor whichever layout exists.
- Tests live in `tests/` (or next to modules if that is already the local convention).
- Build and tool config live in `pyproject.toml`. Do not add a second build backend unless the task asks for it.
- Do not create a frontend route tree to "make it browsable."
## Imports
- Public imports use the **import package name**, not a Next-style `@/` alias and not `src.` as a prefix. Example: `from inventory.pricing import compute_total`.
- If `[project].name` on PyPI differs from the import package (`packages` / `[tool.setuptools.packages.find]`), use the import package in code.
- Inside the package, prefer relative imports for private modules (`from .pricing import compute_total`) when that matches local style.
- Do not add `sys.path.insert` hacks. Do not reach into another distribution's private modules.
- Install the package editable (`pip install -e .`, `uv pip install -e .`, or the command this repo already documents) so imports resolve. Do not copy `.py` files into `site-packages` by hand.
## Tooling
- Honor the lockfile or pin files already in the repo (`uv.lock`, `poetry.lock`, `requirements.txt`, `constraints.txt`).
- Run the nearest existing tool: `pytest`, `ruff`, `mypy` / `pyright`, as already configured. Do not add a second test runner or a second linter.
- Keep `requires-python` and existing ruff/mypy settings. Do not weaken them.
## Changes
- Scope the diff to the module named in the request.
- Do not drive-by refactor unrelated packages.
- After edits, run the nearest typecheck / lint / unit test for the touched package.
## Secrets
- Never commit API keys, tokens, or `.env` values.
- Tests must not read production `.env`. Use environment variable *names* and fixtures.
## What this file is
Root agent contract picked up from the repository root. Glob-scoped Cursor rules live in `.cursor/rules/*.mdc`.