@minus-ai/create-skill 0.1.0-beta.6 → 0.1.0-beta.7
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/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { createInterface } from 'node:readline/promises'
|
|
4
|
-
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'
|
|
4
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'node:fs'
|
|
5
5
|
import { execSync } from 'node:child_process'
|
|
6
6
|
import { createServer } from 'node:net'
|
|
7
7
|
import { join, dirname } from 'node:path'
|
|
@@ -15,6 +15,46 @@ const CREDENTIALS_FILE = join(CREDENTIALS_DIR, 'credentials.json')
|
|
|
15
15
|
|
|
16
16
|
const DEFAULT_PLATFORM_URL = 'http://47.107.144.22:18990'
|
|
17
17
|
|
|
18
|
+
// create-skill 内 node 大版本的唯一写死处。模板里的 engines.node / volta.node /
|
|
19
|
+
// @types/node 全部由它派生,不再各自硬编码。与 minus-plugin lib/toolchain.sh 的
|
|
20
|
+
// NODE_TARGET 同义——两仓各自持有同一 major(create-skill 是独立 npm 包,发布时读不到
|
|
21
|
+
// toolchain.sh,故不做运行时跨仓耦合)。升级大版本只改这一个值。
|
|
22
|
+
const NODE_MAJOR_FLOOR = 24
|
|
23
|
+
|
|
24
|
+
function nodeMajorOf(v) {
|
|
25
|
+
return parseInt(String(v).split('.')[0], 10) || 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// 解析「生成项目实际会跑的那个 node」的确切 patch。Volta 不认 major-only/range,
|
|
29
|
+
// volta.node 必须是确切 patch,所以这里返回一个真实存在的 x.y.z。三档:
|
|
30
|
+
// 1. Volta 已装 ≥floor 的最新 node image —— 项目 dev(经 ~/.volta/bin/pnpm)真正会用
|
|
31
|
+
// 且已安装 → 零下载。
|
|
32
|
+
// 2. 没有合格 Volta image,但 create-skill 自身在跑的 node ≥floor —— pin 它(真实存在,
|
|
33
|
+
// 进项目时 Volta 可能下载,但非凭空写死)。
|
|
34
|
+
// 3. 哪里都找不到 ≥floor 的 node → 不编造版本,报错退出。
|
|
35
|
+
function resolveProjectNodeVersion() {
|
|
36
|
+
const imageDir = join(homedir(), '.volta', 'tools', 'image', 'node')
|
|
37
|
+
if (existsSync(imageDir)) {
|
|
38
|
+
const best = readdirSync(imageDir)
|
|
39
|
+
.filter(name => /^\d+\.\d+\.\d+$/.test(name) && nodeMajorOf(name) >= NODE_MAJOR_FLOOR)
|
|
40
|
+
.sort((a, b) => {
|
|
41
|
+
const pa = a.split('.').map(Number)
|
|
42
|
+
const pb = b.split('.').map(Number)
|
|
43
|
+
return pb[0] - pa[0] || pb[1] - pa[1] || pb[2] - pa[2]
|
|
44
|
+
})[0]
|
|
45
|
+
if (best) return best
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const running = process.versions.node
|
|
49
|
+
if (nodeMajorOf(running) >= NODE_MAJOR_FLOOR) return running
|
|
50
|
+
|
|
51
|
+
console.error(
|
|
52
|
+
`\n ✗ 未找到 Node ${NODE_MAJOR_FLOOR}+。请安装 Node ${NODE_MAJOR_FLOOR}(推荐 https://volta.sh:\n` +
|
|
53
|
+
` curl https://get.volta.sh | bash 后 volta install node@${NODE_MAJOR_FLOOR})后重试。`
|
|
54
|
+
)
|
|
55
|
+
process.exit(1)
|
|
56
|
+
}
|
|
57
|
+
|
|
18
58
|
function findAvailablePort(start = 4001) {
|
|
19
59
|
return new Promise(resolve => {
|
|
20
60
|
const server = createServer()
|
|
@@ -28,7 +68,7 @@ function findAvailablePort(start = 4001) {
|
|
|
28
68
|
// ── Naming helpers ──────────────────────────────────────
|
|
29
69
|
|
|
30
70
|
function idToFolder(id) {
|
|
31
|
-
return id.replace(/[
|
|
71
|
+
return id.trim().replace(/[\s/\\]+/g, '-')
|
|
32
72
|
}
|
|
33
73
|
|
|
34
74
|
function idToClassName(id) {
|
|
@@ -476,7 +516,8 @@ async function main() {
|
|
|
476
516
|
const port = String(await findAvailablePort(4001))
|
|
477
517
|
const apiKey = skillResult.apiKey
|
|
478
518
|
|
|
479
|
-
const
|
|
519
|
+
const nodeVersion = resolveProjectNodeVersion()
|
|
520
|
+
const vars = { skillId: skillResult.id, folder, className, displayName, description, namespace, port, nodeVersion, nodeMajor: String(NODE_MAJOR_FLOOR) }
|
|
480
521
|
|
|
481
522
|
// Backend files (pipeline.py from input-type subdir)
|
|
482
523
|
writeOut(join(targetDir, 'pipeline.py'), render(readTemplate('pipeline.py.tpl', inputType), vars))
|
package/package.json
CHANGED
package/templates/README.md.tpl
CHANGED
|
@@ -6,7 +6,7 @@ Minus Skill 项目,由 `create-skill` 脚手架生成。
|
|
|
6
6
|
|
|
7
7
|
| 依赖 | 最低版本 | 说明 |
|
|
8
8
|
|---|---|---|
|
|
9
|
-
| Node.js | >=
|
|
9
|
+
| Node.js | >= {{nodeMajor}} | 前端构建和开发服务 |
|
|
10
10
|
| pnpm | >= 9 | 包管理(全局 store 共享,多 skill 不重复下载) |
|
|
11
11
|
| Python | >= 3.12 | 后端 Pipeline 运行时 |
|
|
12
12
|
| uv | >= 0.4 | Python 包管理(全局缓存,秒级安装) |
|