Skip to content

Commit a9743fe

Browse files
committed
Add WSL wrapper and usage docs for EncodingFixTool
1 parent 4f74002 commit a9743fe

2 files changed

Lines changed: 70 additions & 3 deletions

File tree

agent-skill/encodingfix-delphi-cleanup/SKILL.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,43 @@ git status --short
2626

2727
If unrelated user changes are dirty, avoid broad cleanup. Narrow `path=...`, override `ext=...`, or ask before touching files outside our work.
2828

29-
2. In a Git worktree, prefer the AI cleanup preset:
29+
2. In a Git worktree, prefer the AI cleanup preset.
30+
31+
From WSL, run the Bash wrapper so WSL paths are converted before the Windows executable receives them. If the repo `bin` directory is on `PATH`, prefer:
32+
33+
```bash
34+
EncodingFixTool.sh path=. preset=delphi-ai scope=git-changed format=json
35+
```
36+
37+
Otherwise, use the repo-local wrapper path:
38+
39+
```bash
40+
./bin/EncodingFixTool.sh path=. preset=delphi-ai scope=git-changed format=json
41+
```
42+
43+
From Windows PowerShell, run:
3044

3145
```powershell
3246
EncodingFixTool path=. preset=delphi-ai scope=git-changed format=json
3347
```
3448

35-
If the executable is not on `PATH`, use a local build such as:
49+
If the executable is not on `PATH`, use a local Windows build such as:
3650

3751
```powershell
3852
.\bin\EncodingFixTool.exe path=. preset=delphi-ai scope=git-changed format=json
3953
```
4054

41-
3. Outside Git, use an explicit path and dry run first:
55+
3. Outside Git, use an explicit path and dry run first.
56+
57+
From WSL:
58+
59+
```bash
60+
EncodingFixTool.sh path=./src preset=delphi-ai format=json dry
61+
```
62+
63+
Use `./bin/EncodingFixTool.sh ...` instead if the wrapper is not on `PATH`.
64+
65+
From Windows PowerShell:
4266

4367
```powershell
4468
EncodingFixTool path=.\src preset=delphi-ai format=json dry

bin/EncodingFixTool.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
5+
exe_path="$script_dir/EncodingFixTool.exe"
6+
7+
if [[ ! -f "$exe_path" ]]; then
8+
printf 'EncodingFixTool.exe not found next to %s\n' "$0" >&2
9+
exit 127
10+
fi
11+
12+
is_windows_path() {
13+
[[ "$1" =~ ^[A-Za-z]:[\\/].* || "$1" =~ ^\\\\.* ]]
14+
}
15+
16+
to_windows_path() {
17+
local value="$1"
18+
19+
if [[ -z "$value" ]] || is_windows_path "$value"; then
20+
printf '%s' "$value"
21+
return
22+
fi
23+
24+
wslpath -aw -- "$value"
25+
}
26+
27+
convert_arg() {
28+
local arg="$1"
29+
30+
if [[ "$arg" =~ ^(-{0,2}|/)(path|config|bkp-dir)([:=])(.*)$ ]]; then
31+
printf '%s%s%s%s' "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "$(to_windows_path "${BASH_REMATCH[4]}")"
32+
else
33+
printf '%s' "$arg"
34+
fi
35+
}
36+
37+
shopt -s nocasematch
38+
converted_args=()
39+
for arg in "$@"; do
40+
converted_args+=("$(convert_arg "$arg")")
41+
done
42+
43+
exec "$exe_path" "${converted_args[@]}"

0 commit comments

Comments
 (0)