openprototype 1.0.1 → 1.1.0
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 -4
- package/README.zh-CN.md +6 -4
- package/bin/cli.js +153 -6
- package/lib/config.js +6 -0
- package/lib/service-manager.js +452 -0
- package/package.json +3 -1
- package/product/demo/pc/customer//350/256/242/345/215/225/order_list.html +25 -0
- package/product/demo/pc/customer//350/256/242/345/215/225/order_list.md +18 -0
- package/product/demo/pc/index.html +267 -22
- package/product/demo/pc/nav-tree.json +11 -2
- package/proto-kit.config.json +3 -0
- package/runtime/server.js +177 -15
- package/runtime/service-runner.js +138 -0
- package/runtime/shared/common/prd-panel.js +55 -5
- package/runtime/shell/agent-panel.css +65 -0
- package/runtime/shell/agent-panel.js +62 -20
- package/scripts/check/service-smoke-test.js +172 -0
- package/scripts/check/sync-nav-tree.js +30 -1
- package/scripts/postinstall.js +52 -0
- package/templates/product-shell/index.html +267 -22
|
@@ -200,7 +200,10 @@
|
|
|
200
200
|
const dot = document.createElement('span');
|
|
201
201
|
dot.className = 'agent-tool-status';
|
|
202
202
|
tool.appendChild(dot);
|
|
203
|
-
|
|
203
|
+
const fallbackTitle = part.tool === 'question'
|
|
204
|
+
? (status === 'completed' ? '已收到回答' : status === 'error' ? '提问失败' : '等待你的回答')
|
|
205
|
+
: (part.tool || '执行工具');
|
|
206
|
+
appendText(tool, '', (part.state && part.state.title) || fallbackTitle);
|
|
204
207
|
wrapper.appendChild(tool);
|
|
205
208
|
});
|
|
206
209
|
return wrapper;
|
|
@@ -229,26 +232,56 @@
|
|
|
229
232
|
function renderQuestion(item) {
|
|
230
233
|
const card = document.createElement('div');
|
|
231
234
|
card.className = 'agent-request-card';
|
|
232
|
-
appendText(card, 'agent-request-title', 'OpenCode
|
|
235
|
+
appendText(card, 'agent-request-title', 'OpenCode 正在等待你的回答');
|
|
233
236
|
const questions = Array.isArray(item.questions) ? item.questions : [];
|
|
234
237
|
questions.forEach((question, index) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
238
|
+
const block = document.createElement('div');
|
|
239
|
+
block.className = 'agent-question';
|
|
240
|
+
block.dataset.questionIndex = String(index);
|
|
241
|
+
if (question.header) appendText(block, 'agent-question-header', question.header);
|
|
242
|
+
appendText(block, 'agent-request-desc', question.question || question.header || `问题 ${index + 1}`);
|
|
243
|
+
|
|
244
|
+
const options = Array.isArray(question.options) ? question.options : [];
|
|
245
|
+
if (options.length) {
|
|
246
|
+
const optionList = document.createElement('div');
|
|
247
|
+
optionList.className = 'agent-question-options';
|
|
248
|
+
options.forEach(option => {
|
|
249
|
+
const label = document.createElement('label');
|
|
250
|
+
label.className = 'agent-question-option';
|
|
251
|
+
const input = document.createElement('input');
|
|
252
|
+
input.type = question.multiple ? 'checkbox' : 'radio';
|
|
253
|
+
input.name = `agent-question-${item.id}-${index}`;
|
|
254
|
+
input.value = option.label || option.value || String(option);
|
|
255
|
+
input.className = 'agent-question-choice';
|
|
256
|
+
label.appendChild(input);
|
|
257
|
+
const content = document.createElement('span');
|
|
258
|
+
appendText(content, 'agent-question-option-label', input.value);
|
|
259
|
+
if (option.description) appendText(content, 'agent-question-option-desc', option.description);
|
|
260
|
+
label.appendChild(content);
|
|
261
|
+
optionList.appendChild(label);
|
|
245
262
|
});
|
|
246
|
-
|
|
247
|
-
field.type = 'text';
|
|
248
|
-
field.placeholder = '输入回答';
|
|
263
|
+
block.appendChild(optionList);
|
|
249
264
|
}
|
|
250
|
-
|
|
265
|
+
|
|
266
|
+
if (question.custom !== false) {
|
|
267
|
+
const custom = document.createElement('input');
|
|
268
|
+
custom.type = 'text';
|
|
269
|
+
custom.className = 'agent-question-field';
|
|
270
|
+
custom.placeholder = options.length ? '其他,请输入' : '输入回答';
|
|
271
|
+
if (!question.multiple) {
|
|
272
|
+
custom.addEventListener('input', () => {
|
|
273
|
+
if (!custom.value.trim()) return;
|
|
274
|
+
block.querySelectorAll('.agent-question-choice').forEach(choice => { choice.checked = false; });
|
|
275
|
+
});
|
|
276
|
+
block.querySelectorAll('.agent-question-choice').forEach(choice => {
|
|
277
|
+
choice.addEventListener('change', () => { if (choice.checked) custom.value = ''; });
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
block.appendChild(custom);
|
|
281
|
+
}
|
|
282
|
+
card.appendChild(block);
|
|
251
283
|
});
|
|
284
|
+
const error = appendText(card, 'agent-question-error', '');
|
|
252
285
|
const actions = document.createElement('div');
|
|
253
286
|
actions.className = 'agent-request-actions';
|
|
254
287
|
const submit = document.createElement('button');
|
|
@@ -256,7 +289,16 @@
|
|
|
256
289
|
submit.className = 'agent-request-btn is-primary';
|
|
257
290
|
submit.textContent = '提交回答';
|
|
258
291
|
submit.addEventListener('click', () => {
|
|
259
|
-
const answers = Array.from(card.querySelectorAll('.agent-question
|
|
292
|
+
const answers = Array.from(card.querySelectorAll('.agent-question')).map(block => {
|
|
293
|
+
const selected = Array.from(block.querySelectorAll('.agent-question-choice:checked')).map(choice => choice.value);
|
|
294
|
+
const custom = block.querySelector('.agent-question-field');
|
|
295
|
+
if (custom && custom.value.trim()) selected.push(custom.value.trim());
|
|
296
|
+
return selected;
|
|
297
|
+
});
|
|
298
|
+
if (answers.some(answer => !answer.length)) {
|
|
299
|
+
error.textContent = '请回答全部问题后再提交';
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
260
302
|
replyQuestion(item.id, answers);
|
|
261
303
|
});
|
|
262
304
|
actions.appendChild(submit);
|
|
@@ -280,9 +322,6 @@
|
|
|
280
322
|
|
|
281
323
|
function renderMessages() {
|
|
282
324
|
refs.messages.replaceChildren();
|
|
283
|
-
state.pending.permissions.forEach(item => refs.messages.appendChild(renderPermission(item)));
|
|
284
|
-
state.pending.questions.forEach(item => refs.messages.appendChild(renderQuestion(item)));
|
|
285
|
-
|
|
286
325
|
const diffCard = renderDiff();
|
|
287
326
|
if (diffCard) refs.messages.appendChild(diffCard);
|
|
288
327
|
|
|
@@ -299,6 +338,9 @@
|
|
|
299
338
|
if (message) refs.messages.appendChild(message);
|
|
300
339
|
}
|
|
301
340
|
|
|
341
|
+
state.pending.permissions.forEach(item => refs.messages.appendChild(renderPermission(item)));
|
|
342
|
+
state.pending.questions.forEach(item => refs.messages.appendChild(renderQuestion(item)));
|
|
343
|
+
|
|
302
344
|
if (!refs.messages.children.length) {
|
|
303
345
|
const empty = document.createElement('div');
|
|
304
346
|
empty.className = 'agent-empty';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const net = require('net');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { spawnSync } = require('child_process');
|
|
9
|
+
|
|
10
|
+
const PKG_ROOT = path.resolve(__dirname, '..', '..');
|
|
11
|
+
const NPM_CLI = process.platform === 'win32'
|
|
12
|
+
? (process.env.npm_execpath || path.join(path.dirname(process.execPath), 'node_modules', 'npm', 'bin', 'npm-cli.js'))
|
|
13
|
+
: null;
|
|
14
|
+
|
|
15
|
+
function run(command, args, cwd, options) {
|
|
16
|
+
const result = spawnSync(command, args, {
|
|
17
|
+
cwd,
|
|
18
|
+
encoding: 'utf8',
|
|
19
|
+
windowsHide: true,
|
|
20
|
+
env: Object.assign({}, process.env, options && options.env),
|
|
21
|
+
timeout: options && options.timeout ? options.timeout : 120000
|
|
22
|
+
});
|
|
23
|
+
if ((result.error || result.status !== 0) && !(options && options.allowFailure)) {
|
|
24
|
+
const spawnError = result.error ? `\n${result.error.stack || result.error.message}` : '';
|
|
25
|
+
throw new Error(`${command} ${args.join(' ')} 失败\n${result.stdout || ''}\n${result.stderr || ''}${spawnError}`);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function npm(args, cwd, options) {
|
|
31
|
+
return process.platform === 'win32'
|
|
32
|
+
? run(process.execPath, [NPM_CLI, ...args], cwd, options)
|
|
33
|
+
: run('npm', args, cwd, options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function freePort() {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const server = net.createServer();
|
|
39
|
+
server.once('error', reject);
|
|
40
|
+
server.listen(0, '127.0.0.1', () => {
|
|
41
|
+
const port = server.address().port;
|
|
42
|
+
server.close((err) => err ? reject(err) : resolve(port));
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function cliPath(projectRoot) {
|
|
48
|
+
return path.join(projectRoot, 'node_modules', 'openprototype', 'bin', 'cli.js');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function cli(projectRoot, args, options) {
|
|
52
|
+
return run(process.execPath, [cliPath(projectRoot), ...args], projectRoot, options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function status(projectRoot) {
|
|
56
|
+
const result = cli(projectRoot, ['service', 'status', '--json']);
|
|
57
|
+
return JSON.parse(result.stdout);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function waitFor(projectRoot, predicate, timeoutMs) {
|
|
61
|
+
const deadline = Date.now() + timeoutMs;
|
|
62
|
+
let current;
|
|
63
|
+
while (Date.now() < deadline) {
|
|
64
|
+
try {
|
|
65
|
+
current = status(projectRoot);
|
|
66
|
+
if (predicate(current)) return current;
|
|
67
|
+
} catch {}
|
|
68
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`等待服务状态超时:${JSON.stringify(current)}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function main() {
|
|
74
|
+
if (!['darwin', 'win32'].includes(process.platform)) {
|
|
75
|
+
console.log('当前平台不支持常驻服务,跳过。');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'openprototype 服务测试 '));
|
|
80
|
+
const packDir = path.join(tempRoot, 'pack');
|
|
81
|
+
const projectRoot = path.join(tempRoot, '中文 project');
|
|
82
|
+
process.env.NPM_CONFIG_CACHE = process.env.NPM_CONFIG_CACHE || path.join(tempRoot, 'npm-cache');
|
|
83
|
+
fs.mkdirSync(packDir, { recursive: true });
|
|
84
|
+
fs.mkdirSync(projectRoot, { recursive: true });
|
|
85
|
+
|
|
86
|
+
let installed = false;
|
|
87
|
+
try {
|
|
88
|
+
const packed = npm(['pack', '--json', '--pack-destination', packDir], PKG_ROOT);
|
|
89
|
+
const packResult = JSON.parse(packed.stdout);
|
|
90
|
+
const packItem = Array.isArray(packResult) ? packResult[0] : (packResult.openprototype || Object.values(packResult)[0]);
|
|
91
|
+
if (!packItem || !packItem.filename) throw new Error(`无法解析 npm pack 输出:${packed.stdout}`);
|
|
92
|
+
const tarball = path.join(packDir, packItem.filename);
|
|
93
|
+
const dependencySpec = `file:${tarball.split(path.sep).join('/')}`;
|
|
94
|
+
const port = await freePort();
|
|
95
|
+
|
|
96
|
+
fs.writeFileSync(path.join(projectRoot, 'package.json'), JSON.stringify({
|
|
97
|
+
name: 'openprototype-service-smoke',
|
|
98
|
+
private: true,
|
|
99
|
+
version: '1.0.0',
|
|
100
|
+
// npm 12 对本地 tarball 按来源路径授权;正式 registry 安装使用包名授权。
|
|
101
|
+
allowScripts: { [dependencySpec]: true },
|
|
102
|
+
dependencies: { openprototype: dependencySpec }
|
|
103
|
+
}, null, 2) + '\n');
|
|
104
|
+
fs.writeFileSync(path.join(projectRoot, 'proto-kit.config.json'), JSON.stringify({
|
|
105
|
+
port,
|
|
106
|
+
host: '127.0.0.1',
|
|
107
|
+
service: { autoInstall: true },
|
|
108
|
+
products: []
|
|
109
|
+
}, null, 2) + '\n');
|
|
110
|
+
|
|
111
|
+
const installResult = npm(['install', '--foreground-scripts'], projectRoot, {
|
|
112
|
+
env: { OPENPROTOTYPE_SERVICE_AUTO_INSTALL: 'force' }
|
|
113
|
+
});
|
|
114
|
+
process.stdout.write(installResult.stdout || '');
|
|
115
|
+
process.stderr.write(installResult.stderr || '');
|
|
116
|
+
installed = true;
|
|
117
|
+
|
|
118
|
+
const initial = await waitFor(projectRoot, (item) => item.running, 20000);
|
|
119
|
+
if (!initial.registered || initial.port !== port || !initial.pid) throw new Error('自动安装后的服务状态不完整');
|
|
120
|
+
|
|
121
|
+
process.kill(initial.pid, 'SIGKILL');
|
|
122
|
+
const restarted = await waitFor(projectRoot, (item) => item.running && item.pid !== initial.pid, process.platform === 'win32' ? 90000 : 30000);
|
|
123
|
+
if (restarted.version !== require(path.join(PKG_ROOT, 'package.json')).version) throw new Error('服务版本不正确');
|
|
124
|
+
|
|
125
|
+
cli(projectRoot, ['service', 'stop', '--json']);
|
|
126
|
+
await waitFor(projectRoot, (item) => !item.running, 15000);
|
|
127
|
+
cli(projectRoot, ['service', 'start', '--json']);
|
|
128
|
+
await waitFor(projectRoot, (item) => item.running, 20000);
|
|
129
|
+
cli(projectRoot, ['service', 'restart', '--json']);
|
|
130
|
+
await waitFor(projectRoot, (item) => item.running, 20000);
|
|
131
|
+
|
|
132
|
+
const logResult = cli(projectRoot, ['service', 'logs', '--json']);
|
|
133
|
+
const log = JSON.parse(logResult.stdout);
|
|
134
|
+
if (!log.path || !log.content.includes('openprototype')) throw new Error('服务日志不可用');
|
|
135
|
+
|
|
136
|
+
cli(projectRoot, ['service', 'uninstall', '--json']);
|
|
137
|
+
installed = false;
|
|
138
|
+
const removed = await waitFor(projectRoot, (item) => !item.registered && !item.running, 15000);
|
|
139
|
+
if (removed.state !== 'unregistered') throw new Error('服务未完全卸载');
|
|
140
|
+
|
|
141
|
+
const configPath = path.join(projectRoot, 'proto-kit.config.json');
|
|
142
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
143
|
+
config.host = '0.0.0.0';
|
|
144
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
145
|
+
const lanResult = cli(projectRoot, ['service', 'install'], { allowFailure: true });
|
|
146
|
+
if (lanResult.status === 0 || !`${lanResult.stdout}\n${lanResult.stderr}`.includes('--allow-lan')) {
|
|
147
|
+
throw new Error('非回环 host 未被安全拦截');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
config.host = '127.0.0.1';
|
|
151
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
152
|
+
const blocker = net.createServer();
|
|
153
|
+
await new Promise((resolve, reject) => blocker.once('error', reject).listen(port, '127.0.0.1', resolve));
|
|
154
|
+
const conflictResult = cli(projectRoot, ['service', 'install'], { allowFailure: true });
|
|
155
|
+
await new Promise((resolve) => blocker.close(resolve));
|
|
156
|
+
if (conflictResult.status === 0 || !`${conflictResult.stdout}\n${conflictResult.stderr}`.includes('端口')) {
|
|
157
|
+
throw new Error('端口冲突未被安装前检查拦截');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
console.log(`service smoke passed: ${process.platform}, port=${port}`);
|
|
161
|
+
} finally {
|
|
162
|
+
if (fs.existsSync(cliPath(projectRoot))) {
|
|
163
|
+
cli(projectRoot, ['service', 'uninstall', '--json'], { allowFailure: true });
|
|
164
|
+
}
|
|
165
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
main().catch((err) => {
|
|
170
|
+
console.error(err.stack || err.message);
|
|
171
|
+
process.exit(1);
|
|
172
|
+
});
|
|
@@ -75,6 +75,35 @@ function sortTree(nodes) {
|
|
|
75
75
|
return nodes;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
function nodeKey(node) {
|
|
79
|
+
return node.file ? `file:${node.file}` : `folder:${node.name}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** 保留 nav-tree.json 中的人工顺序,仅把磁盘新增节点按默认顺序追加到同级末尾。 */
|
|
83
|
+
function preserveTreeOrder(nodes, previousNodes) {
|
|
84
|
+
const currentByKey = new Map(nodes.map((node) => [nodeKey(node), node]));
|
|
85
|
+
const previousByKey = new Map((previousNodes || []).map((node) => [nodeKey(node), node]));
|
|
86
|
+
const ordered = [];
|
|
87
|
+
|
|
88
|
+
(previousNodes || []).forEach((previousNode) => {
|
|
89
|
+
const node = currentByKey.get(nodeKey(previousNode));
|
|
90
|
+
if (!node) return;
|
|
91
|
+
if (node.file && previousNode.title) node.title = previousNode.title;
|
|
92
|
+
ordered.push(node);
|
|
93
|
+
currentByKey.delete(nodeKey(previousNode));
|
|
94
|
+
});
|
|
95
|
+
nodes.forEach((node) => {
|
|
96
|
+
if (currentByKey.has(nodeKey(node))) ordered.push(node);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
ordered.forEach((node) => {
|
|
100
|
+
if (!node.children) return;
|
|
101
|
+
const previousNode = previousByKey.get(nodeKey(node));
|
|
102
|
+
node.children = preserveTreeOrder(node.children, previousNode && previousNode.children);
|
|
103
|
+
});
|
|
104
|
+
return ordered;
|
|
105
|
+
}
|
|
106
|
+
|
|
78
107
|
function buildTree(paths, dirs) {
|
|
79
108
|
const tree = [];
|
|
80
109
|
// 先登记磁盘上的所有目录(含空目录,保住导航页刚创建、还没放页面的文件夹)
|
|
@@ -95,7 +124,7 @@ function syncTarget(target) {
|
|
|
95
124
|
const previous = collectRegisteredPaths(previousTree, new Set());
|
|
96
125
|
const { files: diskPaths, dirs } = listDiskPaths(target.dir);
|
|
97
126
|
const onDisk = new Set(diskPaths);
|
|
98
|
-
const tree = buildTree(diskPaths, dirs);
|
|
127
|
+
const tree = preserveTreeOrder(buildTree(diskPaths, dirs), previousTree);
|
|
99
128
|
const next = collectRegisteredPaths(tree, new Set());
|
|
100
129
|
const added = [...next].filter((p) => !previous.has(p));
|
|
101
130
|
const removed = [...previous].filter((p) => !onDisk.has(p));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { findProjectRoot, loadConfig } = require('../lib/config');
|
|
7
|
+
const { installService, isSupportedPlatform, isLoopbackHost } = require('../lib/service-manager');
|
|
8
|
+
|
|
9
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
function isTruthy(value) {
|
|
12
|
+
return !!value && !['0', 'false', 'no', 'off'].includes(String(value).toLowerCase());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isConsumerInstall(projectRoot) {
|
|
16
|
+
try {
|
|
17
|
+
const installedPackage = path.dirname(require.resolve('openprototype/package.json', { paths: [projectRoot] }));
|
|
18
|
+
return fs.realpathSync(installedPackage) === fs.realpathSync(PKG_ROOT) && fs.realpathSync(projectRoot) !== fs.realpathSync(PKG_ROOT);
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
(async () => {
|
|
25
|
+
const policy = String(process.env.OPENPROTOTYPE_SERVICE_AUTO_INSTALL || '').toLowerCase();
|
|
26
|
+
if (policy === '0' || policy === 'false' || policy === 'off') return;
|
|
27
|
+
if (!isSupportedPlatform()) return;
|
|
28
|
+
if (isTruthy(process.env.CI) && policy !== 'force') return;
|
|
29
|
+
|
|
30
|
+
const startDir = process.env.INIT_CWD || process.cwd();
|
|
31
|
+
const projectRoot = findProjectRoot(startDir);
|
|
32
|
+
const config = loadConfig(projectRoot);
|
|
33
|
+
if (!config.hasConfigFile || !isConsumerInstall(projectRoot)) return;
|
|
34
|
+
if (config.service && config.service.autoInstall === false) return;
|
|
35
|
+
if (!isLoopbackHost(config.host)) {
|
|
36
|
+
console.warn(`[openprototype] 已跳过常驻服务:host=${config.host} 不是本机回环地址。`);
|
|
37
|
+
console.warn('[openprototype] 如确认需要长期开放局域网访问,请运行:npx openprototype service install --allow-lan');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const result = await installService({ projectRoot, explicit: false });
|
|
43
|
+
if (!result.skipped) console.log(`[openprototype] 常驻服务已启动:http://127.0.0.1:${config.port}`);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.warn(`[openprototype] 常驻服务自动安装失败:${err.message}`);
|
|
46
|
+
console.warn('[openprototype] npm 安装不受影响;可稍后运行:npx openprototype service install');
|
|
47
|
+
}
|
|
48
|
+
})().catch((err) => {
|
|
49
|
+
console.warn(`[openprototype] 常驻服务自动安装失败:${err.message}`);
|
|
50
|
+
process.exitCode = 0;
|
|
51
|
+
});
|
|
52
|
+
|