Test build

This commit is contained in:
Colin McDonnell
2025-12-16 22:43:51 -08:00
parent 0be1ad123f
commit 85a205a43f
3 changed files with 61 additions and 43 deletions
+21 -5
View File
@@ -1,12 +1,28 @@
# Ensure lockfile is up to date if package.json changed
# Check if lockfile needs updating
if git diff --cached --name-only | grep -q "^package.json$"; then
echo "🔒 Updating lockfile..."
pnpm lock
git add pnpm-lock.yaml
fi
# Build the action before committing
# Check if entry needs rebuilding
# Rebuild if: entry.ts/esbuild.config.js/.ts files are staged, OR if entry is out of date
NEEDS_REBUILD=false
# Check staged files
if git diff --cached --name-only | grep -qE "^(entry\.ts|esbuild\.config\.js|.*\.ts)$"; then
NEEDS_REBUILD=true
fi
# Check if entry is out of date compared to entry.ts
if [ -f entry.ts ] && [ -f entry ]; then
if [ entry.ts -nt entry ] || [ esbuild.config.js -nt entry ]; then
NEEDS_REBUILD=true
fi
fi
if [ "$NEEDS_REBUILD" = true ]; then
echo "🔨 Building action..."
pnpm build
# Add the built files and lockfile to the commit
git add entry pnpm-lock.yaml
git add entry
fi
+39 -37
View File
@@ -91276,6 +91276,7 @@ var messageHandlers4 = {
log.info(
`\u{1F535} OpenCode init: session_id=${event.session_id || "unknown"}, model=${event.model || "unknown"}`
);
log.info(`\u{1F535} OpenCode init event (full): ${JSON.stringify(event)}`);
finalOutput = "";
accumulatedTokens = { input: 0, output: 0 };
tokensLogged = false;
@@ -91304,9 +91305,6 @@ var messageHandlers4 = {
text: (event) => {
if (event.part?.text?.trim()) {
const message = event.part.text.trim();
log.info(
`\u{1F4DD} OpenCode text output: ${message.substring(0, 200)}${message.length > 200 ? "..." : ""}`
);
log.box(message, { title: "OpenCode" });
finalOutput = message;
}
@@ -91333,35 +91331,39 @@ var messageHandlers4 = {
}
},
tool_use: (event) => {
if (event.tool_name && event.tool_id) {
toolCallTimings.set(event.tool_id, Date.now());
const paramsStr = event.parameters ? JSON.stringify(event.parameters).substring(0, 500) : "{}";
const stepContext = currentStepId ? ` (step=${currentStepType || "unknown"}, stepId=${currentStepId.substring(0, 20)}...)` : "";
log.info(`\u{1F527} OpenCode tool_use: ${event.tool_name}${stepContext}, id=${event.tool_id}`);
log.info(` Parameters: ${paramsStr}${paramsStr.length >= 500 ? "..." : ""}`);
const toolName = event.part?.tool;
const toolId = event.part?.callID;
const parameters = event.part?.state?.input;
const status = event.part?.state?.status;
const output = event.part?.state?.output;
if (toolName && toolId) {
if (stepHistory.length > 0) {
stepHistory[stepHistory.length - 1].toolCalls.push(event.tool_name);
stepHistory[stepHistory.length - 1].toolCalls.push(toolName);
}
log.toolCall({
toolName: event.tool_name,
input: event.parameters || {}
toolName,
input: parameters || {}
});
if (status === "completed" && output) {
log.debug(` output: ${output}`);
}
}
},
tool_result: (event) => {
if (event.tool_id) {
const toolStartTime = toolCallTimings.get(event.tool_id);
const toolId = event.part?.callID || event.tool_id;
const status = event.part?.state?.status || event.status || "unknown";
const output = event.part?.state?.output || event.output;
if (toolId) {
const toolStartTime = toolCallTimings.get(toolId);
if (toolStartTime) {
const toolDuration = Date.now() - toolStartTime;
toolCallTimings.delete(event.tool_id);
const status = event.status || "unknown";
toolCallTimings.delete(toolId);
const stepContext = currentStepId ? ` (step=${currentStepType || "unknown"})` : "";
const outputPreview = typeof event.output === "string" ? event.output.substring(0, 500) : JSON.stringify(event.output).substring(0, 500);
log.info(
`\u{1F527} OpenCode tool_result${stepContext}: id=${event.tool_id}, status=${status}, duration=${toolDuration}ms`
`\u{1F527} OpenCode tool_result${stepContext}: id=${toolId}, status=${status}, duration=${toolDuration}ms`
);
if (outputPreview && outputPreview !== "{}" && outputPreview !== "null") {
log.info(` Output: ${outputPreview}${outputPreview.length >= 500 ? "..." : ""}`);
if (output) {
log.debug(` output: ${typeof output === "string" ? output : JSON.stringify(output)}`);
}
if (toolDuration > 5e3) {
log.warning(
@@ -91370,8 +91372,8 @@ var messageHandlers4 = {
}
}
}
if (event.status === "error") {
const errorMsg = typeof event.output === "string" ? event.output : JSON.stringify(event.output);
if (status === "error") {
const errorMsg = typeof output === "string" ? output : JSON.stringify(output);
log.warning(`\u274C Tool call failed: ${errorMsg}`);
}
},
@@ -91442,6 +91444,12 @@ var opencode = agent({
const repoDir = process.cwd();
log.info(`\u{1F680} Starting OpenCode CLI: ${cliPath} ${args3.join(" ")}`);
log.info(`\u{1F4C1} Working directory: ${repoDir}`);
log.info(`\u{1F3E0} HOME env var: ${env3.HOME}`);
log.info(`\u{1F4CB} Config directory: ${join7(env3.HOME, ".config", "opencode")}`);
const envKeys = Object.keys(env3).filter(
(k) => !k.includes("KEY") && !k.includes("TOKEN") && !k.includes("SECRET")
);
log.info(`\u{1F511} Environment keys (non-sensitive): ${envKeys.join(", ")}`);
const startTime = Date.now();
let lastActivityTime = startTime;
let eventCount = 0;
@@ -91455,7 +91463,7 @@ var opencode = agent({
// 10 minutes timeout to prevent infinite hangs
stdio: ["ignore", "pipe", "pipe"],
onStdout: async (chunk) => {
log.debug(`[opencode stdout] ${chunk}`);
log.debug(JSON.stringify(JSON.parse(chunk), null, 2));
const text = chunk.toString();
output += text;
const lines = text.split("\n");
@@ -91480,25 +91488,16 @@ var opencode = agent({
if (handler2) {
await handler2(event);
} else {
if (event.type && ![
"init",
"message",
"text",
"step_start",
"step_finish",
"tool_use",
"tool_result",
"result",
"error"
].includes(event.type)) {
log.debug(`\u{1F4CB} OpenCode event (unhandled): type=${event.type}`);
}
log.info(
`\u{1F4CB} OpenCode event (unhandled): type=${event.type}, data=${JSON.stringify(event).substring(0, 500)}`
);
}
} catch {
}
}
},
onStderr: (chunk) => {
log.debug(JSON.stringify(JSON.parse(chunk), null, 2));
const trimmed = chunk.trim();
if (trimmed) {
log.warning(trimmed);
@@ -91564,8 +91563,11 @@ function configureOpenCodeMcpServers({
} catch {
}
config3.mcp = opencodeMcpServers;
writeFileSync3(configPath, JSON.stringify(config3, null, 2), "utf-8");
const configJson = JSON.stringify(config3, null, 2);
writeFileSync3(configPath, configJson, "utf-8");
log.info(`MCP config written to ${configPath}`);
log.info(`MCP config contents:
${configJson}`);
}
function configureOpenCodeSandbox({ sandbox }) {
const tempHome = process.env.PULLFROG_TEMP_DIR;
+1 -1
View File
@@ -12,7 +12,7 @@ import { log } from "./utils/cli.ts";
async function run(): Promise<void> {
// Change to GITHUB_WORKSPACE if set (this is where actions/checkout puts the repo)
// JavaScript actions run from the action's directory, not the checked-out repo
// JavaScript actions run from the action's directory, not the checked out repo
if (process.env.GITHUB_WORKSPACE && process.cwd() !== process.env.GITHUB_WORKSPACE) {
log.debug(`Changing to GITHUB_WORKSPACE: ${process.env.GITHUB_WORKSPACE}`);
process.chdir(process.env.GITHUB_WORKSPACE);