@mcptoolshop/ai-loadout 1.0.2 → 1.0.3
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 +14 -0
- package/README.es.md +103 -101
- package/README.fr.md +103 -101
- package/README.hi.md +103 -101
- package/README.it.md +103 -101
- package/README.ja.md +103 -101
- package/README.md +6 -5
- package/README.pt-BR.md +103 -101
- package/README.zh.md +103 -101
- package/package.json +3 -1
package/README.zh.md
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.md">English</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
<p align="center">
|
|
2
|
-
<
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/ai-loadout/readme.png" width="400" alt="ai-loadout">
|
|
3
7
|
</p>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img src="logo.png" width="400" alt="ai-loadout">
|
|
7
|
-
</p>
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://github.com/mcp-tool-shop-org/ai-loadout/actions/workflows/ci.yml"><img src="https://github.com/mcp-tool-shop-org/ai-loadout/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
11
|
+
<a href="https://codecov.io/gh/mcp-tool-shop-org/ai-loadout"><img src="https://codecov.io/gh/mcp-tool-shop-org/ai-loadout/graph/badge.svg" alt="Coverage"></a>
|
|
11
12
|
<a href="https://www.npmjs.com/package/@mcptoolshop/ai-loadout"><img src="https://img.shields.io/npm/v/@mcptoolshop/ai-loadout" alt="npm"></a>
|
|
12
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT
|
|
13
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT License"></a>
|
|
14
|
+
<a href="https://mcp-tool-shop-org.github.io/ai-loadout/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
|
|
13
15
|
</p>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`ai-loadout`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## 安装
|
|
22
|
-
|
|
16
|
+
|
|
17
|
+
用于 AI 代理的上下文感知知识路由器。
|
|
18
|
+
|
|
19
|
+
`ai-loadout` 是一个分派表格式和匹配引擎,它允许 AI 代理加载完成特定任务所需的知识。 与将所有内容都放入上下文中不同,它维护一个小型索引,并在需要时加载数据。
|
|
20
|
+
|
|
21
|
+
可以将其想象成游戏中的装备配置——在每次任务开始前,为代理配备它所需的精确知识。
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
23
25
|
```bash
|
|
24
26
|
npm install @mcptoolshop/ai-loadout
|
|
25
27
|
```
|
|
26
|
-
|
|
27
|
-
## 核心概念
|
|
28
|
-
|
|
29
|
-
###
|
|
30
|
-
|
|
31
|
-
`LoadoutIndex`
|
|
32
|
-
|
|
28
|
+
|
|
29
|
+
## 核心概念
|
|
30
|
+
|
|
31
|
+
### 分派表
|
|
32
|
+
|
|
33
|
+
`LoadoutIndex` 是一个结构化的知识数据索引:
|
|
34
|
+
|
|
33
35
|
```json
|
|
34
36
|
{
|
|
35
37
|
"version": "1.0.0",
|
|
@@ -55,19 +57,19 @@ npm install @mcptoolshop/ai-loadout
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
```
|
|
58
|
-
|
|
59
|
-
### 优先级层级
|
|
60
|
-
|
|
61
|
-
| 层级 | 行为 | 示例 |
|
|
62
|
-
|
|
63
|
-
| `core` | 始终加载 | "
|
|
64
|
-
| `domain` | 当任务关键词匹配时加载 |
|
|
65
|
-
| `manual` |
|
|
66
|
-
|
|
67
|
-
###
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
|
|
61
|
+
### 优先级层级
|
|
62
|
+
|
|
63
|
+
| 层级 | 行为 | 示例 |
|
|
64
|
+
|------|----------|---------|
|
|
65
|
+
| `core` | 始终加载 | "永远不要跳过测试以使 CI 流程通过" |
|
|
66
|
+
| `domain` | 当任务关键词匹配时加载 | 编辑工作流时的 CI 规则 |
|
|
67
|
+
| `manual` | 从不自动加载,仅进行显式查找 | 一些不为人知的平台问题 |
|
|
68
|
+
|
|
69
|
+
### 数据前缀
|
|
70
|
+
|
|
71
|
+
每个数据文件都包含自己的路由元数据:
|
|
72
|
+
|
|
71
73
|
```markdown
|
|
72
74
|
---
|
|
73
75
|
id: github-actions
|
|
@@ -83,41 +85,41 @@ triggers:
|
|
|
83
85
|
# GitHub Actions Rules
|
|
84
86
|
CI minutes are finite...
|
|
85
87
|
```
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## API
|
|
90
|
-
|
|
91
|
-
### `matchLoadout(task, index)`
|
|
92
|
-
|
|
93
|
-
将任务描述与
|
|
94
|
-
|
|
88
|
+
|
|
89
|
+
数据前缀是权威来源。索引是从其派生的。
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### `matchLoadout(task, index)`
|
|
94
|
+
|
|
95
|
+
将任务描述与 `LoadoutIndex` 进行匹配。返回应加载的条目,并按匹配强度排序。
|
|
96
|
+
|
|
95
97
|
```typescript
|
|
96
98
|
import { matchLoadout } from "@mcptoolshop/ai-loadout";
|
|
97
99
|
|
|
98
100
|
const results = matchLoadout("fix the CI workflow", index);
|
|
99
101
|
// [{ entry: { id: "github-actions", ... }, score: 0.67, matchedKeywords: ["ci", "workflow"] }]
|
|
100
102
|
```
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
### `lookupEntry(id, index)`
|
|
108
|
-
|
|
109
|
-
通过 ID
|
|
110
|
-
|
|
103
|
+
|
|
104
|
+
- 核心条目始终包含(得分 1.0)
|
|
105
|
+
- 手动添加的条目从不自动包含
|
|
106
|
+
- 领域条目的得分基于关键词重叠 + 模式加分
|
|
107
|
+
- 结果按得分降序排序
|
|
108
|
+
|
|
109
|
+
### `lookupEntry(id, index)`
|
|
110
|
+
|
|
111
|
+
通过 ID 查找特定条目。用于手动添加的条目或显式访问。
|
|
112
|
+
|
|
111
113
|
```typescript
|
|
112
114
|
import { lookupEntry } from "@mcptoolshop/ai-loadout";
|
|
113
115
|
|
|
114
116
|
const entry = lookupEntry("github-actions", index);
|
|
115
117
|
```
|
|
116
|
-
|
|
117
|
-
### `parseFrontmatter(content)`
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
|
|
119
|
+
### `parseFrontmatter(content)`
|
|
120
|
+
|
|
121
|
+
解析数据文件中的 YAML 格式的数据前缀。
|
|
122
|
+
|
|
121
123
|
```typescript
|
|
122
124
|
import { parseFrontmatter } from "@mcptoolshop/ai-loadout";
|
|
123
125
|
|
|
@@ -126,15 +128,15 @@ if (frontmatter) {
|
|
|
126
128
|
console.log(frontmatter.id, frontmatter.keywords);
|
|
127
129
|
}
|
|
128
130
|
```
|
|
129
|
-
|
|
130
|
-
### `serializeFrontmatter(fm)`
|
|
131
|
-
|
|
132
|
-
将 `Frontmatter`
|
|
133
|
-
|
|
134
|
-
### `validateIndex(index)`
|
|
135
|
-
|
|
136
|
-
验证 `LoadoutIndex`
|
|
137
|
-
|
|
131
|
+
|
|
132
|
+
### `serializeFrontmatter(fm)`
|
|
133
|
+
|
|
134
|
+
将 `Frontmatter` 对象序列化为字符串。
|
|
135
|
+
|
|
136
|
+
### `validateIndex(index)`
|
|
137
|
+
|
|
138
|
+
验证 `LoadoutIndex` 的结构完整性。返回一个包含问题的数组。
|
|
139
|
+
|
|
138
140
|
```typescript
|
|
139
141
|
import { validateIndex } from "@mcptoolshop/ai-loadout";
|
|
140
142
|
|
|
@@ -144,21 +146,21 @@ if (errors.length > 0) {
|
|
|
144
146
|
console.error("Index has errors:", errors);
|
|
145
147
|
}
|
|
146
148
|
```
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### `estimateTokens(text)`
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
|
|
150
|
+
检查内容:必需字段、唯一 ID、kebab-case 格式、摘要范围、领域条目的关键词是否存在、有效的优先级、非负预算。
|
|
151
|
+
|
|
152
|
+
### `estimateTokens(text)`
|
|
153
|
+
|
|
154
|
+
根据文本估算令牌数量。使用字符/4 的启发式方法。
|
|
155
|
+
|
|
154
156
|
```typescript
|
|
155
157
|
import { estimateTokens } from "@mcptoolshop/ai-loadout";
|
|
156
158
|
|
|
157
159
|
const tokens = estimateTokens(fileContent); // ~250
|
|
158
160
|
```
|
|
159
|
-
|
|
160
|
-
##
|
|
161
|
-
|
|
161
|
+
|
|
162
|
+
## 类型
|
|
163
|
+
|
|
162
164
|
```typescript
|
|
163
165
|
import type {
|
|
164
166
|
LoadoutEntry,
|
|
@@ -171,26 +173,26 @@ import type {
|
|
|
171
173
|
Budget,
|
|
172
174
|
} from "@mcptoolshop/ai-loadout";
|
|
173
175
|
```
|
|
174
|
-
|
|
175
|
-
## 使用者
|
|
176
|
-
|
|
177
|
-
- **[@mcptoolshop/claude-rules](https://github.com/mcp-tool-shop-org/claude-rules)** — Claude Code 的 CLAUDE.md 优化器。使用 ai-loadout
|
|
178
|
-
|
|
179
|
-
## 安全性
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
###
|
|
184
|
-
|
|
185
|
-
| 威胁 | 缓解措施 |
|
|
186
|
-
|
|
187
|
-
|
|
|
188
|
-
| 原型污染 |
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
|
|
177
|
+
## 使用者
|
|
178
|
+
|
|
179
|
+
- **[@mcptoolshop/claude-rules](https://github.com/mcp-tool-shop-org/claude-rules)** — 用于 Claude Code 的 CLAUDE.md 优化器。使用 `ai-loadout` 作为分派表和匹配引擎。
|
|
180
|
+
|
|
181
|
+
## 安全性
|
|
182
|
+
|
|
183
|
+
此软件包是一个纯数据库。它不访问文件系统,不进行网络请求,也不收集遥测数据。所有 I/O 由使用者负责。
|
|
184
|
+
|
|
185
|
+
### 安全模型
|
|
186
|
+
|
|
187
|
+
| 威胁 | 缓解措施 |
|
|
188
|
+
|--------|------------|
|
|
189
|
+
| 格式错误的元数据输入 | `parseFrontmatter()` 在无效输入时返回 `null`,不抛出异常,也不使用 `eval` |
|
|
190
|
+
| 原型污染 | 手动编写的解析器使用纯对象字面量,不使用 `JSON.parse` 解析不可信任的嵌套结构 |
|
|
191
|
+
| 包含不良数据的索引 | `validateIndex()` 在问题传播之前捕获结构性问题 |
|
|
192
|
+
| 正则表达式拒绝服务 (DoS) | 不使用用户提供的正则表达式——模式作为纯字符串查找进行匹配 |
|
|
193
|
+
|
|
194
|
+
有关完整的安全策略,请参阅 [SECURITY.md](SECURITY.md)。
|
|
195
|
+
|
|
194
196
|
---
|
|
195
|
-
|
|
196
|
-
由 [MCP Tool Shop](https://mcp-tool-shop.github.io/)
|
|
197
|
+
|
|
198
|
+
由 [MCP Tool Shop](https://mcp-tool-shop.github.io/) 构建。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcptoolshop/ai-loadout",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Context-aware knowledge router for AI agents. Dispatch table, frontmatter spec, keyword matcher, token estimator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"verify": "tsc --noEmit && node --test dist/tests/*.test.js",
|
|
17
17
|
"test": "node --test dist/tests/*.test.js",
|
|
18
|
+
"test:coverage": "c8 --reporter=lcov --reporter=text node --test dist/tests/*.test.js",
|
|
18
19
|
"prepublishOnly": "npm run build"
|
|
19
20
|
},
|
|
20
21
|
"files": [
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@types/node": "^22.0.0",
|
|
47
|
+
"c8": "^11.0.0",
|
|
46
48
|
"typescript": "^5.7.0"
|
|
47
49
|
}
|
|
48
50
|
}
|