shizai-agent-mcp 0.2.9 → 0.3.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 +5 -5
- package/bin/shizai-agent-mcp.js +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,11 @@ npx -y shizai-agent-mcp path
|
|
|
24
24
|
npx -y shizai-agent-mcp uninstall
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
当前 npm launcher 版本为 `0.2.9`,默认下载最新的 `v0.6.
|
|
28
|
-
`shizai-agent-v0.6.
|
|
29
|
-
|
|
30
|
-
`install` 覆盖文件后会自动注册 Codex MCP;需要跳过配置写入时使用
|
|
31
|
-
`install --skip-register`,之后可单独运行 `register codex`。
|
|
27
|
+
当前 npm launcher 版本为 `0.2.9`,默认下载最新的 `v0.6.8` Windows x64 资产:
|
|
28
|
+
`shizai-agent-v0.6.8-windows-x64.zip`。npm 包不附带浏览器自动化依赖,也不要求用户安装额外扩展。
|
|
29
|
+
|
|
30
|
+
`install` 覆盖文件后会自动注册 Codex MCP;需要跳过配置写入时使用
|
|
31
|
+
`install --skip-register`,之后可单独运行 `register codex`。
|
|
32
32
|
|
|
33
33
|
发布 Release 时必须同时上传同名 `.sha256` 文件。安装器先校验、解压到同盘暂存目录,
|
|
34
34
|
再原子替换现有版本;失败会恢复旧安装。测试企业内网镜像时可设置
|
package/bin/shizai-agent-mcp.js
CHANGED
|
@@ -9,7 +9,7 @@ const { execFileSync, spawn } = require('node:child_process');
|
|
|
9
9
|
|
|
10
10
|
const SERVER = 'shizai-agent';
|
|
11
11
|
const REPO = process.env.SHIZAI_AGENT_REPO || 'yimoxzy/shizai-agent';
|
|
12
|
-
const DEFAULT_VERSION = process.env.SHIZAI_AGENT_VERSION || '0.6.
|
|
12
|
+
const DEFAULT_VERSION = process.env.SHIZAI_AGENT_VERSION || '0.6.8';
|
|
13
13
|
const installRoot = process.env.SHIZAI_AGENT_HOME || path.join(
|
|
14
14
|
process.env.LOCALAPPDATA || path.join(os.homedir(), '.local'), 'Programs', 'ShizaiAgent'
|
|
15
15
|
);
|
|
@@ -116,7 +116,7 @@ function download(url, destination) {
|
|
|
116
116
|
const script = `Invoke-WebRequest -UseBasicParsing -Uri ${psQuote(url)} -OutFile ${psQuote(destination)}`;
|
|
117
117
|
runPowerShell(script);
|
|
118
118
|
}
|
|
119
|
-
function install(version, options = {}) {
|
|
119
|
+
function install(version, options = {}) {
|
|
120
120
|
const destination = validateInstallRoot();
|
|
121
121
|
const asset = assetName(version);
|
|
122
122
|
const url = releaseUrl(version, asset);
|
|
@@ -189,34 +189,34 @@ function install(version, options = {}) {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
cleanupInstallArtifacts(parent, [stage, backup]);
|
|
192
|
-
const result = { installed: true, version, directory: destination, command: binaryPath(), verified, stopped_processes: [...stoppedProcesses].sort((left, right) => left - right) };
|
|
193
|
-
if (!options.skipRegister) result.registration = registerCodex(true);
|
|
194
|
-
json(result);
|
|
195
|
-
return result;
|
|
192
|
+
const result = { installed: true, version, directory: destination, command: binaryPath(), verified, stopped_processes: [...stoppedProcesses].sort((left, right) => left - right) };
|
|
193
|
+
if (!options.skipRegister) result.registration = registerCodex(true);
|
|
194
|
+
json(result);
|
|
195
|
+
return result;
|
|
196
196
|
} finally {
|
|
197
197
|
removeDirectoryWithRetries(temp);
|
|
198
198
|
removeDirectoryWithRetries(stage);
|
|
199
199
|
if (fs.existsSync(backup) && fs.existsSync(destination)) removeDirectoryWithRetries(backup);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
function replaceTomlSection(content, section, replacement) {
|
|
203
|
-
const header = `[${section}]`;
|
|
204
|
-
const lines = String(content || '').split(/\r?\n/);
|
|
205
|
-
const kept = [];
|
|
206
|
-
let skipping = false;
|
|
207
|
-
for (const line of lines) {
|
|
208
|
-
if (line.trim() === header) {
|
|
209
|
-
skipping = true;
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (skipping && /^\s*\[.*\]\s*$/.test(line)) skipping = false;
|
|
213
|
-
if (!skipping) kept.push(line);
|
|
214
|
-
}
|
|
215
|
-
const next = kept.join('\n').trimEnd();
|
|
216
|
-
return `${next}${next ? '\r\n\r\n' : ''}${replacement.trim()}\r\n`;
|
|
217
|
-
}
|
|
202
|
+
function replaceTomlSection(content, section, replacement) {
|
|
203
|
+
const header = `[${section}]`;
|
|
204
|
+
const lines = String(content || '').split(/\r?\n/);
|
|
205
|
+
const kept = [];
|
|
206
|
+
let skipping = false;
|
|
207
|
+
for (const line of lines) {
|
|
208
|
+
if (line.trim() === header) {
|
|
209
|
+
skipping = true;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (skipping && /^\s*\[.*\]\s*$/.test(line)) skipping = false;
|
|
213
|
+
if (!skipping) kept.push(line);
|
|
214
|
+
}
|
|
215
|
+
const next = kept.join('\n').trimEnd();
|
|
216
|
+
return `${next}${next ? '\r\n\r\n' : ''}${replacement.trim()}\r\n`;
|
|
217
|
+
}
|
|
218
218
|
function tomlString(value) { return JSON.stringify(String(value)); }
|
|
219
|
-
function registerCodex(silent = false) {
|
|
219
|
+
function registerCodex(silent = false) {
|
|
220
220
|
const config = process.env.SHIZAI_CODEX_CONFIG || path.join(os.homedir(), '.codex', 'config.toml');
|
|
221
221
|
fs.mkdirSync(path.dirname(config), { recursive: true });
|
|
222
222
|
const old = fs.existsSync(config) ? fs.readFileSync(config, 'utf8') : '';
|
|
@@ -224,9 +224,9 @@ function registerCodex(silent = false) {
|
|
|
224
224
|
const section = `[mcp_servers.${SERVER}]\ncommand = ${tomlString(binaryPath())}\nargs = []\nstartup_timeout_sec = 30\ntool_timeout_sec = 120`;
|
|
225
225
|
const next = replaceTomlSection(old, `mcp_servers.${SERVER}`, section);
|
|
226
226
|
fs.writeFileSync(config, next, 'utf8');
|
|
227
|
-
const result = { registered: true, client: 'codex', config, command: binaryPath() };
|
|
228
|
-
if (!silent) json(result);
|
|
229
|
-
return result;
|
|
227
|
+
const result = { registered: true, client: 'codex', config, command: binaryPath() };
|
|
228
|
+
if (!silent) json(result);
|
|
229
|
+
return result;
|
|
230
230
|
}
|
|
231
231
|
function registerJsonClient(client) {
|
|
232
232
|
const locations = {
|
|
@@ -256,7 +256,7 @@ function main() {
|
|
|
256
256
|
const index = args.indexOf('--version');
|
|
257
257
|
const version = index >= 0 ? args[index + 1] : args.find(value => !value.startsWith('-'));
|
|
258
258
|
if (index >= 0 && !version) throw new Error('--version 后需要版本号');
|
|
259
|
-
return install(version || DEFAULT_VERSION, { skipRegister: args.includes('--skip-register') });
|
|
259
|
+
return install(version || DEFAULT_VERSION, { skipRegister: args.includes('--skip-register') });
|
|
260
260
|
}
|
|
261
261
|
if (command === 'register') {
|
|
262
262
|
if (!fs.existsSync(binaryPath())) throw new Error('尚未安装,请先运行 install');
|