State alias rule v2 in AGENTS.md
Check / check (pull_request) Successful in 37s

This commit is contained in:
Danny Kim
2026-10-17 16:02:20 +09:00
parent c778c00068
commit 166476dee9
+14 -10
View File
@@ -19,16 +19,20 @@ dependency. Keep the sources to erasable syntax and `.ts` imports, which
type-checks, and `vp test` runs Vitest. Unit tests sit next to the code as
`src/*.test.ts`; repository-level tests live in `tests/`.
An alias in `package.json` `imports` owns its target: a folder's `index.ts`
owns that folder and everything below it, any other file owns only that file.
No file may be owned by 2 aliases. Outside an area, only the exact alias
reaches it (no deeper `#` specifier, no relative path); inside it, relative
imports of siblings and subfolders are free. `../` is banned in every file
(`import/no-relative-parent-imports`). The one alias is `#testing`
(`./src/testing.ts`): every test imports it by alias, and `tests/` reaches
`src/` only through it. Other `src/` files import `./` siblings freely.
`scripts/` is flat: one file per tool, no subfolders and no `index.ts`
(barrels live only in `src/`), imported directly by file path.
A `#` alias in `package.json` `imports` may point anywhere and owns its
target: an alias to a folder's `index.ts` owns that folder and everything
below it; an alias to any other file owns only that file. No overlap: no file
may be owned by 2 aliases, so no alias inside another alias's area and no 2
aliases with the same target. Outside an area, only the exact alias reaches
it; a deeper alias specifier or a relative path into the area is a bypass.
Inside an area, relative imports of siblings and subfolders are free. `../`
is banned in every file, owned or not
(`import/no-relative-parent-imports`). Files no alias owns need no `index.ts`
and no alias, and import `./` siblings and subfolders freely. The one alias
is `#testing` (`./src/testing.ts`): every test imports it by alias, and
`tests/` reaches `src/` only through it. `scripts/` is flat: one file per
tool, no subfolders and no `index.ts`, imported directly by file path
([.agents/memory/imports-aliases-barrels.md](.agents/memory/imports-aliases-barrels.md)).
The only config files are `package.json`, `tsconfig.json`, and
`vite.config.ts`, plus `package-lock.json`. Repo-local lint rules and the rule