xforce 0.1.0 → 0.1.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/dist/cli/index.js +269 -147
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +125 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -921,6 +921,7 @@ async function runCodingAgent(params) {
|
|
|
921
921
|
},
|
|
922
922
|
"Starting coding agent"
|
|
923
923
|
);
|
|
924
|
+
let stderrOutput = "";
|
|
924
925
|
const result = query({
|
|
925
926
|
prompt,
|
|
926
927
|
options: {
|
|
@@ -936,27 +937,42 @@ async function runCodingAgent(params) {
|
|
|
936
937
|
preset: "claude_code",
|
|
937
938
|
append: CODER_SYSTEM_PROMPT_APPEND
|
|
938
939
|
},
|
|
940
|
+
stderr: (data) => {
|
|
941
|
+
stderrOutput += data;
|
|
942
|
+
log4.debug({ stderr: data.trimEnd() }, "Agent SDK stderr");
|
|
943
|
+
},
|
|
939
944
|
...sessionId ? { resume: sessionId } : {}
|
|
940
945
|
}
|
|
941
946
|
});
|
|
942
947
|
let resultMessage;
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
948
|
+
try {
|
|
949
|
+
for await (const message of result) {
|
|
950
|
+
if (message.type === "assistant" && "content" in message) {
|
|
951
|
+
const content = message.content;
|
|
952
|
+
for (const block of content) {
|
|
953
|
+
if (block.type === "tool_use" && block.name) {
|
|
954
|
+
const detail = describeToolUse(block.name, block.input);
|
|
955
|
+
log4.info({ tool: block.name }, detail);
|
|
956
|
+
onProgress?.(detail);
|
|
957
|
+
}
|
|
951
958
|
}
|
|
952
959
|
}
|
|
960
|
+
if (message.type === "result") {
|
|
961
|
+
resultMessage = message;
|
|
962
|
+
}
|
|
953
963
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
964
|
+
} catch (error) {
|
|
965
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
966
|
+
const stderrDetail = stderrOutput ? `
|
|
967
|
+
stderr:
|
|
968
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
969
|
+
throw new CodingAgentError(`Coding agent process failed: ${msg}${stderrDetail}`, [], 0);
|
|
957
970
|
}
|
|
958
971
|
if (!resultMessage) {
|
|
959
|
-
|
|
972
|
+
const detail = stderrOutput ? `
|
|
973
|
+
stderr:
|
|
974
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
975
|
+
throw new CodingAgentError(`No result message received from coding agent${detail}`, [], 0);
|
|
960
976
|
}
|
|
961
977
|
if (resultMessage.subtype === "error_max_turns") {
|
|
962
978
|
log4.warn(
|
|
@@ -974,8 +990,11 @@ async function runCodingAgent(params) {
|
|
|
974
990
|
};
|
|
975
991
|
}
|
|
976
992
|
if (resultMessage.subtype !== "success") {
|
|
993
|
+
const stderrDetail = stderrOutput ? `
|
|
994
|
+
stderr:
|
|
995
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
977
996
|
throw new CodingAgentError(
|
|
978
|
-
`Coding agent failed: ${resultMessage.subtype}`,
|
|
997
|
+
`Coding agent failed: ${resultMessage.subtype}${stderrDetail}`,
|
|
979
998
|
"errors" in resultMessage ? resultMessage.errors : [],
|
|
980
999
|
resultMessage.total_cost_usd
|
|
981
1000
|
);
|
|
@@ -1069,6 +1088,7 @@ async function runPlanningAgent(params) {
|
|
|
1069
1088
|
{ task: taskSpec.title, model: repoConfig.plannerModel },
|
|
1070
1089
|
"Starting planning agent"
|
|
1071
1090
|
);
|
|
1091
|
+
let stderrOutput = "";
|
|
1072
1092
|
const result = query2({
|
|
1073
1093
|
prompt,
|
|
1074
1094
|
options: {
|
|
@@ -1082,32 +1102,47 @@ async function runPlanningAgent(params) {
|
|
|
1082
1102
|
outputFormat: {
|
|
1083
1103
|
type: "json_schema",
|
|
1084
1104
|
schema: PLAN_JSON_SCHEMA
|
|
1105
|
+
},
|
|
1106
|
+
stderr: (data) => {
|
|
1107
|
+
stderrOutput += data;
|
|
1108
|
+
log5.debug({ stderr: data.trimEnd() }, "Agent SDK stderr");
|
|
1085
1109
|
}
|
|
1086
1110
|
}
|
|
1087
1111
|
});
|
|
1088
1112
|
let resultMessage;
|
|
1089
1113
|
let lastAssistantText = "";
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1114
|
+
try {
|
|
1115
|
+
for await (const message of result) {
|
|
1116
|
+
if (message.type === "assistant" && "content" in message) {
|
|
1117
|
+
const content = message.content;
|
|
1118
|
+
for (const block of content) {
|
|
1119
|
+
if (block.type === "tool_use" && block.name) {
|
|
1120
|
+
const detail = describeToolUse(block.name, block.input);
|
|
1121
|
+
log5.info({ tool: block.name }, detail);
|
|
1122
|
+
onProgress?.(detail);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
const textParts = content.filter((c) => c.type === "text" && c.text).map((c) => c.text);
|
|
1126
|
+
if (textParts.length > 0) {
|
|
1127
|
+
lastAssistantText = textParts.join("\n");
|
|
1098
1128
|
}
|
|
1099
1129
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
lastAssistantText = textParts.join("\n");
|
|
1130
|
+
if (message.type === "result") {
|
|
1131
|
+
resultMessage = message;
|
|
1103
1132
|
}
|
|
1104
1133
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1134
|
+
} catch (error) {
|
|
1135
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1136
|
+
const stderrDetail = stderrOutput ? `
|
|
1137
|
+
stderr:
|
|
1138
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1139
|
+
throw new PipelineError(`Planning agent process failed: ${msg}${stderrDetail}`);
|
|
1108
1140
|
}
|
|
1109
1141
|
if (!resultMessage) {
|
|
1110
|
-
|
|
1142
|
+
const detail = stderrOutput ? `
|
|
1143
|
+
stderr:
|
|
1144
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1145
|
+
throw new PipelineError(`No result message received from planning agent${detail}`);
|
|
1111
1146
|
}
|
|
1112
1147
|
log5.debug(
|
|
1113
1148
|
{
|
|
@@ -1123,8 +1158,11 @@ async function runPlanningAgent(params) {
|
|
|
1123
1158
|
const isMaxTurns = resultMessage.subtype === "error_max_turns";
|
|
1124
1159
|
if (!isSuccess && !isMaxTurns) {
|
|
1125
1160
|
const errorDetail = "errors" in resultMessage ? resultMessage.errors.join(", ") : "unknown";
|
|
1161
|
+
const stderrDetail = stderrOutput ? `
|
|
1162
|
+
stderr:
|
|
1163
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1126
1164
|
throw new PipelineError(
|
|
1127
|
-
`Planning agent failed (${resultMessage.subtype}): ${errorDetail}`
|
|
1165
|
+
`Planning agent failed (${resultMessage.subtype}): ${errorDetail}${stderrDetail}`
|
|
1128
1166
|
);
|
|
1129
1167
|
}
|
|
1130
1168
|
if (isMaxTurns) {
|
|
@@ -1316,6 +1354,7 @@ async function runReviewerAgent(params) {
|
|
|
1316
1354
|
"Starting reviewer agent"
|
|
1317
1355
|
);
|
|
1318
1356
|
const userPrompt = buildReviewerUserPrompt(taskSpec, diff, reviewCycle);
|
|
1357
|
+
let stderrOutput = "";
|
|
1319
1358
|
const agentResult = query3({
|
|
1320
1359
|
prompt: userPrompt,
|
|
1321
1360
|
options: {
|
|
@@ -1328,30 +1367,48 @@ async function runReviewerAgent(params) {
|
|
|
1328
1367
|
outputFormat: {
|
|
1329
1368
|
type: "json_schema",
|
|
1330
1369
|
schema: REVIEW_JSON_SCHEMA
|
|
1370
|
+
},
|
|
1371
|
+
stderr: (data) => {
|
|
1372
|
+
stderrOutput += data;
|
|
1373
|
+
log6.debug({ stderr: data.trimEnd() }, "Agent SDK stderr");
|
|
1331
1374
|
}
|
|
1332
1375
|
}
|
|
1333
1376
|
});
|
|
1334
1377
|
let resultMessage;
|
|
1335
1378
|
let lastAssistantText = "";
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1379
|
+
try {
|
|
1380
|
+
for await (const message of agentResult) {
|
|
1381
|
+
if (message.type === "assistant" && "content" in message) {
|
|
1382
|
+
const textParts = message.content.filter((c) => c.type === "text" && c.text).map((c) => c.text);
|
|
1383
|
+
if (textParts.length > 0) {
|
|
1384
|
+
lastAssistantText = textParts.join("\n");
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
if (message.type === "result") {
|
|
1388
|
+
resultMessage = message;
|
|
1341
1389
|
}
|
|
1342
1390
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1393
|
+
const stderrDetail = stderrOutput ? `
|
|
1394
|
+
stderr:
|
|
1395
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1396
|
+
throw new ReviewerError(`Reviewer agent process failed: ${msg}${stderrDetail}`);
|
|
1346
1397
|
}
|
|
1347
1398
|
if (!resultMessage) {
|
|
1348
|
-
|
|
1399
|
+
const detail = stderrOutput ? `
|
|
1400
|
+
stderr:
|
|
1401
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1402
|
+
throw new ReviewerError(`No result message received from reviewer agent${detail}`);
|
|
1349
1403
|
}
|
|
1350
1404
|
const isSuccess = resultMessage.subtype === "success";
|
|
1351
1405
|
const isMaxTurns = resultMessage.subtype === "error_max_turns";
|
|
1352
1406
|
if (!isSuccess && !isMaxTurns) {
|
|
1353
1407
|
const errorDetail = "errors" in resultMessage ? resultMessage.errors.join(", ") : "unknown";
|
|
1354
|
-
|
|
1408
|
+
const stderrDetail = stderrOutput ? `
|
|
1409
|
+
stderr:
|
|
1410
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1411
|
+
throw new ReviewerError(`Reviewer agent failed (${resultMessage.subtype}): ${errorDetail}${stderrDetail}`);
|
|
1355
1412
|
}
|
|
1356
1413
|
if (isMaxTurns) {
|
|
1357
1414
|
log6.warn("Reviewer hit max turns \u2014 attempting to extract result");
|
|
@@ -1486,6 +1543,7 @@ ${diff}
|
|
|
1486
1543
|
\`\`\`
|
|
1487
1544
|
|
|
1488
1545
|
Analyze this diff for security vulnerabilities. Provide your report as a JSON object matching the required schema.`;
|
|
1546
|
+
let stderrOutput = "";
|
|
1489
1547
|
const result = query4({
|
|
1490
1548
|
prompt,
|
|
1491
1549
|
options: {
|
|
@@ -1498,31 +1556,49 @@ Analyze this diff for security vulnerabilities. Provide your report as a JSON ob
|
|
|
1498
1556
|
outputFormat: {
|
|
1499
1557
|
type: "json_schema",
|
|
1500
1558
|
schema: SECURITY_REPORT_JSON_SCHEMA
|
|
1559
|
+
},
|
|
1560
|
+
stderr: (data) => {
|
|
1561
|
+
stderrOutput += data;
|
|
1562
|
+
log7.debug({ stderr: data.trimEnd() }, "Agent SDK stderr");
|
|
1501
1563
|
}
|
|
1502
1564
|
}
|
|
1503
1565
|
});
|
|
1504
1566
|
let resultMessage;
|
|
1505
1567
|
let lastAssistantText = "";
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1568
|
+
try {
|
|
1569
|
+
for await (const message of result) {
|
|
1570
|
+
if (message.type === "assistant" && "content" in message) {
|
|
1571
|
+
const textParts = message.content.filter((c) => c.type === "text" && c.text).map((c) => c.text);
|
|
1572
|
+
if (textParts.length > 0) {
|
|
1573
|
+
lastAssistantText = textParts.join("\n");
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
if (message.type === "result") {
|
|
1577
|
+
resultMessage = message;
|
|
1511
1578
|
}
|
|
1512
1579
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
1582
|
+
const stderrDetail = stderrOutput ? `
|
|
1583
|
+
stderr:
|
|
1584
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1585
|
+
throw new PipelineError(`Security scanner process failed: ${msg}${stderrDetail}`);
|
|
1516
1586
|
}
|
|
1517
1587
|
if (!resultMessage) {
|
|
1518
|
-
|
|
1588
|
+
const detail = stderrOutput ? `
|
|
1589
|
+
stderr:
|
|
1590
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1591
|
+
throw new PipelineError(`No result message received from security scanner${detail}`);
|
|
1519
1592
|
}
|
|
1520
1593
|
const isSuccess = resultMessage.subtype === "success";
|
|
1521
1594
|
const isMaxTurns = resultMessage.subtype === "error_max_turns";
|
|
1522
1595
|
if (!isSuccess && !isMaxTurns) {
|
|
1523
1596
|
const errorDetail = "errors" in resultMessage ? resultMessage.errors.join(", ") : "unknown";
|
|
1597
|
+
const stderrDetail = stderrOutput ? `
|
|
1598
|
+
stderr:
|
|
1599
|
+
${stderrOutput.slice(0, 2e3)}` : "";
|
|
1524
1600
|
throw new PipelineError(
|
|
1525
|
-
`Security scanner failed (${resultMessage.subtype}): ${errorDetail}`
|
|
1601
|
+
`Security scanner failed (${resultMessage.subtype}): ${errorDetail}${stderrDetail}`
|
|
1526
1602
|
);
|
|
1527
1603
|
}
|
|
1528
1604
|
let parsed;
|