Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .agent/rules/packages.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,31 @@ Use **subpath exports only**. Each submodule is imported via its own path.
Do not re-export children from parent `index.ts` files — this avoids a flat
namespace that grows unwieldy and risks name collisions.

Packages build with **tsdown** to dual ESM + CJS, so each export entry has both
an `import` (ESM: `.js`/`.d.ts`) and a `require` (CJS: `.cjs`/`.d.cts`)
condition, each with its own `types`. List `types` first within each condition.

```json
{
"exports": {
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
"./apierror": { "types": "./dist/apierror/index.d.ts", "import": "./dist/apierror/index.js" },
"./apierror/codes": { "types": "./dist/apierror/codes/index.d.ts", "import": "./dist/apierror/codes/index.js" }
".": {
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
"require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
},
"./apierror": {
"import": { "types": "./dist/apierror/index.d.ts", "default": "./dist/apierror/index.js" },
"require": { "types": "./dist/apierror/index.d.cts", "default": "./dist/apierror/index.cjs" }
}
}
}
```

The build script is `"build": "tsdown"`, driven by a per-package
`tsdown.config.ts` whose `entry` map lists one entry per export subpath. Also
set `"sideEffects": false` so consumers can tree-shake. For generated service
packages all of this is produced by the generator (`packageconfig.go`); for the
hand-written `auth`/`core`/`options` packages it is maintained by hand.

## Verification Checklist

After creating a new package, run all four checks:
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ your training data, the rule wins.
| Runtime | Node.js >= 22, Browser |
| Package manager | npm workspaces |
| Build target | ES2024, ESNext modules |
| Bundler | tsdown (Rolldown-based) |
| Linter | ESLint (strict-type-checked) |
| Formatter | Prettier |
| Test framework | Vitest |
| Module system | ESM only |
| Module system | Dual ESM + CJS (import/require) |

## Directory Layout

Expand Down
Loading
Loading