@hupan56/wlkj 3.3.13 → 3.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/bin/cli.js +0 -7
  2. package/package.json +29 -29
  3. package/templates/qoder/commands/optional/wl-spec.md +0 -8
  4. package/templates/qoder/commands/optional/wl-status.md +0 -8
  5. package/templates/qoder/commands/wl-code.md +0 -8
  6. package/templates/qoder/commands/wl-commit.md +0 -8
  7. package/templates/qoder/commands/wl-init.md +129 -129
  8. package/templates/qoder/commands/wl-search.md +0 -8
  9. package/templates/qoder/commands/wl-task.md +0 -8
  10. package/templates/qoder/commands/wl-test.md +0 -8
  11. package/templates/qoder/config.yaml +2 -3
  12. package/templates/qoder/contracts/insight.md +55 -55
  13. package/templates/qoder/hooks/pre-tool-use-commit.py +124 -124
  14. package/templates/qoder/hooks/session-start.py +384 -384
  15. package/templates/qoder/hooks/stop-eval.py +383 -383
  16. package/templates/qoder/scripts/capability/adapters/mcp.py +322 -322
  17. package/templates/qoder/scripts/capability/registry.py +245 -245
  18. package/templates/qoder/scripts/deployment/setup/install_qoderwork.py +14 -0
  19. package/templates/qoder/scripts/deployment/setup/setup.py +0 -11
  20. package/templates/qoder/scripts/domain/task/wlkj_panel.py +1503 -1503
  21. package/templates/qoder/scripts/foundation/bootstrap.py +145 -156
  22. package/templates/qoder/scripts/foundation/io/context_cache.py +94 -94
  23. package/templates/qoder/scripts/orchestration/wlkj.py +295 -306
  24. package/templates/qoder/scripts/tool_guide.md +70 -70
  25. package/templates/qoder/scripts/validation/eval/alignment_matrix.py +176 -176
  26. package/templates/qoder/scripts/validation/eval/bf2_content_fidelity.py +110 -110
  27. package/templates/qoder/scripts/validation/eval/bf2_llmjudge.py +104 -104
  28. package/templates/qoder/scripts/validation/eval/bf_score.py +218 -218
  29. package/templates/qoder/scripts/validation/eval/code_flywheel.py +150 -150
  30. package/templates/qoder/scripts/validation/eval/dispatcher_ab.py +156 -156
  31. package/templates/qoder/scripts/validation/eval/dispatcher_ab_2026-07-21.json +23 -23
  32. package/templates/qoder/scripts/validation/eval/feature_fidelity_flywheel.py +143 -143
  33. package/templates/qoder/scripts/validation/eval/gradient_matrix.py +261 -261
  34. package/templates/qoder/scripts/validation/eval/gradient_matrix_baseline_2026-07-21.json +33 -33
  35. package/templates/qoder/scripts/validation/eval/metrics_dashboard.py +105 -105
  36. package/templates/qoder/scripts/validation/eval/multi_turn_flywheel.py +118 -118
  37. package/templates/qoder/scripts/validation/eval/prd_fidelity_flywheel.py +128 -128
  38. package/templates/qoder/scripts/validation/eval/prd_flywheel.py +148 -148
  39. package/templates/qoder/scripts/validation/eval/prototype_fidelity_flywheel.py +166 -166
  40. package/templates/qoder/scripts/validation/eval/recall_flywheel.py +148 -148
  41. package/templates/qoder/scripts/validation/eval/robustness_flywheel.py +139 -139
  42. package/templates/qoder/scripts/validation/eval/speed_accuracy_flywheel.py +188 -188
  43. package/templates/qoder/scripts/validation/eval/task_flywheel.py +124 -124
  44. package/templates/qoder/scripts/validation/eval/token_flywheel.py +88 -88
  45. package/templates/qoder/scripts/validation/metrics/eval_code_ac.py +177 -177
  46. package/templates/qoder/scripts/validation/metrics/lint_cases.py +170 -170
  47. package/templates/qoder/scripts/validation/test/test_context_cache.py +78 -78
  48. package/templates/qoder/scripts/validation/test/test_lint_cases.py +60 -60
  49. package/templates/qoder/scripts/validation/test/test_pre_tool_use_commit.py +70 -70
  50. package/templates/qoder/commands/wl-data.md +0 -46
  51. package/templates/qoder/commands/wl-fix.md +0 -47
  52. package/templates/qoder/commands/wl-knowledge.md +0 -41
  53. package/templates/qoder/commands/wl-review.md +0 -49
  54. package/templates/workspace/specs/REQ-TEST-CTX/.context-cache.json +0 -1
@@ -1,124 +1,124 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """pre-tool-use-commit.py - P0-3 w3: wl-commit msg 门禁(PreToolUse on Bash git commit)
4
-
5
- stop-eval.py 里 _enforce_commit_msg_gate 的**正确落点**:pre-tool-use(commit 执行前验 msg),
6
- 而非 stop-eval(后者 git log -1 不分"本轮 wl-commit" vs 平台开发/工具 commit → 误拦)。
7
-
8
- 做法(确定性 + 不误拦其他):
9
- 1. PreToolUse 命中 Bash + command 含 "git commit"
10
- 2. 提取 -m 消息(兼容 -m "x" / -m 'x' / --message=x / 多 -m)
11
- 3. 查需求关联标记 [#REQ-<uuid>] (S3) 或 [#<禅道号>] (S5.1)
12
- 4. 缺标记:
13
- - 默认 ADVISORY(exit 0 + stdout 强提醒)—— 不阻断,避免误拦工具/平台/文档 commit
14
- - 环境变量 WLCOMMIT_GATE_BLOCK=1 时 → exit 2 硬拦(wl-commit 强流程场景才开)
15
-
16
- 铁律:永远 exit 0(除非 BLOCK 模式显式开);失败 try/except 静默(hook 崩绝不阻塞)。
17
- 非 git commit 命令 / 非 Bash → exit 0。
18
- """
19
- import json
20
- import os
21
- import re
22
- import sys
23
-
24
- if sys.platform == 'win32':
25
- try:
26
- sys.stdout.reconfigure(encoding='utf-8')
27
- sys.stderr.reconfigure(encoding='utf-8')
28
- except Exception:
29
- pass
30
-
31
- NL = chr(10)
32
- BASE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
33
- HOOK_ERRORS_LOG = os.path.join(BASE, '.qoder', '.runtime', 'hook-errors.log')
34
-
35
- # 需求关联标记:[#REQ-xxx] 或 [#123](禅道号)
36
- _REQ_TAG_RE = re.compile(r'\[#REQ-[\w-]+\]|\[#\d+\]')
37
- # 提取 git commit -m 的消息(兼容引号/多段/--message= / 组合短旗 -am)
38
- # (?:^|\s)-[a-zA-Z]*m 匹配 -m / -am / -cm 等(单 dash 短旗组合;空白前缀避 --message 误匹)
39
- _M_QUOTED = re.compile(r'''(?:^|\s)-[a-zA-Z]*m\s*(['"])(.*?)\1''', re.S)
40
- _M_BARE = re.compile(r'(?:^|\s)-[a-zA-Z]*m\s+(\S.*?)\s*(?=(?:^|\s)-[a-zA-Z]*m\s|$)', re.S)
41
- _MSG_EQ = re.compile(r'(?:^|\s)--message=(\S.*?)\s*(?:--|$)', re.S)
42
-
43
-
44
- def _read_stdin():
45
- try:
46
- raw = sys.stdin.read()
47
- if raw and raw.strip():
48
- return json.loads(raw)
49
- except Exception:
50
- pass
51
- return {}
52
-
53
-
54
- def _extract_msg(command):
55
- """从 git commit 命令里提取 commit message(拼多 -m)。提不到返 ''。"""
56
- if "--message=" in command:
57
- m = _MSG_EQ.search(command)
58
- if m:
59
- return m.group(1).strip()
60
- # 所有 -m "..." / -m '...' 段拼接
61
- parts = _M_QUOTED.findall(command) # [(quote, msg), ...]
62
- if parts:
63
- return "\n".join(p[1] for p in parts).strip()
64
- # 裸 -m word(无引号)
65
- m = _M_BARE.search(command)
66
- if m:
67
- return m.group(1).strip()
68
- return ""
69
-
70
-
71
- def _log_err(line):
72
- from datetime import datetime
73
- try:
74
- os.makedirs(os.path.dirname(HOOK_ERRORS_LOG), exist_ok=True)
75
- with open(HOOK_ERRORS_LOG, 'a', encoding='utf-8') as f:
76
- f.write('[{}] pre-tool-use-commit: {}{}'.format(
77
- datetime.now().strftime('%Y-%m-%d %H:%M:%S'), str(line)[:200], NL))
78
- except Exception:
79
- pass
80
-
81
-
82
- def main():
83
- data = _read_stdin()
84
- tool = data.get("tool_name") or data.get("tool") or ""
85
- if tool.lower() not in ("bash", "shell", "execute_bash"):
86
- sys.exit(0)
87
- tinput = data.get("tool_input") or data.get("input") or {}
88
- command = tinput.get("command") or tinput.get("cmd") or ""
89
- if not isinstance(command, str) or "git commit" not in command:
90
- sys.exit(0)
91
- # 跳过 --amend 无 -m / 自动生成(如 merge commit)—— 只验带 -m 的显式 commit
92
- msg = _extract_msg(command)
93
- if not msg:
94
- sys.exit(0) # 提不到 -m(可能 -F 文件或 amend),不拦
95
- if _REQ_TAG_RE.search(msg):
96
- sys.exit(0) # 含需求标记,放行
97
-
98
- # 缺标记
99
- block_mode = os.environ.get("WLCOMMIT_GATE_BLOCK", "").lower() in ("1", "true", "yes")
100
- preview = msg.replace("\n", " ")[:100]
101
- if block_mode:
102
- sys.stderr.write(
103
- '【wl-commit msg 门禁·硬拦】commit msg 缺需求关联标记:\n %s\n'
104
- '修复: git commit --amend 补 [#REQ-<uuid>] (S3) 或 [#<禅道号>] (S5.1 push 后)。\n'
105
- '(此硬拦由 WLCOMMIT_GATE_BLOCK=1 开启;平台/工具/文档 commit 关该 env 或走非 wl-commit 流程。)\n'
106
- % preview)
107
- sys.exit(2)
108
- # 默认 advisory:不阻断,强提醒
109
- sys.stdout.write(
110
- '⚠️ 【wl-commit msg 提醒】本次 commit msg 缺需求关联标记 [#REQ-xxx]/[#禅道号]:\n'
111
- ' %s\n'
112
- '若这是 /wl-commit 流程,建议 amend 补标记关联需求(F1 闭环数据);'
113
- '若是平台/工具/文档 commit 可忽略本提醒。\n' % preview)
114
- sys.exit(0)
115
-
116
-
117
- if __name__ == "__main__":
118
- try:
119
- main()
120
- except SystemExit:
121
- raise
122
- except Exception as e:
123
- _log_err("fatal: %s" % str(e)[:150])
124
- sys.exit(0) # 永不阻塞
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """pre-tool-use-commit.py - P0-3 w3: wl-commit msg 门禁(PreToolUse on Bash git commit)
4
+
5
+ stop-eval.py 里 _enforce_commit_msg_gate 的**正确落点**:pre-tool-use(commit 执行前验 msg),
6
+ 而非 stop-eval(后者 git log -1 不分"本轮 wl-commit" vs 平台开发/工具 commit → 误拦)。
7
+
8
+ 做法(确定性 + 不误拦其他):
9
+ 1. PreToolUse 命中 Bash + command 含 "git commit"
10
+ 2. 提取 -m 消息(兼容 -m "x" / -m 'x' / --message=x / 多 -m)
11
+ 3. 查需求关联标记 [#REQ-<uuid>] (S3) 或 [#<禅道号>] (S5.1)
12
+ 4. 缺标记:
13
+ - 默认 ADVISORY(exit 0 + stdout 强提醒)—— 不阻断,避免误拦工具/平台/文档 commit
14
+ - 环境变量 WLCOMMIT_GATE_BLOCK=1 时 → exit 2 硬拦(wl-commit 强流程场景才开)
15
+
16
+ 铁律:永远 exit 0(除非 BLOCK 模式显式开);失败 try/except 静默(hook 崩绝不阻塞)。
17
+ 非 git commit 命令 / 非 Bash → exit 0。
18
+ """
19
+ import json
20
+ import os
21
+ import re
22
+ import sys
23
+
24
+ if sys.platform == 'win32':
25
+ try:
26
+ sys.stdout.reconfigure(encoding='utf-8')
27
+ sys.stderr.reconfigure(encoding='utf-8')
28
+ except Exception:
29
+ pass
30
+
31
+ NL = chr(10)
32
+ BASE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
33
+ HOOK_ERRORS_LOG = os.path.join(BASE, '.qoder', '.runtime', 'hook-errors.log')
34
+
35
+ # 需求关联标记:[#REQ-xxx] 或 [#123](禅道号)
36
+ _REQ_TAG_RE = re.compile(r'\[#REQ-[\w-]+\]|\[#\d+\]')
37
+ # 提取 git commit -m 的消息(兼容引号/多段/--message= / 组合短旗 -am)
38
+ # (?:^|\s)-[a-zA-Z]*m 匹配 -m / -am / -cm 等(单 dash 短旗组合;空白前缀避 --message 误匹)
39
+ _M_QUOTED = re.compile(r'''(?:^|\s)-[a-zA-Z]*m\s*(['"])(.*?)\1''', re.S)
40
+ _M_BARE = re.compile(r'(?:^|\s)-[a-zA-Z]*m\s+(\S.*?)\s*(?=(?:^|\s)-[a-zA-Z]*m\s|$)', re.S)
41
+ _MSG_EQ = re.compile(r'(?:^|\s)--message=(\S.*?)\s*(?:--|$)', re.S)
42
+
43
+
44
+ def _read_stdin():
45
+ try:
46
+ raw = sys.stdin.read()
47
+ if raw and raw.strip():
48
+ return json.loads(raw)
49
+ except Exception:
50
+ pass
51
+ return {}
52
+
53
+
54
+ def _extract_msg(command):
55
+ """从 git commit 命令里提取 commit message(拼多 -m)。提不到返 ''。"""
56
+ if "--message=" in command:
57
+ m = _MSG_EQ.search(command)
58
+ if m:
59
+ return m.group(1).strip()
60
+ # 所有 -m "..." / -m '...' 段拼接
61
+ parts = _M_QUOTED.findall(command) # [(quote, msg), ...]
62
+ if parts:
63
+ return "\n".join(p[1] for p in parts).strip()
64
+ # 裸 -m word(无引号)
65
+ m = _M_BARE.search(command)
66
+ if m:
67
+ return m.group(1).strip()
68
+ return ""
69
+
70
+
71
+ def _log_err(line):
72
+ from datetime import datetime
73
+ try:
74
+ os.makedirs(os.path.dirname(HOOK_ERRORS_LOG), exist_ok=True)
75
+ with open(HOOK_ERRORS_LOG, 'a', encoding='utf-8') as f:
76
+ f.write('[{}] pre-tool-use-commit: {}{}'.format(
77
+ datetime.now().strftime('%Y-%m-%d %H:%M:%S'), str(line)[:200], NL))
78
+ except Exception:
79
+ pass
80
+
81
+
82
+ def main():
83
+ data = _read_stdin()
84
+ tool = data.get("tool_name") or data.get("tool") or ""
85
+ if tool.lower() not in ("bash", "shell", "execute_bash"):
86
+ sys.exit(0)
87
+ tinput = data.get("tool_input") or data.get("input") or {}
88
+ command = tinput.get("command") or tinput.get("cmd") or ""
89
+ if not isinstance(command, str) or "git commit" not in command:
90
+ sys.exit(0)
91
+ # 跳过 --amend 无 -m / 自动生成(如 merge commit)—— 只验带 -m 的显式 commit
92
+ msg = _extract_msg(command)
93
+ if not msg:
94
+ sys.exit(0) # 提不到 -m(可能 -F 文件或 amend),不拦
95
+ if _REQ_TAG_RE.search(msg):
96
+ sys.exit(0) # 含需求标记,放行
97
+
98
+ # 缺标记
99
+ block_mode = os.environ.get("WLCOMMIT_GATE_BLOCK", "").lower() in ("1", "true", "yes")
100
+ preview = msg.replace("\n", " ")[:100]
101
+ if block_mode:
102
+ sys.stderr.write(
103
+ '【wl-commit msg 门禁·硬拦】commit msg 缺需求关联标记:\n %s\n'
104
+ '修复: git commit --amend 补 [#REQ-<uuid>] (S3) 或 [#<禅道号>] (S5.1 push 后)。\n'
105
+ '(此硬拦由 WLCOMMIT_GATE_BLOCK=1 开启;平台/工具/文档 commit 关该 env 或走非 wl-commit 流程。)\n'
106
+ % preview)
107
+ sys.exit(2)
108
+ # 默认 advisory:不阻断,强提醒
109
+ sys.stdout.write(
110
+ '⚠️ 【wl-commit msg 提醒】本次 commit msg 缺需求关联标记 [#REQ-xxx]/[#禅道号]:\n'
111
+ ' %s\n'
112
+ '若这是 /wl-commit 流程,建议 amend 补标记关联需求(F1 闭环数据);'
113
+ '若是平台/工具/文档 commit 可忽略本提醒。\n' % preview)
114
+ sys.exit(0)
115
+
116
+
117
+ if __name__ == "__main__":
118
+ try:
119
+ main()
120
+ except SystemExit:
121
+ raise
122
+ except Exception as e:
123
+ _log_err("fatal: %s" % str(e)[:150])
124
+ sys.exit(0) # 永不阻塞