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

Ouverte
#354 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
cli, devtools

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
TypeScript
Étoiles
360
Forks
27
Merge moyen
23 h 3 min
PR mergées (30 j)
15

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TanStack/intent

Toutes les issues de TanStack/intent

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.