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);