Flesh out debug logs

This commit is contained in:
Colin McDonnell
2025-12-17 13:11:44 -08:00
parent bd932e7696
commit 1f1c1602c5
9 changed files with 57 additions and 54 deletions
+2 -1
View File
@@ -19,7 +19,7 @@ export const claude = agent({
delete process.env.ANTHROPIC_API_KEY;
const prompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(prompt));
log.group("» Full prompt", () => log.info(prompt));
// configure sandbox mode if enabled
const sandboxOptions: Options = payload.sandbox
@@ -63,6 +63,7 @@ export const claude = agent({
// Stream the results
for await (const message of queryInstance) {
log.debug(JSON.stringify(message, null, 2));
const handler = messageHandlers[message.type];
await handler(message as never);
}
+4 -3
View File
@@ -167,7 +167,7 @@ export const cursor = agent({
try {
const fullPrompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(fullPrompt));
log.group("» Full prompt", () => log.info(fullPrompt));
// configure sandbox mode if enabled
// in sandbox mode: remove --force flag and rely on cli-config.json sandbox settings
@@ -212,6 +212,7 @@ export const cursor = agent({
try {
const event = JSON.parse(text) as CursorEvent;
log.debug(JSON.stringify(event, null, 2));
// skip empty thinking deltas
if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
@@ -308,7 +309,7 @@ function configureCursorMcpServers({ mcpServers }: ConfigureMcpServersParams) {
}
writeFileSync(mcpConfigPath, JSON.stringify({ mcpServers: cursorMcpServers }, null, 2), "utf-8");
log.info(`MCP config written to ${mcpConfigPath}`);
log.info(`» MCP config written to ${mcpConfigPath}`);
}
/**
@@ -347,5 +348,5 @@ function configureCursorSandbox({ sandbox }: { sandbox: boolean }): void {
};
writeFileSync(cliConfigPath, JSON.stringify(config, null, 2), "utf-8");
log.info(`CLI config written to ${cliConfigPath} (sandbox: ${sandbox})`);
log.info(`» CLI config written to ${cliConfigPath} (sandbox: ${sandbox})`);
}
+1 -1
View File
@@ -162,7 +162,7 @@ export const gemini = agent({
}
const sessionPrompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(sessionPrompt));
log.group("» Full prompt", () => log.info(sessionPrompt));
// configure sandbox mode if enabled
// --allowed-tools restricts which tools are available (removes others from registry entirely)
+3 -5
View File
@@ -30,7 +30,7 @@ export const opencode = agent({
configureOpenCode({ mcpServers, sandbox: payload.sandbox ?? false });
const prompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(prompt));
log.group("» Full prompt", () => log.info(prompt));
// message positional must come right after "run", before flags
const args = ["run", prompt, "--format", "json"];
@@ -105,9 +105,7 @@ export const opencode = agent({
eventCount++;
// debug log all events to diagnose ordering and missing MCP/bash tool calls
log.debug(
`» event: type=${event.type} data=${JSON.stringify(event).substring(0, 300)}`
);
log.debug(JSON.stringify(event, null, 2));
const timeSinceLastActivity = Date.now() - lastActivityTime;
if (timeSinceLastActivity > 10000) {
@@ -253,7 +251,7 @@ function configureOpenCode({ mcpServers, sandbox }: ConfigureOpenCodeParams): vo
throw error;
}
log.info(`OpenCode config written to ${configPath} (sandbox: ${sandbox})`);
log.info(`» OpenCode config written to ${configPath} (sandbox: ${sandbox})`);
log.debug(`OpenCode config contents:\n${configJson}`);
}
+28 -28
View File
@@ -19736,10 +19736,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
error42(message);
}
exports.setFailed = setFailed2;
function isDebug() {
function isDebug2() {
return process.env["RUNNER_DEBUG"] === "1";
}
exports.isDebug = isDebug;
exports.isDebug = isDebug2;
function debug(message) {
(0, command_1.issueCommand)("debug", {}, message);
}
@@ -80222,7 +80222,7 @@ var package_default = {
var core = __toESM(require_core(), 1);
var import_table = __toESM(require_src(), 1);
var isGitHubActions = !!process.env.GITHUB_ACTIONS;
var isDebugEnabled = () => process.env.LOG_LEVEL === "debug" || process.env.ACTIONS_STEP_DEBUG === "true";
var isDebugEnabled = () => process.env.LOG_LEVEL === "debug" || process.env.ACTIONS_STEP_DEBUG === "true" || process.env.RUNNER_DEBUG === "1" || core.isDebug();
function startGroup2(name) {
if (isGitHubActions) {
core.startGroup(name);
@@ -90162,7 +90162,7 @@ var claude = agent({
run: async ({ payload, mcpServers, apiKey, cliPath, prepResults, repo }) => {
delete process.env.ANTHROPIC_API_KEY;
const prompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(prompt));
log.group("\xBB Full prompt", () => log.info(prompt));
const sandboxOptions = payload.sandbox ? {
permissionMode: "default",
disallowedTools: ["Bash", "WebSearch", "WebFetch", "Write"],
@@ -90195,6 +90195,7 @@ var claude = agent({
}
});
for await (const message of queryInstance) {
log.debug(JSON.stringify(message, null, 2));
const handler2 = messageHandlers[message.type];
await handler2(message);
}
@@ -90843,7 +90844,7 @@ var cursor = agent({
};
try {
const fullPrompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(fullPrompt));
log.group("\xBB Full prompt", () => log.info(fullPrompt));
const cursorArgs = payload.sandbox ? [
"--print",
fullPrompt,
@@ -90876,6 +90877,7 @@ var cursor = agent({
stdout += text;
try {
const event = JSON.parse(text);
log.debug(JSON.stringify(event, null, 2));
if (event.type === "thinking" && event.subtype === "delta" && !event.text) {
return;
}
@@ -90953,7 +90955,7 @@ function configureCursorMcpServers({ mcpServers }) {
};
}
writeFileSync2(mcpConfigPath, JSON.stringify({ mcpServers: cursorMcpServers }, null, 2), "utf-8");
log.info(`MCP config written to ${mcpConfigPath}`);
log.info(`\xBB MCP config written to ${mcpConfigPath}`);
}
function configureCursorSandbox({ sandbox }) {
const realHome = homedir2();
@@ -90982,7 +90984,7 @@ function configureCursorSandbox({ sandbox }) {
}
};
writeFileSync2(cliConfigPath, JSON.stringify(config3, null, 2), "utf-8");
log.info(`CLI config written to ${cliConfigPath} (sandbox: ${sandbox})`);
log.info(`\xBB CLI config written to ${cliConfigPath} (sandbox: ${sandbox})`);
}
// agents/gemini.ts
@@ -91153,7 +91155,7 @@ var gemini = agent({
throw new Error("google_api_key or gemini_api_key is required for gemini agent");
}
const sessionPrompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(sessionPrompt));
log.group("\xBB Full prompt", () => log.info(sessionPrompt));
const args3 = payload.sandbox ? [
"--allowed-tools",
"read_file,list_directory,search_file_content,glob,save_memory,write_todos",
@@ -91276,7 +91278,7 @@ var opencode = agent({
mkdirSync4(configDir, { recursive: true });
configureOpenCode({ mcpServers, sandbox: payload.sandbox ?? false });
const prompt = addInstructions({ payload, prepResults, repo });
log.group("Full prompt", () => log.info(prompt));
log.group("\xBB Full prompt", () => log.info(prompt));
const args3 = ["run", prompt, "--format", "json"];
if (payload.sandbox) {
log.info("\u{1F512} sandbox mode enabled: restricting to read-only operations");
@@ -91326,9 +91328,7 @@ var opencode = agent({
try {
const event = JSON.parse(trimmed);
eventCount++;
log.debug(
`\xBB event: type=${event.type} data=${JSON.stringify(event).substring(0, 300)}`
);
log.debug(JSON.stringify(event, null, 2));
const timeSinceLastActivity = Date.now() - lastActivityTime;
if (timeSinceLastActivity > 1e4) {
const activeToolCalls = toolCallTimings.size;
@@ -91439,7 +91439,7 @@ function configureOpenCode({ mcpServers, sandbox }) {
);
throw error42;
}
log.info(`OpenCode config written to ${configPath} (sandbox: ${sandbox})`);
log.info(`\xBB OpenCode config written to ${configPath} (sandbox: ${sandbox})`);
log.debug(`OpenCode config contents:
${configJson}`);
}
@@ -123903,7 +123903,7 @@ var CheckoutPr = type({
pull_number: type.number.describe("the pull request number to checkout")
});
async function checkoutPrBranch(ctx, pull_number) {
log.info(`\u{1F500} checking out PR #${pull_number}...`);
log.debug(`\u{1F500} checking out PR #${pull_number}...`);
const pr = await ctx.octokit.rest.pulls.get({
owner: ctx.owner,
repo: ctx.name,
@@ -123919,18 +123919,18 @@ async function checkoutPrBranch(ctx, pull_number) {
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false }).trim();
const alreadyOnBranch = currentBranch === headBranch;
if (alreadyOnBranch) {
log.info(`already on PR branch ${headBranch}, skipping checkout`);
log.debug(`already on PR branch ${headBranch}, skipping checkout`);
} else {
log.info(`\u{1F4E5} fetching base branch (${baseBranch})...`);
log.debug(`\u{1F4E5} fetching base branch (${baseBranch})...`);
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
$("git", ["checkout", "-B", baseBranch, `origin/${baseBranch}`]);
log.info(`\u{1F33F} fetching PR #${pull_number} (${headBranch})...`);
log.debug(`\u{1F33F} fetching PR #${pull_number} (${headBranch})...`);
$("git", ["fetch", "--no-tags", "origin", `pull/${pull_number}/head:${headBranch}`]);
$("git", ["checkout", headBranch]);
log.info(`\u2713 checked out PR #${pull_number}`);
log.debug(`\u2713 checked out PR #${pull_number}`);
}
if (alreadyOnBranch) {
log.info(`\u{1F4E5} fetching base branch (${baseBranch})...`);
log.debug(`\u{1F4E5} fetching base branch (${baseBranch})...`);
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
}
if (isFork) {
@@ -123938,13 +123938,13 @@ async function checkoutPrBranch(ctx, pull_number) {
const forkUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${headRepo.full_name}.git`;
try {
$("git", ["remote", "add", remoteName, forkUrl]);
log.info(`\u{1F4CC} added remote '${remoteName}' for fork ${headRepo.full_name}`);
log.debug(`\u{1F4CC} added remote '${remoteName}' for fork ${headRepo.full_name}`);
} catch {
$("git", ["remote", "set-url", remoteName, forkUrl]);
log.info(`\u{1F4CC} updated remote '${remoteName}' for fork ${headRepo.full_name}`);
log.debug(`\u{1F4CC} updated remote '${remoteName}' for fork ${headRepo.full_name}`);
}
$("git", ["config", `branch.${headBranch}.pushRemote`, remoteName]);
log.info(`\u{1F4CC} configured branch '${headBranch}' to push to '${remoteName}'`);
log.debug(`\u{1F4CC} configured branch '${headBranch}' to push to '${remoteName}'`);
if (!pr.data.maintainer_can_modify) {
log.warning(
`\u26A0\uFE0F fork PR has maintainer_can_modify=false - push operations will fail. ask the PR author to enable "Allow edits from maintainers" or the fork may be owned by an organization.`
@@ -124201,12 +124201,12 @@ function CreateBranchTool(ctx) {
"Branch creation blocked: secrets detected in branch name. Please remove any sensitive information (API keys, tokens, passwords) before creating a branch."
);
}
log.info(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
log.debug(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
$("git", ["fetch", "origin", resolvedBaseBranch, "--depth=1"]);
$("git", ["checkout", "-B", resolvedBaseBranch, `origin/${resolvedBaseBranch}`]);
$("git", ["checkout", "-b", branchName]);
$("git", ["push", "-u", "origin", branchName]);
log.info(`Successfully created and pushed branch ${branchName}`);
log.debug(`Successfully created and pushed branch ${branchName}`);
return {
success: true,
branchName,
@@ -124250,7 +124250,7 @@ function CommitFilesTool(ctx) {
}
}
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
log.info(`Committing files on branch ${currentBranch}`);
log.debug(`Committing files on branch ${currentBranch}`);
if (files.length > 0) {
$("git", ["add", ...files]);
} else {
@@ -124258,7 +124258,7 @@ function CommitFilesTool(ctx) {
}
$("git", ["commit", "-m", message]);
const commitSha = $("git", ["rev-parse", "HEAD"], { log: false });
log.info(`Successfully committed: ${commitSha.substring(0, 7)}`);
log.debug(`Successfully committed: ${commitSha.substring(0, 7)}`);
return {
success: true,
commitSha,
@@ -124285,7 +124285,7 @@ function PushBranchTool(_ctx) {
} catch {
}
const args3 = force ? ["push", "--force", "-u", remote, branch] : ["push", "-u", remote, branch];
log.info(`pushing branch ${branch} to ${remote}`);
log.debug(`pushing branch ${branch} to ${remote}`);
if (force) {
log.warning(`force pushing - this will overwrite remote history`);
}
@@ -124542,7 +124542,7 @@ function PullRequestTool(ctx) {
parameters: PullRequest,
execute: execute(ctx, async ({ title, body, base }) => {
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
log.info(`Current branch: ${currentBranch}`);
log.debug(`Current branch: ${currentBranch}`);
if (containsSecrets(title) || containsSecrets(body)) {
throw new Error(
"PR creation blocked: secrets detected in PR title or body. Please remove any sensitive information (API keys, tokens, passwords) before creating a PR."
+9 -9
View File
@@ -25,7 +25,7 @@ export type CheckoutPrResult = {
* Assumes origin remote is already configured with authentication.
*/
export async function checkoutPrBranch(ctx: Context, pull_number: number): Promise<void> {
log.info(`🔀 checking out PR #${pull_number}...`);
log.debug(`🔀 checking out PR #${pull_number}...`);
// fetch PR metadata
const pr = await ctx.octokit.rest.pulls.get({
@@ -48,10 +48,10 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
const alreadyOnBranch = currentBranch === headBranch;
if (alreadyOnBranch) {
log.info(`already on PR branch ${headBranch}, skipping checkout`);
log.debug(`already on PR branch ${headBranch}, skipping checkout`);
} else {
// fetch base branch so origin/<base> exists for diff operations
log.info(`📥 fetching base branch (${baseBranch})...`);
log.debug(`📥 fetching base branch (${baseBranch})...`);
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
// checkout base branch first to avoid "refusing to fetch into current branch" error
@@ -59,18 +59,18 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
$("git", ["checkout", "-B", baseBranch, `origin/${baseBranch}`]);
// fetch PR branch using pull/{n}/head refspec (works for both fork and same-repo PRs)
log.info(`🌿 fetching PR #${pull_number} (${headBranch})...`);
log.debug(`🌿 fetching PR #${pull_number} (${headBranch})...`);
$("git", ["fetch", "--no-tags", "origin", `pull/${pull_number}/head:${headBranch}`]);
// checkout the branch
$("git", ["checkout", headBranch]);
log.info(`✓ checked out PR #${pull_number}`);
log.debug(`✓ checked out PR #${pull_number}`);
}
// ensure base branch is fetched (needed for diff operations)
// fetch if we skipped checkout (already on branch) - otherwise already fetched above
if (alreadyOnBranch) {
log.info(`📥 fetching base branch (${baseBranch})...`);
log.debug(`📥 fetching base branch (${baseBranch})...`);
$("git", ["fetch", "--no-tags", "origin", baseBranch]);
}
@@ -84,16 +84,16 @@ export async function checkoutPrBranch(ctx: Context, pull_number: number): Promi
// add fork as a named remote (ignore error if already exists)
try {
$("git", ["remote", "add", remoteName, forkUrl]);
log.info(`📌 added remote '${remoteName}' for fork ${headRepo.full_name}`);
log.debug(`📌 added remote '${remoteName}' for fork ${headRepo.full_name}`);
} catch {
// remote already exists, update its URL
$("git", ["remote", "set-url", remoteName, forkUrl]);
log.info(`📌 updated remote '${remoteName}' for fork ${headRepo.full_name}`);
log.debug(`📌 updated remote '${remoteName}' for fork ${headRepo.full_name}`);
}
// set branch push config so `git push` knows where to push
$("git", ["config", `branch.${headBranch}.pushRemote`, remoteName]);
log.info(`📌 configured branch '${headBranch}' to push to '${remoteName}'`);
log.debug(`📌 configured branch '${headBranch}' to push to '${remoteName}'`);
// warn if maintainer can't modify (push will likely fail)
if (!pr.data.maintainer_can_modify) {
+5 -5
View File
@@ -34,7 +34,7 @@ export function CreateBranchTool(ctx: Context) {
);
}
log.info(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
log.debug(`Creating branch ${branchName} from ${resolvedBaseBranch}`);
// fetch base branch to ensure we're up to date
$("git", ["fetch", "origin", resolvedBaseBranch, "--depth=1"]);
@@ -49,7 +49,7 @@ export function CreateBranchTool(ctx: Context) {
// push branch to remote (set upstream)
$("git", ["push", "-u", "origin", branchName]);
log.info(`Successfully created and pushed branch ${branchName}`);
log.debug(`Successfully created and pushed branch ${branchName}`);
return {
success: true,
@@ -109,7 +109,7 @@ export function CommitFilesTool(ctx: Context) {
}
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
log.info(`Committing files on branch ${currentBranch}`);
log.debug(`Committing files on branch ${currentBranch}`);
// stage files if provided, otherwise stage all changes
if (files.length > 0) {
@@ -122,7 +122,7 @@ export function CommitFilesTool(ctx: Context) {
$("git", ["commit", "-m", message]);
const commitSha = $("git", ["rev-parse", "HEAD"], { log: false });
log.info(`Successfully committed: ${commitSha.substring(0, 7)}`);
log.debug(`Successfully committed: ${commitSha.substring(0, 7)}`);
return {
success: true,
@@ -162,7 +162,7 @@ export function PushBranchTool(_ctx: Context) {
? ["push", "--force", "-u", remote, branch]
: ["push", "-u", remote, branch];
log.info(`pushing branch ${branch} to ${remote}`);
log.debug(`pushing branch ${branch} to ${remote}`);
if (force) {
log.warning(`force pushing - this will overwrite remote history`);
}
+1 -1
View File
@@ -36,7 +36,7 @@ export function PullRequestTool(ctx: Context) {
parameters: PullRequest,
execute: execute(ctx, async ({ title, body, base }) => {
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false });
log.info(`Current branch: ${currentBranch}`);
log.debug(`Current branch: ${currentBranch}`);
// validate PR title and body for secrets
if (containsSecrets(title) || containsSecrets(body)) {
+4 -1
View File
@@ -9,7 +9,10 @@ import { table } from "table";
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
const isDebugEnabled = () =>
process.env.LOG_LEVEL === "debug" || process.env.ACTIONS_STEP_DEBUG === "true";
process.env.LOG_LEVEL === "debug" ||
process.env.ACTIONS_STEP_DEBUG === "true" ||
process.env.RUNNER_DEBUG === "1" ||
core.isDebug();
/**
* Start a collapsed group (GitHub Actions) or regular group (local)