Electricity Bench

agentic-coding@v1

Ship a working change in a fixture repo, working in it with the agent's own tools.

scoring
programmatic
repeats
1

Grade bands

GradeCapability ≥
A0.9
B0.75
C0.55
D0.35
Fbelow D

Sample task

Published in full, exactly as the models see it. All other tasks in the suite stay private.

t2v7k4 agentic

You are working in `subscriber-toolkit`, a dependency-free TypeScript library and
CLI for cleaning up messy newsletter subscriber exports (parse, normalize,
dedupe, validate, segment). The source lives in `src/` and the test suite runs
with Vitest.

Support wants to print subscriber emails in logs and shared reports without
exposing full addresses. Add a small, pure email-masking formatter.

Create a new module `src/mask.ts` that exports a function:

```ts
export function maskEmail(email: string): string
```

It returns a privacy-preserving display form of an email address:

- Split the address into a local part and a domain. Reuse the existing
  `splitEmail` helper from `src/validate.ts` so masking and validation agree on
  how an address is dissected (the domain therefore comes back lowercased).
- Mask only the local part, keeping the domain intact:
  - a local part of length 1 becomes `*`;
  - a local part of length 2 keeps its first character and masks the second,
    e.g. `jo` becomes `j*`;
  - a local part of length 3 or more keeps its first and last character and
    replaces every character in between with a `*` (one asterisk per hidden
    character), e.g. `jane.doe` becomes `j******e`.
- Recombine as `<maskedLocal>@<domain>`. For example
  `Jane@Example.COM` becomes `J**e@example.com`.
- When the input is not shaped like an email at all (`splitEmail` returns
  `null`), return the fully-masked placeholder `"***"`.

Masking is display-only: do not fold gmail dots or strip `+tags` from the local
part (that is normalization's job, not masking's).

Also export `maskEmail` from the public API barrel in `src/index.ts`, alongside
the other `validate` exports, so library consumers can import it from the
package root.

A provided test, `test/mask.test.ts`, is already in the tree and currently fails
because `src/mask.ts` does not exist yet. Make it pass, and keep every other test
in the repo green.

Use the `read_file`, `write_file`, and `run_command` tools. You can run the test
suite with `node_modules/.bin/vitest run`. When the tests pass, you are done.