Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions marketplaces/large-codebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "large-codebase",
"owner": {
"name": "OpenHands",
"email": "contact@all-hands.dev"
},
"metadata": {
"description": "OpenHands skills for interacting, improving, and refactoring large codebases",
"version": "1.0.0",
"pluginRoot": "./skills"
},
"plugins": [
{
"name": "add-javadoc",
"source": "./add-javadoc",
"description": "Add comprehensive JavaDoc documentation to Java classes and methods. Use when documenting Java code, adding API documentation, or improving code documentation.",
"category": "documentation",
"keywords": [
"javadoc",
"java",
"documentation",
"api-docs"
]
},
{
"name": "cobol-modernization",
"source": "../plugins/cobol-modernization",
"description": "End-to-end COBOL to Java migration workflow. Handles build setup, mainframe dependency removal, and code migration with test validation.",
"category": "development",
"keywords": [
"cobol",
"java",
"migration",
"mainframe",
"modernization"
]
},
{
"name": "migration-scoring",
"source": "../plugins/migration-scoring",
"description": "Evaluate code migration quality with coverage, correctness, and style scoring. Generates executive reports with actionable recommendations.",
"category": "code-quality",
"keywords": [
"migration",
"scoring",
"quality",
"evaluation",
"reporting"
]
}
]
}
113 changes: 113 additions & 0 deletions plugins/cobol-modernization/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
name: cobol-modernization
description: End-to-end COBOL to Java migration workflow. Handles build setup, mainframe dependency removal, and code migration with test validation.
license: MIT
compatibility: Requires GnuCOBOL, Java 11+, Maven/Gradle, Python 3.13 with uv
triggers:
- cobol modernization
- cobol to java
- cobol migration
- mainframe migration
---

End-to-end workflow for migrating COBOL codebases to Java.

## Overview

This plugin orchestrates a multi-phase COBOL modernization project:

1. **Build Setup** — Configure compilation for both COBOL and Java, create test fixtures
2. **Mainframe Planning** — Document transformations needed to remove mainframe dependencies
3. **Mainframe Removal** — Convert CICS/VSAM code to standard COBOL
4. **Java Migration** — Translate standardized COBOL to idiomatic Java

## Prerequisites

- GnuCOBOL compiler (`cobc`)
- Java 11+ with Maven or Gradle
- Python 3.13 with `uv`
- LLM API key (Anthropic or OpenAI)

## Quick Start

```bash
export LLM_API_KEY="your-api-key"
export LLM_MODEL="anthropic/claude-3-5-sonnet-20241022"

uv run python -m lc_sdk_examples.cobol_modernization --src-path /path/to/cobol/project
```

## Workflow Phases

### Phase 1: Build Setup

See [skills/build-setup/SKILL.md](skills/build-setup/SKILL.md)

Creates the foundation for the migration:
- COBOL compilation environment (GnuCOBOL)
- Java project structure (Maven/Gradle + JUnit 5)
- Test fixtures with golden outputs from COBOL execution

**Outputs:**
- `build_notes.md` — Build instructions
- `test-fixtures/` — Input/output test data
- `test_manifest.json` — Test case mapping

### Phase 2: Mainframe Planning

See [skills/mainframe-planning/SKILL.md](skills/mainframe-planning/SKILL.md)

Creates a transformation guide without modifying code:
- Maps CICS/VSAM constructs to standard COBOL equivalents
- Documents error handling replacements
- Identifies UI operations to stub

**Output:**
- `mainframe_dependency_removal_plan.md`

### Phase 3: Mainframe Removal

See [skills/mainframe-removal/SKILL.md](skills/mainframe-removal/SKILL.md)

Applies the transformation guide:
- Replaces EXEC CICS commands with file I/O
- Adds FILE STATUS checking
- Stubs BMS/screen operations

**Verification:**
- Code compiles with GnuCOBOL
- Runs with test fixtures

### Phase 4: Java Migration

See [skills/to-java-migration/SKILL.md](skills/to-java-migration/SKILL.md)

Translates to idiomatic Java:
- Proper Java conventions (not literal translations)
- JUnit tests using golden outputs
- COBOL references in comments

**Done when:**
- All code compiles
- All JUnit tests pass
- No TODOs or stubs remain

## Output Structure

```
your-project/
├── .lc-sdk/
│ ├── initial_batch_graph.json
│ ├── fixed_batch_graph.json
│ └── mainframe_dependency_removal_plan.md
├── test-fixtures/
│ ├── inputs/
│ └── expected_outputs/
├── test_manifest.json
├── src/main/java/
└── src/test/java/
```

## Troubleshooting

See [references/troubleshooting.md](references/troubleshooting.md) for common issues and solutions.
18 changes: 18 additions & 0 deletions plugins/cobol-modernization/references/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Troubleshooting Guide

## COBOL doesn't compile after mainframe removal

- Check FILE STATUS is declared for all files
- Ensure CLOSE statements in all code paths
- Verify paragraph names match PERFORM statements

## Java tests fail

- Compare output byte-by-byte with golden files
- Check decimal precision (use BigDecimal)
- Verify character encoding matches COBOL

## Missing functionality

- Check the migration mapping for coverage gaps
- Review `mainframe_dependency_removal_plan.md` for skipped items
78 changes: 78 additions & 0 deletions plugins/cobol-modernization/skills/build-setup/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
name: build-setup
description: Set up build environment and test fixtures for COBOL-to-Java migrations. Creates compilation infrastructure for both languages and generates golden test data.
license: MIT
compatibility: Requires GnuCOBOL (cobc), Java 11+, Maven or Gradle
triggers:
- cobol build
- cobol test fixtures
- migration build setup
- gnucobol
---

Set up a build environment and create test fixtures for validating COBOL-to-Java migrations.

To install GnuCOBOL, run: `./scripts/install-gnucobol.sh`

## Phase 1: Build Setup

### COBOL Build

- Find a way to compile and run the COBOL code (e.g., GnuCOBOL)
- Verify at least one program compiles and executes
- Note any dependencies or setup required

### Java Build

- Initialize a Java project alongside the COBOL code (Maven or Gradle)
- Set up standard directory structure: `src/main/java`, `src/test/java`
- Include JUnit 5 as a test dependency
- Verify the project builds (even if empty)

## Phase 2: Test Fixture Generation

For each major COBOL program:

### Create Synthetic Test Inputs

- Save to: `test-fixtures/inputs/{PROGRAM_NAME}/`
- Create 3-5 test cases per program covering:
- Normal/happy path (valid, typical data)
- Edge cases (empty input, maximum values, boundary conditions)
- Error cases (invalid formats, missing required fields)

### Generate Golden Outputs

- Run each COBOL program with each test input
- Save COBOL output to: `test-fixtures/expected_outputs/{PROGRAM_NAME}/`
- These become the "golden" outputs that Java must match

### Create Test Manifest

Save to `test_manifest.json`:

```json
{
"PROGRAM1": {
"description": "Brief description of what this program does",
"test_cases": [
{
"name": "normal_invoice",
"input": "inputs/PROGRAM1/test_001.dat",
"expected": "expected_outputs/PROGRAM1/test_001.out",
"description": "Happy path"
}
]
}
}
```

## Deliverables

1. **build_notes.md** — Build instructions for COBOL and Java
2. **test-fixtures/** — Directory with `inputs/` and `expected_outputs/`
3. **test_manifest.json** — JSON manifest of all test cases

## Priority

Focus on programs with core business logic (transactions, calculations, data processing). UI-heavy programs (menu screens, reports) are lower priority.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
# Install GnuCOBOL compiler for COBOL-to-Java migration projects

set -euo pipefail

echo "Installing GnuCOBOL..."

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install -y gnucobol
elif command -v yum &> /dev/null; then
sudo yum install -y gnucobol
else
echo "Error: Unsupported Linux package manager"
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &> /dev/null; then
brew install gnucobol
else
echo "Error: Homebrew not found. Install from https://brew.sh"
exit 1
fi
else
echo "Error: Unsupported OS: $OSTYPE"
exit 1
fi

echo "Verifying installation..."
cobc --version
echo "GnuCOBOL installed successfully!"
62 changes: 62 additions & 0 deletions plugins/cobol-modernization/skills/mainfraime-removal/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: mainframe-removal
description: Apply mainframe dependency transformations to COBOL code using a pre-generated transformation guide. Converts CICS/VSAM constructs to standard COBOL.
license: MIT
compatibility: Requires GnuCOBOL (cobc) for verification
triggers:
- remove mainframe
- cobol transformation
- cics removal
- standard cobol
---

Apply the transformations from a transformation guide to convert mainframe-specific COBOL to standard COBOL.

**Prerequisite**: A transformation guide must exist (see `cobol-mainframe-planning` skill).

## Transformation Requirements

### Data Operations

- Replace each CICS/VSAM construct with its standard COBOL equivalent per the plan
- Add FILE STATUS checks after EVERY file operation:
- Check for success (00) before proceeding
- Handle "not found" (23) distinctly from I/O errors (3x)
- Handle "file not exists" (35) at OPEN time
- Add explicit CLOSE statements in all code paths (including error paths)

### UI/Terminal Operations (BMS maps, SEND/RECEIVE)

- Replace with simple stubs or ACCEPT/DISPLAY statements
- Do NOT spend time replicating screen layouts
- Focus on preserving data flow, not UI fidelity

### Error Handling

- Replace CICS RESP/RESP2 checks with equivalent FILE STATUS logic
- Replace HANDLE CONDITION with explicit status checking after operations
- Ensure error paths don't leave files open

See [references/cics-transformation-examples.md](references/cics-transformation-examples.md) for before/after code examples.

## Verification

After transformation:
- Code MUST compile without errors
- Test with valid input → should execute core business logic
- Test with missing/invalid files → should fail gracefully, not crash

## Preserve

- All original business logic
- Data transformations and calculations
- Validation rules

## Checklist

- [ ] All EXEC CICS commands replaced
- [ ] FILE STATUS declared for all files
- [ ] FILE STATUS checked after every I/O operation
- [ ] CLOSE statements in all code paths
- [ ] Code compiles successfully
- [ ] Basic test execution passes
Loading