xibecode 0.9.9 → 1.0.0
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/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +20 -0
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/resume.d.ts +7 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +136 -0
- package/dist/commands/resume.js.map +1 -0
- package/dist/commands/run-pr.js +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +27 -15
- package/dist/commands/run.js.map +1 -1
- package/dist/core/agent.d.ts +2 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +78 -22
- package/dist/core/agent.js.map +1 -1
- package/dist/core/modes.d.ts.map +1 -1
- package/dist/core/modes.js +7 -6
- package/dist/core/modes.js.map +1 -1
- package/dist/core/plan-artifacts.d.ts.map +1 -1
- package/dist/core/plan-artifacts.js +12 -5
- package/dist/core/plan-artifacts.js.map +1 -1
- package/dist/core/tool-orchestrator.d.ts +8 -0
- package/dist/core/tool-orchestrator.d.ts.map +1 -1
- package/dist/core/tool-orchestrator.js +34 -1
- package/dist/core/tool-orchestrator.js.map +1 -1
- package/dist/core/tools.d.ts +9 -0
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/core/tools.js +114 -97
- package/dist/core/tools.js.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/ui/claude-style-chat.d.ts +5 -0
- package/dist/ui/claude-style-chat.d.ts.map +1 -1
- package/dist/ui/claude-style-chat.js +165 -12
- package/dist/ui/claude-style-chat.js.map +1 -1
- package/dist/webui/server.js +1 -1
- package/package.json +16 -29
package/dist/core/tools.js
CHANGED
|
@@ -20,8 +20,26 @@ import { SwarmOrchestrator } from './swarm.js';
|
|
|
20
20
|
import { PermissionManager } from './permissions.js';
|
|
21
21
|
import { McpOAuthFlowManager } from './mcp/oauth-flow.js';
|
|
22
22
|
const execAsync = promisify(exec);
|
|
23
|
+
const DEFAULT_COMMAND_OUTPUT_CHARS = 20000;
|
|
24
|
+
function compactCommandOutput(value, maxChars) {
|
|
25
|
+
if (value.length <= maxChars) {
|
|
26
|
+
return { output: value, truncated: false, originalLength: value.length };
|
|
27
|
+
}
|
|
28
|
+
const marker = `\n\n[output truncated: kept head/tail, original length ${value.length} chars]\n\n`;
|
|
29
|
+
const available = Math.max(0, maxChars - marker.length);
|
|
30
|
+
const headLength = Math.ceil(available * 0.6);
|
|
31
|
+
const tailLength = Math.floor(available * 0.4);
|
|
32
|
+
return {
|
|
33
|
+
output: `${value.slice(0, headLength)}${marker}${value.slice(value.length - tailLength)}`,
|
|
34
|
+
truncated: true,
|
|
35
|
+
originalLength: value.length,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
23
38
|
/** Returned by former Playwright-backed browser tools; XibeCode does not bundle browsers. */
|
|
24
39
|
export const NO_EMBEDDED_BROWSER_MESSAGE = 'XibeCode does not bundle Playwright, Chromium, or agent-browser. Install agent-browser globally on supported OS/arch if you want it, or use your environment browser MCP / fetch_url. For Playwright E2E in a repo, add @playwright/test there and run it via run_command.';
|
|
40
|
+
export const __testing = {
|
|
41
|
+
compactCommandOutput,
|
|
42
|
+
};
|
|
25
43
|
/**
|
|
26
44
|
* Main tool executor for XibeCode agent
|
|
27
45
|
*
|
|
@@ -420,7 +438,7 @@ export class CodingToolExecutor {
|
|
|
420
438
|
if (!p.command || typeof p.command !== 'string') {
|
|
421
439
|
return { error: true, success: false, message: 'Missing required parameter: command (string)' };
|
|
422
440
|
}
|
|
423
|
-
return this.runCommand(p.command, p.cwd, p.input, p.timeout);
|
|
441
|
+
return this.runCommand(p.command, p.cwd, p.input, p.timeout, p.max_output_chars);
|
|
424
442
|
}
|
|
425
443
|
case 'create_directory': {
|
|
426
444
|
if (!p.path || typeof p.path !== 'string') {
|
|
@@ -1116,6 +1134,10 @@ export class CodingToolExecutor {
|
|
|
1116
1134
|
type: 'number',
|
|
1117
1135
|
description: 'Timeout in seconds (default: 120). Increase for long-running commands like installs.',
|
|
1118
1136
|
},
|
|
1137
|
+
max_output_chars: {
|
|
1138
|
+
type: 'number',
|
|
1139
|
+
description: `Maximum stdout/stderr characters to return per stream (default: ${DEFAULT_COMMAND_OUTPUT_CHARS}). Large output is summarized with head/tail context.`,
|
|
1140
|
+
},
|
|
1119
1141
|
},
|
|
1120
1142
|
required: ['command'],
|
|
1121
1143
|
},
|
|
@@ -1821,10 +1843,16 @@ export class CodingToolExecutor {
|
|
|
1821
1843
|
}
|
|
1822
1844
|
}
|
|
1823
1845
|
async readMultipleFiles(paths) {
|
|
1824
|
-
const
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1846
|
+
const CONCURRENCY_LIMIT = 20;
|
|
1847
|
+
const results = [];
|
|
1848
|
+
for (let i = 0; i < paths.length; i += CONCURRENCY_LIMIT) {
|
|
1849
|
+
const chunk = paths.slice(i, i + CONCURRENCY_LIMIT);
|
|
1850
|
+
const chunkResults = await Promise.allSettled(chunk.map(async (p) => {
|
|
1851
|
+
const content = await this.readFile(p);
|
|
1852
|
+
return { path: p, ...content };
|
|
1853
|
+
}));
|
|
1854
|
+
results.push(...chunkResults);
|
|
1855
|
+
}
|
|
1828
1856
|
return {
|
|
1829
1857
|
files: results
|
|
1830
1858
|
.filter((r) => r.status === 'fulfilled')
|
|
@@ -1984,25 +2012,31 @@ export class CodingToolExecutor {
|
|
|
1984
2012
|
const fullPath = this.resolvePath(dirPath);
|
|
1985
2013
|
try {
|
|
1986
2014
|
const entries = await fs.readdir(fullPath, { withFileTypes: true });
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2015
|
+
const CONCURRENCY_LIMIT = 50;
|
|
2016
|
+
const results = [];
|
|
2017
|
+
for (let i = 0; i < entries.length; i += CONCURRENCY_LIMIT) {
|
|
2018
|
+
const chunk = entries.slice(i, i + CONCURRENCY_LIMIT);
|
|
2019
|
+
const chunkResults = await Promise.all(chunk.map(async (entry) => {
|
|
2020
|
+
const entryPath = path.join(fullPath, entry.name);
|
|
2021
|
+
try {
|
|
2022
|
+
const stats = await fs.stat(entryPath);
|
|
2023
|
+
return {
|
|
2024
|
+
name: entry.name,
|
|
2025
|
+
type: entry.isDirectory() ? 'directory' : 'file',
|
|
2026
|
+
size: stats.size,
|
|
2027
|
+
modified: stats.mtime,
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
catch {
|
|
2031
|
+
return {
|
|
2032
|
+
name: entry.name,
|
|
2033
|
+
type: entry.isDirectory() ? 'directory' : 'file',
|
|
2034
|
+
size: 0,
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
}));
|
|
2038
|
+
results.push(...chunkResults);
|
|
2039
|
+
}
|
|
2006
2040
|
return { path: dirPath, entries: results, count: results.length };
|
|
2007
2041
|
}
|
|
2008
2042
|
catch (error) {
|
|
@@ -2078,86 +2112,69 @@ export class CodingToolExecutor {
|
|
|
2078
2112
|
return { error: true, success: false, message: `Dynamic tool "${toolName}" not found` };
|
|
2079
2113
|
return this.runCommand(def.script, this.workingDir, undefined, 60);
|
|
2080
2114
|
}
|
|
2081
|
-
async runCommand(command, cwd, input, timeout) {
|
|
2115
|
+
async runCommand(command, cwd, input, timeout, maxOutputChars) {
|
|
2082
2116
|
const workDir = cwd ? this.resolvePath(cwd) : this.workingDir;
|
|
2083
2117
|
const timeoutMs = (timeout || 120) * 1000;
|
|
2084
2118
|
const shell = this.platform === 'win32' ? 'powershell.exe' : '/bin/sh';
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
const child = spawn(shell, this.platform === 'win32' ? ['-Command', command] : ['-c', command], {
|
|
2089
|
-
cwd: workDir,
|
|
2090
|
-
env: { ...process.env },
|
|
2091
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
2092
|
-
});
|
|
2093
|
-
let stdout = '';
|
|
2094
|
-
let stderr = '';
|
|
2095
|
-
let killed = false;
|
|
2096
|
-
const timer = setTimeout(() => {
|
|
2097
|
-
killed = true;
|
|
2098
|
-
child.kill('SIGTERM');
|
|
2099
|
-
}, timeoutMs);
|
|
2100
|
-
child.stdout.on('data', (data) => { stdout += data.toString(); });
|
|
2101
|
-
child.stderr.on('data', (data) => { stderr += data.toString(); });
|
|
2102
|
-
// Pipe stdin input (supports \n for multiple answers)
|
|
2103
|
-
const stdinData = input.replace(/\\n/g, '\n');
|
|
2104
|
-
child.stdin.write(stdinData);
|
|
2105
|
-
child.stdin.end();
|
|
2106
|
-
child.on('close', (code) => {
|
|
2107
|
-
clearTimeout(timer);
|
|
2108
|
-
resolve({
|
|
2109
|
-
stdout: stdout.trim(),
|
|
2110
|
-
stderr: stderr.trim(),
|
|
2111
|
-
success: !killed && code === 0,
|
|
2112
|
-
exitCode: code,
|
|
2113
|
-
timedOut: killed,
|
|
2114
|
-
platform: this.platform,
|
|
2115
|
-
});
|
|
2116
|
-
});
|
|
2117
|
-
child.on('error', (err) => {
|
|
2118
|
-
clearTimeout(timer);
|
|
2119
|
-
resolve({
|
|
2120
|
-
stdout: stdout.trim(),
|
|
2121
|
-
stderr: err.message,
|
|
2122
|
-
success: false,
|
|
2123
|
-
platform: this.platform,
|
|
2124
|
-
});
|
|
2125
|
-
});
|
|
2126
|
-
});
|
|
2127
|
-
}
|
|
2128
|
-
// ── Regular exec with timeout ──
|
|
2129
|
-
try {
|
|
2130
|
-
const { stdout, stderr } = await execAsync(command, {
|
|
2119
|
+
const outputLimit = Math.max(1000, maxOutputChars ?? DEFAULT_COMMAND_OUTPUT_CHARS);
|
|
2120
|
+
return new Promise((resolve) => {
|
|
2121
|
+
const child = spawn(shell, this.platform === 'win32' ? ['-Command', command] : ['-c', command], {
|
|
2131
2122
|
cwd: workDir,
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
shell: this.platform === 'win32' ? 'powershell.exe' : undefined,
|
|
2123
|
+
env: { ...process.env },
|
|
2124
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
2135
2125
|
});
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2126
|
+
let stdout = '';
|
|
2127
|
+
let stderr = '';
|
|
2128
|
+
let timedOut = false;
|
|
2129
|
+
let settled = false;
|
|
2130
|
+
const finish = (result) => {
|
|
2131
|
+
if (settled)
|
|
2132
|
+
return;
|
|
2133
|
+
settled = true;
|
|
2134
|
+
clearTimeout(timer);
|
|
2135
|
+
const compactedStdout = compactCommandOutput(String(result.stdout ?? '').trim(), outputLimit);
|
|
2136
|
+
const compactedStderr = compactCommandOutput(String(result.stderr ?? '').trim(), outputLimit);
|
|
2137
|
+
resolve({
|
|
2138
|
+
...result,
|
|
2139
|
+
stdout: compactedStdout.output,
|
|
2140
|
+
stderr: compactedStderr.output,
|
|
2141
|
+
truncated: compactedStdout.truncated || compactedStderr.truncated,
|
|
2142
|
+
originalStdoutLength: compactedStdout.originalLength,
|
|
2143
|
+
originalStderrLength: compactedStderr.originalLength,
|
|
2150
2144
|
platform: this.platform,
|
|
2151
|
-
};
|
|
2152
|
-
}
|
|
2153
|
-
return {
|
|
2154
|
-
stdout: error.stdout?.trim() || '',
|
|
2155
|
-
stderr: error.stderr?.trim() || error.message,
|
|
2156
|
-
success: false,
|
|
2157
|
-
exitCode: error.code,
|
|
2158
|
-
platform: this.platform,
|
|
2145
|
+
});
|
|
2159
2146
|
};
|
|
2160
|
-
|
|
2147
|
+
const timer = setTimeout(() => {
|
|
2148
|
+
timedOut = true;
|
|
2149
|
+
child.kill('SIGTERM');
|
|
2150
|
+
}, timeoutMs);
|
|
2151
|
+
child.stdout.on('data', (data) => { stdout += data.toString(); });
|
|
2152
|
+
child.stderr.on('data', (data) => { stderr += data.toString(); });
|
|
2153
|
+
if (input) {
|
|
2154
|
+
child.stdin.write(input.replace(/\\n/g, '\n'));
|
|
2155
|
+
}
|
|
2156
|
+
child.stdin.end();
|
|
2157
|
+
child.on('close', (code) => {
|
|
2158
|
+
finish({
|
|
2159
|
+
stdout,
|
|
2160
|
+
stderr: timedOut
|
|
2161
|
+
? `${stderr}\nCommand timed out after ${timeout || 120}s. Try increasing the timeout parameter, or use non-interactive flags like --yes to avoid prompts.`
|
|
2162
|
+
: stderr,
|
|
2163
|
+
success: !timedOut && code === 0,
|
|
2164
|
+
exitCode: code,
|
|
2165
|
+
timedOut,
|
|
2166
|
+
});
|
|
2167
|
+
});
|
|
2168
|
+
child.on('error', (err) => {
|
|
2169
|
+
finish({
|
|
2170
|
+
stdout,
|
|
2171
|
+
stderr: err.message,
|
|
2172
|
+
success: false,
|
|
2173
|
+
exitCode: undefined,
|
|
2174
|
+
timedOut,
|
|
2175
|
+
});
|
|
2176
|
+
});
|
|
2177
|
+
});
|
|
2161
2178
|
}
|
|
2162
2179
|
async createDirectory(dirPath) {
|
|
2163
2180
|
const fullPath = this.resolvePath(dirPath);
|