@duanz/pi-skill-trigger 1.0.0 → 1.0.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/README.en.md +58 -0
- package/README.md +58 -0
- package/package.json +8 -4
package/README.en.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# skill-trigger
|
|
2
|
+
|
|
3
|
+
<p align="center"><strong>English</strong> | <a href="./README.md">中文</a></p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/skill-trigger.png" alt="skill-trigger cover" width="880"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>When a task should route through one skill, do not let the model bypass it</strong><br><sub>Soft trigger injection · hard gate on built-in tools · escape hatch kept</sub></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@duanz/pi-skill-trigger"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-skill-trigger.svg?style=flat-square" alt="npm"></a>
|
|
11
|
+
<a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-skill-trigger.svg?style=flat-square" alt="license"></a>
|
|
12
|
+
<a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<code>pi install npm:@duanz/pi-skill-trigger</code>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## Why
|
|
21
|
+
|
|
22
|
+
pi skills are progressively disclosed: the system prompt carries only name + description, and the model decides whether to `read` the body. The docs say it plainly: "models don't always do this; use prompting or /skill:name to force it".
|
|
23
|
+
|
|
24
|
+
A real miss: the user said "go look this up across the web", and the assistant called the built-in `web_search` / `fetch_content` instead of the unified search router. Quota accounting drifted, no free channels were used, and there was no follow-up verification round.
|
|
25
|
+
|
|
26
|
+
## Two layers
|
|
27
|
+
|
|
28
|
+
**Layer 1 — soft injection**: `before_agent_start` matches trigger phrases and injects an invisible reminder for this turn ("this task should go through d-reach; read its SKILL.md first").
|
|
29
|
+
|
|
30
|
+
**Layer 2 — hard gate**: `tool_call` blocks the built-in `web_search` / `fetch_content` until the matching SKILL.md has been read in this session, and names the file to read.
|
|
31
|
+
|
|
32
|
+
## Layer 2 is deliberately narrow
|
|
33
|
+
|
|
34
|
+
1. **Only those two built-in tools; bash untouched.** Daily `curl` runs through bash, and gating it would need an error-prone domain allowlist.
|
|
35
|
+
2. **Local resources pass**: input without `http(s)://` is allowed (`file://`, local images and videos).
|
|
36
|
+
3. **Escape hatch**: any input field containing `#d-reach:allow` passes (explain to the user first); or `PI_SKILL_TRIGGER_GATE=off` disables the layer.
|
|
37
|
+
|
|
38
|
+
## Adding a skill
|
|
39
|
+
|
|
40
|
+
Add one entry to `RULES`; both layers read the same table:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
{
|
|
44
|
+
name: "d-reach",
|
|
45
|
+
path: "/home/you/.pi/agent/skills/d-reach/SKILL.md",
|
|
46
|
+
patterns: /search|look up|find out/i,
|
|
47
|
+
hint: "This task needs the web: read d-reach's SKILL.md first.",
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Limits
|
|
52
|
+
|
|
53
|
+
- Patterns are regexes; rewording can miss. It is a safety net, not a guarantee.
|
|
54
|
+
- The hard gate covers built-in tools only. If the model uses `curl` in bash, this extension stays out of the way (intentionally).
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT © DuanZ
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# skill-trigger
|
|
2
|
+
|
|
3
|
+
<p align="center"><a href="./README.en.md">English</a> | <strong>中文</strong></p>
|
|
4
|
+
|
|
5
|
+
<p align="center"><img src="https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/skill-trigger.png" alt="skill-trigger cover" width="880"></p>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>该走统一路由的时候,别让模型绕过去</strong><br><sub>触发词软注入 · 内置工具硬门禁 · 逃生舱保留</sub></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@duanz/pi-skill-trigger"><img src="https://img.shields.io/npm/v/@duanz%2Fpi-skill-trigger.svg?style=flat-square" alt="npm"></a>
|
|
11
|
+
<a href="https://github.com/DuanZGit/D-Hub/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@duanz%2Fpi-skill-trigger.svg?style=flat-square" alt="license"></a>
|
|
12
|
+
<a href="https://github.com/DuanZGit/D-Hub"><img src="https://img.shields.io/badge/GitHub-DuanZGit%2FD--Hub-181717?style=flat-square&logo=github" alt="GitHub"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/pi-extension-34d399?style=flat-square" alt="pi extension">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<code>pi install npm:@duanz/pi-skill-trigger</code>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
## 它解决什么
|
|
21
|
+
|
|
22
|
+
pi 的技能是渐进披露:系统提示里只有 name + description,正文要模型自己决定去 `read`。官方文档原话是 "models don't always do this; use prompting or /skill:name to force it"。
|
|
23
|
+
|
|
24
|
+
2026-09-25 实测漏过一次:用户说「你去全网看一下」,助手直接调了内置 `web_search` / `fetch_content`,没走 d-reach。后果是额度记账失真、免费通道一个没用、只跑了一轮没有追证轮。
|
|
25
|
+
|
|
26
|
+
## 两层防线
|
|
27
|
+
|
|
28
|
+
**层 1 — 软注入**:`before_agent_start` 里检测触发词,命中就往本轮注入一条不显示的提醒(「这个任务该走 d-reach,先读 SKILL.md」)。
|
|
29
|
+
|
|
30
|
+
**层 2 — 硬门禁**:`tool_call` 里拦住内置 `web_search` / `fetch_content`。本会话没读过对应 SKILL.md 就不放行,并给出该读哪个文件。
|
|
31
|
+
|
|
32
|
+
## 层 2 刻意做窄
|
|
33
|
+
|
|
34
|
+
1. **只拦这两个内置工具,不碰 bash**。日常 `curl` 全走 bash,拦它需要域名白名单那种易错设计。
|
|
35
|
+
2. **本地资源不拦**:输入里没有 `http(s)://` 就放行(`file://`、本地图片/视频)。
|
|
36
|
+
3. **逃生舱**:任一输入字段带 `#d-reach:allow` 即放行(需先向用户说明理由);或 `PI_SKILL_TRIGGER_GATE=off` 整层关掉。
|
|
37
|
+
|
|
38
|
+
## 扩展新技能
|
|
39
|
+
|
|
40
|
+
往 `RULES` 加一条即可,软注入与硬门禁共用同一张表:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
{
|
|
44
|
+
name: "d-reach",
|
|
45
|
+
path: "/home/you/.pi/agent/skills/d-reach/SKILL.md",
|
|
46
|
+
patterns: /搜一下|全网|search|看看有没有/i,
|
|
47
|
+
hint: "这次要联网查东西,先读 d-reach 的 SKILL.md 再做。",
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 限制
|
|
52
|
+
|
|
53
|
+
- 规则是正则,措辞变化可能漏命中——它是兜底,不是保险。
|
|
54
|
+
- 硬门禁只对内置工具生效;模型如果改用 bash 里的 `curl`,本扩展不会拦(这是有意的)。
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT © DuanZ
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duanz/pi-skill-trigger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "按任务内容自动匹配技能,省掉手动挑的一步",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pi-package",
|
|
8
|
-
"pi-extension"
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"pi-web"
|
|
9
10
|
],
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"author": "DuanZ",
|
|
@@ -16,12 +17,15 @@
|
|
|
16
17
|
"directory": "extensions/skill-trigger"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
|
-
"index.ts"
|
|
20
|
+
"index.ts",
|
|
21
|
+
"README.md",
|
|
22
|
+
"README.en.md"
|
|
20
23
|
],
|
|
21
24
|
"pi": {
|
|
22
25
|
"extensions": [
|
|
23
26
|
"./index.ts"
|
|
24
|
-
]
|
|
27
|
+
],
|
|
28
|
+
"image": "https://raw.githubusercontent.com/DuanZGit/D-Hub/master/docs/covers/skill-trigger.png"
|
|
25
29
|
},
|
|
26
30
|
"engines": {
|
|
27
31
|
"node": ">=20"
|