(action: SessionAction)
| 1 | import type { SessionAction } from './types.ts'; |
| 2 | |
| 3 | export function inferFillText(action: SessionAction): string { |
| 4 | const resultText = action.result?.text; |
| 5 | if (typeof resultText === 'string' && resultText.trim().length > 0) { |
| 6 | return resultText; |
| 7 | } |
| 8 | const positionals = action.positionals ?? []; |
| 9 | if (positionals.length === 0) return ''; |
| 10 | const first = positionals[0]; |
| 11 | if (first?.startsWith('@')) { |
| 12 | if (positionals.length >= 3) return positionals.slice(2).join(' ').trim(); |
| 13 | return positionals.slice(1).join(' ').trim(); |
| 14 | } |
| 15 | if ( |
| 16 | positionals.length >= 3 && |
| 17 | !Number.isNaN(Number(positionals[0])) && |
| 18 | !Number.isNaN(Number(positionals[1])) |
| 19 | ) { |
| 20 | return positionals.slice(2).join(' ').trim(); |
| 21 | } |
| 22 | return positionals.slice(1).join(' ').trim(); |
| 23 | } |
| 24 | |
| 25 | export function uniqueStrings(values: string[]): string[] { |
| 26 | const seen = new Set<string>(); |
no test coverage detected
searching dependent graphs…