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

未關閉
#354 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
72/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
node.js, typescript
領域
cli, devtools

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
TypeScript
星號
360
分支
27
平均合併
23 小時 3 分鐘
30 天內合併 PR
15

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/intent 的其他 Issue

查看 TanStack/intent 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。