transskill 0.2.0 → 0.2.2

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 (61) hide show
  1. package/README.md +162 -32
  2. package/README.zh.md +134 -4
  3. package/dist/audit/auditor-registry.d.ts +6 -0
  4. package/dist/audit/auditor-registry.d.ts.map +1 -0
  5. package/dist/audit/auditor-registry.js +17 -0
  6. package/dist/audit/auditor-registry.js.map +1 -0
  7. package/dist/audit/auditor.interface.d.ts +59 -0
  8. package/dist/audit/auditor.interface.d.ts.map +1 -0
  9. package/dist/audit/auditor.interface.js +36 -0
  10. package/dist/audit/auditor.interface.js.map +1 -0
  11. package/dist/audit/index.d.ts +39 -0
  12. package/dist/audit/index.d.ts.map +1 -0
  13. package/dist/audit/index.js +155 -0
  14. package/dist/audit/index.js.map +1 -0
  15. package/dist/audit/reporter/console-reporter.d.ts +4 -0
  16. package/dist/audit/reporter/console-reporter.d.ts.map +1 -0
  17. package/dist/audit/reporter/console-reporter.js +107 -0
  18. package/dist/audit/reporter/console-reporter.js.map +1 -0
  19. package/dist/audit/rules/dangerous-commands.d.ts +15 -0
  20. package/dist/audit/rules/dangerous-commands.d.ts.map +1 -0
  21. package/dist/audit/rules/dangerous-commands.js +189 -0
  22. package/dist/audit/rules/dangerous-commands.js.map +1 -0
  23. package/dist/audit/rules/prompt-injection.d.ts +15 -0
  24. package/dist/audit/rules/prompt-injection.d.ts.map +1 -0
  25. package/dist/audit/rules/prompt-injection.js +65 -0
  26. package/dist/audit/rules/prompt-injection.js.map +1 -0
  27. package/dist/audit/rules/suspicious-urls.d.ts +14 -0
  28. package/dist/audit/rules/suspicious-urls.d.ts.map +1 -0
  29. package/dist/audit/rules/suspicious-urls.js +42 -0
  30. package/dist/audit/rules/suspicious-urls.js.map +1 -0
  31. package/dist/audit/scanner/directory-scanner.d.ts +40 -0
  32. package/dist/audit/scanner/directory-scanner.d.ts.map +1 -0
  33. package/dist/audit/scanner/directory-scanner.js +288 -0
  34. package/dist/audit/scanner/directory-scanner.js.map +1 -0
  35. package/dist/audit/scanner/instruction-scanner.d.ts +20 -0
  36. package/dist/audit/scanner/instruction-scanner.d.ts.map +1 -0
  37. package/dist/audit/scanner/instruction-scanner.js +147 -0
  38. package/dist/audit/scanner/instruction-scanner.js.map +1 -0
  39. package/dist/audit/scanner/mcp-scanner.d.ts +17 -0
  40. package/dist/audit/scanner/mcp-scanner.d.ts.map +1 -0
  41. package/dist/audit/scanner/mcp-scanner.js +181 -0
  42. package/dist/audit/scanner/mcp-scanner.js.map +1 -0
  43. package/dist/audit/scanner/permission-scanner.d.ts +19 -0
  44. package/dist/audit/scanner/permission-scanner.d.ts.map +1 -0
  45. package/dist/audit/scanner/permission-scanner.js +143 -0
  46. package/dist/audit/scanner/permission-scanner.js.map +1 -0
  47. package/dist/index.js +86 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/mapper/default.mapper.js +2 -2
  50. package/dist/mapper/default.mapper.js.map +1 -1
  51. package/dist/parser/cursor-rules.parser.d.ts +5 -0
  52. package/dist/parser/cursor-rules.parser.d.ts.map +1 -1
  53. package/dist/parser/cursor-rules.parser.js +28 -5
  54. package/dist/parser/cursor-rules.parser.js.map +1 -1
  55. package/dist/renderer/cursor-rules.renderer.d.ts.map +1 -1
  56. package/dist/renderer/cursor-rules.renderer.js +3 -5
  57. package/dist/renderer/cursor-rules.renderer.js.map +1 -1
  58. package/dist/renderer/mdc.renderer.d.ts.map +1 -1
  59. package/dist/renderer/mdc.renderer.js +3 -2
  60. package/dist/renderer/mdc.renderer.js.map +1 -1
  61. package/package.json +1 -1
package/README.md CHANGED
@@ -83,34 +83,6 @@ transskill convert .cursorrules --to skill.md --dry-run
83
83
  | MCP JSON | Any MCP-compatible client | ✅ | — |
84
84
  | SOUL.md | OpenClaw | ✅ | — |
85
85
 
86
- ## Commands
87
-
88
- ```bash
89
- # Convert a skill to another format
90
- transskill convert <input> --to <format> [options]
91
-
92
- # List all supported formats
93
- transskill list-formats
94
-
95
- # Validate a skill file or directory
96
- transskill validate <input>
97
-
98
- # See all options
99
- transskill --help
100
- ```
101
-
102
- ### Options for `convert`
103
-
104
- | Flag | Description |
105
- |------|-------------|
106
- | `-t, --to <format>` | Target format (required) |
107
- | `-o, --output <path>` | Output directory (default: current dir) |
108
- | `--install-to <path>` | Install directly to agent config dir |
109
- | `--glob <pattern>` | File glob pattern (for .mdc output) |
110
- | `--always-apply` | Always apply rule (for .mdc output) |
111
- | `--dry-run` | Preview without writing files |
112
- | `-v, --verbose` | Detailed conversion report |
113
-
114
86
  ## How It Works
115
87
 
116
88
  ```
@@ -164,19 +136,177 @@ $ transskill convert ./weather-skill/ --to .cursorrules
164
136
  ⚠️ SKILL.md scripts reference will not work in .cursorrules
165
137
  ```
166
138
 
139
+ ## Commands
140
+
141
+ ```bash
142
+ # Convert a skill to another format
143
+ transskill convert <input> --to <format> [options]
144
+
145
+ # List all supported formats
146
+ transskill list-formats
147
+
148
+ # Validate a skill file or directory
149
+ transskill validate <input>
150
+
151
+ # Security audit a skill file or directory
152
+ transskill audit <input> [options]
153
+
154
+ # See all options
155
+ transskill --help
156
+ ```
157
+
158
+ ### Options for `convert`
159
+
160
+ | Flag | Description |
161
+ |------|-------------|
162
+ | `-t, --to <format>` | Target format (required) |
163
+ | `-o, --output <path>` | Output directory (default: current dir) |
164
+ | `--install-to <path>` | Install directly to agent config dir |
165
+ | `--glob <pattern>` | File glob pattern (for .mdc output) |
166
+ | `--always-apply` | Always apply rule (for .mdc output) |
167
+ | `--dry-run` | Preview without writing files |
168
+ | `-v, --verbose` | Detailed conversion report |
169
+
170
+ ### Options for `audit`
171
+
172
+ | Flag | Description |
173
+ |------|-------------|
174
+ | `--format <type>` | Output format: `console` or `json` (default: console) |
175
+ | `--quiet` | Only show summary score |
176
+ | `--min-severity <level>` | Minimum severity: `info`, `low`, `medium`, `high`, `critical` (default: info) |
177
+ | `--auditor <id>` | Run only specific auditor (can be repeated) |
178
+ | `-v, --verbose` | Show detailed findings |
179
+
180
+ ---
181
+
182
+ ## Security Audit
183
+
184
+ TransSkill includes a built-in security scanner that analyzes skill files for potential security risks before you install or use them.
185
+
186
+ ```bash
187
+ # Quick scan a skill file
188
+ transskill audit my-skill.skill.md
189
+
190
+ # JSON output for programmatic use
191
+ transskill audit ./skill-dir/ --format json
192
+
193
+ # Quiet mode — just the score
194
+ transskill audit my-skill.skill.md --quiet
195
+
196
+ # Only show high and critical issues
197
+ transskill audit .cursorrules --min-severity high
198
+
199
+ # Run a specific auditor only
200
+ transskill audit mcp.json --auditor permission-scanner
201
+ ```
202
+
203
+ ### Audit Levels
204
+
205
+ The scanner checks three layers of security concerns:
206
+
207
+ | Level | Scanner | What It Checks |
208
+ |-------|---------|----------------|
209
+ | **L1 — Instructions** | `instruction-scanner` | Dangerous shell commands (`rm -rf`, `sudo`, `curl|sh`), prompt injection patterns, base64/hex obfuscation, suspicious URLs, remote code execution |
210
+ | **L2 — Permissions** | `permission-scanner` | Overly broad `.mdc` globs, `alwaysApply` without scope, dangerous MCP tool names (shell/exec), filesystem access, network access, Claude `disableModelInvocation` settings |
211
+ | **L3 — MCP** | `permission-scanner` | MCP server commands (`rm`, `sudo`, `kill`), MCP tool capabilities that could be abused |
212
+
213
+ > Note: L3 checks are handled by the same PermissionScanner that handles L2. They are reported together in a single scan pass.
214
+
215
+ ### Scoring System
216
+
217
+ The audit engine computes a numeric score (0–100) with an A–F letter grade:
218
+
219
+ | Level | Score Range | Meaning |
220
+ |-------|-------------|---------|
221
+ | **A** | 90–100 | Excellent — minimal or no issues |
222
+ | **B** | 70–89 | Good — minor low-severity findings |
223
+ | **C** | 50–69 | Fair — moderate issues, review recommended |
224
+ | **D** | 30–49 | Poor — significant issues, use with caution |
225
+ | **F** | 0–29 | Critical — unsafe, do not use without remediation |
226
+
227
+ Each finding carries a severity weight that reduces the score:
228
+
229
+ | Severity | Weight |
230
+ |----------|--------|
231
+ | 🔴 Critical | −25 pts |
232
+ | 🟠 High | −10 pts |
233
+ | 🟡 Medium | −4 pts |
234
+ | 🟢 Low | −1 pt |
235
+ | ℹ️ Info | 0 pts |
236
+
237
+ ### Output Formats
238
+
239
+ **Console** (default): Human-readable report with colored severity labels, line numbers, and context snippets.
240
+
241
+ ```
242
+ $ transskill audit my-skill.skill.md
243
+
244
+ ╔══════════════════════════════════════════════╗
245
+ ║ TransSkill Security Audit ║
246
+ ║ Target: my-skill.skill.md ║
247
+ ╚══════════════════════════════════════════════╝
248
+
249
+ Audit Level: L1 + L2 + L3
250
+
251
+ Findings (3):
252
+
253
+ 🔴 Critical | L2-003b | MCP server 使用危险命令: rm
254
+ → ./my-skill.skill.md
255
+
256
+ 🟠 High | L1-001 | Detected dangerous command: rm -rf /
257
+ → ./my-skill.skill.md:24
258
+ → run: rm -rf /tmp/cache
259
+
260
+ 🟡 Medium | L2-001b | alwaysApply 规则 globs 范围过宽
261
+ → ./my-skill.skill.md
262
+
263
+ Score: 65/100 — Level C
264
+ 3 findings (1 critical, 1 high, 1 medium)
265
+ ```
266
+
267
+ **JSON**: Machine-readable for CI/CD pipelines and programmatic consumption.
268
+
269
+ ```bash
270
+ transskill audit ./skills/ --format json
271
+ ```
272
+
273
+ **Quiet**: One-line summary, ideal for quick checks.
274
+
275
+ ```bash
276
+ transskill audit .cursorrules --quiet
277
+ # 📊 C (65/100) — 3 findings (1🔴 1🟠 1🟡)
278
+ ```
279
+
280
+ ### CI/CD Integration
281
+
282
+ Use the JSON flag to integrate audit results into your CI pipeline:
283
+
284
+ ```bash
285
+ #!/bin/bash
286
+ # Fail build if score drops below B (70)
287
+ RESULT=$(transskill audit ./skills/ --format json)
288
+ SCORE=$(echo $RESULT | jq '.score.total')
289
+ if [ "$SCORE" -lt 70 ]; then
290
+ echo "❌ Security score $SCORE is below threshold (70)"
291
+ exit 1
292
+ fi
293
+ echo "✅ Security score $SCORE — passing"
294
+ ```
295
+
167
296
  ## Project Status
168
297
 
169
- **Active development.** See [tasks.md](specs/tasks.md) for current progress.
298
+ **v0.2.1 — Active development.** See [tasks.md](specs/tasks.md) for current progress.
170
299
 
171
300
  | Phase | Status |
172
301
  |-------|--------|
173
302
  | Phase 0: Project scaffold | ✅ Complete |
174
303
  | Phase 1: InputResolver + types | ✅ Complete |
175
304
  | Phase 2: Parser layer | ✅ Complete |
176
- | Phase 3: Mapper + Renderer | Pending |
177
- | Phase 4: CLI pipeline | Pending |
178
- | Phase 5: Tests | ⬜ Pending |
305
+ | Phase 3: Mapper + Renderer | Complete |
306
+ | Phase 4: CLI pipeline | Complete |
307
+ | Phase 5: Tests | ⬜ In Progress |
179
308
  | Phase 6: CI + publish | ⬜ Pending |
309
+ | Phase A: Security audit | ✅ Complete |
180
310
 
181
311
  ## Contributing
182
312
 
package/README.zh.md CHANGED
@@ -98,6 +98,9 @@ transskill list-formats
98
98
  # 验证技能文件或目录格式
99
99
  transskill validate <input>
100
100
 
101
+ # 安全审计技能文件或目录
102
+ transskill audit <input> [options]
103
+
101
104
  # 查看所有选项
102
105
  transskill --help
103
106
  ```
@@ -114,6 +117,16 @@ transskill --help
114
117
  | `--dry-run` | 预览模式,不写入文件 |
115
118
  | `-v, --verbose` | 显示详细转换报告 |
116
119
 
120
+ ### audit 选项
121
+
122
+ | 参数 | 说明 |
123
+ |------|------|
124
+ | `--format <type>` | 输出格式:`console` 或 `json`(默认 console) |
125
+ | `--quiet` | 仅显示评分摘要 |
126
+ | `--min-severity <level>` | 最低报告级别:`info`, `low`, `medium`, `high`, `critical`(默认 info) |
127
+ | `--auditor <id>` | 仅运行指定的审计器(可重复使用) |
128
+ | `-v, --verbose` | 显示详细发现 |
129
+
117
130
  ## 工作原理
118
131
 
119
132
  ```
@@ -167,19 +180,136 @@ $ transskill convert ./weather-skill/ --to .cursorrules
167
180
  ⚠️ SKILL.md 中的脚本引用在 .cursorrules 中无法使用
168
181
  ```
169
182
 
183
+ ---
184
+
185
+ ## 安全审计
186
+
187
+ TransSkill 内置安全扫描器,可以在安装或使用技能文件之前分析其中的潜在安全风险。
188
+
189
+ ```bash
190
+ # 快速扫描技能文件
191
+ transskill audit my-skill.skill.md
192
+
193
+ # JSON 格式输出,适合程序化处理
194
+ transskill audit ./skill-dir/ --format json
195
+
196
+ # 安静模式——仅显示评分
197
+ transskill audit my-skill.skill.md --quiet
198
+
199
+ # 仅显示高危及以上问题
200
+ transskill audit .cursorrules --min-severity high
201
+
202
+ # 仅运行指定审计器
203
+ transskill audit mcp.json --auditor permission-scanner
204
+ ```
205
+
206
+ ### 审计级别
207
+
208
+ 扫描器检查三个安全层级:
209
+
210
+ | 级别 | 扫描器 | 检查内容 |
211
+ |------|--------|----------|
212
+ | **L1 — 指令扫描** | `instruction-scanner` | 危险 shell 命令(`rm -rf`、`sudo`、`curl|sh`)、提示注入模式、base64/hex 混淆、可疑 URL、远程代码执行 |
213
+ | **L2 — 权限扫描** | `permission-scanner` | `.mdc` glob 范围过宽、`alwaysApply` 无范围限制、危险 MCP 工具名(shell/exec)、文件系统访问、网络访问、Claude `disableModelInvocation` 设置 |
214
+ | **L3 — MCP 扫描** | `permission-scanner` | MCP 服务器命令(`rm`、`sudo`、`kill`)、可能被滥用的 MCP 工具能力 |
215
+
216
+ > 注:L3 检查由同一個 PermissionScanner 处理,与 L2 在一次扫描中一并报告。
217
+
218
+ ### 评分体系
219
+
220
+ 审计引擎计算 0–100 的数值评分,对应 A–F 等级:
221
+
222
+ | 等级 | 分数范围 | 含义 |
223
+ |------|----------|------|
224
+ | **A** | 90–100 | 优秀——几乎没有安全问题 |
225
+ | **B** | 70–89 | 良好——存在少量低风险问题 |
226
+ | **C** | 50–69 | 一般——存在中等风险,建议审查 |
227
+ | **D** | 30–49 | 较差——存在显著风险,谨慎使用 |
228
+ | **F** | 0–29 | 危险——存在严重风险,请勿直接使用 |
229
+
230
+ 每条发现按严重程度扣分:
231
+
232
+ | 严重程度 | 扣分 |
233
+ |----------|------|
234
+ | 🔴 严重(Critical) | −25 分 |
235
+ | 🟠 高危(High) | −10 分 |
236
+ | 🟡 中危(Medium) | −4 分 |
237
+ | 🟢 低危(Low) | −1 分 |
238
+ | ℹ️ 信息(Info) | 0 分 |
239
+
240
+ ### 输出格式
241
+
242
+ **控制台**(默认):带颜色标签、行号和上下文片段的可读报告。
243
+
244
+ ```
245
+ $ transskill audit my-skill.skill.md
246
+
247
+ ╔══════════════════════════════════════════════╗
248
+ ║ TransSkill Security Audit ║
249
+ ║ 目标文件: my-skill.skill.md ║
250
+ ╚══════════════════════════════════════════════╝
251
+
252
+ 审计等级: L1 + L2 + L3
253
+
254
+ 发现 (3 项):
255
+
256
+ 🔴 严重 | L2-003b | MCP 服务器使用了危险命令: rm
257
+ → ./my-skill.skill.md
258
+
259
+ 🟠 高危 | L1-001 | 检测到危险命令: rm -rf /
260
+ → ./my-skill.skill.md:24
261
+ → run: rm -rf /tmp/cache
262
+
263
+ 🟡 中危 | L2-001b | alwaysApply 规则 globs 范围过宽
264
+ → ./my-skill.skill.md
265
+
266
+ 评分: 65/100 — C 级
267
+ 3 项发现 (1 严重, 1 高危, 1 中危)
268
+ ```
269
+
270
+ **JSON**:适合 CI/CD 流水线和程序化处理。
271
+
272
+ ```bash
273
+ transskill audit ./skills/ --format json
274
+ ```
275
+
276
+ **安静模式**:一行摘要,适合快速检查。
277
+
278
+ ```bash
279
+ transskill audit .cursorrules --quiet
280
+ # 📊 C (65/100) — 3 项发现 (1🔴 1🟠 1🟡)
281
+ ```
282
+
283
+ ### CI/CD 集成
284
+
285
+ 结合 JSON 输出将审计结果集成到 CI 流水线:
286
+
287
+ ```bash
288
+ #!/bin/bash
289
+ # 评分低于 B 级(70 分)则构建失败
290
+ RESULT=$(transskill audit ./skills/ --format json)
291
+ SCORE=$(echo $RESULT | jq '.score.total')
292
+ if [ "$SCORE" -lt 70 ]; then
293
+ echo "❌ 安全评分 $SCORE 低于阈值 (70)"
294
+ exit 1
295
+ fi
296
+ echo "✅ 安全评分 $SCORE — 通过"
297
+ ```
298
+
170
299
  ## 项目进度
171
300
 
172
- **活跃开发中。** 详见 [tasks.md](specs/tasks.md)。
301
+ **v0.2.1 — 活跃开发中。** 详见 [tasks.md](specs/tasks.md)。
173
302
 
174
303
  | 阶段 | 状态 |
175
304
  |------|------|
176
305
  | Phase 0: 项目脚手架 | ✅ 已完成 |
177
306
  | Phase 1: InputResolver + 类型定义 | ✅ 已完成 |
178
307
  | Phase 2: Parser 层 | ✅ 已完成 |
179
- | Phase 3: Mapper + Renderer | 待完成 |
180
- | Phase 4: CLI 完整管道 | 待完成 |
181
- | Phase 5: 测试覆盖 | ⬜ 待完成 |
308
+ | Phase 3: Mapper + Renderer | 已完成 |
309
+ | Phase 4: CLI 完整管道 | 已完成 |
310
+ | Phase 5: 测试覆盖 | ⬜ 进行中 |
182
311
  | Phase 6: CI + 发布 | ⬜ 待完成 |
312
+ | Phase A: 安全审计 | ✅ 已完成 |
183
313
 
184
314
  ## 贡献指南
185
315
 
@@ -0,0 +1,6 @@
1
+ import type { Auditor } from './auditor.interface.js';
2
+ export declare function registerAuditor(auditor: Auditor): void;
3
+ export declare function getAuditor(id: string): Auditor | undefined;
4
+ export declare function getAuditors(): Auditor[];
5
+ export declare function clearAuditors(): void;
6
+ //# sourceMappingURL=auditor-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditor-registry.d.ts","sourceRoot":"","sources":["../../src/audit/auditor-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAItD,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAKtD;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE1D;AAED,wBAAgB,WAAW,IAAI,OAAO,EAAE,CAEvC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
@@ -0,0 +1,17 @@
1
+ const auditors = new Map();
2
+ export function registerAuditor(auditor) {
3
+ if (auditors.has(auditor.id)) {
4
+ throw new Error(`Auditor '${auditor.id}' is already registered`);
5
+ }
6
+ auditors.set(auditor.id, auditor);
7
+ }
8
+ export function getAuditor(id) {
9
+ return auditors.get(id);
10
+ }
11
+ export function getAuditors() {
12
+ return Array.from(auditors.values());
13
+ }
14
+ export function clearAuditors() {
15
+ auditors.clear();
16
+ }
17
+ //# sourceMappingURL=auditor-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditor-registry.js","sourceRoot":"","sources":["../../src/audit/auditor-registry.ts"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE5C,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,CAAC,EAAE,yBAAyB,CAAC,CAAC;IACnE,CAAC;IACD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { FormatType, IntermediateSkill } from '../core/types.js';
2
+ export type Severity = 'critical' | 'high' | 'medium' | 'low' | 'info';
3
+ export declare const SEVERITY_ORDER: Severity[];
4
+ export declare const SEVERITY_WEIGHTS: Record<Severity, number>;
5
+ export declare const SEVERITY_LABELS: Record<Severity, string>;
6
+ export interface AuditFinding {
7
+ id: string;
8
+ severity: Severity;
9
+ title: string;
10
+ description: string;
11
+ filePath: string;
12
+ lineNumber?: number;
13
+ snippet?: string;
14
+ recommendation?: string;
15
+ cwe?: string;
16
+ }
17
+ export type ScoreLevel = 'A' | 'B' | 'C' | 'D' | 'F';
18
+ export interface SecurityScore {
19
+ total: number;
20
+ level: ScoreLevel;
21
+ critical: number;
22
+ high: number;
23
+ medium: number;
24
+ low: number;
25
+ info: number;
26
+ }
27
+ export declare function computeScore(critical: number, high: number, medium: number, low: number, _info: number): SecurityScore;
28
+ export interface AuditReport {
29
+ target: string;
30
+ format: FormatType;
31
+ isDirectory: boolean;
32
+ findings: AuditFinding[];
33
+ score: SecurityScore;
34
+ summary: string;
35
+ timestamp: string;
36
+ }
37
+ export interface Auditor {
38
+ /** Unique auditor identifier */
39
+ readonly id: string;
40
+ /** Human-readable name */
41
+ readonly name: string;
42
+ /** Description of what this auditor checks */
43
+ readonly description: string;
44
+ /** Which format(s) this auditor supports (empty = all) */
45
+ readonly supportedFormats?: FormatType[];
46
+ /** Run audit on a parsed skill */
47
+ audit(skill: IntermediateSkill, filePath: string): AuditFinding[];
48
+ /** Whether this auditor can handle directory-level checks */
49
+ readonly supportsDirectory?: boolean;
50
+ }
51
+ export interface AuditOptions {
52
+ /** Minimum severity to report */
53
+ minSeverity?: Severity;
54
+ /** Specific auditor IDs to run (empty = all) */
55
+ auditors?: string[];
56
+ /** Skip directory-level checks */
57
+ noDirectory?: boolean;
58
+ }
59
+ //# sourceMappingURL=auditor.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditor.interface.d.ts","sourceRoot":"","sources":["../../src/audit/auditor.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvE,eAAO,MAAM,cAAc,EAAE,QAAQ,EAAkD,CAAC;AAExF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMrD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMpD,CAAC;AAIF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,aAAa,CAiBf;AAID,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAID,MAAM,WAAW,OAAO;IACtB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,UAAU,EAAE,CAAC;IACzC,kCAAkC;IAClC,KAAK,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IAClE,6DAA6D;IAC7D,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAID,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,kCAAkC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1,36 @@
1
+ export const SEVERITY_ORDER = ['critical', 'high', 'medium', 'low', 'info'];
2
+ export const SEVERITY_WEIGHTS = {
3
+ critical: 25,
4
+ high: 10,
5
+ medium: 4,
6
+ low: 1,
7
+ info: 0,
8
+ };
9
+ export const SEVERITY_LABELS = {
10
+ critical: '🔴 Critical',
11
+ high: '🟠 High',
12
+ medium: '🟡 Medium',
13
+ low: '🟢 Low',
14
+ info: 'ℹ️ Info',
15
+ };
16
+ export function computeScore(critical, high, medium, low, _info) {
17
+ const raw = 100 -
18
+ critical * SEVERITY_WEIGHTS.critical -
19
+ high * SEVERITY_WEIGHTS.high -
20
+ medium * SEVERITY_WEIGHTS.medium -
21
+ low * SEVERITY_WEIGHTS.low;
22
+ const total = Math.max(0, Math.min(100, raw));
23
+ let level;
24
+ if (total >= 90)
25
+ level = 'A';
26
+ else if (total >= 70)
27
+ level = 'B';
28
+ else if (total >= 50)
29
+ level = 'C';
30
+ else if (total >= 30)
31
+ level = 'D';
32
+ else
33
+ level = 'F';
34
+ return { total, level, critical, high, medium, low, info: _info };
35
+ }
36
+ //# sourceMappingURL=auditor.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auditor.interface.js","sourceRoot":"","sources":["../../src/audit/auditor.interface.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,cAAc,GAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,gBAAgB,GAA6B;IACxD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,WAAW;IACnB,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,SAAS;CAChB,CAAC;AA8BF,MAAM,UAAU,YAAY,CAC1B,QAAgB,EAChB,IAAY,EACZ,MAAc,EACd,GAAW,EACX,KAAa;IAEb,MAAM,GAAG,GACP,GAAG;QACH,QAAQ,GAAG,gBAAgB,CAAC,QAAQ;QACpC,IAAI,GAAG,gBAAgB,CAAC,IAAI;QAC5B,MAAM,GAAG,gBAAgB,CAAC,MAAM;QAChC,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAE9C,IAAI,KAAiB,CAAC;IACtB,IAAI,KAAK,IAAI,EAAE;QAAE,KAAK,GAAG,GAAG,CAAC;SACxB,IAAI,KAAK,IAAI,EAAE;QAAE,KAAK,GAAG,GAAG,CAAC;SAC7B,IAAI,KAAK,IAAI,EAAE;QAAE,KAAK,GAAG,GAAG,CAAC;SAC7B,IAAI,KAAK,IAAI,EAAE;QAAE,KAAK,GAAG,GAAG,CAAC;;QAC7B,KAAK,GAAG,GAAG,CAAC;IAEjB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { AuditReport, AuditOptions } from './auditor.interface.js';
2
+ import type { IntermediateSkill } from '../core/types.js';
3
+ /**
4
+ * AuditEngine — the main entry point for security auditing.
5
+ *
6
+ * Flow:
7
+ * 1. Get all registered auditors
8
+ * 2. Filter by options (minSeverity, specific auditors)
9
+ * 3. Run each applicable auditor against the parsed skill
10
+ * 4. Aggregate findings
11
+ * 5. Compute score + generate report
12
+ */
13
+ export declare class AuditEngine {
14
+ private readonly options;
15
+ constructor(options?: AuditOptions);
16
+ /**
17
+ * Audit a single parsed skill file.
18
+ */
19
+ auditSkill(skill: IntermediateSkill, filePath: string, target?: string): AuditReport;
20
+ /**
21
+ * Audit a skill directory, including file-level and directory-level checks.
22
+ */
23
+ auditDirectory(skill: IntermediateSkill, rootPath: string, skillFilePath: string, target?: string): AuditReport;
24
+ /**
25
+ * Run all auditors and return the report object.
26
+ */
27
+ run(skill: IntermediateSkill, filePath: string, isDirectory: boolean): AuditReport;
28
+ /**
29
+ * Generate console-friendly report string.
30
+ */
31
+ reportToString(report: AuditReport): string;
32
+ /**
33
+ * Generate JSON report string.
34
+ */
35
+ reportToJson(report: AuditReport, pretty?: boolean): string;
36
+ private resolveAuditors;
37
+ private buildReport;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EACX,YAAY,EAEb,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAItE;;;;;;;;;GASG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;gBAErC,OAAO,GAAE,YAAiB;IAQtC;;OAEG;IACH,UAAU,CACR,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GACd,WAAW;IAuBd;;OAEG;IACH,cAAc,CACZ,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,MAAM,GACd,WAAW;IAiCd;;OAEG;IACH,GAAG,CACD,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,OAAO,GACnB,WAAW;IAId;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM;IAI3C;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,UAAO,GAAG,MAAM;IAIxD,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,WAAW;CAoDpB"}