Evaluate: Typed tool hooks (beforeToolCall/afterToolCall) for terraphim-skills
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
Línea de trabajo
Read ~/.claude/hooks/pre_tool_use.sh and ~/.claude/hooks/post_tool_use.sh to understand the current shell-hook contracts, then review knowledge/claude-agent-sdk-reference.md and the linked Pi hook design. Define a compatible Rust trait, compare shell invocation with Rust dispatch, and prototype the git-safety guard. Done means the benchmark, prototype, and an explicit adopt, retain, or hybrid decision are documented.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Parent Epic
#682 -- Evaluate Pi architectural patterns
Pattern
Pi's agent-core provides typed hooks at the tool execution boundary:
beforeToolCall: async ({ toolCall, args, context }) => {
if (toolCall.name === "bash" && args.command.includes("rm -rf")) {
return { block: true, reason: "Destructive command blocked" };
}
}
afterToolCall: async ({ toolCall, result, isError, context }) => {
return { details: { ...result.details, audited: true } };
}
These hooks:
- Run after argument validation but before execution (beforeToolCall)
- Can block execution with a typed reason
- Can modify tool results before they reach the LLM (afterToolCall)
- Are in-process callbacks with full type safety (not JSON over shell)
Current State
terraphim-skills hooks system:
- PreToolUse (
~/.claude/hooks/pre_tool_use.sh): git safety guard + KG text replacement. Shell script, receives JSON on stdin, returns JSON on stdout. - PostToolUse (
~/.claude/hooks/post_tool_use.sh): learning capture for failed commands. Shell script. - Both are shell commands -- no type safety, JSON parsing overhead, subprocess spawn cost.
Claude Code hooks:
- 22 lifecycle events
- Shell command, HTTP POST, or prompt/agent types
- JSON-based input/output contract
- Exit code 2 for blocking
Claude Agent SDK hooks:
- Callback functions (Python/TypeScript) -- closer to Pi's model
- Typed input objects, structured output
permissionDecision: "deny"for blocking
Evaluation Questions
- Should terraphim-skills adopt typed Rust hooks? Current shell hooks have subprocess overhead (~50ms per invocation). A Rust-native hook system would be sub-millisecond.
- What's the right abstraction? Pi uses
{ block: true, reason }. Claude uses{ permissionDecision: "deny", permissionDecisionReason }. terraphim could use a trait:fn before_tool_call(&self, tool: &ToolCall, args: &Value) -> HookResult. - Does this replace or complement shell hooks? Shell hooks are user-facing (CLAUDE.md configurable). Rust hooks would be for skill/extension developers.
- Integration with terraphim-skills Markdown format: Skills are currently Markdown files. Typed hooks would require a Rust module alongside the Markdown. Is this acceptable complexity?
Acceptance Criteria
- Design a Rust hook trait compatible with terraphim-skills
- Benchmark: shell hook invocation time vs Rust trait dispatch
- Prototype: port git-safety-guard from shell to Rust hook
- Decision: adopt Rust hooks, keep shell-only, or hybrid approach
References
- Pi beforeToolCall/afterToolCall: https://github.com/badlogic/pi-mono/tree/main/packages/agent
- Current shell hooks: ~/.claude/hooks/pre_tool_use.sh, ~/.claude/hooks/post_tool_use.sh
- terraphim-skills: https://github.com/terraphim/terraphim-skills
- Claude Agent SDK hooks: knowledge/claude-agent-sdk-reference.md
- Lenguaje dominante
- Rust
- Estrellas
- 64
- Forks
- 5
- Merge medio
- 1 h 17 min
- PR fusionados (30 d)
- 2
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de terraphim/terraphim-ai
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
terraphim/terraphim-ai#885 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
terraphim/terraphim-ai#871 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
terraphim/terraphim-ai#810 · 2 comentarios ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
terraphim/terraphim-ai#729 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
terraphim/terraphim-ai#728 ·
Todos los issues de terraphim/terraphim-ai
Issues similares
-
discover: `sudo RTK_DISABLED=$VAR …` is not detected as a bypass when `sudo` is a transparent prefixAbiertoarea:cli bug good first issue priority:medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rtk-ai/rtk#4412 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[review-skill] Unresolved review threads need paginated GraphQL; first:100 silently truncatesAbiertoskill:code-review
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
component:sight
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
agentic-os-org/ANOLISA#4115 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
rivet-dev/rivet#5819 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
A-io-database bug needs triage python
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día