@lynn123411/dsh-kimi-cu 0.3.7 → 0.3.9
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.md +6 -6
- package/cordis.patch.yml +0 -18
- package/lib/client.js +178 -45
- package/lib/client.js.map +2 -2
- package/lib/index.js +122 -95
- package/lib/index.js.map +2 -2
- package/package.json +2 -1
- package/scripts/assert-lib-untracked.mjs +0 -6
- package/scripts/check-bundle.mjs +79 -119
- package/scripts/lib/client-bundle.mjs +0 -10
- package/scripts/smoke-client.mjs +0 -8
- package/scripts/smoke-host.mjs +8 -19
- package/scripts/test-card.mjs +225 -70
- package/scripts/test-exclusivity.mjs +46 -27
- package/scripts/test-status.mjs +86 -28
- package/scripts/test-update.mjs +17 -11
package/scripts/check-bundle.mjs
CHANGED
|
@@ -1,48 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 包内自检:这个 bundle 装上之后,patch 里那三行真的各就各位,平台分流与技能目录都对。
|
|
4
|
-
*
|
|
5
|
-
* 三层断言,越往下越贴近真实装载:
|
|
6
|
-
* 1. 清单面:files 点名的都在、bundle patch 指得到、exports 与 main 都在、dsh.client 声明了
|
|
7
|
-
* web 与四个契约包、两个语言的标题与说明齐备、两份技能的 frontmatter 合规。
|
|
8
|
-
* 2. 文本面:patch 只插三行、id 与内核包名一致、两条技能行各带自己的平台守卫与目录。这一层不需要内核,CI 上照跑。
|
|
9
|
-
* 3. 契约面(本机装了内核才有):用内核 Include 的 parseEntryYaml 读 patch,再把两条技能行的 config
|
|
10
|
-
* 交给 skill-filesystem 的 Config schema 校验。
|
|
11
|
-
*
|
|
12
|
-
* 随包技能能不能被真发现与真装载不在这里:那是 tools/probes/preset-skills.mjs 的事,check 里
|
|
13
|
-
* 对两个技能根各跑一次。
|
|
14
|
-
*
|
|
15
|
-
* 跑法:pnpm check / node scripts/check-bundle.mjs
|
|
16
|
-
* 退出码:0 通过(含明说跳过),1 不通过。
|
|
17
|
-
*/
|
|
18
2
|
import assert from 'node:assert/strict';
|
|
19
3
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
20
4
|
import { dirname, join, resolve } from 'node:path';
|
|
21
5
|
import { pathToFileURL } from 'node:url';
|
|
22
6
|
|
|
7
|
+
import { parseEntryYaml, stringifyEntryYaml } from '@deepseek-ai/cordis-plugin-include';
|
|
8
|
+
|
|
23
9
|
import { currentKernel } from '../../../tools/lib/repo.mjs';
|
|
24
10
|
import { resolveInstall } from '../src/server/resolve.ts';
|
|
25
11
|
|
|
26
12
|
const PACKAGE_NAME = '@lynn123411/dsh-kimi-cu';
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
13
|
+
const SKILL_ROWS = {
|
|
14
|
+
'skill-kimi-cu-macos': { dir: 'macos', platform: 'darwin' },
|
|
15
|
+
'skill-kimi-cu-windows': { dir: 'windows', platform: 'win32' },
|
|
16
|
+
};
|
|
17
|
+
const ROW_IDS = ['dsh-kimi-cu', ...Object.keys(SKILL_ROWS)];
|
|
32
18
|
|
|
33
19
|
const packageDir = resolve(import.meta.dirname, '..');
|
|
20
|
+
const baseUrl = pathToFileURL(join(packageDir, 'index.js')).href;
|
|
34
21
|
const manifest = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'));
|
|
35
22
|
|
|
36
23
|
let passed = 0;
|
|
37
24
|
let total = 0;
|
|
38
25
|
const skipped = [];
|
|
39
26
|
|
|
40
|
-
/**
|
|
41
|
-
* 跑一条断言;同步与异步的断言共用一条路径(await 一个同步返回值是空操作)。
|
|
42
|
-
* @param label - 这条断言在说什么。
|
|
43
|
-
* @param fn - 断言本体,靠 node:assert 抛错。
|
|
44
|
-
* @returns {Promise<void>}
|
|
45
|
-
*/
|
|
46
27
|
async function test(label, fn) {
|
|
47
28
|
total += 1;
|
|
48
29
|
try {
|
|
@@ -55,18 +36,11 @@ async function test(label, fn) {
|
|
|
55
36
|
console.log(' ok ' + label);
|
|
56
37
|
}
|
|
57
38
|
|
|
58
|
-
/**
|
|
59
|
-
* 明说跳过一条要内核才能跑的断言——「没跑」不能被读成「通过」。
|
|
60
|
-
* @param label - 跳过的是哪条。
|
|
61
|
-
* @param why - 为什么跑不了。
|
|
62
|
-
* @returns {void}
|
|
63
|
-
*/
|
|
64
39
|
function skip(label, why) {
|
|
65
40
|
skipped.push({ label, why });
|
|
66
41
|
console.log(' skip ' + label + '(' + why + ')');
|
|
67
42
|
}
|
|
68
43
|
|
|
69
|
-
// ── 1. 清单面 ─────────────────────────────────────────────────────────────────
|
|
70
44
|
await test('bundle patch 指得到,files 点名的条目都在', () => {
|
|
71
45
|
const declared = manifest.dsh?.bundle?.patch;
|
|
72
46
|
assert.equal(typeof declared, 'string', 'package.json 缺 dsh.bundle.patch');
|
|
@@ -121,18 +95,71 @@ await test('两份技能都在,frontmatter 的 name 与目录名一致且带
|
|
|
121
95
|
}
|
|
122
96
|
});
|
|
123
97
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
98
|
+
function validatePatch(patches) {
|
|
99
|
+
assert.ok(Array.isArray(patches), 'bundle patch 要声明 YAML 列表');
|
|
100
|
+
const rows = patches.flatMap((patch) => {
|
|
101
|
+
assert.deepEqual(Object.keys(patch), ['insert'], 'bundle patch 只插入配置行');
|
|
102
|
+
assert.ok(Array.isArray(patch.insert), 'insert 要声明配置行列表');
|
|
103
|
+
return patch.insert;
|
|
104
|
+
});
|
|
105
|
+
assert.deepEqual(rows.map(({ id }) => id).sort(), [...ROW_IDS].sort(), 'patch 只插入约定的三条配置行');
|
|
106
|
+
|
|
107
|
+
const rootRow = rows.find(({ id }) => id === 'dsh-kimi-cu');
|
|
108
|
+
assert.equal(rootRow.name, PACKAGE_NAME, '根层行要挂本包');
|
|
109
|
+
assert.equal(rootRow.disabled, undefined, '根层行没有平台守卫');
|
|
110
|
+
|
|
111
|
+
for (const [id, { dir, platform }] of Object.entries(SKILL_ROWS)) {
|
|
112
|
+
const row = rows.find((entry) => entry.id === id);
|
|
113
|
+
assert.equal(row.name, '@deepseek-ai/dsh-skill-filesystem', id + ' 要挂内核的 skill-filesystem');
|
|
114
|
+
const guard = row.disabled?.__jsExpr;
|
|
115
|
+
assert.equal(typeof guard, 'string', id + ' 的平台守卫要用 !!js');
|
|
116
|
+
for (const platformUnderTest of ['darwin', 'win32', 'linux']) {
|
|
117
|
+
assert.equal(evaluateExpression(guard, baseUrl, { platform: platformUnderTest }), platformUnderTest !== platform,
|
|
118
|
+
id + ' 的平台守卫对 ' + platformUnderTest + ' 判定有误');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const config = row.config;
|
|
122
|
+
assert.equal(config?.providerName, 'kimi-cu', id + ' 要用独立的 providerName');
|
|
123
|
+
assert.equal(config.includeDefaultRoots, false, id + ' 不该重复扫项目与用户技能目录');
|
|
124
|
+
assert.ok(Array.isArray(config.customSkillDirs), id + ' 要声明技能目录列表');
|
|
125
|
+
assert.equal(config.customSkillDirs.length, 1, id + ' 只扫对应平台的技能目录');
|
|
126
|
+
const expression = config.customSkillDirs[0]?.__jsExpr;
|
|
127
|
+
assert.equal(typeof expression, 'string', id + ' 的技能目录要用 !!js');
|
|
128
|
+
assert.equal(evaluateExpression(expression, baseUrl), join(packageDir, 'skills', dir), id + ' 的表达式要落回 skills/' + dir);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const patchEntries = parseEntryYaml(patchText);
|
|
133
|
+
|
|
134
|
+
await test('用 Include 方言检查 patch 的三条配置行、平台守卫与技能配置', () => {
|
|
135
|
+
validatePatch(patchEntries);
|
|
130
136
|
});
|
|
131
137
|
|
|
132
|
-
await test('
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
await test('patch 可以改用引号和缩进表达同一份配置', () => {
|
|
139
|
+
const canonical = stringifyEntryYaml(patchEntries, { lineWidth: 0 });
|
|
140
|
+
const alternate = canonical
|
|
141
|
+
.replace(/^ +/gm, ' $&')
|
|
142
|
+
.replace(/^( +(?:- )?id: )([\w-]+)$/gm, '$1"$2"');
|
|
143
|
+
assert.match(alternate, /^ +(?:- )?id: "dsh-kimi-cu"$/m);
|
|
144
|
+
const reformatted = parseEntryYaml(alternate);
|
|
145
|
+
assert.deepEqual(reformatted, patchEntries);
|
|
146
|
+
validatePatch(reformatted);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await test('patch 会拒绝错误守卫、错误包名和额外配置行', () => {
|
|
150
|
+
const sourceRows = patchEntries.flatMap(({ insert }) => insert);
|
|
151
|
+
const incorrectGuard = structuredClone(sourceRows);
|
|
152
|
+
incorrectGuard.find(({ id }) => id === 'skill-kimi-cu-macos').disabled = { __jsExpr: "process.platform !== 'win32'" };
|
|
153
|
+
const incorrectName = structuredClone(sourceRows);
|
|
154
|
+
incorrectName.find(({ id }) => id === 'skill-kimi-cu-windows').name = '@deepseek-ai/dsh-mcp-client';
|
|
155
|
+
const cases = [
|
|
156
|
+
[incorrectGuard, /平台守卫对 darwin 判定有误/],
|
|
157
|
+
[incorrectName, /要挂内核的 skill-filesystem/],
|
|
158
|
+
[[...sourceRows, { id: 'extra', name: PACKAGE_NAME }], /只插入约定的三条配置行/],
|
|
159
|
+
];
|
|
160
|
+
for (const [rows, expected] of cases) {
|
|
161
|
+
assert.throws(() => validatePatch(parseEntryYaml(stringifyEntryYaml([{ insert: rows }]))), expected);
|
|
162
|
+
}
|
|
136
163
|
});
|
|
137
164
|
|
|
138
165
|
await test('MCP 连接由宿主半边注册给 mcpManager,命令取自探测器', () => {
|
|
@@ -146,24 +173,6 @@ await test('MCP 连接由宿主半边注册给 mcpManager,命令取自探测
|
|
|
146
173
|
assert.ok(timeout >= 120000, '工具调用上限要覆盖长任务,现为 ' + timeout);
|
|
147
174
|
});
|
|
148
175
|
|
|
149
|
-
/**
|
|
150
|
-
* 取某一行在 patch 文本里的那一段(到下一行 id 或文件末尾)。
|
|
151
|
-
* @param id - 行 id。
|
|
152
|
-
* @returns 该行的文本。
|
|
153
|
-
*/
|
|
154
|
-
function rowBlock(id) {
|
|
155
|
-
const start = patchText.indexOf('id: ' + id);
|
|
156
|
-
assert.ok(start !== -1, 'patch 里找不到 ' + id + ' 行');
|
|
157
|
-
const nextId = ROW_IDS.map((other) => patchText.indexOf('id: ' + other, start + 1)).filter((at) => at > start);
|
|
158
|
-
return patchText.slice(start, nextId.length === 0 ? undefined : Math.min(...nextId));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
await test('根层行挂本包,不带平台守卫', () => {
|
|
162
|
-
const block = rowBlock('dsh-kimi-cu');
|
|
163
|
-
assert.ok(block.includes("name: '" + PACKAGE_NAME + "'"), '根层行要挂本包');
|
|
164
|
-
assert.doesNotMatch(block, /disabled:/, '根层行在别的平台上也要加载,卡片负责说明不支持');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
176
|
await test('探测器给出的 MCP 命令就是各平台的真实路径', () => {
|
|
168
177
|
const mac = resolveInstall({ platform: 'darwin', env: {}, exists: () => true });
|
|
169
178
|
assert.equal(mac.mcp.command, '/Applications/KimiCU.app/Contents/Resources/kimi-cu-mcp', 'macOS 要使用官方启动脚本');
|
|
@@ -171,7 +180,7 @@ await test('探测器给出的 MCP 命令就是各平台的真实路径', () =>
|
|
|
171
180
|
const win = resolveInstall({
|
|
172
181
|
platform: 'win32',
|
|
173
182
|
env: { LOCALAPPDATA: 'C:\\Users\\t\\AppData\\Local' },
|
|
174
|
-
exists: () =>
|
|
183
|
+
exists: (path) => path === 'C:\\Users\\t\\AppData\\Local\\Kimi Computer Use\\kimi-cu.exe',
|
|
175
184
|
});
|
|
176
185
|
assert.equal(win.mcp.command, 'C:\\Users\\t\\AppData\\Local\\Kimi Computer Use\\kimi-cu.exe');
|
|
177
186
|
assert.deepEqual(win.mcp.args, ['mcp'], 'Windows 的 MCP 只传 mcp');
|
|
@@ -179,23 +188,6 @@ await test('探测器给出的 MCP 命令就是各平台的真实路径', () =>
|
|
|
179
188
|
assert.equal(other.mcp, null, '不受支持的平台上探测器给 null,宿主半边就不注册');
|
|
180
189
|
});
|
|
181
190
|
|
|
182
|
-
await test('两条技能行另取 providerName、关掉默认目录,各扫自己的目录', () => {
|
|
183
|
-
for (const [id, dir] of Object.entries(SKILL_DIRS)) {
|
|
184
|
-
const block = rowBlock(id);
|
|
185
|
-
assert.ok(block.includes('providerName: kimi-cu'), id + ' 不另取名就会与内核那条默认技能行同名');
|
|
186
|
-
assert.ok(block.includes('includeDefaultRoots: false'), id + ' 不该重复扫项目与用户技能目录');
|
|
187
|
-
assert.ok(block.includes("'skills', '" + dir + "'"), id + ' 要扫 skills/' + dir);
|
|
188
|
-
assert.ok(block.includes("createRequire(baseUrl).resolve('" + PACKAGE_NAME + "/package.json')"), id + ' 的技能目录要按包名解析');
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// ── 3. 契约面(要本机已装内核) ────────────────────────────────────────────────
|
|
193
|
-
/**
|
|
194
|
-
* 在内核安装树的包仓里找某个包的真实目录。
|
|
195
|
-
* @param kernel - 内核安装树。
|
|
196
|
-
* @param name - 包名,例如 @deepseek-ai/dsh-mcp-client。
|
|
197
|
-
* @returns 包目录;没装就是 undefined。
|
|
198
|
-
*/
|
|
199
191
|
function kernelPackageDir(kernel, name) {
|
|
200
192
|
const store = join(kernel.dir, 'node_modules/.pnpm');
|
|
201
193
|
if (!existsSync(store)) return undefined;
|
|
@@ -207,13 +199,6 @@ function kernelPackageDir(kernel, name) {
|
|
|
207
199
|
return undefined;
|
|
208
200
|
}
|
|
209
201
|
|
|
210
|
-
/**
|
|
211
|
-
* 照 Loader 的方式求值一条 !!js 表达式:作用域里有 baseUrl 与 process。
|
|
212
|
-
* @param expression - 表达式原文。
|
|
213
|
-
* @param baseUrl - 装载该行的目录(file URL)。
|
|
214
|
-
* @param processScope - process 替身;默认真 process。
|
|
215
|
-
* @returns 求值结果。
|
|
216
|
-
*/
|
|
217
202
|
function evaluateExpression(expression, baseUrl, processScope = process) {
|
|
218
203
|
const evaluate = new Function('scope', 'expression', 'with (scope) { return eval(expression) }');
|
|
219
204
|
return evaluate({ baseUrl, process: processScope }, expression);
|
|
@@ -224,10 +209,6 @@ const contractLabels = [
|
|
|
224
209
|
'两条技能行的 config 通过内核 skill-filesystem 的真 Config schema,表达式落回对应目录',
|
|
225
210
|
];
|
|
226
211
|
|
|
227
|
-
/**
|
|
228
|
-
* 本机内核,取不到就 undefined。
|
|
229
|
-
* @returns 内核安装树或 undefined。
|
|
230
|
-
*/
|
|
231
212
|
function localKernel() {
|
|
232
213
|
try {
|
|
233
214
|
return currentKernel();
|
|
@@ -237,11 +218,6 @@ function localKernel() {
|
|
|
237
218
|
}
|
|
238
219
|
}
|
|
239
220
|
|
|
240
|
-
/**
|
|
241
|
-
* 内核里这两个包齐了才能验契约面;缺哪样就说哪样。
|
|
242
|
-
* @param kernel - 内核安装树。
|
|
243
|
-
* @returns 两个包目录或 undefined。
|
|
244
|
-
*/
|
|
245
221
|
function contractDirs(kernel) {
|
|
246
222
|
const dirs = {
|
|
247
223
|
include: kernelPackageDir(kernel, '@deepseek-ai/cordis-plugin-include'),
|
|
@@ -255,37 +231,21 @@ function contractDirs(kernel) {
|
|
|
255
231
|
return dirs;
|
|
256
232
|
}
|
|
257
233
|
|
|
258
|
-
/**
|
|
259
|
-
* 用内核装载时那份 YAML 方言读 patch,并按 id 摊平成一张表。
|
|
260
|
-
* @param includeDir - 内核 cordis-plugin-include 的目录。
|
|
261
|
-
* @returns id 到行的映射。
|
|
262
|
-
*/
|
|
263
|
-
async function parseRows(includeDir) {
|
|
264
|
-
const { parseEntryYaml } = await import(pathToFileURL(join(includeDir, 'lib/index.js')).href);
|
|
265
|
-
const entries = parseEntryYaml(patchText);
|
|
266
|
-
const rows = new Map();
|
|
267
|
-
for (const patch of entries) for (const row of patch.insert ?? []) rows.set(row.id, row);
|
|
268
|
-
return rows;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
234
|
const kernel = localKernel();
|
|
272
235
|
const dirs = kernel === undefined ? undefined : contractDirs(kernel);
|
|
273
236
|
|
|
274
237
|
if (kernel !== undefined && dirs !== undefined) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
assert.deepEqual([...rows.keys()].sort(), [...ROW_IDS].sort(), '解析出来该只有这三行');
|
|
238
|
+
await test('开发依赖与本机内核 ' + kernel.version + ' 对 patch 的解析结果一致', async () => {
|
|
239
|
+
const { parseEntryYaml: parseInstalledYaml } = await import(pathToFileURL(join(dirs.include, 'lib/index.js')).href);
|
|
240
|
+
assert.deepEqual(parseInstalledYaml(patchText), patchEntries);
|
|
279
241
|
});
|
|
280
242
|
|
|
281
243
|
await test('两条技能行的 config 通过内核 skill-filesystem 的真 Config schema,表达式落回对应目录', async () => {
|
|
282
244
|
const { Config } = await import(pathToFileURL(join(dirs.skills, 'lib/index.js')).href);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const fromPackage = evaluateExpression(expression, pathToFileURL(join(packageDir, 'index.js')).href);
|
|
288
|
-
assert.equal(resolve(fromPackage), resolve(join(packageDir, 'skills', dir)), id + ' 的表达式要落回 skills/' + dir);
|
|
245
|
+
const rows = patchEntries.flatMap(({ insert }) => insert);
|
|
246
|
+
for (const [id, { dir }] of Object.entries(SKILL_ROWS)) {
|
|
247
|
+
const row = rows.find((entry) => entry.id === id);
|
|
248
|
+
const fromPackage = evaluateExpression(row.config.customSkillDirs[0].__jsExpr, baseUrl);
|
|
289
249
|
const resolved = Config({ ...row.config, customSkillDirs: [fromPackage] });
|
|
290
250
|
assert.equal(resolved.providerName, 'kimi-cu');
|
|
291
251
|
assert.equal(resolved.includeDefaultRoots, false);
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 按 Web shell 的方式装载 lib/client.js:window.__ModuleLoader__ 桩件 + 平台模块表。
|
|
3
|
-
* 两个客户端自检共用这一份,模块表只写一遍。
|
|
4
|
-
*/
|
|
5
1
|
import { createRequire } from 'node:module';
|
|
6
2
|
import { join } from 'node:path';
|
|
7
3
|
|
|
8
4
|
const require = createRequire(import.meta.url);
|
|
9
5
|
|
|
10
|
-
/** ui-primitives 的薄桩:只顶掉 bundle 真的 require 的那几个名字。 */
|
|
11
6
|
const primitives = {
|
|
12
7
|
Button: () => null,
|
|
13
8
|
Tag: () => null,
|
|
14
9
|
};
|
|
15
10
|
|
|
16
|
-
/**
|
|
17
|
-
* 装载浏览器 bundle。
|
|
18
|
-
* @param root - 包根目录。
|
|
19
|
-
* @returns bundle 的导出与它 require 过的模块 id。
|
|
20
|
-
*/
|
|
21
11
|
export async function loadClientBundle(root) {
|
|
22
12
|
let exported;
|
|
23
13
|
const requires = [];
|
package/scripts/smoke-client.mjs
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 浏览器半边自检:按 Web shell 的方式装载 lib/client.js,喂假 cordis 服务,断言
|
|
3
|
-
* 字典与插件页状态卡注册。**未声明的服务读取必须抛**——漏声明不会报错,只会让插件
|
|
4
|
-
* 在页面里消失(docs/rules/client-wiring.md),守卫自身要有反例断言证明它还能抛。
|
|
5
|
-
*
|
|
6
|
-
* 跑法:pnpm test / node scripts/smoke-client.mjs
|
|
7
|
-
*/
|
|
8
1
|
import { fileURLToPath } from 'node:url';
|
|
9
2
|
import { JSDOM } from 'jsdom';
|
|
10
3
|
import { dirname, join, resolve } from 'node:path';
|
|
@@ -30,7 +23,6 @@ const registrations = [];
|
|
|
30
23
|
const errors = [];
|
|
31
24
|
const effects = [];
|
|
32
25
|
|
|
33
|
-
/** cordis 忠实的上下文:读未声明的服务抛 cannot get property "x" without inject。 */
|
|
34
26
|
function makeCtx(label, declared = []) {
|
|
35
27
|
const table = {
|
|
36
28
|
locale: {
|
package/scripts/smoke-host.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 宿主半边自检:真 cordis Context + 真 ToolRuntime,断言 kimi_cu_status 注册得上、
|
|
3
|
-
* 返回的状态形状对、patch 的五条行各就各位。
|
|
4
|
-
*
|
|
5
|
-
* 跑法:pnpm test / node scripts/smoke-host.mjs
|
|
6
|
-
*/
|
|
7
1
|
import assert from 'node:assert/strict';
|
|
8
2
|
import { readFileSync } from 'node:fs';
|
|
9
3
|
import { dirname, join, resolve } from 'node:path';
|
|
10
4
|
import { fileURLToPath } from 'node:url';
|
|
11
5
|
|
|
12
6
|
import { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import { parseEntryYaml } from '@deepseek-ai/cordis-plugin-include';
|
|
13
8
|
import SystemPrompt from '@deepseek-ai/dsh-system-prompt';
|
|
14
9
|
import ToolRuntime from '@deepseek-ai/dsh-tools';
|
|
15
10
|
import { NativeToolRegistry } from '@deepseek-ai/dsh-tools/pipeline';
|
|
@@ -35,7 +30,6 @@ async function test(label, fn) {
|
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
/** 起一个真内核上下文:工具表 + 它写工具 schema 用的提示词服务。 */
|
|
39
33
|
function host() {
|
|
40
34
|
const ctx = new Context();
|
|
41
35
|
new SystemPrompt(ctx, {});
|
|
@@ -92,18 +86,13 @@ await test('更新路由路径固定', () => {
|
|
|
92
86
|
});
|
|
93
87
|
|
|
94
88
|
await test('patch 有三行,根层行 id 与包名对得上', () => {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
assert.deepEqual(rows[0], ['dsh-kimi-cu', pkgName]);
|
|
103
|
-
assert.deepEqual(rows[1], ['skill-kimi-cu-macos', '@deepseek-ai/dsh-skill-filesystem']);
|
|
104
|
-
assert.deepEqual(rows[2], ['skill-kimi-cu-windows', '@deepseek-ai/dsh-skill-filesystem']);
|
|
105
|
-
// MCP 连接由宿主半边注册,patch 里不该再有 mcp-client 行。
|
|
106
|
-
assert.equal(patch.includes('dsh-mcp-client'), false, 'MCP 连接已交给 mcpManager,patch 里不该再出现静态行');
|
|
89
|
+
const patches = parseEntryYaml(readFileSync(join(root, 'cordis.patch.yml'), 'utf8'));
|
|
90
|
+
const rows = patches.flatMap((patch) => patch.insert ?? []);
|
|
91
|
+
assert.deepEqual(rows.map(({ id, name }) => [id, name]), [
|
|
92
|
+
[plugin.name, pkgName],
|
|
93
|
+
['skill-kimi-cu-macos', '@deepseek-ai/dsh-skill-filesystem'],
|
|
94
|
+
['skill-kimi-cu-windows', '@deepseek-ai/dsh-skill-filesystem'],
|
|
95
|
+
]);
|
|
107
96
|
});
|
|
108
97
|
|
|
109
98
|
console.log('\nsmoke-host: ' + passed + '/' + total + ' 条断言通过');
|