Changed the default value of the package_path parameter in result-refactor.md from "internal" to "internal/git".
69 lines
1.9 KiB
Markdown
69 lines
1.9 KiB
Markdown
---
|
|
name: result-refactor
|
|
description: Convert traditional Go error handling to Result[T] monadic style
|
|
version: 1.0
|
|
|
|
parameters:
|
|
package_path:
|
|
type: string
|
|
default: internal/git
|
|
description: Package to refactor
|
|
dry_run:
|
|
type: bool
|
|
default: true
|
|
description: If true, only generate patches
|
|
|
|
project_languages:
|
|
- go
|
|
|
|
extensions:
|
|
go:
|
|
- .go
|
|
|
|
allowed_shell_commands:
|
|
- go test ./...
|
|
- go fmt ./...
|
|
- go vet ./...
|
|
- rg --files
|
|
- git diff --name-only
|
|
- jq
|
|
|
|
---
|
|
|
|
# Result[T] Refactoring Recipe
|
|
|
|
**Overview**
|
|
Refactors all error handling in the target package to use the new Result[T] pattern.
|
|
|
|
## Execution Steps
|
|
|
|
### Step 1: Discover files
|
|
**Objective:** Find every file that needs changing.
|
|
**Instructions:** Recursively scan `{{.package_path}}` for `.go` files containing `if err != nil`.
|
|
**Expected output:** A clean list of full file paths (one per line). If none, say "No files found matching the criteria."
|
|
|
|
### Step 2: Refactor each file
|
|
**Objective:** Generate the updated code.
|
|
**Instructions:** For each file from Step 1:
|
|
- Read the full original content.
|
|
- Refactor it to use `Result[T]` instead of naked errors (follow existing style, preserve all comments).
|
|
- Return **ONLY** a single JSON array in this exact format (no extra text, no markdown):
|
|
```json
|
|
[
|
|
{
|
|
"file": "internal/example.go",
|
|
"content": "the complete refactored file here"
|
|
}
|
|
]
|
|
```
|
|
|
|
### Step 3: Apply or patch
|
|
**Objective:**
|
|
Safely write changes or create reviewable output.
|
|
**Instructions:**
|
|
- If dry_run is true → create a unified diff patch file for review.
|
|
- If false → write the new files (backup originals as .bak).
|
|
**Expected output:** Confirmation of what was written + full path to any patch file.
|
|
|
|
**Final Summary**
|
|
Give me a concise executive summary: number of files changed, any warnings or patterns you noticed, and your recommended next step. |