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

Aperta Adatta ai principianti
#3,571 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, go, kubernetes
Ambito
backend, devops

Direzione di ricerca

Leggi go/core/internal/skillsinit/git.go, concentrandoti su CloneGit e sul percorso di checkout delle Full refs. L’issue fornisce una riproduzione minima con Git puro; conferma come vengono passati gli argomenti di checkout, poi esamina i test vicini relativi a questo comportamento. Il lavoro è concluso quando le refs SHA dei commit vengono estratte correttamente sulla linea 0.10 e le refs di branch e tag continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
4.1k
Fork
871
Merge medio
1g 8h
PR unite (30g)
183

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di kagent-dev/kagent

Tutte le issue di kagent-dev/kagent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.