hooks: the edit gate counts a failed lookup and an unrun command as a check

Aberta
#354 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
cli, devtools

Direção de pesquisa

Start with .intent/hooks/intent-claude-gate.mjs, focusing on main() and the SessionStart and PreToolUse paths described in the issue. Trace createSessionCatalogContext, appendObservation, and parseIntentInvocation, then check the hook’s available PostToolUse handling. Done means failed or unrun lookups do not unlock edits, while a successful catalog shown at session start or a successful command run does.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Which version

@tanstack/intent 0.5.6. The hook was written by pnpm exec intent hooks install --scope project --agents claude, and the file is .intent/hooks/intent-claude-gate.mjs.

What happens

The gate lets edit tools through once the session's state file holds a list or a load (hasIntentCheck). Two paths write that record without the skills ever having been looked up.

1. A failed lookup at session start still counts as a check.

In main(), on SessionStart:

const additionalContext = await createSessionCatalogContext(rootForEvent(event))
appendObservation(stateFile, { action: 'list', raw: CATALOG_COMMAND })
if (additionalContext) {
  process.stdout.write(JSON.stringify(sessionStartOutput(additionalContext)))
}

createSessionCatalogContext catches every error and returns ''. So when the lookup fails (Intent not installed, the local CLI not found, the list command failing), no catalog is shown to the agent, but list is recorded anyway, and every edit is allowed from then on.

2. A proposed command is recorded before it has run.

The observation is taken in PreToolUse from the text of the Bash command (parseIntentInvocation), before the command runs and whatever it does. So these are recorded as a check, and unlock edits:

  • false && pnpm exec intent list (Intent never runs)
  • pnpm exec intent list when it then exits non-zero
  • a Bash call the user declines at the permission prompt
What I expected
  • On SessionStart, list is recorded only when the catalog was produced and handed to the agent.
  • A list or load typed by the agent is recorded once it has run and succeeded, for example from PostToolUse with the tool's result, not from the command text in PreToolUse.
Why it matters

The gate's promise is "the agent looked the skills up before its first edit". Both paths let a session edit with no skill list ever shown, and nothing tells the user that the lookup did not happen.

Happy to test a fix.

Linguagem predominante
TypeScript
Estrelas
360
Forks
27
Merge médio
23h 3min
PRs com merge (30d)
15

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de TanStack/intent

Todas as issues de TanStack/intent

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.