@zhongqian97-code/ecode 0.5.25 → 0.5.27

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/index.js +29 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -108,6 +108,24 @@ function loadConfig() {
108
108
  defaultProvider: fileConfig.defaultProvider
109
109
  };
110
110
  }
111
+ function saveConfig(partial) {
112
+ const configPath = join(homedir(), ".ecode", "config.json");
113
+ const configDir = join(homedir(), ".ecode");
114
+ mkdirSync(configDir, { recursive: true });
115
+ let existing = {};
116
+ if (existsSync(configPath)) {
117
+ try {
118
+ const raw = readFileSync(configPath, "utf-8");
119
+ existing = JSON.parse(raw);
120
+ } catch (err) {
121
+ const msg = err instanceof Error ? err.message : String(err);
122
+ process.stderr.write(`[ecode] warning: ${configPath} parse failed (${msg}), overwriting with new config
123
+ `);
124
+ }
125
+ }
126
+ const merged = { ...existing, ...partial };
127
+ writeFileSync(configPath, JSON.stringify(merged, null, 2), "utf-8");
128
+ }
111
129
 
112
130
  // src/ui/App.tsx
113
131
  import { useState as useState3, useCallback, useRef as useRef2, useEffect as useEffect3, useMemo } from "react";
@@ -6088,6 +6106,9 @@ function generateAdminHtml(version2) {
6088
6106
  }
6089
6107
  } catch (e) {
6090
6108
  showToast('\u521B\u5EFA\u4F1A\u8BDD\u5931\u8D25: ' + e.message, 'error');
6109
+ if (e.message && e.message.includes('API Key')) {
6110
+ openConfigModal(true);
6111
+ }
6091
6112
  }
6092
6113
  });
6093
6114
 
@@ -6134,7 +6155,7 @@ function generateAdminHtml(version2) {
6134
6155
  });
6135
6156
 
6136
6157
  // \u2500\u2500 \u914D\u7F6E\u6A21\u6001\u6846 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
6137
- document.getElementById('config-btn').addEventListener('click', async () => {
6158
+ async function openConfigModal(focusApiKey) {
6138
6159
  try {
6139
6160
  const data = await apiFetch('/api/config');
6140
6161
  document.getElementById('cfg-model').value = data.model || '';
@@ -6145,7 +6166,12 @@ function generateAdminHtml(version2) {
6145
6166
  showToast('\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25: ' + e.message, 'error');
6146
6167
  }
6147
6168
  document.getElementById('config-modal').classList.add('open');
6148
- });
6169
+ if (focusApiKey) {
6170
+ setTimeout(() => document.getElementById('cfg-apikey').focus(), 50);
6171
+ }
6172
+ }
6173
+
6174
+ document.getElementById('config-btn').addEventListener('click', () => openConfigModal(false));
6149
6175
 
6150
6176
  document.getElementById('cancel-config').addEventListener('click', () => {
6151
6177
  document.getElementById('config-modal').classList.remove('open');
@@ -6644,7 +6670,7 @@ async function buildServer(opts) {
6644
6670
  version: opts.version
6645
6671
  });
6646
6672
  await app.register(sessionsRoutes, { config: opts.config, manager: opts.manager });
6647
- await app.register(configRoutes, { config: opts.config });
6673
+ await app.register(configRoutes, { config: opts.config, save: saveConfig });
6648
6674
  await app.register(automationRoutes, { config: opts.config });
6649
6675
  await app.register(chatRoutes, { config: opts.config, manager: opts.manager });
6650
6676
  await app.register(systemRoutes, { version: opts.version });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhongqian97-code/ecode",
3
- "version": "0.5.25",
3
+ "version": "0.5.27",
4
4
  "description": "A minimal Claude Code clone with REPL interface and bash tool calling",
5
5
  "type": "module",
6
6
  "author": "zhongqian97-code",