shizai-agent-mcp 0.2.7 → 0.2.9

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 CHANGED
@@ -24,8 +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.7`,默认下载最新的 `v0.6.7` Windows x64 资产:
27
+ 当前 npm launcher 版本为 `0.2.9`,默认下载最新的 `v0.6.7` Windows x64 资产:
28
28
  `shizai-agent-v0.6.7-windows-x64.zip`。npm 包不附带浏览器自动化依赖,也不要求用户安装额外扩展。
29
+
30
+ `install` 覆盖文件后会自动注册 Codex MCP;需要跳过配置写入时使用
31
+ `install --skip-register`,之后可单独运行 `register codex`。
29
32
 
30
33
  发布 Release 时必须同时上传同名 `.sha256` 文件。安装器先校验、解压到同盘暂存目录,
31
34
  再原子替换现有版本;失败会恢复旧安装。测试企业内网镜像时可设置
@@ -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) {
119
+ function install(version, options = {}) {
120
120
  const destination = validateInstallRoot();
121
121
  const asset = assetName(version);
122
122
  const url = releaseUrl(version, asset);
@@ -189,21 +189,34 @@ function install(version) {
189
189
  }
190
190
  }
191
191
  cleanupInstallArtifacts(parent, [stage, backup]);
192
- json({ installed: true, version, directory: destination, command: binaryPath(), verified, stopped_processes: [...stoppedProcesses].sort((left, right) => left - right) });
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;
193
196
  } finally {
194
197
  removeDirectoryWithRetries(temp);
195
198
  removeDirectoryWithRetries(stage);
196
199
  if (fs.existsSync(backup) && fs.existsSync(destination)) removeDirectoryWithRetries(backup);
197
200
  }
198
201
  }
199
- function replaceTomlSection(content, section, replacement) {
200
- const escaped = section.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
201
- const pattern = new RegExp(`^\\[${escaped}\\]\\r?\\n[\\s\\S]*?(?=^\\[|$)`, 'm');
202
- const next = content.replace(pattern, '').trimEnd();
203
- return `${next}${next ? '\r\n\r\n' : ''}${replacement.trim()}\r\n`;
204
- }
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
+ }
205
218
  function tomlString(value) { return JSON.stringify(String(value)); }
206
- function registerCodex() {
219
+ function registerCodex(silent = false) {
207
220
  const config = process.env.SHIZAI_CODEX_CONFIG || path.join(os.homedir(), '.codex', 'config.toml');
208
221
  fs.mkdirSync(path.dirname(config), { recursive: true });
209
222
  const old = fs.existsSync(config) ? fs.readFileSync(config, 'utf8') : '';
@@ -211,7 +224,9 @@ function registerCodex() {
211
224
  const section = `[mcp_servers.${SERVER}]\ncommand = ${tomlString(binaryPath())}\nargs = []\nstartup_timeout_sec = 30\ntool_timeout_sec = 120`;
212
225
  const next = replaceTomlSection(old, `mcp_servers.${SERVER}`, section);
213
226
  fs.writeFileSync(config, next, 'utf8');
214
- json({ registered: true, client: 'codex', config, command: binaryPath() });
227
+ const result = { registered: true, client: 'codex', config, command: binaryPath() };
228
+ if (!silent) json(result);
229
+ return result;
215
230
  }
216
231
  function registerJsonClient(client) {
217
232
  const locations = {
@@ -241,7 +256,7 @@ function main() {
241
256
  const index = args.indexOf('--version');
242
257
  const version = index >= 0 ? args[index + 1] : args.find(value => !value.startsWith('-'));
243
258
  if (index >= 0 && !version) throw new Error('--version 后需要版本号');
244
- return install(version || DEFAULT_VERSION);
259
+ return install(version || DEFAULT_VERSION, { skipRegister: args.includes('--skip-register') });
245
260
  }
246
261
  if (command === 'register') {
247
262
  if (!fs.existsSync(binaryPath())) throw new Error('尚未安装,请先运行 install');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shizai-agent-mcp",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Installer and launcher for the Shizai Agent local MCP server",
5
5
  "bin": {
6
6
  "shizai-agent-mcp": "bin/shizai-agent-mcp.js"