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: 修复tui /help显示问题
jingjinduocacd813480a9
diff --git a/jiuwenclaw/channels/tui/frontend/src/app-state.ts b/jiuwenclaw/channels/tui/frontend/src/app-state.tsindex ce46cf430c..8d4c5f3c45 100644--- a/jiuwenclaw/channels/tui/frontend/src/app-state.ts+++ b/jiuwenclaw/channels/tui/frontend/src/app-state.ts@@ -413,6 +413,7 @@ export class CliPiAppState {const snapshot = this.getSnapshot();const toolGroupIds = getToolGroupIds(snapshot.entries, snapshot.toolExecutions);return {+ version: snapshot.modelInfo.version || "",sendEventOnly: this.sendEventOnly,request: this.request,askQuestions: this.askQuestions,diff --git a/jiuwenclaw/channels/tui/frontend/src/core/commands/builtins/help.ts b/jiuwenclaw/channels/tui/frontend/src/core/commands/builtins/help.tsindex 97d12187a9..fced176ba6 100644--- a/jiuwenclaw/channels/tui/frontend/src/core/commands/builtins/help.ts+++ b/jiuwenclaw/channels/tui/frontend/src/core/commands/builtins/help.ts@@ -1,6 +1,47 @@import { CommandKind, type SlashCommand, type SlashCommandListProvider } from "../types.js";import { makeItem } from "../helpers.js";+const COMMAND_GROUPS: Record<string, { name: string; commands: string[] }> = {+ core: {+ name: "Core",+ commands: ["help", "clear", "exit", "init", "copy", "hotkey"],+ },+ session: {+ name: "Session",+ commands: ["resume", "rename", "session", "compact", "sessions", "new"],+ },+ model: {+ name: "Model",+ commands: ["model", "mode", "theme", "color"],+ },+ evolution: {+ name: "Evolution",+ commands: ["evolve", "evolve_list", "evolve_rebuild", "evolve_simplify"],+ },+ mcp: {+ name: "MCP",+ commands: ["mcp"],+ },+ skills: {+ name: "Skills",+ commands: ["skills", "teamskills"],+ },+ config: {+ name: "Config",+ commands: ["config", "permissions", "workspace", "diff", "plan"],+ },+};++/** 获取命令所属分组 */+function getCommandGroup(commandName: string): string | null {+ for (const [groupKey, group] of Object.entries(COMMAND_GROUPS)) {+ if (group.commands.includes(commandName)) {+ return groupKey;+ }+ }+ return null;+}+export function createHelpCommand(getCommands: SlashCommandListProvider): SlashCommand {return {name: "help",@@ -9,20 +50,51 @@ export function createHelpCommand(getCommands: SlashCommandListProvider): SlashCexample: "/help",kind: CommandKind.BUILT_IN,action: (ctx) => {- const lines = getCommands()- .filter((command) => !command.hidden)- .map((command) => ({+ const commands = getCommands().filter((command) => !command.hidden);++ const groupedCommands: Record<string, Array<{ label: string; value?: string; description: string }>> = {};+ const ungroupedCommands: Array<{ label: string; value?: string; description: string }> = [];++ for (const command of commands) {+ const item = {label: `/${command.name}`,value: command.usage?.replace(/^\/[^\s]+/, "").trim() || undefined,description: command.description,+ };++ const groupKey = getCommandGroup(command.name);+ if (groupKey) {+ if (!groupedCommands[groupKey]) {+ groupedCommands[groupKey] = [];+ }+ groupedCommands[groupKey].push(item);+ } else {+ ungroupedCommands.push(item);+ }+ }++ const groups = Object.keys(COMMAND_GROUPS)+ .filter((key) => groupedCommands[key]?.length > 0)+ .map((key) => ({+ name: COMMAND_GROUPS[key].name,+ items: groupedCommands[key],}));++ if (ungroupedCommands.length > 0) {+ groups.push({+ name: "Other",+ items: ungroupedCommands,+ });+ }+ctx.addItem(makeItem(ctx.sessionId, "info", "Available commands", "?", {view: "help",title: "Slash Commands",- items: lines,+ groups,+ version: ctx.version,}),);},};-}+}\ No newline at end of filediff --git a/jiuwenclaw/channels/tui/frontend/src/core/commands/types.ts b/jiuwenclaw/channels/tui/frontend/src/core/commands/types.tsindex 70ba598011..42b6d846f6 100644--- a/jiuwenclaw/channels/tui/frontend/src/core/commands/types.ts+++ b/jiuwenclaw/channels/tui/frontend/src/core/commands/types.ts@@ -21,6 +21,8 @@ export interface CommandSuggestion {}export interface CommandContext {+ /** 版本信息 */+ version: string;/*** options.logAsUser=false 可用于发送内部控制消息(例如 /init 生成的 orchestration prompt),* 避免在 CLI/TUI 历史中渲染为普通用户输入。diff --git a/jiuwenclaw/channels/tui/frontend/src/core/types.ts b/jiuwenclaw/channels/tui/frontend/src/core/types.tsindex a5d70260be..6be345920f 100644--- a/jiuwenclaw/channels/tui/frontend/src/core/types.ts+++ b/jiuwenclaw/channels/tui/frontend/src/core/types.ts@@ -31,6 +31,11 @@ export interface InfoMeta {view?: "help" | "list" | "kv";title?: string;items?: Array<{ label: string; value?: string; description?: string }>;+ groups?: Array<{+ name: string;+ items: Array<{ label: string; value?: string; description?: string }>;+ }>;+ version?: string;}export interface ToolCallDisplay {diff --git a/jiuwenclaw/channels/tui/frontend/src/ui/components/messages/meta-components.ts b/jiuwenclaw/channels/tui/frontend/src/ui/components/messages/meta-components.tsindex 3d6745bc0b..86a795e4f6 100644--- a/jiuwenclaw/channels/tui/frontend/src/ui/components/messages/meta-components.ts+++ b/jiuwenclaw/channels/tui/frontend/src/ui/components/messages/meta-components.ts@@ -1,9 +1,44 @@+import { visibleWidth } from "@mariozechner/pi-tui";import type { Component } from "@mariozechner/pi-tui";import type { HistoryItem } from "../../../core/types.js";import { palette } from "../../theme.js";import { padToWidth, prefixedLines, renderWrappedText, summarize } from "../../rendering/text.js";import { renderClaudeResponseLines, renderMediaItems } from "./shared.js";+function renderGroupedHelpView(+ width: number,+ meta: Extract<HistoryItem, { kind: "info" }>["meta"],+): string[] {+ const lines: string[] = [];+ const innerWidth = Math.max(1, width);++ const version = meta?.version || "";+ const versionText = version ? `jiuwenclaw CLI v${version}` : "jiuwenclaw CLI";+ lines.push(...renderWrappedText(innerWidth, `· ${versionText} — ${meta?.title ?? "Slash Commands"}`, palette.text.info));+ lines.push("");++ for (const group of meta?.groups ?? []) {+ const groupTitle = `── ${group.name} `;+ const groupPadding = Math.max(0, innerWidth - visibleWidth(groupTitle));+ const fullGroupTitle = groupTitle + "─".repeat(groupPadding);+ lines.push(padToWidth(palette.text.secondary(fullGroupTitle), innerWidth));++ for (const item of group.items) {+ const value = item.value ? ` ${item.value}` : "";+ const labelLine = ` ${item.label}${value}`;+ lines.push(padToWidth(palette.text.accent(labelLine), innerWidth));+ if (item.description) {+ lines.push(padToWidth(palette.text.dim(` ${item.description}`), innerWidth));+ }+ }+ lines.push("");+ }++ lines.push(padToWidth(palette.text.dim("Press Esc to close"), innerWidth));++ return lines;+}+export class SystemMessageComponent implements Component {constructor(private readonly entry: Extract<HistoryItem, { kind: "system" }>) {}@@ -47,6 +82,11 @@ export class InfoMessageComponent implements Component {render(width: number): string[] {const meta = this.entry.meta;++ if (meta?.view === "help" && meta.groups?.length) {+ return renderGroupedHelpView(width, meta);+ }+const lines: string[] = [];const innerWidth = Math.max(1, width);const title = meta?.title ?? this.entry.content;