engine7 7.1.45 → 7.1.47

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 (2) hide show
  1. package/dist/cli.mjs +34 -3
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -2157,7 +2157,7 @@ function generateConfig(v) {
2157
2157
  config.models.providers[v.primaryProvider] = {
2158
2158
  baseUrl: (v.customBaseUrl || "").trim(),
2159
2159
  api: "anthropic",
2160
- apiKey: v.primaryApiKey.trim(),
2160
+ apiKey: "env:" + v.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY",
2161
2161
  models: [
2162
2162
  { id: v.customModelId, name: v.customModelId, reasoning: false, input: ["text"], contextWindow: 2e5, maxTokens: 8192 }
2163
2163
  ]
@@ -2170,7 +2170,7 @@ function generateConfig(v) {
2170
2170
  }
2171
2171
  config.models.providers[v.primaryProvider] = {
2172
2172
  ...def,
2173
- apiKey: v.primaryApiKey.trim(),
2173
+ apiKey: "env:" + v.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY",
2174
2174
  ...def.baseUrl ? { baseUrl: def.baseUrl.trim() } : {}
2175
2175
  };
2176
2176
  }
@@ -2344,7 +2344,21 @@ async function main() {
2344
2344
  if (args[i] === "--state-dir" && args[i + 1]) stateDir = args[++i].trim();
2345
2345
  else if (args[i] === "--config" && args[i + 1]) configName = args[++i].trim();
2346
2346
  }
2347
- if (!stateDir) stateDir = path3.resolve(process.cwd());
2347
+ if (!stateDir) {
2348
+ const cwd = path3.resolve(process.cwd());
2349
+ if (fs3.existsSync(path3.join(cwd, "configs"))) {
2350
+ stateDir = cwd;
2351
+ } else {
2352
+ const pointer = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7.json");
2353
+ if (fs3.existsSync(pointer)) {
2354
+ try {
2355
+ stateDir = JSON.parse(fs3.readFileSync(pointer, "utf8")).stateDir || "";
2356
+ } catch {
2357
+ }
2358
+ }
2359
+ if (!stateDir) stateDir = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
2360
+ }
2361
+ }
2348
2362
  if (!target && !isLegacyAddchannel) {
2349
2363
  console.log("\u{1F527} engine7 reconfig \u2014 \u91CD\u65B0\u914D\u7F6E\u5DF2\u88C5\u7684 agent");
2350
2364
  console.log(" \u7528\u6CD5: engine7 reconfig <\u76EE\u6807>");
@@ -3111,6 +3125,23 @@ WantedBy=default.target`;
3111
3125
  } else {
3112
3126
  console.log("\n\u{1F4E6} \u6B63\u5728\u521B\u5EFA\u76EE\u5F55\u548C\u6587\u4EF6...\n");
3113
3127
  execute(tree);
3128
+ if (values.primaryApiKey && values.primaryApiKey.trim()) {
3129
+ const envName = values.primaryProvider.toUpperCase().replace(/[^A-Z0-9_]/g, "_") + "_API_KEY";
3130
+ const secretsDir = path3.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7-secrets");
3131
+ if (!fs3.existsSync(secretsDir)) fs3.mkdirSync(secretsDir, { recursive: true });
3132
+ const envFile = path3.join(secretsDir, "main7.env");
3133
+ let envContent = "";
3134
+ if (fs3.existsSync(envFile)) envContent = fs3.readFileSync(envFile, "utf8");
3135
+ const lines = envContent.split("\n").filter((l) => l && !l.startsWith(envName + "="));
3136
+ lines.push(envName + "=" + values.primaryApiKey.trim());
3137
+ fs3.writeFileSync(envFile, lines.join("\n") + "\n", "utf8");
3138
+ try {
3139
+ fs3.chmodSync(envFile, 384);
3140
+ } catch {
3141
+ }
3142
+ console.log("\u{1F511} API key \u5DF2\u5B58\u5165: " + envFile);
3143
+ console.log(" config \u91CC\u53EA\u6709 env:" + envName + " \u5360\u4F4D\u7B26\uFF0C\u660E\u6587\u4E0D\u843D config");
3144
+ }
3114
3145
  const skillsSrc = findTemplateDir("skills");
3115
3146
  if (skillsSrc) {
3116
3147
  const skillsDest = path3.join(opts.stateDir, "workspace", "skills");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.1.45",
3
+ "version": "7.1.47",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — 给助手一个家 / A home for your AI assistant",
6
6
  "main": "dist/main.mjs",