Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 42b023cc86 | |||
| 854e3d5e4d | |||
| 5bb1b779a8 | |||
| 599264694e | |||
| b9c15e9f38 | |||
| 7ef44eb254 |
+1
-4
@@ -1,6 +1,3 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
. "$(dirname -- "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
# Ensure lockfile is up to date
|
# Ensure lockfile is up to date
|
||||||
echo "🔒 Updating lockfile..."
|
echo "🔒 Updating lockfile..."
|
||||||
pnpm install --lockfile-only
|
pnpm install --lockfile-only
|
||||||
@@ -10,4 +7,4 @@ echo "🔨 Building action..."
|
|||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# Add the built files and lockfile to the commit
|
# Add the built files and lockfile to the commit
|
||||||
git add entry.cjs pnpm-lock.yaml
|
git add entry.js pnpm-lock.yaml
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ inputs:
|
|||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "node20"
|
using: "node20"
|
||||||
main: "entry.cjs"
|
main: "entry.js"
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: "code"
|
icon: "code"
|
||||||
|
|||||||
+112
-111
File diff suppressed because one or more lines are too long
@@ -5,26 +5,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import { type } from "arktype";
|
import { type Inputs, main } from "./main.ts";
|
||||||
import { Inputs, main } from "./main.ts";
|
|
||||||
import { createMcpServer } from "./mcp/server.ts";
|
import { createMcpServer } from "./mcp/server.ts";
|
||||||
import packageJson from "./package.json" with { type: "json" };
|
|
||||||
import { log } from "./utils/cli.ts";
|
|
||||||
|
|
||||||
// Export createMcpServer so it can be called from the spawned MCP process
|
// Export createMcpServer so it can be called from the spawned MCP process
|
||||||
export { createMcpServer };
|
export { createMcpServer };
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
log.info(`🐸 Running pullfrog/action@${packageJson.version}...`);
|
const inputs: Inputs = {
|
||||||
|
prompt: core.getInput("prompt", { required: true }),
|
||||||
const inputsJson = process.env.INPUTS_JSON;
|
anthropic_api_key: core.getInput("anthropic_api_key") || undefined,
|
||||||
if (!inputsJson) {
|
};
|
||||||
throw new Error("INPUTS_JSON environment variable not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
const parsed = type("string.json.parse").assert(inputsJson);
|
|
||||||
const inputs = Inputs.assert(parsed);
|
|
||||||
|
|
||||||
const result = await main(inputs);
|
const result = await main(inputs);
|
||||||
|
|
||||||
@@ -37,11 +29,4 @@ async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only run main action if INPUTS_JSON is set (running as GitHub Action)
|
await run();
|
||||||
// When SDK spawns MCP server, it calls createMcpServer() directly
|
|
||||||
if (process.env.INPUTS_JSON) {
|
|
||||||
// Wrap in IIFE to avoid top-level await in CJS
|
|
||||||
(async () => {
|
|
||||||
await run();
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|||||||
+8
-3
@@ -5,18 +5,23 @@ import { build } from "esbuild";
|
|||||||
await build({
|
await build({
|
||||||
entryPoints: ["./entry.ts"],
|
entryPoints: ["./entry.ts"],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outfile: "./entry.cjs",
|
outfile: "./entry.js",
|
||||||
format: "cjs",
|
format: "esm",
|
||||||
platform: "node",
|
platform: "node",
|
||||||
target: "node20",
|
target: "node20",
|
||||||
minify: true,
|
minify: true,
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
// Mark optional peer dependencies as external to avoid bundling errors
|
// Bundle all dependencies - GitHub Actions doesn't have node_modules
|
||||||
|
// Only mark optional peer dependencies as external
|
||||||
external: [
|
external: [
|
||||||
"@valibot/to-json-schema",
|
"@valibot/to-json-schema",
|
||||||
"effect",
|
"effect",
|
||||||
"sury",
|
"sury",
|
||||||
],
|
],
|
||||||
|
// Provide a proper require shim for CommonJS modules bundled into ESM
|
||||||
|
banner: {
|
||||||
|
js: `import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; const require = createRequire(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);`,
|
||||||
|
},
|
||||||
// Enable tree-shaking to remove unused code
|
// Enable tree-shaking to remove unused code
|
||||||
treeShaking: true,
|
treeShaking: true,
|
||||||
// Drop console statements in production (but keep for debugging)
|
// Drop console statements in production (but keep for debugging)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { type } from "arktype";
|
import { type } from "arktype";
|
||||||
import { claude } from "./agents/claude.ts";
|
import { claude } from "./agents/claude.ts";
|
||||||
import { createMcpConfigs } from "./mcp/config.ts";
|
import { createMcpConfigs } from "./mcp/config.ts";
|
||||||
|
import packageJson from "./package.json" with { type: "json" };
|
||||||
import { log } from "./utils/cli.ts";
|
import { log } from "./utils/cli.ts";
|
||||||
import { parseRepoContext, setupGitHubInstallationToken } from "./utils/github.ts";
|
import { parseRepoContext, setupGitHubInstallationToken } from "./utils/github.ts";
|
||||||
import { setupGitAuth, setupGitConfig } from "./utils/setup.ts";
|
import { setupGitAuth, setupGitConfig } from "./utils/setup.ts";
|
||||||
@@ -22,7 +23,15 @@ export type PromptJSON = {};
|
|||||||
|
|
||||||
export async function main(inputs: Inputs): Promise<MainResult> {
|
export async function main(inputs: Inputs): Promise<MainResult> {
|
||||||
try {
|
try {
|
||||||
log.info("Starting agent run...");
|
log.info(`🐸 Running pullfrog/action@${packageJson.version}...`);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
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);
|
||||||
|
log.debug(`New working directory: ${process.cwd()}`);
|
||||||
|
}
|
||||||
|
|
||||||
setupGitConfig();
|
setupGitConfig();
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -15,15 +15,19 @@ export function createMcpConfigs(githubInstallationToken: string): McpConfigs {
|
|||||||
const repoContext = parseRepoContext();
|
const repoContext = parseRepoContext();
|
||||||
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
||||||
|
|
||||||
// Get absolute path to entry.cjs - use GITHUB_ACTION_PATH if available, otherwise current directory
|
// Get absolute path to entry.js - use GITHUB_ACTION_PATH if available, otherwise current directory
|
||||||
const entryPath = process.env.GITHUB_ACTION_PATH
|
const entryPath = process.env.GITHUB_ACTION_PATH
|
||||||
? `${process.env.GITHUB_ACTION_PATH}/entry.cjs`
|
? `${process.env.GITHUB_ACTION_PATH}/entry.js`
|
||||||
: `${process.cwd()}/entry.cjs`;
|
: `${process.cwd()}/entry.js`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[ghPullfrogMcpName]: {
|
[ghPullfrogMcpName]: {
|
||||||
command: "node",
|
command: "node",
|
||||||
args: ["-e", `require('${entryPath.replace(/'/g, "\\'")}').createMcpServer()`],
|
args: [
|
||||||
|
"--input-type=module",
|
||||||
|
"-e",
|
||||||
|
`import('${entryPath.replace(/'/g, "\\'")}').then(m => m.createMcpServer())`,
|
||||||
|
],
|
||||||
env: {
|
env: {
|
||||||
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
||||||
GITHUB_REPOSITORY: githubRepository,
|
GITHUB_REPOSITORY: githubRepository,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pullfrog/action",
|
"name": "@pullfrog/action",
|
||||||
"version": "0.0.75",
|
"version": "0.0.80",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { fromHere } from "@ark/fs";
|
|||||||
import arg from "arg";
|
import arg from "arg";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
import { type Inputs, main } from "./main.ts";
|
import { type Inputs, main } from "./main.ts";
|
||||||
import packageJson from "./package.json" with { type: "json" };
|
|
||||||
import { log } from "./utils/cli.ts";
|
import { log } from "./utils/cli.ts";
|
||||||
import { setupTestRepo } from "./utils/setup.ts";
|
import { setupTestRepo } from "./utils/setup.ts";
|
||||||
|
|
||||||
@@ -15,8 +14,6 @@ export async function run(
|
|||||||
prompt: string
|
prompt: string
|
||||||
): Promise<{ success: boolean; output?: string | undefined; error?: string | undefined }> {
|
): Promise<{ success: boolean; output?: string | undefined; error?: string | undefined }> {
|
||||||
try {
|
try {
|
||||||
log.info(`🐸 Running pullfrog/action@${packageJson.version}...`);
|
|
||||||
|
|
||||||
const tempDir = join(process.cwd(), ".temp");
|
const tempDir = join(process.cwd(), ".temp");
|
||||||
setupTestRepo({ tempDir, forceClean: true });
|
setupTestRepo({ tempDir, forceClean: true });
|
||||||
|
|
||||||
|
|||||||
+27
-2
@@ -41,17 +41,42 @@ export function setupTestRepo(options: SetupOptions): void {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup git configuration to avoid identity errors
|
* Setup git configuration to avoid identity errors
|
||||||
|
* Only runs in GitHub Actions environment to avoid overwriting local git config
|
||||||
*/
|
*/
|
||||||
export function setupGitConfig(): void {
|
export function setupGitConfig(): void {
|
||||||
|
// Only set up git config in GitHub Actions environment
|
||||||
|
// In local development, use the user's existing git config
|
||||||
|
if (!process.env.GITHUB_ACTIONS) {
|
||||||
|
log.warning("Skipping git configuration setup (not in GitHub Actions)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info("🔧 Setting up git configuration...");
|
log.info("🔧 Setting up git configuration...");
|
||||||
execSync('git config user.email "action@pullfrog.ai"', { stdio: "inherit" });
|
try {
|
||||||
execSync('git config user.name "Pullfrog Action"', { stdio: "inherit" });
|
execSync('git config user.email "action@pullfrog.ai"', { stdio: "pipe" });
|
||||||
|
execSync('git config user.name "Pullfrog Action"', { stdio: "pipe" });
|
||||||
|
log.debug("setupGitConfig: ✓ Git configuration set successfully");
|
||||||
|
} catch (error) {
|
||||||
|
// If git config fails, log warning but don't fail the action
|
||||||
|
// This can happen if we're not in a git repo or git isn't available
|
||||||
|
log.warning(
|
||||||
|
`Failed to set git config: ${error instanceof Error ? error.message : String(error)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup git authentication using GitHub token
|
* Setup git authentication using GitHub token
|
||||||
|
* Only runs in GitHub Actions environment to avoid breaking local git remotes
|
||||||
*/
|
*/
|
||||||
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
|
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
|
||||||
|
// Only set up git auth in GitHub Actions environment
|
||||||
|
// In local testing, this would overwrite the real git remote with fake credentials
|
||||||
|
if (!process.env.GITHUB_ACTIONS) {
|
||||||
|
log.warning("Skipping git authentication setup (not in GitHub Actions)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info("🔐 Setting up git authentication...");
|
log.info("🔐 Setting up git authentication...");
|
||||||
|
|
||||||
// Remove existing git auth headers that actions/checkout might have set
|
// Remove existing git auth headers that actions/checkout might have set
|
||||||
|
|||||||
Reference in New Issue
Block a user