Skip to content

Commit 7b3a6f4

Browse files
committed
Add freebuff model command alias
1 parent 37d0892 commit 7b3a6f4

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { describe, expect, test } from 'bun:test'
2+
3+
describe('freebuff command aliases', () => {
4+
test('/model aliases /end-session in freebuff', () => {
5+
const slashCommandsUrl = new URL(
6+
'../../data/slash-commands.ts',
7+
import.meta.url,
8+
).href
9+
const commandRegistryUrl = new URL(
10+
'../command-registry.ts',
11+
import.meta.url,
12+
).href
13+
14+
const result = Bun.spawnSync({
15+
cmd: [
16+
'bun',
17+
'--eval',
18+
`
19+
import { SLASH_COMMANDS } from ${JSON.stringify(slashCommandsUrl)}
20+
import { findCommand } from ${JSON.stringify(commandRegistryUrl)}
21+
22+
const endSession = SLASH_COMMANDS.find((cmd) => cmd.id === 'end-session')
23+
if (!endSession) throw new Error('end-session slash command missing')
24+
if (!endSession.aliases?.includes('model')) {
25+
throw new Error('end-session slash command is missing model alias')
26+
}
27+
28+
const modelCommand = findCommand('model')
29+
if (!modelCommand) throw new Error('model command alias missing')
30+
if (modelCommand.name !== 'end-session') {
31+
throw new Error('model alias did not resolve to end-session')
32+
}
33+
`,
34+
],
35+
cwd: process.cwd(),
36+
env: {
37+
...process.env,
38+
FREEBUFF_MODE: 'true',
39+
NODE_ENV: 'test',
40+
NEXT_PUBLIC_CB_ENVIRONMENT: 'test',
41+
NEXT_PUBLIC_CODEBUFF_APP_URL: 'https://app.codebuff.test',
42+
NEXT_PUBLIC_SUPPORT_EMAIL: 'support@codebuff.test',
43+
NEXT_PUBLIC_POSTHOG_API_KEY: 'phc_test_key',
44+
NEXT_PUBLIC_POSTHOG_HOST_URL: 'https://posthog.codebuff.test',
45+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: 'pk_test_123',
46+
NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL: 'https://stripe.codebuff.test',
47+
NEXT_PUBLIC_WEB_PORT: '3000',
48+
},
49+
stderr: 'pipe',
50+
stdout: 'pipe',
51+
})
52+
53+
const stderr = new TextDecoder().decode(result.stderr)
54+
expect(result.exitCode, stderr).toBe(0)
55+
})
56+
})

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ const ALL_SLASH_COMMANDS: SlashCommand[] = [
176176
{
177177
id: 'end-session',
178178
label: 'end-session',
179-
description: 'End your free session and return to the waiting room (lets you switch model)',
179+
description: 'End your free session (lets you switch model)',
180+
aliases: ['model'],
180181
},
181182
{
182183
id: 'logout',

0 commit comments

Comments
 (0)