skills-init: commit-SHA skill refs never start (git checkout -- <sha> reads the SHA as a pathspec)

Đang mở Phù hợp với người mới
#3,571 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
84/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ệ
git, go, kubernetes
Lĩnh vực
backend, devops

Hướng nghiên cứu

Đọc go/core/internal/skillsinit/git.go, tập trung vào CloneGit và đường dẫn checkout Full refs. Issue đưa ra một cách tái hiện tối thiểu chỉ dùng Git; hãy xác nhận các đối số checkout được truyền như thế nào, sau đó kiểm tra các bài kiểm thử gần đó cho hành vi này. Hoàn tất khi các ref SHA của commit được checkout thành công trên dòng 0.10 và các ref branch, tag vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What happens

An agent whose skills pin a commit SHA never leaves Init. skills-init fails with:

error: pathspec '<sha>' did not match any file(s) known to git
skills-init: clone <url>: exit status 1

Agents that pin a branch or tag are fine.

Why

CloneGit in go/core/internal/skillsinit/git.go takes the Full path for a commit SHA and runs:

if err := runGitIn(ref.Dest, "checkout", "--", ref.Ref); err != nil {

With the -- separator, git treats everything after it as a pathspec, not a revision. So the SHA is looked up as a file name and the checkout fails. The commit is present in the clone; only the argument parsing is wrong.

The comment above the call says the separator is there so "a ref starting with -" cannot be parsed as a flag, and notes that refs are already validated as 40-char hex when Full is true. That validation is real — the controller sets Full from isCommitSHA, which is ^[0-9a-fA-F]{40}$ — so a 40-character hex string can never be an option and the separator protects nothing.

Minimal reproduction

No kagent needed; this is plain git:

git clone https://github.com/<any>/<repo>.git /tmp/r
cd /tmp/r
git checkout -- "$(git rev-parse HEAD)"   # error: pathspec ... did not match any file(s) known to git
git checkout    "$(git rev-parse HEAD)"   # works

Fix

Drop the separator:

if err := runGitIn(ref.Dest, "checkout", ref.Ref); err != nil {

git checkout <sha> -- (separator last) also works, but the plain form is what the surrounding comment already describes.

Versions

Present in v0.10.4, v0.10.5 and v0.10.6 — the same line in all three.

Already fixed on main / v1.0.0-rc3, where CloneGit was rewritten to git fetch --depth 1 origin <commit> followed by git checkout --detach FETCH_HEAD. So this only affects the 0.10 line.

Impact

Any agent using skills.gitRefs with a commit SHA — which is the recommended way to pin skills — cannot start on 0.10.x. Branch and tag refs are unaffected.

Ngôn ngữ chính
Go
Star
4.1k
Fork
871
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
183

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kagent-dev/kagent

Tất cả issue của kagent-dev/kagent

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.