code-abyss 1.5.1

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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -0
  3. package/bin/install.js +193 -0
  4. package/bin/uninstall.js +42 -0
  5. package/config/AGENTS.md +247 -0
  6. package/config/CLAUDE.md +207 -0
  7. package/config/settings.example.json +27 -0
  8. package/output-styles/abyss-cultivator.md +399 -0
  9. package/package.json +41 -0
  10. package/skills/SKILL.md +115 -0
  11. package/skills/ai/SKILL.md +29 -0
  12. package/skills/ai/agent-dev.md +242 -0
  13. package/skills/ai/llm-security.md +288 -0
  14. package/skills/architecture/SKILL.md +41 -0
  15. package/skills/architecture/api-design.md +225 -0
  16. package/skills/architecture/caching.md +299 -0
  17. package/skills/architecture/cloud-native.md +285 -0
  18. package/skills/architecture/compliance.md +299 -0
  19. package/skills/architecture/data-security.md +184 -0
  20. package/skills/architecture/message-queue.md +329 -0
  21. package/skills/architecture/security-arch.md +210 -0
  22. package/skills/development/SKILL.md +43 -0
  23. package/skills/development/cpp.md +246 -0
  24. package/skills/development/go.md +323 -0
  25. package/skills/development/java.md +277 -0
  26. package/skills/development/python.md +288 -0
  27. package/skills/development/rust.md +313 -0
  28. package/skills/development/shell.md +313 -0
  29. package/skills/development/typescript.md +277 -0
  30. package/skills/devops/SKILL.md +36 -0
  31. package/skills/devops/cost-optimization.md +272 -0
  32. package/skills/devops/database.md +217 -0
  33. package/skills/devops/devsecops.md +198 -0
  34. package/skills/devops/git-workflow.md +181 -0
  35. package/skills/devops/observability.md +280 -0
  36. package/skills/devops/performance.md +273 -0
  37. package/skills/devops/testing.md +186 -0
  38. package/skills/gen-docs/SKILL.md +114 -0
  39. package/skills/gen-docs/scripts/doc_generator.py +491 -0
  40. package/skills/multi-agent/SKILL.md +268 -0
  41. package/skills/run_skill.py +88 -0
  42. package/skills/security/SKILL.md +51 -0
  43. package/skills/security/blue-team.md +379 -0
  44. package/skills/security/code-audit.md +265 -0
  45. package/skills/security/pentest.md +226 -0
  46. package/skills/security/red-team.md +321 -0
  47. package/skills/security/threat-intel.md +322 -0
  48. package/skills/security/vuln-research.md +369 -0
  49. package/skills/tests/README.md +225 -0
  50. package/skills/tests/SUMMARY.md +362 -0
  51. package/skills/tests/__init__.py +3 -0
  52. package/skills/tests/test_change_analyzer.py +558 -0
  53. package/skills/tests/test_doc_generator.py +538 -0
  54. package/skills/tests/test_module_scanner.py +376 -0
  55. package/skills/tests/test_quality_checker.py +516 -0
  56. package/skills/tests/test_security_scanner.py +426 -0
  57. package/skills/verify-change/SKILL.md +138 -0
  58. package/skills/verify-change/scripts/change_analyzer.py +529 -0
  59. package/skills/verify-module/SKILL.md +125 -0
  60. package/skills/verify-module/scripts/module_scanner.py +321 -0
  61. package/skills/verify-quality/SKILL.md +158 -0
  62. package/skills/verify-quality/scripts/quality_checker.py +481 -0
  63. package/skills/verify-security/SKILL.md +141 -0
  64. package/skills/verify-security/scripts/security_scanner.py +368 -0
@@ -0,0 +1,277 @@
1
+ ---
2
+ name: typescript
3
+ description: TypeScript/JavaScript 开发。前后端、Node.js、React、Vue。当用户提到 TypeScript、JavaScript、Node、React、Vue、Next.js 时使用。
4
+ ---
5
+
6
+ # 📜 符箓秘典 · TypeScript/JavaScript
7
+
8
+
9
+ ## TypeScript 基础
10
+
11
+ ### 类型系统
12
+ ```typescript
13
+ // 基础类型
14
+ let name: string = "Alice";
15
+ let age: number = 25;
16
+ let active: boolean = true;
17
+ let items: string[] = ["a", "b"];
18
+ let tuple: [string, number] = ["hello", 10];
19
+
20
+ // 接口
21
+ interface User {
22
+ id: number;
23
+ name: string;
24
+ email?: string; // 可选
25
+ readonly createdAt: Date; // 只读
26
+ }
27
+
28
+ // 类型别名
29
+ type ID = string | number;
30
+ type Status = "pending" | "active" | "inactive";
31
+
32
+ // 泛型
33
+ function identity<T>(arg: T): T {
34
+ return arg;
35
+ }
36
+
37
+ interface Response<T> {
38
+ data: T;
39
+ status: number;
40
+ }
41
+
42
+ // 工具类型
43
+ type Partial<T> = { [P in keyof T]?: T[P] };
44
+ type Required<T> = { [P in keyof T]-?: T[P] };
45
+ type Pick<T, K extends keyof T> = { [P in K]: T[P] };
46
+ type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
47
+ ```
48
+
49
+ ## Node.js 后端
50
+
51
+ ### Express
52
+ ```typescript
53
+ import express, { Request, Response, NextFunction } from 'express';
54
+
55
+ const app = express();
56
+ app.use(express.json());
57
+
58
+ // 中间件
59
+ const authMiddleware = (req: Request, res: Response, next: NextFunction) => {
60
+ const token = req.headers.authorization;
61
+ if (!token) {
62
+ return res.status(401).json({ error: 'Unauthorized' });
63
+ }
64
+ next();
65
+ };
66
+
67
+ // 路由
68
+ app.get('/api/users/:id', async (req: Request, res: Response) => {
69
+ const { id } = req.params;
70
+ const user = await getUserById(id);
71
+ res.json(user);
72
+ });
73
+
74
+ app.post('/api/users', async (req: Request, res: Response) => {
75
+ const user = await createUser(req.body);
76
+ res.status(201).json(user);
77
+ });
78
+
79
+ // 错误处理
80
+ app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
81
+ console.error(err.stack);
82
+ res.status(500).json({ error: 'Internal Server Error' });
83
+ });
84
+
85
+ app.listen(3000);
86
+ ```
87
+
88
+ ### Fastify
89
+ ```typescript
90
+ import Fastify from 'fastify';
91
+
92
+ const fastify = Fastify({ logger: true });
93
+
94
+ fastify.get('/users/:id', async (request, reply) => {
95
+ const { id } = request.params as { id: string };
96
+ return { id };
97
+ });
98
+
99
+ fastify.listen({ port: 3000 });
100
+ ```
101
+
102
+ ## React
103
+
104
+ ### 函数组件
105
+ ```tsx
106
+ import React, { useState, useEffect, useCallback } from 'react';
107
+
108
+ interface User {
109
+ id: number;
110
+ name: string;
111
+ }
112
+
113
+ interface Props {
114
+ userId: number;
115
+ onSelect?: (user: User) => void;
116
+ }
117
+
118
+ const UserCard: React.FC<Props> = ({ userId, onSelect }) => {
119
+ const [user, setUser] = useState<User | null>(null);
120
+ const [loading, setLoading] = useState(true);
121
+
122
+ useEffect(() => {
123
+ fetchUser(userId).then(data => {
124
+ setUser(data);
125
+ setLoading(false);
126
+ });
127
+ }, [userId]);
128
+
129
+ const handleClick = useCallback(() => {
130
+ if (user && onSelect) {
131
+ onSelect(user);
132
+ }
133
+ }, [user, onSelect]);
134
+
135
+ if (loading) return <div>Loading...</div>;
136
+ if (!user) return <div>User not found</div>;
137
+
138
+ return (
139
+ <div onClick={handleClick}>
140
+ <h2>{user.name}</h2>
141
+ </div>
142
+ );
143
+ };
144
+
145
+ export default UserCard;
146
+ ```
147
+
148
+ ### Hooks
149
+ ```tsx
150
+ // 自定义 Hook
151
+ function useFetch<T>(url: string) {
152
+ const [data, setData] = useState<T | null>(null);
153
+ const [loading, setLoading] = useState(true);
154
+ const [error, setError] = useState<Error | null>(null);
155
+
156
+ useEffect(() => {
157
+ fetch(url)
158
+ .then(res => res.json())
159
+ .then(setData)
160
+ .catch(setError)
161
+ .finally(() => setLoading(false));
162
+ }, [url]);
163
+
164
+ return { data, loading, error };
165
+ }
166
+
167
+ // 使用
168
+ const { data, loading } = useFetch<User[]>('/api/users');
169
+ ```
170
+
171
+ ## Vue 3
172
+
173
+ ### Composition API
174
+ ```vue
175
+ <script setup lang="ts">
176
+ import { ref, computed, onMounted } from 'vue';
177
+
178
+ interface User {
179
+ id: number;
180
+ name: string;
181
+ }
182
+
183
+ const props = defineProps<{
184
+ userId: number;
185
+ }>();
186
+
187
+ const emit = defineEmits<{
188
+ (e: 'select', user: User): void;
189
+ }>();
190
+
191
+ const user = ref<User | null>(null);
192
+ const loading = ref(true);
193
+
194
+ const displayName = computed(() => user.value?.name ?? 'Unknown');
195
+
196
+ onMounted(async () => {
197
+ user.value = await fetchUser(props.userId);
198
+ loading.value = false;
199
+ });
200
+
201
+ const handleClick = () => {
202
+ if (user.value) {
203
+ emit('select', user.value);
204
+ }
205
+ };
206
+ </script>
207
+
208
+ <template>
209
+ <div v-if="loading">Loading...</div>
210
+ <div v-else-if="user" @click="handleClick">
211
+ <h2>{{ displayName }}</h2>
212
+ </div>
213
+ </template>
214
+ ```
215
+
216
+ ## 测试
217
+
218
+ ### Jest/Vitest
219
+ ```typescript
220
+ import { describe, it, expect, vi } from 'vitest';
221
+ import { render, screen, fireEvent } from '@testing-library/react';
222
+ import UserCard from './UserCard';
223
+
224
+ describe('UserCard', () => {
225
+ it('should render user name', async () => {
226
+ render(<UserCard userId={1} />);
227
+ expect(await screen.findByText('Alice')).toBeInTheDocument();
228
+ });
229
+
230
+ it('should call onSelect when clicked', async () => {
231
+ const onSelect = vi.fn();
232
+ render(<UserCard userId={1} onSelect={onSelect} />);
233
+
234
+ const card = await screen.findByRole('button');
235
+ fireEvent.click(card);
236
+
237
+ expect(onSelect).toHaveBeenCalledWith({ id: 1, name: 'Alice' });
238
+ });
239
+ });
240
+
241
+ // Mock
242
+ vi.mock('./api', () => ({
243
+ fetchUser: vi.fn().mockResolvedValue({ id: 1, name: 'Alice' })
244
+ }));
245
+ ```
246
+
247
+ ## 项目结构
248
+
249
+ ```
250
+ myproject/
251
+ ├── package.json
252
+ ├── tsconfig.json
253
+ ├── src/
254
+ │ ├── index.ts
255
+ │ ├── components/
256
+ │ ├── hooks/
257
+ │ ├── services/
258
+ │ ├── types/
259
+ │ └── utils/
260
+ ├── tests/
261
+ └── public/
262
+ ```
263
+
264
+ ## 常用库
265
+
266
+ | 库 | 用途 |
267
+ |---|------|
268
+ | Express/Fastify | Node.js 框架 |
269
+ | React/Vue | 前端框架 |
270
+ | Next.js/Nuxt | 全栈框架 |
271
+ | Prisma | ORM |
272
+ | Zod | 数据验证 |
273
+ | Vitest/Jest | 测试 |
274
+ | ESLint/Prettier | 代码规范 |
275
+
276
+ ---
277
+
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: devops
3
+ description: DevOps 能力索引。Git、测试、DevSecOps、数据库。当用户提到 DevOps、CI/CD、Git、测试时路由到此。
4
+ ---
5
+
6
+ # 🔧 炼器秘典 · DevOps 能力中枢
7
+
8
+
9
+ ## 能力矩阵
10
+
11
+ | Skill | 定位 | 核心能力 |
12
+ |-------|------|----------|
13
+ | [git-workflow](git-workflow.md) | 版本控制 | Git、分支策略、PR |
14
+ | [testing](testing.md) | 软件测试 | 单元测试、集成测试、TDD |
15
+ | [devsecops](devsecops.md) | 安全开发 | CI/CD安全、供应链安全 |
16
+ | [database](database.md) | 数据库 | SQL、NoSQL、优化 |
17
+ | [performance](performance.md) | 性能优化 | Profiling、火焰图、基准测试 |
18
+ | [observability](observability.md) | 可观测性 | 日志、指标、追踪、SLO |
19
+ | [cost-optimization](cost-optimization.md) | 成本优化 | FinOps、右尺寸、Spot、伸缩 |
20
+
21
+ ## DevOps 原则
22
+
23
+ ```yaml
24
+ 文化:
25
+ - 协作与共享
26
+ - 持续改进
27
+ - 自动化一切
28
+ - 快速反馈
29
+
30
+ 实践:
31
+ - 持续集成 (CI)
32
+ - 持续交付 (CD)
33
+ - 基础设施即代码
34
+ - 监控与可观测性
35
+ ```
36
+
@@ -0,0 +1,272 @@
1
+ ---
2
+ name: cost-optimization
3
+ description: 成本优化秘典。FinOps框架、计算/存储/网络优化、成本建模。当用户提到成本、费用、FinOps、省钱、预算、账单时路由到此。
4
+ ---
5
+
6
+ # 🔧 炼器秘典 · 成本优化
7
+
8
+
9
+ ## FinOps 框架
10
+
11
+ ```
12
+ ┌─────────────────────────────────────┐
13
+ │ FinOps 生命周期 │
14
+ ├───────────┬───────────┬─────────────┤
15
+ │ Inform │ Optimize │ Operate │
16
+ │ 可视化 │ 优化 │ 运营 │
17
+ │ 谁花了 │ 怎么省 │ 持续治理 │
18
+ │ 多少钱 │ 多少钱 │ 流程制度 │
19
+ └───────────┴───────────┴─────────────┘
20
+ ```
21
+
22
+ | 阶段 | 目标 | 关键动作 |
23
+ |------|------|----------|
24
+ | Inform | 成本可视化 | 标签策略、成本分摊、Dashboard |
25
+ | Optimize | 降低浪费 | 右尺寸、预留、Spot、清理闲置 |
26
+ | Operate | 持续治理 | 预算告警、审批流程、定期审查 |
27
+
28
+ ---
29
+
30
+ ## 成本分析
31
+
32
+ ### 标签策略
33
+
34
+ ```yaml
35
+ 必选标签:
36
+ - Environment: prod/staging/dev
37
+ - Team: platform/backend/frontend
38
+ - Service: order-service/user-service
39
+ - Owner: team-email
40
+ - CostCenter: CC-001
41
+
42
+ 可选标签:
43
+ - Project: project-name
44
+ - Temporary: expiry-date
45
+ ```
46
+
47
+ ### 成本归因
48
+
49
+ ```
50
+ 总成本
51
+ ├── 按团队: Team-A (40%) | Team-B (35%) | 共享 (25%)
52
+ ├── 按环境: Prod (60%) | Staging (25%) | Dev (15%)
53
+ ├── 按服务: 计算 (45%) | 存储 (25%) | 网络 (15%) | 其他 (15%)
54
+ └── 按类型: On-Demand (30%) | Reserved (50%) | Spot (10%) | 其他 (10%)
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 计算优化
60
+
61
+ ### 右尺寸 (Right-sizing)
62
+
63
+ ```bash
64
+ # AWS - 查找低利用率实例
65
+ aws ce get-rightsizing-recommendation \
66
+ --service EC2 \
67
+ --configuration '{"RecommendationTarget":"SAME_INSTANCE_FAMILY","BenefitsConsidered":true}'
68
+
69
+ # 判断标准
70
+ # CPU 平均 < 20% 且 峰值 < 50% → 缩小
71
+ # CPU 平均 > 70% 或 峰值 > 90% → 扩大
72
+ # Memory 使用 < 30% → 缩小
73
+ ```
74
+
75
+ ### 预留实例 / Savings Plans
76
+
77
+ | 类型 | 折扣 | 灵活性 | 适用 |
78
+ |------|------|--------|------|
79
+ | Reserved Instance (1yr) | ~30% | 低 | 稳定负载 |
80
+ | Reserved Instance (3yr) | ~50% | 低 | 长期稳定 |
81
+ | Savings Plans (Compute) | ~30% | 高 | 跨实例族 |
82
+ | Savings Plans (EC2) | ~40% | 中 | 固定区域 |
83
+
84
+ ### Spot 实例
85
+
86
+ ```yaml
87
+ 适用场景:
88
+ - 批处理任务
89
+ - CI/CD 构建
90
+ - 无状态 Web 服务(配合 ASG)
91
+ - 大数据处理
92
+
93
+ 不适用:
94
+ - 数据库
95
+ - 有状态服务
96
+ - 长时间运行的关键任务
97
+
98
+ 最佳实践:
99
+ - 多实例类型混合
100
+ - 跨可用区分散
101
+ - 设置中断处理 (2分钟通知)
102
+ - 配合 On-Demand 保底
103
+ ```
104
+
105
+ ### 自动伸缩
106
+
107
+ ```yaml
108
+ # Target Tracking (推荐)
109
+ scaling_policy:
110
+ type: TargetTrackingScaling
111
+ target_value: 70 # CPU 目标 70%
112
+ scale_in_cooldown: 300
113
+ scale_out_cooldown: 60
114
+
115
+ # 预测性伸缩
116
+ predictive_scaling:
117
+ mode: ForecastAndScale
118
+ scheduling_buffer_time: 300
119
+
120
+ # 定时伸缩 (已知流量模式)
121
+ scheduled_actions:
122
+ - schedule: "cron(0 8 * * MON-FRI)" # 工作日早8点扩容
123
+ min_capacity: 10
124
+ - schedule: "cron(0 20 * * MON-FRI)" # 晚8点缩容
125
+ min_capacity: 2
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 存储优化
131
+
132
+ ### 存储分层
133
+
134
+ | 层级 | 访问频率 | 成本 | 适用 |
135
+ |------|----------|------|------|
136
+ | S3 Standard | 频繁 | $$$ | 活跃数据 |
137
+ | S3 IA | 月级 | $$ | 备份、日志 |
138
+ | S3 Glacier | 季度级 | $ | 归档 |
139
+ | S3 Glacier Deep | 年级 | ¢ | 合规归档 |
140
+
141
+ ### 生命周期策略
142
+
143
+ ```json
144
+ {
145
+ "Rules": [
146
+ {
147
+ "ID": "log-lifecycle",
148
+ "Filter": {"Prefix": "logs/"},
149
+ "Transitions": [
150
+ {"Days": 30, "StorageClass": "STANDARD_IA"},
151
+ {"Days": 90, "StorageClass": "GLACIER"},
152
+ {"Days": 365, "StorageClass": "DEEP_ARCHIVE"}
153
+ ],
154
+ "Expiration": {"Days": 2555}
155
+ }
156
+ ]
157
+ }
158
+ ```
159
+
160
+ ### 数据库存储
161
+
162
+ ```yaml
163
+ 优化策略:
164
+ - 定期清理过期数据 (TTL/分区删除)
165
+ - 压缩历史表
166
+ - 归档冷数据到对象存储
167
+ - 使用列式存储处理分析查询
168
+ - 审查未使用的索引
169
+ ```
170
+
171
+ ---
172
+
173
+ ## 网络优化
174
+
175
+ | 优化项 | 方法 | 节省 |
176
+ |--------|------|------|
177
+ | 跨 AZ 流量 | 同 AZ 优先路由 | ~$0.01/GB |
178
+ | 跨 Region 流量 | CDN + 边缘缓存 | ~$0.02/GB |
179
+ | NAT Gateway | 使用 VPC Endpoint | ~$0.045/GB |
180
+ | 数据传输 | 压缩 + 批量 | 30-70% |
181
+
182
+ ```yaml
183
+ VPC Endpoint 优先:
184
+ - S3: Gateway Endpoint (免费)
185
+ - DynamoDB: Gateway Endpoint (免费)
186
+ - 其他 AWS 服务: Interface Endpoint (按小时计费,但省流量费)
187
+ ```
188
+
189
+ ---
190
+
191
+ ## 应用层优化
192
+
193
+ ### 缓存降本
194
+
195
+ ```
196
+ 无缓存: 100% 请求打到数据库 → 需要大实例
197
+ 加缓存: 80% 缓存命中 → 数据库可缩小 60%
198
+ ```
199
+
200
+ ### 架构降本
201
+
202
+ | 模式 | 场景 | 节省 |
203
+ |------|------|------|
204
+ | Serverless | 低流量/突发 | 按调用付费,空闲零成本 |
205
+ | 容器化 | 中等流量 | 提高资源利用率 |
206
+ | 队列削峰 | 突发流量 | 减少峰值资源需求 |
207
+ | 读写分离 | 读多写少 | 读副本用小实例 |
208
+
209
+ ### 代码级降本
210
+
211
+ ```yaml
212
+ 减少外部调用:
213
+ - 批量 API 调用替代循环单次
214
+ - 本地缓存热数据
215
+ - 连接池复用
216
+
217
+ 减少计算:
218
+ - 惰性计算
219
+ - 增量处理替代全量
220
+ - 合理的超时设置(避免资源空等)
221
+ ```
222
+
223
+ ---
224
+
225
+ ## 成本建模
226
+
227
+ ### 单位经济学
228
+
229
+ ```
230
+ 单用户成本 = 总基础设施成本 / 活跃用户数
231
+
232
+ 目标: 随规模增长,单用户成本递减
233
+ ```
234
+
235
+ ### 成本预测
236
+
237
+ ```yaml
238
+ 输入:
239
+ - 当前月成本: $10,000
240
+ - 用户增长率: 20%/月
241
+ - 基础设施弹性系数: 0.7 (成本增长 = 用户增长 × 0.7)
242
+
243
+ 预测:
244
+ - M+1: $10,000 × (1 + 0.2 × 0.7) = $11,400
245
+ - M+3: ~$14,800
246
+ - M+6: ~$22,100
247
+ ```
248
+
249
+ ---
250
+
251
+ ## 成本优化清单
252
+
253
+ ```yaml
254
+ 即时见效 (Quick Wins):
255
+ - [ ] 清理闲置资源 (未挂载 EBS、空闲 EIP、停止的实例)
256
+ - [ ] 删除未使用的快照和 AMI
257
+ - [ ] 右尺寸低利用率实例
258
+ - [ ] 启用 S3 生命周期策略
259
+
260
+ 中期优化:
261
+ - [ ] 购买 Savings Plans / Reserved Instances
262
+ - [ ] Spot 实例用于非关键负载
263
+ - [ ] 配置自动伸缩
264
+ - [ ] VPC Endpoint 替代 NAT Gateway
265
+
266
+ 长期治理:
267
+ - [ ] 标签策略 100% 覆盖
268
+ - [ ] 成本分摊 Dashboard
269
+ - [ ] 月度成本审查会议
270
+ - [ ] 预算告警自动化
271
+ ```
272
+