Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 681e08557c |
+2
-3
@@ -1,12 +1,11 @@
|
|||||||
import { query, type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
import { query, type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
||||||
import { log } from "../utils/cli.ts";
|
import { log } from "../utils/cli.ts";
|
||||||
import { instructions } from "./shared.ts";
|
import { type Agent, instructions } from "./shared.ts";
|
||||||
import type { Agent } from "./types.ts";
|
|
||||||
|
|
||||||
export const claude: Agent = {
|
export const claude: Agent = {
|
||||||
run: async ({ prompt, mcpServers, apiKey }) => {
|
run: async ({ prompt, mcpServers, apiKey }) => {
|
||||||
process.env.ANTHROPIC_API_KEY = apiKey;
|
process.env.ANTHROPIC_API_KEY = apiKey;
|
||||||
// Create the query with SDK options
|
|
||||||
const queryInstance = query({
|
const queryInstance = query({
|
||||||
prompt: `${instructions}\n\n${prompt}`,
|
prompt: `${instructions}\n\n${prompt}`,
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
+29
-4
@@ -1,12 +1,37 @@
|
|||||||
import { mcpServerName } from "../mcp/config.ts";
|
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||||
|
import { ghPullfrogMcpName } from "../mcp/config.ts";
|
||||||
|
|
||||||
export const instructions = `- use the ${mcpServerName} MCP server to interact with github
|
/**
|
||||||
- if ${mcpServerName} is not available or doesn't include the functionality you need, describe why and bail
|
* Result returned by agent execution
|
||||||
|
*/
|
||||||
|
export interface AgentResult {
|
||||||
|
success: boolean;
|
||||||
|
output?: string;
|
||||||
|
error?: string;
|
||||||
|
metadata?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for agent creation
|
||||||
|
*/
|
||||||
|
export interface AgentConfig {
|
||||||
|
apiKey: string;
|
||||||
|
githubInstallationToken: string;
|
||||||
|
prompt: string;
|
||||||
|
mcpServers: Record<string, McpServerConfig>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Agent = {
|
||||||
|
run: (config: AgentConfig) => Promise<AgentResult>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const instructions = `- use the ${ghPullfrogMcpName} MCP server to interact with github
|
||||||
|
- if ${ghPullfrogMcpName} is not available or doesn't include the functionality you need, describe why and bail
|
||||||
- do not under any circumstances use the gh cli
|
- do not under any circumstances use the gh cli
|
||||||
- if prompted by a comment to respond to create a new issue, pr or anything else, after succeeding,
|
- if prompted by a comment to respond to create a new issue, pr or anything else, after succeeding,
|
||||||
also respond to the original comment with a very brief message containing a link to it
|
also respond to the original comment with a very brief message containing a link to it
|
||||||
- if prompted to review a PR:
|
- if prompted to review a PR:
|
||||||
(1) get PR info with mcp__${mcpServerName}__get_pull_request
|
(1) get PR info with mcp__${ghPullfrogMcpName}__get_pull_request
|
||||||
(2) fetch both branches: git fetch origin <base> --depth=20 && git fetch origin <head>
|
(2) fetch both branches: git fetch origin <base> --depth=20 && git fetch origin <head>
|
||||||
(3) checkout the PR branch: git checkout origin/<head> (you MUST do this before reading any files)
|
(3) checkout the PR branch: git checkout origin/<head> (you MUST do this before reading any files)
|
||||||
(4) view diff: git diff origin/<base>...origin/<head> (this shows what changed)
|
(4) view diff: git diff origin/<base>...origin/<head> (this shows what changed)
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Result returned by agent execution
|
|
||||||
*/
|
|
||||||
export interface AgentResult {
|
|
||||||
success: boolean;
|
|
||||||
output?: string;
|
|
||||||
error?: string;
|
|
||||||
metadata?: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for agent creation
|
|
||||||
*/
|
|
||||||
export interface AgentConfig {
|
|
||||||
apiKey: string;
|
|
||||||
githubInstallationToken: string;
|
|
||||||
prompt: string;
|
|
||||||
mcpServers: Record<string, McpServerConfig>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Agent = {
|
|
||||||
run: (config: AgentConfig) => Promise<AgentResult>;
|
|
||||||
};
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { type } from "arktype";
|
import { type } from "arktype";
|
||||||
import { claude } from "./agents/claude.ts";
|
import { claude } from "./agents/claude.ts";
|
||||||
import { createMcpConfig } from "./mcp/config.ts";
|
import { createMcpConfigs } from "./mcp/config.ts";
|
||||||
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";
|
||||||
@@ -29,13 +29,9 @@ export async function main(inputs: Inputs): Promise<MainResult> {
|
|||||||
|
|
||||||
setupGitAuth(githubInstallationToken, repoContext);
|
setupGitAuth(githubInstallationToken, repoContext);
|
||||||
|
|
||||||
// Create MCP config
|
const mcpServers = createMcpConfigs(githubInstallationToken);
|
||||||
const mcpConfig = JSON.parse(createMcpConfig(githubInstallationToken));
|
|
||||||
|
|
||||||
log.debug(`📋 MCP Config: ${JSON.stringify(mcpConfig, null, 2)}`);
|
log.debug(`📋 MCP Config: ${JSON.stringify(mcpServers, null, 2)}`);
|
||||||
|
|
||||||
// Extract mcpServers object from config
|
|
||||||
const mcpServers = mcpConfig.mcpServers || {};
|
|
||||||
|
|
||||||
log.info("Running Claude Agent SDK...");
|
log.info("Running Claude Agent SDK...");
|
||||||
log.box(inputs.prompt, { title: "Prompt" });
|
log.box(inputs.prompt, { title: "Prompt" });
|
||||||
|
|||||||
+16
-17
@@ -1,32 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
* Simple MCP configuration helper for adding our minimal GitHub comment server
|
* Simple MCP configuration helper for adding our minimal GitHub comment server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||||
import { fromHere } from "@ark/fs";
|
import { fromHere } from "@ark/fs";
|
||||||
import { parseRepoContext } from "../utils/github.ts";
|
import { parseRepoContext } from "../utils/github.ts";
|
||||||
|
|
||||||
const actionPath = fromHere("..");
|
const actionPath = fromHere("..");
|
||||||
|
|
||||||
export const mcpServerName = "gh-pullfrog";
|
export const ghPullfrogMcpName = "gh-pullfrog";
|
||||||
|
|
||||||
export function createMcpConfig(githubInstallationToken: string) {
|
export type McpName = typeof ghPullfrogMcpName;
|
||||||
|
|
||||||
|
export type McpConfigs = Record<McpName, McpServerConfig>;
|
||||||
|
|
||||||
|
export function createMcpConfigs(githubInstallationToken: string): McpConfigs {
|
||||||
const repoContext = parseRepoContext();
|
const repoContext = parseRepoContext();
|
||||||
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
||||||
|
|
||||||
return JSON.stringify(
|
return {
|
||||||
{
|
[ghPullfrogMcpName]: {
|
||||||
mcpServers: {
|
command: "node",
|
||||||
[mcpServerName]: {
|
args: [`${actionPath}/mcp/server.ts`],
|
||||||
command: "node",
|
env: {
|
||||||
args: [`${actionPath}/mcp/server.ts`],
|
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
||||||
env: {
|
GITHUB_REPOSITORY: githubRepository,
|
||||||
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
|
||||||
GITHUB_REPOSITORY: githubRepository,
|
|
||||||
LOG_LEVEL: process.env.LOG_LEVEL,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
null,
|
};
|
||||||
2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pullfrog/action",
|
"name": "@pullfrog/action",
|
||||||
"version": "0.0.66",
|
"version": "0.0.67",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
||||||
import { tmpdir } from "node:os";
|
|
||||||
import { join } from "node:path";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a temporary file with the given content
|
|
||||||
*/
|
|
||||||
export function createTempFile(content: string, filename = "temp.txt"): string {
|
|
||||||
const tempDir = mkdtempSync(join(tmpdir(), "pullfrog-"));
|
|
||||||
const filePath = join(tempDir, filename);
|
|
||||||
writeFileSync(filePath, content);
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user