centaurus-cli 2.7.1 → 2.7.3
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/dist/cli-adapter.d.ts +15 -0
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +380 -122
- package/dist/cli-adapter.js.map +1 -1
- package/dist/config/mcp-config-manager.d.ts +53 -0
- package/dist/config/mcp-config-manager.d.ts.map +1 -0
- package/dist/config/mcp-config-manager.js +210 -0
- package/dist/config/mcp-config-manager.js.map +1 -0
- package/dist/config/slash-commands.d.ts +14 -0
- package/dist/config/slash-commands.d.ts.map +1 -0
- package/dist/config/slash-commands.js +65 -0
- package/dist/config/slash-commands.js.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/mcp-command-handler.d.ts +16 -0
- package/dist/mcp/mcp-command-handler.d.ts.map +1 -0
- package/dist/mcp/mcp-command-handler.js +196 -0
- package/dist/mcp/mcp-command-handler.js.map +1 -0
- package/dist/mcp/mcp-server-manager.d.ts +30 -0
- package/dist/mcp/mcp-server-manager.d.ts.map +1 -0
- package/dist/mcp/mcp-server-manager.js +165 -0
- package/dist/mcp/mcp-server-manager.js.map +1 -0
- package/dist/mcp/mcp-tool-wrapper.d.ts +12 -0
- package/dist/mcp/mcp-tool-wrapper.d.ts.map +1 -0
- package/dist/mcp/mcp-tool-wrapper.js +57 -0
- package/dist/mcp/mcp-tool-wrapper.js.map +1 -0
- package/dist/services/ai-service-client.d.ts.map +1 -1
- package/dist/services/ai-service-client.js +1 -0
- package/dist/services/ai-service-client.js.map +1 -1
- package/dist/services/environment-context-injector.d.ts +2 -2
- package/dist/services/environment-context-injector.d.ts.map +1 -1
- package/dist/services/environment-context-injector.js +4 -4
- package/dist/services/environment-context-injector.js.map +1 -1
- package/dist/tools/command.d.ts +1 -2
- package/dist/tools/command.d.ts.map +1 -1
- package/dist/tools/command.js +39 -131
- package/dist/tools/command.js.map +1 -1
- package/dist/tools/file-ops.d.ts +3 -3
- package/dist/tools/file-ops.d.ts.map +1 -1
- package/dist/tools/file-ops.js +125 -99
- package/dist/tools/file-ops.js.map +1 -1
- package/dist/tools/get-diff.d.ts +5 -0
- package/dist/tools/get-diff.d.ts.map +1 -1
- package/dist/tools/get-diff.js +67 -5
- package/dist/tools/get-diff.js.map +1 -1
- package/dist/tools/grep-search.d.ts +13 -21
- package/dist/tools/grep-search.d.ts.map +1 -1
- package/dist/tools/grep-search.js +309 -280
- package/dist/tools/grep-search.js.map +1 -1
- package/dist/tools/inspect-symbol.d.ts +5 -0
- package/dist/tools/inspect-symbol.d.ts.map +1 -1
- package/dist/tools/inspect-symbol.js +102 -20
- package/dist/tools/inspect-symbol.js.map +1 -1
- package/dist/tools/types.d.ts +2 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/validation.d.ts +8 -10
- package/dist/tools/validation.d.ts.map +1 -1
- package/dist/tools/validation.js +35 -37
- package/dist/tools/validation.js.map +1 -1
- package/dist/ui/components/App.d.ts +4 -0
- package/dist/ui/components/App.d.ts.map +1 -1
- package/dist/ui/components/App.js +182 -70
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/AuthWelcomeScreen.d.ts.map +1 -1
- package/dist/ui/components/AuthWelcomeScreen.js +1 -9
- package/dist/ui/components/AuthWelcomeScreen.js.map +1 -1
- package/dist/ui/components/CodeBlock.d.ts.map +1 -1
- package/dist/ui/components/CodeBlock.js +24 -13
- package/dist/ui/components/CodeBlock.js.map +1 -1
- package/dist/ui/components/DiffViewer.d.ts +1 -0
- package/dist/ui/components/DiffViewer.d.ts.map +1 -1
- package/dist/ui/components/DiffViewer.js +107 -70
- package/dist/ui/components/DiffViewer.js.map +1 -1
- package/dist/ui/components/FileCreationPreview.d.ts +8 -0
- package/dist/ui/components/FileCreationPreview.d.ts.map +1 -0
- package/dist/ui/components/FileCreationPreview.js +63 -0
- package/dist/ui/components/FileCreationPreview.js.map +1 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -1
- package/dist/ui/components/InputBox.js +134 -10
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/InteractiveShell.d.ts +1 -0
- package/dist/ui/components/InteractiveShell.d.ts.map +1 -1
- package/dist/ui/components/InteractiveShell.js +30 -8
- package/dist/ui/components/InteractiveShell.js.map +1 -1
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/ui/components/MarkdownRenderer.js +8 -30
- package/dist/ui/components/MarkdownRenderer.js.map +1 -1
- package/dist/ui/components/SlashCommandAutocomplete.d.ts +11 -0
- package/dist/ui/components/SlashCommandAutocomplete.d.ts.map +1 -0
- package/dist/ui/components/SlashCommandAutocomplete.js +15 -0
- package/dist/ui/components/SlashCommandAutocomplete.js.map +1 -0
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.js +212 -53
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
- package/dist/ui/components/ToolExecutionStatus.d.ts.map +1 -1
- package/dist/ui/components/ToolExecutionStatus.js +28 -1
- package/dist/ui/components/ToolExecutionStatus.js.map +1 -1
- package/dist/utils/input-classifier.d.ts.map +1 -1
- package/dist/utils/input-classifier.js +3 -1
- package/dist/utils/input-classifier.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +71 -0
- package/dist/utils/shell.js.map +1 -1
- package/package.json +2 -1
- package/prompts/system-prompt-autonomous.md +22 -73
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
3
|
// Maximum number of lines to show before truncating
|
|
4
4
|
const MAX_PREVIEW_LINES = 8;
|
|
5
|
+
// Maximum number of lines to show in full view
|
|
6
|
+
const MAX_FULL_VIEW_LINES = 1000;
|
|
5
7
|
export const CodeBlock = React.memo(({ code, language = 'text', title }) => {
|
|
8
|
+
const [showFull, setShowFull] = useState(false);
|
|
9
|
+
useInput((input, key) => {
|
|
10
|
+
if (input === 'o' && key.ctrl) {
|
|
11
|
+
setShowFull(prev => !prev);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
6
14
|
const lines = code.split('\n');
|
|
7
15
|
// Determine if we need to truncate
|
|
8
16
|
const totalLines = lines.length;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
17
|
+
const limit = showFull ? MAX_FULL_VIEW_LINES : MAX_PREVIEW_LINES;
|
|
18
|
+
const shouldTruncate = totalLines > limit;
|
|
19
|
+
const displayLines = shouldTruncate ? lines.slice(0, limit) : lines;
|
|
20
|
+
const hiddenLines = shouldTruncate ? totalLines - limit : 0;
|
|
12
21
|
return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "#003b59", paddingX: 1, paddingY: 1 },
|
|
13
|
-
title && (React.createElement(Box, { marginBottom: 1 },
|
|
14
|
-
React.createElement(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
title && (React.createElement(Box, { marginBottom: 1, justifyContent: "space-between" },
|
|
23
|
+
React.createElement(Box, null,
|
|
24
|
+
React.createElement(Text, { color: "#00ccff", bold: true },
|
|
25
|
+
"\uD83D\uDCC4 ",
|
|
26
|
+
title),
|
|
27
|
+
language && React.createElement(Text, { color: "#666666" },
|
|
28
|
+
" (",
|
|
29
|
+
language,
|
|
30
|
+
")")),
|
|
31
|
+
React.createElement(Text, { color: "#666666", dimColor: true }, showFull ? 'Press Ctrl+O to collapse' : 'Press Ctrl+O to expand'))),
|
|
21
32
|
displayLines.map((line, idx) => (React.createElement(Box, { key: idx },
|
|
22
33
|
React.createElement(Text, { color: "#666666" },
|
|
23
34
|
String(idx + 1).padStart(3, ' '),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../src/ui/components/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","sourceRoot":"","sources":["../../../src/ui/components/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAQ1C,oDAAoD;AACpD,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,+CAA+C;AAC/C,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAA6B,KAAK,CAAC,IAAI,CAAC,CAAC,EAC7D,IAAI,EACJ,QAAQ,GAAG,MAAM,EACjB,KAAK,EACN,EAAE,EAAE;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE/B,mCAAmC;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC;IAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACjE,MAAM,cAAc,GAAG,UAAU,GAAG,KAAK,CAAC;IAC1C,MAAM,YAAY,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,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AAC,CAAC,OAAO;iCACvD,CACH,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiffViewer.d.ts","sourceRoot":"","sources":["../../../src/ui/components/DiffViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"DiffViewer.d.ts","sourceRoot":"","sources":["../../../src/ui/components/DiffViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgJhD,CAAC"}
|
|
@@ -1,77 +1,114 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return false;
|
|
15
|
-
if (line.startsWith('Index:'))
|
|
16
|
-
return false;
|
|
17
|
-
if (trimmed.startsWith('==='))
|
|
18
|
-
return false;
|
|
19
|
-
// Keep empty lines and actual diff content
|
|
20
|
-
return true;
|
|
21
|
-
});
|
|
22
|
-
// Count additions and deletions BEFORE rendering
|
|
23
|
-
const addedCount = contentLines.filter(line => line.startsWith('+')).length;
|
|
24
|
-
const deletedCount = contentLines.filter(line => line.startsWith('-')).length;
|
|
25
|
-
// Determine if we need to truncate
|
|
26
|
-
const totalLines = contentLines.length;
|
|
27
|
-
const shouldTruncate = totalLines > MAX_PREVIEW_LINES;
|
|
28
|
-
const displayLines = shouldTruncate ? contentLines.slice(0, MAX_PREVIEW_LINES) : contentLines;
|
|
29
|
-
const hiddenLines = shouldTruncate ? totalLines - MAX_PREVIEW_LINES : 0;
|
|
30
|
-
const getLineStyle = (line) => {
|
|
31
|
-
if (line.startsWith('+')) {
|
|
32
|
-
return { backgroundColor: 'green', color: 'black' };
|
|
33
|
-
}
|
|
34
|
-
if (line.startsWith('-')) {
|
|
35
|
-
return { backgroundColor: 'red', color: 'black' };
|
|
36
|
-
}
|
|
37
|
-
return { color: 'white' };
|
|
38
|
-
};
|
|
39
|
-
const getDisplayLine = (line) => {
|
|
40
|
-
// Remove +/- prefix from diff lines
|
|
41
|
-
if (line.startsWith('+')) {
|
|
42
|
-
return line.slice(1);
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
|
+
import { wrapText } from '../../utils/markdown-parser.js';
|
|
4
|
+
// Maximum number of lines to show before truncating in diff view
|
|
5
|
+
// Reduced to 5 to prevent screen overflow and UI glitching
|
|
6
|
+
const MAX_PREVIEW_LINES = 5;
|
|
7
|
+
// Maximum number of lines to show in full view before truncating
|
|
8
|
+
const MAX_FULL_VIEW_LINES = 1000;
|
|
9
|
+
export const DiffViewer = ({ diff, filePath, fullDiff }) => {
|
|
10
|
+
const [showFull, setShowFull] = useState(false);
|
|
11
|
+
useInput((input, key) => {
|
|
12
|
+
if (fullDiff && input === 'o' && key.ctrl) {
|
|
13
|
+
setShowFull(prev => !prev);
|
|
43
14
|
}
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
});
|
|
16
|
+
const renderDiffContent = (diffText, maxLines) => {
|
|
17
|
+
const lines = diffText.split('\n');
|
|
18
|
+
// Parse diff to find starting line numbers
|
|
19
|
+
let currentLineNum = 1; // Default if no header found
|
|
20
|
+
// Filter out diff metadata lines and count changes
|
|
21
|
+
const contentLines = [];
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const trimmed = line.trim();
|
|
24
|
+
// Handle diff headers to update line number
|
|
25
|
+
if (line.startsWith('@@')) {
|
|
26
|
+
// Parse @@ -old,count +new,count @@
|
|
27
|
+
const match = line.match(/@@ \-\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
|
|
28
|
+
if (match && match[1]) {
|
|
29
|
+
currentLineNum = parseInt(match[1], 10);
|
|
30
|
+
}
|
|
31
|
+
continue; // Skip the header line itself in display
|
|
32
|
+
}
|
|
33
|
+
// Skip other metadata
|
|
34
|
+
if (line.startsWith('---') || line.startsWith('+++'))
|
|
35
|
+
continue;
|
|
36
|
+
if (line.startsWith('Index:'))
|
|
37
|
+
continue;
|
|
38
|
+
if (trimmed.startsWith('==='))
|
|
39
|
+
continue;
|
|
40
|
+
// Process content lines
|
|
41
|
+
if (line.startsWith('+')) {
|
|
42
|
+
contentLines.push({ text: line.slice(1), type: 'added', lineNum: currentLineNum++ });
|
|
43
|
+
}
|
|
44
|
+
else if (line.startsWith('-')) {
|
|
45
|
+
contentLines.push({ text: line.slice(1), type: 'deleted' });
|
|
46
|
+
// Do not increment currentLineNum for deletions in the new file
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Context line
|
|
50
|
+
contentLines.push({ text: line.slice(1), type: 'context', lineNum: currentLineNum++ });
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
|
-
|
|
53
|
+
// Count additions and deletions
|
|
54
|
+
const addedCount = contentLines.filter(l => l.type === 'added').length;
|
|
55
|
+
const deletedCount = contentLines.filter(l => l.type === 'deleted').length;
|
|
56
|
+
// Determine if we need to truncate
|
|
57
|
+
const totalLines = contentLines.length;
|
|
58
|
+
const shouldTruncate = totalLines > maxLines;
|
|
59
|
+
const displayLines = shouldTruncate ? contentLines.slice(0, maxLines) : contentLines;
|
|
60
|
+
const hiddenLines = shouldTruncate ? totalLines - maxLines : 0;
|
|
61
|
+
const getLineStyle = (type) => {
|
|
62
|
+
if (type === 'added')
|
|
63
|
+
return { backgroundColor: 'green', color: 'black' };
|
|
64
|
+
if (type === 'deleted')
|
|
65
|
+
return { backgroundColor: 'red', color: 'black' };
|
|
66
|
+
return { color: 'white' };
|
|
67
|
+
};
|
|
68
|
+
// Generate summary text
|
|
69
|
+
const addedText = addedCount === 1 ? '1 line added' : `${addedCount} lines added`;
|
|
70
|
+
const deletedText = deletedCount === 1 ? '1 line deleted' : `${deletedCount} lines deleted`;
|
|
71
|
+
// Calculate available width for content
|
|
72
|
+
// Terminal width - borders (2) - padding (2) - line number (5 with space)
|
|
73
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
74
|
+
const maxContentWidth = Math.max(40, terminalWidth - 11);
|
|
75
|
+
return (React.createElement(React.Fragment, null,
|
|
76
|
+
displayLines.map((line, idx) => {
|
|
77
|
+
const style = getLineStyle(line.type);
|
|
78
|
+
// Format line number: fixed width 4 chars
|
|
79
|
+
const lineNumStr = line.lineNum ? line.lineNum.toString().padStart(4, ' ') : ' ';
|
|
80
|
+
// Use wrapText utility to wrap long lines properly
|
|
81
|
+
const text = line.text || ' ';
|
|
82
|
+
const wrappedLines = wrapText(text, maxContentWidth, 0);
|
|
83
|
+
return wrappedLines.map((wrappedLine, lineIdx) => (React.createElement(Box, { key: `${idx}-${lineIdx}`, flexDirection: "column" },
|
|
84
|
+
React.createElement(Box, { flexDirection: "row" },
|
|
85
|
+
React.createElement(Text, { color: "gray" },
|
|
86
|
+
lineIdx === 0 ? lineNumStr : ' ',
|
|
87
|
+
' '),
|
|
88
|
+
React.createElement(Text, { ...style }, wrappedLine)))));
|
|
89
|
+
}).flat(),
|
|
90
|
+
shouldTruncate && (React.createElement(Box, { marginTop: 1 },
|
|
91
|
+
React.createElement(Text, { color: "#ffaa00", dimColor: true },
|
|
92
|
+
"... ",
|
|
93
|
+
hiddenLines,
|
|
94
|
+
" more ",
|
|
95
|
+
hiddenLines === 1 ? 'line' : 'lines',
|
|
96
|
+
" not shown ..."))),
|
|
97
|
+
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
98
|
+
React.createElement(Text, { color: "#666666" }, '─'.repeat(80))),
|
|
99
|
+
React.createElement(Box, null,
|
|
100
|
+
React.createElement(Text, { color: "green" }, addedText),
|
|
101
|
+
React.createElement(Text, { color: "#666666" }, ", "),
|
|
102
|
+
React.createElement(Text, { color: "red" }, deletedText))));
|
|
48
103
|
};
|
|
49
|
-
// Generate summary text
|
|
50
|
-
const addedText = addedCount === 1 ? '1 line added' : `${addedCount} lines added`;
|
|
51
|
-
const deletedText = deletedCount === 1 ? '1 line deleted' : `${deletedCount} lines deleted`;
|
|
52
104
|
return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "#ffaa00", paddingX: 1 },
|
|
53
|
-
React.createElement(Box,
|
|
54
|
-
React.createElement(Text, { color: "#ffffff", bold: true },
|
|
55
|
-
|
|
56
|
-
React.createElement(Text, { color: "#666666" }, '─'.repeat(120))),
|
|
57
|
-
displayLines.map((line, idx) => {
|
|
58
|
-
const style = getLineStyle(line);
|
|
59
|
-
const displayText = getDisplayLine(line);
|
|
60
|
-
return (React.createElement(Box, { key: idx },
|
|
61
|
-
React.createElement(Text, { ...style }, displayText || ' ')));
|
|
62
|
-
}),
|
|
63
|
-
shouldTruncate && (React.createElement(Box, { marginTop: 1 },
|
|
64
|
-
React.createElement(Text, { color: "#ffaa00", dimColor: true },
|
|
65
|
-
"... ",
|
|
66
|
-
hiddenLines,
|
|
67
|
-
" more ",
|
|
68
|
-
hiddenLines === 1 ? 'line' : 'lines',
|
|
69
|
-
" not shown ..."))),
|
|
105
|
+
React.createElement(Box, { justifyContent: "space-between" },
|
|
106
|
+
React.createElement(Text, { color: "#ffffff", bold: true }, showFull ? 'Full File Preview' : 'Diff Preview'),
|
|
107
|
+
fullDiff && (React.createElement(Text, { color: "#666666", dimColor: true }, showFull ? 'Press Ctrl+O for Diff' : 'Press Ctrl+O for Full File'))),
|
|
70
108
|
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
71
|
-
React.createElement(Text, { color: "#666666" }, '─'.repeat(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
React.createElement(Text, { color: "red" }, deletedText))));
|
|
109
|
+
React.createElement(Text, { color: "#666666" }, '─'.repeat(80))),
|
|
110
|
+
showFull && fullDiff
|
|
111
|
+
? renderDiffContent(fullDiff, MAX_FULL_VIEW_LINES)
|
|
112
|
+
: renderDiffContent(diff, MAX_PREVIEW_LINES)));
|
|
76
113
|
};
|
|
77
114
|
//# sourceMappingURL=DiffViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiffViewer.js","sourceRoot":"","sources":["../../../src/ui/components/DiffViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DiffViewer.js","sourceRoot":"","sources":["../../../src/ui/components/DiffViewer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAQ1D,iEAAiE;AACjE,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,iEAAiE;AACjE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IACpF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,QAAQ,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAC1C,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB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,QAAQ,UAC3B,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,4BAA4B,CAC7D,CACR,CACG;QAGN,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;YAChC,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS,IAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAQ,CACzC;QAEL,QAAQ,IAAI,QAAQ;YACnB,CAAC,CAAC,iBAAiB,CAAC,QAAQ,EAAE,mBAAmB,CAAC;YAClD,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAE1C,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCreationPreview.d.ts","sourceRoot":"","sources":["../../../src/ui/components/FileCreationPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,UAAU,wBAAwB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAQD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAmFlE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
|
+
import { wrapText } from '../../utils/markdown-parser.js';
|
|
4
|
+
// Maximum number of lines to show before truncating in preview
|
|
5
|
+
// Using 10 lines as a reasonable default for preview
|
|
6
|
+
const MAX_PREVIEW_LINES = 10;
|
|
7
|
+
// Maximum number of lines to show in full view before truncating
|
|
8
|
+
const MAX_FULL_VIEW_LINES = 1000;
|
|
9
|
+
export const FileCreationPreview = ({ content, filePath }) => {
|
|
10
|
+
const [showFull, setShowFull] = useState(false);
|
|
11
|
+
useInput((input, key) => {
|
|
12
|
+
if (input === 'o' && key.ctrl) {
|
|
13
|
+
setShowFull(prev => !prev);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const renderContent = (text, maxLines) => {
|
|
17
|
+
const lines = text.split('\n');
|
|
18
|
+
const totalLines = lines.length;
|
|
19
|
+
const shouldTruncate = totalLines > maxLines;
|
|
20
|
+
const displayLines = shouldTruncate ? lines.slice(0, maxLines) : lines;
|
|
21
|
+
const hiddenLines = shouldTruncate ? totalLines - maxLines : 0;
|
|
22
|
+
// Calculate available width for content
|
|
23
|
+
// Terminal width - borders (2) - padding (2) - line number (5 with space)
|
|
24
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
25
|
+
const maxContentWidth = Math.max(40, terminalWidth - 11);
|
|
26
|
+
return (React.createElement(React.Fragment, null,
|
|
27
|
+
displayLines.map((line, idx) => {
|
|
28
|
+
// Format line number: fixed width 4 chars
|
|
29
|
+
const lineNumStr = (idx + 1).toString().padStart(4, ' ');
|
|
30
|
+
// Use wrapText utility to wrap long lines properly
|
|
31
|
+
const wrappedLines = wrapText(line || ' ', maxContentWidth, 0);
|
|
32
|
+
return wrappedLines.map((wrappedLine, lineIdx) => (React.createElement(Box, { key: `${idx}-${lineIdx}`, flexDirection: "column" },
|
|
33
|
+
React.createElement(Box, { flexDirection: "row" },
|
|
34
|
+
React.createElement(Text, { color: "gray" },
|
|
35
|
+
lineIdx === 0 ? lineNumStr : ' ',
|
|
36
|
+
' '),
|
|
37
|
+
React.createElement(Text, { color: "white" }, wrappedLine)))));
|
|
38
|
+
}).flat(),
|
|
39
|
+
shouldTruncate && (React.createElement(Box, { marginTop: 1 },
|
|
40
|
+
React.createElement(Text, { color: "#00cc66", dimColor: true },
|
|
41
|
+
"... ",
|
|
42
|
+
hiddenLines,
|
|
43
|
+
" more ",
|
|
44
|
+
hiddenLines === 1 ? 'line' : 'lines',
|
|
45
|
+
" not shown ..."))),
|
|
46
|
+
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
47
|
+
React.createElement(Text, { color: "#666666" }, '─'.repeat(80))),
|
|
48
|
+
React.createElement(Box, null,
|
|
49
|
+
React.createElement(Text, { color: "#00cc66" },
|
|
50
|
+
totalLines,
|
|
51
|
+
" lines to be created"))));
|
|
52
|
+
};
|
|
53
|
+
return (React.createElement(Box, { flexDirection: "column", borderStyle: "round", borderColor: "#00cc66", paddingX: 1 },
|
|
54
|
+
React.createElement(Box, { justifyContent: "space-between" },
|
|
55
|
+
React.createElement(Text, { color: "#ffffff", bold: true },
|
|
56
|
+
"New File Preview: ",
|
|
57
|
+
filePath || 'Untitled'),
|
|
58
|
+
React.createElement(Text, { color: "#666666", dimColor: true }, showFull ? 'Press Ctrl+O to collapse' : 'Press Ctrl+O for Full File')),
|
|
59
|
+
React.createElement(Box, { marginTop: 1, marginBottom: 1 },
|
|
60
|
+
React.createElement(Text, { color: "#666666" }, '─'.repeat(80))),
|
|
61
|
+
renderContent(content, showFull ? MAX_FULL_VIEW_LINES : MAX_PREVIEW_LINES)));
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=FileCreationPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileCreationPreview.js","sourceRoot":"","sources":["../../../src/ui/components/FileCreationPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAO1D,+DAA+D;AAC/D,qDAAqD;AACrD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,iEAAiE;AACjE,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7F,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC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AAQ,IAAI,UAAU,CAAQ;YAC5E,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,UACzB,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,4BAA4B,CAClE,CACL;QAGN,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC;YAC9B,oBAAC,IAAI,IAAC,KAAK,EAAC,SAAS,IAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAQ,CAC3C;QAEL,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CACzE,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBox.d.ts","sourceRoot":"","sources":["../../../src/ui/components/InputBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"InputBox.d.ts","sourceRoot":"","sources":["../../../src/ui/components/InputBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD,UAAU,aAAa;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+CD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAs5B3C,CAAC"}
|
|
@@ -6,6 +6,8 @@ import { Breadcrumbs } from './Breadcrumbs.js';
|
|
|
6
6
|
import { ContextWindowIndicator } from './ContextWindowIndicator.js';
|
|
7
7
|
import { detectIntent } from '../../utils/input-classifier.js';
|
|
8
8
|
import { CommandHistoryManager } from '../../utils/command-history.js';
|
|
9
|
+
import { SlashCommandAutocomplete } from './SlashCommandAutocomplete.js';
|
|
10
|
+
import { filterCommands } from '../../config/slash-commands.js';
|
|
9
11
|
const getVisualLines = (text, width) => {
|
|
10
12
|
const logicalLines = text.split('\n');
|
|
11
13
|
const visualLines = [];
|
|
@@ -61,6 +63,10 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
61
63
|
const [redoStack, setRedoStack] = useState([]);
|
|
62
64
|
// Selection State
|
|
63
65
|
const [selection, setSelection] = useState(null);
|
|
66
|
+
// Slash Command Autocomplete State
|
|
67
|
+
const [slashAutocompleteVisible, setSlashAutocompleteVisible] = useState(false);
|
|
68
|
+
const [slashAutocompleteCommands, setSlashAutocompleteCommands] = useState([]);
|
|
69
|
+
const [slashAutocompleteSelectedIndex, setSlashAutocompleteSelectedIndex] = useState(0);
|
|
64
70
|
// Configuration for scrolling
|
|
65
71
|
const MAX_VISIBLE_LINES = 9;
|
|
66
72
|
// Load history on mount
|
|
@@ -153,6 +159,38 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
153
159
|
// Detect OS for platform-specific key handling
|
|
154
160
|
const isWindows = process.platform === 'win32';
|
|
155
161
|
const inputCharCode = input ? input.charCodeAt(0) : null;
|
|
162
|
+
// Handle slash command autocomplete navigation
|
|
163
|
+
if (slashAutocompleteVisible) {
|
|
164
|
+
if (key.downArrow) {
|
|
165
|
+
setSlashAutocompleteSelectedIndex(prev => Math.min(prev + 1, slashAutocompleteCommands.length - 1));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (key.upArrow) {
|
|
169
|
+
setSlashAutocompleteSelectedIndex(prev => Math.max(prev - 1, 0));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (key.return && input.length <= 1 && !key.shift && !key.ctrl) {
|
|
173
|
+
// Select the highlighted command
|
|
174
|
+
const selected = slashAutocompleteCommands[slashAutocompleteSelectedIndex];
|
|
175
|
+
// Check if we're in MCP subcommand mode
|
|
176
|
+
if (value.startsWith('/mcp ')) {
|
|
177
|
+
// We're selecting an MCP subcommand, keep "/mcp " and append the subcommand
|
|
178
|
+
setValue(`/mcp ${selected.name} `);
|
|
179
|
+
setCursorOffset(`/mcp ${selected.name} `.length);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Regular slash command, replace everything
|
|
183
|
+
setValue(`/${selected.name} `);
|
|
184
|
+
setCursorOffset(`/${selected.name} `.length);
|
|
185
|
+
}
|
|
186
|
+
setSlashAutocompleteVisible(false);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (key.escape) {
|
|
190
|
+
setSlashAutocompleteVisible(false);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
156
194
|
// DELETE WORD BACKWARDS - Check this FIRST before standard backspace/delete
|
|
157
195
|
// Triggers on any of these conditions:
|
|
158
196
|
// 1. Ctrl+W (char code 23) - Standard Unix terminal shortcut
|
|
@@ -178,6 +216,35 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
178
216
|
const newValue = value.slice(0, newOffset) + value.slice(cursorOffset);
|
|
179
217
|
setValue(newValue);
|
|
180
218
|
setCursorOffset(newOffset);
|
|
219
|
+
// Update slash command autocomplete
|
|
220
|
+
if (newValue.startsWith('/') && !newValue.includes(' ')) {
|
|
221
|
+
const query = newValue.slice(1);
|
|
222
|
+
const matches = filterCommands(query);
|
|
223
|
+
if (matches.length > 0) {
|
|
224
|
+
setSlashAutocompleteCommands(matches);
|
|
225
|
+
setSlashAutocompleteVisible(true);
|
|
226
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
setSlashAutocompleteVisible(false);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (newValue.startsWith('/mcp ')) {
|
|
233
|
+
// MCP subcommands
|
|
234
|
+
const fullQuery = newValue.slice(1);
|
|
235
|
+
const matches = filterCommands(fullQuery);
|
|
236
|
+
if (matches.length > 0) {
|
|
237
|
+
setSlashAutocompleteCommands(matches);
|
|
238
|
+
setSlashAutocompleteVisible(true);
|
|
239
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
setSlashAutocompleteVisible(false);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
setSlashAutocompleteVisible(false);
|
|
247
|
+
}
|
|
181
248
|
}
|
|
182
249
|
setHistoryIndex(-1);
|
|
183
250
|
setCompletions([]);
|
|
@@ -237,35 +304,61 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
237
304
|
// 1. Backspace or Delete key flag is present
|
|
238
305
|
// 2. OR char code 8 (standard backspace)
|
|
239
306
|
// 3. OR char code 127 (DEL) on non-Windows (Mac/Linux treat 127 as normal backspace)
|
|
307
|
+
// NOTE: On Windows/Ink, Backspace often reports as 'delete: true', so we treat key.delete as Backspace to ensure the Backspace key works correctly.
|
|
240
308
|
const isDeleteChar = key.backspace ||
|
|
241
309
|
key.delete ||
|
|
242
310
|
inputCharCode === 8 ||
|
|
243
311
|
(!isWindows && inputCharCode === 127);
|
|
244
312
|
if (isDeleteChar) {
|
|
245
313
|
pushToUndoStack();
|
|
314
|
+
let newValue = value;
|
|
246
315
|
if (selection) {
|
|
247
316
|
// Delete selection
|
|
248
317
|
const start = Math.min(selection.start, selection.end);
|
|
249
318
|
const end = Math.max(selection.start, selection.end);
|
|
250
|
-
|
|
319
|
+
newValue = value.slice(0, start) + value.slice(end);
|
|
251
320
|
setValue(newValue);
|
|
252
321
|
setCursorOffset(start);
|
|
253
322
|
setSelection(null);
|
|
254
323
|
}
|
|
255
|
-
else if (key.delete && cursorOffset < value.length) {
|
|
256
|
-
// Delete key: Delete character at cursor (forward delete)
|
|
257
|
-
const newValue = value.slice(0, cursorOffset) + value.slice(cursorOffset + 1);
|
|
258
|
-
setValue(newValue);
|
|
259
|
-
}
|
|
260
324
|
else if (cursorOffset > 0) {
|
|
261
|
-
// Backspace: Delete character before cursor
|
|
262
|
-
|
|
325
|
+
// Backspace (or Delete acting as Backspace): Delete character before cursor
|
|
326
|
+
newValue = value.slice(0, cursorOffset - 1) + value.slice(cursorOffset);
|
|
263
327
|
setValue(newValue);
|
|
264
328
|
setCursorOffset(cursorOffset - 1);
|
|
265
329
|
}
|
|
266
330
|
// Reset history/completions on edit
|
|
267
331
|
setHistoryIndex(-1);
|
|
268
332
|
setCompletions([]);
|
|
333
|
+
// Update slash command autocomplete
|
|
334
|
+
if (newValue.startsWith('/') && !newValue.includes(' ')) {
|
|
335
|
+
const query = newValue.slice(1);
|
|
336
|
+
const matches = filterCommands(query);
|
|
337
|
+
if (matches.length > 0) {
|
|
338
|
+
setSlashAutocompleteCommands(matches);
|
|
339
|
+
setSlashAutocompleteVisible(true);
|
|
340
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
setSlashAutocompleteVisible(false);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else if (newValue.startsWith('/mcp ')) {
|
|
347
|
+
// MCP subcommands
|
|
348
|
+
const fullQuery = newValue.slice(1);
|
|
349
|
+
const matches = filterCommands(fullQuery);
|
|
350
|
+
if (matches.length > 0) {
|
|
351
|
+
setSlashAutocompleteCommands(matches);
|
|
352
|
+
setSlashAutocompleteVisible(true);
|
|
353
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
setSlashAutocompleteVisible(false);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
setSlashAutocompleteVisible(false);
|
|
361
|
+
}
|
|
269
362
|
return;
|
|
270
363
|
}
|
|
271
364
|
// Handle Enter
|
|
@@ -509,6 +602,36 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
509
602
|
// Reset history/completions
|
|
510
603
|
setHistoryIndex(-1);
|
|
511
604
|
setCompletions([]);
|
|
605
|
+
// Check for slash command autocomplete
|
|
606
|
+
if (newValue.startsWith('/') && !newValue.includes(' ')) {
|
|
607
|
+
// Main slash commands (no space yet)
|
|
608
|
+
const query = newValue.slice(1);
|
|
609
|
+
const matches = filterCommands(query);
|
|
610
|
+
if (matches.length > 0) {
|
|
611
|
+
setSlashAutocompleteCommands(matches);
|
|
612
|
+
setSlashAutocompleteVisible(true);
|
|
613
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
setSlashAutocompleteVisible(false);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
else if (newValue.startsWith('/mcp ')) {
|
|
620
|
+
// MCP subcommands (when user types "/mcp ")
|
|
621
|
+
const fullQuery = newValue.slice(1); // Remove leading "/", pass "mcp <subquery>" to filterCommands
|
|
622
|
+
const matches = filterCommands(fullQuery);
|
|
623
|
+
if (matches.length > 0) {
|
|
624
|
+
setSlashAutocompleteCommands(matches);
|
|
625
|
+
setSlashAutocompleteVisible(true);
|
|
626
|
+
setSlashAutocompleteSelectedIndex(0);
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
setSlashAutocompleteVisible(false);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
setSlashAutocompleteVisible(false);
|
|
634
|
+
}
|
|
512
635
|
}
|
|
513
636
|
}, { isActive });
|
|
514
637
|
const handleTabCompletion = async () => {
|
|
@@ -707,10 +830,11 @@ export const InputBox = React.memo(({ onSubmit, placeholder = 'Ask anything...',
|
|
|
707
830
|
React.createElement(Text, { color: "#666666" }, "> "),
|
|
708
831
|
renderInput()),
|
|
709
832
|
React.createElement(Box, { marginY: 1, justifyContent: "space-between", width: "100%" },
|
|
710
|
-
React.createElement(Text, { color: "#666666", dimColor: true }, isAutoMode ? ('Ctrl+D to
|
|
833
|
+
React.createElement(Text, { color: "#666666", dimColor: true }, isAutoMode ? ('Ctrl+D to switch modes • Ctrl+T to auto-approve') : commandMode ? ('Ctrl+D to switch modes • Tab for autocomplete') : ('Ctrl+D to switch modes • Ctrl+T to auto-approve • Shift+Enter for new line')),
|
|
711
834
|
React.createElement(Box, { gap: 1 },
|
|
712
835
|
!commandMode && autoAcceptMode ? (React.createElement(Text, { color: "#00cc66", bold: true }, "[AUTO-ACCEPT: ON]")) : !commandMode ? (React.createElement(Text, { color: "#666666", dimColor: true }, "[AUTO-ACCEPT: OFF]")) : null,
|
|
713
836
|
!commandMode && (React.createElement(Box, { marginLeft: 1 },
|
|
714
|
-
React.createElement(ContextWindowIndicator, { currentTokens: currentTokens, maxTokens: maxTokens })))))
|
|
837
|
+
React.createElement(ContextWindowIndicator, { currentTokens: currentTokens, maxTokens: maxTokens }))))),
|
|
838
|
+
slashAutocompleteVisible && (React.createElement(SlashCommandAutocomplete, { commands: slashAutocompleteCommands, selectedIndex: slashAutocompleteSelectedIndex }))));
|
|
715
839
|
});
|
|
716
840
|
//# sourceMappingURL=InputBox.js.map
|