Skip to content

Windows install: interpreter probe, UTF-8 I/O and LF line endings - #57

Merged
maceorichards merged 18 commits into
developfrom
feat/iss-52-windows-install-fixes
Nov 4, 2026
Merged

maceorichards merged 18 commits into
developfrom
feat/iss-52-windows-install-fixes

Conversation

@maceorichards

Copy link
Copy Markdown
Owner

Summary

A fresh Windows clone (Git Bash, Git for Windows' default core.autocrlf=true, Python from python.org) can now run ./sync.sh and install every skill. Linux and macOS behave as before.

 sync.sh
-  exec python3 -I lib/sync.py "$@"
+  for candidate in python3, python, "py -3"
+    if candidate runs and is Python 3.9+
+      exec candidate -I -X utf8 lib/sync.py "$@"
+  print "devflow needs Python 3.9+; tried: …" and exit 1
 sync (lib/sync.py)
   ensure_vendor
-    git clone url
+    git clone -c core.autocrlf=false url          # vendor clones are LF
+    elif effective core.autocrlf is true           # an existing CRLF clone
+      rm --cached + reset --hard, autocrlf off     # repaired once
+      then record core.autocrlf=false              # only after the reset succeeds
   build_skill / edit
-    git apply patches/<name>.patch
+    apply_patch: read as UTF-8, CRLF → LF, then
+      git -c core.autocrlf=false apply (patch on stdin)
   every text open() / fdopen() / subprocess(text=True)
+    encoding="utf-8"; generated files written with newline="\n"
+.gitattributes                 # * text=auto eol=lf
 .github/workflows/ci.yml
+  windows-install              # windows-latest, Git Bash, core.autocrlf true,
+                               # setup-python (python, not python3): dry run, sync,
+                               # managed check, re-sync reports no change
 README.md
+  Quickstart: Windows line + one-time repair for clones made before this fix
 smoke/drive.py                 # same UTF-8 rule (agent output was decoded as cp1252)

Encoding: an AST test fails if any text-mode open, os.fdopen or subprocess call in the sync library or the smoke driver doesn't pass encoding="utf-8".

Evidence

core.autocrlf=true converts LF to CRLF on checkout on any OS, so the Windows failures reproduce in the sandbox tests on Linux and macOS.

  • Before: the acceptance tests run against develop:
    • CRLF patches → FAIL … patch failed: patches/<name>.patch and exit 1.
    • Vendor clones checked out under core.autocrlf=true → installed skill files contain \r.
    • A Store-shim python3 → exit 49, "Python was not found…".
    • 22 text I/O calls in the sync library and 4 in the smoke driver have no encoding.
  • After: DEVFLOW_REQUIRE_VENDORS=1 python3 -m unittest → 323 passed, 0 failed (baseline 267; 56 new tests).
    • Every manifest skill installs with CRLF patches, with CRLF vendor clones, and with fresh clones under core.autocrlf=true, and a re-sync reports no change.
    • A vendor repair whose reset fails is retried on the next sync.
    • The probe falls through python3 → python → py -3, skips an interpreter below 3.9, and reports the failure.
  • Not yet verified: the windows-install job runs for the first time on this PR.

Merge Danger

Door: two-way

The only step that rewrites anything on a user's machine is the one-time vendor-clone repair. It runs git reset --hard inside vendor/, which is regenerable and never edited (AGENTS.md), and only when the clone's effective core.autocrlf is true. Default Linux and macOS setups never trigger it. The .gitattributes renormalize changed no file content.

Blast Radius: installer

Every ./sync.sh run goes through the new interpreter probe and the stdin patch path. The new tests cover both on Linux and macOS. Windows coverage is the new CI job only; the unit suite's Windows port is #51.

Tickets

Ticket Lane Outcome Merge
#53 UTF-8 for every text read and write in the sync and smoke driver fast closed 324c871
#54 LF line endings independent of the user's git config fast closed 1c5386a
#55 Interpreter probe in sync.sh fast closed d05b600
#56 Windows CI job and README fast closed 0ff2d77
Final review fix: persist the vendor repair's setting only after the reset succeeds — committed 70de2de

Rulings made during the build:

Follow-ups

Ruling for the maintainer

  • Duplicated CI steps (standards, Important). The windows-install job copies fresh-install's managed-skill check and its re-sync check, so the status-word list now lives in three places: twice in ci.yml and once in tests/test_line_endings.py. Either fix (an OS matrix, or a shared check script) would break Windows CI job and README #56's acceptance tests, which pin a windows-latest job containing the check. Decide whether to restructure and update those tests together.

Minor findings from the final review

  • The repair trigger compares core.autocrlf to the string true. git's other true spellings (yes, on, 1) skip the repair; use git config --type=bool.
  • sh() decodes git output strictly as UTF-8, so a non-UTF-8 byte (e.g. a Latin-1 vendor commit message in --update) now raises. Consider errors="replace", as the stdin path already does.
  • The Windows CI job doesn't check that installed files are LF. The re-sync check compares two outputs of the same pipeline, so a CRLF regression would still pass.
  • Two tests are missing: a re-sync after fresh vendor clones reports no change, and sync.sh save writes LF and UTF-8.
  • devflow.local.json, the git ignore append and the smoke driver's writes still use platform newlines.
  • apply_patch converts every CRLF, including any inside content lines. This has no effect today, because no vendor file has CRLF in its index.
  • Test-code cleanups: the unused NAMES dict in test_interpreter_probe.py; WindowsQuickstartTest borrowing ReadmeFirstRunTest.quickstart; the harness re-reading manifest.json in three places.
  • Add a DESIGN.md entry for the decisions: Git Bash only, the probe order, LF everywhere.
  • The README's "before the line-ending fix" should name a version or date.

Closes #52
Closes #53
Closes #54
Closes #55
Closes #56
Closes #48
Closes #49
Closes #50

🤖 Generated with Claude Code

maceorichards and others added 18 commits November 3, 2026 21:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every text open(), os.fdopen() and text=True subprocess call in lib/sync.py and
smoke/drive.py names encoding="utf-8", so a cp1252-locale Windows run handles
non-ASCII skill text. Generated files (rewritten skill files, frontmatter,
codex agents/openai.yaml, managed marker, lock file, saved patches) are written
with newline="\n"; provider instructions files keep newline="", and the git
ignore append gains only the encoding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sync.sh now runs the first candidate that passes a 3.9+ check (the Windows
Store shim and older Pythons are skipped), with -I -X utf8. When none
qualifies it names the floor and every candidate tried and exits 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ore.autocrlf says

- .gitattributes declares `* text=auto eol=lf` (renormalize changed no file).
- New vendor clones are made with `-c core.autocrlf=false`, recorded in their config.
  An existing clone whose effective core.autocrlf is true gets a local false and one
  index drop plus hard reset; otherwise it is left untouched.
- Patches are read as UTF-8, CRLF turned into LF, and fed to
  `git -c core.autocrlf=false apply` on stdin, in both the build and `sync.sh edit`.
- sh() can send stdin input, as UTF-8 bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PNG signatures contain a CR byte; line endings only apply to text files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Forces core.autocrlf true before checkout, uses setup-python's python,
and checks the install and a no-change re-sync like fresh-install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tart

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the reset succeeds

The one-time CRLF repair of a vendor clone wrote core.autocrlf=false before
`git rm --cached` and `git reset --hard`. A failed reset (a locked file on
Windows) left an empty index and CRLF files, and the repair never retried.
Run rm/reset under `-c core.autocrlf=false` and persist the local setting
last; `--ignore-unmatch` lets the retry run on the emptied index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maceorichards
maceorichards merged commit 5250fb9 into develop Nov 4, 2026
5 checks passed
@maceorichards
maceorichards deleted the feat/iss-52-windows-install-fixes branch November 4, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment