improve agent api

This commit is contained in:
David Blass
2025-10-31 03:15:51 -04:00
parent 15a7154aea
commit 681e08557c
7 changed files with 51 additions and 70 deletions
+2 -3
View File
@@ -1,12 +1,11 @@
import { query, type SDKMessage } from "@anthropic-ai/claude-agent-sdk";
import { log } from "../utils/cli.ts";
import { instructions } from "./shared.ts";
import type { Agent } from "./types.ts";
import { type Agent, instructions } from "./shared.ts";
export const claude: Agent = {
run: async ({ prompt, mcpServers, apiKey }) => {
process.env.ANTHROPIC_API_KEY = apiKey;
// Create the query with SDK options
const queryInstance = query({
prompt: `${instructions}\n\n${prompt}`,
options: {
+29 -4
View File
@@ -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
- 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
- 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>
(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)
-25
View File
@@ -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>;
};