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

Abierto Apto para principiantes
#3,571 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
git, go, kubernetes
Área
backend, devops

Línea de trabajo

Lee go/core/internal/skillsinit/git.go, centrándote en CloneGit y en la ruta de checkout de Full refs. El issue incluye una reproducción mínima con Git sin capas adicionales; confirma cómo se pasan los argumentos de checkout y después revisa las pruebas cercanas para este comportamiento. El trabajo estará terminado cuando las refs de SHA de commit se puedan extraer correctamente en la línea 0.10 y las refs de ramas y etiquetas sigan funcionando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
4.1k
Forks
871
Merge medio
1 d 8 h
PR fusionados (30 d)
183

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kagent-dev/kagent

Todos los issues de kagent-dev/kagent

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.