|
| 1 | +# PROJECT KNOWLEDGE BASE |
| 2 | + |
| 3 | +**Generated:** 2026-03-05T10:50:45Z |
| 4 | +**Commit:** 44b1a3e |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | +unpux is an ESM-only TypeScript library + CLI that normalizes package metadata across npm, PyPI, crates.io, RubyGems, and Packagist using PURL-first APIs. |
| 9 | +The architecture is layered: `core` abstractions, per-ecosystem `registries`, optional `cache` decorator, and CLI `commands`. |
| 10 | + |
| 11 | +## STRUCTURE |
| 12 | +```text |
| 13 | +pkio/ |
| 14 | +|- src/ # source modules and entrypoints |
| 15 | +| |- core/ # contracts, parsing, client, errors |
| 16 | +| |- registries/ # ecosystem adapters |
| 17 | +| |- cache/ # storage and lockfile caching |
| 18 | +| |- commands/ # citty command handlers |
| 19 | +| |- index.ts # public API barrel |
| 20 | +| `- cli.ts # executable entrypoint |
| 21 | +|- test/ # unit + e2e tests |
| 22 | +|- .github/workflows/ # CI and publish workflows |
| 23 | +`- build.config.ts # obuild entry matrix |
| 24 | +``` |
| 25 | + |
| 26 | +## WHERE TO LOOK |
| 27 | +| Task | Location | Notes | |
| 28 | +|------|----------|-------| |
| 29 | +| Public API changes | `src/index.ts` | Main export surface used by package root `.` | |
| 30 | +| Add ecosystem support | `src/registries/*.ts` | Implement `Registry`, then register via side-effect import | |
| 31 | +| PURL behavior | `src/core/purl.ts` | Validation, normalization, parser/builder | |
| 32 | +| HTTP/retry behavior | `src/core/client.ts` | Retry status handling and timeout defaults | |
| 33 | +| Cache semantics | `src/cache/lockfile.ts` | TTL + integrity freshness gates | |
| 34 | +| CLI command behavior | `src/commands/*.ts`, `src/cli.ts` | Dynamic subcommand loading through citty | |
| 35 | +| Test updates | `test/unit/*.test.ts`, `test/e2e/smoke.test.ts` | Unit first; e2e for live registry checks | |
| 36 | +| Build/export wiring | `build.config.ts`, `package.json` | Entry points, exports, bin wiring | |
| 37 | + |
| 38 | +## CODE MAP |
| 39 | +| Symbol | Type | Location | Refs | Role | |
| 40 | +|--------|------|----------|------|------| |
| 41 | +| `create` | function | `src/core/registry.ts` | high | Registry factory from ecosystem key | |
| 42 | +| `createCached` | function | `src/cache/index.ts` | medium | Decorates a registry with cache + lockfile | |
| 43 | +| `parsePURL` | function | `src/core/purl.ts` | high | Canonical parser for all PURL input | |
| 44 | +| `Client` | class | `src/core/client.ts` | high | Central HTTP behavior, retry, timeout | |
| 45 | +| `CachedRegistry` | class | `src/cache/cached-registry.ts` | medium | Cache wrapper implementing `Registry` | |
| 46 | +| `main` | constant command | `src/cli.ts` | medium | CLI root with subcommand routing | |
| 47 | +| `DEFAULT_TTL` | constant | `src/cache/lockfile.ts` | medium | Project-wide cache freshness policy | |
| 48 | + |
| 49 | +## CONVENTIONS |
| 50 | +- ESM-only; TypeScript imports keep `.ts` extension style in source. |
| 51 | +- `tsc` is typecheck-only (`noEmit`); build artifacts come from `obuild`. |
| 52 | +- Public API is export-barrel-driven; avoid hidden side-channel exports. |
| 53 | +- Registries are plugin-like via registration factories, not hardcoded switch logic. |
| 54 | +- Tests use Vitest globals with `test/unit` and `test/e2e` split. |
| 55 | + |
| 56 | +## ANTI-PATTERNS (THIS PROJECT) |
| 57 | +- Do not parse PURLs outside `src/core/purl.ts`; call `createFromPURL`/`parsePURL`. |
| 58 | +- Do not bypass `Client` for direct fetch logic in registries. |
| 59 | +- Do not duplicate retry/backoff constants outside `src/core/client.ts`. |
| 60 | +- Do not hardcode cache TTL in random modules; use `DEFAULT_TTL` in `src/cache/lockfile.ts`. |
| 61 | +- Do not add CommonJS output or `require` paths; package is ESM-first. |
| 62 | + |
| 63 | +## UNIQUE STYLES |
| 64 | +- Side-effect ecosystem registration is intentional (`import 'unpux/registries'`). |
| 65 | +- `cache` is an optional decorator layer, not mandatory in core flows. |
| 66 | +- Bulk fetch helpers intentionally skip failed packages instead of failing all. |
| 67 | + |
| 68 | +## COMMANDS |
| 69 | +```bash |
| 70 | +pnpm typecheck |
| 71 | +pnpm build |
| 72 | +pnpm test:run |
| 73 | +pnpm test |
| 74 | +pnpm release |
| 75 | +``` |
| 76 | + |
| 77 | +## NOTES |
| 78 | +- Release workflow triggers on tags `v*` and publishes with `pnpm publish --no-git-checks`. |
| 79 | +- Node runtime floor is `>=22.6.0`; respect modern syntax assumptions. |
| 80 | +- Unit tests are broad; e2e smoke tests can be network-sensitive. |
0 commit comments