makecindy / makecindy/cindy

扩展 Cindy hook 的事件载荷与 session context

Open
#1,112 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

**提交人**: Yop
**客户端版本**: 0.1.22

---

## 使用场景

当前 Cindy hook 的事件载荷非常有限。尤其是 will-user-message,实际只有:

{ sessionId, text }

在 claw-kit 的实际场景中,WUM hook 需要调用 auto-claw 生成环境/配置诊断与 workflow prompt,并根据当前项目执行项目级流程。但 WUM 无法直接获得当前 session 绑定的工作目录(workdir/workspace),也无法通过现有公开 API 读取完整的 session context。

目前只能依赖 did-session-created 先提供类似 { sessionId, workdir } 的信息,再由插件缓存并交给后续 hook 使用。这导致 hook 之间存在隐式时序依赖:如果 WUM 先触发,插件就无法判断当前项目、定位 .claw 或可靠执行项目级逻辑。Host 内部明明已经保存并能通过 sessionId 查询 workingDir,但这个上下文没有暴露给 hook;现有 session_context 也只在 Ghost tool-call 中注入,不能用于 subscribe hook。

## 诉求

希望重新设计并扩展 hook 的事件载荷和上下文协议,使需要处理用户消息的 hook 能够自包含地处理当前 session,不必依赖另一个 hook 先运行并在内存中缓存上下文。

至少希望提供可信的 session context,例如:

{ session_id, workdir, workdir_is_local, workdir_is_read_only }

同时按事件适用范围提供更完整、稳定的元数据,例如事件名、hookId、序列号/时间戳、当前会话或任务标识,以及相关命令参数、退出状态和错误输出等。

## 建议方案

建议参考 Codex、OpenCode 等成熟工具的 hook 生命周期和参数设计,基于真实使用场景建立统一、可扩展且版本化的协议,而不是只为单一插件临时增加字段。可以复用现有 Ghost tool-call 的 session_context 安全语义,并通过字段白名单和明确的本地/远程、只读属性控制暴露范围。

这样 claw-kit 就能直接从 WUM 获取当前工作区上下文,也可以移除 session-created hook 与 sessionId→workdir 缓存,避免额外的生命周期耦合和竞态。
---
**版本区域**: CN
**OS**: win32 x64 (10.0.26200)
**界面语言**: zh-CN

Contributor guide

Open the contributing guide

Research direction

Start by tracing the subscribe hook protocol and the existing Ghost tool-call session_context path mentioned in the issue, including how the host resolves a sessionId to its working directory. Compare the current event payloads with the requested session and lifecycle metadata, then define the versioned protocol and exposure rules. Done means a WUM hook can obtain reliable session context without depending on did-session-created or an in-memory cache.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.