@kevlns/art-workshop 0.3.8 → 0.3.11
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/AGENTS.md +9 -0
- package/art-workshop.mjs +19 -10
- package/docs/commands.md +103 -50
- package/docs/deployment.md +15 -43
- package/docs/local-models/qwen-image-2.1.json +55 -0
- package/docs/local-models/qwen-image-2.1.md +31 -0
- package/lib/agent.mjs +1 -1
- package/lib/deployment-guide.mjs +12 -0
- package/lib/environment-operations.mjs +49 -0
- package/lib/environments.mjs +20 -35
- package/lib/style-bundle.mjs +85 -0
- package/package.json +1 -1
- package/skills/art-workshop/SKILL.md +9 -0
- package/v-cli.plugin.json +223 -100
- package/lib/deployment-process.mjs +0 -19
- package/lib/deployment-source.mjs +0 -24
- package/lib/deployment-worker.mjs +0 -86
- package/lib/deployment.mjs +0 -75
package/v-cli.plugin.json
CHANGED
|
@@ -1944,245 +1944,368 @@
|
|
|
1944
1944
|
},
|
|
1945
1945
|
{
|
|
1946
1946
|
"path": [
|
|
1947
|
-
"
|
|
1948
|
-
"
|
|
1947
|
+
"job",
|
|
1948
|
+
"template"
|
|
1949
1949
|
],
|
|
1950
|
-
"
|
|
1950
|
+
"usage": "v-cli art job template --project <id> --kind <generate|edit> [--core <id>]",
|
|
1951
|
+
"description": "只读返回工具权威的任务配置模板;生成任务使用已冻结核心的题材",
|
|
1952
|
+
"arguments": [],
|
|
1951
1953
|
"options": [
|
|
1952
1954
|
{
|
|
1953
|
-
"flags": "--
|
|
1954
|
-
"description": "
|
|
1955
|
+
"flags": "--project <id>",
|
|
1956
|
+
"description": "工程身份"
|
|
1955
1957
|
},
|
|
1956
1958
|
{
|
|
1957
|
-
"flags": "--
|
|
1958
|
-
"description": "
|
|
1959
|
+
"flags": "--kind <generate|edit>",
|
|
1960
|
+
"description": "任务类型"
|
|
1959
1961
|
},
|
|
1960
1962
|
{
|
|
1961
|
-
"flags": "--
|
|
1962
|
-
"description": "
|
|
1963
|
+
"flags": "--core <id>",
|
|
1964
|
+
"description": "生成任务的冻结核心身份"
|
|
1963
1965
|
}
|
|
1964
1966
|
],
|
|
1965
1967
|
"output": {
|
|
1966
1968
|
"format": "json",
|
|
1967
|
-
"description": "
|
|
1969
|
+
"description": "只读返回工具权威的任务配置模板;生成任务使用已冻结核心的题材"
|
|
1970
|
+
},
|
|
1971
|
+
"exitCodes": {
|
|
1972
|
+
"0": "成功",
|
|
1973
|
+
"1": "校验、版本冲突或执行失败"
|
|
1968
1974
|
},
|
|
1969
1975
|
"safety": [
|
|
1970
|
-
"
|
|
1976
|
+
"只读返回模板;不创建任务或文件"
|
|
1977
|
+
]
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
"path": [
|
|
1981
|
+
"job",
|
|
1982
|
+
"from-candidate"
|
|
1971
1983
|
],
|
|
1972
|
-
"usage": "art-
|
|
1984
|
+
"usage": "v-cli art job from-candidate --project <id> --id <task> --run <id> --candidate <id>",
|
|
1985
|
+
"description": "将完整候选导入私有底图,创建独立编辑草稿,不运行",
|
|
1973
1986
|
"arguments": [],
|
|
1987
|
+
"options": [
|
|
1988
|
+
{
|
|
1989
|
+
"flags": "--project <id>",
|
|
1990
|
+
"description": "工程身份"
|
|
1991
|
+
},
|
|
1992
|
+
{
|
|
1993
|
+
"flags": "--id <task>",
|
|
1994
|
+
"description": "源任务身份"
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
"flags": "--run <id>",
|
|
1998
|
+
"description": "真实批次"
|
|
1999
|
+
},
|
|
2000
|
+
{
|
|
2001
|
+
"flags": "--candidate <id>",
|
|
2002
|
+
"description": "完整候选身份"
|
|
2003
|
+
}
|
|
2004
|
+
],
|
|
2005
|
+
"output": {
|
|
2006
|
+
"format": "json",
|
|
2007
|
+
"description": "将完整候选导入私有底图,创建独立编辑草稿,不运行"
|
|
2008
|
+
},
|
|
2009
|
+
"exitCodes": {
|
|
2010
|
+
"0": "成功",
|
|
2011
|
+
"1": "校验、版本冲突或执行失败"
|
|
2012
|
+
},
|
|
2013
|
+
"safety": [
|
|
2014
|
+
"写入新的编辑草稿和私有底图;保留候选来源;不启动生成"
|
|
2015
|
+
]
|
|
2016
|
+
},
|
|
2017
|
+
{
|
|
2018
|
+
"path": [
|
|
2019
|
+
"task",
|
|
2020
|
+
"resume"
|
|
2021
|
+
],
|
|
2022
|
+
"usage": "art-workshop task resume TASK",
|
|
2023
|
+
"description": "仅恢复原上游任务的查询和下载,绝不重新提交",
|
|
2024
|
+
"arguments": [
|
|
2025
|
+
{
|
|
2026
|
+
"name": "TASK",
|
|
2027
|
+
"required": true,
|
|
2028
|
+
"description": "art 任务 ID"
|
|
2029
|
+
}
|
|
2030
|
+
],
|
|
2031
|
+
"options": [],
|
|
2032
|
+
"output": {
|
|
2033
|
+
"format": "json",
|
|
2034
|
+
"description": "仅恢复原上游任务的查询和下载,绝不重新提交"
|
|
2035
|
+
},
|
|
1974
2036
|
"exitCodes": {
|
|
1975
2037
|
"0": "成功",
|
|
1976
|
-
"1": "
|
|
2038
|
+
"1": "失败;未确认停止时保留服务并报告"
|
|
2039
|
+
},
|
|
2040
|
+
"safety": [
|
|
2041
|
+
"写入原任务状态",
|
|
2042
|
+
"查询原上游任务并下载已有产物",
|
|
2043
|
+
"提交结果未知时拒绝恢复"
|
|
2044
|
+
]
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
"path": [
|
|
2048
|
+
"environment",
|
|
2049
|
+
"guide"
|
|
2050
|
+
],
|
|
2051
|
+
"description": "本地环境部署指南",
|
|
2052
|
+
"usage": "art-workshop environment guide",
|
|
2053
|
+
"arguments": [],
|
|
2054
|
+
"options": [
|
|
2055
|
+
{
|
|
2056
|
+
"flags": "--guide <id>",
|
|
2057
|
+
"description": "部署指南标识;省略使用环境登记或推荐方案"
|
|
2058
|
+
}
|
|
2059
|
+
],
|
|
2060
|
+
"output": {
|
|
2061
|
+
"format": "json",
|
|
2062
|
+
"description": "环境事实与验收结果"
|
|
2063
|
+
},
|
|
2064
|
+
"safety": [
|
|
2065
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2066
|
+
],
|
|
2067
|
+
"exitCodes": {
|
|
2068
|
+
"0": "成功",
|
|
2069
|
+
"1": "验收或执行失败"
|
|
2070
|
+
}
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
"path": [
|
|
2074
|
+
"environment",
|
|
2075
|
+
"list"
|
|
2076
|
+
],
|
|
2077
|
+
"description": "本地环境目录发现",
|
|
2078
|
+
"usage": "art-workshop environment list",
|
|
2079
|
+
"arguments": [],
|
|
2080
|
+
"options": [],
|
|
2081
|
+
"output": {
|
|
2082
|
+
"format": "json",
|
|
2083
|
+
"description": "环境事实与验收结果"
|
|
2084
|
+
},
|
|
2085
|
+
"safety": [
|
|
2086
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2087
|
+
],
|
|
2088
|
+
"exitCodes": {
|
|
2089
|
+
"0": "成功",
|
|
2090
|
+
"1": "验收或执行失败"
|
|
1977
2091
|
}
|
|
1978
2092
|
},
|
|
1979
2093
|
{
|
|
1980
2094
|
"path": [
|
|
1981
|
-
"
|
|
1982
|
-
"
|
|
2095
|
+
"environment",
|
|
2096
|
+
"inspect"
|
|
1983
2097
|
],
|
|
1984
|
-
"description": "
|
|
2098
|
+
"description": "本地环境只读检测",
|
|
2099
|
+
"usage": "art-workshop environment inspect",
|
|
2100
|
+
"arguments": [],
|
|
1985
2101
|
"options": [
|
|
1986
2102
|
{
|
|
1987
|
-
"flags": "--
|
|
1988
|
-
"description": "
|
|
2103
|
+
"flags": "--directory <value>",
|
|
2104
|
+
"description": "本机环境根目录"
|
|
1989
2105
|
},
|
|
1990
2106
|
{
|
|
1991
|
-
"flags": "--
|
|
1992
|
-
"description": "
|
|
2107
|
+
"flags": "--endpoint <value>",
|
|
2108
|
+
"description": "本机 HTTP 服务根地址"
|
|
2109
|
+
},
|
|
2110
|
+
{
|
|
2111
|
+
"flags": "--guide <id>",
|
|
2112
|
+
"description": "部署指南标识;省略使用环境登记或推荐方案"
|
|
1993
2113
|
}
|
|
1994
2114
|
],
|
|
1995
2115
|
"output": {
|
|
1996
2116
|
"format": "json",
|
|
1997
|
-
"description": "
|
|
2117
|
+
"description": "环境事实与验收结果"
|
|
1998
2118
|
},
|
|
1999
2119
|
"safety": [
|
|
2000
|
-
"
|
|
2120
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2001
2121
|
],
|
|
2002
|
-
"usage": "art-workshop deployment start",
|
|
2003
|
-
"arguments": [],
|
|
2004
2122
|
"exitCodes": {
|
|
2005
2123
|
"0": "成功",
|
|
2006
|
-
"1": "
|
|
2124
|
+
"1": "验收或执行失败"
|
|
2007
2125
|
}
|
|
2008
2126
|
},
|
|
2009
2127
|
{
|
|
2010
2128
|
"path": [
|
|
2011
|
-
"
|
|
2012
|
-
"
|
|
2129
|
+
"environment",
|
|
2130
|
+
"verify"
|
|
2013
2131
|
],
|
|
2014
|
-
"description": "
|
|
2132
|
+
"description": "本地环境确定性验收",
|
|
2133
|
+
"usage": "art-workshop environment verify",
|
|
2134
|
+
"arguments": [],
|
|
2015
2135
|
"options": [
|
|
2016
2136
|
{
|
|
2017
|
-
"flags": "--
|
|
2018
|
-
"description": "
|
|
2137
|
+
"flags": "--directory <value>",
|
|
2138
|
+
"description": "本机环境根目录"
|
|
2139
|
+
},
|
|
2140
|
+
{
|
|
2141
|
+
"flags": "--endpoint <value>",
|
|
2142
|
+
"description": "本机 HTTP 服务根地址"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
"flags": "--guide <id>",
|
|
2146
|
+
"description": "部署指南标识;省略使用环境登记或推荐方案"
|
|
2019
2147
|
}
|
|
2020
2148
|
],
|
|
2021
2149
|
"output": {
|
|
2022
2150
|
"format": "json",
|
|
2023
|
-
"description": "
|
|
2151
|
+
"description": "环境事实与验收结果"
|
|
2024
2152
|
},
|
|
2025
2153
|
"safety": [
|
|
2026
|
-
"
|
|
2154
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2027
2155
|
],
|
|
2028
|
-
"usage": "art-workshop deployment status",
|
|
2029
|
-
"arguments": [],
|
|
2030
2156
|
"exitCodes": {
|
|
2031
2157
|
"0": "成功",
|
|
2032
|
-
"1": "
|
|
2158
|
+
"1": "验收或执行失败"
|
|
2033
2159
|
}
|
|
2034
2160
|
},
|
|
2035
2161
|
{
|
|
2036
2162
|
"path": [
|
|
2037
|
-
"
|
|
2038
|
-
"
|
|
2163
|
+
"environment",
|
|
2164
|
+
"register"
|
|
2039
2165
|
],
|
|
2040
|
-
"description": "
|
|
2166
|
+
"description": "本地环境验收并登记",
|
|
2167
|
+
"usage": "art-workshop environment register",
|
|
2168
|
+
"arguments": [],
|
|
2041
2169
|
"options": [
|
|
2042
2170
|
{
|
|
2043
|
-
"flags": "--
|
|
2044
|
-
"description": "
|
|
2171
|
+
"flags": "--directory <value>",
|
|
2172
|
+
"description": "本机环境根目录"
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
"flags": "--endpoint <value>",
|
|
2176
|
+
"description": "本机 HTTP 服务根地址"
|
|
2177
|
+
},
|
|
2178
|
+
{
|
|
2179
|
+
"flags": "--guide <id>",
|
|
2180
|
+
"description": "部署指南标识;省略使用环境登记或推荐方案"
|
|
2045
2181
|
}
|
|
2046
2182
|
],
|
|
2047
2183
|
"output": {
|
|
2048
2184
|
"format": "json",
|
|
2049
|
-
"description": "
|
|
2185
|
+
"description": "环境事实与验收结果"
|
|
2050
2186
|
},
|
|
2051
2187
|
"safety": [
|
|
2052
|
-
"
|
|
2188
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2053
2189
|
],
|
|
2054
|
-
"usage": "art-workshop deployment cancel",
|
|
2055
|
-
"arguments": [],
|
|
2056
2190
|
"exitCodes": {
|
|
2057
2191
|
"0": "成功",
|
|
2058
|
-
"1": "
|
|
2192
|
+
"1": "验收或执行失败"
|
|
2059
2193
|
}
|
|
2060
2194
|
},
|
|
2061
2195
|
{
|
|
2062
2196
|
"path": [
|
|
2063
|
-
"
|
|
2064
|
-
"
|
|
2197
|
+
"environment",
|
|
2198
|
+
"unregister"
|
|
2065
2199
|
],
|
|
2066
|
-
"description": "
|
|
2200
|
+
"description": "本地环境解除登记",
|
|
2201
|
+
"usage": "art-workshop environment unregister",
|
|
2202
|
+
"arguments": [],
|
|
2067
2203
|
"options": [
|
|
2068
2204
|
{
|
|
2069
|
-
"flags": "--
|
|
2070
|
-
"description": "
|
|
2205
|
+
"flags": "--directory <value>",
|
|
2206
|
+
"description": "本机环境根目录"
|
|
2071
2207
|
}
|
|
2072
2208
|
],
|
|
2073
2209
|
"output": {
|
|
2074
2210
|
"format": "json",
|
|
2075
|
-
"description": "
|
|
2211
|
+
"description": "环境事实与验收结果"
|
|
2076
2212
|
},
|
|
2077
2213
|
"safety": [
|
|
2078
|
-
"
|
|
2214
|
+
"不执行安装、下载或采样;register 重新验收后登记,unregister 不删除安装文件或停止服务"
|
|
2079
2215
|
],
|
|
2080
|
-
"usage": "art-workshop deployment recover",
|
|
2081
|
-
"arguments": [],
|
|
2082
2216
|
"exitCodes": {
|
|
2083
2217
|
"0": "成功",
|
|
2084
|
-
"1": "
|
|
2218
|
+
"1": "验收或执行失败"
|
|
2085
2219
|
}
|
|
2086
2220
|
},
|
|
2087
2221
|
{
|
|
2088
2222
|
"path": [
|
|
2089
|
-
"
|
|
2090
|
-
"
|
|
2223
|
+
"style",
|
|
2224
|
+
"export"
|
|
2091
2225
|
],
|
|
2092
|
-
"usage": "
|
|
2093
|
-
"description": "
|
|
2226
|
+
"usage": "art-workshop style export",
|
|
2227
|
+
"description": "导出冻结风格及必要参考,不复制运行状态",
|
|
2094
2228
|
"arguments": [],
|
|
2095
2229
|
"options": [
|
|
2096
2230
|
{
|
|
2097
|
-
"flags": "--project <
|
|
2231
|
+
"flags": "--project <value>",
|
|
2098
2232
|
"description": "工程身份"
|
|
2099
2233
|
},
|
|
2100
2234
|
{
|
|
2101
|
-
"flags": "--
|
|
2102
|
-
"description": "
|
|
2235
|
+
"flags": "--id <value>",
|
|
2236
|
+
"description": "冻结风格身份"
|
|
2103
2237
|
},
|
|
2104
2238
|
{
|
|
2105
|
-
"flags": "--
|
|
2106
|
-
"description": "
|
|
2239
|
+
"flags": "--out <value>",
|
|
2240
|
+
"description": "风格包输出文件"
|
|
2107
2241
|
}
|
|
2108
2242
|
],
|
|
2109
2243
|
"output": {
|
|
2110
2244
|
"format": "json",
|
|
2111
|
-
"description": "
|
|
2245
|
+
"description": "导出冻结风格及必要参考,不复制运行状态"
|
|
2112
2246
|
},
|
|
2113
2247
|
"exitCodes": {
|
|
2114
2248
|
"0": "成功",
|
|
2115
|
-
"1": "
|
|
2249
|
+
"1": "校验失败"
|
|
2116
2250
|
},
|
|
2117
2251
|
"safety": [
|
|
2118
|
-
"
|
|
2252
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2119
2253
|
]
|
|
2120
2254
|
},
|
|
2121
2255
|
{
|
|
2122
2256
|
"path": [
|
|
2123
|
-
"
|
|
2124
|
-
"
|
|
2257
|
+
"style",
|
|
2258
|
+
"import"
|
|
2125
2259
|
],
|
|
2126
|
-
"usage": "
|
|
2127
|
-
"description": "
|
|
2260
|
+
"usage": "art-workshop style import",
|
|
2261
|
+
"description": "导入固定版本的共享冻结风格,保留原身份和版本",
|
|
2128
2262
|
"arguments": [],
|
|
2129
2263
|
"options": [
|
|
2130
2264
|
{
|
|
2131
|
-
"flags": "--project <
|
|
2132
|
-
"description": "
|
|
2133
|
-
},
|
|
2134
|
-
{
|
|
2135
|
-
"flags": "--id <task>",
|
|
2136
|
-
"description": "源任务身份"
|
|
2137
|
-
},
|
|
2138
|
-
{
|
|
2139
|
-
"flags": "--run <id>",
|
|
2140
|
-
"description": "真实批次"
|
|
2265
|
+
"flags": "--project <value>",
|
|
2266
|
+
"description": "目标工程"
|
|
2141
2267
|
},
|
|
2142
2268
|
{
|
|
2143
|
-
"flags": "--
|
|
2144
|
-
"description": "
|
|
2269
|
+
"flags": "--file <value>",
|
|
2270
|
+
"description": "风格包文件"
|
|
2145
2271
|
}
|
|
2146
2272
|
],
|
|
2147
2273
|
"output": {
|
|
2148
2274
|
"format": "json",
|
|
2149
|
-
"description": "
|
|
2275
|
+
"description": "导入固定版本的共享冻结风格,保留原身份和版本"
|
|
2150
2276
|
},
|
|
2151
2277
|
"exitCodes": {
|
|
2152
2278
|
"0": "成功",
|
|
2153
|
-
"1": "
|
|
2279
|
+
"1": "校验失败"
|
|
2154
2280
|
},
|
|
2155
2281
|
"safety": [
|
|
2156
|
-
"
|
|
2282
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2157
2283
|
]
|
|
2158
2284
|
},
|
|
2159
2285
|
{
|
|
2160
2286
|
"path": [
|
|
2161
|
-
"
|
|
2162
|
-
"
|
|
2287
|
+
"style",
|
|
2288
|
+
"sources"
|
|
2163
2289
|
],
|
|
2164
|
-
"usage": "art-workshop
|
|
2165
|
-
"description": "
|
|
2166
|
-
"arguments": [
|
|
2290
|
+
"usage": "art-workshop style sources",
|
|
2291
|
+
"description": "只读列出多个冻结风格来源并报告不可用目录和身份冲突",
|
|
2292
|
+
"arguments": [],
|
|
2293
|
+
"options": [
|
|
2167
2294
|
{
|
|
2168
|
-
"
|
|
2169
|
-
"
|
|
2170
|
-
"description": "art 任务 ID"
|
|
2295
|
+
"flags": "--input <value>",
|
|
2296
|
+
"description": "来源目录列表 JSON 文件"
|
|
2171
2297
|
}
|
|
2172
2298
|
],
|
|
2173
|
-
"options": [],
|
|
2174
2299
|
"output": {
|
|
2175
2300
|
"format": "json",
|
|
2176
|
-
"description": "
|
|
2301
|
+
"description": "只读列出多个冻结风格来源并报告不可用目录和身份冲突"
|
|
2177
2302
|
},
|
|
2178
2303
|
"exitCodes": {
|
|
2179
2304
|
"0": "成功",
|
|
2180
|
-
"1": "
|
|
2305
|
+
"1": "校验失败"
|
|
2181
2306
|
},
|
|
2182
2307
|
"safety": [
|
|
2183
|
-
"
|
|
2184
|
-
"查询原上游任务并下载已有产物",
|
|
2185
|
-
"提交结果未知时拒绝恢复"
|
|
2308
|
+
"冻结风格包只读;不覆盖已有文件;修改请派生草稿;只导出明确引用的参考图片"
|
|
2186
2309
|
]
|
|
2187
2310
|
}
|
|
2188
2311
|
]
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {statSync} from 'node:fs';
|
|
2
|
-
import {spawn,execFileSync} from 'node:child_process';
|
|
3
|
-
|
|
4
|
-
export function deploymentCommandError(executable,error){
|
|
5
|
-
const missing=error.code==='ENOENT';
|
|
6
|
-
const detail=missing
|
|
7
|
-
? `找不到部署命令 ${executable}。${executable==='git'?'请安装 Git for Windows 并加入 PATH,然后完全退出并重新启动 Vant。':'请确认该命令已安装并在 Vant 的 PATH 中可用。'}`
|
|
8
|
-
: `部署命令 ${executable} 无法执行(${error.code??error.status??'未知错误'}),请查看部署日志。`;
|
|
9
|
-
return new Error(detail,{cause:error});
|
|
10
|
-
}
|
|
11
|
-
export function checkDeploymentCommand(executable){
|
|
12
|
-
try{execFileSync(executable,['--version'],{windowsHide:true,timeout:10000,stdio:'pipe'});}
|
|
13
|
-
catch(error){throw deploymentCommandError(executable,error);}
|
|
14
|
-
}
|
|
15
|
-
export function spawnDeploymentCommand(executable,args,cwd){
|
|
16
|
-
try{if(!statSync(cwd).isDirectory())throw new Error('不是目录');}
|
|
17
|
-
catch(error){throw new Error(`部署工作目录不可用:${cwd}。请重新检测安装目录。`,{cause:error});}
|
|
18
|
-
return spawn(executable,args,{cwd,windowsHide:true,stdio:['ignore','inherit','inherit']});
|
|
19
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {existsSync,mkdirSync,renameSync,rmSync} from 'node:fs';
|
|
2
|
-
import {dirname} from 'node:path';
|
|
3
|
-
import {execFileSync} from 'node:child_process';
|
|
4
|
-
import {ownedPath} from './workspace.mjs';
|
|
5
|
-
import {hash} from './shared.mjs';
|
|
6
|
-
import {deploymentCommandError} from './deployment-process.mjs';
|
|
7
|
-
|
|
8
|
-
export async function ensureDeploymentSource(path,source,{control,command,check}){
|
|
9
|
-
check();
|
|
10
|
-
if(existsSync(path)){
|
|
11
|
-
const git=args=>{try{return execFileSync('git',['-C',path,...args],{encoding:'utf8',windowsHide:true,timeout:10000}).trim();}catch(error){throw deploymentCommandError('git',error);}};
|
|
12
|
-
const current=git(['rev-parse','HEAD']),remote=git(['remote','get-url','origin']).replace(/\.git$/,''),dirty=git(['status','--porcelain','--untracked-files=no']);
|
|
13
|
-
if(current!==source.commit||remote!==source.repository||dirty)throw new Error('现有源码不是干净的固定部署版本,保留用户环境;请另选空目录');return;
|
|
14
|
-
}
|
|
15
|
-
mkdirSync(dirname(path),{recursive:true});
|
|
16
|
-
const staging=ownedPath(control,'staging','source-'+hash(source).slice(0,16));
|
|
17
|
-
// spawn requires its working directory to exist even when Git is installed.
|
|
18
|
-
mkdirSync(dirname(staging),{recursive:true});
|
|
19
|
-
if(existsSync(staging))rmSync(staging,{recursive:true,force:true});
|
|
20
|
-
const network=['-c','http.lowSpeedLimit=1024','-c','http.lowSpeedTime=60'];
|
|
21
|
-
await command('git',[...network,'clone','--filter=blob:none','--no-checkout',source.repository,staging],dirname(staging));
|
|
22
|
-
await command('git',[...network,'-C',staging,'checkout','--detach',source.commit],dirname(staging));
|
|
23
|
-
check();if(existsSync(path))throw new Error('源码目标被其他操作创建,禁止覆盖');renameSync(staging,path);
|
|
24
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {environmentRoot,writeMarker} from './environments.mjs';
|
|
2
|
-
import {existsSync,mkdirSync,createReadStream,renameSync,rmSync,readFileSync} from 'node:fs';
|
|
3
|
-
import {join,dirname} from 'node:path';
|
|
4
|
-
import {spawnDeploymentCommand,deploymentCommandError} from './deployment-process.mjs';
|
|
5
|
-
import {ensureDeploymentSource} from './deployment-source.mjs';
|
|
6
|
-
import {createHash} from 'node:crypto';
|
|
7
|
-
import {readJson,writeJson,hash} from './shared.mjs';
|
|
8
|
-
import {loadSettings} from './settings.mjs';
|
|
9
|
-
import {ownedPath} from './workspace.mjs';
|
|
10
|
-
import {locked,sleep,stateRead} from './runtime.mjs';
|
|
11
|
-
import {processIdentity,stopIdentity,ensureService} from './service.mjs';
|
|
12
|
-
import {LOCAL_RECIPE,validateDeploymentPlan} from './deployment.mjs';
|
|
13
|
-
import {loadBackend,BUILTIN_WORKFLOW} from './workflows.mjs';
|
|
14
|
-
import {inspectEnvironment} from './diagnostics.mjs';
|
|
15
|
-
import {generate} from './providers.mjs';
|
|
16
|
-
import {cancelPrompt} from './comfyui.mjs';
|
|
17
|
-
import {finishPlan} from './plan.mjs';
|
|
18
|
-
import {bindBackend} from './backends.mjs';
|
|
19
|
-
import {validateImage} from './images.mjs';
|
|
20
|
-
|
|
21
|
-
const file=process.argv[2],state=readJson(file),plan=state.plan,settings=loadSettings({file:plan.settingsFile});
|
|
22
|
-
const persist=()=>{state.heartbeat=new Date().toISOString();writeJson(file,state);};
|
|
23
|
-
const cancelled=()=>existsSync(file+'.cancel');
|
|
24
|
-
const check=()=>{if(cancelled())throw new Error('部署已取消');};
|
|
25
|
-
const stage=value=>{state.stage=value;persist();check();};
|
|
26
|
-
state.workerPid=process.pid;state.status='running';persist();const heartbeat=setInterval(persist,1000);
|
|
27
|
-
let childIdentity,unsettled=false;
|
|
28
|
-
async function command(executable,args,cwd){
|
|
29
|
-
check();const child=spawnDeploymentCommand(executable,args,cwd);
|
|
30
|
-
const completion=new Promise((resolve,reject)=>{child.once('error',error=>reject(deploymentCommandError(executable,error)));child.once('exit',(code)=>code===0?resolve():reject(new Error('部署命令 '+executable+' 失败,退出码 '+code)));});
|
|
31
|
-
// Attach rejection immediately while awaiting the process identity.
|
|
32
|
-
completion.catch(()=>{});await sleep(100);childIdentity=child.pid?processIdentity(child.pid):null;
|
|
33
|
-
let stopping;
|
|
34
|
-
const timer=setInterval(()=>{if(cancelled()&&childIdentity){clearInterval(timer);stopping=stopIdentity(childIdentity).catch(()=>{unsettled=true;});}},100);
|
|
35
|
-
try{await completion;check();}finally{clearInterval(timer);if(stopping)await stopping;if(childIdentity&&processIdentity(childIdentity.pid)){try{await stopIdentity(childIdentity);}catch{unsettled=true;}}childIdentity=null;}
|
|
36
|
-
}
|
|
37
|
-
async function sha256(path){const digest=createHash('sha256');let bytes=0;for await(const chunk of createReadStream(path)){check();digest.update(chunk);bytes+=chunk.length;state.processedBytes=bytes;}return digest.digest('hex');}
|
|
38
|
-
const repository=(path,source)=>ensureDeploymentSource(path,source,{control:environmentRoot(plan.installRoot),command,check});
|
|
39
|
-
|
|
40
|
-
try{
|
|
41
|
-
validateDeploymentPlan(plan,settings);
|
|
42
|
-
const control=environmentRoot(plan.installRoot),claim=ownedPath(control,'deployment.json');
|
|
43
|
-
await locked(control,'install',async()=>{
|
|
44
|
-
const old=stateRead(claim);if(old&&old.deploymentId!==state.deploymentId&&old.stopConfirmed!==true)throw new Error('该安装目录已有运行或停止未知的部署,禁止重复操作');
|
|
45
|
-
writeJson(claim,{deploymentId:state.deploymentId,workspace:plan.workspace,status:'running',stopConfirmed:false});
|
|
46
|
-
try{
|
|
47
|
-
stage('校验固定源码与节点');await repository(ownedPath(plan.installRoot,'ComfyUI'),LOCAL_RECIPE.comfy);
|
|
48
|
-
await repository(ownedPath(plan.installRoot,'ComfyUI/custom_nodes/ComfyUI-GGUF'),LOCAL_RECIPE.plugin);
|
|
49
|
-
const venvOwner=ownedPath(control,'venv-owned.json'),ownedVenv=stateRead(venvOwner);
|
|
50
|
-
const installPython=!plan.portable&&(!existsSync(plan.python)||ownedVenv?.recipeHash===hash(LOCAL_RECIPE));
|
|
51
|
-
if(installPython){
|
|
52
|
-
if(!existsSync(plan.python)){writeJson(venvOwner,{recipeHash:hash(LOCAL_RECIPE),python:plan.python});stage('创建独立 Python 环境');await command(plan.basePython,['-m','venv',ownedPath(plan.installRoot,'.venv')],plan.installRoot);}
|
|
53
|
-
stage('安装 CUDA 运行依赖');await command(plan.python,['-m','pip','install','torch=='+LOCAL_RECIPE.torch,'torchvision=='+LOCAL_RECIPE.torchvision,'--index-url',LOCAL_RECIPE.torchIndex],plan.installRoot);
|
|
54
|
-
await command(plan.python,['-m','pip','install','-r',ownedPath(plan.installRoot,'ComfyUI/requirements.txt'),'gguf=='+LOCAL_RECIPE.gguf,'sentencepiece','protobuf'],plan.installRoot);
|
|
55
|
-
}
|
|
56
|
-
stage('核验 Python 与 CUDA');await command(plan.python,['-c',`import torch,gguf; import importlib.metadata as m; assert torch.cuda.is_available(), 'NVIDIA CUDA unavailable'; assert torch.__version__.split('+')[0]=='${LOCAL_RECIPE.torch}', 'Torch version differs'; assert m.version('gguf')=='${LOCAL_RECIPE.gguf}', 'GGUF version differs'`],plan.installRoot);
|
|
57
|
-
for(const model of LOCAL_RECIPE.models){
|
|
58
|
-
const destination=ownedPath(plan.installRoot,'ComfyUI/models',model.path);stage('校验模型 '+model.path);state.processedBytes=0;
|
|
59
|
-
if(existsSync(destination)){if(await sha256(destination)!==model.sha256)throw new Error('现有模型哈希不匹配,保留原文件:'+model.path);continue;}
|
|
60
|
-
stage('下载模型 '+model.path);mkdirSync(dirname(destination),{recursive:true});const temporary=ownedPath(control,hash(model.path)+'.part');
|
|
61
|
-
try{await command('curl.exe',['--fail','--location','--retry','2','--connect-timeout','20','--max-time','7200','--output',temporary,model.url],plan.installRoot);if(await sha256(temporary)!==model.sha256)throw new Error('下载模型哈希校验失败');check();if(existsSync(destination))throw new Error('模型目标被其他操作创建,禁止覆盖');renameSync(temporary,destination);}finally{rmSync(temporary,{force:true});}
|
|
62
|
-
}
|
|
63
|
-
const configured={...settings,generation:{defaultBackend:'local-qwen',defaults:{},backends:{'local-qwen':{provider:'comfyui',model:LOCAL_RECIPE.models[0].path.split('/').at(-1),endpoints:[plan.endpoint],launch:{executable:plan.python,cwd:plan.installRoot,args:['-s','ComfyUI/main.py','--disable-dynamic-vram','--lowvram','--disable-auto-launch',...(new URL(plan.endpoint).port?['--port',new URL(plan.endpoint).port]:[])]}}}}};
|
|
64
|
-
stage('检测固定工作流与环境');const backend=loadBackend(configured,'local-qwen'),endpoint=await ensureService(backend,join(control,'runtime'),{cancelled});
|
|
65
|
-
const report=await inspectEnvironment(endpoint,backend);if(!report.ok)throw new Error('部署环境检查未通过');state.environment=report;
|
|
66
|
-
// Readiness is proved by generation and editing, rather than a listening port.
|
|
67
|
-
const {queue_running=[],queue_pending=[]}=await(await fetch(new URL('/queue',endpoint))).json();if(queue_running.length||queue_pending.length)throw new Error('现有服务正在执行其他任务,本次不插入验收采样;任务结束后重试部署验证');
|
|
68
|
-
const output=ownedPath(control,'verification',state.deploymentId);mkdirSync(output,{recursive:true});
|
|
69
|
-
let source;
|
|
70
|
-
for(const mode of ['generate','edit']){
|
|
71
|
-
stage(mode==='generate'?'单图生成验证':'底图编辑验证');
|
|
72
|
-
const base=finishPlan({module:mode,project:'deployment',job:'verification',execution:{model:LOCAL_RECIPE.models[0].path.split('/').at(-1),size:'512*512',perValue:1,promptExtend:false,watermark:false},sources:{recipe:LOCAL_RECIPE.id},snapshots:{},refs:[],items:[{itemId:'verification',variantId:'base',seed:7619,prompt:mode==='generate'?'一个圆润的青绿色科幻能量球,简洁轮廓,柔和高光,纯白背景。':'保持原图轮廓和构图,将主体颜色改成金黄色。',negativeBlock:'文字,水印',imageArgs:mode==='edit'?[source]:[],checks:{content:[],style:[],asset:[]}}]});
|
|
73
|
-
const modeOutput=ownedPath(output,mode);mkdirSync(modeOutput,{recursive:true});
|
|
74
|
-
const bound=bindBackend(base,configured,'local-qwen'),result=await generate(bound,bound.items[0],{endpoint,root:join(control,'runtime'),outputDir:modeOutput,prefix:mode,cancelled,onPrompt:promptId=>{state.promptId=promptId;persist();}});
|
|
75
|
-
state.promptId=null;const path=ownedPath(modeOutput,result.files[0]),info=await validateImage(readFileSync(path));if(info.width!==512||info.height!==512)throw new Error('部署验证图片尺寸不符');source=path;state.verification??=[];state.verification.push({mode,path,hash:await sha256(path),planHash:bound.planHash});persist();
|
|
76
|
-
}
|
|
77
|
-
stage('保存已验证部署配置');for(const evidence of state.verification)if(await sha256(evidence.path)!==evidence.hash)throw new Error('部署采样证据发生变化,不保存完成状态');const raw=readJson(settings.file);raw.generation={...raw.generation,defaultBackend:'local-qwen',backends:{...raw.generation?.backends,'local-qwen':configured.generation.backends['local-qwen']}};writeJson(settings.file,raw);
|
|
78
|
-
writeMarker(plan.installRoot,{python:plan.portable?'python_embeded/python.exe':'.venv/Scripts/python.exe',endpoint:plan.endpoint,recipe:LOCAL_RECIPE.id,verification:'generate-and-edit'});state.status='succeeded';state.stopConfirmed=true;state.workflow=BUILTIN_WORKFLOW;
|
|
79
|
-
}catch(error){
|
|
80
|
-
if(error.unsettled&&!state.promptId)unsettled=true;
|
|
81
|
-
if(state.promptId){try{await cancelPrompt(plan.endpoint,state.promptId);state.promptId=null;}catch{unsettled=true;}}
|
|
82
|
-
state.status=unsettled?'unknown':cancelled()?'cancelled':'failed';state.stopConfirmed=!unsettled;state.error=error.message;
|
|
83
|
-
}finally{writeJson(claim,{deploymentId:state.deploymentId,workspace:plan.workspace,status:state.status,stopConfirmed:state.stopConfirmed});}
|
|
84
|
-
});
|
|
85
|
-
}catch(error){if(error.unsettled)unsettled=true;state.status=unsettled?'unknown':cancelled()?'cancelled':'failed';state.stopConfirmed=!unsettled;state.error=error.message;}
|
|
86
|
-
finally{clearInterval(heartbeat);state.finishedAt=new Date().toISOString();persist();}
|