diff --git a/.codex/skills/git-submit/SKILL.md b/.codex/skills/git-submit/SKILL.md deleted file mode 100644 index 555a93e..0000000 --- a/.codex/skills/git-submit/SKILL.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -name: git-submit -description: 执行 Git 提交和推送工作流 ---- - -# Git 提交/推送工作流(Codex CLI) - -当用户明确要求提交/推送时使用。 - -## 操作流程 - -### 1)检查当前状态(不需要用户确认) - -- 查看分支/干净程度:`git status -sb` -- 查看变更概要:`git diff --stat` - -如发现明显问题,优先在提交前处理: - -- 误把生成物/大文件加入:先移除或补 `.gitignore` -- 变更跨度过大:提醒用户是否需要拆分提交 - -### 2)起草提交信息(中文;默认不需要用户确认) - -根据对话历史和修改的文件信息,按下方规范直接生成提交信息并继续执行后续流程。 - -- 如果用户已经明确给出提交信息,直接使用用户提供的版本 -- 如果用户没有指定提交信息,按下方规范自动生成最合适的一条 -- **不要**为了 commit message 再额外等待用户确认,除非用户明确要求先看 message 再提交 - -#### Git Commit Message 规范 - -##### 1)格式 - -```text -(): -``` - -说明: - -- ``:提交类型(必填) -- ``:影响范围/模块(必填) -- ``:一句话说明“做了什么”(必填) - ---- - -##### 2)type 列表 - -统一使用小写: - -| type | 含义 | -|---|---| -| `feat` | 新功能 | -| `fix` | 修复 bug | -| `docs` | 文档变更 | -| `style` | 仅格式/风格(不改语义) | -| `refactor` | 重构(不改变外部行为) | -| `perf` | 性能优化 | -| `test` | 测试相关 | -| `build` | 构建系统 | -| `ci` | CI 相关 | -| `chore` | 杂项维护 | -| `revert` | 回滚提交 | - ---- - -##### 3)scope 列表 - -建议从以下范围中选择(保持一致即可): - -| scope | 含义 | -|---|---| -| `frontend` | 前端(ANTLR 驱动、AST 构建入口等) | -| `ast` | AST 相关 | -| `sema` | 语义分析(符号表、常量求值等) | -| `ir` | IR 核心结构 | -| `irgen` | AST → IR 生成 | -| `mir` | Machine IR(指令选择、寄存器分配、栈帧等) | -| `backend` | 后端目标相关(如需要可细化 `aarch64`) | -| `antlr` | 语法文件/ANTLR 相关 | -| `build` | 构建配置 | -| `test` | 测试 | -| `doc` | 文档 | -| `misc` | 其他无法归类但需要说明的范围 | - -提交信息示例: - -```text -refactor(irgen): 简化 AST → IR 构建流程 -``` - -### 3)后续流程(均不需要用户确认) - -- 暂存所有改动:`git add -A` -- 单行摘要:`git commit -m "(): "`,需要补充说明时用多行:`git commit -m "" -m "" -m ""` -- 推送:`git push`,推送完成后立即停止,不要再运行其他命令 diff --git a/.githooks/commit-msg b/.githooks/commit-msg deleted file mode 100755 index f54edfc..0000000 --- a/.githooks/commit-msg +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -msg_file="${1:-}" - -if [[ -z "${msg_file}" || ! -f "${msg_file}" ]]; then - echo "错误:未找到提交信息文件(commit-msg hook 未收到有效参数)。" >&2 - exit 1 -fi - -# 读取第一条“有效提交信息”(跳过空行与注释行),并兼容 CRLF。 -first_line="$( - awk ' - { - sub(/\r$/, "") - if ($0 ~ /^[[:space:]]*#/) next - if ($0 ~ /^[[:space:]]*$/) next - print - exit - } - ' "${msg_file}" -)" - -allowed_types=( - feat fix docs style refactor perf test build ci chore revert -) - -allowed_scopes=( - frontend ast sema ir irgen mir backend antlr build test doc dev -) - -print_allowed() { - local IFS="|" - echo "允许的 type:${allowed_types[*]}" >&2 - echo "允许的 scope:${allowed_scopes[*]}" >&2 -} - -fail() { - local reason="$1" - local extra="${2:-}" - - echo "错误:提交信息不符合规范:${reason}" >&2 - echo "" >&2 - echo "当前提交信息:" >&2 - echo " ${first_line}" >&2 - echo "" >&2 - echo "规范格式:" >&2 - echo " (): " >&2 - echo "" >&2 - echo "注意:" >&2 - echo " 1) 冒号必须是英文 ':'(不是中文 ':')。" >&2 - echo " 2) 冒号后必须严格跟 1 个空格(': ')。" >&2 - echo "" >&2 - print_allowed - echo "" >&2 - echo "示例:" >&2 - echo " feat(irgen): add constant folding" >&2 - echo " fix(sema): handle null symbol" >&2 - echo " docs(doc): update build instructions" >&2 - if [[ -n "${extra}" ]]; then - echo "" >&2 - echo "${extra}" >&2 - fi - echo "" >&2 - echo "参考文档:doc/Git Commit Message 规范.md" >&2 - exit 1 -} - -if [[ -z "${first_line}" ]]; then - fail "提交信息为空(第一行不能为空)。" -fi - -# 允许 merge 提交信息(如:git merge 默认生成的 message)。 -if [[ "${first_line}" == "Merge "* ]]; then - exit 0 -fi - -# 允许 fixup!/squash!(用于 rebase --autosquash 等流程)。 -if [[ "${first_line}" == "fixup!"* || "${first_line}" == "squash!"* ]]; then - exit 0 -fi - -# 先做一些常见错误的定向提示。 -if [[ "${first_line}" == *":"* ]]; then - fail "检测到中文冒号 ':'。" "请把中文冒号替换为英文冒号 ':',并确保冒号后有且仅有 1 个空格。" -fi - -if [[ "${first_line}" =~ ^[A-Za-z]+\([A-Za-z]+\):[^[:space:]].*$ ]]; then - fail "冒号后缺少空格。" "正确写法应为 ': '(英文冒号 + 1 个空格)。" -fi - -if [[ "${first_line}" =~ ^[A-Za-z]+\([A-Za-z]+\):[[:space:]]{2,}.*$ ]]; then - fail "冒号后空格数量不正确(多于 1 个空格)。" "请确保冒号后严格是 1 个空格(': ')。" -fi - -type="" -scope="" -subject="" - -if [[ "${first_line}" =~ ^([A-Za-z]+)\(([A-Za-z]+)\):\ (.+)$ ]]; then - type="${BASH_REMATCH[1]}" - scope="${BASH_REMATCH[2]}" - subject="${BASH_REMATCH[3]}" -else - fail "格式不正确。" "请按 '(): ' 格式填写。" -fi - -if [[ "${subject}" =~ ^[[:space:]] ]]; then - fail "冒号后的空格数量不正确(多于 1 个空格)。" "请确保冒号后严格是 1 个空格(': ')。" -fi - -case "${type}" in - feat | fix | docs | style | refactor | perf | test | build | ci | chore | revert) ;; - *) - fail "type 不合法:${type}" "请使用允许的 type(小写)。" - ;; -esac - -case "${scope}" in - frontend | ast | sema | ir | irgen | mir | backend | antlr | build | test | doc | dev) ;; - *) - fail "scope 不合法:${scope}" "请使用允许的 scope(严格限制)。" - ;; -esac - -exit 0 diff --git a/scripts/setup-git-hooks.sh b/scripts/setup-git-hooks.sh deleted file mode 100755 index 86503d3..0000000 --- a/scripts/setup-git-hooks.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -repo_root="$(git rev-parse --show-toplevel 2>/dev/null || true)" -if [[ -z "${repo_root}" ]]; then - echo "错误:当前目录不是 Git 仓库,无法配置 hooks。" >&2 - exit 1 -fi - -cd "${repo_root}" - -hooks_dir=".githooks" -if [[ ! -d "${hooks_dir}" ]]; then - echo "错误:未找到 ${hooks_dir} 目录,请确认仓库已包含 hooks 文件。" >&2 - exit 1 -fi - -git config core.hooksPath "${hooks_dir}" - -echo "已启用本仓库 Git hooks:" >&2 -echo " core.hooksPath=${hooks_dir}" >&2 -echo "" >&2 -echo "现在执行 git commit 时会校验提交信息是否符合:" >&2 -echo " doc/Git Commit Message 规范.md" >&2 -echo "" >&2 -echo "查看当前配置:" >&2 -echo " git config --get core.hooksPath" >&2 -echo "" >&2 -echo "如需取消(恢复默认 .git/hooks): " >&2 -echo " git config --unset core.hooksPath" >&2