Skip to content

Commit 06789ac

Browse files
committed
docs: refine EncodingFix skill layout
1 parent ff77242 commit 06789ac

4 files changed

Lines changed: 186 additions & 176 deletions

File tree

agent-skill/SKILL.md

Lines changed: 0 additions & 156 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
name: encodingfix-delphi-cleanup
3+
description: Use EncodingFixTool whenever an AI agent edits, generates, patches, or reviews Delphi/Pascal files and needs safe CRLF or UTF-8 cleanup. Trigger this skill after apply_patch, WSL/Linux tools, formatters, bulk rewrites, or pre-commit cleanup involving .pas, .dpr, .dpk, .inc, .dfm, or .dproj files, even when the user only mentions wrong line endings or encoding drift.
4+
---
5+
6+
# EncodingFix Delphi Cleanup
7+
8+
Run EncodingFixTool after AI/editor work may have changed Delphi line endings or encoding. Keep the cleanup narrow, auditable, and separate from build/test validation.
9+
10+
## Use This For
11+
12+
- Delphi files: `.pas`, `.dpr`, `.dpk`, `.inc`, `.dfm`, `.dproj`.
13+
- AI-generated or patched Delphi code that should use Windows CRLF.
14+
- Delphi files that should be UTF-8 with BOM when non-ASCII text is present.
15+
- Pre-build or pre-commit cleanup after code generation, patching, formatters, WSL, or Linux tooling.
16+
17+
Do not use it for unrelated dirty files, vendored code, non-Delphi cleanup, or as a replacement for the repo's build/test gates. Binary `.dfm` files are safe because EncodingFixTool skips them.
18+
19+
## Core Workflow
20+
21+
1. Check the dirty set first:
22+
23+
```powershell
24+
git status --short
25+
```
26+
27+
If unrelated user changes are dirty, avoid broad cleanup. Narrow `path=...`, override `ext=...`, or ask before touching files outside our work.
28+
29+
2. In a Git worktree, prefer the AI cleanup preset:
30+
31+
```powershell
32+
EncodingFixTool path=. preset=delphi-ai scope=git-changed format=json
33+
```
34+
35+
If the executable is not on `PATH`, use a local build such as:
36+
37+
```powershell
38+
.\bin\EncodingFixTool.exe path=. preset=delphi-ai scope=git-changed format=json
39+
```
40+
41+
3. Outside Git, use an explicit path and dry run first:
42+
43+
```powershell
44+
EncodingFixTool path=.\src preset=delphi-ai format=json dry
45+
```
46+
47+
Run the same command without `dry` only after the reported scope is correct.
48+
49+
## Read Results
50+
51+
Treat the run as successful only when the process exits with code `0` and JSON `failed` is `0`.
52+
53+
- `changed > 0`: inspect the relevant diffs before reporting done.
54+
- `skipped > 0`: usually expected for binary `.dfm`; mention it only when relevant.
55+
- `failed > 0` or exit code `1`: stop and report the file-level failure.
56+
- Exit code `2`: fix the missing `path` and rerun.
57+
58+
## Verify
59+
60+
After cleanup:
61+
62+
```powershell
63+
git diff --stat
64+
git ls-files --eol *.pas *.dpr *.dpk *.inc *.dfm *.dproj
65+
```
66+
67+
Then continue with the repo's normal Delphi build/test gates. EncodingFixTool only fixes encoding and line endings.
68+
69+
## Reporting Pattern
70+
71+
Keep the final note short and evidence-based:
72+
73+
```text
74+
Ran EncodingFixTool with preset=delphi-ai scope=git-changed format=json.
75+
Result: scanned=4, changed=2, skipped=1, failed=0.
76+
Checked git diff --stat and continued with the repo build/test gate.
77+
```
78+
79+
If the tool was not run, state why: for example, no Delphi files were touched, the worktree had unrelated changes, or EncodingFixTool was unavailable.
80+
81+
## More Detail
82+
83+
Read `references/encodingfix-tool.md` only when you need command details, preset precedence, dry-run behavior, install/copy notes, or examples for non-standard scopes.

agent-skill/evals/evals.json renamed to agent-skill/encodingfix-delphi-cleanup/evals/evals.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
{
2-
"skill_name": "encodingfix-delphi-cleanup",
3-
"evals": [
4-
{
5-
"id": 1,
6-
"prompt": "I just used apply_patch on several Delphi .pas and .dfm files in this repo. Before you run the build, clean up any AI-created LF line endings or encoding issues without touching unrelated files.",
7-
"expected_output": "The agent should check git status, run EncodingFixTool with path=. preset=delphi-ai scope=git-changed format=json, inspect the JSON summary and relevant diffs, then continue to the normal build/test gate."
8-
},
9-
{
10-
"id": 2,
11-
"prompt": "This is a Delphi checkout but it is not a Git worktree. Please repair CRLF/UTF-8 only under .\\src after generated code was pasted there.",
12-
"expected_output": "The agent should avoid scope=git-changed, use an explicit path such as path=.\\src with preset=delphi-ai format=json dry first, then rerun without dry only after confirming scope."
13-
},
14-
{
15-
"id": 3,
16-
"prompt": "The worktree has my unrelated changes plus your generated Delphi units. Fix only your files' line endings and tell me what happened.",
17-
"expected_output": "The agent should not run a broad scope=git-changed cleanup over all dirty files. It should narrow path or extensions, ask if needed, run dry when scope is unclear, and report scanned/changed/skipped/failed counts."
18-
}
19-
]
20-
}
1+
{
2+
"skill_name": "encodingfix-delphi-cleanup",
3+
"evals": [
4+
{
5+
"id": 1,
6+
"prompt": "I just used apply_patch on several Delphi .pas and .dfm files in this repo. Before you run the build, clean up any AI-created LF line endings or encoding issues without touching unrelated files.",
7+
"expected_output": "The agent should check git status, run EncodingFixTool with path=. preset=delphi-ai scope=git-changed format=json, inspect the JSON summary and relevant diffs, then continue to the normal build/test gate."
8+
},
9+
{
10+
"id": 2,
11+
"prompt": "This is a Delphi checkout but it is not a Git worktree. Please repair CRLF/UTF-8 only under .\\src after generated code was pasted there.",
12+
"expected_output": "The agent should avoid scope=git-changed, use an explicit path such as path=.\\src with preset=delphi-ai format=json dry first, then rerun without dry only after confirming scope."
13+
},
14+
{
15+
"id": 3,
16+
"prompt": "The worktree has my unrelated changes plus your generated Delphi units. Fix only your files' line endings and tell me what happened.",
17+
"expected_output": "The agent should not run a broad scope=git-changed cleanup over all dirty files. It should narrow path or extensions, ask if needed, run dry when scope is unclear, and report scanned/changed/skipped/failed counts."
18+
}
19+
]
20+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# EncodingFixTool Reference
2+
3+
Use this reference when the standard `preset=delphi-ai scope=git-changed` workflow is not enough.
4+
5+
## Runtime Dependency
6+
7+
Prefer `EncodingFixTool` from `PATH`. If unavailable, use a repo-local executable such as `.\bin\EncodingFixTool.exe`.
8+
9+
## Delphi AI Preset
10+
11+
`preset=delphi-ai` is designed for AI/editor cleanup:
12+
13+
- Delphi extensions: `.pas`, `.dpr`, `.dpk`, `.inc`, `.dfm`, `.dproj`.
14+
- Recursive scan.
15+
- CRLF normalization.
16+
- UTF-8 BOM policy for files with non-ASCII text.
17+
- Binary `.dfm` safety.
18+
19+
`scope=git-changed` limits work to modified and untracked files in the current Git worktree. Do not use it outside Git, and do not use it when unrelated dirty files would be included.
20+
21+
## Dry Run
22+
23+
Use `dry` when the scope is not obvious, many files are dirty, or the user only asked for inspection:
24+
25+
```powershell
26+
EncodingFixTool path=. preset=delphi-ai scope=git-changed format=json dry
27+
```
28+
29+
`dry` reports what would change without rewriting files. Proceed without `dry` only when the file set is expected.
30+
31+
## Non-Git Or Narrow Scope
32+
33+
Outside a Git worktree:
34+
35+
```powershell
36+
EncodingFixTool path=.\src preset=delphi-ai format=json dry
37+
EncodingFixTool path=.\src preset=delphi-ai format=json
38+
```
39+
40+
For a deliberately narrow repair, keep overrides visible:
41+
42+
```powershell
43+
EncodingFixTool path=.\src preset=delphi-ai ext=pas,inc format=json dry
44+
```
45+
46+
## Configured Presets
47+
48+
Repo presets may live in `.encodingfix.json`; user presets may live in:
49+
50+
```text
51+
%APPDATA%\MaxLogic\EncodingFixTool\config.json
52+
```
53+
54+
Preset precedence:
55+
56+
```text
57+
built-in defaults < user config < repo .encodingfix.json < explicit config=... < CLI arguments
58+
```
59+
60+
Example repo config:
61+
62+
```json
63+
{
64+
"presets": {
65+
"agent": {
66+
"ext": "pas,dpr,dpk,inc,dfm,dproj",
67+
"eol": "crlf",
68+
"utf8-bom": "y",
69+
"recursive": "y"
70+
}
71+
}
72+
}
73+
```
74+
75+
Run it with:
76+
77+
```powershell
78+
EncodingFixTool path=. preset=agent scope=git-changed format=json
79+
```
80+
81+
## Install Or Copy
82+
83+
To install this as an agent skill, copy the `encodingfix-delphi-cleanup/` folder into the agent's skills directory. Keep `SKILL.md`, `references/`, and `evals/` together.

0 commit comments

Comments
 (0)