ework-web 0.2.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/config.ts CHANGED
@@ -107,7 +107,7 @@ export const SETTINGS_GROUPS: SettingGroup[] = [
107
107
  {
108
108
  title: "AI 模型",
109
109
  fields: [
110
- { key: "defaultModel", label: "默认模型(空 = 用 opencode 自己的默认)", type: "model" },
110
+ { key: "defaultModel", label: "默认模型(空 = 用 opencode.json;注意环境变量可能污染,建议点下方刷新自动选一个)", type: "model" },
111
111
  ],
112
112
  },
113
113
  {
package/src/index.ts CHANGED
@@ -630,6 +630,18 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
630
630
  if (!ctx.user || ctx.user.is_admin !== 1) return html(errorPage("403", "需要管理员"), 403);
631
631
  const ids = await opencode.listModels();
632
632
  replaceCachedModels(ids);
633
+ // M-1: pin a default model so opencode never falls back to env vars. The
634
+ // previous empty default meant the daemon omitted --model and opencode
635
+ // picked the model from leaked env (e.g. OPENCODE_MODEL / a provider
636
+ // default) — silent and wrong. Pick the first available model when none
637
+ // is configured; the operator can change or clear it on /settings.
638
+ if (!cfg.defaultModel) {
639
+ const picked = ids.find((id) => typeof id === "string" && id.length > 0);
640
+ if (picked) {
641
+ setConfig("defaultModel", picked);
642
+ Object.assign(cfg, loadConfig());
643
+ }
644
+ }
633
645
  const rh = new Headers(SEC_HEADERS);
634
646
  rh.set("location", "/settings?saved=1");
635
647
  return new Response(null, { status: 303, headers: rh });
@@ -18,7 +18,7 @@ export function buildProjectModelPage(
18
18
  const effective = cur || globalDefault;
19
19
  const effectiveLine = effective
20
20
  ? `<p class="hint">实际生效:<code>${escapeHtml(effective)}</code>${cur ? "" : " (继承全局默认)"}</p>`
21
- : `<p class="hint">实际生效:<em>未配置</em> — daemon 不会加 <code>--model</code>,opencode 按自己的 opencode.json + 环境变量选。</p>`;
21
+ : `<p class="hint">实际生效:<em>未配置</em> — daemon 不会加 <code>--model</code>,opencode opencode.json 选;注意环境变量(如 <code>OPENCODE_MODEL</code>)可能污染。建议去 <a href="/settings">全局设置</a> 点「刷新 opencode 模型列表」自动选一个默认。</p>`;
22
22
  // Empty cache → free-text input (same degradation as global settings).
23
23
  const field = models.length === 0
24
24
  ? `<input type="text" name="model" value="${escapeAttr(cur)}" placeholder="provider/model(去 /settings 刷新模型列表)">`