Skip to content

Commit d4ffea4

Browse files
authored
Merge pull request #41 from aridyckovsky/feat/normalized-audit-schema
feat(core,cli): normalized audit schema and core business logic
2 parents 439a70d + 7697e3b commit d4ffea4

80 files changed

Lines changed: 8001 additions & 2174 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
"@effect-migrate/core": minor
3+
"@effect-migrate/cli": minor
4+
---
5+
6+
Add normalized schema for 40-70% audit.json size reduction and move business logic to core
7+
8+
**Breaking Changes:**
9+
10+
1. **Schema version 0.1.0 → 0.2.0** (audit.json - no backwards compatibility)
11+
- Replace `byFile`/`byRule` with deduplicated `rules[]`, `files[]`, `results[]` arrays
12+
- Add index-based groupings in `groups` field for O(1) lookup
13+
- Implement deterministic ordering (sorted rules/files) for reproducible output
14+
- Add stable content-based keys for cross-checkpoint delta computation
15+
- Compact range representation using tuples instead of objects
16+
- Add separate `info` counter to FindingsSummary (previously counted as warnings)
17+
18+
2. **CLI loaders removed** - business logic moved to @effect-migrate/core
19+
- ❌ Removed `@effect-migrate/cli/loaders/config` - use `@effect-migrate/core` exports instead
20+
- ❌ Removed `@effect-migrate/cli/loaders/presets` - use `PresetLoader` service instead
21+
22+
**New @effect-migrate/core exports:**
23+
24+
Config utilities:
25+
26+
- `mergeConfig(defaults, userConfig)` - Merge preset defaults with user config
27+
- `deepMerge(target, source)` - Deep merge plain objects (arrays replaced, not concatenated)
28+
- `isPlainObject(value)` - Type guard for plain objects
29+
30+
Preset loading:
31+
32+
- `PresetLoader` - Context.Tag for preset loading service
33+
- `PresetLoaderService` - Service interface
34+
- `PresetLoaderNpmLive` - Default Layer for npm-based preset resolution
35+
- `PresetLoadError` - Tagged error for preset loading failures
36+
- `Preset` - Preset type (rules + optional defaults)
37+
- `LoadPresetsResult` - Result of loading multiple presets
38+
39+
Rule construction:
40+
41+
- `rulesFromConfig(config)` - Build rules from config (pattern + boundary)
42+
43+
Schema enhancements:
44+
45+
- Config now supports `presets?: string[]` field for preset names
46+
47+
Normalizer utilities:
48+
49+
- `normalizeResults(results, config, threads?)` - Convert to normalized schema
50+
- `expandResult(normalized)` - Convert back to flat format
51+
- `deriveResultKey(result)` - Generate stable content-based key
52+
53+
**@effect-migrate/cli changes:**
54+
55+
New workspace-aware preset resolution:
56+
57+
- `PresetLoaderWorkspaceLive` - Layer that tries workspace path first, falls back to npm
58+
- Supports monorepo development with automatic workspace preset detection
59+
- Windows-compatible file URL handling with `pathToFileURL()`
60+
61+
Refactored loaders:
62+
63+
- `loadRulesAndConfig()` now orchestrates core services instead of implementing logic
64+
- Uses `Effect.catchTag("PresetLoadError")` for precise error handling
65+
- Reduced CLI code by ~1291 lines (60% reduction in loaders)
66+
67+
**Build improvements:**
68+
69+
- Implement TypeScript Project References (src/test separation) for proper type checking
70+
- Fix NodeNext module resolution (.js extension requirements)
71+
- Consolidate test organization (all tests in `test/` directories)
72+
- Fix barrel import violations (use direct imports from @effect/platform)
73+
- Remove duplicate utils folder (merged util/ into utils/)
74+
75+
**Migration guide:**
76+
77+
If you were importing from CLI loaders:
78+
79+
```typescript
80+
// Before
81+
import { loadConfig } from "@effect-migrate/cli/loaders/config"
82+
import { loadPresets } from "@effect-migrate/cli/loaders/presets"
83+
84+
// After
85+
import { loadConfig, PresetLoader } from "@effect-migrate/core"
86+
87+
const config = yield * loadConfig(configPath)
88+
const loader = yield * PresetLoader
89+
const { rules, defaults } = yield * loader.loadPresets(config.presets ?? [])
90+
```
91+
92+
**Test coverage:**
93+
94+
- 50 new tests for core utilities (config merge, preset loading, rule builders)
95+
- 6 new tests for CLI workspace preset resolution
96+
- 40+ tests for normalized schema
97+
- Total: 308 tests passing

.changeset/update-readmes.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
"@effect-migrate/core": patch
3+
"@effect-migrate/cli": patch
4+
---
5+
6+
Update all READMEs to reflect current architecture and published usage
7+
8+
**Documentation improvements:**
9+
10+
- Root README: Accurate CLI commands, output schemas (index.json, audit.json, metrics.json, threads.json), real rule examples, proper roadmap
11+
- CLI README: Complete options documentation (--strict, --log-level, --amp-out), troubleshooting guide, local development instructions
12+
- Core README: Comprehensive exported API documentation, service architecture, Layer patterns, real rule examples from preset-basic
13+
14+
**Key updates:**
15+
16+
- Reflect dogfooding status and unstable API warnings across all packages
17+
- Document complementary relationship with @effect/language-service
18+
- Add proper roadmap with planned features (SQLite, Polars, OpenTelemetry, MCP server, workflow orchestration)
19+
- User-focused: Published npm usage as primary, local development as secondary
20+
- Real examples from actual codebase (patterns.ts, boundaries.ts)
21+
22+
Resolves #24

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
- name: Install dependencies
4545
run: pnpm install --frozen-lockfile
4646

47+
- name: Build
48+
run: pnpm build
49+
4750
- name: Build TypeScript declarations
4851
run: pnpm build:types
4952

@@ -53,8 +56,5 @@ jobs:
5356
- name: Lint
5457
run: pnpm lint
5558

56-
- name: Build
57-
run: pnpm build
58-
5959
- name: Test
6060
run: pnpm test:ci

0 commit comments

Comments
 (0)