Skip to content

Commit 32d2978

Browse files
魔仙堡魔仙堡
authored andcommitted
feat: ship compiled Claude Code hooks in published tarball (v0.1.3)
- build:hooks compiles today-push.ts / session-end.ts to dist/hooks/*.js (core inlined, node-only, no bun needed) - publish script includes dist/hooks in release tarball - mcp README: hooks section now shows released-package usage (node <installed>/dist/hooks/...), no source clone required - verified: fresh tarball install -> hooks run directly Made-with: Proma
1 parent 485aeb9 commit 32d2978

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

packages/proactive-mcp/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,23 @@ npx proactive-mcp --today
103103
3. **LLM 配置同源**:apiKey 决定主信任源,baseUrl/model 只从同源取;baseUrl 仅 https(localhost 例外)。
104104
4. **反馈闭环**:接受建议(correction 类)→ 写入行为纠正 + 回流用户画像;高频忽略 → 类型自动静默。
105105

106-
## 进阶:Claude Code hooks(源码模式,可选
106+
## 进阶:Claude Code hooks(会话级主动推送,随发布包内置
107107

108-
> 发布包(tarball)不含 hooks/ 目录。以下仅适用于从源码 `git clone` 的场景
108+
发布包已内置编译好的 hooks(`node_modules/@proactive-agent/mcp/dist/hooks/`),无需 clone 源码
109109

110110
`.claude/settings.json` 添加:
111111

112112
```json
113113
{
114114
"hooks": {
115-
"SessionStart": [{ "hooks": [{ "type": "command", "command": "bun run /abs/path/to/packages/proactive-mcp/hooks/today-push.ts" }] }],
116-
"Stop": [{ "hooks": [{ "type": "command", "command": "bun run /abs/path/to/packages/proactive-mcp/hooks/session-end.ts" }] }]
115+
"SessionStart": [{ "hooks": [{ "type": "command", "command": "node /abs/path/to/node_modules/@proactive-agent/mcp/dist/hooks/today-push.js" }] }],
116+
"Stop": [{ "hooks": [{ "type": "command", "command": "node /abs/path/to/node_modules/@proactive-agent/mcp/dist/hooks/session-end.js" }] }]
117117
}
118118
}
119119
```
120120

121+
> 路径写你实际安装位置的绝对路径。也可以复制 hooks 到项目里再引用。
122+
121123
- **today-push**(SessionStart):会话开始时注入今日待处理建议/热点场景;无内容则沉默不打扰
122124
- **session-end**(Stop):会话结束时从 transcript 提取记忆(默认待确认)+ 评估主动建议
123125

packages/proactive-mcp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"typecheck": "tsc --noEmit",
2424
"start": "bun run src/index.ts",
2525
"test": "bun test src/",
26-
"build": "bun build src/index.ts --target=node --banner '#!/usr/bin/env node' --outfile=dist/index.js"
26+
"build": "bun build src/index.ts --target=node --banner '#!/usr/bin/env node' --outfile=dist/index.js",
27+
"build:hooks": "bun build hooks/today-push.ts --target=node --banner '#!/usr/bin/env node' --outfile=dist/hooks/today-push.js && bun build hooks/session-end.ts --target=node --banner '#!/usr/bin/env node' --outfile=dist/hooks/session-end.js"
2728
},
2829
"devDependencies": {
2930
"@types/bun": "latest",

scripts/publish-proactive.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -euo pipefail
1515
export PATH="$HOME/.bun/bin:$PATH"
1616
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
1717
PUBLISH_DIR="$ROOT/dist-publish"
18-
VERSION="0.1.2"
18+
VERSION="0.1.3"
1919
LICENSE="${LICENSE:-MIT}"
2020

2121
echo "==> 构建 bundle"
@@ -63,6 +63,11 @@ cat > "$PUBLISH_DIR/mcp/package.json" <<EOF
6363
}
6464
EOF
6565
cp "$ROOT/packages/proactive-mcp/dist/index.js" "$PUBLISH_DIR/mcp/dist/"
66+
# hooks 编译进发布包(内联 core,node 直接运行;会话级主动推送无需 clone 源码)
67+
mkdir -p "$PUBLISH_DIR/mcp/dist/hooks"
68+
(cd "$ROOT/packages/proactive-mcp" && bun run build:hooks 2>/dev/null || echo " (hooks 编译跳过)")
69+
cp "$ROOT/packages/proactive-mcp/dist/hooks/today-push.js" "$PUBLISH_DIR/mcp/dist/hooks/" 2>/dev/null || true
70+
cp "$ROOT/packages/proactive-mcp/dist/hooks/session-end.js" "$PUBLISH_DIR/mcp/dist/hooks/" 2>/dev/null || true
6671
(cd "$ROOT/packages/proactive-mcp" && bunx tsc --declaration --emitDeclarationOnly --module esnext --moduleResolution bundler --skipLibCheck --downlevelIteration --target es2022 --outDir "$PUBLISH_DIR/mcp/dist" src/index.ts 2>/dev/null || true)
6772
cp "$ROOT/packages/proactive-mcp/README.md" "$PUBLISH_DIR/mcp/" 2>/dev/null || true
6873
cp "$ROOT/CHANGELOG.md" "$PUBLISH_DIR/mcp/" 2>/dev/null || true

0 commit comments

Comments
 (0)