@microi.net/cli 4.6.2
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/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/mcp-codex-stdio-adapter.js +189 -0
- package/dist/mcp-server.js +972 -0
- package/dist/mcp-trae-windows-launcher.cmd +21 -0
- package/dist/microi-cli-mcp.js +7 -0
- package/dist/microi-cli.js +1645 -0
- package/dist/microi-skills.meta.json +335 -0
- package/dist/microi.skills/.microi-skills-version.json +6 -0
- package/dist/microi.skills/README.md +276 -0
- package/dist/microi.skills/ai-engine/SKILL.md +140 -0
- package/dist/microi.skills/ai-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/app-store/SKILL.md +105 -0
- package/dist/microi.skills/app-store/agents/openai.yaml +4 -0
- package/dist/microi.skills/business-blueprint/SKILL.md +184 -0
- package/dist/microi.skills/datasource-engine/SKILL.md +89 -0
- package/dist/microi.skills/datasource-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/dos-orm/SKILL.md +76 -0
- package/dist/microi.skills/dos-orm/references/api-reference.md +229 -0
- package/dist/microi.skills/job-engine/SKILL.md +141 -0
- package/dist/microi.skills/job-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/message-notification/SKILL.md +113 -0
- package/dist/microi.skills/message-notification/agents/openai.yaml +6 -0
- package/dist/microi.skills/message-notification/references/contracts.md +99 -0
- package/dist/microi.skills/microi-ai-app-auth.js +651 -0
- package/dist/microi.skills/microi-ai-application/SKILL.md +80 -0
- package/dist/microi.skills/microi-ai-application/agents/openai.yaml +4 -0
- package/dist/microi.skills/microi-ai-application/references/frontend-baseline.md +164 -0
- package/dist/microi.skills/microi-client-frontend/SKILL.md +562 -0
- package/dist/microi.skills/microi-datasource-mapping/SKILL.md +108 -0
- package/dist/microi.skills/microi-db-schema/SKILL.md +170 -0
- package/dist/microi.skills/microi-db-schema/agents/openai.yaml +4 -0
- package/dist/microi.skills/microi-db-schema/references/core-tables.md +695 -0
- package/dist/microi.skills/microi-db-schema/references/form-component-options.md +256 -0
- package/dist/microi.skills/microi-db-schema/references/schema-overview.md +203 -0
- package/dist/microi.skills/microi-db-schema/references/schema.md +647 -0
- package/dist/microi.skills/microi-db-schema/references/table-catalog.md +1607 -0
- package/dist/microi.skills/microi-deployment/SKILL.md +117 -0
- package/dist/microi.skills/microi-deployment/references/deployment-matrix.md +94 -0
- package/dist/microi.skills/microi-docs-coverage/SKILL.md +91 -0
- package/dist/microi.skills/microi-docs-coverage/references/capability-map.md +65 -0
- package/dist/microi.skills/microi-docs-coverage/scripts/audit-doc-skill-coverage.mjs +887 -0
- package/dist/microi.skills/microi-form-engine/SKILL.md +159 -0
- package/dist/microi.skills/microi-form-engine/references/component-catalog.md +116 -0
- package/dist/microi.skills/microi-form-engine/references/data-source-events.md +117 -0
- package/dist/microi.skills/microi-form-layout/SKILL.md +373 -0
- package/dist/microi.skills/microi-frontend-sdk/SKILL.md +304 -0
- package/dist/microi.skills/microi-left-right-layout/SKILL.md +132 -0
- package/dist/microi.skills/microi-microservice/SKILL.md +115 -0
- package/dist/microi.skills/microi-microservice/references/runtime-delivery.md +145 -0
- package/dist/microi.skills/microi-mobile-app-quality/SKILL.md +436 -0
- package/dist/microi.skills/microi-solution-quotation/SKILL.md +76 -0
- package/dist/microi.skills/microi-solution-quotation/agents/openai.yaml +4 -0
- package/dist/microi.skills/microi-solution-quotation/scripts/build_solution_quote.py +296 -0
- package/dist/microi.skills/microi-system-delivery/SKILL.md +446 -0
- package/dist/microi.skills/microi-ui/SKILL.md +321 -0
- package/dist/microi.skills/microi-uniapp-frontend/SKILL.md +483 -0
- package/dist/microi.skills/microi.v8.js +1758 -0
- package/dist/microi.skills/module-engine/SKILL.md +131 -0
- package/dist/microi.skills/module-engine/references/module-config.md +174 -0
- package/dist/microi.skills/page-engine/SKILL.md +397 -0
- package/dist/microi.skills/performance-testing/SKILL.md +207 -0
- package/dist/microi.skills/playwright-e2e/SKILL.md +769 -0
- package/dist/microi.skills/print-engine/SKILL.md +237 -0
- package/dist/microi.skills/production-readonly-audit/SKILL.md +39 -0
- package/dist/microi.skills/report-engine/SKILL.md +69 -0
- package/dist/microi.skills/report-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/search-engine/SKILL.md +73 -0
- package/dist/microi.skills/search-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/spider-engine/SKILL.md +188 -0
- package/dist/microi.skills/translate-engine/SKILL.md +91 -0
- package/dist/microi.skills/translate-engine/agents/openai.yaml +4 -0
- package/dist/microi.skills/ui-design/SKILL.md +1575 -0
- package/dist/microi.skills/ui-design/assets/pattern-showcase/app.js +54 -0
- package/dist/microi.skills/ui-design/assets/pattern-showcase/index.html +163 -0
- package/dist/microi.skills/ui-design/assets/pattern-showcase/styles.css +311 -0
- package/dist/microi.skills/ui-design/assets/templates/MCI-DESIGN.md +98 -0
- package/dist/microi.skills/ui-design/references/design-pattern-library.md +171 -0
- package/dist/microi.skills/ui-design/references/mci-design-contract.md +84 -0
- package/dist/microi.skills/ui-design/references/motion-and-media.md +71 -0
- package/dist/microi.skills/ui-design/references/product-flow-recipes.md +94 -0
- package/dist/microi.skills/uniapp-mall-assets/SKILL.md +105 -0
- package/dist/microi.skills/v8-api-config/SKILL.md +272 -0
- package/dist/microi.skills/v8-cache-pattern/SKILL.md +286 -0
- package/dist/microi.skills/v8-crud-api/SKILL.md +398 -0
- package/dist/microi.skills/v8-debugging/SKILL.md +279 -0
- package/dist/microi.skills/v8-explorer-tree/SKILL.md +224 -0
- package/dist/microi.skills/v8-export-import/SKILL.md +590 -0
- package/dist/microi.skills/v8-file-upload/SKILL.md +497 -0
- package/dist/microi.skills/v8-formengine-http/SKILL.md +218 -0
- package/dist/microi.skills/v8-frontend-events/SKILL.md +349 -0
- package/dist/microi.skills/v8-frontend-events/references/bluetooth-print-api.md +107 -0
- package/dist/microi.skills/v8-frontend-events/references/bluetooth-print.md +185 -0
- package/dist/microi.skills/v8-http-integration/SKILL.md +379 -0
- package/dist/microi.skills/v8-image-processing/SKILL.md +187 -0
- package/dist/microi.skills/v8-image-processing/agents/openai.yaml +4 -0
- package/dist/microi.skills/v8-image-processing/references/api-reference.md +620 -0
- package/dist/microi.skills/v8-menu-buttons/SKILL.md +661 -0
- package/dist/microi.skills/v8-mongodb/SKILL.md +149 -0
- package/dist/microi.skills/v8-mq-mqtt/SKILL.md +227 -0
- package/dist/microi.skills/v8-saas-multi-tenant/SKILL.md +193 -0
- package/dist/microi.skills/v8-security/SKILL.md +417 -0
- package/dist/microi.skills/v8-sql-query/SKILL.md +290 -0
- package/dist/microi.skills/v8-table-event/SKILL.md +385 -0
- package/dist/microi.skills/v8-template-engine/SKILL.md +165 -0
- package/dist/microi.skills/v8-utilities/SKILL.md +79 -0
- package/dist/microi.skills/v8-utilities/references/client-api-index.md +136 -0
- package/dist/microi.skills/v8-utilities/references/platform-http-routes.md +80 -0
- package/dist/microi.skills/v8-utilities/references/server-api-index.md +129 -0
- package/dist/microi.skills/v8-workflow/SKILL.md +322 -0
- package/dist/microi.skills/workspace-conventions/SKILL.md +479 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Microi吾码
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Microi吾码 CLI(microi.net/cli)
|
|
2
|
+
|
|
3
|
+
`microi.net/cli` 是产品展示名,npm 中合法的安装包名是 `@microi.net/cli`。它面向偏好 Codex CLI、Claude Code、Trae 或普通终端的 Microi 开发者,与 Microi吾码 VS Code 插件共用工作区配置、Token、AI 规则、Skills、MCP 配置和 V8 同步目录;两者可以同时安装并交替使用。
|
|
4
|
+
|
|
5
|
+
## 安装与首次初始化
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @microi.net/cli
|
|
9
|
+
cd 你的项目目录
|
|
10
|
+
microi init --pull
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`microi init` 会依次添加服务器、提示输入帐号和密码、在服务器启用时显示验证码图片路径、登录、注入 AI 配置并配置 MCP。密码只存在于当前 CLI 进程内,不写入文件;长期使用的是工作区内受 Git 排除保护的 Token 文件。
|
|
14
|
+
|
|
15
|
+
如果只初始化 AI/MCP、不立即拉取 V8 代码,执行 `microi init`。首次生成 Codex MCP 配置后,需要新开一个 Codex 对话,当前已打开的对话通常不会热加载新工具。
|
|
16
|
+
|
|
17
|
+
## 常用命令
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
microi profile list
|
|
21
|
+
microi profile add
|
|
22
|
+
microi auth login --profile 1
|
|
23
|
+
microi ai init
|
|
24
|
+
microi mcp init
|
|
25
|
+
microi pull --scope all --profile 1
|
|
26
|
+
microi sync status --scope all --profile 1
|
|
27
|
+
microi push "Microi-V8-Engine/.../接口.js"
|
|
28
|
+
microi doctor
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
自动化脚本可加 `--json`,并用 `--workspace D:\path\to\project` 指定工作区。`push` 是显式远端写入命令,不会因普通文件保存自动执行。
|
|
32
|
+
|
|
33
|
+
## 与 VS Code 插件的关系
|
|
34
|
+
|
|
35
|
+
- 共用 `Microi-V8-Engine/.microi-config.json` 和 `.microi-mcp-tokens.json`。
|
|
36
|
+
- 共用 `Microi-V8-Engine/` 下的 V8 源码和同步基线。
|
|
37
|
+
- MCP 写入采用合并方式,只替换由 Microi 管理的 server,不删除其他 MCP。
|
|
38
|
+
- 配置和 Token 使用原子写入并保留未知字段;MCP 记录来源/版本,交替使用不同版本时保留较新的内置 Server。
|
|
39
|
+
- `microi doctor` 会显示 MCP 提供者是 CLI、VS Code 还是旧版 `legacy`。历史旧版不能被新代码隔空修复;运行旧工具后,再在较新一端运行 `microi mcp init` 即可恢复新版配置。
|
|
40
|
+
- CLI 负责无 IDE 的连接、登录、AI/MCP 初始化、拉取、差异检查和显式推送;可视化树、编辑器按钮和逐行调试 UI 仍由 VS Code 插件提供。
|
|
41
|
+
|
|
42
|
+
完整文档:<https://microi.net/doc/v8-engine/vs-code-plugin.html>
|
|
43
|
+
|
|
44
|
+
## 维护者发布
|
|
45
|
+
|
|
46
|
+
CLI 与 VSIX 使用同一版本号。仓库根目录执行 `node publish.js --package-only --no-bump` 会构建并校验 VSIX 与 CLI npm tarball,但不会改版本或上传。
|
|
47
|
+
|
|
48
|
+
首次发布前,先在 npm 创建免费公开组织 `microi.net`,再登录。两个插件市场使用环境变量 `VSCE_PAT` / `OVSX_PAT`,或已被 Git 忽略的 `publish-tokens.local.json`:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd Microi.VSCode/cli
|
|
52
|
+
npm login --registry=https://registry.npmjs.org/
|
|
53
|
+
npm whoami --registry=https://registry.npmjs.org/
|
|
54
|
+
cd ..
|
|
55
|
+
npm run publish:preflight
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
预检通过后执行 `npm run publish`。脚本会在递增版本前验证 npm、Visual Studio Marketplace 和 Open VSX 三方权限,同时更新插件/CLI/Skills 版本,优先发布 CLI,并在结束时回读三端公开版本。旧的 `publish-tokens.json` 曾被 Git 跟踪,必须废弃其 PAT,把新 PAT 放入环境变量或 `publish-tokens.local.json`,再删除旧文件并从 Git 索引移除;脚本不再读取它。
|
|
59
|
+
|
|
60
|
+
如果当前版本的 VS Marketplace 与 Open VSX 已经发布、只需补发 CLI,不要再次运行普通发布命令;执行:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm run publish:cli:resume
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
如果 CLI 已发布、扩展市场失败,可用 `npm run publish:extensions:resume`、`npm run publish:vsce:resume` 或 `npm run publish:ovsx:resume`。补发只能用于同一份源码/产物;中断后若代码已改动,必须发布下一个新版本。
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Codex MCP stdio adapter for the bundled Microi MCP server.
|
|
4
|
+
*
|
|
5
|
+
* The MCP SDK version used by Microi currently speaks newline-delimited
|
|
6
|
+
* JSON-RPC over stdio. Some Codex runtimes send and expect Content-Length
|
|
7
|
+
* framed JSON-RPC. This adapter bridges both formats without changing the
|
|
8
|
+
* normal VS Code/Cursor/Trae/Claude MCP configuration.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const childProcess = require('node:child_process');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
|
|
14
|
+
const target = process.argv[2];
|
|
15
|
+
if (!target) {
|
|
16
|
+
console.error('[microi-mcp-adapter] Missing target MCP server path.');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const child = childProcess.spawn(process.execPath, [target, ...process.argv.slice(3)], {
|
|
21
|
+
cwd: process.cwd(),
|
|
22
|
+
env: process.env,
|
|
23
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
24
|
+
windowsHide: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
let inputBuffer = Buffer.alloc(0);
|
|
28
|
+
let outputBuffer = Buffer.alloc(0);
|
|
29
|
+
let clientFraming = null; // 'content-length' | 'line'
|
|
30
|
+
let shutdownRequested = false;
|
|
31
|
+
let requestedExitCode = 0;
|
|
32
|
+
let forceExitTimer = null;
|
|
33
|
+
|
|
34
|
+
function stopChildAndExit(exitCode = 0) {
|
|
35
|
+
if (shutdownRequested) return;
|
|
36
|
+
shutdownRequested = true;
|
|
37
|
+
requestedExitCode = exitCode;
|
|
38
|
+
|
|
39
|
+
if (!child.stdin.destroyed) {
|
|
40
|
+
child.stdin.end();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (child.exitCode !== null) {
|
|
44
|
+
process.exit(requestedExitCode);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
child.kill('SIGTERM');
|
|
49
|
+
} catch {
|
|
50
|
+
process.exit(requestedExitCode);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
forceExitTimer = setTimeout(() => {
|
|
54
|
+
try {
|
|
55
|
+
child.kill('SIGKILL');
|
|
56
|
+
} catch {
|
|
57
|
+
// 子进程可能已在超时边界退出。
|
|
58
|
+
}
|
|
59
|
+
process.exit(requestedExitCode);
|
|
60
|
+
}, 2000);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Codex 会为每个 MCP 连接启动一个适配器。客户端退出、重载或异常断开时,
|
|
64
|
+
// 必须同步终止其子 MCP 服务,否则孤儿进程会持续累积并挤占前端构建内存。
|
|
65
|
+
process.stdin.on('end', () => stopChildAndExit(0));
|
|
66
|
+
process.stdin.on('error', () => stopChildAndExit(1));
|
|
67
|
+
process.stdout.on('error', error => {
|
|
68
|
+
stopChildAndExit(error && error.code === 'EPIPE' ? 0 : 1);
|
|
69
|
+
});
|
|
70
|
+
process.on('disconnect', () => stopChildAndExit(0));
|
|
71
|
+
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
|
|
72
|
+
process.on(signal, () => stopChildAndExit(0));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const parentPid = process.ppid;
|
|
76
|
+
if (parentPid > 1) {
|
|
77
|
+
const parentWatchTimer = setInterval(() => {
|
|
78
|
+
try {
|
|
79
|
+
process.kill(parentPid, 0);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error && error.code === 'ESRCH') {
|
|
82
|
+
stopChildAndExit(0);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, 5000);
|
|
86
|
+
parentWatchTimer.unref();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
process.on('exit', () => {
|
|
90
|
+
if (child.exitCode === null) {
|
|
91
|
+
try {
|
|
92
|
+
child.kill('SIGKILL');
|
|
93
|
+
} catch {
|
|
94
|
+
// 退出阶段只做尽力清理。
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
function writeLineToChild(jsonText) {
|
|
100
|
+
if (!child.stdin.destroyed) {
|
|
101
|
+
child.stdin.write(jsonText.trimEnd() + '\n');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function writeToClient(jsonText) {
|
|
106
|
+
const text = jsonText.trim();
|
|
107
|
+
if (!text) return;
|
|
108
|
+
|
|
109
|
+
if (clientFraming === 'line') {
|
|
110
|
+
process.stdout.write(text + '\n');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const bytes = Buffer.byteLength(text, 'utf8');
|
|
115
|
+
process.stdout.write(`Content-Length: ${bytes}\r\n\r\n${text}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function processInputBuffer() {
|
|
119
|
+
while (inputBuffer.length > 0) {
|
|
120
|
+
const asText = inputBuffer.toString('utf8');
|
|
121
|
+
|
|
122
|
+
if (/^Content-Length:/i.test(asText)) {
|
|
123
|
+
clientFraming = 'content-length';
|
|
124
|
+
const headerEnd = asText.indexOf('\r\n\r\n');
|
|
125
|
+
if (headerEnd < 0) return;
|
|
126
|
+
|
|
127
|
+
const header = asText.slice(0, headerEnd);
|
|
128
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
129
|
+
if (!match) {
|
|
130
|
+
console.error('[microi-mcp-adapter] Invalid Content-Length header.');
|
|
131
|
+
stopChildAndExit(1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const length = Number(match[1]);
|
|
136
|
+
const bodyStart = Buffer.byteLength(asText.slice(0, headerEnd + 4), 'utf8');
|
|
137
|
+
if (inputBuffer.length < bodyStart + length) return;
|
|
138
|
+
|
|
139
|
+
const body = inputBuffer.slice(bodyStart, bodyStart + length).toString('utf8');
|
|
140
|
+
writeLineToChild(body);
|
|
141
|
+
inputBuffer = inputBuffer.slice(bodyStart + length);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
clientFraming = clientFraming || 'line';
|
|
146
|
+
const newline = inputBuffer.indexOf(0x0a);
|
|
147
|
+
if (newline < 0) return;
|
|
148
|
+
|
|
149
|
+
const line = inputBuffer.slice(0, newline + 1).toString('utf8').trim();
|
|
150
|
+
inputBuffer = inputBuffer.slice(newline + 1);
|
|
151
|
+
if (line) {
|
|
152
|
+
writeLineToChild(line);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
process.stdin.on('data', chunk => {
|
|
158
|
+
inputBuffer = Buffer.concat([inputBuffer, chunk]);
|
|
159
|
+
processInputBuffer();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
child.stdout.on('data', chunk => {
|
|
163
|
+
outputBuffer = Buffer.concat([outputBuffer, chunk]);
|
|
164
|
+
let newlineIndex;
|
|
165
|
+
while ((newlineIndex = outputBuffer.indexOf(0x0a)) >= 0) {
|
|
166
|
+
const line = outputBuffer.slice(0, newlineIndex).toString('utf8').trim();
|
|
167
|
+
outputBuffer = outputBuffer.slice(newlineIndex + 1);
|
|
168
|
+
if (line) writeToClient(line);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
child.stderr.on('data', chunk => {
|
|
173
|
+
process.stderr.write(chunk);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
child.on('exit', code => {
|
|
177
|
+
if (forceExitTimer) {
|
|
178
|
+
clearTimeout(forceExitTimer);
|
|
179
|
+
}
|
|
180
|
+
if (outputBuffer.length > 0) {
|
|
181
|
+
writeToClient(outputBuffer.toString('utf8'));
|
|
182
|
+
}
|
|
183
|
+
process.exit(shutdownRequested ? requestedExitCode : (code || 0));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
child.on('error', err => {
|
|
187
|
+
console.error(`[microi-mcp-adapter] Failed to start ${path.basename(target)}: ${err.message}`);
|
|
188
|
+
stopChildAndExit(1);
|
|
189
|
+
});
|