Skip to content

Commit 0e179fa

Browse files
committed
fix(ups): 问句切分保留定界符附回句尾——'Should I commit this?' 句尾问号被切分吞掉误触发(CI 实测);.zsh 注册表移除回滚——归属契约测试锁定送检剥离才是正解
1 parent dea4d08 commit 0e179fa

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎docs/LANGUAGES.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
| PHP | `.php` | `php -l {file}` | `php-cs-fixer fix` | composer require --dev php-cs-fixer |
2121
| Ruby | `.rb` | `rubocop` | `rubocop -A` | gem install rubocop |
2222
| Scala | `.scala` `.sc` | `scalafmt --check .` | `scalafmt` | coursier install scalafmt |
23-
| Shell | `.sh` `.bash` | `shellcheck --severity=warning {file}` | `shfmt -w .` | brew install shellcheck shfmt |
23+
| Shell | `.sh` `.bash` `.zsh` | `shellcheck --severity=warning {file}` | `shfmt -w .` | brew install shellcheck shfmt |
2424
| Dockerfile | (文件名匹配) | `hadolint {file}` | `hadolint` | brew install hadolint |
2525
| YAML | `.yml` `.yaml` | `yamllint .` | `yamllint .` | pip install yamllint |
2626
| Elixir | `.ex` `.exs` | `mix credo --strict` | `mix format` | 项目需配置 credo 依赖 |

‎hooks/user_prompt_validator.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ def is_trigger(user_text: str) -> bool:
8989
# 问句抑制按**句子粒度**:`这个方案 OK 吗?帮我提交` 问句与祈使混排时,
9090
# 整条文本级的问号判断会把祈使句一起静默(软门缺失,硬门兜底,但漏提醒
9191
# 不符合"软门多提醒不算错"的既定原则)。
92-
sentences = [seg for seg in _re.split(r"[。!!??\n\r]+", user_text) if seg.strip()]
92+
# 切分时用捕获组保留定界符并附回句尾——"Should I commit this?" 的问号
93+
# 在句尾,若把定界符当纯分隔符吃掉,句内标记消失会误触发(CI 实测)。
94+
parts = _re.split(r"([。!!??\n\r]+)", user_text)
95+
sentences = []
96+
for i in range(0, len(parts) - 1, 2):
97+
seg = (parts[i] + parts[i + 1]).strip()
98+
if seg:
99+
sentences.append(seg)
100+
tail = parts[-1].strip() if len(parts) % 2 == 1 else ""
101+
if tail:
102+
sentences.append(tail)
93103
trigger_sentences = [seg for seg in sentences if _TRIGGER_RE.search(seg)]
94104
if not trigger_sentences:
95105
return False

‎scripts/languages.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@
369369
"name": "Shell",
370370
"extensions": [
371371
".sh",
372-
".bash"
372+
".bash",
373+
".zsh"
373374
],
374375
"markers": [],
375376
"status": "stable",

0 commit comments

Comments
 (0)