Commit cb2e2bf37c846479dcd9cb4f01e12ee5edd02631

Authored by zichun
1 parent 1a85f0b0

chore(lite): drop cross-module hook, bump plugin meta to lite

.claude-plugin/plugin.json
1 { 1 {
2 "name": "erp-workflow", 2 "name": "erp-workflow",
3 - "description": "ERP 项目全流程框架:阶段 A 计划(一次性) + 阶段 B 编码(模块循环 + 功能循环),含完整 skill 流水线 + 守门 hook + 软规则留痕。",  
4 - "version": "0.1.0", 3 + "description": "ERP/全栈项目精简流程框架(lite):计划三段(一次性)+ 编码统一功能循环(后端模块 / 前端阶段共用),保留 TDD、需求可追溯、DB-as-SSoT + Flyway、本地里程碑 tag。",
  4 + "version": "0.1.0-lite",
5 "skills": ["./skills/plan", "./skills/coding", "./skills/crosscut"] 5 "skills": ["./skills/plan", "./skills/coding", "./skills/crosscut"]
6 } 6 }
hooks/hooks.json deleted
1 -{  
2 - "hooks": {  
3 - "PostToolUse": [  
4 - {  
5 - "matcher": "Edit|Write",  
6 - "hooks": [  
7 - { "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}\"/hooks/scripts/log-cross-module.sh" }  
8 - ]  
9 - }  
10 - ]  
11 - }  
12 -}  
hooks/scripts/log-cross-module.sh deleted
1 -#!/usr/bin/env bash  
2 -# PostToolUse hook: 检测 Edit/Write 是否触及"当前模块以外"的模块路径,若是则在当前模块的跨模块日志中留痕(软规则 S2)。  
3 -# CC 在当前模块开发期间改动其他模块(无论目标模块是否已打里程碑)都会在此处留痕。  
4 -  
5 -set -euo pipefail  
6 -  
7 -input="$(cat)"  
8 -tool_name="$(printf '%s' "$input" | jq -r '.tool_name // empty')"  
9 -case "$tool_name" in Edit|Write) ;; *) exit 0 ;; esac  
10 -  
11 -file_path="$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty')"  
12 -[ -n "$file_path" ] || exit 0  
13 -  
14 -project_dir="${CLAUDE_PROJECT_DIR:-$(pwd)}"  
15 -docs08="$project_dir/docs/08-模块任务管理.md"  
16 -[ -f "$docs08" ] || exit 0  
17 -  
18 -# 跳过 docs/08 自身的改动(元数据文件编辑不是代码跨模块改动,不触发 S2)  
19 -case "$file_path" in *"/docs/08-模块任务管理.md") exit 0 ;; esac  
20 -  
21 -# 当前模块 = 当前 git 分支名去掉 `module-` 前缀。  
22 -# module-start 步骤 3 保证模块循环期间处于 module-<id> 分支;  
23 -# 非 module-* 分支(如 main、feature/*、docs/*)不在模块循环内,不触发 S2 留痕。  
24 -current_branch="$(cd "$project_dir" 2>/dev/null && git branch --show-current 2>/dev/null || echo '')"  
25 -case "$current_branch" in  
26 - module-*) current_module="${current_branch#module-}" ;;  
27 - *) exit 0 ;;  
28 -esac  
29 -[ -n "$current_module" ] || exit 0  
30 -  
31 -# 遍历 docs/08 § 二 的所有 `- module_X` 行,提取 module_id 和其下的"路径:"行。  
32 -# docs/08 § 二 的模块块结构:  
33 -# - module_0 <name>  
34 -# - 依赖: ...  
35 -# - 路径: backend/module/xxx/, frontend/pages/xxx/  
36 -# - 里程碑: milestone/<id> 或 —  
37 -hit_module=""  
38 -# 用 awk 逐模块解析:每碰到 `- module_` 记录 module_id($2),然后在其下找第一个 `- 路径:` 行  
39 -# current_module 已在上文计算,在外层循环被排除 → 只会命中"非当前模块"的路径  
40 -while IFS=$'\t' read -r mod paths; do  
41 - [ "$mod" = "$current_module" ] && continue  
42 - IFS=',' read -ra scope_arr <<< "$paths"  
43 - for s in "${scope_arr[@]}"; do  
44 - s="$(echo "$s" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//; s:/$::')"  
45 - [ -z "$s" ] && continue  
46 - case "$file_path" in *"$s"*) hit_module="$mod"; break 2;; esac  
47 - done  
48 -done < <(awk '  
49 - /^- module_/ {  
50 - # `- module_xxx <name>` awk 默认分词:$1=-、$2=module_xxx、$3=<name>  
51 - mod=$2  
52 - next  
53 - }  
54 - mod && /^[[:space:]]*- 路径:/ {  
55 - sub(/^[[:space:]]*- 路径:[[:space:]]*/,"")  
56 - print mod "\t" $0  
57 - mod=""  
58 - }  
59 - /^- module_/ && mod { mod="" }  
60 -' "$docs08")  
61 -  
62 -[ -n "$hit_module" ] || exit 0  
63 -  
64 -log_dir="$project_dir/docs/superpowers/module-reports"  
65 -mkdir -p "$log_dir"  
66 -log_file="$log_dir/${current_module}-cross-module.md"  
67 -if [ ! -f "$log_file" ]; then  
68 - # 单一来源:hook 是日志文件的唯一创建者,从插件模板渲染表头。  
69 - plugin_root="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "$0")/../.." && pwd)}"  
70 - template="$plugin_root/skills/crosscut/cross-module-log/templates/cross-module-log-template.md"  
71 - if [ -f "$template" ]; then  
72 - sed "s/{{module_name}}/${current_module}/g" "$template" > "$log_file"  
73 - else  
74 - # 模板缺失的兜底(不该发生):写最小可用表头,避免阻塞当前 Edit/Write  
75 - {  
76 - echo "# 跨模块改动日志 — ${current_module}"  
77 - echo ""  
78 - echo "| 时间戳 | 目标模块 | 文件 | 改动摘要 | 原因 | 影响评估 |"  
79 - echo "|---|---|---|---|---|---|"  
80 - } > "$log_file"  
81 - fi  
82 -fi  
83 -  
84 -ts="$(date -u +%FT%TZ)"  
85 -rel_path="${file_path#$project_dir/}"  
86 -echo "| ${ts} | ${hit_module} | ${rel_path} | ${tool_name} | TBD(CC 补) | TBD(CC 补) |" >> "$log_file"  
87 -  
88 -jq -n --arg m "$hit_module" --arg f "$log_file" --arg p "$rel_path" \  
89 - '{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:("跨模块改动检测:\($p) 属于模块 [\($m)](非当前模块)。存根已写入 \($f),含 TBD(CC 补) 占位。**不需要现在处理**——所有 TBD 由 module-report § ⑦ 一次性调用 cross-module-log skill 批量补齐(软规则 S2)。")}}'