Skip to content

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中mcp、sandbox、diff、memory命令

douranac858bd03546
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
index 7232a559a8..c81c856e56 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/CommandService.ts
@@ -51,30 +51,6 @@ export interface InstalledSkillEntry {
description: string;
}
-/**
- * 被完全屏蔽的命令名单(单一事实源)。
- *
- * 列在这里的命令:不进注册表 → /help 不显示、Tab 补全无、手动输入落到命令分发器
- * 显示 "Unknown command: /<name>"。包含其别名与子命令(注册时整体跳过)。
- *
- * 恢复某个命令:把它的名字从下面集合里删掉即可,无需改命令定义、import 或 app-screen
- * 入口块——入口块调用 isCommandDisabled(...) 查询本名单,会自动放行。
- *
- * 注意:/mcp、/memory 在 app-screen.ts 的 handleSubmit 里有"绕过分发器直接开界面"的
- * 入口块,那两块同样调用 isCommandDisabled(...) 查询本名单,故增删本名单即同步生效。
- */
-const DISABLED_COMMANDS = new Set<string>([
- "diff",
- "mcp",
- "sandbox",
- "memory",
-]);
-
-/** 查询某命令是否被屏蔽(供 app-screen 入口块等处查询,保持单一事实源)。 */
-export function isCommandDisabled(name: string): boolean {
- return DISABLED_COMMANDS.has(name.toLowerCase());
-}
-
export class CommandService {
private commands = new Map<string, SlashCommand>();
private aliases = new Map<string, string>();
@@ -89,9 +65,8 @@ export class CommandService {
onInstalledSkillsChange?: (skills: readonly InstalledSkillEntry[]) => void;
register(commands: readonly SlashCommand[]): void {
- // 屏蔽命令在注册阶段整体跳过:topLevelCommands、commands map、aliases 三者一致地不收录。
- this.topLevelCommands = [...commands].filter((command) => !isCommandDisabled(command.name));
- for (const command of this.topLevelCommands) {
+ this.topLevelCommands = [...commands];
+ for (const command of commands) {
this.registerCommand(command);
}
}
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/help.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/help.ts
index 949e7221b4..d17001fd82 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/help.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/help.ts
@@ -1,5 +1,4 @@
import { CommandKind, type SlashCommand, type SlashCommandListProvider } from "../types.js";
-import { isCommandDisabled } from "../CommandService.js";
import { makeItem } from "../helpers.js";
const COMMAND_GROUPS: Record<string, { name: string; commands: string[] }> = {
@@ -47,12 +46,7 @@ export function createHelpCommand(getCommands: SlashCommandListProvider): SlashC
example: "/help",
kind: CommandKind.BUILT_IN,
action: (ctx) => {
- // 过滤:hidden 命令 + 被 DISABLED_COMMANDS 屏蔽的命令都不展示。
- // getCommands() 返回的是注册前原始数组(未过滤屏蔽名单),故需在此显式排除,
- // 否则 /help 会列出已被屏蔽的命令(diff/mcp/sandbox/memory),与"输入报 Unknown"割裂。
- const commands = getCommands().filter(
- (command) => !command.hidden && !isCommandDisabled(command.name),
- );
+ 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 }> = [];
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index 0778b08422..c8482ca996 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -31,7 +31,6 @@ import {
} from "../core/attachments.js";
import {
CommandService,
- isCommandDisabled,
parseSlashCommand,
type InstalledSkillEntry,
} from "../core/commands/CommandService.js";
@@ -687,9 +686,8 @@ class ComposerAutocompleteProvider implements AutocompleteProvider {
}
// /memory edit|toggle + 空格:直接调用 completion 获取文件/key 列表,绕过 CombinedAutocompleteProvider
- // memory 被屏蔽(isCommandDisabled)时跳过本块,避免对已禁用命令补全参数而暴露其存在。
const memArgMatch = textBeforeCursor.match(/^\/memory\s+(edit|toggle)\s+(\S*)$/);
- if (memArgMatch && this.memoryArgCompletion && !isCommandDisabled("memory")) {
+ if (memArgMatch && this.memoryArgCompletion) {
try {
const sub = memArgMatch[1];
const argPrefix = memArgMatch[2].toLowerCase();
@@ -717,8 +715,7 @@ class ComposerAutocompleteProvider implements AutocompleteProvider {
// inner provider 会以 "edit" 为 prefix 返回文件列表,applyCompletion 时会把
// "edit" 替换成文件名 → /memory JIUWENSWARM.local.md(丢失子命令)。
// 用户需要先输入空格,才走上面的 memArgMatch 路径正确展示文件列表。
- // memory 被屏蔽时不抑制(让 inner provider 按未知命令处理)。
- if (!isCommandDisabled("memory") && /^\/memory\s+(edit|toggle)$/.test(textBeforeCursor)) {
+ if (/^\/memory\s+(edit|toggle)$/.test(textBeforeCursor)) {
return null;
}
@@ -3089,9 +3086,7 @@ export class AppScreen implements Component, Focusable {
await this.openModelList();
return;
}
- // /mcp 入口:未被屏蔽时直接开 MCP 列表界面;被屏蔽(isCommandDisabled)则跳过本块,
- // 落到下方命令分发器显示 "Unknown command: /mcp"。屏蔽名单见 CommandService.DISABLED_COMMANDS。
- if (!isCommandDisabled("mcp") && /^\/mcp(?:\s+list)?\s*$/.test(text)) {
+ if (/^\/mcp(?:\s+list)?\s*$/.test(text)) {
this.editor.addToHistory(text);
this.editor.setText("");
this.state.addItem(addCommandEcho(snapshot.sessionId, text));
@@ -3113,10 +3108,8 @@ export class AppScreen implements Component, Focusable {
// /memory(无参)及 /memory <edit|status|toggle|open>(无后续参数)
// 打开 MemoryView 页签控制台;带参数的形式(/memory edit <path>、/memory toggle <key>)
// 不匹配,继续走命令分发器(保留 completion)。
- // 被屏蔽(isCommandDisabled)时跳过本块,落到分发器显示 "Unknown command: /memory"。
- // 屏蔽名单见 CommandService.DISABLED_COMMANDS,恢复时删名字即可,本块无需改动。
const memMatch = text.match(/^\/memory(?:\s+(edit|status|toggle|open))?$/);
- if (memMatch && !isCommandDisabled("memory")) {
+ if (memMatch) {
this.editor.addToHistory(text);
this.editor.setText("");
this.state.addItem(addCommandEcho(snapshot.sessionId, text));