Test
This commit is contained in:
@@ -85,6 +85,7 @@ function buildRuntimeContext({ repo, prepResults }: BuildRuntimeContextParams):
|
|||||||
|
|
||||||
// working directory
|
// working directory
|
||||||
lines.push(`working_directory: ${process.cwd()}`);
|
lines.push(`working_directory: ${process.cwd()}`);
|
||||||
|
lines.push(`log_level: ${process.env.LOG_LEVEL}`);
|
||||||
|
|
||||||
// git status (try to get it, but don't fail if git isn't available)
|
// git status (try to get it, but don't fail if git isn't available)
|
||||||
try {
|
try {
|
||||||
|
|||||||
+8
-4
@@ -73,6 +73,7 @@ export const opencode = agent({
|
|||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
let lastActivityTime = startTime;
|
let lastActivityTime = startTime;
|
||||||
let eventCount = 0;
|
let eventCount = 0;
|
||||||
|
let stdoutBuffer = "";
|
||||||
|
|
||||||
let output = "";
|
let output = "";
|
||||||
const result = await spawn({
|
const result = await spawn({
|
||||||
@@ -83,13 +84,15 @@ export const opencode = agent({
|
|||||||
timeout: 600000, // 10 minutes timeout to prevent infinite hangs
|
timeout: 600000, // 10 minutes timeout to prevent infinite hangs
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
onStdout: async (chunk) => {
|
onStdout: async (chunk) => {
|
||||||
const parsed = JSON.parse(chunk);
|
|
||||||
log.debug(JSON.stringify(parsed, null, 2));
|
|
||||||
const text = chunk.toString();
|
const text = chunk.toString();
|
||||||
output += text;
|
output += text;
|
||||||
|
stdoutBuffer += text;
|
||||||
|
|
||||||
|
// parse each complete line as JSON (opencode outputs one JSON object per line)
|
||||||
|
const lines = stdoutBuffer.split("\n");
|
||||||
|
// keep the last (potentially incomplete) line in the buffer
|
||||||
|
stdoutBuffer = lines.pop() || "";
|
||||||
|
|
||||||
// parse each line as JSON (opencode outputs one JSON object per line)
|
|
||||||
const lines = text.split("\n");
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const trimmed = line.trim();
|
const trimmed = line.trim();
|
||||||
if (!trimmed) {
|
if (!trimmed) {
|
||||||
@@ -98,6 +101,7 @@ export const opencode = agent({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const event = JSON.parse(trimmed) as OpenCodeEvent;
|
const event = JSON.parse(trimmed) as OpenCodeEvent;
|
||||||
|
log.debug(JSON.stringify(event, null, 2));
|
||||||
eventCount++;
|
eventCount++;
|
||||||
const timeSinceLastActivity = Date.now() - lastActivityTime;
|
const timeSinceLastActivity = Date.now() - lastActivityTime;
|
||||||
if (timeSinceLastActivity > 10000) {
|
if (timeSinceLastActivity > 10000) {
|
||||||
|
|||||||
@@ -89578,6 +89578,7 @@ function formatPrepResults(results) {
|
|||||||
function buildRuntimeContext({ repo, prepResults }) {
|
function buildRuntimeContext({ repo, prepResults }) {
|
||||||
const lines = [];
|
const lines = [];
|
||||||
lines.push(`working_directory: ${process.cwd()}`);
|
lines.push(`working_directory: ${process.cwd()}`);
|
||||||
|
lines.push(`log_level: ${process.env.LOG_LEVEL}`);
|
||||||
try {
|
try {
|
||||||
const gitStatus = execSync("git status --short", { encoding: "utf-8", stdio: "pipe" }).trim();
|
const gitStatus = execSync("git status --short", { encoding: "utf-8", stdio: "pipe" }).trim();
|
||||||
lines.push(`git_status: ${gitStatus || "(clean)"}`);
|
lines.push(`git_status: ${gitStatus || "(clean)"}`);
|
||||||
@@ -91298,6 +91299,7 @@ var opencode = agent({
|
|||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
let lastActivityTime = startTime;
|
let lastActivityTime = startTime;
|
||||||
let eventCount = 0;
|
let eventCount = 0;
|
||||||
|
let stdoutBuffer = "";
|
||||||
let output = "";
|
let output = "";
|
||||||
const result = await spawn4({
|
const result = await spawn4({
|
||||||
cmd: cliPath,
|
cmd: cliPath,
|
||||||
@@ -91308,11 +91310,11 @@ var opencode = agent({
|
|||||||
// 10 minutes timeout to prevent infinite hangs
|
// 10 minutes timeout to prevent infinite hangs
|
||||||
stdio: ["ignore", "pipe", "pipe"],
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
onStdout: async (chunk) => {
|
onStdout: async (chunk) => {
|
||||||
const parsed2 = JSON.parse(chunk);
|
|
||||||
log.debug(JSON.stringify(parsed2, null, 2));
|
|
||||||
const text = chunk.toString();
|
const text = chunk.toString();
|
||||||
output += text;
|
output += text;
|
||||||
const lines = text.split("\n");
|
stdoutBuffer += text;
|
||||||
|
const lines = stdoutBuffer.split("\n");
|
||||||
|
stdoutBuffer = lines.pop() || "";
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
const trimmed = line.trim();
|
const trimmed = line.trim();
|
||||||
if (!trimmed) {
|
if (!trimmed) {
|
||||||
@@ -91320,6 +91322,7 @@ var opencode = agent({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const event = JSON.parse(trimmed);
|
const event = JSON.parse(trimmed);
|
||||||
|
log.debug(JSON.stringify(event, null, 2));
|
||||||
eventCount++;
|
eventCount++;
|
||||||
const timeSinceLastActivity = Date.now() - lastActivityTime;
|
const timeSinceLastActivity = Date.now() - lastActivityTime;
|
||||||
if (timeSinceLastActivity > 1e4) {
|
if (timeSinceLastActivity > 1e4) {
|
||||||
|
|||||||
Reference in New Issue
Block a user