fix: align WeChat channel modes

This commit is contained in:
lofyer
2026-08-10 11:47:03 +08:00
parent a9ae00a845
commit 2cb712e4ba
11 changed files with 36 additions and 27 deletions
+1 -1
View File
@@ -226,5 +226,5 @@ export function startEnvironmentChannels(
export function isReadOnlyChannelMessage(
message: ChannelInboundText
): boolean {
return message.workMode === 'ask' || message.workMode === 'plan'
return message.workMode === 'ask'
}
+7 -1
View File
@@ -71,7 +71,7 @@ async function waitForSent(
}
describe('channel contracts', () => {
it('normalizes text, defaults to ask, and strictly refuses execute mode', () => {
it('normalizes text, defaults to ask, and refuses non-ask modes', () => {
expect(
channelInboundTextSchema.parse({
channel: ' fake ',
@@ -98,6 +98,12 @@ describe('channel contracts', () => {
workMode: 'execute'
}).success
).toBe(false)
expect(
channelInboundTextSchema.safeParse({
...inbound(),
workMode: 'plan'
}).success
).toBe(false)
expect(
channelInboundTextSchema.parse({
channel: 'fake',
@@ -13,8 +13,8 @@ describe('parseRemoteChannelPrompt', () => {
workMode: 'execute',
prompt: '请整理下载目录'
})
expect(parseRemoteChannelPrompt('总结进展', 'plan')).toEqual({
workMode: 'plan',
expect(parseRemoteChannelPrompt('总结进展', 'ask')).toEqual({
workMode: 'ask',
prompt: '总结进展'
})
})
+3 -3
View File
@@ -1,4 +1,4 @@
import type { WorkMode } from '../../shared/assistant-contracts'
import type { InteractiveWorkMode } from '../../shared/assistant-contracts'
const COMMAND_PATTERN =
/^\/(?<command>ask|execute|exec)(?=$|[\s::])[\s::]*/iu
@@ -7,9 +7,9 @@ const CHINESE_PATTERN =
export function parseRemoteChannelPrompt(
text: string,
defaultWorkMode: WorkMode
defaultWorkMode: InteractiveWorkMode
): {
workMode: WorkMode
workMode: InteractiveWorkMode
prompt: string
} {
const value = text.trim()