feat: add plugin version command

This commit is contained in:
xmanrui 2026-08-25 12:25:01 +08:00
parent 10ca7eec2c
commit c5becbe379
24 changed files with 240 additions and 172 deletions

View file

@ -1,8 +1,11 @@
import { t } from './i18n.mjs';
import manifest from '../../../package.json' with { type: 'json' };
const CONTROL_COMMAND = /^\/(?:stop|steer)(?=$|\s)/iu;
const CONTROL_COMMAND = /^\/(?:stop|steer|version)(?=$|\s)/iu;
const STOP_COMMAND = /^\/stop(?=$|\s)/iu;
const VERSION_COMMAND = /^\/version(?=$|\s)/iu;
const STOP_USAGE = '用法:/stop(不带参数)';
const VERSION_USAGE = '用法:/version(不带参数)';
const STEER_USAGE = '用法:/steer <补充指令>';
const TEXT_ONLY = '控制命令仅支持纯文字,请移除图片后重试。';
@ -41,9 +44,16 @@ export async function runControlCommand(text, harness, state, key, {
if (!isControlCommand(text)) return null;
const command = text.trim();
const stop = STOP_COMMAND.test(command);
const version = VERSION_COMMAND.test(command);
if (hasImages) return commandResult(t(TEXT_ONLY));
if (version) {
return /^\/version$/iu.test(command)
? commandResult(`dsh-im v${manifest.version}`)
: commandResult(t(VERSION_USAGE));
}
if (stop) {
if (!/^\/stop$/iu.test(command)) return commandResult(t(STOP_USAGE));
const session = boundSession(harness, state, key);

View file

@ -229,6 +229,7 @@ export default {
'/new 开启全新会话': '/new Start a new session',
'📊 状态 / 压缩': '📊 Status / compact',
'/status 连接状态': '/status Connection status',
'`/version` — 查看插件版本': '`/version` — show the plugin version',
'/compact 压缩当前会话上下文': '/compact Compact the current session context',
'/archived on/off 会话列表显示/隐藏归档': '/archived on/off Show/hide archived sessions',
'👁 关注': '👁 Watches',

View file

@ -69,6 +69,7 @@ export default {
'/stop 停止当前任务': '/stop Stop the current task',
'/steer 补充指令 纠偏当前任务': '/steer <additional instruction> Steer the current task',
'/status 检查连接状态': '/status Check the connection status',
'/version 查看插件版本': '/version Show the plugin version',
'/help 显示本帮助': '/help Show this help',
'{label}机器人与 DeepSeek Harness 连接正常。':
'The {label} bot is connected to DeepSeek Harness and working normally.',

View file

@ -242,6 +242,7 @@ export default {
// control-command.mjs
'用法:/stop(不带参数)': 'Usage: /stop (no arguments)',
'用法:/version(不带参数)': 'Usage: /version (no arguments)',
'用法:/steer <补充指令>': 'Usage: /steer <additional instruction>',
'控制命令仅支持纯文字,请移除图片后重试。':
'Control commands support text only; please remove images and try again.',

View file

@ -13,6 +13,7 @@ export default {
'停止当前任务': 'Stop the current task',
'纠偏当前任务': 'Steer the current task',
'检查连接状态': 'Check connection status',
'查看插件版本': 'Show plugin version',
'显示帮助': 'Show help',
'该 Telegram 机器人已配置 Webhook,请先在原服务中移除 Webhook 后重试。':
'This Telegram bot already has a Webhook configured. Remove the Webhook from the original service and try again.',

View file

@ -494,6 +494,7 @@ export class TextHarnessBridge {
t('/send 提交当前批次'),
t('/cancel 取消当前批次'),
t('/status 检查连接状态'),
t('/version 查看插件版本'),
t('/help 显示本帮助'),
].join('\n'));
return;