mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-11 13:41:53 +00:00
Bring apps/desktop and ui-tui to a clean state for typecheck, eslint,
and prettier:
- Run prettier across both trees (printWidth/wrap drift; prettier is not
CI-enforced for these JS projects, so main had accumulated drift).
- Apply eslint --fix for padding-line-between-statements and perfectionist
import/export sorting.
- Manual fixes for non-auto-fixable rules:
- remove unused node:net import in electron/main.cjs (uses Electron net)
- replace inline `typeof import(...)` annotations with top-level
`import type * as EnvModule` in two ui-tui test files
- scoped eslint-disable no-control-regex on intentional sentinel/ANSI
regexes (mathUnicode.ts, text.ts)
- resolve react-hooks/exhaustive-deps per-case: correct swapped/missing
deps, collapse redundant session.* members, and justified disables on
settings mount-only data-load effects to preserve run-once behavior
No behavior changes; test pass/fail counts are unchanged from the main
baseline.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { formatAbandonedClarify, stripTrailingPasteNewlines } from './text.js'
|
|
|
|
describe('stripTrailingPasteNewlines', () => {
|
|
it('removes trailing newline runs from pasted text', () => {
|
|
expect(stripTrailingPasteNewlines('alpha\n')).toBe('alpha')
|
|
expect(stripTrailingPasteNewlines('alpha\nbeta\n\n')).toBe('alpha\nbeta')
|
|
})
|
|
|
|
it('preserves interior newlines', () => {
|
|
expect(stripTrailingPasteNewlines('alpha\nbeta\ngamma')).toBe('alpha\nbeta\ngamma')
|
|
})
|
|
|
|
it('preserves newline-only pastes', () => {
|
|
expect(stripTrailingPasteNewlines('\n\n')).toBe('\n\n')
|
|
})
|
|
})
|
|
|
|
describe('formatAbandonedClarify', () => {
|
|
it('renders the question, numbered options, and reason', () => {
|
|
const out = formatAbandonedClarify('How do you want to scope?', ['Option A', 'Option B', 'Option C'], 'timed out')
|
|
|
|
expect(out).toBe(
|
|
[
|
|
'ask How do you want to scope?',
|
|
' 1. Option A',
|
|
' 2. Option B',
|
|
' 3. Option C',
|
|
' (timed out — no selection)'
|
|
].join('\n')
|
|
)
|
|
})
|
|
|
|
it('handles a prompt with no choices (free-text clarify)', () => {
|
|
const out = formatAbandonedClarify('What is the target branch?', null, 'cancelled')
|
|
|
|
expect(out).toBe(['ask What is the target branch?', ' (cancelled — no selection)'].join('\n'))
|
|
})
|
|
|
|
it('trims surrounding whitespace on the question', () => {
|
|
const out = formatAbandonedClarify(' trailing space ', [], 'timed out')
|
|
|
|
expect(out.split('\n')[0]).toBe('ask trailing space')
|
|
})
|
|
|
|
it('numbers options 1-based to match the live ClarifyPrompt', () => {
|
|
const out = formatAbandonedClarify('q', ['first'], 'timed out')
|
|
|
|
expect(out).toContain(' 1. first')
|
|
expect(out).not.toContain(' 0.')
|
|
})
|
|
})
|