agent-skill-installer 0.1.3 → 0.1.5

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.
package/README.md CHANGED
@@ -25,14 +25,14 @@
25
25
  # 查看可安装 skills
26
26
  npx agent-skill-installer list
27
27
 
28
- # 安装一个 skill(默认安装到 ~/.agent/skills)
28
+ # 安装一个 skill(默认安装到 ~/.agents/skills)
29
29
  npx agent-skill-installer install git-commit-helper
30
30
 
31
31
  # 一次安装多个 skills
32
32
  npx agent-skill-installer install git-commit-helper codex-session-daily-report
33
33
 
34
34
  # 安装到自定义目录
35
- npx agent-skill-installer install git-commit-helper --dest ~/.agent/skills
35
+ npx agent-skill-installer install git-commit-helper --dest ~/.codex/skills
36
36
 
37
37
  # 覆盖已存在 skill
38
38
  npx agent-skill-installer install git-commit-helper --force
package/bin/cli.js CHANGED
@@ -6,7 +6,7 @@ const os = require("node:os");
6
6
 
7
7
  const REPO_ROOT = path.resolve(__dirname, "..");
8
8
  const SKILLS_SOURCE_DIR = path.join(REPO_ROOT, "skills");
9
- const DEFAULT_DEST = path.join(os.homedir(), ".agent", "skills");
9
+ const DEFAULT_DEST = path.join(os.homedir(), ".agents", "skills");
10
10
 
11
11
  function printHelp() {
12
12
  console.log(`agent-skill-installer
@@ -17,7 +17,7 @@ Usage:
17
17
 
18
18
  Commands:
19
19
  list List installable skills in this package.
20
- install <skill...> Install one or more skills to ~/.agent/skills by default.
20
+ install <skill...> Install one or more skills to ~/.agents/skills by default.
21
21
 
22
22
  Options:
23
23
  --dest <path> Custom destination directory.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-skill-installer",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Install one or more Codex skills from this package via npx.",
5
5
  "bin": {
6
6
  "agent-skill-installer": "bin/cli.js"
@@ -3,44 +3,46 @@ name: git-commit-helper
3
3
  description: "严格生成与校验中文 Git 提交信息,固定格式为 type(scope): summary,type 仅允许 feat/fix/refactor/perf/style/test/docs/chore,summary 必须用祈使句、不超过 50 字符、不得以句号结尾且不得包含 and/&/multiple changes。使用该技能于编写提交说明、检查提交文本是否合规,或执行使用 codex (codex-ice@gmail.com) 身份的提交时。"
4
4
  ---
5
5
 
6
- 按固定规范生成中文提交信息,并在提交前进行格式校验。
7
- 统一使用作者身份:`codex <codex-ice@gmail.com>`。
6
+ 生成中文提交信息,先校验再提交。统一使用作者身份:`codex <codex-ice@gmail.com>`。
8
7
 
9
8
  ## 工作流
10
9
 
11
- 1. 先查看暂存变更,确认本次提交只表达一个意图:`git diff --cached --name-status`。
12
- 2. 选择 `type`,必须是以下之一:`feat` `fix` `refactor` `perf` `style` `test` `docs` `chore`。
13
- 3. 写首行:`<type>(<scope>): <summary>`。
14
- 4. 首行后可选正文;若 `type=perf`,必须写正文说明优化原因。
15
- 5. 使用脚本校验:`python3 scripts/validate_commit_message.py --file <msg-file>`。
16
- 6. 通过校验后提交,并固定作者身份:
17
- `git -c user.name='codex' -c user.email='codex-ice@gmail.com' commit -F <msg-file>`。
10
+ 1. 检查暂存区,只允许一个明确意图:
11
+ `git diff --cached --name-status`
12
+ 2. 选择 `type`:`feat` `fix` `refactor` `perf` `style` `test` `docs` `chore`。
13
+ 3. 写提交消息文件,固定首行格式:
14
+ `<type>(<scope>): <summary>`
15
+ 4. 若 `type=perf`,在空行后写正文并说明优化原因。
16
+ 5. 执行校验:
17
+ `python3 skills/git-commit-helper/scripts/validate_commit_message.py --file <msg-file>`
18
+ 6. 校验通过后提交:
19
+ `git -c user.name='codex' -c user.email='codex-ice@gmail.com' commit -F <msg-file>`
18
20
 
19
21
  ## 强制规则
20
22
 
21
- 1. 格式必须严格为:`<type>(<scope>): <summary>`。
22
- 2. `type` 只能从这 8 个值中选择:`feat` `fix` `refactor` `perf` `style` `test` `docs` `chore`。
23
- 3. `summary` 必须满足:
24
- - 使用祈使句。
25
- - 不超过 50 字符。
26
- - 不要句号(`。` 或 `.`)。
27
- - 不要出现 `and`、`&`、`multiple changes`。
28
- - 使用中文表达。
29
- 4. 提交文本(`summary` 与可选正文)使用中文。
30
- 5. `perf` 类型必须在正文说明优化原因。
23
+ 1. 首行必须是:`<type>(<scope>): <summary>`。
24
+ 2. `scope` 只允许小写字母、数字、连字符(例如 `album`、`build-cache`)。
25
+ 3. `summary` 必须使用中文祈使句,且不超过 50 字符。
26
+ 4. `summary` 不能以 `。` 或 `.` 结尾。
27
+ 5. `summary` 不能包含 `and`、`&`、`multiple changes`。
28
+ 6. `summary` 与正文必须使用中文表达。
29
+ 7. 若包含正文,第 2 行必须是空行。
30
+ 8. `perf` 必须包含正文说明优化原因。
31
31
 
32
- ## 示例
32
+ ## 快速模板
33
33
 
34
- 正确:
35
- - `fix(album): 避免滚动时重复渲染`
36
- - `docs(api): 补充鉴权参数说明`
34
+ ```text
35
+ fix(scope): 优化某个单一行为
37
36
 
38
- 错误:
39
- - `update code`
40
- - `fix bug and refactor logic`
41
- - `optimize`
37
+ 仅在需要时写正文,说明原因或背景
38
+ ```
42
39
 
43
- ## 脚本资源
40
+ ## 失败处理
44
41
 
45
- - `scripts/validate_commit_message.py`
46
- 校验提交文本是否符合本技能的强制规则。
42
+ 1. 阅读脚本返回的逐条错误。
43
+ 2. 仅修改被指出的问题,避免一次改多个意图。
44
+ 3. 重新执行校验,直到输出“校验通过”。
45
+
46
+ ## 资源
47
+
48
+ - `skills/git-commit-helper/scripts/validate_commit_message.py`:提交信息规则校验器
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "git-commit-helper"
3
- short_description: "Generate Chinese Git commit messages with strict checks"
4
- default_prompt: "Use $git-commit-helper to draft a Chinese commit message and validate it before committing as codex <codex-ice@gmail.com>."
3
+ short_description: "严格生成并校验中文 Git 提交信息"
4
+ default_prompt: "Use $git-commit-helper to draft a Chinese commit message in `type(scope): summary`, validate it with the bundled script, then commit as codex <codex-ice@gmail.com>."
@@ -19,6 +19,18 @@ FORBIDDEN_SUMMARY_PATTERNS = (
19
19
  re.compile(r"&"),
20
20
  re.compile(r"multiple changes", re.IGNORECASE),
21
21
  )
22
+ PAST_TENSE_PREFIXES = (
23
+ "已",
24
+ "已经",
25
+ "完成",
26
+ "修复了",
27
+ "新增了",
28
+ "优化了",
29
+ "更新了",
30
+ "重构了",
31
+ "添加了",
32
+ "改了",
33
+ )
22
34
  FORBIDDEN_ENDINGS = (".", "。")
23
35
  MAX_SUMMARY_LEN = 50
24
36
 
@@ -49,36 +61,50 @@ def validate_commit_message(message: str) -> list[str]:
49
61
 
50
62
  match = HEADER_RE.match(header)
51
63
  commit_type = None
64
+ raw_summary = ""
52
65
  summary = ""
53
66
  if not match:
54
67
  errors.append("首行格式必须为 <type>(<scope>): <summary>")
55
68
  else:
56
69
  commit_type = match.group("type")
57
- summary = match.group("summary").strip()
70
+ raw_summary = match.group("summary")
71
+ summary = raw_summary.strip()
58
72
 
59
73
  if len(lines) > 1 and lines[1] != "":
60
74
  errors.append("若包含正文,第 2 行必须为空行")
61
75
 
62
- body = "\n".join(lines[2:]).strip() if len(lines) > 2 else ""
76
+ body_lines = lines[2:] if len(lines) > 2 else []
77
+ body = "\n".join(body_lines).strip()
63
78
 
64
79
  if commit_type and commit_type not in ALLOWED_TYPES:
65
80
  errors.append("type 必须是 feat/fix/refactor/perf/style/test/docs/chore 之一")
66
81
 
82
+ if not summary and match:
83
+ errors.append("summary 不能为空")
84
+
67
85
  if summary:
86
+ if raw_summary != summary:
87
+ errors.append("summary 前后不能有空格")
68
88
  if len(summary) > MAX_SUMMARY_LEN:
69
89
  errors.append("summary 长度不能超过 50 字符")
70
90
  if summary.endswith(FORBIDDEN_ENDINGS):
71
91
  errors.append("summary 结尾不能使用句号")
72
92
  if not CJK_RE.search(summary):
73
93
  errors.append("summary 必须使用中文")
94
+ if summary.startswith(PAST_TENSE_PREFIXES):
95
+ errors.append("summary 必须使用祈使句,避免使用“已/完成/xxx了”开头")
74
96
 
75
97
  for pattern in FORBIDDEN_SUMMARY_PATTERNS:
76
98
  if pattern.search(summary):
77
99
  errors.append("summary 不能包含 and / & / multiple changes")
78
100
  break
79
101
 
80
- if body and not CJK_RE.search(body):
81
- errors.append("正文需使用中文")
102
+ for line_no, line in enumerate(body_lines, start=3):
103
+ stripped = line.strip()
104
+ if not stripped:
105
+ continue
106
+ if not CJK_RE.search(stripped):
107
+ errors.append(f"正文第 {line_no} 行需使用中文")
82
108
 
83
109
  if commit_type == "perf" and not body:
84
110
  errors.append("perf 类型必须提供正文说明优化原因")