Files
WechatExplorer/scripts/test-skill-install-instruction.cjs
T
Wxw-Gu cf3f115124 feat: 完成 TraceMemo v2.2.0 品牌身份与数据迁移升级
- 将 WechatExplorer 产品身份升级为 TraceMemo
- 更新 appId、Runtime Identity、Reader Skill 和 API 环境变量
- 增加旧用户数据、Knowledge、Token 与 AI Provider 安全迁移
- 保留 Windows WeFlow 和旧版配置兼容
- 完善首次启动迁移测试及 v2.2.0 发布文档
- 移除 macOS Intel x64 构建与发布支持
2026-08-11 17:52:57 +08:00

71 lines
1.9 KiB
JavaScript

const assert = require('node:assert/strict')
const fs = require('node:fs')
const path = require('node:path')
const ts = require('typescript')
const filePath = path.join(
__dirname,
'..',
'src',
'renderer',
'src',
'features',
'api-center',
'utils',
'buildSkillInstallInstruction.ts'
)
const source = fs.readFileSync(filePath, 'utf8')
const output = ts.transpileModule(source, {
compilerOptions: { module: ts.ModuleKind.CommonJS }
}).outputText
const moduleExports = {}
new Function('exports', 'require', 'module', output)(moduleExports, require, {
exports: moduleExports
})
const { buildSkillInstallInstruction } = moduleExports
const local = {
type: 'local',
directoryPath: 'C:/skill/tracememo-reader',
skillPath: 'C:/skill/tracememo-reader/SKILL.md',
version: 'v1.0'
}
for (const [target, expected] of [
['codex', 'Codex 项目或用户 Skill 目录'],
['claude-code', '按照 SKILL\.md 调用本地 HTTP API'],
['openclaw', '作为 TraceMemo Reader Skill 安装'],
['generic', '读取并安装']
]) {
const text = buildSkillInstallInstruction({
target,
source: local,
apiBaseUrl: { host: '127.0.0.1', port: 6131 }
})
assert.match(text, new RegExp(expected))
assert.match(text, /http:\/\/127\.0\.0\.1:6131\/api\/v1\/health/)
assert.match(text, /TRACEMEMO_API_TOKEN/)
assert.match(text, /WECHATEXPLORER_API_TOKEN/)
assert.match(text, /Authorization: Bearer/)
assert.doesNotMatch(text, /mcpServers/)
}
assert.match(
buildSkillInstallInstruction({
target: 'codex',
source: local,
apiBaseUrl: { host: '0.0.0.0', port: 7000 }
}),
/http:\/\/127\.0\.0\.1:7000\/api\/v1\/health/
)
assert.match(
buildSkillInstallInstruction({
target: 'generic',
source: { type: 'remote', installUrl: 'https://example.com/skill', version: 'v1.0' },
apiBaseUrl: { host: 'localhost', port: 6131 }
}),
/https:\/\/example\.com\/skill/
)
console.log('skill install instruction tests passed')