fix(workflow-generator): satisfy knip + update slash command registry test

- Drop the export on apply.ts:deriveAppName — it's only used internally
  by applyToNewApp, and knip was flagging the unused public export.
- Extend the slash.spec registration assertion to include the new
  'create' command so SlashCommandProvider's mount/unmount checks pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
crazywoola
2026-05-29 15:49:32 +08:00
parent 2a67c7e92d
commit d6bec58bfa
2 changed files with 5 additions and 7 deletions

View File

@ -106,6 +106,7 @@ describe('SlashCommandProvider', () => {
'account',
'zen',
'go',
'create',
])
expect(mockRegister).toHaveBeenCalledWith(expect.objectContaining({ name: 'theme' }), { setTheme: mockSetTheme })
expect(mockRegister).toHaveBeenCalledWith(expect.objectContaining({ name: 'language' }), { setLocale: mockSetLocale })
@ -121,6 +122,7 @@ describe('SlashCommandProvider', () => {
'account',
'zen',
'go',
'create',
])
})
})

View File

@ -8,13 +8,9 @@ const MODE_TO_APP_MODE: Record<WorkflowGeneratorMode, AppModeEnum> = {
'advanced-chat': AppModeEnum.ADVANCED_CHAT,
}
/**
* Derive a sane App name from the user's instruction.
* - Trims whitespace.
* - Caps length at 40 chars.
* - Strips trailing punctuation.
*/
export const deriveAppName = (instruction: string): string => {
// Derive a sane App name from the user's instruction: trim, cap at 40 chars,
// strip trailing punctuation.
const deriveAppName = (instruction: string): string => {
const trimmed = instruction.trim().slice(0, 40)
return trimmed.replace(/[.,!?;:。,!?;:]+$/, '').trim() || 'Generated Workflow'
}