@xagent-ai/cli 1.3.2 → 1.3.4
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.js +18 -7
- package/dist/cli.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +3 -1
- package/dist/session.js.map +1 -1
- package/dist/shell.d.ts +9 -0
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +28 -0
- package/dist/shell.js.map +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +6 -5
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +18 -7
- package/src/session.ts +4 -2
- package/src/shell.ts +31 -0
- package/src/tools.ts +6 -5
package/src/shell.ts
CHANGED
|
@@ -2,6 +2,37 @@ import { existsSync } from 'fs';
|
|
|
2
2
|
import { spawn, spawnSync } from 'child_process';
|
|
3
3
|
import { output as logOutput } from './output-util.js';
|
|
4
4
|
|
|
5
|
+
// Track if Windows console encoding has been initialized
|
|
6
|
+
let windowsEncodingInitialized = false;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Initialize Windows console encoding to UTF-8.
|
|
10
|
+
* This should be called once at startup to avoid repeated chcp calls.
|
|
11
|
+
*/
|
|
12
|
+
export function initializeWindowsEncoding(): void {
|
|
13
|
+
if (process.platform !== 'win32' || windowsEncodingInitialized) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Set code page to UTF-8 and configure console output encoding
|
|
19
|
+
spawnSync('chcp', ['65001'], {
|
|
20
|
+
encoding: 'utf-8',
|
|
21
|
+
stdio: ['ignore', 'ignore', 'ignore'] // Suppress all output
|
|
22
|
+
});
|
|
23
|
+
windowsEncodingInitialized = true;
|
|
24
|
+
} catch {
|
|
25
|
+
// Ignore errors - encoding setup is not critical
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Check if Windows encoding has been initialized.
|
|
31
|
+
*/
|
|
32
|
+
export function isWindowsEncodingInitialized(): boolean {
|
|
33
|
+
return windowsEncodingInitialized;
|
|
34
|
+
}
|
|
35
|
+
|
|
5
36
|
/**
|
|
6
37
|
* Find bash executable on PATH (Windows).
|
|
7
38
|
*/
|
package/src/tools.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { getCancellationManager } from './cancellation.js';
|
|
|
14
14
|
import { SystemPromptGenerator } from './system-prompt-generator.js';
|
|
15
15
|
import { getSingletonSession } from './session.js';
|
|
16
16
|
import { ripgrep, fdFind } from './ripgrep.js';
|
|
17
|
-
import { getShellConfig, killProcessTree, quoteShellCommand } from './shell.js';
|
|
17
|
+
import { getShellConfig, killProcessTree, quoteShellCommand, isWindowsEncodingInitialized } from './shell.js';
|
|
18
18
|
import { truncateTail, buildTruncationNotice } from './truncate.js';
|
|
19
19
|
import { createAIClient } from './ai-client-factory.js';
|
|
20
20
|
|
|
@@ -445,10 +445,11 @@ This is useful when working with skills that have local dependencies.
|
|
|
445
445
|
|
|
446
446
|
// Set up cross-platform encoding environment for command execution
|
|
447
447
|
if (process.platform === 'win32') {
|
|
448
|
-
// Windows: set
|
|
449
|
-
//
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
// Windows: Only set encoding if not already initialized at startup
|
|
449
|
+
// This avoids repeated chcp calls that can cause screen flicker
|
|
450
|
+
if (!isWindowsEncodingInitialized()) {
|
|
451
|
+
finalCommand = `chcp 65001 *>$null; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${finalCommand}`;
|
|
452
|
+
}
|
|
452
453
|
} else {
|
|
453
454
|
// Unix/macOS: set locale to UTF-8 for proper encoding handling
|
|
454
455
|
finalCommand = `export LC_ALL=C.UTF-8; export LANG=C.UTF-8; export PYTHONIOENCODING=utf-8; ${finalCommand}`;
|