Refactor CLI and InkApp components for improved functionality and user experience. Update model settings in InkApp, enhance terminal input handling, and streamline dependency management in package.json. Remove unused dependencies and update dotenv version for better environment variable management.

This commit is contained in:
sebseb7
2025-08-13 00:59:20 +00:00
parent 58d8c352f3
commit 83ac8709b7
8 changed files with 457 additions and 646 deletions

View File

@@ -30,22 +30,24 @@ class TerminalService extends EventEmitter {
env: {
...process.env,
TERM: 'xterm-256color',
PS1: '> '
PS1: 'bash> '
},
});
this.ptyProcess.onData((data) => {
const str = String(data);
for (let i = 0; i < str.length; i += 1) {
const ch = str[i];
if (ch === '\\n') {
// Normalize CRLF to LF to avoid double-handling \r and \n
const normalized = str.replace(/\r\n/g, '\n');
for (let i = 0; i < normalized.length; i += 1) {
const ch = normalized[i];
if (ch === '\n') {
// Line feed completes the current line
this.lines.push(this.partial);
this.partial = '';
} else if (ch === '\\r') {
// Carriage return: move to start of line; start overwriting
} else if (ch === '\r') {
// Standalone carriage return: simulate return to start of line (overwrite)
this.partial = '';
} else if (ch === '\\b' || ch === '\\x7f') {
} else if (ch === '\b' || ch === '\x7f') {
// Backspace or DEL: remove last char if present
if (this.partial.length > 0) {
this.partial = this.partial.slice(0, -1);