63 lines
4.1 KiB
Markdown
63 lines
4.1 KiB
Markdown
# Tasks — add-discord-client
|
|
|
|
> Every checkbox reflects work actually done in this change.
|
|
|
|
## 1. Spec authoring
|
|
|
|
- [x] 1.1 Read `../suaveplan/enterprise/discord-client.md` end-to-end
|
|
- [x] 1.2 Read upstream impl at `../suaveplan/packages/universal/discord-client/src/`
|
|
- [x] 1.3 Read OpenSpec templates + enterprise-package-migration SKILL
|
|
- [x] 1.4 Draft `proposal.md` from `openspec/templates/proposal.md`
|
|
- [x] 1.5 Fill in `## Source mapping` table — every requirement cites a line range or is in the "no source line" table with justification
|
|
- [x] 1.6 Draft `specs/discord-client/spec.md` from `openspec/templates/spec-delta.md`
|
|
- [x] 1.7 Every requirement in the spec delta carries a `**Verified by:**` line naming concrete `it(...)` titles
|
|
|
|
## 2. Implementation
|
|
|
|
- [x] 2.1 Scaffold `packages/messaging/discord-client/` (package.json @0.1.0, tsconfig, vite.config, vitest.config, polyfills)
|
|
- [x] 2.2 `src/errors/discord-client-error.ts` — `defineCodes("DISCORD", [...])` + `DiscordClientError extends SuaveplanError<DiscordClientCode>`
|
|
- [x] 2.3 `src/types/discord-client.types.ts` — `DiscordBotConfig`/`DiscordWebhookConfig`/`DiscordMessage`/`DiscordEmbed`/`DiscordResponse`/`DiscordChannel`/`DiscordDeliveryReport`/`FetchLike` + Zod schemas
|
|
- [x] 2.4 `src/utils/rate-limit.ts` — `parseRetryAfterMs(response, clock?)` parser for 3 header variants
|
|
- [x] 2.5 `src/utils/http.ts` — `executeDiscordRequest` funnel mapping 401/403/404/429/5xx/non-ok to DISCORD codes, AbortController timeout → TIMEOUT, OTel counter + histogram lazy-init with `resetDiscordHttpMetrics()`
|
|
- [x] 2.6 `src/core/bot-client/discord-bot-client.ts` — full bot REST surface
|
|
- [x] 2.7 `src/core/webhook/discord-webhook.ts` — webhook surface + DeliveryReport
|
|
- [x] 2.8 `src/index.ts` — explicit named re-exports (no `export *`)
|
|
|
|
## 3. Tests
|
|
|
|
- [x] 3.1 `src/errors/discord-client-error.test.ts` — frozen registry, code prefix, code union, error class
|
|
- [x] 3.2 `src/utils/rate-limit.test.ts` — all 3 header variants, edge cases, default clock
|
|
- [x] 3.3 `src/utils/http.test.ts` — every status code mapping, abort/timeout, OTel via recording `MeterProvider`
|
|
- [x] 3.4 `src/core/bot-client/discord-bot-client.test.ts` — constructor validation, every public method, cache eviction, URL encoding
|
|
- [x] 3.5 `src/core/webhook/discord-webhook.test.ts` — config validation, send/sendText/sendEmbed, threading, defaults
|
|
- [x] 3.6 `tests/dep-graph.test.ts` — pins runtime deps + `sideEffects: false`
|
|
- [x] 3.7 Every `it(...)` carries `{ timeout: 5000 }` or `{ timeout: 30000 }`
|
|
|
|
## 4. Documentation
|
|
|
|
- [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, full API reference) — 6 modules
|
|
- [x] 4.2 `README.md` at package root links every co-located `.md` under `## Modules`
|
|
|
|
## 5. Pre-archive verification (5-gate triple)
|
|
|
|
- [x] 5.1 `bun run check` — exit 0, "No fixes applied"
|
|
- [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/discord-client` — green (62 tests pass)
|
|
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/discord-client` — 100/100/100/100 (istanbul)
|
|
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/discord-client` — PASS (0 error, 0 warn, 0 info)
|
|
- [x] 5.5 `bunx turbo build --filter=@suaveplan/discord-client` — green
|
|
|
|
## 6. Pre-archive 7-row checklist
|
|
|
|
- [x] 6.1 Generics threaded — `executeDiscordRequest<T>` and `DiscordClientCode` literal union
|
|
- [x] 6.2 Zod schemas wired at every boundary — `DiscordBotConfigSchema`, `DiscordWebhookConfigSchema`, `DiscordMessageSchema`
|
|
- [x] 6.3 Every `DISCORD_CODES` code thrown by ≥1 production path
|
|
- [x] 6.4 Strict-mode behaviours tested (Zod boundary on/off — invalid config + valid config both pinned)
|
|
- [x] 6.5 OTel instruments emitted from production paths, asserted with a recording `MeterProvider`
|
|
- [x] 6.6 Lifecycle dedup tested where claimed — in-memory message cache set/get/evict
|
|
- [x] 6.7 No retroactive tick
|
|
|
|
## 7. Archive
|
|
|
|
- [x] 7.1 Fold spec delta into `openspec/specs/discord-client/spec.md`
|
|
- [x] 7.2 Move `openspec/changes/add-discord-client/` → `openspec/archive/2026-05-18-add-discord-client/`
|