Skip to content

Commit b4b9829

Browse files
authored
Merge pull request #40 from aridyckovsky/feat/core-version-registry
feat(core,cli): schema version registry and revision utilities for Amp context artifacts
2 parents 229015a + 3c30a89 commit b4b9829

47 files changed

Lines changed: 17552 additions & 847 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@effect-migrate/cli": minor
3+
---
4+
5+
Add tri-state --amp-out option with Effect patterns
6+
7+
- Add `normalizeArgs.ts` for handling bare --amp-out flag (converts to sentinel value)
8+
- Add Effect-based helpers in `amp/options.ts`:
9+
- `resolveAmpOut()`: converts Option<string> to tri-state AmpOutMode
10+
- `withAmpOut()`: conditionally executes Effect when output requested
11+
- `getAmpOutPathWithDefault()`: for commands that always write output
12+
- Refactor audit, metrics, and thread commands to use helpers (no switch statements)
13+
- Support three modes:
14+
- Omitted flag: no file output
15+
- Bare flag `--amp-out`: writes to default path `.amp/effect-migrate`
16+
- Flag with value `--amp-out=path`: writes to custom path

.changeset/cli-uses-core-amp.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@effect-migrate/cli": patch
3+
---
4+
5+
Refactor CLI to use amp utilities from core package
6+
7+
- Import amp utilities from `@effect-migrate/core/amp` instead of local modules
8+
- Create `amp/options.ts` for CLI-specific amp options
9+
- Update audit, metrics, and thread commands to use core schemas
10+
- Remove duplicate amp utility code from CLI package
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@effect-migrate/core": minor
3+
---
4+
5+
Add unified schema versioning and amp utilities to core package
6+
7+
- Add `SCHEMA_VERSION` constant - single version for all artifacts (simplicity over complexity)
8+
- Add Semver schema validator with subpath export `@effect-migrate/core/schema`
9+
- Move amp utilities (context-writer, metrics-writer, thread-manager) from CLI to core
10+
- Add `schemaVersion` field to index.json and audit.json schemas
11+
- Add `revision` counter field to audit.json (increments on each write)
12+
- Export amp utilities via `@effect-migrate/core/amp` subpath
13+
- All artifacts share same schema version for clearer versioning semantics

.changeset/upgrade-effect-deps.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@effect-migrate/core": patch
3+
"@effect-migrate/cli": patch
4+
"@effect-migrate/preset-basic": patch
5+
---
6+
7+
Upgrade `effect` packages and fix dependency versions
8+
9+
- Upgrade `effect` from 3.18.4 to 3.19.2
10+
- Upgrade `@effect/platform` from 0.92.1 to 0.93.0
11+
- Upgrade `@effect/platform-node` from 0.98.4 to 0.100.0
12+
- Upgrade `@effect/cli` from 0.71.0 to 0.72.0
13+
- Upgrade `@effect/vitest` from 0.26.0 to 0.27.0
14+
- Replace "latest" with specific versions for `@types/node` (^24.10.0) and `typescript` (^5.9.3)

README.md

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -242,33 +242,43 @@ Warnings: 1
242242
### 3. Generate Amp Context
243243

244244
```bash
245+
# Write to custom directory
245246
pnpm effect-migrate audit --amp-out .amp/effect-migrate
247+
248+
# Or write to default .amp/ directory
249+
pnpm effect-migrate audit --amp-out
246250
```
247251

248-
This creates `.amp/effect-migrate/context.json`:
252+
This creates structured context files with schema versioning:
249253

254+
**`.amp/effect-migrate/index.json`** (entry point):
250255
```json
251256
{
252-
"version": 1,
257+
"schemaVersion": "0.1.0",
253258
"timestamp": "2025-01-03T10:00:00Z",
254-
"projectPath": "/Users/you/project",
255-
"migrationState": {
256-
"phase": "pattern-detection",
257-
"completedModules": ["src/models/user.ts"],
258-
"pendingModules": ["src/api/fetchUser.ts"]
259-
},
260-
"findings": {
261-
"summary": {
262-
"errors": 1,
263-
"warnings": 3,
264-
"totalFiles": 24,
265-
"migratedFiles": 16,
266-
"progress": 67
259+
"resources": {
260+
"audit": "./audit.json",
261+
"metrics": "./metrics.json",
262+
"threads": "./threads.json",
263+
"badges": "./badges.md"
264+
}
265+
}
266+
```
267+
268+
**`.amp/effect-migrate/audit.json`** (detailed findings):
269+
```json
270+
{
271+
"schemaVersion": "0.1.0",
272+
"revision": 1,
273+
"timestamp": "2025-01-03T10:00:00Z",
274+
"findings": [
275+
{
276+
"ruleId": "no-async-await",
277+
"severity": "warning",
278+
"file": "src/api/fetchUser.ts",
279+
"line": 23,
280+
"message": "Replace async/await with Effect.gen"
267281
}
268-
},
269-
"recommendations": [
270-
"Convert async/await functions to Effect.gen",
271-
"Replace node:fs imports with @effect/platform/FileSystem"
272282
]
273283
}
274284
```
@@ -359,11 +369,12 @@ I'm migrating src/api/fetchUser.ts to Effect.
359369

360370
Amp will:
361371

362-
- Load audit.json and metrics.json via index.json
372+
- Load the index.json (schema version 0.1.0) which references all context files
373+
- Read audit.json (with revision tracking) and metrics.json
363374
- Know which files are migrated vs. legacy
364375
- Suggest Effect patterns based on active rules
365-
- Track progress and next steps
366-
- Cross-reference prior migration threads
376+
- Track progress across audit revisions
377+
- Cross-reference prior migration threads from threads.json
367378

368379
### 6. Programmatic Use (Amp TypeScript SDK)
369380

@@ -373,8 +384,8 @@ import { execute } from "@sourcegraph/amp-sdk"
373384
async function proposeNextSteps(cwd: string) {
374385
const prompt = [
375386
"Load @.amp/effect-migrate/index.json",
376-
"Read @.amp/effect-migrate/metrics.json and @.amp/effect-migrate/audit.json",
377-
"Propose the 3 highest-impact modules to migrate next."
387+
"The index references audit.json (with schemaVersion and revision), metrics.json, and threads.json",
388+
"Propose the 3 highest-impact modules to migrate next based on the current revision."
378389
].join("\n")
379390

380391
for await (const msg of execute({ prompt, options: { cwd, continue: false } })) {
@@ -386,6 +397,11 @@ async function proposeNextSteps(cwd: string) {
386397
}
387398
```
388399

400+
**Schema versioning benefits:**
401+
- All context files include `schemaVersion: "0.1.0"` for compatibility tracking
402+
- `audit.json` includes a `revision` number that increments on each run
403+
- Amp can detect schema changes and handle migrations gracefully
404+
389405
See [Amp TypeScript SDK documentation](https://ampcode.com/docs/sdk) for more examples and options.
390406

391407
---

0 commit comments

Comments
 (0)