forgex-agent 0.5.1 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +14 -3
  2. package/main.js +273 -217
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,14 +18,25 @@ forgex --version
18
18
  ## 快速开始
19
19
 
20
20
  ```bash
21
- # 配置模型 API Key(会做一次连通性测试)
21
+ # 方式一:直接启动。首次运行会自动进入连接向导(provider → baseUrl → API Key → model)
22
+ forgex
23
+
24
+ # 方式二:先单独配置,会做一次连通性测试
22
25
  forgex connect
26
+ ```
27
+
28
+ 首次运行会在 `~/.forgex/config.json` 生成配置。API Key 不写入配置文件,而是保存到环境变量(Windows 用户级环境变量;Unix 会提示 export 命令)。
23
29
 
24
- # 在当前目录启动 TUI
30
+ 如果只想用环境变量,也可以完全不建配置文件——启动时会按 Key 自动识别 Provider:
31
+
32
+ ```bash
33
+ export DEEPSEEK_API_KEY=sk-xxx # 自动使用 https://api.deepseek.com + deepseek-flash
25
34
  forgex
35
+
36
+ # 也支持 DASHSCOPE_API_KEY / OPENAI_API_KEY
37
+ # 自定义端点仍用 FORGEX_BASE_URL / FORGEX_MODEL / FORGEX_API_KEY(或 forgex connect)
26
38
  ```
27
39
 
28
- 首次运行会在 `~/.forgex/config.json` 生成配置。API Key 不写入配置文件,而是保存到环境变量(Windows 用户级环境变量;Unix 会提示 export 命令)。
29
40
 
30
41
  ## TUI 命令
31
42
 
package/main.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // apps/cli/src/main.ts
9
- import { stderr as stderr3, stdout as stdout8 } from "node:process";
9
+ import { stderr as stderr4, stdout as stdout8 } from "node:process";
10
10
 
11
11
  // packages/shared/dist/errors/index.js
12
12
  var ForgeError = class _ForgeError extends Error {
@@ -572,6 +572,7 @@ function flagNumber(flags, name) {
572
572
  // apps/cli/src/commands/chat.ts
573
573
  import React2 from "react";
574
574
  import { render } from "ink";
575
+ import { stderr as stderr2 } from "node:process";
575
576
 
576
577
  // apps/cli/src/config/load-config.ts
577
578
  import { existsSync, readFileSync } from "node:fs";
@@ -4619,6 +4620,43 @@ var coerce = {
4619
4620
  };
4620
4621
  var NEVER = INVALID;
4621
4622
 
4623
+ // apps/cli/src/config/providers.ts
4624
+ var PROVIDERS = {
4625
+ deepseek: {
4626
+ name: "DeepSeek",
4627
+ defaultBaseUrl: "https://api.deepseek.com",
4628
+ defaultModel: "deepseek-flash",
4629
+ apiKeyEnv: "DEEPSEEK_API_KEY",
4630
+ contextWindow: 1e6,
4631
+ maxOutputTokens: 8192
4632
+ },
4633
+ qwen: {
4634
+ name: "Qwen (DashScope compatible-mode)",
4635
+ defaultBaseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
4636
+ defaultModel: "qwen-plus",
4637
+ apiKeyEnv: "DASHSCOPE_API_KEY",
4638
+ contextWindow: 131072,
4639
+ maxOutputTokens: 8192
4640
+ },
4641
+ openai: {
4642
+ name: "OpenAI",
4643
+ defaultBaseUrl: "https://api.openai.com/v1",
4644
+ defaultModel: "gpt-4o-mini",
4645
+ apiKeyEnv: "OPENAI_API_KEY",
4646
+ contextWindow: 128e3,
4647
+ maxOutputTokens: 16384
4648
+ },
4649
+ custom: {
4650
+ name: "\u81EA\u5B9A\u4E49\u517C\u5BB9\u7AEF\u70B9\uFF08vLLM / Ollama / \u5185\u7F51\u7F51\u5173\uFF09",
4651
+ defaultBaseUrl: "http://127.0.0.1:8000/v1",
4652
+ defaultModel: "local-model",
4653
+ apiKeyEnv: "FORGEX_API_KEY",
4654
+ contextWindow: 32768,
4655
+ maxOutputTokens: 4096
4656
+ }
4657
+ };
4658
+ var PROVIDERS_KEYS = Object.keys(PROVIDERS);
4659
+
4622
4660
  // apps/cli/src/config/load-config.ts
4623
4661
  var DEFAULT_BASE_URL = "http://127.0.0.1:8000/v1";
4624
4662
  var DEFAULT_MODEL = "local-model";
@@ -4701,7 +4739,9 @@ function loadConfig(options = {}) {
4701
4739
  }
4702
4740
  const envData = readEnvConfig(env);
4703
4741
  if (Object.keys(envData).length > 0) sources.push("\u73AF\u5883\u53D8\u91CF");
4704
- const merged = deepMerge(fileData, envData);
4742
+ const detected = detectProviderFromEnv(env, fileData);
4743
+ if (detected) sources.push("\u73AF\u5883\u53D8\u91CF\uFF08\u81EA\u52A8\u8BC6\u522B Provider\uFF09");
4744
+ const merged = deepMerge(deepMerge(fileData, detected ?? {}), envData);
4705
4745
  const parsed = ConfigSchema.safeParse(merged);
4706
4746
  if (!parsed.success) {
4707
4747
  const issues = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
@@ -4817,6 +4857,31 @@ function readEnvConfig(env) {
4817
4857
  if (Object.keys(agent).length > 0) out.agent = agent;
4818
4858
  return out;
4819
4859
  }
4860
+ function detectProviderFromEnv(env, fileData) {
4861
+ if (env.FORGEX_BASE_URL || env.FORGEX_MODEL || env.FORGEX_API_KEY || env.FORGEX_API_KEY_ENV) {
4862
+ return null;
4863
+ }
4864
+ const fileModel = fileData.model;
4865
+ if (isRecord(fileModel)) {
4866
+ if (typeof fileModel.baseUrl === "string" || typeof fileModel.model === "string") return null;
4867
+ if (typeof fileModel.apiKey === "string" || typeof fileModel.apiKeyEnv === "string") return null;
4868
+ }
4869
+ for (const preset of Object.values(PROVIDERS)) {
4870
+ if (preset.apiKeyEnv === "FORGEX_API_KEY") continue;
4871
+ const key = env[preset.apiKeyEnv];
4872
+ if (!key || key.trim() === "") continue;
4873
+ return {
4874
+ model: {
4875
+ baseUrl: preset.defaultBaseUrl,
4876
+ model: preset.defaultModel,
4877
+ apiKeyEnv: preset.apiKeyEnv,
4878
+ contextWindow: preset.contextWindow,
4879
+ maxOutputTokens: preset.maxOutputTokens
4880
+ }
4881
+ };
4882
+ }
4883
+ return null;
4884
+ }
4820
4885
  function determineModelConfigured(fileData, env, parsed) {
4821
4886
  if (env.FORGEX_BASE_URL || env.FORGEX_MODEL) return true;
4822
4887
  const model = fileData.model;
@@ -4859,6 +4924,20 @@ function normalizeBaseUrl(baseUrl) {
4859
4924
  return baseUrl.replace(/\/+$/, "");
4860
4925
  }
4861
4926
 
4927
+ // apps/cli/src/config/setup-hint.ts
4928
+ function modelSetupHint(options) {
4929
+ const lines = [
4930
+ "\u5C1A\u672A\u914D\u7F6E\u6A21\u578B\u3002",
4931
+ options.interactive ? "\u5728\u4EA4\u4E92\u5F0F\u7EC8\u7AEF\u91CC\u76F4\u63A5\u8FD0\u884C `forgex` \u4F1A\u81EA\u52A8\u8FDB\u5165\u8FDE\u63A5\u5411\u5BFC\u3002" : "\u4EFB\u9009\u4E00\u79CD\u65B9\u5F0F\u5B8C\u6210\u914D\u7F6E\uFF1A",
4932
+ " 1. \u4EA4\u4E92\u5F0F\u5411\u5BFC\uFF1Aforgex connect",
4933
+ " 2. \u975E\u4EA4\u4E92\u5F0F\uFF1Aforgex connect --provider deepseek --api-key sk-xxx --model deepseek-flash",
4934
+ " 3. \u53EA\u8BBE\u7F6E Key\uFF1Aexport DEEPSEEK_API_KEY=sk-xxx\uFF08\u542F\u52A8\u65F6\u81EA\u52A8\u8BC6\u522B DeepSeek\uFF09",
4935
+ " 4. \u73AF\u5883\u53D8\u91CF\uFF1AFORGEX_BASE_URL / FORGEX_MODEL / FORGEX_API_KEY",
4936
+ " 5. \u914D\u7F6E\u6587\u4EF6\uFF1A~/.forgex/config.json \u6216\u9879\u76EE\u6839\u76EE\u5F55 forgex.config.json"
4937
+ ];
4938
+ return lines.join("\n");
4939
+ }
4940
+
4862
4941
  // packages/models/dist/openai-compatible.js
4863
4942
  var DEFAULT_TIMEOUT_MS = 12e4;
4864
4943
  var MAX_ERROR_BODY = 2e3;
@@ -6999,7 +7078,7 @@ function execFileText(program, args, options = {}) {
6999
7078
  maxBuffer: options.maxBuffer ?? 8 * 1024 * 1024,
7000
7079
  windowsHide: true,
7001
7080
  encoding: "utf8"
7002
- }, (error, stdout9, stderr4) => {
7081
+ }, (error, stdout9, stderr5) => {
7003
7082
  if (error) {
7004
7083
  const errCode = error.code;
7005
7084
  if (errCode === "ENOENT") {
@@ -7012,11 +7091,11 @@ function execFileText(program, args, options = {}) {
7012
7091
  resolve5({
7013
7092
  code: typeof errCode === "number" ? errCode : -1,
7014
7093
  stdout: String(stdout9 ?? ""),
7015
- stderr: String(stderr4 ?? error.message)
7094
+ stderr: String(stderr5 ?? error.message)
7016
7095
  });
7017
7096
  return;
7018
7097
  }
7019
- resolve5({ code: 0, stdout: String(stdout9 ?? ""), stderr: String(stderr4 ?? "") });
7098
+ resolve5({ code: 0, stdout: String(stdout9 ?? ""), stderr: String(stderr5 ?? "") });
7020
7099
  });
7021
7100
  });
7022
7101
  }
@@ -7704,7 +7783,7 @@ var SshClient = class {
7704
7783
  return this.abortedResult(command, spec, started, "SSH \u8FDE\u63A5\u88AB\u53D6\u6D88");
7705
7784
  }
7706
7785
  let stdout9 = "";
7707
- let stderr4 = "";
7786
+ let stderr5 = "";
7708
7787
  let truncated = false;
7709
7788
  let timedOut = false;
7710
7789
  let exitCode = null;
@@ -7750,9 +7829,9 @@ var SshClient = class {
7750
7829
  }).stderr.on("data", (data) => {
7751
7830
  const chunk = data.toString("utf8");
7752
7831
  const stderrLimit = Math.floor(maxOutputBytes * 0.5);
7753
- if (byteLength(stderr4) < stderrLimit) {
7754
- stderr4 += chunk;
7755
- if (byteLength(stderr4) >= stderrLimit)
7832
+ if (byteLength(stderr5) < stderrLimit) {
7833
+ stderr5 += chunk;
7834
+ if (byteLength(stderr5) >= stderrLimit)
7756
7835
  truncated = true;
7757
7836
  } else {
7758
7837
  truncated = true;
@@ -7774,7 +7853,7 @@ var SshClient = class {
7774
7853
  return {
7775
7854
  exitCode,
7776
7855
  stdout: truncated ? truncateWithNote(stdout9, maxOutputBytes, 0.9) : stdout9,
7777
- stderr: truncated ? truncateWithNote(stderr4, Math.floor(maxOutputBytes * 0.5), 0.9) : stderr4,
7856
+ stderr: truncated ? truncateWithNote(stderr5, Math.floor(maxOutputBytes * 0.5), 0.9) : stderr5,
7778
7857
  truncated,
7779
7858
  timedOut,
7780
7859
  durationMs: Date.now() - started,
@@ -8687,8 +8766,8 @@ function runViaExecutor(binary, spec, signal) {
8687
8766
  cleanup();
8688
8767
  const raw = Buffer.concat(outChunks).toString("utf8").trim();
8689
8768
  if (!raw) {
8690
- const stderr4 = Buffer.concat(errChunks).toString("utf8").trim();
8691
- finish(() => reject(new ForgeError("TOOL_FAILED", `\u6267\u884C\u5668\u672A\u8FD4\u56DE\u7ED3\u679C${stderr4 ? `: ${stderr4}` : ""}`)));
8769
+ const stderr5 = Buffer.concat(errChunks).toString("utf8").trim();
8770
+ finish(() => reject(new ForgeError("TOOL_FAILED", `\u6267\u884C\u5668\u672A\u8FD4\u56DE\u7ED3\u679C${stderr5 ? `: ${stderr5}` : ""}`)));
8692
8771
  return;
8693
8772
  }
8694
8773
  let parsed;
@@ -11316,41 +11395,6 @@ import { execFileSync } from "node:child_process";
11316
11395
  import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync } from "node:fs";
11317
11396
  import { homedir as homedir2 } from "node:os";
11318
11397
  import { dirname as dirname4, join as join8, resolve as resolve3 } from "node:path";
11319
- var PROVIDERS = {
11320
- deepseek: {
11321
- name: "DeepSeek",
11322
- defaultBaseUrl: "https://api.deepseek.com",
11323
- defaultModel: "deepseek-flash",
11324
- apiKeyEnv: "DEEPSEEK_API_KEY",
11325
- contextWindow: 1e6,
11326
- maxOutputTokens: 8192
11327
- },
11328
- qwen: {
11329
- name: "Qwen (DashScope compatible-mode)",
11330
- defaultBaseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
11331
- defaultModel: "qwen-plus",
11332
- apiKeyEnv: "DASHSCOPE_API_KEY",
11333
- contextWindow: 131072,
11334
- maxOutputTokens: 8192
11335
- },
11336
- openai: {
11337
- name: "OpenAI",
11338
- defaultBaseUrl: "https://api.openai.com/v1",
11339
- defaultModel: "gpt-4o-mini",
11340
- apiKeyEnv: "OPENAI_API_KEY",
11341
- contextWindow: 128e3,
11342
- maxOutputTokens: 16384
11343
- },
11344
- custom: {
11345
- name: "\u81EA\u5B9A\u4E49\u517C\u5BB9\u7AEF\u70B9\uFF08vLLM / Ollama / \u5185\u7F51\u7F51\u5173\uFF09",
11346
- defaultBaseUrl: "http://127.0.0.1:8000/v1",
11347
- defaultModel: "local-model",
11348
- apiKeyEnv: "FORGEX_API_KEY",
11349
- contextWindow: 32768,
11350
- maxOutputTokens: 4096
11351
- }
11352
- };
11353
- var PROVIDERS_KEYS = Object.keys(PROVIDERS);
11354
11398
  function resolveProvider(input) {
11355
11399
  const trimmed = input.trim();
11356
11400
  if (!trimmed) return "deepseek";
@@ -11569,7 +11613,7 @@ function switchModel(runtime, name) {
11569
11613
  }
11570
11614
 
11571
11615
  // apps/cli/src/version.ts
11572
- var VERSION = "0.5.1";
11616
+ var VERSION = "0.5.2";
11573
11617
 
11574
11618
  // apps/cli/src/ui/input-edit.ts
11575
11619
  function applyInputKey(state, char, key) {
@@ -12675,16 +12719,155 @@ function printHelp() {
12675
12719
  );
12676
12720
  }
12677
12721
 
12722
+ // apps/cli/src/commands/connect.ts
12723
+ import { createInterface as createInterface3 } from "node:readline/promises";
12724
+ import { resolve as resolve4 } from "node:path";
12725
+ import { stderr, stdin as stdin2, stdout as stdout2 } from "node:process";
12726
+ async function connectCommand(args, _options) {
12727
+ const isInteractive = Boolean(stdin2.isTTY);
12728
+ const configPath = defaultConfigPath();
12729
+ const existing = readExistingConfig(configPath);
12730
+ if (!isInteractive) {
12731
+ const provider = flagString(args.flags, "provider") ?? "custom";
12732
+ const apiKey = flagString(args.flags, "api-key") ?? "";
12733
+ const preset = PROVIDERS[provider.toLowerCase()];
12734
+ const baseUrl = flagString(args.flags, "base-url") ?? preset?.defaultBaseUrl ?? "";
12735
+ const model = flagString(args.flags, "model") ?? preset?.defaultModel ?? "";
12736
+ if (!apiKey) {
12737
+ stderr.write("[connect] --api-key \u5728\u975E\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u5FC5\u586B\n");
12738
+ return 2;
12739
+ }
12740
+ return await doConnect({ provider, apiKey, baseUrl, model, configPath, existing });
12741
+ }
12742
+ stdout2.write("ForgeX Connect \u2014 \u8FDE\u63A5\u4F60\u7684\u6A21\u578B\u63D0\u4F9B\u65B9\n\n");
12743
+ const rl = createInterface3({ input: stdin2, output: stderr });
12744
+ try {
12745
+ stdout2.write("\u9009\u62E9\u6A21\u578B\u63D0\u4F9B\u65B9\uFF08\u8F93\u5165\u7F16\u53F7\u6216\u540D\u79F0\uFF09\uFF1A\n");
12746
+ PROVIDERS_KEYS.forEach((key, i) => {
12747
+ const p = PROVIDERS[key];
12748
+ stdout2.write(` ${i + 1}. ${p.name} (${p.defaultBaseUrl})
12749
+ `);
12750
+ });
12751
+ stdout2.write("\n> ");
12752
+ const providerInput = (await rl.question("")).trim();
12753
+ const provider = resolveProvider(providerInput);
12754
+ const preset = PROVIDERS[provider];
12755
+ const baseUrlDefault = preset?.defaultBaseUrl ?? existing.model.baseUrl;
12756
+ stdout2.write(`baseUrl [${baseUrlDefault}]: `);
12757
+ const baseUrl = (await rl.question("")).trim() || baseUrlDefault;
12758
+ stdout2.write("\nAPI Key\uFF08\u8F93\u5165\u4E0D\u4F1A\u88AB\u9690\u85CF\uFF0C\u7C98\u8D34\u540E\u6309\u56DE\u8F66\uFF09: ");
12759
+ const apiKey = (await rl.question("")).trim();
12760
+ if (!apiKey) {
12761
+ stderr.write("[connect] API Key \u4E0D\u80FD\u4E3A\u7A7A\n");
12762
+ return 2;
12763
+ }
12764
+ const modelDefault = preset?.defaultModel ?? existing.model.model;
12765
+ stdout2.write(`
12766
+ \u6A21\u578B\u540D [${modelDefault}]: `);
12767
+ const model = (await rl.question("")).trim() || modelDefault;
12768
+ const saveDefault = configPath;
12769
+ stdout2.write(`
12770
+ \u4FDD\u5B58\u914D\u7F6E\u5230 [${saveDefault}]\uFF1A`);
12771
+ const saveInput = (await rl.question("")).trim();
12772
+ const finalConfigPath = saveInput ? resolve4(saveInput) : saveDefault;
12773
+ stdout2.write("\n--------------------------------------------\n");
12774
+ stdout2.write(`Provider : ${provider}
12775
+ `);
12776
+ stdout2.write(`Base URL : ${baseUrl}
12777
+ `);
12778
+ stdout2.write(`Model : ${model}
12779
+ `);
12780
+ stdout2.write(`API Key : ${maskKey(apiKey)}
12781
+ `);
12782
+ stdout2.write(`Config : ${finalConfigPath}
12783
+ `);
12784
+ stdout2.write("--------------------------------------------\n");
12785
+ stdout2.write("\u8FDE\u901A\u6027\u6D4B\u8BD5\u4E2D\uFF085s \u8D85\u65F6\uFF09...\n");
12786
+ return await doConnect({ provider, apiKey, baseUrl, model, configPath: finalConfigPath, existing });
12787
+ } finally {
12788
+ rl.close();
12789
+ }
12790
+ }
12791
+ async function doConnect(params) {
12792
+ const { provider, apiKey, baseUrl, model, configPath, existing } = params;
12793
+ const testResult = await testConnectivity({ baseUrl, apiKey, model });
12794
+ if (!testResult.ok) {
12795
+ stderr.write(`
12796
+ [FAIL] \u8FDE\u901A\u6027\u6D4B\u8BD5\u5931\u8D25\uFF1A${testResult.reason}
12797
+ `);
12798
+ if (testResult.detail) stderr.write(` ${testResult.detail}
12799
+ `);
12800
+ stderr.write("\n\u63D0\u793A\uFF1A\n");
12801
+ stderr.write(" \xB7 \u786E\u8BA4 API Key \u6709\u6548\uFF1A\u53BB provider \u63A7\u5236\u53F0\u65B0\u5EFA\u4E00\u4E2A\n");
12802
+ stderr.write(" \xB7 \u786E\u8BA4 baseUrl \u6B63\u786E\uFF08DeepSeek: https://api.deepseek.com\uFF09\n");
12803
+ stderr.write(" \xB7 \u786E\u8BA4\u6A21\u578B\u540D\uFF08DeepSeek: deepseek-flash / deepseek-v4-pro\uFF09\n");
12804
+ return 1;
12805
+ }
12806
+ const preset = PROVIDERS[provider];
12807
+ const envName = preset?.apiKeyEnv ?? provider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY";
12808
+ const envPersisted = persistApiKey(envName, apiKey);
12809
+ process.env[envName] = apiKey;
12810
+ saveConnectionConfig(configPath, existing, {
12811
+ baseUrl,
12812
+ model,
12813
+ envName,
12814
+ ...preset ? { contextWindow: preset.contextWindow, maxOutputTokens: preset.maxOutputTokens } : {}
12815
+ });
12816
+ stdout2.write(`
12817
+ [OK] \u8FDE\u901A\u6027\u6D4B\u8BD5\u901A\u8FC7 \u2705
12818
+ `);
12819
+ stdout2.write(` \u54CD\u5E94\u8017\u65F6: ${testResult.latencyMs}ms
12820
+ `);
12821
+ stdout2.write(`
12822
+ \u914D\u7F6E\u5DF2\u5199\u5165\uFF1A${configPath}
12823
+ `);
12824
+ stdout2.write(`API Key \u6301\u4E45\u5316\uFF1A`);
12825
+ if (envPersisted.ok) {
12826
+ stdout2.write(`\u2705 ${envName}\uFF08\u7528\u6237\u7EA7\u73AF\u5883\u53D8\u91CF\uFF09
12827
+ `);
12828
+ stdout2.write(` \u5F53\u524D\u4F1A\u8BDD\u5DF2\u751F\u6548 \u2705
12829
+ `);
12830
+ } else {
12831
+ stdout2.write(`\u26A0\uFE0F \u9700\u624B\u52A8\u8BBE\u7F6E\uFF1A
12832
+ `);
12833
+ stdout2.write(` ${envPersisted.hint}
12834
+ `);
12835
+ }
12836
+ stdout2.write(`
12837
+ \u73B0\u5728\u53EF\u4EE5\u8DD1\uFF1A
12838
+ `);
12839
+ stdout2.write(` forgex run "\u4F60\u597D\uFF0C\u4ECB\u7ECD\u4E00\u4E0B ForgeX"
12840
+ `);
12841
+ stdout2.write(` forgex doctor
12842
+ `);
12843
+ return 0;
12844
+ }
12845
+
12678
12846
  // apps/cli/src/commands/chat.ts
12679
12847
  async function chatCommand(args, options) {
12680
- const loaded = loadConfig({
12848
+ const configFlag = flagString(args.flags, "config");
12849
+ const readConfig = () => loadConfig({
12681
12850
  cwd: options.cwd,
12682
- ...flagString(args.flags, "config") ? { configPath: flagString(args.flags, "config") } : {}
12851
+ ...configFlag ? { configPath: configFlag } : {}
12683
12852
  });
12853
+ let loaded = readConfig();
12684
12854
  if (!loaded.modelConfigured) {
12685
- throw new Error(
12686
- "\u5C1A\u672A\u914D\u7F6E\u6A21\u578B\u3002\u8BF7\u521B\u5EFA forgex.config.json\uFF08\u53C2\u8003 README\uFF09\u6216\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF FORGEX_BASE_URL / FORGEX_MODEL\u3002"
12687
- );
12855
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
12856
+ if (!interactive) {
12857
+ throw new ForgeError("CONFIG_INVALID", modelSetupHint({ interactive: false }));
12858
+ }
12859
+ stderr2.write("\u5C1A\u672A\u914D\u7F6E\u6A21\u578B\uFF0C\u5148\u8FDB\u5165\u8FDE\u63A5\u5411\u5BFC\uFF08Ctrl+C \u53EF\u53D6\u6D88\uFF09\n\n");
12860
+ const code = await connectCommand(args, { cwd: options.cwd });
12861
+ if (code !== 0) {
12862
+ throw new ForgeError("CONFIG_INVALID", "\u6A21\u578B\u8FDE\u63A5\u672A\u5B8C\u6210\uFF0C\u5DF2\u9000\u51FA\u3002\u7A0D\u540E\u53EF\u91CD\u65B0\u6267\u884C\uFF1Aforgex connect");
12863
+ }
12864
+ loaded = readConfig();
12865
+ if (!loaded.modelConfigured) {
12866
+ throw new ForgeError(
12867
+ "CONFIG_INVALID",
12868
+ `\u8FDE\u63A5\u5411\u5BFC\u6CA1\u6709\u751F\u6210\u53EF\u7528\u7684\u6A21\u578B\u914D\u7F6E\uFF08${loaded.configPath ?? "\u672A\u627E\u5230\u914D\u7F6E\u6587\u4EF6"}\uFF09\uFF0C\u8BF7\u68C0\u67E5\u4FDD\u5B58\u8DEF\u5F84\u540E\u91CD\u8BD5`
12869
+ );
12870
+ }
12688
12871
  }
12689
12872
  const bridge = new ApprovalBridge();
12690
12873
  const runtime = createRuntime({
@@ -12713,18 +12896,15 @@ async function chatCommand(args, options) {
12713
12896
  }
12714
12897
 
12715
12898
  // apps/cli/src/commands/run.ts
12716
- import { createInterface as createInterface3 } from "node:readline/promises";
12717
- import { stdin as stdin2, stdout as stdout2, stderr } from "node:process";
12899
+ import { createInterface as createInterface4 } from "node:readline/promises";
12900
+ import { stdin as stdin3, stdout as stdout3, stderr as stderr3 } from "node:process";
12718
12901
  async function runCommand(args, options) {
12719
12902
  const loaded = loadConfig({
12720
12903
  cwd: options.cwd,
12721
12904
  ...flagString(args.flags, "config") ? { configPath: flagString(args.flags, "config") } : {}
12722
12905
  });
12723
12906
  if (!loaded.modelConfigured) {
12724
- throw new ForgeError(
12725
- "CONFIG_INVALID",
12726
- "\u5C1A\u672A\u914D\u7F6E\u6A21\u578B\u3002\u8BF7\u521B\u5EFA forgex.config.json \u6216\u8BBE\u7F6E FORGEX_BASE_URL / FORGEX_MODEL\u3002"
12727
- );
12907
+ throw new ForgeError("CONFIG_INVALID", modelSetupHint({ interactive: false }));
12728
12908
  }
12729
12909
  const prompt = (args.positionals.join(" ").trim() || await readStdin()).trim();
12730
12910
  if (!prompt) {
@@ -12732,8 +12912,8 @@ async function runCommand(args, options) {
12732
12912
  }
12733
12913
  const json = flagBool(args.flags, "json");
12734
12914
  const autoApprove = flagBool(args.flags, "yes");
12735
- const interactive = Boolean(stdin2.isTTY) && !json;
12736
- const rl = interactive ? createInterface3({ input: stdin2, output: stderr, terminal: true }) : null;
12915
+ const interactive = Boolean(stdin3.isTTY) && !json;
12916
+ const rl = interactive ? createInterface4({ input: stdin3, output: stderr3, terminal: true }) : null;
12737
12917
  let approvalHandler;
12738
12918
  if (autoApprove) {
12739
12919
  approvalHandler = () => true;
@@ -12759,22 +12939,22 @@ async function runCommand(args, options) {
12759
12939
  switch (event.type) {
12760
12940
  case "assistant:delta":
12761
12941
  sawDelta = true;
12762
- stdout2.write(event.text);
12942
+ stdout3.write(event.text);
12763
12943
  break;
12764
12944
  case "tool:start":
12765
- stderr.write(`[\u5DE5\u5177] \u8C03\u7528 ${event.name}
12945
+ stderr3.write(`[\u5DE5\u5177] \u8C03\u7528 ${event.name}
12766
12946
  `);
12767
12947
  break;
12768
12948
  case "tool:end":
12769
- stderr.write(`[\u5DE5\u5177] ${event.name} ${event.result.ok ? "\u6210\u529F" : "\u5931\u8D25"}\uFF1A${event.result.summary}
12949
+ stderr3.write(`[\u5DE5\u5177] ${event.name} ${event.result.ok ? "\u6210\u529F" : "\u5931\u8D25"}\uFF1A${event.result.summary}
12770
12950
  `);
12771
12951
  break;
12772
12952
  case "notice":
12773
- stderr.write(`[\u63D0\u793A] ${event.message}
12953
+ stderr3.write(`[\u63D0\u793A] ${event.message}
12774
12954
  `);
12775
12955
  break;
12776
12956
  case "approval:resolved":
12777
- stderr.write(`[\u5BA1\u6279] ${event.decision}
12957
+ stderr3.write(`[\u5BA1\u6279] ${event.decision}
12778
12958
  `);
12779
12959
  break;
12780
12960
  default:
@@ -12783,10 +12963,10 @@ async function runCommand(args, options) {
12783
12963
  });
12784
12964
  try {
12785
12965
  const result = await runtime.agent.run(prompt, {});
12786
- if (!json && !sawDelta && result.text) stdout2.write(`${result.text}
12966
+ if (!json && !sawDelta && result.text) stdout3.write(`${result.text}
12787
12967
  `);
12788
12968
  if (json) {
12789
- stdout2.write(
12969
+ stdout3.write(
12790
12970
  `${JSON.stringify(
12791
12971
  {
12792
12972
  sessionId: result.sessionId,
@@ -12801,7 +12981,7 @@ async function runCommand(args, options) {
12801
12981
  `
12802
12982
  );
12803
12983
  } else {
12804
- stderr.write(
12984
+ stderr3.write(
12805
12985
  `[\u5B8C\u6210] \u7ED3\u675F\u539F\u56E0=${result.reason} \u7528\u65F6=${result.metrics.totalMs}ms \u6A21\u578B=${result.metrics.modelCalls} \u6B21 \u5DE5\u5177=${result.metrics.toolCalls} \u6B21 tokens=${result.metrics.totalTokens}
12806
12986
  `
12807
12987
  );
@@ -12814,9 +12994,9 @@ async function runCommand(args, options) {
12814
12994
  }
12815
12995
  }
12816
12996
  async function readStdin() {
12817
- if (stdin2.isTTY) return "";
12997
+ if (stdin3.isTTY) return "";
12818
12998
  const chunks = [];
12819
- for await (const chunk of stdin2) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
12999
+ for await (const chunk of stdin3) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
12820
13000
  return Buffer.concat(chunks).toString("utf8");
12821
13001
  }
12822
13002
 
@@ -12825,7 +13005,7 @@ import { execFile as execFile3 } from "node:child_process";
12825
13005
  import { accessSync, constants, existsSync as existsSync4 } from "node:fs";
12826
13006
  import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
12827
13007
  import { dirname as dirname5 } from "node:path";
12828
- import { stdout as stdout3 } from "node:process";
13008
+ import { stdout as stdout4 } from "node:process";
12829
13009
  async function doctorCommand(args, options) {
12830
13010
  const checks = [];
12831
13011
  const full = flagBool(args.flags, "full");
@@ -12946,14 +13126,14 @@ async function doctorCommand(args, options) {
12946
13126
  detail: `mode=${loaded.config.security.mode} \u5199\u5BA1\u6279=${loaded.config.security.requireApprovalForWrite} \u6267\u884C\u5BA1\u6279=${loaded.config.security.requireApprovalForExecute}`
12947
13127
  });
12948
13128
  }
12949
- stdout3.write("ForgeX \u73AF\u5883\u81EA\u68C0\n");
13129
+ stdout4.write("ForgeX \u73AF\u5883\u81EA\u68C0\n");
12950
13130
  for (const check of checks) {
12951
- stdout3.write(`[${label(check.status)}] ${check.name}: ${check.detail}
13131
+ stdout4.write(`[${label(check.status)}] ${check.name}: ${check.detail}
12952
13132
  `);
12953
13133
  }
12954
13134
  const failed = checks.filter((check) => check.status === "fail").length;
12955
13135
  const warned = checks.filter((check) => check.status === "warn").length;
12956
- stdout3.write(`
13136
+ stdout4.write(`
12957
13137
  \u7ED3\u679C\uFF1A${checks.length} \u9879\u68C0\u67E5\uFF0C${failed} \u9879\u5931\u8D25\uFF0C${warned} \u9879\u8B66\u544A
12958
13138
  `);
12959
13139
  return failed > 0 ? 1 : 0;
@@ -12986,21 +13166,21 @@ function formatBytes2(bytes) {
12986
13166
  }
12987
13167
 
12988
13168
  // apps/cli/src/commands/tools.ts
12989
- import { stdout as stdout4 } from "node:process";
13169
+ import { stdout as stdout5 } from "node:process";
12990
13170
  function toolsCommand() {
12991
13171
  const registry = new ToolRegistry(createBuiltinTools());
12992
13172
  const tools = registry.list();
12993
- stdout4.write(`ForgeX \u5185\u7F6E\u5DE5\u5177\uFF08${tools.length} \u4E2A\uFF09
13173
+ stdout5.write(`ForgeX \u5185\u7F6E\u5DE5\u5177\uFF08${tools.length} \u4E2A\uFF09
12994
13174
 
12995
13175
  `);
12996
13176
  for (const tool of tools) {
12997
13177
  const tags = tool.tags && tool.tags.length > 0 ? ` \u6807\u7B7E=${tool.tags.join(",")}` : "";
12998
- stdout4.write(`- ${tool.name} [${tool.riskLevel}] \u8D85\u65F6=${tool.timeoutMs}ms \u8F93\u51FA\u4E0A\u9650=${tool.maxOutputBytes}B${tags}
13178
+ stdout5.write(`- ${tool.name} [${tool.riskLevel}] \u8D85\u65F6=${tool.timeoutMs}ms \u8F93\u51FA\u4E0A\u9650=${tool.maxOutputBytes}B${tags}
12999
13179
  `);
13000
- stdout4.write(` ${tool.description.split("\n")[0]}
13180
+ stdout5.write(` ${tool.description.split("\n")[0]}
13001
13181
  `);
13002
13182
  }
13003
- stdout4.write(
13183
+ stdout5.write(
13004
13184
  "\n\u8BF4\u660E\uFF1A\u98CE\u9669\u7B49\u7EA7\u51B3\u5B9A\u9ED8\u8BA4\u6743\u9650\u7B56\u7565\uFF1Bexecute \u7EA7\u547D\u4EE4\u9ED8\u8BA4\u9700\u8981\u4EBA\u5DE5\u5BA1\u6279\uFF0Cprivileged \u7EA7\u9ED8\u8BA4\u62D2\u7EDD\u3002\n"
13005
13185
  );
13006
13186
  return 0;
@@ -13008,7 +13188,7 @@ function toolsCommand() {
13008
13188
 
13009
13189
  // apps/cli/src/commands/sessions.ts
13010
13190
  import { existsSync as existsSync5 } from "node:fs";
13011
- import { stdout as stdout5 } from "node:process";
13191
+ import { stdout as stdout6 } from "node:process";
13012
13192
  function sessionsCommand(args, options) {
13013
13193
  const loaded = loadConfig({
13014
13194
  cwd: options.cwd,
@@ -13016,7 +13196,7 @@ function sessionsCommand(args, options) {
13016
13196
  });
13017
13197
  const dbPath = loaded.config.session.dbPath;
13018
13198
  if (!existsSync5(dbPath)) {
13019
- stdout5.write(`\u4F1A\u8BDD\u6570\u636E\u5E93\u5C1A\u672A\u521B\u5EFA: ${dbPath}
13199
+ stdout6.write(`\u4F1A\u8BDD\u6570\u636E\u5E93\u5C1A\u672A\u521B\u5EFA: ${dbPath}
13020
13200
  `);
13021
13201
  return 0;
13022
13202
  }
@@ -13025,18 +13205,18 @@ function sessionsCommand(args, options) {
13025
13205
  try {
13026
13206
  const sessions = store.listSessions(limit);
13027
13207
  if (sessions.length === 0) {
13028
- stdout5.write("\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55\n");
13208
+ stdout6.write("\u6682\u65E0\u4F1A\u8BDD\u8BB0\u5F55\n");
13029
13209
  return 0;
13030
13210
  }
13031
- stdout5.write(`\u6700\u8FD1 ${sessions.length} \u4E2A\u4F1A\u8BDD\uFF08\u6570\u636E\u5E93: ${dbPath}\uFF09
13211
+ stdout6.write(`\u6700\u8FD1 ${sessions.length} \u4E2A\u4F1A\u8BDD\uFF08\u6570\u636E\u5E93: ${dbPath}\uFF09
13032
13212
 
13033
13213
  `);
13034
13214
  for (const session of sessions) {
13035
13215
  const title = session.title ?? "(\u672A\u547D\u540D)";
13036
- stdout5.write(`${session.id} ${session.updatedAt} ${session.model} ${title}
13216
+ stdout6.write(`${session.id} ${session.updatedAt} ${session.model} ${title}
13037
13217
  `);
13038
13218
  }
13039
- stdout5.write('\n\u4F7F\u7528 forgex chat --session <id> \u6062\u590D\u4F1A\u8BDD\uFF1Bforgex run --session <id> "..." \u7EE7\u7EED\u4EFB\u52A1\u3002\n');
13219
+ stdout6.write('\n\u4F7F\u7528 forgex chat --session <id> \u6062\u590D\u4F1A\u8BDD\uFF1Bforgex run --session <id> "..." \u7EE7\u7EED\u4EFB\u52A1\u3002\n');
13040
13220
  return 0;
13041
13221
  } finally {
13042
13222
  store.close();
@@ -13044,14 +13224,14 @@ function sessionsCommand(args, options) {
13044
13224
  }
13045
13225
 
13046
13226
  // apps/cli/src/commands/config.ts
13047
- import { stdout as stdout6 } from "node:process";
13227
+ import { stdout as stdout7 } from "node:process";
13048
13228
  function configCommand(args, options) {
13049
13229
  const loaded = loadConfig({
13050
13230
  cwd: options.cwd,
13051
13231
  ...flagString(args.flags, "config") ? { configPath: flagString(args.flags, "config") } : {}
13052
13232
  });
13053
13233
  const { apiKey, ...safeModel } = loaded.config.model;
13054
- stdout6.write(
13234
+ stdout7.write(
13055
13235
  `${JSON.stringify(
13056
13236
  {
13057
13237
  configPath: loaded.configPath,
@@ -13068,132 +13248,8 @@ function configCommand(args, options) {
13068
13248
  `
13069
13249
  );
13070
13250
  if (!loaded.modelConfigured) {
13071
- stdout6.write("\n[warn] \u5C1A\u672A\u914D\u7F6E\u6A21\u578B\uFF1A\u8BF7\u8BBE\u7F6E forgex.config.json \u6216 FORGEX_BASE_URL / FORGEX_MODEL\u3002\n");
13072
- }
13073
- return 0;
13074
- }
13075
-
13076
- // apps/cli/src/commands/connect.ts
13077
- import { createInterface as createInterface4 } from "node:readline/promises";
13078
- import { resolve as resolve4 } from "node:path";
13079
- import { stderr as stderr2, stdin as stdin3, stdout as stdout7 } from "node:process";
13080
- async function connectCommand(args, _options) {
13081
- const isInteractive = Boolean(stdin3.isTTY);
13082
- const configPath = defaultConfigPath();
13083
- const existing = readExistingConfig(configPath);
13084
- if (!isInteractive) {
13085
- const provider = flagString(args.flags, "provider") ?? "custom";
13086
- const apiKey = flagString(args.flags, "api-key") ?? "";
13087
- const preset = PROVIDERS[provider.toLowerCase()];
13088
- const baseUrl = flagString(args.flags, "base-url") ?? preset?.defaultBaseUrl ?? "";
13089
- const model = flagString(args.flags, "model") ?? preset?.defaultModel ?? "";
13090
- if (!apiKey) {
13091
- stderr2.write("[connect] --api-key \u5728\u975E\u4EA4\u4E92\u6A21\u5F0F\u4E0B\u5FC5\u586B\n");
13092
- return 2;
13093
- }
13094
- return await doConnect({ provider, apiKey, baseUrl, model, configPath, existing });
13251
+ stdout7.write("\n[warn] \u5C1A\u672A\u914D\u7F6E\u6A21\u578B\uFF1A\u8BF7\u8BBE\u7F6E forgex.config.json \u6216 FORGEX_BASE_URL / FORGEX_MODEL\u3002\n");
13095
13252
  }
13096
- stdout7.write("ForgeX Connect \u2014 \u8FDE\u63A5\u4F60\u7684\u6A21\u578B\u63D0\u4F9B\u65B9\n\n");
13097
- const rl = createInterface4({ input: stdin3, output: stderr2 });
13098
- try {
13099
- stdout7.write("\u9009\u62E9\u6A21\u578B\u63D0\u4F9B\u65B9\uFF08\u8F93\u5165\u7F16\u53F7\u6216\u540D\u79F0\uFF09\uFF1A\n");
13100
- PROVIDERS_KEYS.forEach((key, i) => {
13101
- const p = PROVIDERS[key];
13102
- stdout7.write(` ${i + 1}. ${p.name} (${p.defaultBaseUrl})
13103
- `);
13104
- });
13105
- stdout7.write("\n> ");
13106
- const providerInput = (await rl.question("")).trim();
13107
- const provider = resolveProvider(providerInput);
13108
- const preset = PROVIDERS[provider];
13109
- const baseUrlDefault = preset?.defaultBaseUrl ?? existing.model.baseUrl;
13110
- stdout7.write(`baseUrl [${baseUrlDefault}]: `);
13111
- const baseUrl = (await rl.question("")).trim() || baseUrlDefault;
13112
- stdout7.write("\nAPI Key\uFF08\u8F93\u5165\u4E0D\u4F1A\u88AB\u9690\u85CF\uFF0C\u7C98\u8D34\u540E\u6309\u56DE\u8F66\uFF09: ");
13113
- const apiKey = (await rl.question("")).trim();
13114
- if (!apiKey) {
13115
- stderr2.write("[connect] API Key \u4E0D\u80FD\u4E3A\u7A7A\n");
13116
- return 2;
13117
- }
13118
- const modelDefault = preset?.defaultModel ?? existing.model.model;
13119
- stdout7.write(`
13120
- \u6A21\u578B\u540D [${modelDefault}]: `);
13121
- const model = (await rl.question("")).trim() || modelDefault;
13122
- const saveDefault = configPath;
13123
- stdout7.write(`
13124
- \u4FDD\u5B58\u914D\u7F6E\u5230 [${saveDefault}]\uFF1A`);
13125
- const saveInput = (await rl.question("")).trim();
13126
- const finalConfigPath = saveInput ? resolve4(saveInput) : saveDefault;
13127
- stdout7.write("\n--------------------------------------------\n");
13128
- stdout7.write(`Provider : ${provider}
13129
- `);
13130
- stdout7.write(`Base URL : ${baseUrl}
13131
- `);
13132
- stdout7.write(`Model : ${model}
13133
- `);
13134
- stdout7.write(`API Key : ${maskKey(apiKey)}
13135
- `);
13136
- stdout7.write(`Config : ${finalConfigPath}
13137
- `);
13138
- stdout7.write("--------------------------------------------\n");
13139
- stdout7.write("\u8FDE\u901A\u6027\u6D4B\u8BD5\u4E2D\uFF085s \u8D85\u65F6\uFF09...\n");
13140
- return await doConnect({ provider, apiKey, baseUrl, model, configPath: finalConfigPath, existing });
13141
- } finally {
13142
- rl.close();
13143
- }
13144
- }
13145
- async function doConnect(params) {
13146
- const { provider, apiKey, baseUrl, model, configPath, existing } = params;
13147
- const testResult = await testConnectivity({ baseUrl, apiKey, model });
13148
- if (!testResult.ok) {
13149
- stderr2.write(`
13150
- [FAIL] \u8FDE\u901A\u6027\u6D4B\u8BD5\u5931\u8D25\uFF1A${testResult.reason}
13151
- `);
13152
- if (testResult.detail) stderr2.write(` ${testResult.detail}
13153
- `);
13154
- stderr2.write("\n\u63D0\u793A\uFF1A\n");
13155
- stderr2.write(" \xB7 \u786E\u8BA4 API Key \u6709\u6548\uFF1A\u53BB provider \u63A7\u5236\u53F0\u65B0\u5EFA\u4E00\u4E2A\n");
13156
- stderr2.write(" \xB7 \u786E\u8BA4 baseUrl \u6B63\u786E\uFF08DeepSeek: https://api.deepseek.com\uFF09\n");
13157
- stderr2.write(" \xB7 \u786E\u8BA4\u6A21\u578B\u540D\uFF08DeepSeek: deepseek-flash / deepseek-v4-pro\uFF09\n");
13158
- return 1;
13159
- }
13160
- const preset = PROVIDERS[provider];
13161
- const envName = preset?.apiKeyEnv ?? provider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY";
13162
- const envPersisted = persistApiKey(envName, apiKey);
13163
- process.env[envName] = apiKey;
13164
- saveConnectionConfig(configPath, existing, {
13165
- baseUrl,
13166
- model,
13167
- envName,
13168
- ...preset ? { contextWindow: preset.contextWindow, maxOutputTokens: preset.maxOutputTokens } : {}
13169
- });
13170
- stdout7.write(`
13171
- [OK] \u8FDE\u901A\u6027\u6D4B\u8BD5\u901A\u8FC7 \u2705
13172
- `);
13173
- stdout7.write(` \u54CD\u5E94\u8017\u65F6: ${testResult.latencyMs}ms
13174
- `);
13175
- stdout7.write(`
13176
- \u914D\u7F6E\u5DF2\u5199\u5165\uFF1A${configPath}
13177
- `);
13178
- stdout7.write(`API Key \u6301\u4E45\u5316\uFF1A`);
13179
- if (envPersisted.ok) {
13180
- stdout7.write(`\u2705 ${envName}\uFF08\u7528\u6237\u7EA7\u73AF\u5883\u53D8\u91CF\uFF09
13181
- `);
13182
- stdout7.write(` \u5F53\u524D\u4F1A\u8BDD\u5DF2\u751F\u6548 \u2705
13183
- `);
13184
- } else {
13185
- stdout7.write(`\u26A0\uFE0F \u9700\u624B\u52A8\u8BBE\u7F6E\uFF1A
13186
- `);
13187
- stdout7.write(` ${envPersisted.hint}
13188
- `);
13189
- }
13190
- stdout7.write(`
13191
- \u73B0\u5728\u53EF\u4EE5\u8DD1\uFF1A
13192
- `);
13193
- stdout7.write(` forgex run "\u4F60\u597D\uFF0C\u4ECB\u7ECD\u4E00\u4E0B ForgeX"
13194
- `);
13195
- stdout7.write(` forgex doctor
13196
- `);
13197
13253
  return 0;
13198
13254
  }
13199
13255
 
@@ -13203,7 +13259,7 @@ async function main(argv) {
13203
13259
  const unknown = unknownFlags(args.flags);
13204
13260
  if (unknown.length > 0) {
13205
13261
  const rendered = unknown.map((name) => name.length === 1 ? `-${name}` : `--${name}`).join(", ");
13206
- stderr3.write(`\u672A\u77E5\u53C2\u6570: ${rendered}
13262
+ stderr4.write(`\u672A\u77E5\u53C2\u6570: ${rendered}
13207
13263
 
13208
13264
  `);
13209
13265
  printHelp2();
@@ -13212,7 +13268,7 @@ async function main(argv) {
13212
13268
  const missingValue = flagsMissingValue(args.flags);
13213
13269
  if (missingValue.length > 0) {
13214
13270
  const rendered = missingValue.map((name) => `--${name}`).join(", ");
13215
- stderr3.write(`\u53C2\u6570\u7F3A\u5C11\u53D6\u503C: ${rendered}
13271
+ stderr4.write(`\u53C2\u6570\u7F3A\u5C11\u53D6\u503C: ${rendered}
13216
13272
 
13217
13273
  `);
13218
13274
  printHelp2();
@@ -13248,7 +13304,7 @@ async function main(argv) {
13248
13304
  case "connect":
13249
13305
  return await connectCommand(args, { cwd });
13250
13306
  default:
13251
- stderr3.write(`\u672A\u77E5\u547D\u4EE4: ${args.command}
13307
+ stderr4.write(`\u672A\u77E5\u547D\u4EE4: ${args.command}
13252
13308
 
13253
13309
  `);
13254
13310
  printHelp2();
@@ -13295,7 +13351,7 @@ function formatError(err) {
13295
13351
  void main(process.argv.slice(2)).then((code) => {
13296
13352
  process.exitCode = code;
13297
13353
  }).catch((err) => {
13298
- stderr3.write(`[\u9519\u8BEF] ${formatError(err)}
13354
+ stderr4.write(`[\u9519\u8BEF] ${formatError(err)}
13299
13355
  `);
13300
13356
  process.exitCode = 1;
13301
13357
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forgex-agent",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "ForgeX - TUI-first coding & DevOps agent runtime",
5
5
  "license": "MIT",
6
6
  "type": "module",