JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: support /config theme and hidden /session
huanggawa42414c94a563
diff --git "a/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md" "b/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"index cbe4eb674a..5b8dd5402a 100644--- "a/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"+++ "b/docs/zh/TUI\344\275\277\347\224\250\346\214\207\345\215\227.md"@@ -77,7 +77,6 @@| `/plan` | - | 进入当前模式族的 plan 子模式,或发送规划请求 | `/plan`、`/plan open`、`/plan 迁移步骤` | 非 `team` || `/rename` | - | 查看/重命名/清空当前会话标题 | `/rename`、`/rename 标题`、`/rename clear` | 全部 || `/resume` | `/continue` | 列出或恢复历史会话;无参 `/resume` 与 `/continue` 在 TUI 中可打开交互列表(见下) | `/resume list`、`/resume <id>` | 全部 |-| `/session` | `/remote`, `/sessions` | 查看远程会话 URL、二维码等(`/sessions` 为别名,与 `/session` 相同) | `/session` | 全部 || `/skills` | - | 技能与市场源管理 | `/skills`、`/skills install ...` | 全部 || `/teamskills` | - | TeamSkills Hub(初始化、校验、打包、搜索、安装等) | `/teamskills list` | 全部 || `/model` | - | 查看/新增/切换模型 | `/model`、`/model add name k=v` | 全部 |diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/config.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/config.tsindex 66282ca6d0..7cdb5323c5 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/config.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/config.ts@@ -1,5 +1,6 @@import { addError, addInfo, extractObject, formatValue } from "../helpers.js";import { CommandKind, type CommandContext, type SlashCommand } from "../types.js";+import type { ThemeName } from "../../../ui/theme.js";const COMPLETION_SCHEMA_TTL_MS = 30_000;let cachedSchemaKeys: string[] | null = null;@@ -17,6 +18,35 @@ export interface ConfigItemSchema {source: "env" | "yaml";}+const FRONTEND_SCHEMA_KEYS = new Set(["theme"]);++const FRONTEND_SCHEMAS: ConfigItemSchema[] = [+ {+ key: "theme",+ label: "主题",+ group: "Theme",+ type: "select",+ options: ["dark", "light"],+ default: "default",+ source: "yaml",+ },+];++function getFrontendSchema(key: string): ConfigItemSchema | undefined {+ return FRONTEND_SCHEMAS.find((s) => s.key === key);+}++function getFrontendValue(ctx: CommandContext, key: string): string {+ if (key === "theme") return ctx.themeName;+ return "";+}++function applyFrontendConfig(ctx: CommandContext, key: string, value: string): void {+ if (key === "theme") {+ ctx.setThemeName(value as ThemeName);+ }+}+function flattenConfigEntries(value: unknown,prefix = "",@@ -182,6 +212,17 @@ async function showConfigOverview(ctx: CommandContext): Promise<void> {}}+ // Theme section (frontend-only, not from backend schema)+ items.push({ label: "── Theme ──", description: "" });+ for (const schema of FRONTEND_SCHEMAS) {+ const currentValue = getFrontendValue(ctx, schema.key);+ items.push({+ label: schema.key,+ value: currentValue,+ description: schema.description ?? schema.label,+ });+ }+ctx.addItem(addInfo(ctx.sessionId, "Configuration", "c", {view: "kv",@@ -208,16 +249,16 @@ export function createConfigCommand(): SlashCommand {const subCommands = ["get", "set", "list", "edit", "reset"];const now = Date.now();if (cachedSchemaKeys && now - cachedSchemaAt < COMPLETION_SCHEMA_TTL_MS) {- return [...subCommands, ...cachedSchemaKeys];+ return [...subCommands, ...cachedSchemaKeys, ...FRONTEND_SCHEMA_KEYS];}try {const payload = await ctx.request<{ schema?: ConfigItemSchema[] }>("config.get", {});const configKeys = (payload.schema ?? []).map((item) => item.key);cachedSchemaKeys = configKeys;cachedSchemaAt = now;- return [...subCommands, ...configKeys];+ return [...subCommands, ...configKeys, ...FRONTEND_SCHEMA_KEYS];} catch {- return [...subCommands];+ return [...subCommands, ...FRONTEND_SCHEMA_KEYS];}},subCommands: [@@ -229,6 +270,17 @@ export function createConfigCommand(): SlashCommand {takesArgs: true,action: async (ctx, args) => {const key = args.trim();+ // Handle frontend-only config keys+ if (key && FRONTEND_SCHEMA_KEYS.has(key)) {+ ctx.addItem(+ addInfo(ctx.sessionId, `Config: ${key}`, "c", {+ view: "kv",+ title: `Config · ${key}`,+ items: [{ label: key, value: getFrontendValue(ctx, key) }],+ }),+ );+ return;+ }let payload: unknown;try {payload = await ctx.request("config.get", key ? { key } : {});@@ -253,6 +305,44 @@ export function createConfigCommand(): SlashCommand {ctx.addItem(addError(ctx.sessionId, "usage: /config set <key> <value>"));return;}+ // Handle frontend-only config keys+ const frontendSchema = getFrontendSchema(key);+ if (frontendSchema) {+ if (frontendSchema.type === "select" && frontendSchema.options) {+ if (!value) {+ ctx.addItem(+ addError(ctx.sessionId, `Interactive selection not available. Options: ${frontendSchema.options.join(", ")}`),+ );+ return;+ }+ if (!frontendSchema.options.includes(value)) {+ ctx.addItem(+ addError(+ ctx.sessionId,+ `Invalid value "${value}" for ${key}. Options: ${frontendSchema.options.join(", ")}`,+ ),+ );+ return;+ }+ }+ if (!value) {+ ctx.addItem(addError(ctx.sessionId, "usage: /config set <key> <value>"));+ return;+ }+ applyFrontendConfig(ctx, key, value);+ ctx.addItem(+ addInfo(ctx.sessionId, `Config ${key} updated (applied)`, "c", {+ view: "kv",+ title: "Config Updated",+ items: [+ { label: "key", value: key },+ { label: "value", value },+ { label: "applied", value: "true" },+ ],+ }),+ );+ return;+ }let configPayload: Record<string, unknown> & { schema?: ConfigItemSchema[] };try {configPayload = await ctx.request<Record<string, unknown> & { schema?: ConfigItemSchema[] }>(@@ -343,6 +433,15 @@ export function createConfigCommand(): SlashCommand {});}}+ // Append frontend-only items+ items.push({ label: "── Theme ──", description: "" });+ for (const schema of FRONTEND_SCHEMAS) {+ items.push({+ label: schema.key,+ value: getFrontendValue(ctx, schema.key),+ description: schema.description ?? schema.label,+ });+ }ctx.addItem(addInfo(ctx.sessionId, "All config items", "c", { view: "kv", title: "Config Items", items }));},},@@ -364,7 +463,17 @@ export function createConfigCommand(): SlashCommand {return;}if (ctx.enterConfigEditor) {- ctx.enterConfigEditor(undefined, payload);+ // Inject frontend-only schemas into payload for the editor+ const mergedPayload: Record<string, unknown> & { schema?: ConfigItemSchema[] } = {+ ...payload,+ schema: [...(payload.schema ?? []), ...FRONTEND_SCHEMAS],+ };+ for (const schema of FRONTEND_SCHEMAS) {+ if (mergedPayload[schema.key] === undefined) {+ mergedPayload[schema.key] = getFrontendValue(ctx, schema.key);+ }+ }+ ctx.enterConfigEditor(undefined, mergedPayload);} else {ctx.addItem(addError(ctx.sessionId, "Interactive editor not available in this mode"));}@@ -382,6 +491,24 @@ export function createConfigCommand(): SlashCommand {ctx.addItem(addError(ctx.sessionId, "usage: /config reset <key>"));return;}+ // Handle frontend-only config keys+ const frontendSchema = getFrontendSchema(key);+ if (frontendSchema) {+ const defaultValue = frontendSchema.default ?? "";+ applyFrontendConfig(ctx, key, defaultValue);+ ctx.addItem(+ addInfo(ctx.sessionId, `Config ${key} reset to ${defaultValue} (applied)`, "c", {+ view: "kv",+ title: "Config Reset",+ items: [+ { label: "key", value: key },+ { label: "value", value: defaultValue },+ { label: "applied", value: "true" },+ ],+ }),+ );+ return;+ }let configPayload: Record<string, unknown> & { schema?: ConfigItemSchema[] };try {configPayload = await ctx.request<Record<string, unknown> & { schema?: ConfigItemSchema[] }>(@@ -410,6 +537,17 @@ export function createConfigCommand(): SlashCommand {return;}const key = args.trim();+ // Handle frontend-only config keys+ if (FRONTEND_SCHEMA_KEYS.has(key)) {+ ctx.addItem(+ addInfo(ctx.sessionId, `Config: ${key}`, "c", {+ view: "kv",+ title: `Config · ${key}`,+ items: [{ label: key, value: getFrontendValue(ctx, key) }],+ }),+ );+ return;+ }let payload: unknown;try {payload = await ctx.request("config.get", key ? { key } : {});diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/session.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/session.tsindex b3e4a2972f..6acb67a948 100644--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/session.ts+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/session.ts@@ -8,6 +8,7 @@ export function createSessionCommand(): SlashCommand {description: "Show remote session URL and QR code",usage: "/session",example: "/remote",+ hidden: true,kind: CommandKind.BUILT_IN,action: async (ctx) => {try {diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.tsindex fc9411cce3..fe3eeeb44e 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts@@ -52,7 +52,7 @@ import {teamWorkingStartedAtMs,} from "./components/team-shared.js";import { padToWidth } from "./rendering/text.js";-import { editorTheme, palette, selectListTheme } from "./theme.js";+import { editorTheme, palette, selectListTheme, setCurrentThemeName } from "./theme.js";const END_CURSOR = "\x1b[7m \x1b[0m";const PERMISSION_TOOL_RE = /工具\s+`([^`]+)`\s+需要授权/;@@ -2339,6 +2339,23 @@ export class AppScreen implements Component, Focusable {schema: ConfigItemSchema,currentValues: Record<string, string>,): Promise<void> {+ // Handle frontend-only config keys+ if (key === "theme") {+ this.state.setThemeName(value as import("./theme.js").ThemeName);+ currentValues[key] = value;+ this.state.addItem(addInfo(this.state.getSnapshot().sessionId, `✓ ${key}: ${value} (applied)`, "c"));+ if (this.statusViewState) {+ this.statusViewState.phase = "tab_view";+ this.statusViewState.tab = "config";+ this.rebuildStatusViewTabList();+ this.configEditorState = null;+ this.tui.requestRender();+ } else {+ this.configEditorState = null;+ this.tui.requestRender();+ }+ return;+ }try {const result = await this.state.request<{updated: string[];diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/theme.ts b/jiuwenswarm/channels/tui/frontend/src/ui/theme.tsindex f9877cf147..f8becff2de 100644--- a/jiuwenswarm/channels/tui/frontend/src/ui/theme.ts+++ b/jiuwenswarm/channels/tui/frontend/src/ui/theme.ts@@ -30,10 +30,10 @@ function highlightCodeBlock(code: string): string[] {return lines.map((line) => highlightLine(line));}-export type ThemeName = "system" | "dark" | "light";+export type ThemeName = "default" | "dark" | "light";export type AccentColorName = "default" | "blue" | "green" | "pink" | "purple" | "red" | "yellow";-const THEME_OPTIONS: readonly ThemeName[] = ["system", "dark", "light"] as const;+const THEME_OPTIONS: readonly ThemeName[] = ["default", "dark", "light"] as const;const ACCENT_OPTIONS: readonly AccentColorName[] = ["default","blue",@@ -148,7 +148,7 @@ const ACCENT_COLORS: Record<Exclude<AccentColorName, "default">, string> = {};const _initConfig = loadTuiConfig();-let currentThemeName: ThemeName = _initConfig.theme ?? "system";+let currentThemeName: ThemeName = _initConfig.theme ?? "default";let currentAccentColor: AccentColorName = _initConfig.accentColor ?? "default";function detectSystemTheme(): "light" | "dark" {@@ -184,7 +184,7 @@ function detectSystemTheme(): "light" | "dark" {}function getResolvedThemeName(): "light" | "dark" {- return currentThemeName === "system" ? detectSystemTheme() : currentThemeName;+ return currentThemeName === "default" ? detectSystemTheme() : currentThemeName;}function getThemeDefinition(): ThemeDefinition {