Files
2026-05-27 23:29:53 +01:00

88 lines
4.2 KiB
Markdown

# Tasks — `@suaveplan/i18n-icu-parser` (ICU parser, interpolation, pluralization)
> Reconciled retroactively after Wave 2 shipped under commit `cd86db44`. Package is built, tested, and validated; this pass folds the spec delta into `openspec/specs/i18n-icu-parser/spec.md` and archives the change folder. All `**Verified by:**` paths in the spec have been confirmed to exist in `packages/i18n/i18n-icu-parser/src/`.
## 1. Spec authoring
- [x] 1.1 Cross-cutting design + AGENTS sections read
- [x] 1.2 Source-mapping table populated
- [x] 1.3 `proposal.md` authored
- [x] 1.4 `specs/i18n-icu-parser/spec.md` delta drafted with 7 requirements
- [x] 1.5 Every requirement carries a `**Verified by:**` line
- [x] 1.6 `openspec change validate i18n-icu-parser` clean
## 2. Package scaffold
- [x] 2.1 `packages/i18n/i18n-icu-parser/src/{parser,interpolation,pluralization,observability}/` structure
- [x] 2.2 `package.json` — `@suaveplan/i18n-icu-parser@0.0.0`, `type: module`, `sideEffects: false`, deps include `@suaveplan/i18n-shared`/`@suaveplan/error`/`@suaveplan/types`/`@opentelemetry/api`
- [x] 2.3 `tsconfig.lib.json` extends shared library config
- [x] 2.4 `vite.config.ts` + `vitest.config.ts`
- [x] 2.5 `README.md` with Modules table
## 3. Implementation — parser
- [x] 3.1 `src/parser/message.ts` — ICU MessageFormat AST parser (text / variable / plural / select / unclosed-brace rejection)
- [x] 3.2 `src/parser/message-render.ts` — AST → string with `FormatBridge` dispatch
- [x] 3.3 `src/parser/format-bridge.ts` — `FormatBridge` interface + `noopFormatBridge` fallback
## 4. Implementation — interpolation
- [x] 4.1 `src/interpolation/interpolation.ts` — variable substitution with `maxDepth`, escape options
- [x] 4.2 `src/interpolation/escape-html.ts` — 5-char HTML escape
- [x] 4.3 `src/interpolation/escape-regex.ts` — regex meta-char escape
## 5. Implementation — pluralization
- [x] 5.1 `src/pluralization/pluralization.ts` — CLDR plural rules across covered locales (English, Welsh, ...) with `PLURAL_RULE_NOT_FOUND` for unknown locales
## 6. Implementation — observability
- [x] 6.1 `src/observability/metrics.ts` — OTel counters/histograms
## 7. Root barrel + subpath exports
- [x] 7.1 `src/index.ts` — explicit named re-exports (no `export *`)
- [x] 7.2 `package.json` exports map covers root + parser/interpolation/pluralization subpaths
## 8. Documentation
- [x] 8.1 Sibling `.md` per implementation file
- [x] 8.2 README links every `.md`
## 9. Tests (runner-neutral imports)
- [x] 9.1 `parser/message.test.ts` — text/variable/plural/unclosed-brace
- [x] 9.2 `parser/message-render.test.ts` — bridge dispatch + fallback
- [x] 9.3 `parser/format-bridge.test.ts` — noop bridge
- [x] 9.4 `interpolation/interpolation.test.ts` — substitution, depth, escape
- [x] 9.5 `interpolation/escape-html.test.ts` + `escape-regex.test.ts`
- [x] 9.6 `pluralization/pluralization.test.ts` — English + Welsh + unknown-locale throw
- [x] 9.7 `index.test.ts` — every documented subpath resolves
- [x] 9.8 `observability/metrics.test.ts`
- [x] 9.9 Every `it(...)` carries `{ timeout: 5000 }`
- [x] 9.10 Runner-neutral imports — CLAUDE.md §11 grep clean
## 10. Pre-archive verification
- [x] 10.1 Biome clean
- [x] 10.2 `bunx turbo lint typecheck test --filter=@suaveplan/i18n-icu-parser` green at commit time
- [x] 10.3 `bunx turbo test:coverage --filter=@suaveplan/i18n-icu-parser` 100/100/100/100 at commit time
- [x] 10.4 Conformance script clean
- [x] 10.5 Build green
## 11. Pre-archive 7-row checklist
- [x] 11.1 Generics threaded — `FormatBridge` interface; AST nodes typed
- [x] 11.2 Zod schemas — N/A (parser operates on `string`; no boundary)
- [x] 11.3 Error codes — `INTERPOLATION_ERROR`, `PLURAL_RULE_NOT_FOUND`, `NESTING_DEPTH_EXCEEDED` consumed from `i18n-shared`
- [x] 11.4 Strict-mode tested
- [x] 11.5 OTel — counters + histograms
- [x] 11.6 Lifecycle dedup — N/A (pure functions)
- [x] 11.7 No retroactive tick — boxes ticked during reconciliation pass after honest audit
## 12. Archive
- [x] 12.1 Spec delta folded into `openspec/specs/i18n-icu-parser/spec.md` (canonical, status ACTIVE, 7 requirements)
- [x] 12.2 Folder moved to `openspec/archive/2026-05-09-i18n-icu-parser/`
- [x] 12.3 `MANIFEST.md` already lists the package