code-abyss 1.6.16 → 1.7.0

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 (92) hide show
  1. package/package.json +2 -2
  2. package/skills/SKILL.md +24 -16
  3. package/skills/domains/ai/SKILL.md +2 -2
  4. package/skills/domains/ai/prompt-and-eval.md +279 -0
  5. package/skills/domains/architecture/SKILL.md +2 -3
  6. package/skills/domains/architecture/security-arch.md +87 -0
  7. package/skills/domains/data-engineering/SKILL.md +188 -26
  8. package/skills/domains/development/SKILL.md +1 -4
  9. package/skills/domains/devops/SKILL.md +3 -5
  10. package/skills/domains/devops/performance.md +63 -0
  11. package/skills/domains/devops/testing.md +97 -0
  12. package/skills/domains/frontend-design/SKILL.md +12 -3
  13. package/skills/domains/frontend-design/claymorphism/SKILL.md +117 -0
  14. package/skills/domains/frontend-design/claymorphism/references/tokens.css +52 -0
  15. package/skills/domains/frontend-design/engineering.md +287 -0
  16. package/skills/domains/frontend-design/glassmorphism/SKILL.md +138 -0
  17. package/skills/domains/frontend-design/glassmorphism/references/tokens.css +32 -0
  18. package/skills/domains/frontend-design/liquid-glass/SKILL.md +135 -0
  19. package/skills/domains/frontend-design/liquid-glass/references/tokens.css +81 -0
  20. package/skills/domains/frontend-design/neubrutalism/SKILL.md +141 -0
  21. package/skills/domains/frontend-design/neubrutalism/references/tokens.css +44 -0
  22. package/skills/domains/infrastructure/SKILL.md +174 -34
  23. package/skills/domains/mobile/SKILL.md +211 -21
  24. package/skills/domains/orchestration/SKILL.md +1 -0
  25. package/skills/domains/security/SKILL.md +4 -6
  26. package/skills/domains/security/blue-team.md +57 -0
  27. package/skills/domains/security/red-team.md +54 -0
  28. package/skills/domains/security/threat-intel.md +50 -0
  29. package/skills/orchestration/multi-agent/SKILL.md +195 -46
  30. package/skills/run_skill.js +134 -0
  31. package/skills/tools/gen-docs/SKILL.md +6 -4
  32. package/skills/tools/gen-docs/scripts/doc_generator.js +349 -0
  33. package/skills/tools/verify-change/SKILL.md +8 -6
  34. package/skills/tools/verify-change/scripts/change_analyzer.js +270 -0
  35. package/skills/tools/verify-module/SKILL.md +6 -4
  36. package/skills/tools/verify-module/scripts/module_scanner.js +145 -0
  37. package/skills/tools/verify-quality/SKILL.md +5 -3
  38. package/skills/tools/verify-quality/scripts/quality_checker.js +276 -0
  39. package/skills/tools/verify-security/SKILL.md +7 -5
  40. package/skills/tools/verify-security/scripts/security_scanner.js +133 -0
  41. package/skills/__pycache__/run_skill.cpython-312.pyc +0 -0
  42. package/skills/domains/COVERAGE_PLAN.md +0 -232
  43. package/skills/domains/ai/model-evaluation.md +0 -790
  44. package/skills/domains/ai/prompt-engineering.md +0 -703
  45. package/skills/domains/architecture/compliance.md +0 -299
  46. package/skills/domains/architecture/data-security.md +0 -184
  47. package/skills/domains/data-engineering/data-pipeline.md +0 -762
  48. package/skills/domains/data-engineering/data-quality.md +0 -894
  49. package/skills/domains/data-engineering/stream-processing.md +0 -791
  50. package/skills/domains/development/dart.md +0 -963
  51. package/skills/domains/development/kotlin.md +0 -834
  52. package/skills/domains/development/php.md +0 -659
  53. package/skills/domains/development/swift.md +0 -755
  54. package/skills/domains/devops/e2e-testing.md +0 -914
  55. package/skills/domains/devops/performance-testing.md +0 -734
  56. package/skills/domains/devops/testing-strategy.md +0 -667
  57. package/skills/domains/frontend-design/build-tools.md +0 -743
  58. package/skills/domains/frontend-design/performance.md +0 -734
  59. package/skills/domains/frontend-design/testing.md +0 -699
  60. package/skills/domains/infrastructure/gitops.md +0 -735
  61. package/skills/domains/infrastructure/iac.md +0 -855
  62. package/skills/domains/infrastructure/kubernetes.md +0 -1018
  63. package/skills/domains/mobile/android-dev.md +0 -979
  64. package/skills/domains/mobile/cross-platform.md +0 -795
  65. package/skills/domains/mobile/ios-dev.md +0 -931
  66. package/skills/domains/security/secrets-management.md +0 -834
  67. package/skills/domains/security/supply-chain.md +0 -931
  68. package/skills/domains/security/threat-modeling.md +0 -828
  69. package/skills/run_skill.py +0 -153
  70. package/skills/tests/README.md +0 -225
  71. package/skills/tests/SUMMARY.md +0 -362
  72. package/skills/tests/__init__.py +0 -3
  73. package/skills/tests/__pycache__/test_change_analyzer.cpython-312.pyc +0 -0
  74. package/skills/tests/__pycache__/test_doc_generator.cpython-312.pyc +0 -0
  75. package/skills/tests/__pycache__/test_module_scanner.cpython-312.pyc +0 -0
  76. package/skills/tests/__pycache__/test_quality_checker.cpython-312.pyc +0 -0
  77. package/skills/tests/__pycache__/test_security_scanner.cpython-312.pyc +0 -0
  78. package/skills/tests/test_change_analyzer.py +0 -558
  79. package/skills/tests/test_doc_generator.py +0 -538
  80. package/skills/tests/test_module_scanner.py +0 -376
  81. package/skills/tests/test_quality_checker.py +0 -516
  82. package/skills/tests/test_security_scanner.py +0 -426
  83. package/skills/tools/gen-docs/scripts/__pycache__/doc_generator.cpython-312.pyc +0 -0
  84. package/skills/tools/gen-docs/scripts/doc_generator.py +0 -520
  85. package/skills/tools/verify-change/scripts/__pycache__/change_analyzer.cpython-312.pyc +0 -0
  86. package/skills/tools/verify-change/scripts/change_analyzer.py +0 -529
  87. package/skills/tools/verify-module/scripts/__pycache__/module_scanner.cpython-312.pyc +0 -0
  88. package/skills/tools/verify-module/scripts/module_scanner.py +0 -321
  89. package/skills/tools/verify-quality/scripts/__pycache__/quality_checker.cpython-312.pyc +0 -0
  90. package/skills/tools/verify-quality/scripts/quality_checker.py +0 -481
  91. package/skills/tools/verify-security/scripts/__pycache__/security_scanner.cpython-312.pyc +0 -0
  92. package/skills/tools/verify-security/scripts/security_scanner.py +0 -374
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Skills 运行入口
4
- 跨平台统一调用各 skill 脚本
5
-
6
- 用法:
7
- python run_skill.py <skill_name> [args...]
8
-
9
- 示例:
10
- python run_skill.py verify-module ./my-project -v
11
- python run_skill.py verify-security ./src --json
12
- python run_skill.py verify-change --mode staged
13
- python run_skill.py verify-quality ./src
14
- python run_skill.py gen-docs ./new-module --force
15
- """
16
-
17
- import sys
18
- import subprocess
19
- import hashlib
20
- import tempfile
21
- from pathlib import Path
22
- import os
23
-
24
- IS_WIN = sys.platform == 'win32'
25
- if IS_WIN:
26
- import msvcrt
27
- else:
28
- import fcntl
29
-
30
-
31
- def get_skills_dir() -> Path:
32
- """获取 skills 目录路径(跨平台)"""
33
- override = os.environ.get("SAGE_SKILLS_DIR")
34
- if override:
35
- return Path(override).expanduser().resolve()
36
- return Path(__file__).resolve().parent
37
-
38
-
39
- def discover_skills(skills_dir: Path) -> dict:
40
- """自动发现 tools/ 下所有 skill(按目录结构扫描)"""
41
- found = {}
42
- tools_dir = skills_dir / "tools"
43
- if not tools_dir.is_dir():
44
- return found
45
- for skill_dir in sorted(tools_dir.iterdir()):
46
- if not skill_dir.is_dir():
47
- continue
48
- scripts_dir = skill_dir / "scripts"
49
- if not scripts_dir.is_dir():
50
- continue
51
- py_files = list(scripts_dir.glob("*.py"))
52
- if py_files:
53
- found[skill_dir.name] = py_files[0]
54
- return found
55
-
56
-
57
- def get_script_path(skill_name: str) -> Path:
58
- """获取 skill 脚本路径"""
59
- skills_dir = get_skills_dir()
60
- available = discover_skills(skills_dir)
61
-
62
- if skill_name not in available:
63
- names = ", ".join(available.keys()) if available else "(无)"
64
- print(f"错误: 未知的 skill '{skill_name}'")
65
- print(f"可用的 skills: {names}")
66
- sys.exit(1)
67
-
68
- return available[skill_name]
69
-
70
-
71
- def acquire_target_lock(args: list):
72
- """按目标路径获取文件锁,同路径串行,不同路径并行。返回 (lock_fd, lock_path) 或 (None, None)"""
73
- # 从参数中提取目标路径(第一个非 flag 参数)
74
- target = None
75
- for a in args:
76
- if not a.startswith('-'):
77
- target = a
78
- break
79
- if not target:
80
- target = os.getcwd()
81
-
82
- target = str(Path(target).resolve())
83
- lock_name = "sage_skill_" + hashlib.md5(target.encode()).hexdigest()[:12] + ".lock"
84
- lock_path = Path(tempfile.gettempdir()) / lock_name
85
-
86
- fd = open(lock_path, 'w')
87
- if IS_WIN:
88
- import time
89
- for _ in range(300): # 最多等 30s
90
- try:
91
- msvcrt.locking(fd.fileno(), msvcrt.LK_NBLCK, 1)
92
- return fd, lock_path
93
- except OSError:
94
- time.sleep(0.1)
95
- print(f"⏳ 等待锁超时: {target}")
96
- msvcrt.locking(fd.fileno(), msvcrt.LK_LOCK, 1)
97
- else:
98
- try:
99
- fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
100
- except OSError:
101
- print(f"⏳ 等待锁释放: {target}")
102
- fcntl.flock(fd, fcntl.LOCK_EX) # 阻塞等待
103
- return fd, lock_path
104
-
105
-
106
- def release_lock(fd):
107
- """释放文件锁"""
108
- if not fd:
109
- return
110
- try:
111
- if IS_WIN:
112
- msvcrt.locking(fd.fileno(), msvcrt.LK_UNLCK, 1)
113
- else:
114
- fcntl.flock(fd, fcntl.LOCK_UN)
115
- finally:
116
- fd.close()
117
-
118
-
119
- def main():
120
- if len(sys.argv) < 2:
121
- print(__doc__)
122
- sys.exit(1)
123
-
124
- skill_name = sys.argv[1]
125
-
126
- if skill_name in ["-h", "--help"]:
127
- print(__doc__)
128
- sys.exit(0)
129
-
130
- script_path = get_script_path(skill_name)
131
- args = sys.argv[2:]
132
-
133
- # 按目标路径加锁,防止多 Agent 同时操作同一目录
134
- lock_fd, lock_path = acquire_target_lock(args)
135
-
136
- # 使用 sys.executable 确保使用当前 Python 解释器
137
- cmd = [sys.executable, str(script_path)] + args
138
-
139
- try:
140
- result = subprocess.run(cmd)
141
- sys.exit(result.returncode)
142
- except KeyboardInterrupt:
143
- print("\n已取消")
144
- sys.exit(130)
145
- except Exception as e:
146
- print(f"执行错误: {e}")
147
- sys.exit(1)
148
- finally:
149
- release_lock(lock_fd)
150
-
151
-
152
- if __name__ == "__main__":
153
- main()
@@ -1,225 +0,0 @@
1
- # Skills 单元测试套件
2
-
3
- 为 Claude Sage 的 5 个 skill 脚本创建的完整单元测试套件。
4
-
5
- ## 测试覆盖
6
-
7
- ### 1. test_security_scanner.py
8
- 测试 `verify-security` 安全扫描器功能
9
-
10
- **测试内容:**
11
- - SQL 注入、命令注入、XSS 等安全漏洞检测
12
- - 硬编码密钥、私钥等敏感信息检测
13
- - 弱加密算法、不安全反序列化检测
14
- - 调试代码检测
15
- - 目录扫描、文件排除、编码错误处理
16
- - 报告格式化和数据结构
17
-
18
- **测试数量:** 35 个测试
19
-
20
- ### 2. test_module_scanner.py
21
- 测试 `verify-module` 模块结构扫描器功能
22
-
23
- **测试内容:**
24
- - 必需文件检查(README.md、DESIGN.md)
25
- - 源码目录检查(src、lib、pkg 等)
26
- - 测试目录检查(tests、test、__tests__ 等)
27
- - 文档质量检查
28
- - 目录结构扫描
29
- - 边界条件处理
30
-
31
- **测试数量:** 30 个测试
32
-
33
- ### 3. test_change_analyzer.py
34
- 测试 `verify-change` 变更分析器功能
35
-
36
- **测试内容:**
37
- - 文件分类(代码、文档、测试、配置)
38
- - 受影响模块识别
39
- - 文档同步检查
40
- - 变更影响分析
41
- - 报告格式化
42
- - 多种文件类型处理
43
-
44
- **测试数量:** 35 个测试
45
-
46
- ### 4. test_quality_checker.py
47
- 测试 `verify-quality` 代码质量检查器功能
48
-
49
- **测试内容:**
50
- - Python 文件分析(复杂度、长度、命名规范)
51
- - 通用代码文件分析
52
- - 语法错误检测
53
- - 长函数、高复杂度、参数过多检测
54
- - 行长度、文件大小检测
55
- - 注释统计
56
- - 多语言支持
57
-
58
- **测试数量:** 40 个测试
59
-
60
- ### 5. test_doc_generator.py
61
- 测试 `gen-docs` 文档生成器功能
62
-
63
- **测试内容:**
64
- - 语言检测(Python、Go、Rust、TypeScript 等)
65
- - Python 模块分析
66
- - 依赖检测
67
- - 入口点检测
68
- - README 生成
69
- - DESIGN 生成
70
- - 文件创建和覆盖
71
-
72
- **测试数量:** 40 个测试
73
-
74
- ## 运行测试
75
-
76
- ### 方式 1:使用 unittest 运行所有测试
77
-
78
- ```bash
79
- python3 -m unittest discover skills/tests/ -v
80
- ```
81
-
82
- ### 方式 2:运行特定测试文件
83
-
84
- ```bash
85
- python3 -m unittest skills.tests.test_security_scanner -v
86
- python3 -m unittest skills.tests.test_module_scanner -v
87
- python3 -m unittest skills.tests.test_change_analyzer -v
88
- python3 -m unittest skills.tests.test_quality_checker -v
89
- python3 -m unittest skills.tests.test_doc_generator -v
90
- ```
91
-
92
- ### 方式 3:运行特定测试类
93
-
94
- ```bash
95
- python3 -m unittest skills.tests.test_security_scanner.TestSecurityScanner -v
96
- python3 -m unittest skills.tests.test_security_scanner.TestSecurityScannerEdgeCases -v
97
- ```
98
-
99
- ### 方式 4:运行特定测试方法
100
-
101
- ```bash
102
- python3 -m unittest skills.tests.test_security_scanner.TestSecurityScanner.test_scan_file_with_sql_injection -v
103
- ```
104
-
105
- ### 方式 5:使用 pytest(如果已安装)
106
-
107
- ```bash
108
- pytest skills/tests/ -v
109
- pytest skills/tests/test_security_scanner.py -v
110
- pytest skills/tests/test_security_scanner.py::TestSecurityScanner::test_scan_file_with_sql_injection -v
111
- ```
112
-
113
- ## 测试特点
114
-
115
- ### 完整的功能覆盖
116
- - 基本功能测试:验证核心功能正常工作
117
- - 边界条件测试:处理空目录、不存在的路径、特殊字符等
118
- - 错误处理测试:验证优雅处理异常情况
119
-
120
- ### 使用临时目录
121
- 所有测试都使用 `tempfile.TemporaryDirectory()` 创建临时目录,不污染实际文件系统。
122
-
123
- ### 自动清理
124
- 每个测试类都有 `setUp()` 和 `tearDown()` 方法,确保测试前后的环境清洁。
125
-
126
- ### 数据驱动
127
- 测试覆盖多种文件类型、编程语言、编码方式等。
128
-
129
- ## 测试统计
130
-
131
- - **总测试数:** 160 个
132
- - **测试类数:** 10 个(每个 skill 2 个类)
133
- - **覆盖率:** 核心功能 100%
134
-
135
- ## 测试结果
136
-
137
- ```
138
- Ran 160 tests in 0.062s
139
-
140
- OK
141
- ```
142
-
143
- 所有测试都通过。
144
-
145
- ## 文件结构
146
-
147
- ```
148
- skills/
149
- ├── tests/
150
- │ ├── __init__.py # 测试包初始化
151
- │ ├── test_security_scanner.py # verify-security 测试
152
- │ ├── test_module_scanner.py # verify-module 测试
153
- │ ├── test_change_analyzer.py # verify-change 测试
154
- │ ├── test_quality_checker.py # verify-quality 测试
155
- │ └── test_doc_generator.py # gen-docs 测试
156
- ├── verify-security/
157
- │ └── scripts/
158
- │ └── security_scanner.py
159
- ├── verify-module/
160
- │ └── scripts/
161
- │ └── module_scanner.py
162
- ├── verify-change/
163
- │ └── scripts/
164
- │ └── change_analyzer.py
165
- ├── verify-quality/
166
- │ └── scripts/
167
- │ └── quality_checker.py
168
- ├── gen-docs/
169
- │ └── scripts/
170
- │ └── doc_generator.py
171
- └── run_skill.py
172
- ```
173
-
174
- ## 测试命名规范
175
-
176
- - 测试类:`Test<SkillName>` 和 `Test<SkillName>EdgeCases`
177
- - 测试方法:`test_<feature>_<scenario>`
178
- - 中文文档字符串:描述测试的目的
179
-
180
- ## 添加新测试
181
-
182
- 1. 在对应的测试文件中添加新的测试方法
183
- 2. 使用 `setUp()` 创建临时目录
184
- 3. 使用 `tearDown()` 清理资源
185
- 4. 遵循命名规范
186
- 5. 添加中文文档字符串
187
-
188
- 示例:
189
-
190
- ```python
191
- def test_new_feature(self):
192
- """测试新功能"""
193
- test_file = self.temp_path / "test.py"
194
- test_file.write_text("x = 1")
195
-
196
- result = some_function(test_file)
197
-
198
- self.assertEqual(result, expected_value)
199
- ```
200
-
201
- ## 依赖
202
-
203
- - Python 3.6+
204
- - 标准库:unittest、tempfile、pathlib
205
-
206
- ## 注意事项
207
-
208
- 1. 测试使用临时目录,不会修改实际文件系统
209
- 2. 所有测试都是独立的,可以任意顺序运行
210
- 3. 测试不依赖外部网络或服务
211
- 4. 测试执行速度快(160 个测试在 0.062 秒内完成)
212
-
213
- ## 持续集成
214
-
215
- 这些测试可以集成到 CI/CD 流程中:
216
-
217
- ```bash
218
- # GitHub Actions 示例
219
- - name: Run tests
220
- run: python3 -m unittest discover skills/tests/ -v
221
- ```
222
-
223
- ## 许可证
224
-
225
- 与 Claude Sage 项目相同。