|
| 1 | +# Agent Notes |
| 2 | + |
| 3 | +## Effect-First Patterns (Required) |
| 4 | +- Command handlers must use `Command.action(...)` with `Effect` values. |
| 5 | +- Do not use `actionAsync` anywhere. |
| 6 | +- Prefer `Effect.gen` for multi-step flows and `Effect.sync` for pure sync handlers. |
| 7 | +- Use `Effect.catchAll` at command boundaries to map runtime errors into structured CLI envelopes. |
| 8 | + |
| 9 | +## API Layer Pattern |
| 10 | +- Public module APIs use this shape: |
| 11 | + 1. Internal Promise implementation: `async function fooPromise(...)`. |
| 12 | + 2. Effect API: `export function fooEffect(...) => Effect.tryPromise(...)`. |
| 13 | + 3. Promise boundary wrapper (for compatibility): `export function foo(...) => Effect.runPromise(fooEffect(...))`. |
| 14 | +- Keep `Effect.runPromise` usage at boundaries only (CLI entrypoint and compatibility wrappers). |
| 15 | + |
| 16 | +## Imports and Dependencies |
| 17 | +- Use `import * as Effect from "effect/Effect"` directly. |
| 18 | +- Do not reintroduce `toEffect`/`effect-interop`; wrappers are explicit per function. |
| 19 | +- Prefer static imports of `*Effect` APIs over dynamic imports in commands. |
| 20 | + |
| 21 | +## Streaming / Long-Running Commands |
| 22 | +- For streamed command output, emit: |
| 23 | + 1. start event, |
| 24 | + 2. progress/step events, |
| 25 | + 3. final result event, |
| 26 | + 4. mapped stream error event on failure. |
| 27 | +- Keep stream callbacks best-effort and non-fatal. |
| 28 | + |
| 29 | +## Verification Checklist |
| 30 | +- `pnpm exec tsc --noEmit` |
| 31 | +- `pnpm run build` |
| 32 | +- `pnpm test tests/integration/cli-smoke.test.ts tests/unit/application-deploy-security.test.ts tests/unit/cli/deploy-stream.test.ts` |
| 33 | +- `rg "export async function" src` should be `0`. |
| 34 | +- `rg "toEffect|effect-interop" src` should be `0`. |
| 35 | + |
| 36 | +## Migration Pitfalls Seen |
| 37 | +- Name collisions: if a file already has a hand-written `*Effect` (example: deploy), do not route compatibility wrappers to the wrong effect signature. |
| 38 | +- Codemods can break import blocks; run typecheck immediately after broad transforms. |
| 39 | +- Keep command-level error emission consistent (`mapRuntimeError` + `nextActionsFor(...)`). |
0 commit comments