my-dev-kit-orchestrator 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,14 +38,19 @@ exports.writeStagePrompts = writeStagePrompts;
38
38
  const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
40
  function header(ctx) {
41
- return [
41
+ const lines = [
42
42
  `Stage: ${ctx.stage}`,
43
43
  `Workflow mode: ${ctx.mode}`,
44
44
  `Run ID: ${ctx.runId}`,
45
45
  `Project root: ${ctx.projectRoot}`,
46
46
  `Run folder: ${ctx.runFolder}`,
47
- '',
48
- ].join('\n');
47
+ ];
48
+ if (ctx.sourceRepoRoot)
49
+ lines.push(`Source repository: ${ctx.sourceRepoRoot}`);
50
+ if (ctx.targetRepoRoot)
51
+ lines.push(`Target repository: ${ctx.targetRepoRoot}`);
52
+ lines.push('');
53
+ return lines.join('\n');
49
54
  }
50
55
  // ─── Core shared stages ───────────────────────────────────────────────────────
51
56
  function requestBriefPrompt(ctx) {
@@ -1268,6 +1273,1072 @@ Return format:
1268
1273
  Status: complete | incomplete | blocked
1269
1274
  `;
1270
1275
  }
1276
+ // ─── Extraction-mode-specific stages ─────────────────────────────────────────
1277
+ function extractionRequestBriefPrompt(ctx) {
1278
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
1279
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1280
+ return `${header(ctx)}
1281
+ Inputs:
1282
+ - original extraction request: ${ctx.runFolder}/00-request.txt
1283
+
1284
+ Task:
1285
+ Produce ${ctx.runFolder}/artifacts/request-brief.txt (artifact: ExtractionRequestBrief).
1286
+
1287
+ Extraction guardrails:
1288
+ - The source repository is evidence, not destiny. Do not port code just because it exists.
1289
+ - Do not start by copying files from source to target.
1290
+ - Do not assume the source architecture is the desired target architecture.
1291
+ - Do not implement anything in the target repository in this stage.
1292
+
1293
+ The ExtractionRequestBrief must define:
1294
+ - original request (verbatim from 00-request.txt)
1295
+ - source repository: ${sourceDir}
1296
+ - target repository: ${targetDir}
1297
+ - workflow or feature to extract
1298
+ - desired target scope (what should exist in the target when complete)
1299
+ - features explicitly excluded from the extraction
1300
+ - critical behaviors to preserve from the source workflow
1301
+ - expected deliverables
1302
+ - constraints
1303
+ - success criteria
1304
+ - ambiguity or missing information
1305
+ - expected next stage: source-architecture-context
1306
+
1307
+ Required output artifact: ExtractionRequestBrief
1308
+ Output file: ${ctx.runFolder}/artifacts/request-brief.txt
1309
+
1310
+ Stop conditions:
1311
+ - do not inspect source code deeply in this stage
1312
+ - do not write pseudocode
1313
+ - do not write tests
1314
+ - do not start implementing in this stage
1315
+ - do not port files
1316
+
1317
+ Return format:
1318
+ Produce the artifact as a plain-text file using this template:
1319
+ Artifact: ExtractionRequestBrief
1320
+ Workflow mode: extraction
1321
+ Original request: ...
1322
+ Source repository: ${sourceDir}
1323
+ Target repository: ${targetDir}
1324
+ Workflow or feature to extract: ...
1325
+ Desired target scope: ...
1326
+ Excluded features: ...
1327
+ Critical behaviors to preserve: ...
1328
+ Expected deliverables: ...
1329
+ Constraints: ...
1330
+ Success criteria: ...
1331
+ Ambiguity or missing information: ...
1332
+ Expected next stage: source-architecture-context
1333
+ Status: complete | incomplete | blocked
1334
+ `;
1335
+ }
1336
+ function sourceArchitectureContextPrompt(ctx) {
1337
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
1338
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1339
+ return `${header(ctx)}
1340
+ Inputs:
1341
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1342
+ - source repository: ${sourceDir}
1343
+
1344
+ Task:
1345
+ Use my-dev-kit to inspect the source repository and produce a supporting retrieval report and source architecture context artifact.
1346
+
1347
+ Produce two output files:
1348
+ 1. Supporting retrieval report: ${ctx.runFolder}/reports/source-architecture-context-retrieval-report.txt
1349
+ 2. Required workflow artifact: ${ctx.runFolder}/artifacts/source-architecture-context-packet.txt (artifact: SourceArchitectureContextPacket)
1350
+
1351
+ Extraction guardrails:
1352
+ - The source repository is evidence, not destiny. Do not port code just because it exists.
1353
+ - Do not start by reading whole source files.
1354
+ - Do not use target repository indexing to infer source behavior.
1355
+ - Do not modify the source repository.
1356
+ - Do not decide porting strategy in this stage.
1357
+ - Do not modify the target repository in this stage.
1358
+ - Source and target index directories must stay separate.
1359
+
1360
+ Source repository inspection sequence (when my-dev-kit is available):
1361
+
1362
+ Step 1 — Index the source repository into its own index directory:
1363
+ npx @dailephd/my-dev-kit index --root ${sourceDir} --src src --out ${sourceDir}/.my-dev-kit --call-graph --json
1364
+
1365
+ Do not use ${targetDir}/.my-dev-kit to infer source behavior.
1366
+
1367
+ Step 2 — Search for task-specific candidate nodes in the source repository:
1368
+ npx @dailephd/my-dev-kit search --index ${sourceDir}/.my-dev-kit --query "<task-specific term>" --limit 20 --json
1369
+ Run multiple queries for different aspects of the extraction request.
1370
+
1371
+ Step 3 — Look up selected nodes and their relationships:
1372
+ npx @dailephd/my-dev-kit lookup --index ${sourceDir}/.my-dev-kit --node "<selected-node-id>" --depth 1 --json
1373
+
1374
+ Step 4 — Slice around the strongest relevant node:
1375
+ npx @dailephd/my-dev-kit slice --index ${sourceDir}/.my-dev-kit --node "<strongest-node-id>" --depth 2 --direction both --json
1376
+
1377
+ Step 5 — Retrieve exact symbol source (preferred):
1378
+ npx @dailephd/my-dev-kit source --index ${sourceDir}/.my-dev-kit --node "<symbol-node-id>" --max-lines 160 --format numbered
1379
+
1380
+ Step 6 — Use line-range retrieval only as fallback when symbol retrieval is insufficient:
1381
+ npx @dailephd/my-dev-kit source --index ${sourceDir}/.my-dev-kit --file "<file-path>" --start <start-line> --end <end-line> --max-lines 220 --format numbered
1382
+
1383
+ Step 7 — Avoid reading whole source files unless bounded retrieval is insufficient. If a whole file must be read, state why.
1384
+
1385
+ If my-dev-kit is unavailable, use focused manual inspection of relevant files and symbols in the source repository. Document what was inspected and why.
1386
+
1387
+ The SourceArchitectureContextPacket must identify relevant source architecture context without deciding what to port.
1388
+
1389
+ Required output artifact: SourceArchitectureContextPacket
1390
+ Output file: ${ctx.runFolder}/artifacts/source-architecture-context-packet.txt
1391
+
1392
+ Supporting report output file: ${ctx.runFolder}/reports/source-architecture-context-retrieval-report.txt
1393
+
1394
+ Stop conditions:
1395
+ - do not decide porting strategy in this stage
1396
+ - do not write pseudocode
1397
+ - do not start implementing in this stage
1398
+ - do not write test files
1399
+ - do not modify source or target repositories
1400
+
1401
+ Return format:
1402
+
1403
+ Write the supporting retrieval report using this template:
1404
+
1405
+ Source retrieval evidence report
1406
+
1407
+ Source repository: ${sourceDir}
1408
+ Index directory: ${sourceDir}/.my-dev-kit
1409
+
1410
+ Refreshed or reused:
1411
+ manifest.json status:
1412
+ Semantic artifacts available:
1413
+
1414
+ Search queries run:
1415
+ - Query:
1416
+ Reason:
1417
+
1418
+ Candidate nodes selected:
1419
+ - Node ID:
1420
+ Reason:
1421
+
1422
+ Lookup commands run:
1423
+ - Node ID:
1424
+ Useful relationships found:
1425
+
1426
+ Graph slices created:
1427
+ - Focus node:
1428
+ - Depth:
1429
+ - Direction:
1430
+ - Reason:
1431
+
1432
+ Source symbols retrieved:
1433
+ - Symbol node ID:
1434
+ - File path:
1435
+ - Reason:
1436
+
1437
+ Full files read beyond retrieved source:
1438
+ - File path or none:
1439
+ - Reason:
1440
+
1441
+ Context gaps or uncertainty:
1442
+ - Gap:
1443
+ Impact:
1444
+
1445
+ Then write SourceArchitectureContextPacket using this template:
1446
+
1447
+ Artifact: SourceArchitectureContextPacket
1448
+ Workflow mode: extraction
1449
+ Source repository: ${sourceDir}
1450
+
1451
+ Relevant source files: ...
1452
+ Relevant source symbols: ...
1453
+ Relevant source components / modules / routes / services: ...
1454
+ Source data contracts: ...
1455
+ Source persistence dependencies: ...
1456
+ Source external service dependencies: ...
1457
+ Source state owners: ...
1458
+ Source tests found: ...
1459
+ Source patterns: ...
1460
+ Context gaps or uncertainty: ...
1461
+ Expected next stage: source-workflow-map
1462
+ Status: complete | incomplete | blocked
1463
+ `;
1464
+ }
1465
+ function sourceWorkflowMapPrompt(ctx) {
1466
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
1467
+ return `${header(ctx)}
1468
+ Inputs:
1469
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1470
+ - ${ctx.runFolder}/artifacts/source-architecture-context-packet.txt
1471
+ - source repository (read-only evidence): ${sourceDir}
1472
+
1473
+ Task:
1474
+ Produce ${ctx.runFolder}/artifacts/source-workflow-map.txt (artifact: SourceWorkflowMap).
1475
+
1476
+ This stage describes what exists in the source repository. It does not decide what to port.
1477
+
1478
+ Extraction guardrails:
1479
+ - The source repository is evidence, not destiny. Do not port code just because it exists.
1480
+ - Do not decide porting strategy in this stage.
1481
+ - Do not start by copying files.
1482
+ - Do not modify the source repository.
1483
+ - Do not modify the target repository in this stage.
1484
+ - do not start implementing in this stage.
1485
+
1486
+ Required sections for SourceWorkflowMap:
1487
+ - Source repo path
1488
+ - Workflow entry point
1489
+ - User-facing steps
1490
+ - Frontend components
1491
+ - Frontend state owners
1492
+ - API routes
1493
+ - Backend services
1494
+ - Data contracts
1495
+ - Persistence dependencies
1496
+ - External service dependencies
1497
+ - Tests found
1498
+ - Known behavior risks
1499
+ - Ambiguous or missing context
1500
+
1501
+ Required output artifact: SourceWorkflowMap
1502
+ Output file: ${ctx.runFolder}/artifacts/source-workflow-map.txt
1503
+
1504
+ Stop conditions:
1505
+ - do not include porting decisions
1506
+ - do not include implementation plans
1507
+ - do not include target architecture details
1508
+ - do not write pseudocode
1509
+ - do not implement code
1510
+ - do not write test files
1511
+ - completion criteria: all required sections are present; the map describes what exists in the source, not what should be built in the target
1512
+
1513
+ Return format:
1514
+ Produce the artifact as a plain-text file using this template:
1515
+
1516
+ Artifact: SourceWorkflowMap
1517
+ Workflow mode: extraction
1518
+ Source repo path: ${sourceDir}
1519
+ Workflow entry point: <entry point file or component>
1520
+
1521
+ User-facing steps:
1522
+ 1. <step>
1523
+ 2. <step>
1524
+
1525
+ Frontend components: <list>
1526
+ Frontend state owners: <list>
1527
+
1528
+ API routes: <list>
1529
+ Backend services: <list>
1530
+ Data contracts: <list>
1531
+
1532
+ Persistence dependencies: <list>
1533
+ External service dependencies: <list>
1534
+
1535
+ Tests found: <list>
1536
+
1537
+ Known behavior risks:
1538
+ - <risk>
1539
+
1540
+ Ambiguous or missing context:
1541
+ - <gap>
1542
+
1543
+ Status: complete | incomplete | blocked
1544
+ `;
1545
+ }
1546
+ function portingMapPrompt(ctx) {
1547
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
1548
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1549
+ return `${header(ctx)}
1550
+ Inputs:
1551
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1552
+ - ${ctx.runFolder}/artifacts/source-architecture-context-packet.txt
1553
+ - ${ctx.runFolder}/artifacts/source-workflow-map.txt
1554
+
1555
+ Task:
1556
+ Produce TWO output files:
1557
+ 1. ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt (artifact: SourceToTargetPortingMap)
1558
+ 2. ${ctx.runFolder}/artifacts/do-not-port-list.txt (artifact: DoNotPortList)
1559
+
1560
+ Classify each source subsystem as: port as-is, port with refactor, rewrite cleanly, discard, or postpone.
1561
+ Explicitly list every source system that must not be ported.
1562
+
1563
+ Extraction guardrails:
1564
+ - The source repository is evidence, not destiny. Do not port code just because it exists.
1565
+ - Do not create a second copy of the old architecture inside the target project.
1566
+ - Do not port authentication, persistence, workspaces, database schema, background jobs, or downstream workflows unless explicitly in scope.
1567
+ - Do not preserve old UI labels if they conflict with the new workflow.
1568
+ - do not start implementing in this stage.
1569
+ - Do not modify source or target repositories.
1570
+
1571
+ SourceToTargetPortingMap required structure for each item:
1572
+ - Source behavior
1573
+ - Source files or symbols
1574
+ - Target behavior
1575
+ - Target module or component (planned target location in ${targetDir})
1576
+ - Decision: port as-is | port with refactor | rewrite cleanly | discard | postpone
1577
+ - Reason
1578
+ - Required tests
1579
+ - Risks
1580
+
1581
+ DoNotPortList required sections:
1582
+ - Systems excluded from the target project
1583
+ - UI labels excluded from the target project
1584
+ - Backend routes excluded from the target project
1585
+ - Persistence layers excluded from the target project
1586
+ - Downstream workflows excluded from the target project
1587
+ - Reason each exclusion exists
1588
+ - Consequences if accidentally ported
1589
+
1590
+ Completion criteria:
1591
+ - Every significant source subsystem has a documented decision in SourceToTargetPortingMap
1592
+ - Every discarded subsystem also appears in DoNotPortList
1593
+ - Both artifact files must be present before the next stage can proceed
1594
+
1595
+ Required output artifact: SourceToTargetPortingMap
1596
+ Output file: ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
1597
+
1598
+ Required output artifact: DoNotPortList
1599
+ Output file: ${ctx.runFolder}/artifacts/do-not-port-list.txt
1600
+
1601
+ Stop conditions:
1602
+ - do not include implementation code
1603
+ - do not start implementing
1604
+ - do not write test files
1605
+ - do not modify source or target repositories
1606
+
1607
+ Return format:
1608
+ Produce both artifacts as plain-text files.
1609
+
1610
+ SourceToTargetPortingMap template:
1611
+
1612
+ Artifact: SourceToTargetPortingMap
1613
+ Workflow mode: extraction
1614
+ Source repository: ${sourceDir}
1615
+ Target repository: ${targetDir}
1616
+
1617
+ --- Item ---
1618
+ Source behavior: <description>
1619
+ Source files or symbols: <list>
1620
+ Target behavior: <description>
1621
+ Target module or component: <planned target location>
1622
+ Decision: <port as-is | port with refactor | rewrite cleanly | discard | postpone>
1623
+ Reason: <explanation>
1624
+ Required tests: <list>
1625
+ Risks: <list>
1626
+
1627
+ --- Item ---
1628
+ ...
1629
+
1630
+ Status: complete | incomplete | blocked
1631
+
1632
+ DoNotPortList template:
1633
+
1634
+ Artifact: DoNotPortList
1635
+ Workflow mode: extraction
1636
+ Source repository: ${sourceDir}
1637
+ Target repository: ${targetDir}
1638
+
1639
+ Systems excluded from the target project:
1640
+ - <system name>: <reason>
1641
+
1642
+ UI labels excluded:
1643
+ - <label>: <reason for exclusion>
1644
+
1645
+ Backend routes excluded:
1646
+ - <route>: <reason>
1647
+
1648
+ Persistence layers excluded:
1649
+ - <persistence layer>: <reason>
1650
+
1651
+ Downstream workflows excluded:
1652
+ - <workflow>: <reason>
1653
+
1654
+ Consequences if accidentally ported:
1655
+ - <consequence>
1656
+
1657
+ Status: complete | incomplete | blocked
1658
+ `;
1659
+ }
1660
+ function goldenBehaviorContractPrompt(ctx) {
1661
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1662
+ return `${header(ctx)}
1663
+ Inputs:
1664
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1665
+ - ${ctx.runFolder}/artifacts/source-workflow-map.txt
1666
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
1667
+ - ${ctx.runFolder}/artifacts/do-not-port-list.txt
1668
+
1669
+ Task:
1670
+ Produce ${ctx.runFolder}/artifacts/golden-behavior-contract.txt (artifact: GoldenBehaviorContract).
1671
+
1672
+ Define the exact behavior that the target implementation must satisfy.
1673
+ This is the primary source of truth for the target implementation and the judge stage.
1674
+ No production implementation should begin before this artifact exists.
1675
+
1676
+ Extraction guardrails:
1677
+ - Do not include source implementation details as requirements.
1678
+ - Do not include source file paths or source architecture references as requirements.
1679
+ - Do not reference source architecture as the target design.
1680
+ - do not start implementing in this stage.
1681
+ - Do not modify source or target repositories in this stage.
1682
+ - The source repository is evidence. This artifact defines what must be true in the target, not what exists in the source.
1683
+
1684
+ Required sections:
1685
+ - User-visible behavior
1686
+ - API behavior
1687
+ - State behavior
1688
+ - Sorting and ranking behavior
1689
+ - Pagination behavior
1690
+ - Selection behavior
1691
+ - Error and empty-state behavior
1692
+ - Edge cases
1693
+ - Non-negotiable regression tests
1694
+ - Acceptance criteria
1695
+
1696
+ For fragile or complex workflows, define specific testable statements. Examples:
1697
+ - Search results must be ordered by relevance descending.
1698
+ - Page-size options must be 10, 30, 50, and 100.
1699
+ - Pagination must use Previous, numbered pages, ellipsis, last page, and Next.
1700
+ - Selection must be stored by stable item ID, not page index.
1701
+ - Select all current page must select only visible page items.
1702
+ - Deselect all current page must deselect only visible page items.
1703
+ - Automatic mode must use top N valid ranked results, not the first N visible rows.
1704
+ - Manual mode must use only user-selected items.
1705
+ - Changing page size must preserve valid selections.
1706
+ - Out-of-range pages must be clamped.
1707
+
1708
+ Completion criteria:
1709
+ - Every user-visible behavior item is described precisely enough that a developer could implement it without reading the source repository.
1710
+ - Every non-negotiable regression test is listed.
1711
+
1712
+ Required output artifact: GoldenBehaviorContract
1713
+ Output file: ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
1714
+
1715
+ Stop conditions:
1716
+ - do not write pseudocode
1717
+ - do not write test files
1718
+ - do not implement code
1719
+ - do not reference source architecture as the target design
1720
+
1721
+ Return format:
1722
+ Produce the artifact as a plain-text file using this template:
1723
+
1724
+ Artifact: GoldenBehaviorContract
1725
+ Workflow mode: extraction
1726
+ Target repository: ${targetDir}
1727
+
1728
+ User-visible behavior:
1729
+ 1. <behavior>
1730
+ 2. <behavior>
1731
+
1732
+ API behavior:
1733
+ - <endpoint>: <contract>
1734
+
1735
+ State behavior:
1736
+ - <state item>: <contract>
1737
+
1738
+ Sorting and ranking behavior:
1739
+ - <rule>
1740
+
1741
+ Pagination behavior:
1742
+ - <rule>
1743
+
1744
+ Selection behavior:
1745
+ - <rule>
1746
+
1747
+ Error and empty-state behavior:
1748
+ - <case>: <expected result>
1749
+
1750
+ Edge cases:
1751
+ - <case>: <expected result>
1752
+
1753
+ Non-negotiable regression tests:
1754
+ 1. <test description>
1755
+ 2. <test description>
1756
+
1757
+ Acceptance criteria:
1758
+ - <criterion>
1759
+
1760
+ Status: complete | incomplete | blocked
1761
+ `;
1762
+ }
1763
+ function targetArchitecturePrompt(ctx) {
1764
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
1765
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1766
+ return `${header(ctx)}
1767
+ Inputs:
1768
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1769
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
1770
+ - ${ctx.runFolder}/artifacts/do-not-port-list.txt
1771
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
1772
+
1773
+ Task:
1774
+ Produce ${ctx.runFolder}/artifacts/target-architecture-proposal.txt (artifact: TargetArchitectureProposal).
1775
+
1776
+ Describe the clean target architecture before implementation begins.
1777
+
1778
+ Extraction guardrails:
1779
+ - Do not carry source implementation details forward without an explicit porting decision.
1780
+ - Do not include any architecture items from the DoNotPortList.
1781
+ - do not start implementing in this stage.
1782
+ - The proposal must be sufficient for implementation to begin without consulting the source repository again.
1783
+ - Every item must map back to the SourceToTargetPortingMap or be a new target-side concern.
1784
+
1785
+ If the target repository already exists, use my-dev-kit to inspect it separately from the source repository:
1786
+ npx @dailephd/my-dev-kit index --root ${targetDir} --src src --out ${targetDir}/.my-dev-kit --call-graph --json
1787
+ npx @dailephd/my-dev-kit search --index ${targetDir}/.my-dev-kit --query "<task term>" --limit 20 --json
1788
+
1789
+ Do not mix source (${sourceDir}/.my-dev-kit) and target (${targetDir}/.my-dev-kit) retrieval results.
1790
+
1791
+ If the target repository does not exist yet, define the planned structure and contracts before any scaffolding begins.
1792
+
1793
+ Required sections:
1794
+ - Target repo path
1795
+ - Target project purpose
1796
+ - Target workflow
1797
+ - Frontend components
1798
+ - Backend services
1799
+ - API routes
1800
+ - Shared contracts
1801
+ - State ownership
1802
+ - Persistence policy
1803
+ - External dependencies
1804
+ - Testing strategy overview
1805
+ - Source components reused
1806
+ - Source components rewritten
1807
+ - Source components discarded
1808
+ - Architecture guardrails
1809
+
1810
+ Required output artifact: TargetArchitectureProposal
1811
+ Output file: ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
1812
+
1813
+ Stop conditions:
1814
+ - do not write production code
1815
+ - do not write test files
1816
+ - do not include items from DoNotPortList
1817
+ - do not reference source implementation without a porting decision
1818
+
1819
+ Return format:
1820
+ Produce the artifact as a plain-text file using this template:
1821
+
1822
+ Artifact: TargetArchitectureProposal
1823
+ Workflow mode: extraction
1824
+ Target repo path: ${targetDir}
1825
+ Target project purpose: <description>
1826
+
1827
+ Target workflow:
1828
+ 1. <step>
1829
+ 2. <step>
1830
+
1831
+ Frontend components: <list>
1832
+ Backend services: <list>
1833
+ API routes: <list>
1834
+ Shared contracts: <list>
1835
+
1836
+ State ownership:
1837
+ - <state>: owned by <component>
1838
+
1839
+ Persistence policy: <description>
1840
+ External dependencies: <list>
1841
+
1842
+ Testing strategy overview: <description>
1843
+
1844
+ Source components reused: <list>
1845
+ Source components rewritten: <list>
1846
+ Source components discarded: <list>
1847
+
1848
+ Architecture guardrails:
1849
+ - <guardrail>
1850
+
1851
+ Status: complete | incomplete | blocked
1852
+ `;
1853
+ }
1854
+ function extractionBehaviorModelPrompt(ctx) {
1855
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1856
+ return `${header(ctx)}
1857
+ Inputs:
1858
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1859
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
1860
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
1861
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
1862
+
1863
+ Task:
1864
+ Produce ${ctx.runFolder}/artifacts/behavior-model.txt (artifact: BehaviorModel).
1865
+
1866
+ Use the GoldenBehaviorContract as the primary source of truth for the target behavior.
1867
+ Map behavior to the target system in ${targetDir}, not to the source architecture.
1868
+
1869
+ Extraction guardrails:
1870
+ - Do not use source implementation details as the behavior definition.
1871
+ - Do not port behavior not listed in the SourceToTargetPortingMap or GoldenBehaviorContract.
1872
+ - do not start implementing in this stage.
1873
+ - Do not write test files.
1874
+
1875
+ The BehaviorModel must define:
1876
+ - behavior summary (target system only)
1877
+ - externally visible behavior
1878
+ - internal supporting behavior
1879
+ - state variables
1880
+ - inputs
1881
+ - events
1882
+ - derived values
1883
+ - invariants
1884
+ - valid states
1885
+ - invalid states
1886
+ - boundaries and partitions
1887
+ - empty states
1888
+ - error states
1889
+ - loading or pending states when relevant
1890
+ - external contracts
1891
+ - state transitions
1892
+ - behavior from the GoldenBehaviorContract to preserve
1893
+ - behavior intentionally changed from source
1894
+ - unresolved design questions
1895
+
1896
+ Required output artifact: BehaviorModel
1897
+ Output file: ${ctx.runFolder}/artifacts/behavior-model.txt
1898
+
1899
+ Stop conditions:
1900
+ - do not write production code
1901
+ - do not write test files
1902
+ - do not produce source architecture in behavior descriptions
1903
+
1904
+ Return format:
1905
+ Produce the artifact as a plain-text file following the BehaviorModel template.
1906
+ Artifact: BehaviorModel
1907
+ Workflow mode: extraction
1908
+ Target repository: ${targetDir}
1909
+ Inputs used: ...
1910
+ Behavior summary: ...
1911
+ [all required sections]
1912
+ Status: complete | incomplete | blocked
1913
+ `;
1914
+ }
1915
+ function extractionPseudocodePacketPrompt(ctx) {
1916
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1917
+ return `${header(ctx)}
1918
+ Inputs:
1919
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1920
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
1921
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
1922
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
1923
+
1924
+ Task:
1925
+ Produce ${ctx.runFolder}/artifacts/pseudocode-packet.txt (artifact: PseudocodePacket).
1926
+
1927
+ Convert the BehaviorModel into implementation-neutral pseudocode for the target system.
1928
+ Map to the target architecture in ${targetDir}, not to the source architecture.
1929
+ This is the shared design contract for both implementation and testing.
1930
+
1931
+ Extraction guardrails:
1932
+ - Do not copy source implementation code into this artifact.
1933
+ - Do not reference source module paths as the target module paths.
1934
+ - Do not port patterns from the DoNotPortList.
1935
+ - do not start implementing in this stage.
1936
+
1937
+ The PseudocodePacket must define:
1938
+ - behavior references (from GoldenBehaviorContract)
1939
+ - data flow
1940
+ - state flow
1941
+ - state transitions
1942
+ - derived-value rules
1943
+ - validation rules
1944
+ - empty-state handling
1945
+ - error-state handling
1946
+ - external contract handling
1947
+ - target component, module, service, route, command, or helper contracts
1948
+ - acceptance criteria
1949
+ - likely files or modules to create or modify in the target repository
1950
+ - implementation constraints
1951
+ - assumptions preserved
1952
+ - unresolved implementation questions
1953
+
1954
+ Required output artifact: PseudocodePacket
1955
+ Output file: ${ctx.runFolder}/artifacts/pseudocode-packet.txt
1956
+
1957
+ Stop conditions:
1958
+ - do not write production code
1959
+ - do not write test files
1960
+ - do not modify source or target repositories
1961
+
1962
+ Return format:
1963
+ Produce the artifact as a plain-text file following the PseudocodePacket template.
1964
+ Artifact: PseudocodePacket
1965
+ Workflow mode: extraction
1966
+ Target repository: ${targetDir}
1967
+ Inputs used: ...
1968
+ [all required sections]
1969
+ Status: complete | incomplete | blocked
1970
+ `;
1971
+ }
1972
+ function extractionTestStrategyPrompt(ctx) {
1973
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
1974
+ return `${header(ctx)}
1975
+ Inputs:
1976
+ - ${ctx.runFolder}/artifacts/request-brief.txt
1977
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
1978
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
1979
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
1980
+ - ${ctx.runFolder}/artifacts/pseudocode-packet.txt
1981
+
1982
+ Task:
1983
+ Produce ${ctx.runFolder}/artifacts/test-strategy-packet.txt (artifact: TestStrategyPacket).
1984
+
1985
+ Derive test responsibilities from the GoldenBehaviorContract, BehaviorModel, and PseudocodePacket.
1986
+ All tests must target the target repository in ${targetDir}.
1987
+ Do not write test files in this stage.
1988
+
1989
+ Extraction guardrails:
1990
+ - Do not test source repository behavior.
1991
+ - Do not write test files in this stage.
1992
+ - Do not start implementing code.
1993
+
1994
+ The TestStrategyPacket must include:
1995
+ - contract tests (from GoldenBehaviorContract)
1996
+ - backend unit tests
1997
+ - frontend component tests
1998
+ - state behavior tests
1999
+ - integration tests
2000
+ - E2E tests for the full extracted workflow
2001
+ - regression tests for every non-negotiable item in the GoldenBehaviorContract
2002
+ - behavior under test
2003
+ - participating layers
2004
+ - state variables
2005
+ - events
2006
+ - derived values
2007
+ - invariants
2008
+ - boundaries and partitions
2009
+ - external contracts
2010
+ - relevant failure modes
2011
+ - test matrix
2012
+ - test level assignment (unit / component / integration / end-to-end)
2013
+ - required verification commands
2014
+ - coverage gaps
2015
+
2016
+ Each test responsibility must trace to at least one of:
2017
+ - golden behavior contract item
2018
+ - behavior
2019
+ - invariant
2020
+ - state transition
2021
+ - derived value
2022
+ - boundary
2023
+ - external contract
2024
+ - failure mode
2025
+
2026
+ Required output artifact: TestStrategyPacket
2027
+ Output file: ${ctx.runFolder}/artifacts/test-strategy-packet.txt
2028
+
2029
+ Stop conditions:
2030
+ - do not write test files in this stage
2031
+ - do not write production code
2032
+ - do not invent behavior not in GoldenBehaviorContract or BehaviorModel
2033
+
2034
+ Return format:
2035
+ Produce the artifact as a plain-text file following the TestStrategyPacket template.
2036
+ Artifact: TestStrategyPacket
2037
+ Workflow mode: extraction
2038
+ Target repository: ${targetDir}
2039
+ Inputs used: ...
2040
+ [all required sections]
2041
+ Status: complete | incomplete | blocked
2042
+ `;
2043
+ }
2044
+ function extractionImplementationPrompt(ctx) {
2045
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
2046
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
2047
+ return `${header(ctx)}
2048
+ Inputs:
2049
+ - ${ctx.runFolder}/artifacts/request-brief.txt
2050
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2051
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
2052
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
2053
+ - ${ctx.runFolder}/artifacts/do-not-port-list.txt
2054
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
2055
+ - ${ctx.runFolder}/artifacts/pseudocode-packet.txt
2056
+
2057
+ Task:
2058
+ Implement the extracted workflow in the target repository and produce ${ctx.runFolder}/artifacts/implementation-report.txt (artifact: ImplementationReport).
2059
+
2060
+ Implement in ${targetDir} only. The source repository (${sourceDir}) is read-only evidence.
2061
+ Use the GoldenBehaviorContract as the implementation source of truth.
2062
+ Follow the TargetArchitectureProposal and PseudocodePacket.
2063
+
2064
+ Extraction guardrails:
2065
+ - Implement only in the target repository (${targetDir}) unless source repository changes are explicitly permitted by the request brief.
2066
+ - Do not copy files directly from source to target.
2067
+ - Do not port systems listed in the DoNotPortList.
2068
+ - Do not import source repository modules into the target.
2069
+ - Do not assume source architecture is the required target architecture.
2070
+ - The GoldenBehaviorContract defines what must be true — not the source code.
2071
+
2072
+ The ImplementationReport must include:
2073
+ - files read (source and target)
2074
+ - files created or changed (target only)
2075
+ - behavior implemented (must map to GoldenBehaviorContract items)
2076
+ - pseudocode sections implemented
2077
+ - porting decisions applied (from SourceToTargetPortingMap)
2078
+ - systems excluded (from DoNotPortList)
2079
+ - deviations from the PseudocodePacket and reason for each
2080
+ - source repository changes made, if any (normally: none)
2081
+ - blockers encountered
2082
+ - unresolved risks
2083
+ - tests that should be run
2084
+ - notes for the test implementation stage
2085
+
2086
+ Required output artifact: ImplementationReport
2087
+ Output file: ${ctx.runFolder}/artifacts/implementation-report.txt
2088
+
2089
+ Stop conditions:
2090
+ - do not port DoNotPortList systems
2091
+ - do not modify the source repository unless explicitly allowed by the request brief
2092
+ - do not claim verification success without command evidence
2093
+ - do not broaden scope without reporting a blocker
2094
+
2095
+ Return format:
2096
+ Produce the artifact as a plain-text file following the ImplementationReport template.
2097
+ Artifact: ImplementationReport
2098
+ Workflow mode: extraction
2099
+ Source repository: ${sourceDir}
2100
+ Target repository: ${targetDir}
2101
+ Inputs used: ...
2102
+ [all required sections]
2103
+ Status: complete | incomplete | blocked
2104
+ `;
2105
+ }
2106
+ function extractionTestImplementationPrompt(ctx) {
2107
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
2108
+ return `${header(ctx)}
2109
+ Inputs:
2110
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2111
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
2112
+ - ${ctx.runFolder}/artifacts/pseudocode-packet.txt
2113
+ - ${ctx.runFolder}/artifacts/test-strategy-packet.txt
2114
+ - ${ctx.runFolder}/artifacts/implementation-report.txt (if available)
2115
+
2116
+ Task:
2117
+ Add or update tests in the target repository and produce ${ctx.runFolder}/artifacts/test-implementation-report.txt (artifact: TestImplementationReport).
2118
+
2119
+ All test work must happen in ${targetDir}.
2120
+ Prioritize non-negotiable regression tests from the GoldenBehaviorContract.
2121
+ Follow the TestStrategyPacket. Do not invent a separate test strategy.
2122
+
2123
+ Extraction guardrails:
2124
+ - Add or update tests in the target repository only.
2125
+ - Do not add tests to the source repository.
2126
+ - Regression tests must cover every non-negotiable item in the GoldenBehaviorContract.
2127
+ - Do not claim tests passed unless command evidence is included.
2128
+
2129
+ The TestImplementationReport must include:
2130
+ - test files changed (target repository only)
2131
+ - tests added
2132
+ - tests updated
2133
+ - GoldenBehaviorContract items covered
2134
+ - behaviors covered
2135
+ - invariants covered
2136
+ - state transitions covered
2137
+ - derived values covered
2138
+ - boundaries covered
2139
+ - external contracts covered
2140
+ - failure modes covered
2141
+ - TestStrategyPacket items not implemented
2142
+ - reason for each missing test
2143
+ - verification commands to run
2144
+
2145
+ Required output artifact: TestImplementationReport
2146
+ Output file: ${ctx.runFolder}/artifacts/test-implementation-report.txt
2147
+
2148
+ Stop conditions:
2149
+ - do not replace the TestStrategyPacket with a new unrelated strategy
2150
+ - do not change production behavior unless reporting a blocker
2151
+ - do not add tests to the source repository
2152
+
2153
+ Return format:
2154
+ Produce the artifact as a plain-text file following the TestImplementationReport template.
2155
+ Artifact: TestImplementationReport
2156
+ Workflow mode: extraction
2157
+ Target repository: ${targetDir}
2158
+ [all required sections]
2159
+ Status: complete | incomplete | blocked
2160
+ `;
2161
+ }
2162
+ function extractionVerificationPrompt(ctx) {
2163
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
2164
+ return `${header(ctx)}
2165
+ Inputs:
2166
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2167
+ - ${ctx.runFolder}/artifacts/test-strategy-packet.txt
2168
+ - ${ctx.runFolder}/artifacts/implementation-report.txt
2169
+ - ${ctx.runFolder}/artifacts/test-implementation-report.txt
2170
+
2171
+ Task:
2172
+ Run validation commands in the target repository and produce ${ctx.runFolder}/artifacts/verification-report.txt (artifact: VerificationReport).
2173
+
2174
+ Run target project validation commands in ${targetDir}.
2175
+ Do not validate the source repository unless explicitly requested by the request brief.
2176
+
2177
+ Extraction guardrails:
2178
+ - Run all validation commands from inside the target repository.
2179
+ - Do not claim checks passed unless actual command output was produced.
2180
+ - Do not hide failed commands.
2181
+
2182
+ The VerificationReport must include:
2183
+ - commands run and working directory for each (should be ${targetDir})
2184
+ - exit codes
2185
+ - pass/fail status
2186
+ - output summary
2187
+ - failed tests if any
2188
+ - GoldenBehaviorContract items verified by tests
2189
+ - skipped checks
2190
+ - reason for skipped checks
2191
+ - environment notes if relevant
2192
+ - remaining verification gaps
2193
+
2194
+ Required output artifact: VerificationReport
2195
+ Output file: ${ctx.runFolder}/artifacts/verification-report.txt
2196
+
2197
+ Stop conditions:
2198
+ - do not claim checks passed unless command output was produced
2199
+ - do not hide failed commands
2200
+ - do not validate source repository unless explicitly requested
2201
+
2202
+ Return format:
2203
+ Produce the artifact as a plain-text file following the VerificationReport template.
2204
+ Artifact: VerificationReport
2205
+ Workflow mode: extraction
2206
+ Target repository: ${targetDir}
2207
+ [all required sections]
2208
+ Status: complete | incomplete | blocked
2209
+ `;
2210
+ }
2211
+ function extractionJudgePrompt(ctx) {
2212
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
2213
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
2214
+ return `${header(ctx)}
2215
+ Inputs:
2216
+ - ${ctx.runFolder}/artifacts/request-brief.txt
2217
+ - ${ctx.runFolder}/artifacts/source-workflow-map.txt
2218
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
2219
+ - ${ctx.runFolder}/artifacts/do-not-port-list.txt
2220
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2221
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
2222
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
2223
+ - ${ctx.runFolder}/artifacts/pseudocode-packet.txt
2224
+ - ${ctx.runFolder}/artifacts/test-strategy-packet.txt
2225
+ - ${ctx.runFolder}/artifacts/implementation-report.txt
2226
+ - ${ctx.runFolder}/artifacts/test-implementation-report.txt
2227
+ - ${ctx.runFolder}/artifacts/verification-report.txt
2228
+
2229
+ Task:
2230
+ Review the target implementation against all extraction artifacts and produce ${ctx.runFolder}/artifacts/judge-report.txt (artifact: JudgeReport).
2231
+
2232
+ Do not mark the run as passed unless the target implementation satisfies the GoldenBehaviorContract.
2233
+
2234
+ The JudgeReport must assess:
2235
+ - implementation vs GoldenBehaviorContract (primary gate)
2236
+ - implementation vs PseudocodePacket
2237
+ - implementation vs TargetArchitectureProposal
2238
+ - tests vs TestStrategyPacket
2239
+ - tests vs GoldenBehaviorContract non-negotiable regression tests
2240
+ - DoNotPortList compliance: no excluded systems were ported
2241
+ - SourceToTargetPortingMap decisions followed
2242
+ - source repository read-only compliance: was the source repository modified?
2243
+ - behavior coverage
2244
+ - verification evidence
2245
+ - scope control
2246
+ - risks and gaps
2247
+
2248
+ Verdict must be one of:
2249
+ PASS | DESIGN_INCOMPLETE | PSEUDOCODE_INCOMPLETE | IMPLEMENTATION_MISMATCH |
2250
+ TEST_COVERAGE_INCOMPLETE | ARCHITECTURE_MISMATCH | DO_NOT_PORT_VIOLATION |
2251
+ GOLDEN_CONTRACT_NOT_SATISFIED | NEED_VERIFICATION | SCOPE_VIOLATION | BLOCKED
2252
+
2253
+ Required output artifact: JudgeReport
2254
+ Output file: ${ctx.runFolder}/artifacts/judge-report.txt
2255
+
2256
+ Source repository: ${sourceDir}
2257
+ Target repository: ${targetDir}
2258
+
2259
+ Stop conditions:
2260
+ - do not rewrite code
2261
+ - do not approve without verification evidence
2262
+ - do not hide gaps in GoldenBehaviorContract coverage
2263
+
2264
+ Return format:
2265
+ Produce the artifact as a plain-text file.
2266
+ Artifact: JudgeReport
2267
+ Workflow mode: extraction
2268
+ Source repository: ${sourceDir}
2269
+ Target repository: ${targetDir}
2270
+ Verdict: ...
2271
+ GoldenBehaviorContract satisfied: yes | no | partial
2272
+ DoNotPortList compliant: yes | no
2273
+ Source repository modified: yes | no
2274
+ Recommended next stage if not PASS: ...
2275
+ Status: complete
2276
+ `;
2277
+ }
2278
+ function extractionFinalReportPrompt(ctx) {
2279
+ const sourceDir = ctx.sourceRepoRoot ?? '<source-repo-root>';
2280
+ const targetDir = ctx.targetRepoRoot ?? '<target-repo-root>';
2281
+ return `${header(ctx)}
2282
+ Inputs:
2283
+ - ${ctx.runFolder}/artifacts/request-brief.txt
2284
+ - ${ctx.runFolder}/artifacts/source-workflow-map.txt
2285
+ - ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
2286
+ - ${ctx.runFolder}/artifacts/do-not-port-list.txt
2287
+ - ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2288
+ - ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
2289
+ - ${ctx.runFolder}/artifacts/behavior-model.txt
2290
+ - ${ctx.runFolder}/artifacts/pseudocode-packet.txt
2291
+ - ${ctx.runFolder}/artifacts/test-strategy-packet.txt
2292
+ - ${ctx.runFolder}/artifacts/implementation-report.txt
2293
+ - ${ctx.runFolder}/artifacts/test-implementation-report.txt
2294
+ - ${ctx.runFolder}/artifacts/verification-report.txt
2295
+ - ${ctx.runFolder}/artifacts/judge-report.txt
2296
+
2297
+ Task:
2298
+ Summarize the completed extraction workflow and produce ${ctx.runFolder}/artifacts/final-report.txt (artifact: FinalReport).
2299
+
2300
+ The FinalReport must include:
2301
+ - Mode: extraction
2302
+ - Run ID: ${ctx.runId}
2303
+ - Original extraction request
2304
+ - Source repository: ${sourceDir}
2305
+ - Target repository: ${targetDir}
2306
+ - Final status (judge verdict)
2307
+ - Source workflow map: ${ctx.runFolder}/artifacts/source-workflow-map.txt
2308
+ - Source-to-target porting map: ${ctx.runFolder}/artifacts/source-to-target-porting-map.txt
2309
+ - Do-not-port list: ${ctx.runFolder}/artifacts/do-not-port-list.txt
2310
+ - Golden behavior contract: ${ctx.runFolder}/artifacts/golden-behavior-contract.txt
2311
+ - Target architecture proposal: ${ctx.runFolder}/artifacts/target-architecture-proposal.txt
2312
+ - Source components reused
2313
+ - Source components rewritten
2314
+ - Source components discarded
2315
+ - Files changed in target repository
2316
+ - Files changed in source repository (normally: none)
2317
+ - Tests added or updated
2318
+ - Verification commands and results
2319
+ - Judge result
2320
+ - Remaining risks
2321
+ - Recommended next extraction or implementation step
2322
+
2323
+ Required output artifact: FinalReport
2324
+ Output file: ${ctx.runFolder}/artifacts/final-report.txt
2325
+
2326
+ Stop conditions:
2327
+ - do not exaggerate success
2328
+ - do not omit failed or skipped verification
2329
+ - do not hide unresolved risks
2330
+
2331
+ Return format:
2332
+ Produce the artifact as a plain-text file following the FinalReport template.
2333
+ Artifact: FinalReport
2334
+ Workflow mode: extraction
2335
+ Run ID: ${ctx.runId}
2336
+ Source repository: ${sourceDir}
2337
+ Target repository: ${targetDir}
2338
+ [all required sections]
2339
+ Status: complete
2340
+ `;
2341
+ }
1271
2342
  // ─── Stage router ─────────────────────────────────────────────────────────────
1272
2343
  function generateStagePrompt(meta, stageName) {
1273
2344
  const stageIndex = meta.stages.findIndex((s) => s.name === stageName);
@@ -1282,20 +2353,24 @@ function generateStagePrompt(meta, stageName) {
1282
2353
  runFolder: meta.runFolder,
1283
2354
  stageNumber: stageIndex + 1,
1284
2355
  totalStages: meta.stages.length,
2356
+ sourceRepoRoot: meta.sourceRepoRoot,
2357
+ targetRepoRoot: meta.targetRepoRoot,
1285
2358
  };
2359
+ const isExtraction = meta.mode === 'extraction';
1286
2360
  switch (stageName) {
1287
- // shared
2361
+ // shared — non-extraction
1288
2362
  case 'architecture-context': return architectureContextPrompt(ctx);
1289
- case 'behavior-model': return behaviorModelPrompt(ctx);
1290
- case 'pseudocode-packet': return pseudocodePacketPrompt(ctx);
1291
- case 'test-strategy': return testStrategyPrompt(ctx);
1292
- case 'implementation': return implementationPrompt(ctx);
1293
- case 'test-implementation': return testImplementationPrompt(ctx);
1294
- case 'verification': return verificationPrompt(ctx);
1295
- case 'judge': return judgePrompt(ctx);
1296
- case 'final-report': return finalReportPrompt(ctx);
2363
+ case 'verification': return isExtraction ? extractionVerificationPrompt(ctx) : verificationPrompt(ctx);
2364
+ case 'judge': return isExtraction ? extractionJudgePrompt(ctx) : judgePrompt(ctx);
2365
+ case 'final-report': return isExtraction ? extractionFinalReportPrompt(ctx) : finalReportPrompt(ctx);
2366
+ // shared stages with extraction-specific overrides
2367
+ case 'behavior-model': return isExtraction ? extractionBehaviorModelPrompt(ctx) : behaviorModelPrompt(ctx);
2368
+ case 'pseudocode-packet': return isExtraction ? extractionPseudocodePacketPrompt(ctx) : pseudocodePacketPrompt(ctx);
2369
+ case 'test-strategy': return isExtraction ? extractionTestStrategyPrompt(ctx) : testStrategyPrompt(ctx);
2370
+ case 'implementation': return isExtraction ? extractionImplementationPrompt(ctx) : implementationPrompt(ctx);
2371
+ case 'test-implementation': return isExtraction ? extractionTestImplementationPrompt(ctx) : testImplementationPrompt(ctx);
1297
2372
  // feature
1298
- case 'request-brief': return requestBriefPrompt(ctx);
2373
+ case 'request-brief': return isExtraction ? extractionRequestBriefPrompt(ctx) : requestBriefPrompt(ctx);
1299
2374
  // repair
1300
2375
  case 'observed-behavior-report': return observedBehaviorReportPrompt(ctx);
1301
2376
  case 'behavior-trace': return behaviorTracePrompt(ctx);
@@ -1318,6 +2393,12 @@ function generateStagePrompt(meta, stageName) {
1318
2393
  case 'failure-mode-matrix': return failureModeMatrixPrompt(ctx);
1319
2394
  case 'guard-pseudocode-packet': return guardPseudocodePacketPrompt(ctx);
1320
2395
  case 'resilience-test-strategy': return resilienceTestStrategyPrompt(ctx);
2396
+ // extraction-specific
2397
+ case 'source-architecture-context': return sourceArchitectureContextPrompt(ctx);
2398
+ case 'source-workflow-map': return sourceWorkflowMapPrompt(ctx);
2399
+ case 'porting-map': return portingMapPrompt(ctx);
2400
+ case 'golden-behavior-contract': return goldenBehaviorContractPrompt(ctx);
2401
+ case 'target-architecture': return targetArchitecturePrompt(ctx);
1321
2402
  default:
1322
2403
  throw new Error(`No prompt generator for stage: "${stageName}"`);
1323
2404
  }