[hooks] SessionStart injects the knowledge-update frontmatter on a CRLF checkout
Maintainer thường phản hồi trong vòng 1 ngày
@abhiramshaji-cyber đang làm issue này rồi.
Từ ngày 17/11/2026.
- #430 của @abhiramshaji-cyber — đang mở
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 86/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
Hướng nghiên cứu
Đọc hooks/src/inject-claude-md.mts, đặc biệt là stripFrontmatter và hàm gọi nó, main; so sánh với trình phân tích cú pháp hiện có trong hooks/src/skill-map-frontmatter.mts, có xử lý CRLF và BOM. Tái hiện lỗi bằng cách chuyển đổi CRLF của issue và chạy hook bắt đầu phiên cho cả hai phần. Hoàn tất khi các đầu vào LF, CRLF và BOM bỏ qua frontmatter, và phần 2 bắt đầu bằng tiêu đề tiếp nối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hope you're doing well! On a checkout with CRLF line endings, the SessionStart hook injects the whole YAML frontmatter of skills/knowledge-update/SKILL.md into the session context, because its frontmatter regex only matches LF.
What this code is for
hooks/inject-claude-md.mjs runs at SessionStart for Claude Code and Cursor (--part 1/2 and --part 2/2 in hooks.json). It reads vercel-session.md and skills/knowledge-update/SKILL.md with a plain readFileSync (safeReadFile), drops the SKILL.md frontmatter, and splits the result into parts that stay under Claude Code's hook output cap. The splitting work from the recent PRs is really nice, and it is why the part 2 header matters below.
Current behaviour
- Someone installs the plugin on Windows. The marketplace install is a git clone, and the repo has no
.gitattributes, so Git for Windows withcore.autocrlf=truechecks every file out with CRLF (#119 showsi/lf w/crlfon a real checkout). - A session starts and
inject-claude-md.mjsreads SKILL.md, which now starts with---\r\n. stripFrontmatterruns/^---\n[\s\S]*?\n---\n?([\s\S]*)$/, which needs\nright after---, so it does not match and returns the whole file.- The whole frontmatter block (23 lines with the
---lines:name: knowledge-update,description: ...,metadata, ...) goes into the Claude Code text and the Cursoradditional_context. - The first line of the knowledge update is now
---, not# Vercel Knowledge Updates (...), so part 2 loses its(continued)header, and every line keeps its\r.
Expected behaviour
The frontmatter is dropped the same way on LF, CRLF and BOM files, and part 2 starts with # Vercel Knowledge Updates (...) (continued).
Minimal repro (on main at 90cc681)
mkdir /tmp/vp && cp -R hooks skills vercel-session.md /tmp/vp/ && cd "$(cd /tmp/vp && pwd -P)"
perl -pi -e 's/\n/\r\n/' skills/knowledge-update/SKILL.md
echo '{"session_id":"x"}' | VERCEL_PLUGIN_GREENFIELD=true node "$PWD/hooks/inject-claude-md.mjs" | grep -c '^name: knowledge-update'
# 1, expected 0
echo '{"session_id":"x"}' | VERCEL_PLUGIN_GREENFIELD=true node "$PWD/hooks/inject-claude-md.mjs" --part 2/2 | head -1 | cat -v
# ## New products LLMs may not know about^M (no "(continued)" header, and a \r on every line)
(pwd -P because the hook only runs when its real path matches argv[1], and /tmp is a symlink on macOS; the greenfield flag just makes it inject outside a Vercel project.)
Why only this entry point
hooks/src/skill-map-frontmatter.mts already has a CRLF and BOM aware extractFrontmatter, and the OpenCode entry point already uses it for the same file (extractFrontmatter(knowledgeUpdate).body.trim()). inject-claude-md has its own copy that never got the CRLF handling.

stripFrontmatter and its only caller, main in inject-claude-md.mts, Functions view in Architect

extractFrontmatter and its callers, the OpenCode buildSessionContext among them, Functions view in Architect
flowchart LR
classDef box fill:#eef1ff,stroke:#4c5bd4,color:#111827
classDef bad fill:#ffd6d6,stroke:#cc0000,color:#111827,stroke-width:3px
classDef good fill:#c8f0c8,stroke:#008800,color:#111827,stroke-width:3px
F["SKILL.md checked out with CRLF"] --> C["inject-claude-md main, Claude Code and Cursor"]
F --> O["opencode-plugin buildSessionContext"]
C --> S{"stripFrontmatter, LF only"}
O --> E{"extractFrontmatter, CRLF and BOM aware"}
S -->|"no match"| SB["frontmatter injected, no continued header"]
E -->|"match"| EB["body only"]
class F,C,O box
class S,SB bad
class E,EB good
This is related to #119 (CRLF in the build scripts) but a separate path, since this one runs on every session start.
A question
Would you be happy with inject-claude-md reusing extractFrontmatter so both entry points share one parser? I have a small PR ready that does that, also has the part splitter work on LF text, and adds a CRLF and BOM test for the session start output. I left .gitattributes out of it on purpose. Would a * text=auto eol=lf there be welcome too, maybe together with #119, or would you rather keep the code tolerant and not touch checkout settings? Happy to go either way, and thanks for taking a look!
- Ngôn ngữ chính
- TypeScript
- Star
- 336
- Fork
- 80
- Merge trung bình
- 3 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 68
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của vercel/vercel-plugin
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
vercel/vercel-plugin#388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
vercel/vercel-plugin#312 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
vercel/vercel-plugin#311 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 78/100
vercel/vercel-plugin#199 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
vercel/vercel-plugin#182 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của vercel/vercel-plugin
Issue tương tự
-
status/need-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google-gemini/gemini-cli#30328 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
severity:medium triage:confirmed triage:in-progress triage:reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Cotal-AI/Cotal#7231 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
boxlite-ai/boxlite#2777 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug P3
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày