Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e799025
test(iss-52-t53): acceptance tests
maceorichards Nov 4, 2026
cf0c009
test(iss-52-t55): acceptance tests
maceorichards Nov 4, 2026
18e86c4
fix(iss-52-t53): read, write and decode all sync and smoke text as UTF-8
maceorichards Nov 4, 2026
324c871
Merge #53: UTF-8 for every text read and write in the sync and smoke …
maceorichards Nov 4, 2026
0cd4d8d
fix(iss-52-t55): probe python3, python, py -3 for Python 3.9+ in sync.sh
maceorichards Nov 4, 2026
25e288b
Merge branch 'feat/iss-52-windows-install-fixes' into feat/iss-52-win…
maceorichards Nov 4, 2026
d05b600
Merge #55: Interpreter probe in sync.sh
maceorichards Nov 4, 2026
95a8483
test(iss-52-t54): acceptance tests
maceorichards Nov 4, 2026
193623e
test(iss-52-t54): installed skills are LF under core.autocrlf=true
maceorichards Nov 4, 2026
c886553
fix(iss-52-t54): keep vendor clones and applied patches LF whatever c…
maceorichards Nov 4, 2026
5886d29
Merge branch 'feat/iss-52-windows-install-fixes' into feat/iss-52-win…
maceorichards Nov 4, 2026
59785f5
test(iss-52-t54): skip binary files in the vendor CR check
maceorichards Nov 4, 2026
1c5386a
Merge #54: LF line endings independent of the user's git config
maceorichards Nov 4, 2026
44b1a21
test(iss-52-t56): acceptance tests
maceorichards Nov 4, 2026
0ffb43b
ci(iss-52-t56): add a windows-latest fresh-install job under Git Bash
maceorichards Nov 4, 2026
9f2a789
docs(iss-52-t56): Windows line and one-time CRLF repair in the Quicks…
maceorichards Nov 4, 2026
0ff2d77
Merge #56: Windows CI job and README
maceorichards Nov 4, 2026
70de2de
fix(iss-52): persist the vendor repair's autocrlf setting only after …
maceorichards Nov 4, 2026
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,42 @@ jobs:
run: python3 -m unittest
env:
DEVFLOW_REQUIRE_VENDORS: "1"

windows-install:
# A fresh install under Git Bash with Git for Windows' default line endings.
# The unit suite doesn't run here yet (#51).
runs-on: windows-latest
steps:
- name: Force the default Windows line-ending setting
run: git config --global core.autocrlf true
- uses: actions/checkout@v4
- uses: actions/setup-python@v5 # provides python, not python3
with:
python-version: "3.x"
- name: Dry run
run: ./sync.sh --dry-run
- name: Sync
run: ./sync.sh
- name: Every manifest skill is installed and managed
run: |
python - <<'PY'
import json, os, sys
man = json.load(open("manifest.json", encoding="utf-8"))
root = os.path.expanduser("~/.claude/skills")
missing = [s["name"] for s in man["skills"]
if not os.path.isfile(os.path.join(root, s["name"], man["marker"]))]
if missing:
sys.exit("not installed with a %s marker in %s: %s" % (man["marker"], root, ", ".join(missing)))
print("%d managed skills in %s" % (len(man["skills"]), root))
PY
- name: Re-sync and dry run report no change
# Every status that changes something (or would) starts its line with one of these words.
run: |
for args in "" "--dry-run"; do
out=$(./sync.sh $args)
echo "$out"
if grep -E '^[[:space:]]*(installed|updated|removed|added|would|FAIL|WARN|SKIP)([[:space:]]|$)' <<<"$out"; then
echo "::error::./sync.sh $args reported a change after a full sync"
exit 1
fi
done
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Use it as is, or fork it to choose your own skills: edit `manifest.json`, then r

**Prerequisites:** Python 3.9+, git, the GitHub CLI `gh` signed in (`gh auth login`), and one supported provider (see [Providers](#providers)). GitHub is the only tracker the workflows support.

**Windows:** run everything from Git Bash, with Python 3.9+ from python.org or the Microsoft Store.

```bash
git clone https://github.com/maceorichards/devflow.git
cd devflow
Expand All @@ -17,6 +19,8 @@ cd devflow

The dry run clones the upstream skill repos into `vendor/` at the locked commits and shows what would change, writing nothing outside the clone. The second command builds and installs for Claude Code; to pick other providers, run `./sync.sh providers <list>` instead. Then, in each project, run `/setup-devflow-skills` once (see [Workflows](#workflows)).

If you cloned on Windows before the line-ending fix, bash rejects `sync.sh`. Repair the clone once: commit or stash your changes, then run `git rm -rq --cached . && git reset -q --hard`, or clone again. `devflow.local.json` and `vendor/` are git-ignored and aren't affected.

What the sync edits outside the clone:
- Each selected provider's skills folder (e.g. `~/.claude/skills`): only folders it marks with `.managed-by-devflow`. A folder of the same name without the marker is skipped.
- The devflow section of each provider's instructions file (e.g. `~/.claude/CLAUDE.md`), between `devflow` markers. The rest of the file is left alone.
Expand Down
82 changes: 54 additions & 28 deletions lib/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,26 @@
MD_END = "<!-- devflow:end -->"


def sh(args, cwd=None, check=True):
r = subprocess.run(args, cwd=cwd, capture_output=True, text=True)
def sh(args, cwd=None, check=True, input=None):
"""Run a command; its stdout and stderr come back as UTF-8 text. `input` (text) goes to
stdin as UTF-8 bytes, because a text-mode stdin turns LF into CRLF on Windows."""
if input is None:
r = subprocess.run(args, cwd=cwd, capture_output=True, text=True, encoding="utf-8")
else:
r = subprocess.run(args, cwd=cwd, input=input.encode("utf-8"), capture_output=True)
r.stdout, r.stderr = (b.decode("utf-8", "replace").replace("\r\n", "\n")
for b in (r.stdout, r.stderr))
if check and r.returncode != 0:
raise RuntimeError(f"{' '.join(args)} failed:\n{r.stdout}{r.stderr}")
return r


def load():
with open(MANIFEST) as f:
with open(MANIFEST, encoding="utf-8") as f:
man = json.load(f)
lock = {}
if os.path.exists(LOCK):
with open(LOCK) as f:
with open(LOCK, encoding="utf-8") as f:
lock = json.load(f)
return man, lock

Expand All @@ -55,7 +62,18 @@ def ensure_vendor(man, src, sha=None):
d = vendor_dir(man, src)
if not os.path.isdir(os.path.join(d, ".git")):
print(f"cloning {src} …")
sh(["git", "clone", "-q", man["vendors"][src]["url"], d])
# -c on clone checks out LF and records core.autocrlf=false in the clone's config.
sh(["git", "clone", "-q", "-c", "core.autocrlf=false", man["vendors"][src]["url"], d])
elif sh(["git", "config", "--get", "core.autocrlf"], cwd=d, check=False).stdout.strip() == "true":
# A clone checked out with CRLF (Windows' default): make it LF once. Vendor clones
# are never edited, so dropping the index and resetting loses nothing. The setting is
# persisted only after the reset succeeds: if it fails (a locked file), the trigger
# still reads true and the next sync retries (on an index the failed reset left empty,
# hence --ignore-unmatch).
sh(["git", "-c", "core.autocrlf=false", "rm", "-q", "--cached", "-r", "--ignore-unmatch", "."],
cwd=d)
sh(["git", "-c", "core.autocrlf=false", "reset", "-q", "--hard"], cwd=d)
sh(["git", "config", "--local", "core.autocrlf", "false"], cwd=d)
if sha:
cur = sh(["git", "rev-parse", "HEAD"], cwd=d).stdout.strip()
if cur != sha:
Expand All @@ -76,7 +94,7 @@ def write_atomic(path, text, newline=None):
mode = 0o666 & ~umask
fd, tmp = tempfile.mkstemp(dir=os.path.dirname(path), prefix=f".{os.path.basename(path)}.")
try:
with os.fdopen(fd, "w", newline=newline) as f:
with os.fdopen(fd, "w", encoding="utf-8", newline=newline) as f:
f.write(text)
os.chmod(tmp, mode)
os.replace(tmp, path)
Expand All @@ -88,7 +106,7 @@ def write_atomic(path, text, newline=None):

# --------------------------------------------------------------------- frontmatter
def set_frontmatter(path, skill):
with open(path) as f:
with open(path, encoding="utf-8") as f:
txt = f.read()
m = re.match(r"---\n(.*?)\n---\n", txt, re.S)
if not m:
Expand All @@ -104,7 +122,7 @@ def set_frontmatter(path, skill):
if skill["tier"] == "slash":
out.append("disable-model-invocation: true")
new = "---\n" + "\n".join(out) + "\n---\n" + txt[m.end():]
with open(path, "w") as f:
with open(path, "w", encoding="utf-8", newline="\n") as f:
f.write(new)


Expand All @@ -113,7 +131,7 @@ def set_codex_policy(stage, skill):
path = os.path.join(stage, "agents", "openai.yaml")
lines = []
if os.path.exists(path):
with open(path) as f:
with open(path, encoding="utf-8") as f:
lines = f.read().split("\n")
# drop any top-level policy: block (that line and its indented children)
kept, skipping = [], False
Expand All @@ -133,11 +151,20 @@ def set_codex_policy(stage, skill):
os.remove(path)
return
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w") as f:
with open(path, "w", encoding="utf-8", newline="\n") as f:
f.write(text + "\n")


# --------------------------------------------------------------------- build
def apply_patch(rel, cwd):
"""`git apply` the patch at ROOT/rel in cwd. The patch is read as UTF-8 with CRLF turned
into LF, and core.autocrlf is off, so neither the checkout nor git config adds a CR."""
with open(os.path.join(ROOT, rel), encoding="utf-8", newline="") as f:
text = f.read().replace("\r\n", "\n")
return sh(["git", "-c", "core.autocrlf=false", "apply", "--whitespace=nowarn", "-p1"],
cwd=cwd, check=False, input=text)


def build_skill(man, skill, stage_root):
"""Return (staged_dir, error_or_None)."""
stage = os.path.join(stage_root, skill["name"])
Expand All @@ -149,8 +176,7 @@ def build_skill(man, skill, stage_root):
return stage, f"source missing: {src}"
shutil.copytree(src, stage)
if skill.get("patch"):
patch = os.path.join(ROOT, skill["patch"])
r = sh(["git", "apply", "--whitespace=nowarn", "-p1", patch], cwd=stage, check=False)
r = apply_patch(skill["patch"], stage)
if r.returncode != 0:
return stage, f"patch failed: {skill['patch']}\n{r.stderr.strip()}"
# Text rewrites on every .md and .yaml file, after the patch: the vendor's prefix is
Expand All @@ -165,13 +191,13 @@ def build_skill(man, skill, stage_root):
for fn in files:
if fn.endswith((".md", ".yaml")):
p = os.path.join(dp, fn)
with open(p) as f:
with open(p, encoding="utf-8") as f:
t = f.read()
new = t
for old, rep in subs:
new = new.replace(old, rep)
if new != t:
with open(p, "w") as f:
with open(p, "w", encoding="utf-8", newline="\n") as f:
f.write(new)
set_frontmatter(os.path.join(stage, "SKILL.md"), skill)
set_codex_policy(stage, skill)
Expand Down Expand Up @@ -200,7 +226,7 @@ def install(man, skill, stage, lock, dry, dest_root):
if dry:
return f"would {action}"
os.makedirs(dest_root, exist_ok=True)
with open(os.path.join(stage, marker), "w") as f:
with open(os.path.join(stage, marker), "w", encoding="utf-8", newline="\n") as f:
src = skill["source"]
f.write(json.dumps({"source": src, "path": skill["path"],
"commit": lock.get(src, "owned"), "tier": skill["tier"]}) + "\n")
Expand Down Expand Up @@ -288,7 +314,7 @@ def git_ignore_target():
try:
r = subprocess.run(["git", "config", "--global", "--includes", "--type=path", "--get",
"core.excludesFile"],
capture_output=True, text=True)
capture_output=True, text=True, encoding="utf-8")
except OSError as e:
raise ValueError(f"could not read core.excludesFile ({e})")
if r.returncode not in (0, 1):
Expand Down Expand Up @@ -325,12 +351,12 @@ def unreadable_skip(tilde_path):

def sync_instructions(tilde_path, dry):
path = os.path.expanduser(tilde_path)
with open(os.path.join(ROOT, "global", "claude-md-section.md")) as f:
with open(os.path.join(ROOT, "global", "claude-md-section.md"), encoding="utf-8") as f:
section = f.read().replace("{{clone}}", clone_path()).strip() + "\n"
cur = ""
if os.path.exists(path):
try:
with open(path, newline="") as f:
with open(path, encoding="utf-8", newline="") as f:
cur = f.read()
except (UnicodeDecodeError, OSError):
return unreadable_skip(tilde_path)
Expand All @@ -356,7 +382,7 @@ def remove_instructions(tilde_path, dry):
if not os.path.isfile(path):
return None
try:
with open(path, newline="") as f:
with open(path, encoding="utf-8", newline="") as f:
cur = f.read()
except (UnicodeDecodeError, OSError):
return unreadable_skip(tilde_path)
Expand All @@ -379,7 +405,7 @@ def remove_instructions(tilde_path, dry):


def sync_git_ignore(dry):
with open(os.path.join(ROOT, "global", "git-ignore-lines")) as f:
with open(os.path.join(ROOT, "global", "git-ignore-lines"), encoding="utf-8") as f:
want = [l.strip() for l in f if l.strip() and not l.startswith("#")]
manual = "add these lines yourself: " + ", ".join(want)
try:
Expand All @@ -390,15 +416,15 @@ def sync_git_ignore(dry):
missing = want # nothing is known to be present until the file has been read
action = "read"
try:
cur = open(target).read() if os.path.exists(target) else ""
cur = open(target, encoding="utf-8").read() if os.path.exists(target) else ""
have = {l.strip() for l in cur.splitlines()}
missing = [l for l in want if l not in have]
if not missing:
return f"git ignore lines present in {shown}"
if not dry:
action = "write"
os.makedirs(os.path.dirname(target), exist_ok=True)
with open(target, "a") as f:
with open(target, "a", encoding="utf-8") as f:
if cur and not cur.endswith("\n"):
f.write("\n")
if "# devflow" not in cur:
Expand Down Expand Up @@ -429,7 +455,7 @@ def selected_providers(man):
if not os.path.exists(LOCAL):
return ["claude"]
try:
with open(LOCAL) as f:
with open(LOCAL, encoding="utf-8") as f:
names = json.load(f)["providers"]
except (OSError, ValueError, KeyError, TypeError):
names = None
Expand Down Expand Up @@ -567,7 +593,7 @@ def update(man, lock):


def save_lock(lock):
with open(LOCK, "w") as f:
with open(LOCK, "w", encoding="utf-8", newline="\n") as f:
json.dump(lock, f, indent=2)
f.write("\n")

Expand All @@ -591,17 +617,17 @@ def edit(man, lock, name):
shutil.copytree(src, os.path.join(work, "a"))
shutil.copytree(src, os.path.join(work, "b"))
if skill.get("patch") and os.path.exists(os.path.join(ROOT, skill["patch"])):
sh(["git", "apply", "--whitespace=nowarn", "-p1", os.path.join(ROOT, skill["patch"])],
cwd=os.path.join(work, "b"), check=False)
apply_patch(skill["patch"], os.path.join(work, "b"))
print(f"Edit {work}/b (upstream + current patch), then run: sync.sh save {name}")


def save(man, name):
skill = find_skill(man, name)
work = os.path.join(ROOT, ".patch-work", name)
r = subprocess.run(["diff", "-ruN", "a", "b"], cwd=work, capture_output=True, text=True)
r = subprocess.run(["diff", "-ruN", "a", "b"], cwd=work, capture_output=True, text=True,
encoding="utf-8")
patch_rel = skill.get("patch") or f"patches/{name}.patch"
with open(os.path.join(ROOT, patch_rel), "w") as f:
with open(os.path.join(ROOT, patch_rel), "w", encoding="utf-8", newline="\n") as f:
f.write(r.stdout)
if not skill.get("patch"):
print(f"Add \"patch\": \"{patch_rel}\" to {name} in manifest.json")
Expand Down
9 changes: 5 additions & 4 deletions smoke/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,25 @@ class Fail(Exception):
def run(argv, cwd):
"""(exit code, stdout, stderr) of argv, with no shell and no stdin."""
try:
r = subprocess.run(argv, cwd=cwd, stdin=subprocess.DEVNULL, capture_output=True, text=True)
r = subprocess.run(argv, cwd=cwd, stdin=subprocess.DEVNULL, capture_output=True, text=True,
encoding="utf-8")
except OSError as e:
return 127, "", f"{argv[0]}: {e}\n"
return r.returncode, r.stdout, r.stderr


def write(path, text):
with open(path, "w") as f:
with open(path, "w", encoding="utf-8") as f:
f.write(text)


def read(path):
with open(path) as f:
with open(path, encoding="utf-8") as f:
return f.read()


def load_agent(name):
with open(AGENTS) as f:
with open(AGENTS, encoding="utf-8") as f:
table = json.load(f)
if name not in table:
raise Fail(f"unknown agent {name!r}; agents.json has {', '.join(sorted(table))}")
Expand Down
15 changes: 14 additions & 1 deletion sync.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#!/usr/bin/env bash
# devflow: rebuild and install managed skills. See README.md.
set -euo pipefail
exec python3 -I "$(cd "$(dirname "$0")" && pwd)/lib/sync.py" "$@"
here="$(cd "$(dirname "$0")" && pwd)"

# Interpreter probe: the first candidate that runs and is Python 3.9+ wins. A missing command,
# the Windows Store shim (exits non-zero) or an older Python fails the check and is skipped.
check='import sys; sys.exit(0 if tuple(sys.version_info[:2]) >= (3, 9) else 1)'
for candidate in python3 python "py -3"; do
# $candidate is unquoted on purpose: "py -3" is a command plus its argument.
if $candidate -I -c "$check" >/dev/null 2>&1; then
exec $candidate -I -X utf8 "$here/lib/sync.py" "$@"
fi
done

echo "devflow needs Python 3.9+; tried: python3, python, py -3" >&2
exit 1
Loading
Loading