Skip to content

Commit 9e0c75d

Browse files
committed
Add freebuff model command alias
1 parent 37d0892 commit 9e0c75d

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, expect, test } from 'bun:test'
2+
3+
describe('freebuff command aliases', () => {
4+
test('/model aliases /end-session in freebuff', () => {
5+
const result = Bun.spawnSync({
6+
cmd: [
7+
'bun',
8+
'--eval',
9+
`
10+
import { SLASH_COMMANDS } from './cli/src/data/slash-commands.ts'
11+
import { findCommand } from './cli/src/commands/command-registry.ts'
12+
13+
const endSession = SLASH_COMMANDS.find((cmd) => cmd.id === 'end-session')
14+
if (!endSession) throw new Error('end-session slash command missing')
15+
if (!endSession.aliases?.includes('model')) {
16+
throw new Error('end-session slash command is missing model alias')
17+
}
18+
19+
const modelCommand = findCommand('model')
20+
if (!modelCommand) throw new Error('model command alias missing')
21+
if (modelCommand.name !== 'end-session') {
22+
throw new Error('model alias did not resolve to end-session')
23+
}
24+
`,
25+
],
26+
cwd: process.cwd(),
27+
env: {
28+
...process.env,
29+
FREEBUFF_MODE: 'true',
30+
NODE_ENV: 'test',
31+
},
32+
stderr: 'pipe',
33+
stdout: 'pipe',
34+
})
35+
36+
expect(result.exitCode).toBe(0)
37+
})
38+
})

cli/src/commands/command-registry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ const ALL_COMMANDS: CommandDefinition[] = [
596596
// user picks a model and hits Enter to rejoin the queue.
597597
defineCommand({
598598
name: 'end-session',
599+
aliases: ['model'],
599600
handler: (params) => {
600601
params.setMessages((prev) => [
601602
...prev,

cli/src/data/slash-commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ const ALL_SLASH_COMMANDS: SlashCommand[] = [
177177
id: 'end-session',
178178
label: 'end-session',
179179
description: 'End your free session and return to the waiting room (lets you switch model)',
180+
aliases: ['model'],
180181
},
181182
{
182183
id: 'logout',

0 commit comments

Comments
 (0)