codexmate 0.0.6 → 0.0.7
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/cli.js +47 -8
- package/package.json +1 -1
- package/web-ui.html +3 -1
package/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ const crypto = require('crypto');
|
|
|
6
6
|
const toml = require('@iarna/toml');
|
|
7
7
|
const JSON5 = require('json5');
|
|
8
8
|
const zipLib = require('zip-lib');
|
|
9
|
-
const { exec, execSync } = require('child_process');
|
|
9
|
+
const { exec, execSync, spawn } = require('child_process');
|
|
10
10
|
const http = require('http');
|
|
11
11
|
const https = require('https');
|
|
12
12
|
const readline = require('readline');
|
|
@@ -5136,13 +5136,46 @@ function cmdStart(options = {}) {
|
|
|
5136
5136
|
if (error) console.warn('无法自动打开浏览器,请手动访问:', url);
|
|
5137
5137
|
});
|
|
5138
5138
|
}
|
|
5139
|
-
});
|
|
5140
|
-
}
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5139
|
+
});
|
|
5140
|
+
}
|
|
5141
|
+
|
|
5142
|
+
async function cmdCodex(args = []) {
|
|
5143
|
+
const extraArgs = Array.isArray(args) ? args.filter(arg => arg !== undefined) : [];
|
|
5144
|
+
const hasYolo = extraArgs.includes('--yolo');
|
|
5145
|
+
const finalArgs = hasYolo ? extraArgs : ['--yolo', ...extraArgs];
|
|
5146
|
+
|
|
5147
|
+
return new Promise((resolve, reject) => {
|
|
5148
|
+
const child = spawn('codex', finalArgs, {
|
|
5149
|
+
stdio: 'inherit',
|
|
5150
|
+
shell: process.platform === 'win32'
|
|
5151
|
+
});
|
|
5152
|
+
|
|
5153
|
+
child.on('error', (err) => {
|
|
5154
|
+
reject(new Error(`无法启动 codex,请确认已安装并在 PATH 中: ${err.message}`));
|
|
5155
|
+
});
|
|
5156
|
+
|
|
5157
|
+
child.on('exit', (code, signal) => {
|
|
5158
|
+
if (typeof code === 'number') {
|
|
5159
|
+
resolve(code);
|
|
5160
|
+
return;
|
|
5161
|
+
}
|
|
5162
|
+
if (signal === 'SIGINT') {
|
|
5163
|
+
resolve(130);
|
|
5164
|
+
return;
|
|
5165
|
+
}
|
|
5166
|
+
if (signal === 'SIGTERM') {
|
|
5167
|
+
resolve(143);
|
|
5168
|
+
return;
|
|
5169
|
+
}
|
|
5170
|
+
resolve(1);
|
|
5171
|
+
});
|
|
5172
|
+
});
|
|
5173
|
+
}
|
|
5174
|
+
|
|
5175
|
+
// ============================================================================
|
|
5176
|
+
// 主程序
|
|
5177
|
+
// ============================================================================
|
|
5178
|
+
async function main() {
|
|
5146
5179
|
const bootstrap = ensureManagedConfigBootstrap();
|
|
5147
5180
|
if (bootstrap && bootstrap.notice) {
|
|
5148
5181
|
console.log(`\n[Init] ${bootstrap.notice}`);
|
|
@@ -5163,6 +5196,7 @@ async function main() {
|
|
|
5163
5196
|
console.log(' codexmate add-model <模型> 添加模型');
|
|
5164
5197
|
console.log(' codexmate delete-model <模型> 删除模型');
|
|
5165
5198
|
console.log(' codexmate start [--host <HOST>] 启动 Web 界面');
|
|
5199
|
+
console.log(' codexmate codex [参数...] 等同于 codex --yolo');
|
|
5166
5200
|
console.log(' codexmate export-session --source <codex|claude> (--session-id <ID>|--file <PATH>) [--output <PATH>] [--max-messages <N|all|Infinity>]');
|
|
5167
5201
|
console.log(' codexmate zip <路径> [--max:级别] 压缩(7-Zip 优先)');
|
|
5168
5202
|
console.log(' codexmate unzip <zip文件> [输出目录] 解压(7-Zip 优先)');
|
|
@@ -5184,6 +5218,11 @@ async function main() {
|
|
|
5184
5218
|
case 'add-model': cmdAddModel(args[1]); break;
|
|
5185
5219
|
case 'delete-model': cmdDeleteModel(args[1]); break;
|
|
5186
5220
|
case 'start': cmdStart(parseStartOptions(args.slice(1))); break;
|
|
5221
|
+
case 'codex': {
|
|
5222
|
+
const exitCode = await cmdCodex(args.slice(1));
|
|
5223
|
+
process.exit(exitCode);
|
|
5224
|
+
break;
|
|
5225
|
+
}
|
|
5187
5226
|
case 'export-session': await cmdExportSession(args.slice(1)); break;
|
|
5188
5227
|
case 'zip': {
|
|
5189
5228
|
// 解析 --max:N 参数
|
package/package.json
CHANGED
package/web-ui.html
CHANGED
|
@@ -3278,7 +3278,9 @@
|
|
|
3278
3278
|
|
|
3279
3279
|
<script>
|
|
3280
3280
|
const { createApp } = Vue;
|
|
3281
|
-
const API_BASE = '
|
|
3281
|
+
const API_BASE = (location && location.origin && location.origin !== 'null')
|
|
3282
|
+
? location.origin
|
|
3283
|
+
: 'http://localhost:3737';
|
|
3282
3284
|
const DEFAULT_OPENCLAW_TEMPLATE = `{
|
|
3283
3285
|
// OpenClaw config (JSON5)
|
|
3284
3286
|
agent: {
|