Skip to content

Commit 3e55bef

Browse files
acn-ericlawclaude
andcommitted
feat: Windows line-ending hardening — .gitattributes pins *.sh + .githooks/* to LF (v4.20.2)
A Copilot Windows-feasibility check confirmed the bootstrap works via Git Bash but missed the CRLF trap: with no .gitattributes, a Windows clone (core.autocrlf=true) rewrites *.sh + .githooks/* to CRLF and bash fails ('bad interpreter: /usr/bin/env bash^M'). Adds .gitattributes (root + templates/) + ENABLE Step 7b + a 4.20.1->4.20.2 rung to install/merge it additively. Makes the bootstrap + hooks robust on Windows (Git Bash / WSL). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4aa389b commit 3e55bef

10 files changed

Lines changed: 94 additions & 3 deletions

File tree

‎.gitattributes‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# agent-memory — keep executable scripts + git hooks LF so bash runs them on Windows (Git Bash / WSL).
2+
# Git for Windows defaults to core.autocrlf=true; without this, *.sh and .githooks/* would be rewritten
3+
# to CRLF on checkout and bash would fail with "bad interpreter: /usr/bin/env bash^M".
4+
*.sh text eol=lf
5+
.githooks/* text eol=lf

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
> introduced after 3.0.0 shipped), organized by capability rather than by individual
1212
> commit. The capability ladder matches `VERSION` and `UPGRADE.md`.
1313
14+
## Version 4.20.2, 6/24/2026
15+
16+
> **Windows line-ending hardening (PATCH).** Adds a **`.gitattributes`** pinning `*.sh` and `.githooks/*`
17+
> to **LF**, so Git for Windows (`core.autocrlf=true` by default) doesn't rewrite them to CRLF on checkout —
18+
> which would break bash (`bad interpreter: /usr/bin/env bash^M`) and silently disable the hook + `init.sh`.
19+
> From a Copilot Windows-feasibility check: the bootstrap works via Git Bash/WSL, but without this it was
20+
> luck-of-the-default. Now robust on Windows.
21+
22+
### Added
23+
- **`.gitattributes`** (root + `templates/`) — `*.sh text eol=lf`, `.githooks/* text eol=lf`. Installed /
24+
merged into targets additively (ENABLE Step 7b + a `4.20.1 → 4.20.2` rung), same discipline as the
25+
`.gitignore` block. `VERSION` → 4.20.2.
26+
1427
## Version 4.20.1, 6/24/2026
1528

1629
> **Self-init folded into `copilot-instructions.md` (PATCH).** A fresh-clone dogfood showed v4.20.0's

‎ENABLE.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,22 @@ add. Adding a path to `.gitignore` does not untrack files already committed, so
478478
is safe even if a vendor dir was previously committed (e.g. before a Mode C migration
479479
moved it to `legacy/`).
480480

481+
### Step 7b — Install / merge `.gitattributes` (Windows line-ending hardening, v4.20.2)
482+
483+
The executable scripts (`*.sh`) and git hooks (`.githooks/*`) **must stay LF**, or Git for Windows
484+
(`core.autocrlf=true` by default) rewrites them to CRLF on checkout and bash fails with
485+
`bad interpreter: /usr/bin/env bash^M`. The canonical rules live in `templates/.gitattributes`:
486+
487+
```
488+
*.sh text eol=lf
489+
.githooks/* text eol=lf
490+
```
491+
492+
Apply additively (same discipline as `.gitignore`): **no `.gitattributes`** → copy
493+
`templates/.gitattributes` verbatim; **exists** → add only the LF rules not already present
494+
(de-duplicate; never remove/reorder the user's entries). After adding, run `git add --renormalize .`
495+
(a no-op if the files are already LF) so the index reflects the attributes.
496+
481497
---
482498

483499
## Step 8 — Verify

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ it in place** — additively, never destructively.
214214
| 4.19.0 | **Vendor-neutral ritual triggers:** the after-session ritual no longer depends on the agent self-triggering (which failed in practice — skipped even with Claude; Copilot-only teams had no triggers). Enable installs a committed **`.githooks/post-commit`** (auto-stubs a session log when a commit does real work without one; re-syncs adapters) — **agent-activated** via `core.hooksPath`, zero manual user step — plus a **CI floor** (`.github/workflows/agent-memory.yml`: `memory-lint` + advisory session-log check on push/PR, zero per-user setup). Advisory by default (opt-in `AGENT_MEMORY_STRICT` gate); `no-build-step-agent-run` holds (git/CI invoke them; the tool runs nothing). Honest limit: git can't auto-run hooks on a bare clone → CI is the backstop. Design: `docs/DESIGN-ritual-triggers.md` |
215215
| 4.20.0 | **First-run init for fresh clones:** a Copilot dogfood showed a fresh clone self-initializes the *memory* bootstrap but not the gitignored adapters or the (unactivated) hook. Adds **`.githooks/init.sh`** (one idempotent command: regenerate adapters + activate the hook) + an **`AGENTS.md` self-init note** so the agent does it on its first session — one step (or one human command) instead of two. CI stays the zero-config floor |
216216
| 4.20.1 | **Self-init in `copilot-instructions.md`:** v4.20.0's self-init reached Claude but not Copilot CLI (its `start` front-loads `copilot-instructions.md` + summarizes). Folds the first-run init into the top of `copilot-instructions.md` so Copilot runs `bash .githooks/init.sh` before summarizing; the `init.sh` fallback + CI floor are unchanged |
217+
| 4.20.2 | **Windows line-ending hardening:** a `.gitattributes` pins `*.sh` + `.githooks/*` to LF so Git for Windows (`core.autocrlf=true`) doesn't rewrite them to CRLF and break bash (`bad interpreter: …^M`). Installed/merged into targets additively. Makes the bootstrap + hooks robust on Windows (Git Bash / WSL), not luck-of-the-default. From a Copilot Windows-feasibility check |
217218

218219

219220
When you "AI enable" a repo that's already on an older version, Mode B detects the

‎UPGRADE.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ The current tool version lives in the root **`VERSION`** file (semver):
6565
| 4.19.0 | **Vendor-neutral ritual triggers (MINOR):** the after-session ritual no longer relies on the agent self-triggering. Enable installs a committed **`.githooks/post-commit`** (auto-stubs a session log when a commit does real work without one; re-syncs adapters), **agent-activated** via `git config core.hooksPath .githooks` (no manual user step), plus a **CI floor** (`.github/workflows/agent-memory.yml`: `memory-lint` + advisory session-log check on push/PR, zero per-user setup). Advisory by default (opt-in `AGENT_MEMORY_STRICT=1` gate); `no-build-step-agent-run` holds (git/CI invoke them; the tool runs nothing). Honest limit: git can't auto-run hooks on a bare clone → CI is the backstop. From real client-team pain (ritual not followed even with Claude; Copilot-only teams had no triggers) + the zero-manual/untrained-user constraint; design `docs/DESIGN-ritual-triggers.md` |
6666
| 4.20.0 | **First-run init (MINOR):** closes the fresh-clone activation gap (Copilot dogfood: the memory bootstrap self-initializes, but a clone has the gitignored adapters **absent** + the hook **unactivated**). Adds **`.githooks/init.sh`** (one idempotent command: regenerate adapters + `git config core.hooksPath .githooks`) + an **`AGENTS.md` self-init note** so the agent does it on its first session. One agent-run step (or one human command) instead of two; CI stays the zero-config floor |
6767
| 4.20.1 | **Self-init in `copilot-instructions.md` (PATCH):** v4.20.0's self-init reached Claude (acts on `AGENTS.md`) but **not Copilot CLI** (its `start` front-loads `copilot-instructions.md` + summarizes — so on a fresh clone the hook stayed inactive + adapters absent). Folds the first-run init into the **top of `copilot-instructions.md`** so Copilot runs `bash .githooks/init.sh` before summarizing. Re-sync that one file; the `init.sh` fallback + CI floor are unchanged |
68+
| 4.20.2 | **Windows line-ending hardening (PATCH):** adds a **`.gitattributes`** pinning `*.sh` + `.githooks/*` to **LF**, so Git for Windows (`core.autocrlf=true`) doesn't rewrite them to CRLF on checkout (which breaks bash: `bad interpreter: /usr/bin/env bash^M`, silently disabling the hook + `init.sh`). Installed/merged into targets additively (like the `.gitignore` block). Makes the bootstrap + hooks robust on Windows (Git Bash / WSL), not luck-of-the-default. From a Copilot Windows-feasibility check |
6869

6970

7071
Each enabled repo records what it is on in **`.agent/version.md`**:
@@ -1133,3 +1134,19 @@ acting on the AGENTS.md self-init (hook stayed inactive, adapters absent).
11331134
and `mode`.
11341135
3. **Report**: `copilot-instructions.md` now carries the first-run self-init (Copilot acts before
11351136
summarizing); the `bash .githooks/init.sh` fallback + CI floor are unchanged.
1137+
1138+
## Rung: 4.20.1 → 4.20.2 — Windows line-ending hardening (PATCH)
1139+
1140+
Additive: a `.gitattributes` that keeps the executable scripts + git hooks LF, so they run under bash on
1141+
Windows. No memory-file shape change. Surfaced from a Copilot Windows-feasibility check — the bootstrap
1142+
works via Git Bash, but with **no `.gitattributes`** a Windows clone (`core.autocrlf=true` by default)
1143+
rewrites `*.sh` + `.githooks/*` to CRLF and bash fails (`bad interpreter: /usr/bin/env bash^M`).
1144+
1145+
1. **Install / merge `.gitattributes`** (per ENABLE Step 7b): if the target has none, copy
1146+
`templates/.gitattributes` verbatim; if it has one, **add only** the LF rules not already present
1147+
(`*.sh text eol=lf`, `.githooks/* text eol=lf`) — de-duplicate; never remove/reorder existing entries.
1148+
Then `git add --renormalize .` (a no-op if the files are already LF).
1149+
2. **Stamp** `.agent/version.md` → `version: 4.20.2`, `last_upgraded: <today>`, preserving `enabled_with`
1150+
and `mode`.
1151+
3. **Report**: `.gitattributes` added/merged (LF for `*.sh` + `.githooks/*`); the bootstrap + hooks are now
1152+
robust on Windows (Git Bash / WSL).

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.20.1
1+
4.20.2

‎docs/DESIGN-ritual-triggers.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
> **+ 4.20.1:** self-init also folded into **`copilot-instructions.md`** — a fresh-clone dogfood showed
1313
> Claude self-inits (it acts on `AGENTS.md`) but Copilot CLI did **not** (its `start` front-loads
1414
> `copilot-instructions.md` + summarizes), so the first-run init now **leads** that file too.
15+
> **+ 4.20.2:** a `.gitattributes` pins `*.sh` + `.githooks/*` to **LF** so they run under bash on Windows
16+
> (Git Bash / WSL) regardless of `core.autocrlf` — Windows-hardening from a Copilot feasibility check
17+
> (otherwise a Windows clone rewrites them to CRLF and bash fails). **Validated cross-platform on the
18+
> happy path; Windows now robust, not luck-of-the-default.**
1519
> Sibling to `DESIGN-evolving-memory.md`, `DESIGN-vbdi-lifecycle.md`, `DESIGN-skills-layer.md`, and
1620
> `DESIGN-fresh-context-review.md`. Realizes the `(blueprint)` gap **`bp-ritual-triggers`** →
1721
> serves `vision-agent-memory`.

0 commit comments

Comments
 (0)