mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
fix: [Feature] 支持使用 /workspacelist 序号切换工作区 (#87)
This commit is contained in:
parent
840e5aa857
commit
91f49a603b
12 changed files with 49 additions and 23 deletions
|
|
@ -74,7 +74,7 @@ const HELP_TEXT_LINES = [
|
|||
'/new 开启一个全新会话',
|
||||
'/compact 压缩当前会话的较早上下文',
|
||||
'/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)',
|
||||
'/workspace 工作区绝对路径 切换工作区',
|
||||
'/workspace 工作区序号或绝对路径 切换工作区',
|
||||
'/workspacelist 列出工作区绝对路径',
|
||||
'/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题',
|
||||
'/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话',
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ function isFeishuLocalCommand(text, { hasImages = false, hasFiles = false } = {}
|
|||
|
||||
/** Canonical workspace/session help advertised by every bridge family. */
|
||||
const WORKSPACE_HELP_LINES = [
|
||||
'/workspace 工作区序号或绝对路径 切换工作区',
|
||||
'/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话',
|
||||
'/workspacelist 列出工作区绝对路径',
|
||||
'/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题',
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ function helpText() {
|
|||
t('/new 开启一个全新会话'),
|
||||
t('/compact 压缩当前会话的较早上下文'),
|
||||
t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
|
||||
t('/workspace 工作区绝对路径 切换工作区'),
|
||||
t('/workspace 工作区序号或绝对路径 切换工作区'),
|
||||
t('/workspacelist 列出工作区绝对路径'),
|
||||
t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
|
||||
t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ export default {
|
|||
'{label}机器人已连接 DeepSeek Harness。': 'The {label} bot is connected to DeepSeek Harness.',
|
||||
'/new 开启一个全新会话': '/new Start a brand-new session',
|
||||
'/compact 压缩当前会话的较早上下文': '/compact Compact the earlier context of the current session',
|
||||
'/workspace 工作区绝对路径 切换工作区': '/workspace <absolute workspace path> Switch workspace',
|
||||
'/workspace 工作区序号或绝对路径 切换工作区':
|
||||
'/workspace <workspace index or absolute path> Switch workspace',
|
||||
'/workspacelist 列出工作区绝对路径': '/workspacelist List absolute workspace paths',
|
||||
'/sessionlist [工作区序号或绝对路径] 列出会话 ID 和标题':
|
||||
'/sessionlist [workspace index or absolute path] List session IDs and titles',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ export default {
|
|||
'当前 Harness Host 上存在的工作区({count}):':
|
||||
'Workspaces on the current Harness Host ({count}):',
|
||||
'(当前)': '(current)',
|
||||
'切换用法:/workspace 工作区绝对路径': 'To switch: /workspace Workspace absolute path',
|
||||
'切换用法:/workspace 工作区序号或绝对路径':
|
||||
'To switch: /workspace Workspace index or absolute path',
|
||||
'查看会话:/sessionlist 工作区序号或绝对路径':
|
||||
'To view Sessions: /sessionlist Workspace index or absolute path',
|
||||
'机器人正在移除或已重新接入,无法列出原会话的工作区。':
|
||||
|
|
@ -80,10 +81,12 @@ export default {
|
|||
'归档:{archived}': 'Archived: {archived}',
|
||||
'是': 'Yes',
|
||||
'否': 'No',
|
||||
'用法:/workspace 工作区绝对路径': 'Usage: /workspace Workspace absolute path',
|
||||
'用法:/workspace 工作区序号或绝对路径':
|
||||
'Usage: /workspace Workspace index or absolute path',
|
||||
'当前机器人暂不支持切换工作区。': 'This bot does not support switching Workspaces yet.',
|
||||
'工作区已切换为:{workspace}': 'Workspace switched to: {workspace}',
|
||||
'{message}\n用法:/workspace 工作区绝对路径': '{message}\nUsage: /workspace Workspace absolute path',
|
||||
'{message}\n用法:/workspace 工作区序号或绝对路径':
|
||||
'{message}\nUsage: /workspace Workspace index or absolute path',
|
||||
'机器人正在移除或已重新接入,无法切换原会话的工作区。':
|
||||
'The bot is being removed or has been reconnected; cannot switch the Workspace of the original Session.',
|
||||
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ export class TextHarnessBridge {
|
|||
t('/new 开启一个全新会话'),
|
||||
t('/compact 压缩当前会话的较早上下文'),
|
||||
t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
|
||||
t('/workspace 工作区绝对路径 切换工作区'),
|
||||
t('/workspace 工作区序号或绝对路径 切换工作区'),
|
||||
t('/workspacelist 列出工作区绝对路径'),
|
||||
t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
|
||||
t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ async function runWorkspaceListCommand(match, harness) {
|
|||
`${index + 1}. ${workspace}${workspace === current ? t('(当前)') : ''}`
|
||||
)),
|
||||
'',
|
||||
t('切换用法:/workspace 工作区绝对路径'),
|
||||
t('切换用法:/workspace 工作区序号或绝对路径'),
|
||||
t('查看会话:/sessionlist 工作区序号或绝对路径'),
|
||||
];
|
||||
const message = lines.join('\n');
|
||||
|
|
@ -366,18 +366,30 @@ export async function runWorkspaceCommand(text, harness, conversationKey) {
|
|||
if (!match) return null;
|
||||
const workspace = match[1]?.trim();
|
||||
if (!workspace) {
|
||||
return commandResult(t('用法:/workspace 工作区绝对路径'));
|
||||
return commandResult(t('用法:/workspace 工作区序号或绝对路径'));
|
||||
}
|
||||
if (typeof harness?.switchWorkspace !== 'function') {
|
||||
return commandResult(t('当前机器人暂不支持切换工作区。'));
|
||||
}
|
||||
try {
|
||||
const current = await harness.switchWorkspace(workspace);
|
||||
let selected = workspace;
|
||||
if (/^\d+$/u.test(workspace)) {
|
||||
if (typeof harness?.listWorkspaces !== 'function') {
|
||||
return commandResult(t('当前机器人暂不支持按序号选择工作区。'));
|
||||
}
|
||||
const { paths } = await workspacePathSnapshot(harness);
|
||||
const position = Number(workspace);
|
||||
if (!Number.isSafeInteger(position) || position < 1 || position > paths.length) {
|
||||
return commandResult(t('工作区序号不存在,请先执行 /workspacelist。'));
|
||||
}
|
||||
selected = paths[position - 1];
|
||||
}
|
||||
const current = await harness.switchWorkspace(selected);
|
||||
return commandResult(t('工作区已切换为:{workspace}', { workspace: current }));
|
||||
} catch (error) {
|
||||
if (['workspace-not-absolute', 'workspace-not-found', 'workspace-not-directory'].includes(error?.code)) {
|
||||
return commandResult(t(`{message}
|
||||
用法:/workspace 工作区绝对路径`, { message: error.message }));
|
||||
用法:/workspace 工作区序号或绝对路径`, { message: error.message }));
|
||||
}
|
||||
if (error?.code === 'workspace-bot-not-found') {
|
||||
return commandResult(t('机器人正在移除或已重新接入,无法切换原会话的工作区。'));
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ function helpText() {
|
|||
t('/new 开启一个全新会话'),
|
||||
t('/compact 压缩当前会话的较早上下文'),
|
||||
t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
|
||||
t('/workspace 工作区绝对路径 切换工作区'),
|
||||
t('/workspace 工作区序号或绝对路径 切换工作区'),
|
||||
t('/workspacelist 列出工作区绝对路径'),
|
||||
t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
|
||||
t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ const HELP_TEXT = () => [
|
|||
t('/new 开启一个全新会话'),
|
||||
t('/compact 压缩当前会话的较早上下文'),
|
||||
t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
|
||||
t('/workspace 工作区绝对路径 切换工作区'),
|
||||
t('/workspace 工作区序号或绝对路径 切换工作区'),
|
||||
t('/workspacelist 列出工作区绝对路径'),
|
||||
t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
|
||||
t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue