@yottameta/yotta-guardian 0.1.0 → 0.1.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.
- package/CHANGELOG.md +11 -0
- package/README.md +163 -154
- package/README.zh-CN.md +156 -0
- package/SKILL.md +1 -1
- package/package.json +6 -4
- package/scripts/yotta_guardian.py +1 -1
- package/scripts/__pycache__/guardian_rules.cpython-38.pyc +0 -0
- package/scripts/__pycache__/test_yotta_guardian.cpython-38.pyc +0 -0
- package/scripts/__pycache__/yotta_guardian.cpython-38.pyc +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## v0.1.1 (2026-08-28)
|
|
4
|
+
|
|
5
|
+
中英双语 README 对齐(老张拍板「英文门面 + 中文全档」):
|
|
6
|
+
|
|
7
|
+
- **README.md 改为英文**:作为 GitHub / npm / ClawHub 首页的英文门面(翻译 + 精简,覆盖定位 / 核心价值 / 命令 / 快速使用 / 安装 / 使用示例 / 边界 / 开发校验全流程)。
|
|
8
|
+
- **新增 README.zh-CN.md**:原中文完整主文档整体平移,顶部加语言切换链接。
|
|
9
|
+
- **修复代码围栏**:README 中 `_BT_`bash / `_BT_` 占位符全部改为标准 ```bash / ```(Markdown 渲染修复)。
|
|
10
|
+
- **package.json**:description 改英文;files 加 README.zh-CN.md;版本 0.1.0 → 0.1.1。
|
|
11
|
+
- 版本四处对齐:package.json / SKILL frontmatter / 引擎 VERSION / 文档。
|
|
12
|
+
- 边界(B 方案):references / CHANGELOG / 测试注释不翻译;SKILL 触发描述保持中文。
|
|
13
|
+
|
|
3
14
|
## v0.1.0 (2026-08-26)
|
|
4
15
|
|
|
5
16
|
YottaMeta 自有实现首版(护栏/拦截方向参考开源社区 safe-guardian 类技能思路,已完全重写,零依赖、无上游代码):
|
package/README.md
CHANGED
|
@@ -1,154 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<p align="center"
|
|
10
|
-
<p align="center"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<a href="
|
|
15
|
-
<a href="https://
|
|
16
|
-
<a href="https://
|
|
17
|
-
<a href="https://github.com/YottaMeta/yotta-guardian
|
|
18
|
-
<a href="https://github.com/YottaMeta/yotta-guardian"><img alt="
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
python3 scripts/yotta_guardian.py
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
npx -y @yottameta/yotta-guardian
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
bash
|
|
96
|
-
bash install.sh
|
|
97
|
-
bash install.sh
|
|
98
|
-
bash install.sh
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
| Trae
|
|
119
|
-
|
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
3
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
<p align="center"><b>Language</b>: English · <a href="./README.zh-CN.md">中文</a></p>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/banner.png" alt="yotta-guardian banner" width="100%" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">yotta-guardian · 元盾 (Yuandun)</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">YottaMeta's tool-call interception guardrail: a <b>deterministic rule engine + pluggable intent verifier</b> that evaluates exec / write / edit / read / run / shell tool calls and returns <b>allow / deny + matched rules + audit logs</b>. Use it as a deterministic safety gate before an agent runs a high-risk command, writes a sensitive system path, or changes system configuration.</p>
|
|
10
|
+
<p align="center">Activates when an agent is about to perform dangerous operations — recursive delete, disk formatting, privilege escalation, firewall changes, reverse shell, download-and-run, writes to core system files — <b>deterministic verdicts by rules, not prompt-engineering luck</b>.</p>
|
|
11
|
+
<p align="center">Pure Python 3.8+ standard library, zero external dependencies; Windows + Linux + macOS; read-only evaluation by default, configurable allowances, full audit trail.</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
|
15
|
+
<a href="https://agentskills.io/"><img alt="Standard: agentskills.io" src="https://img.shields.io/badge/standard-agentskills.io-orange" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@yottameta/yotta-guardian"><img alt="npm package" src="https://img.shields.io/npm/v/@yottameta/yotta-guardian" /></a>
|
|
17
|
+
<a href="https://github.com/YottaMeta/yotta-guardian"><img alt="GitHub stars" src="https://img.shields.io/github/stars/YottaMeta/yotta-guardian" /></a>
|
|
18
|
+
<a href="https://github.com/YottaMeta/yotta-guardian/commits/main"><img alt="last commit" src="https://img.shields.io/github/last-commit/YottaMeta/yotta-guardian" /></a>
|
|
19
|
+
<a href="https://github.com/YottaMeta/yotta-guardian"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen" /></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
## What it is
|
|
23
|
+
|
|
24
|
+
When an AI agent acts autonomously, a single recursive delete, one disk write, or a download-and-run can cause irreversible damage. Yuandun packages these dangerous actions into a deterministic rule engine: every tool call (exec / write / edit / read / run / shell) is evaluated structurally — command text, argv-level verb and target analysis, sensitive paths, and written content — producing an allow / deny verdict with the matched rules and reasons, plus audit-log trails.
|
|
25
|
+
|
|
26
|
+
It is not tied to any single platform: an agent-agnostic toolkit that works in any agent supporting Agent Skills. Read-only evaluation by default — it neither executes nor auto-approves dangerous actions; intent verification calls no model by default and can be plugged into any external verifier (e.g. an LLM gateway) through a JSON protocol.
|
|
27
|
+
|
|
28
|
+
## Core value
|
|
29
|
+
|
|
30
|
+
- **Deterministic rule engine** — text patterns (download-and-run / encoded execution / reverse shell) + argv-level verb/target analysis (rm / dd / mkfs / chmod / chown / privilege escalation / firewall / services / persistence) + sensitive paths + written content: four stacked layers of rules.
|
|
31
|
+
- **Sensitive-path guard** — writes to /etc/passwd, /etc/sudoers, SSH authorized keys, /boot, /dev devices, Windows system directories and hosts, and registry startup entries are denied.
|
|
32
|
+
- **Pluggable intent verification (no model required)** — zero-dependency by default; optional built-in local heuristics (--heuristic), or any external intent verifier via a stdin/stdout JSON protocol (--verifier / config file).
|
|
33
|
+
- **Three policies** — default (deny high+), strict (deny medium+), loose (deny critical only), chosen per scenario.
|
|
34
|
+
- **Audit trail** — JSONL audit log + audit query subcommand; every allow / deny is traceable.
|
|
35
|
+
- **Machine readable** — --json outputs pure JSON (per-call verdicts, rules, exit codes); --batch pre-checks a list of calls, ideal as a pre-execution gate.
|
|
36
|
+
|
|
37
|
+
## Why use it
|
|
38
|
+
|
|
39
|
+
| Advantage | Description |
|
|
40
|
+
|---|---|
|
|
41
|
+
| **Zero dependency** | Python 3.8+ standard library; no daemon / database / external scanner; Windows + Linux + macOS |
|
|
42
|
+
| **Deterministic** | Verdicts are reproducible and explainable, not model probability; intent verification is off by default and opt-in |
|
|
43
|
+
| **Structural** | Evaluates commands, paths and content per tool type (exec / write / edit / read), not naive string matching |
|
|
44
|
+
| **Configurable** | --allow / --allow-path / custom rule JSON (policy / deny / allow / verifier) |
|
|
45
|
+
| **Traceable** | Every verdict lands in a JSONL audit log; audit subcommand filters by denied / tool / time |
|
|
46
|
+
| **Ecosystem distribution** | GitHub + npm + ClawHub synced; install via npx / install.sh / manual copy |
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
| Command | Description |
|
|
51
|
+
|---|---|
|
|
52
|
+
| check | Evaluate one or a batch of tool calls (--batch); text / JSON / Markdown reports |
|
|
53
|
+
| audit | Query audit logs (--tail / --denied / --since / --tool / --json) |
|
|
54
|
+
| rules | Print the built-in rule summary / validate a custom rules file |
|
|
55
|
+
| version | Print the version |
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
Windows uses python, Linux/macOS uses python3.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Check one exec call (0 = allowed)
|
|
63
|
+
python3 scripts/yotta_guardian.py check exec --cmd "git status"
|
|
64
|
+
|
|
65
|
+
# Check a dangerous command (denied by default, exit code 3)
|
|
66
|
+
python3 scripts/yotta_guardian.py check exec --cmd "rm -rf /"
|
|
67
|
+
|
|
68
|
+
# Check a write (writing /etc/passwd is denied)
|
|
69
|
+
python3 scripts/yotta_guardian.py check write --path /etc/passwd --content "..."
|
|
70
|
+
|
|
71
|
+
# Batch pre-check (the agent hands the pending call list to the guardrail before running)
|
|
72
|
+
python3 scripts/yotta_guardian.py check --batch calls.json --json
|
|
73
|
+
|
|
74
|
+
# Audit
|
|
75
|
+
python3 scripts/yotta_guardian.py check exec --cmd "..." --audit-log .yotta-guardian/audit.jsonl
|
|
76
|
+
python3 scripts/yotta_guardian.py audit --file .yotta-guardian/audit.jsonl --tail 20
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Exit codes (same semantics as the YuanAn / YuanShen family): **0** = allowed; **1** = allowed with warning (manual review recommended); **2** = denied (high); **3** = denied (critical); **4** = usage error / fatal exception.
|
|
80
|
+
|
|
81
|
+
## Install
|
|
82
|
+
|
|
83
|
+
Pick any one of the three methods; skill files are fetched from **npm** (GitHub is slower without a proxy; npm can use a domestic mirror).
|
|
84
|
+
|
|
85
|
+
### Method 1: npm (recommended, one-liner)
|
|
86
|
+
```bash
|
|
87
|
+
# domestic mirror (optional): npm config set registry https://registry.npmmirror.com
|
|
88
|
+
npx -y @yottameta/yotta-guardian -g
|
|
89
|
+
npx -y @yottameta/yotta-guardian --dir <your-skills-dir> # any agent: install to a specific directory
|
|
90
|
+
```
|
|
91
|
+
> Not in the preset list? Use --dir to point at the agent's skills directory, or manual copy (method 3). --list shows each agent's default directory. You can also npm pack @yottameta/yotta-guardian and unpack it to install via method 2 / 3.
|
|
92
|
+
|
|
93
|
+
### Method 2: install.sh one-shot
|
|
94
|
+
After obtaining the skill folder (npm pack unpack or git clone), enter the folder:
|
|
95
|
+
```bash
|
|
96
|
+
bash install.sh -g # user level; bash install.sh --list shows all directories
|
|
97
|
+
bash install.sh --agent codex # specific agent (--list shows available ones)
|
|
98
|
+
bash install.sh # project level: auto-detect existing .claude/.cursor/.codex skills dirs
|
|
99
|
+
bash install.sh --dir /path/to/skills
|
|
100
|
+
```
|
|
101
|
+
> Covers 17 agent families including Trae / Qwen / Comate / CodeBuddy / Kimi. Windows users: works with Git Bash; otherwise use method 3.
|
|
102
|
+
|
|
103
|
+
### Method 3: manual copy
|
|
104
|
+
Copy the whole yotta-guardian folder into the target agent's skills directory. Common locations (user level; Windows uses %USERPROFILE%, Linux/macOS uses ~):
|
|
105
|
+
|
|
106
|
+
| Agent | User-level directory | Project-level directory |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| Codex | %USERPROFILE%\.codex\skills\yotta-guardian\ | .codex\skills\ |
|
|
109
|
+
| Claude Code | %USERPROFILE%\.claude\skills\yotta-guardian\ | .claude\skills\ |
|
|
110
|
+
| Cursor | %USERPROFILE%\.cursor\skills\yotta-guardian\ | .cursor\skills\ |
|
|
111
|
+
| Windsurf | %USERPROFILE%\.codeium\windsurf\skills\yotta-guardian\ | .windsurf\skills\ |
|
|
112
|
+
| opencode | %USERPROFILE%\.config\opencode\skills\yotta-guardian\ | .opencode\skills\ |
|
|
113
|
+
| Gemini | %USERPROFILE%\.gemini\skills\yotta-guardian\ | .gemini\skills\ |
|
|
114
|
+
| Goose | %USERPROFILE%\.config\goose\skills\yotta-guardian\ | .goose\skills\ |
|
|
115
|
+
| Amp | %USERPROFILE%\.config\agents\skills\yotta-guardian\ | .agents\skills\ |
|
|
116
|
+
| Kiro | %USERPROFILE%\.kiro\skills\yotta-guardian\ | .kiro\skills\ |
|
|
117
|
+
| WorkBuddy | %USERPROFILE%\.workbuddy\skills\yotta-guardian\ | .workbuddy\skills\ |
|
|
118
|
+
| Trae Code CLI | %USERPROFILE%\.traecli\skills\yotta-guardian\ | .traecli\skills\ |
|
|
119
|
+
| Trae IDE (CN) | %USERPROFILE%\.trae-cn\skills\yotta-guardian\ | .trae\skills\ |
|
|
120
|
+
| Qwen Code | %USERPROFILE%\.qwen\skills\yotta-guardian\ | .qwen\skills\ |
|
|
121
|
+
| Comate | %USERPROFILE%\.comate\skills\yotta-guardian\ | .comate\skills\ |
|
|
122
|
+
| CodeBuddy | %USERPROFILE%\.codebuddy\skills\yotta-guardian\ | .codebuddy\skills\ |
|
|
123
|
+
| Kimi | %USERPROFILE%\.kimi\skills\yotta-guardian\ | .kimi\skills\ |
|
|
124
|
+
| Generic AGENTS.md | %USERPROFILE%\.agents\skills\yotta-guardian\ | .agents\skills\ |
|
|
125
|
+
|
|
126
|
+
> If Codex's CODEX_HOME is set, it overrides the default; the same applies to opencode's XDG_CONFIG_HOME. .agents\skills is not a universal directory — only OpenCode / Cursor / Cline / Amp / Kimi / Gemini CLI / GitHub Copilot etc. read it; **Claude Code and Codex do not read it by default**. When unsure, use --dir or let the agent install it.
|
|
127
|
+
|
|
128
|
+
## Usage examples (AI agent)
|
|
129
|
+
|
|
130
|
+
1. Hook this repo's SKILL.md into any AI agent's skill/rule system (see install above).
|
|
131
|
+
2. Before executing any high-risk tool call, run a check first:
|
|
132
|
+
```bash
|
|
133
|
+
python3 scripts/yotta_guardian.py check exec --cmd "<pending command>" --json
|
|
134
|
+
```
|
|
135
|
+
With exit code 2 / 3, do not execute — explain the matched rules to the user; only with explicit authorization use --allow / --allow-path / custom rules.
|
|
136
|
+
3. For multiple calls, pre-check in batch:
|
|
137
|
+
```bash
|
|
138
|
+
python3 scripts/yotta_guardian.py check --batch calls.json --json
|
|
139
|
+
```
|
|
140
|
+
4. Before writing sensitive paths / changing system config, check the target path and content with write / edit.
|
|
141
|
+
5. High-risk operations land in the audit log; query them later with audit.
|
|
142
|
+
|
|
143
|
+
## Boundaries (security red lines)
|
|
144
|
+
|
|
145
|
+
- **Read-only evaluation by default** — does not execute, does not auto-approve, does not modify anything; it is a gate before execution, not a substitute for the user's decision.
|
|
146
|
+
- **No hidden audit** — every verdict is recorded and traceable; rules are configurable but critical rules cannot be overridden.
|
|
147
|
+
- **Authorization** — for explicitly authorized / own-asset / educational environments only; using it to bypass real-world authorization is the user's own responsibility.
|
|
148
|
+
|
|
149
|
+
## Development & validation
|
|
150
|
+
|
|
151
|
+
- Tests: python scripts/test_yotta_guardian.py (60 tests; Windows: python)
|
|
152
|
+
- Base validation: python tools/validate-skill.py yotta-guardian (run at the repo root)
|
|
153
|
+
- Rule details: references/rules.md; policies & exit codes: references/policies.md; intent-verifier protocol: references/intent-verifier.md
|
|
154
|
+
|
|
155
|
+
Keep tests green and bump the version before releasing changes.
|
|
156
|
+
|
|
157
|
+
## Changelog
|
|
158
|
+
|
|
159
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
[MIT](./LICENSE) © YottaMeta. "Yuandun" / "yotta-guardian" and the YottaMeta family names (yotta-* prefix) are YottaMeta brand identifiers; derived works must not reuse them, see [NOTICE](./NOTICE). The guardrail direction references open-source safe-guardian style skills; the implementation is YottaMeta's own new code.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<p align="center"><b>Language</b>: <a href="./README.md">English</a> · 中文</p>
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img src="assets/banner.png" alt="yotta-guardian banner" width="100%" />
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">yotta-guardian · 元盾</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">YottaMeta 自有的工具调用拦截护栏:<b>确定性规则引擎 + 可插拔意图验证</b>,对 exec / write / edit / read / run / shell 工具调用做安全评估,输出 allow / deny + 命中规则 + 审计日志。适用于代理要执行高风险命令、写入系统敏感路径、或修改系统配置之前的确定性安全检查。</p>
|
|
11
|
+
<p align="center">检测到递归删除、磁盘格式化、提权、防火墙改动、反向 shell、下载即执行、写入系统核心文件等危险操作意图时自动激活——<b>不靠提示词兜底,按规则确定性判定</b>。</p>
|
|
12
|
+
<p align="center">纯 Python 3.8+ 标准库实现,零外部依赖;Windows + Linux + macOS 通用;默认只读评估、可配置放行、审计留痕。</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue" /></a>
|
|
16
|
+
<a href="https://agentskills.io/"><img alt="Standard: agentskills.io" src="https://img.shields.io/badge/standard-agentskills.io-orange" /></a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/@yottameta/yotta-guardian"><img alt="npm package" src="https://img.shields.io/npm/v/@yottameta/yotta-guardian" /></a>
|
|
18
|
+
<a href="https://github.com/YottaMeta/yotta-guardian"><img alt="GitHub stars" src="https://img.shields.io/github/stars/YottaMeta/yotta-guardian" /></a>
|
|
19
|
+
<a href="https://github.com/YottaMeta/yotta-guardian/commits/main"><img alt="last commit" src="https://img.shields.io/github/last-commit/YottaMeta/yotta-guardian" /></a>
|
|
20
|
+
<a href="https://github.com/YottaMeta/yotta-guardian"><img alt="PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen" /></a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## 这是什么
|
|
24
|
+
|
|
25
|
+
AI 代理在自主执行时,一条递归删除、一次磁盘写入、一段下载即执行,就可能造成不可逆损失。元盾把这些危险动作做成确定性规则引擎:对每一次工具调用(exec / write / edit / read / run / shell)做结构化评估——命令文本、argv 级动词与目标分析、敏感路径、写入内容——给出 allow / deny 判定、命中规则与原因,并支持审计日志留痕。
|
|
26
|
+
|
|
27
|
+
它不是某个平台的专属功能,而是一份与智能体无关的工具包:装进任何支持 Agent Skills 的智能体即可按需调用。默认只读评估,不自动执行也不放行危险操作;意图验证默认不调用任何模型,可通过协议外接任意验证器(如 LLM 网关)。
|
|
28
|
+
|
|
29
|
+
## 核心价值
|
|
30
|
+
|
|
31
|
+
- **确定性规则引擎**:文本模式(下载即执行 / 编码执行 / 反向 shell 等)+ argv 级动词/目标分析(rm / dd / mkfs / chmod / chown / 提权 / 防火墙 / 服务 / 持久化等)+ 敏感路径 + 写入内容,四层规则叠加判定。
|
|
32
|
+
- **敏感路径守卫**:/etc/passwd、/etc/sudoers、SSH 授权文件、/boot、/dev 设备、Windows 系统目录与 hosts、注册表启动项等写入即拒。
|
|
33
|
+
- **可插拔意图验证(不绑模型)**:默认零依赖;可启用内置本地启发式(--heuristic),也可通过 stdin/stdout JSON 协议外接任意意图验证器(--verifier / 配置文件)。
|
|
34
|
+
- **三档策略**:default(拒绝 high+)/ strict(拒绝 medium+)/ loose(仅拒绝 critical),按场景取舍。
|
|
35
|
+
- **审计留痕**:JSONL 审计日志 + audit 查询子命令,拒绝/放行全程可追溯。
|
|
36
|
+
- **机器可读**:--json 输出纯净 JSON(含逐条判定、规则、退出码),--batch 批量预检,适合智能体在执行前 gate。
|
|
37
|
+
|
|
38
|
+
## 核心优势
|
|
39
|
+
|
|
40
|
+
| 优势 | 说明 |
|
|
41
|
+
|---|---|
|
|
42
|
+
| **零依赖** | Python 3.8+ 标准库,无 daemon / 无数据库 / 无外部扫描器;Windows + Linux + macOS 通用 |
|
|
43
|
+
| **确定性** | 规则判定可复现、可解释,不依赖模型概率;意图验证默认关闭,需显式启用 |
|
|
44
|
+
| **结构化** | 按工具类型(exec / write / edit / read)分别评估命令、路径与内容,不是简单字符串匹配 |
|
|
45
|
+
| **可配置** | --allow / --allow-path / 自定义规则 JSON(policy / deny / allow / verifier) |
|
|
46
|
+
| **可追溯** | 每次判定落 JSONL 审计日志,audit 子命令可按拒绝 / 工具 / 时间过滤 |
|
|
47
|
+
| **生态分发** | GitHub + npm + ClawHub 三源同步发布;npx / install.sh / 手动复制三种安装方式 |
|
|
48
|
+
|
|
49
|
+
## 功能体系
|
|
50
|
+
|
|
51
|
+
| 能力 | 说明 |
|
|
52
|
+
|---|---|
|
|
53
|
+
| check | 评估一条或一批工具调用(--batch),文本 / JSON / Markdown 报告三种输出 |
|
|
54
|
+
| audit | 查询审计日志(--tail / --denied / --since / --tool / --json) |
|
|
55
|
+
| rules | 打印内置规则摘要 / 校验自定义规则文件 |
|
|
56
|
+
| version | 打印版本 |
|
|
57
|
+
|
|
58
|
+
## 快速使用
|
|
59
|
+
|
|
60
|
+
Windows 用 python,Linux/macOS 用 python3。
|
|
61
|
+
|
|
62
|
+
`````bash
|
|
63
|
+
# 检查一条 exec(0 = 允许)
|
|
64
|
+
python3 scripts/yotta_guardian.py check exec --cmd "git status"
|
|
65
|
+
|
|
66
|
+
# 检查危险命令(默认拒绝,退出码 3)
|
|
67
|
+
python3 scripts/yotta_guardian.py check exec --cmd "rm -rf /"
|
|
68
|
+
|
|
69
|
+
# 检查写操作(写入 /etc/passwd 被拒)
|
|
70
|
+
python3 scripts/yotta_guardian.py check write --path /etc/passwd --content "..."
|
|
71
|
+
|
|
72
|
+
# 批量预检(agent 在执行前把待执行调用列表交给护栏)
|
|
73
|
+
python3 scripts/yotta_guardian.py check --batch calls.json --json
|
|
74
|
+
|
|
75
|
+
# 审计
|
|
76
|
+
python3 scripts/yotta_guardian.py check exec --cmd "..." --audit-log .yotta-guardian/audit.jsonl
|
|
77
|
+
python3 scripts/yotta_guardian.py audit --file .yotta-guardian/audit.jsonl --tail 20
|
|
78
|
+
`````
|
|
79
|
+
|
|
80
|
+
退出码语义(与元安 / 元审家族一致):0 = 允许;1 = 允许但带警告(建议人工复核);2 = 拒绝(high);3 = 拒绝(critical);4 = 用法错误 / 致命异常。
|
|
81
|
+
|
|
82
|
+
## 安装
|
|
83
|
+
|
|
84
|
+
三种方式任选其一,技能文件统一从 **npm** 获取(GitHub 无代理时较慢,npm 可配国内镜像加速)。
|
|
85
|
+
|
|
86
|
+
### 方式一:npm(推荐,一行安装)
|
|
87
|
+
`````bash
|
|
88
|
+
# 国内加速(可选):npm config set registry https://registry.npmmirror.com
|
|
89
|
+
npx -y @yottameta/yotta-guardian -g
|
|
90
|
+
npx -y @yottameta/yotta-guardian --dir <你的技能目录> # 任意智能体:指定目录安装
|
|
91
|
+
`````
|
|
92
|
+
> 智能体不在预置列表里?用 --dir 指定它的 skills 目录,或手动复制(方式三)。--list 可查看各智能体对应的默认目录。想手动拿文件也可 npm pack @yottameta/yotta-guardian 解包后按方式二/三安装。
|
|
93
|
+
|
|
94
|
+
### 方式二:install.sh 一键安装
|
|
95
|
+
获取技能文件夹后(npm pack 解包或 git clone),进入技能文件夹:
|
|
96
|
+
`````bash
|
|
97
|
+
bash install.sh -g # 用户级;bash install.sh --list 查看全部目录
|
|
98
|
+
bash install.sh --agent codex # 指定智能体(--list 可查看可用项)
|
|
99
|
+
bash install.sh # 项目级:自动检测已存在的 .claude/.cursor/.codex 等 skills 目录
|
|
100
|
+
bash install.sh --dir /path/to/skills
|
|
101
|
+
`````
|
|
102
|
+
> 覆盖 17 类智能体,含国内 Trae / Qwen / Comate / CodeBuddy / Kimi。Windows 用户:装有 Git Bash 即可用;否则用方式三手动复制。
|
|
103
|
+
|
|
104
|
+
### 方式三:手动复制
|
|
105
|
+
把整个 yotta-guardian 文件夹复制到目标智能体的 skills 目录。常见位置(用户级;Windows 用 %USERPROFILE%,Linux/macOS 用 ~):
|
|
106
|
+
|
|
107
|
+
| 智能体 | 用户级目录 | 项目级目录 |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| Codex | %USERPROFILE%\.codex\skills\yotta-guardian\ | .codex\skills\ |
|
|
110
|
+
| Claude Code | %USERPROFILE%\.claude\skills\yotta-guardian\ | .claude\skills\ |
|
|
111
|
+
| Cursor | %USERPROFILE%\.cursor\skills\yotta-guardian\ | .cursor\skills\ |
|
|
112
|
+
| Windsurf | %USERPROFILE%\.codeium\windsurf\skills\yotta-guardian\ | .windsurf\skills\ |
|
|
113
|
+
| opencode | %USERPROFILE%\.config\opencode\skills\yotta-guardian\ | .opencode\skills\ |
|
|
114
|
+
| Gemini | %USERPROFILE%\.gemini\skills\yotta-guardian\ | .gemini\skills\ |
|
|
115
|
+
| Goose | %USERPROFILE%\.config\goose\skills\yotta-guardian\ | .goose\skills\ |
|
|
116
|
+
| Amp | %USERPROFILE%\.config\agents\skills\yotta-guardian\ | .agents\skills\ |
|
|
117
|
+
| Kiro | %USERPROFILE%\.kiro\skills\yotta-guardian\ | .kiro\skills\ |
|
|
118
|
+
| WorkBuddy | %USERPROFILE%\.workbuddy\skills\yotta-guardian\ | .workbuddy\skills\ |
|
|
119
|
+
| Trae Code CLI | %USERPROFILE%\.traecli\skills\yotta-guardian\ | .traecli\skills\ |
|
|
120
|
+
| Trae IDE(国内) | %USERPROFILE%\.trae-cn\skills\yotta-guardian\ | .trae\skills\ |
|
|
121
|
+
| Qwen Code | %USERPROFILE%\.qwen\skills\yotta-guardian\ | .qwen\skills\ |
|
|
122
|
+
| Comate | %USERPROFILE%\.comate\skills\yotta-guardian\ | .comate\skills\ |
|
|
123
|
+
| CodeBuddy | %USERPROFILE%\.codebuddy\skills\yotta-guardian\ | .codebuddy\skills\ |
|
|
124
|
+
| Kimi | %USERPROFILE%\.kimi\skills\yotta-guardian\ | .kimi\skills\ |
|
|
125
|
+
| 通用 AGENTS.md | %USERPROFILE%\.agents\skills\yotta-guardian\ | .agents\skills\ |
|
|
126
|
+
|
|
127
|
+
> Codex 默认目录若设置了环境变量 CODEX_HOME,以该变量为准;opencode 若设置 XDG_CONFIG_HOME 同理。.agents\skills 并非通用目录,仅 OpenCode / Cursor / Cline / Amp / Kimi / Gemini CLI / GitHub Copilot 等会读取,Claude Code 与 Codex 默认不读。不确定时用 --dir 指定,或让该智能体自行安装。
|
|
128
|
+
|
|
129
|
+
## 使用示例(AI 智能体)
|
|
130
|
+
|
|
131
|
+
1. 将本仓库的 SKILL.md 接入任意 AI 智能体的技能/规则系统(见上方安装)。
|
|
132
|
+
2. 在执行任何高风险工具调用前,先跑一次 check:
|
|
133
|
+
`````bash
|
|
134
|
+
python3 scripts/yotta_guardian.py check exec --cmd "<待执行命令>" --json
|
|
135
|
+
`````
|
|
136
|
+
退出码 2 / 3 时不要执行,向用户说明命中规则;确有授权再用 --allow / --allow-path / 自定义规则放行。
|
|
137
|
+
3. 一次要执行多条时,用 --batch 批量预检:
|
|
138
|
+
`````bash
|
|
139
|
+
python3 scripts/yotta_guardian.py check --batch calls.json --json
|
|
140
|
+
`````
|
|
141
|
+
4. 写敏感路径 / 修改系统配置前,用 write / edit 检查目标路径与内容。
|
|
142
|
+
5. 高风险操作落审计日志,事后用 audit 查询。
|
|
143
|
+
|
|
144
|
+
## 开发与校验
|
|
145
|
+
|
|
146
|
+
- 测试:python scripts/test_yotta_guardian.py(60 项)
|
|
147
|
+
- 基础校验:python tools/validate-skill.py yotta-guardian(在仓库根目录运行)
|
|
148
|
+
- 规则说明:references/rules.md;策略与退出码:references/policies.md;意图验证器协议:references/intent-verifier.md
|
|
149
|
+
|
|
150
|
+
## 许可证
|
|
151
|
+
|
|
152
|
+
MIT © YottaMeta —— 详见 [LICENSE](./LICENSE)。
|
|
153
|
+
|
|
154
|
+
## 致谢
|
|
155
|
+
|
|
156
|
+
护栏/拦截方向参考开源社区 safe-guardian 类技能思路,实现为 YottaMeta 全新自有代码(详见 [NOTICE](./NOTICE))。
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yotta-guardian
|
|
3
|
-
version: 0.1.
|
|
3
|
+
version: 0.1.1
|
|
4
4
|
description: 元盾 —— 跨智能体的危险调用拦截护栏:确定性规则引擎 + 可插拔意图验证(不绑模型),拦截危险 exec / write / edit / read / run / shell 工具调用,提供审计日志。触发:代理要执行高风险命令(递归删除、磁盘格式化、提权、防火墙改动、反向 shell、下载即执行等)、要写入系统敏感路径或修改系统配置、要在执行危险操作前做安全检查、或用户说 护栏/拦截/危险操作/安全检查 等。边界:默认只读评估,不自动执行也不放行危险操作;不替代用户决策;不隐藏审计记录;规则可配置。
|
|
5
5
|
license: MIT
|
|
6
6
|
---
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yottameta/yotta-guardian",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "元盾
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Yuandun (元盾) — cross-agent dangerous tool-call guardrail: a deterministic rule engine + pluggable intent verifier (model-agnostic) that evaluates exec/write/edit/read/run/shell calls and provides audit logs. Triggers when an agent is about to run a high-risk command, write sensitive paths, or change system config. Boundaries: read-only evaluation by default, configurable allowances.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"agent-skills",
|
|
8
|
-
"yotta-guardian"
|
|
8
|
+
"yotta-guardian",
|
|
9
|
+
"security"
|
|
9
10
|
],
|
|
10
11
|
"files": [
|
|
11
12
|
"SKILL.md",
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
"assets",
|
|
18
19
|
"bin",
|
|
19
20
|
"NOTICE",
|
|
20
|
-
"CHANGELOG.md"
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"README.zh-CN.md"
|
|
21
23
|
],
|
|
22
24
|
"repository": {
|
|
23
25
|
"type": "git",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|