@trans-ai/trans-code 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/screens/REPL.tsx +19 -9
- package/src/screens/history-rule.test.ts +16 -0
- package/src/screens/history-rule.ts +12 -0
- package/src/version.ts +1 -1
package/package.json
CHANGED
package/src/screens/REPL.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Text, useInput, useApp } from 'ink';
|
|
1
|
+
import { Box, Text, useInput, useApp, useStdout } from 'ink';
|
|
2
2
|
import { useState, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { findCommand, getCommands, type CommandContext } from '../commands.js';
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
slashQuery,
|
|
36
36
|
} from './slash-completion.js';
|
|
37
37
|
import { resolveSubmitInput } from './submit.js';
|
|
38
|
+
import { historyRule } from './history-rule.js';
|
|
38
39
|
import { renderDiff } from './diff-render.js';
|
|
39
40
|
import { createTurnStats, recordCall, shouldCollapse, summaryLine } from './turn-summary.js';
|
|
40
41
|
import { buildSystemPrompt, INIT_PROMPT, loadProjectContext } from '../agent/system-prompt.js';
|
|
@@ -64,6 +65,7 @@ interface REPLProps {
|
|
|
64
65
|
|
|
65
66
|
export default function REPL({ ctx, updateNotice }: REPLProps) {
|
|
66
67
|
const { exit } = useApp();
|
|
68
|
+
const { stdout } = useStdout();
|
|
67
69
|
const [input, setInput] = useState('');
|
|
68
70
|
// Multiple keystrokes can be handled in one React batch before a
|
|
69
71
|
// re-render; closures over `input` would see stale values (e.g. the
|
|
@@ -970,14 +972,18 @@ export default function REPL({ ctx, updateNotice }: REPLProps) {
|
|
|
970
972
|
{history.map((entry, i) => (
|
|
971
973
|
<Box key={i} flexDirection="column">
|
|
972
974
|
{entry.input && (
|
|
973
|
-
<Box>
|
|
974
|
-
<Text color="
|
|
975
|
-
<
|
|
975
|
+
<Box flexDirection="column">
|
|
976
|
+
<Text color="gray" dimColor>{historyRule(stdout?.columns ?? 80)}</Text>
|
|
977
|
+
<Box>
|
|
978
|
+
<Text color="green" bold>> </Text>
|
|
979
|
+
<Text color="cyan" bold>{entry.input}</Text>
|
|
980
|
+
</Box>
|
|
981
|
+
<Text color="gray" dimColor>{historyRule(stdout?.columns ?? 80)}</Text>
|
|
976
982
|
</Box>
|
|
977
983
|
)}
|
|
978
984
|
{entry.output && (
|
|
979
985
|
<Box marginLeft={2}>
|
|
980
|
-
<Text
|
|
986
|
+
<Text>{entry.output}</Text>
|
|
981
987
|
</Box>
|
|
982
988
|
)}
|
|
983
989
|
</Box>
|
|
@@ -1056,10 +1062,14 @@ export default function REPL({ ctx, updateNotice }: REPLProps) {
|
|
|
1056
1062
|
)}
|
|
1057
1063
|
|
|
1058
1064
|
{phase !== 'model_select' && (
|
|
1059
|
-
<Box>
|
|
1060
|
-
<Text color={
|
|
1061
|
-
<
|
|
1062
|
-
|
|
1065
|
+
<Box flexDirection="column">
|
|
1066
|
+
<Text color="gray" dimColor>{historyRule(stdout?.columns ?? 80)}</Text>
|
|
1067
|
+
<Box>
|
|
1068
|
+
<Text color={phase === 'idle' ? 'green' : 'yellow'}>{promptLabel}</Text>
|
|
1069
|
+
<Text>{phase === 'model_apikey' ? '*'.repeat(input.length) : input}</Text>
|
|
1070
|
+
<Text color="gray">▎</Text>
|
|
1071
|
+
</Box>
|
|
1072
|
+
<Text color="gray" dimColor>{historyRule(stdout?.columns ?? 80)}</Text>
|
|
1063
1073
|
</Box>
|
|
1064
1074
|
)}
|
|
1065
1075
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { historyRule } from './history-rule.js';
|
|
3
|
+
|
|
4
|
+
describe('historyRule', () => {
|
|
5
|
+
test('fills the terminal width minus a small margin', () => {
|
|
6
|
+
expect(historyRule(80)).toHaveLength(78);
|
|
7
|
+
expect(historyRule(120)).toHaveLength(118);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('uses the box-drawing dash and never collapses on narrow terminals', () => {
|
|
11
|
+
expect(historyRule(80).startsWith('─')).toBe(true);
|
|
12
|
+
expect(historyRule(20)).toHaveLength(18);
|
|
13
|
+
expect(historyRule(4).length).toBeGreaterThanOrEqual(10); // clamped floor
|
|
14
|
+
expect(historyRule(0).length).toBeGreaterThanOrEqual(10);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Minimum rule length so narrow terminals still show a visible divider. */
|
|
2
|
+
const MIN_RULE = 10;
|
|
3
|
+
/** Right margin so the rule never wraps onto the next line. */
|
|
4
|
+
const MARGIN = 2;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The horizontal rule drawn around a user question in the chat history.
|
|
8
|
+
* Box-drawing dash repeated to the terminal width minus a small margin.
|
|
9
|
+
*/
|
|
10
|
+
export function historyRule(columns: number): string {
|
|
11
|
+
return '─'.repeat(Math.max(MIN_RULE, columns - MARGIN));
|
|
12
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated from package.json by scripts/sync-version.ts (npm version hook)
|
|
2
|
-
export const VERSION = '0.6.
|
|
2
|
+
export const VERSION = '0.6.2';
|