mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 11:28:55 +08:00
refactor: unify action into single composite step with run.ts entrypoint (#898)
* refactor: unify action into single composite step with run.ts entrypoint Consolidate the prepare and base-action phases into a single composite step that runs src/entrypoints/run.ts. This simplifies the action.yml from multiple steps to one execution step, while keeping the same behavior. Key changes: - Add src/entrypoints/run.ts as unified entrypoint - Simplify action.yml to single 'Run Claude Code Action' step - Pass all inputs via environment variables - Update base-action to accept inputs via env vars - Support agent mode auto-detection from prompt input * refactor: keep SSH signing cleanup and token revocation as separate action steps Move SSH signing key cleanup and app token revocation back to separate composite action steps in action.yml with always() conditions, rather than handling them inside run.ts. This keeps these cleanup concerns as independently visible steps in the workflow. * fix: address PR review feedback - Use path.dirname() instead of manual string slicing for executable path - Differentiate prepare vs execution errors in catch block so tracking comment accurately reflects which phase failed - Update CLAUDE.md architecture docs to reflect unified run.ts entrypoint and four-phase design * fix: address PR review feedback - Use path.dirname() instead of manual string slicing for executable path - Differentiate prepare vs execution errors in catch block so tracking comment accurately reflects which phase failed - Rewrite CLAUDE.md to focus on mental model, key concepts, and gotchas instead of exhaustive file listings
This commit is contained in:
@@ -31,6 +31,7 @@ describe("generatePrompt", () => {
|
||||
claudeBranch: undefined,
|
||||
},
|
||||
mcpConfig: "{}",
|
||||
claudeArgs: "",
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -52,6 +53,7 @@ describe("generatePrompt", () => {
|
||||
claudeBranch: undefined,
|
||||
},
|
||||
mcpConfig: "{}",
|
||||
claudeArgs: "",
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
@@ -163,10 +163,8 @@ describe("Agent Mode", () => {
|
||||
});
|
||||
|
||||
// Verify claude_args includes user args (no MCP config in agent mode without allowed tools)
|
||||
const callArgs = setOutputSpy.mock.calls[0];
|
||||
expect(callArgs[0]).toBe("claude_args");
|
||||
expect(callArgs[1]).toBe("--model claude-sonnet-4 --max-turns 10");
|
||||
expect(callArgs[1]).not.toContain("--mcp-config");
|
||||
expect(result.claudeArgs).toBe("--model claude-sonnet-4 --max-turns 10");
|
||||
expect(result.claudeArgs).not.toContain("--mcp-config");
|
||||
|
||||
// Verify return structure - should use "main" as fallback when no env vars set
|
||||
expect(result).toEqual({
|
||||
@@ -177,6 +175,7 @@ describe("Agent Mode", () => {
|
||||
claudeBranch: undefined,
|
||||
},
|
||||
mcpConfig: expect.any(String),
|
||||
claudeArgs: "--model claude-sonnet-4 --max-turns 10",
|
||||
});
|
||||
|
||||
// Clean up
|
||||
@@ -269,7 +268,7 @@ describe("Agent Mode", () => {
|
||||
},
|
||||
},
|
||||
} as any;
|
||||
await agentMode.prepare({
|
||||
const result = await agentMode.prepare({
|
||||
context: contextWithPrompts,
|
||||
octokit: mockOctokit,
|
||||
githubToken: "test-token",
|
||||
@@ -279,9 +278,7 @@ describe("Agent Mode", () => {
|
||||
// but we can verify the method completes without errors
|
||||
// With our conditional MCP logic, agent mode with no allowed tools
|
||||
// should not include any MCP config
|
||||
const callArgs = setOutputSpy.mock.calls[0];
|
||||
expect(callArgs[0]).toBe("claude_args");
|
||||
// Should be empty or just whitespace when no MCP servers are included
|
||||
expect(callArgs[1]).not.toContain("--mcp-config");
|
||||
expect(result.claudeArgs).not.toContain("--mcp-config");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ describe("pull_request_target event support", () => {
|
||||
claudeBranch: undefined,
|
||||
},
|
||||
mcpConfig: "{}",
|
||||
claudeArgs: "",
|
||||
}),
|
||||
};
|
||||
|
||||
@@ -313,6 +314,7 @@ describe("pull_request_target event support", () => {
|
||||
claudeBranch: undefined,
|
||||
},
|
||||
mcpConfig: "{}",
|
||||
claudeArgs: "",
|
||||
}),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user