@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/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
- <a href="README.md">English</a> | <a href="README.zh.md">中文</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> | <a href="README.ja.md">日本語</a>
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 许可证"></a>
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
- 面向 AI 代理的上下文感知知识路由器。
16
-
17
- `ai-loadout` 是一种调度表格式和匹配引擎,让 AI 代理能够为当前任务加载正确的知识。无需将所有内容都塞入上下文,你只需维护一个小型索引,按需加载有效负载。
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` | 始终加载 | "绝不跳过测试来让 CI 通过" |
64
- | `domain` | 当任务关键词匹配时加载 | 编辑 workflow 时的 CI 规则 |
65
- | `manual` | 从不自动加载,仅限显式查找 | 罕见的平台问题 |
66
-
67
- ### 有效负载 Frontmatter
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
- Frontmatter 是唯一的事实来源。索引从中派生。
88
-
89
- ## API
90
-
91
- ### `matchLoadout(task, index)`
92
-
93
- 将任务描述与 loadout 索引进行匹配。返回应加载的条目,按匹配强度排序。
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
- - core 条目始终包含(得分 1.0)
103
- - manual 条目从不自动包含
104
- - domain 条目按关键词重叠度 + 模式加分评分
105
- - 结果按得分降序排列
106
-
107
- ### `lookupEntry(id, index)`
108
-
109
- 通过 ID 查找特定条目。用于 manual 条目或显式访问。
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
- 从有效负载文件中解析类 YAML 格式的 frontmatter。
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
- 检查项:必填字段、唯一 ID、kebab-case 格式、摘要长度限制、domain 条目的关键词存在性、有效优先级、非负预算。
149
-
150
- ### `estimateTokens(text)`
151
-
152
- 估算文本的 token 数量。使用字符数/4 的启发式方法。
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
- 此包是一个纯数据库。它不访问文件系统、不发起网络请求、不收集遥测数据。所有 I/O 由使用者负责。
182
-
183
- ### 威胁模型
184
-
185
- | 威胁 | 缓解措施 |
186
- |------|----------|
187
- | 格式错误的 frontmatter 输入 | `parseFrontmatter()` 在无效输入时返回 `null` — 无异常、无 eval |
188
- | 原型污染 | 手动解析器使用普通对象字面量,不对不可信的嵌套结构使用 `JSON.parse` |
189
- | 包含错误数据的索引 | `validateIndex()` 在问题扩散前检测结构性问题 |
190
- | Regex DoS | 无用户提供的正则表达式 — 模式作为纯字符串查找进行匹配 |
191
-
192
- 完整安全策略请参阅 [SECURITY.md](SECURITY.md)。
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.2",
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
  }