@posthog/agent 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -65
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/src/adapters/types.d.ts +1 -1
- package/dist/src/agent.d.ts +0 -13
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +2 -214
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.d.ts +1 -1
- package/dist/src/agents/execution.js +2 -2
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/git-manager.js +1 -1
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +0 -8
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +0 -32
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/task-progress-reporter.d.ts +0 -6
- package/dist/src/task-progress-reporter.d.ts.map +1 -1
- package/dist/src/task-progress-reporter.js +2 -26
- package/dist/src/task-progress-reporter.js.map +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +26 -4
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/types.d.ts +0 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +0 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -3
- package/src/adapters/types.ts +1 -1
- package/src/agent.ts +3 -234
- package/src/agents/execution.ts +2 -2
- package/src/git-manager.ts +1 -1
- package/src/posthog-api.ts +0 -40
- package/src/task-progress-reporter.ts +2 -34
- package/src/template-manager.ts +35 -5
- package/src/types.ts +0 -7
- package/dist/src/agent-registry.d.ts +0 -16
- package/dist/src/agent-registry.d.ts.map +0 -1
- package/dist/src/agent-registry.js +0 -62
- package/dist/src/agent-registry.js.map +0 -1
- package/dist/src/stage-executor.d.ts +0 -20
- package/dist/src/stage-executor.d.ts.map +0 -1
- package/dist/src/stage-executor.js +0 -178
- package/dist/src/stage-executor.js.map +0 -1
- package/dist/src/workflow-registry.d.ts +0 -11
- package/dist/src/workflow-registry.d.ts.map +0 -1
- package/dist/src/workflow-registry.js +0 -27
- package/dist/src/workflow-registry.js.map +0 -1
- package/dist/src/workflow-types.d.ts +0 -45
- package/dist/src/workflow-types.d.ts.map +0 -1
- package/src/agent-registry.ts +0 -65
- package/src/stage-executor.ts +0 -210
- package/src/workflow-registry.ts +0 -30
- package/src/workflow-types.ts +0 -52
package/dist/src/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Task, ExecutionResult, PlanResult, AgentConfig } from './types.js';\nimport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\nimport { TaskManager } from './task-manager.js';\nimport { PostHogAPIClient } from './posthog-api.js';\nimport { PostHogFileManager } from './file-manager.js';\nimport { GitManager } from './git-manager.js';\nimport { TemplateManager } from './template-manager.js';\nimport { ClaudeAdapter } from './adapters/claude/claude-adapter.js';\nimport type { ProviderAdapter } from './adapters/types.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { Logger } from './utils/logger.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport { WorkflowRegistry } from './workflow-registry.js';\nimport { StageExecutor } from './stage-executor.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\nimport { OpenAIExtractor, type ExtractedQuestion, type ExtractedQuestionWithAnswer } from './structured-extraction.js';\n\nexport class Agent {\n private workingDirectory: string;\n private onEvent?: (event: any) => void;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private adapter: ProviderAdapter;\n private logger: Logger;\n private agentRegistry: AgentRegistry;\n private workflowRegistry: WorkflowRegistry;\n private stageExecutor: StageExecutor;\n private progressReporter: TaskProgressReporter;\n private promptBuilder: PromptBuilder;\n private extractor?: OpenAIExtractor;\n private mcpServers?: Record<string, any>;\n public debug: boolean;\n\n constructor(config: AgentConfig = {}) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl = config.posthogMcpUrl\n || process.env.POSTHOG_MCP_URL\n || 'https://mcp.posthog.com/mcp';\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers['Authorization'] = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: 'http' as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n }\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers\n };\n this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });\n this.taskManager = new TaskManager();\n // Hardcode Claude adapter for now - extensible for other providers later\n this.adapter = new ClaudeAdapter();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child('FileManager')\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child('GitManager')\n // TODO: Add author config from environment or config\n });\n this.templateManager = new TemplateManager();\n this.agentRegistry = new AgentRegistry();\n\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n });\n }\n\n this.workflowRegistry = new WorkflowRegistry(this.posthogAPI);\n this.promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n posthogClient: this.posthogAPI,\n logger: this.logger.child('PromptBuilder')\n });\n this.stageExecutor = new StageExecutor(\n this.agentRegistry,\n this.logger,\n this.promptBuilder,\n undefined, // eventHandler set via setEventHandler below\n this.mcpServers\n );\n this.stageExecutor.setEventHandler((event) => this.emitEvent(event));\n this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n \n // Initialize OpenAI extractor if API key is available\n if (process.env.OPENAI_API_KEY) {\n this.extractor = new OpenAIExtractor(this.logger.child('OpenAIExtractor'));\n }\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {\n return;\n }\n\n try {\n const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n\n this.logger.debug('Configured LLM gateway', { gatewayUrl });\n } catch (error) {\n this.logger.error('Failed to configure LLM gateway', error);\n throw error;\n }\n }\n\n // Workflow-based execution\n async runWorkflow(taskOrId: Task | string, workflowId: string, options: WorkflowExecutionOptions = {}): Promise<{ task: Task; workflow: WorkflowDefinition }> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n await this.workflowRegistry.loadWorkflows();\n const workflow = this.workflowRegistry.getWorkflow(workflowId);\n if (!workflow) {\n throw new Error(`Workflow ${workflowId} not found`);\n }\n const orderedStages = [...workflow.stages].sort((a, b) => a.position - b.position);\n\n // Ensure task is assigned to workflow and positioned at first stage\n if (this.posthogAPI) {\n try {\n if ((task.workflow as any) !== workflowId) {\n await this.posthogAPI.updateTask(task.id, { workflow: workflowId } as any);\n (task as any).workflow = workflowId;\n }\n } catch (e) {\n this.logger.warn('Failed to sync task workflow before execution', { error: (e as Error).message });\n }\n }\n\n const executionId = this.taskManager.generateExecutionId();\n this.logger.info('Starting workflow execution', { taskId: task.id, workflowId, executionId });\n this.taskManager.startExecution(task.id, 'plan_and_build', executionId);\n await this.progressReporter.start(task.id, {\n totalSteps: orderedStages.length,\n });\n\n // Set initial stage on the newly created run\n const firstStage = orderedStages[0];\n if (this.posthogAPI && this.progressReporter.runId && firstStage) {\n try {\n await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {\n current_stage: firstStage.id\n });\n } catch (e) {\n this.logger.warn('Failed to set initial stage on run', { error: (e as Error).message });\n }\n }\n\n try {\n let startIndex = 0;\n const currentStageId = (task as any).current_stage as string | undefined;\n\n // If task is already at the last stage, fail gracefully without progressing\n if (currentStageId) {\n const currIdx = orderedStages.findIndex(s => s.id === currentStageId);\n const atLastStage = currIdx >= 0 && currIdx === orderedStages.length - 1;\n if (atLastStage) {\n const finalStageKey = orderedStages[currIdx]?.key;\n this.emitEvent(this.adapter.createStatusEvent('no_next_stage', { stage: finalStageKey }));\n await this.progressReporter.noNextStage(finalStageKey);\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n }\n }\n\n if (options.resumeFromCurrentStage && currentStageId) {\n const idx = orderedStages.findIndex(s => s.id === currentStageId);\n if (idx >= 0) startIndex = idx;\n }\n\n // Align server-side stage when restarting from a different stage\n if (this.posthogAPI && this.progressReporter.runId) {\n const targetStage = orderedStages[startIndex];\n if (targetStage && targetStage.id !== currentStageId) {\n try {\n await this.posthogAPI.updateTaskRun(task.id, this.progressReporter.runId, {\n current_stage: targetStage.id\n });\n } catch (e) {\n this.logger.warn('Failed to update run stage', { error: (e as Error).message });\n }\n }\n }\n\n for (let i = startIndex; i < orderedStages.length; i++) {\n const stage = orderedStages[i];\n await this.progressReporter.stageStarted(stage.key, i);\n await this.executeStage(task, stage, options);\n await this.progressReporter.stageCompleted(stage.key, i + 1);\n if (options.autoProgress) {\n const hasNext = i < orderedStages.length - 1;\n if (hasNext) {\n await this.progressToNextStage(task.id, stage.key);\n }\n }\n }\n await this.progressReporter.complete();\n this.taskManager.completeExecution(executionId, { task, workflow });\n return { task, workflow };\n } catch (error) {\n await this.progressReporter.fail(error as Error);\n this.taskManager.failExecution(executionId, error as Error);\n throw error;\n }\n }\n\n async executeStage(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions = {}): Promise<void> {\n this.emitEvent(this.adapter.createStatusEvent('stage_start', { stage: stage.key }));\n const overrides = options.stageOverrides?.[stage.key];\n const agentName = stage.agent_name || 'code_generation';\n const agentDef = this.agentRegistry.getAgent(agentName);\n const isManual = stage.is_manual_only === true;\n const stageKeyLower = (stage.key || '').toLowerCase().trim();\n const isPlanningByKey = stageKeyLower === 'plan' || stageKeyLower.includes('plan');\n const isPlanning = !isManual && ((agentDef?.agent_type === 'planning') || isPlanningByKey);\n const shouldCreatePlanningBranch = overrides?.createPlanningBranch !== false; // default true\n const shouldCreateImplBranch = overrides?.createImplementationBranch !== false; // default true\n\n if (isPlanning && shouldCreatePlanningBranch) {\n const planningBranch = await this.createPlanningBranch(task.id);\n await this.updateTaskBranch(task.id, planningBranch);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { stage: stage.key, branch: planningBranch }));\n await this.progressReporter.branchCreated(stage.key, planningBranch);\n } else if (!isPlanning && !isManual && shouldCreateImplBranch) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n\n const result = await this.stageExecutor.execute(task, stage, options);\n\n if (result.plan) {\n await this.writePlan(task.id, result.plan);\n await this.commitPlan(task.id, task.title);\n this.emitEvent(this.adapter.createStatusEvent('commit_made', { stage: stage.key, kind: 'plan' }));\n await this.progressReporter.commitMade(stage.key, 'plan');\n }\n\n if (isManual) {\n const defaultOpenPR = true; // manual stages default to PR for review\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n // Ensure we're on an implementation branch for PRs\n let branchName = await this.gitManager.getCurrentBranch();\n const onTaskBranch = branchName.includes(`posthog/task-${task.id}`);\n if (!onTaskBranch && (overrides?.createImplementationBranch !== false)) {\n const implBranch = await this.createImplementationBranch(task.id);\n await this.updateTaskBranch(task.id, implBranch);\n branchName = implBranch;\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { stage: stage.key, branch: implBranch }));\n await this.progressReporter.branchCreated(stage.key, implBranch);\n }\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n // Do not auto-progress on manual stages\n this.emitEvent(this.adapter.createStatusEvent('stage_complete', { stage: stage.key }));\n return;\n }\n\n if (result.results) {\n const existingPlan = await this.readPlan(task.id);\n const planSummary = existingPlan ? existingPlan.split('\\n')[0] : undefined;\n await this.commitImplementation(task.id, task.title, planSummary);\n this.emitEvent(this.adapter.createStatusEvent('commit_made', { stage: stage.key, kind: 'implementation' }));\n await this.progressReporter.commitMade(stage.key, 'implementation');\n }\n\n // PR creation on complete stage (or if explicitly requested), regardless of whether edits occurred\n {\n const defaultOpenPR = stage.key.toLowerCase().includes('complete');\n const openPR = overrides?.openPullRequest ?? defaultOpenPR;\n if (openPR) {\n const branchName = await this.gitManager.getCurrentBranch();\n try {\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n await this.updateTaskBranch(task.id, branchName);\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { stage: stage.key, prUrl }));\n await this.progressReporter.pullRequestCreated(stage.key, prUrl);\n } catch {}\n }\n }\n\n this.emitEvent(this.adapter.createStatusEvent('stage_complete', { stage: stage.key }));\n }\n\n // Adaptive task execution - 3-phase workflow (research → plan → build)\n async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });\n\n // Initialize progress reporter for task run tracking (needed for PR attachment)\n await this.progressReporter.start(task.id, { totalSteps: 3 }); // 3 phases: research, plan, build\n this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));\n\n // Phase 1: Branch check\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n this.logger.info('Creating task branch', { taskSlug });\n const branchName = `posthog/task-${taskSlug}`;\n await this.gitManager.createOrSwitchToBranch(branchName);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));\n \n // Initial commit\n await this.fileManager.ensureGitignore();\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });\n } else {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n } else {\n this.logger.info('Switching to existing task branch', { branch: existingBranch });\n await this.gitManager.switchToBranch(existingBranch);\n }\n\n // Phase 2: Research\n const researchExists = await this.fileManager.readResearch(task.id);\n if (!researchExists) {\n this.logger.info('Starting research phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'research' }));\n \n // Run research agent\n const researchPrompt = await this.promptBuilder.buildResearchPrompt(task, cwd);\n const { RESEARCH_SYSTEM_PROMPT } = await import('./agents/research.js');\n const fullPrompt = RESEARCH_SYSTEM_PROMPT + '\\n\\n' + researchPrompt;\n \n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n let researchContent = '';\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) researchContent += c.text + '\\n';\n }\n }\n }\n\n // Write research.md\n if (researchContent.trim()) {\n await this.fileManager.writeResearch(task.id, researchContent.trim());\n this.logger.info('Research completed', { taskId: task.id });\n }\n\n // Commit research\n await this.gitManager.addAllPostHogFiles();\n \n // Extract questions using structured output and save to questions.json\n if (this.extractor) {\n try {\n this.logger.info('Extracting questions from research.md', { taskId: task.id });\n const questions = await this.extractQuestionsFromResearch(task.id, false);\n \n this.logger.info('Questions extracted successfully', { taskId: task.id, count: questions.length });\n \n // Save questions.json\n await this.fileManager.writeQuestions(task.id, {\n questions,\n answered: false,\n answers: null,\n });\n \n this.logger.info('Questions saved to questions.json', { taskId: task.id });\n \n // Emit event for Array to pick up (local mode)\n if (!isCloudMode) {\n this.emitEvent({\n type: 'artifact',\n ts: Date.now(),\n kind: 'research_questions',\n content: questions,\n });\n this.logger.info('Emitted research_questions artifact event', { taskId: task.id });\n }\n } catch (error) {\n this.logger.error('Failed to extract questions', { error: error instanceof Error ? error.message : String(error) });\n this.emitEvent({\n type: 'error',\n ts: Date.now(),\n message: `Failed to extract questions: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n } else {\n this.logger.warn('OpenAI extractor not available (OPENAI_API_KEY not set), skipping question extraction');\n this.emitEvent({\n type: 'status',\n ts: Date.now(),\n phase: 'extraction_skipped',\n message: 'Question extraction skipped - OPENAI_API_KEY not configured',\n });\n }\n \n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Research phase for ${task.title}`);\n } else {\n await this.gitManager.commitChanges(`Research phase for ${task.title}`);\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'research' }));\n return; // Local mode: return to user\n }\n }\n\n // Phase 3: Auto-answer questions (cloud mode only)\n if (isCloudMode) {\n const questionsData = await this.fileManager.readQuestions(task.id);\n if (questionsData && !questionsData.answered) {\n this.logger.info('Auto-answering research questions', { taskId: task.id });\n \n // Extract questions with recommended answers using structured output\n if (this.extractor) {\n const questionsWithAnswers = await this.extractQuestionsFromResearch(task.id, true) as ExtractedQuestionWithAnswer[];\n \n // Save answers to questions.json\n await this.fileManager.writeQuestions(task.id, {\n questions: questionsWithAnswers.map(qa => ({\n id: qa.id,\n question: qa.question,\n options: qa.options,\n })),\n answered: true,\n answers: questionsWithAnswers.map(qa => ({\n questionId: qa.id,\n selectedOption: qa.recommendedAnswer,\n customInput: qa.justification,\n })),\n });\n \n this.logger.info('Auto-answers saved to questions.json', { taskId: task.id });\n await this.gitManager.addAllPostHogFiles();\n await this.gitManager.commitAndPush(`Answer research questions for ${task.title}`);\n } else {\n this.logger.warn('OpenAI extractor not available, skipping auto-answer');\n }\n }\n }\n\n // Phase 4: Plan\n const planExists = await this.readPlan(task.id);\n if (!planExists) {\n // Check if questions have been answered\n const questionsData = await this.fileManager.readQuestions(task.id);\n if (!questionsData || !questionsData.answered) {\n this.logger.info('Waiting for user answers to research questions');\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'research_questions' }));\n return; // Wait for user to answer questions\n }\n\n this.logger.info('Starting planning phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'planning' }));\n \n // Build context with research + questions + answers\n const research = await this.fileManager.readResearch(task.id);\n let researchContext = '';\n if (research) {\n researchContext += `## Research Analysis\\n\\n${research}\\n\\n`;\n }\n \n // Add questions and answers\n researchContext += `## Implementation Decisions\\n\\n`;\n const answers = questionsData.answers || [];\n for (const question of questionsData.questions) {\n const answer = answers.find((a: any) => a.questionId === question.id);\n \n researchContext += `### ${question.question}\\n\\n`;\n if (answer) {\n researchContext += `**Selected:** ${answer.selectedOption}\\n`;\n if (answer.customInput) {\n researchContext += `**Details:** ${answer.customInput}\\n`;\n }\n } else {\n this.logger.warn('No answer found for question', { questionId: question.id });\n researchContext += `**Selected:** Not answered\\n`;\n }\n researchContext += '\\n';\n }\n \n // Run planning agent with full context\n const planningPrompt = await this.promptBuilder.buildPlanningPrompt(task, cwd);\n const { PLANNING_SYSTEM_PROMPT } = await import('./agents/planning.js');\n const fullPrompt = PLANNING_SYSTEM_PROMPT + '\\n\\n' + planningPrompt + '\\n\\n' + researchContext;\n \n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n let planContent = '';\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) planContent += c.text + '\\n';\n }\n }\n }\n\n // Write plan.md\n if (planContent.trim()) {\n await this.writePlan(task.id, planContent.trim());\n this.logger.info('Plan completed', { taskId: task.id });\n }\n\n // Commit plan\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Planning phase for ${task.title}`);\n } else {\n await this.gitManager.commitChanges(`Planning phase for ${task.title}`);\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'planning' }));\n return; // Local mode: return to user\n }\n }\n\n // Phase 5: Build\n const latestRun = task.latest_run;\n const prExists = latestRun?.output && (latestRun.output as any).pr_url;\n \n if (!prExists) {\n this.logger.info('Starting build phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'build' }));\n \n // Run execution agent\n const executionPrompt = await this.promptBuilder.buildExecutionPrompt(task, cwd);\n const { EXECUTION_SYSTEM_PROMPT } = await import('./agents/execution.js');\n const fullPrompt = EXECUTION_SYSTEM_PROMPT + '\\n\\n' + executionPrompt;\n \n const { PermissionMode } = await import('./types.js');\n const permissionMode = options.permissionMode || PermissionMode.ACCEPT_EDITS;\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode,\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n }\n\n // Commit and push implementation\n // Stage ALL changes (not just .posthog/)\n const hasChanges = await this.gitManager.hasChanges();\n if (hasChanges) {\n await this.gitManager.addFiles(['.']); // Stage all changes\n await this.gitManager.commitChanges(`Implementation for ${task.title}`);\n \n // Push to origin\n const branchName = await this.gitManager.getCurrentBranch();\n await this.gitManager.pushBranch(branchName);\n \n this.logger.info('Implementation committed and pushed', { taskId: task.id });\n } else {\n this.logger.warn('No changes to commit in build phase', { taskId: task.id });\n }\n\n // Create PR\n const branchName = await this.gitManager.getCurrentBranch();\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n this.logger.info('Pull request created', { taskId: task.id, prUrl });\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));\n \n // Attach PR to task run\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });\n } catch (error) {\n this.logger.warn('Could not attach PR to task', { error: error instanceof Error ? error.message : String(error) });\n }\n } else {\n this.logger.info('PR already exists, skipping build phase', { taskId: task.id });\n }\n\n // Phase 6: Complete\n await this.progressReporter.complete();\n this.logger.info('Task execution complete', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));\n }\n\n async progressToNextStage(taskId: string, currentStageKey?: string): Promise<void> {\n if (!this.posthogAPI || !this.progressReporter.runId) {\n throw new Error('PostHog API not configured or no active run. Cannot progress stage.');\n }\n try {\n await this.posthogAPI.progressTaskRun(taskId, this.progressReporter.runId);\n } catch (error) {\n if (error instanceof Error && error.message.includes('No next stage available')) {\n this.logger.warn('No next stage available when attempting to progress run', {\n taskId,\n runId: this.progressReporter.runId,\n stage: currentStageKey,\n error: error.message,\n });\n this.emitEvent(this.adapter.createStatusEvent('no_next_stage', { stage: currentStageKey }));\n await this.progressReporter.noNextStage(currentStageKey);\n return;\n }\n throw error;\n }\n }\n\n // Direct prompt execution - still supported for low-level usage\n async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {\n await this._configureLlmGateway();\n const baseOptions: Record<string, any> = {\n model: \"claude-sonnet-4-5-20250929\",\n cwd: options.repositoryPath || this.workingDirectory,\n permissionMode: (options.permissionMode as any) || \"default\",\n settingSources: [\"local\"],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n const results = [];\n for await (const message of response) {\n this.logger.debug('Received message in direct run', message);\n // Emit raw SDK event\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n // Emit transformed event\n const transformedEvent = this.adapter.transform(message);\n if (transformedEvent) {\n this.emitEvent(transformedEvent);\n }\n results.push(message);\n }\n \n return { results };\n }\n \n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n this.logger.debug('Fetching task from PostHog', { taskId });\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n \n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n workflow?: string;\n current_stage?: string;\n }): Promise<Task[]> {\n if (!this.posthogAPI) {\n throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n }\n return this.posthogAPI.listTasks(filters);\n }\n \n // File system operations for task artifacts\n async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {\n this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });\n await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });\n }\n \n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n this.logger.debug('Reading task file', { taskId, fileName });\n return await this.fileManager.readTaskFile(taskId, fileName);\n }\n \n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug('Getting task files', { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug('Found task files', { taskId, fileCount: files.length });\n return files;\n }\n \n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.info('Writing plan', { taskId, planLength: plan.length });\n await this.fileManager.writePlan(taskId, plan);\n }\n \n async readPlan(taskId: string): Promise<string | null> {\n this.logger.debug('Reading plan', { taskId });\n return await this.fileManager.readPlan(taskId);\n }\n\n async extractQuestionsFromResearch(taskId: string, includeAnswers: boolean = false): Promise<ExtractedQuestion[] | ExtractedQuestionWithAnswer[]> {\n this.logger.info('Extracting questions from research.md', { taskId, includeAnswers });\n \n if (!this.extractor) {\n throw new Error('OpenAI extractor not initialized. Set OPENAI_API_KEY environment variable.');\n }\n\n const researchContent = await this.fileManager.readResearch(taskId);\n if (!researchContent) {\n throw new Error('research.md not found for task ' + taskId);\n }\n\n if (includeAnswers) {\n return await this.extractor.extractQuestionsWithAnswers(researchContent);\n } else {\n return await this.extractor.extractQuestions(researchContent);\n }\n }\n \n // Git operations for task workflow\n async createPlanningBranch(taskId: string): Promise<string> {\n this.logger.info('Creating planning branch', { taskId });\n const branchName = await this.gitManager.createTaskPlanningBranch(taskId);\n this.logger.debug('Planning branch created', { taskId, branchName });\n // Only create gitignore after we're on the new branch\n await this.fileManager.ensureGitignore();\n return branchName;\n }\n \n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n this.logger.info('Committing plan', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);\n this.logger.debug('Plan committed', { taskId, commitHash });\n return commitHash;\n }\n \n async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });\n const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);\n this.logger.debug('Implementation branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n this.logger.info('Committing implementation', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);\n this.logger.debug('Implementation committed', { taskId, commitHash });\n return commitHash;\n }\n\n async createPullRequest(taskId: string, branchName: string, taskTitle: string, taskDescription: string): Promise<string> {\n this.logger.info('Creating pull request', { taskId, branchName, taskTitle });\n\n // Build PR body\n const prBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody\n );\n\n this.logger.info('Pull request created', { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {\n this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n const updates: any = {\n output: { pr_url: prUrl }\n };\n if (branchName) {\n updates.branch = branchName;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);\n this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task run branch', { taskId, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot update branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });\n this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager['executionStates']) {\n if (execution.taskId === taskId && execution.status === 'running') {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager['executionStates'].values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private emitEvent(event: any): void {\n if (this.debug && event.type !== 'token') {\n // Log all events except tokens (too verbose)\n this.logger.debug('Emitting event', { type: event.type, ts: event.ts });\n }\n const persistPromise = this.progressReporter.recordEvent(event);\n if (persistPromise && typeof persistPromise.then === 'function') {\n persistPromise.catch((error: Error) =>\n this.logger.debug('Failed to persist agent event', { message: error.message })\n );\n }\n this.onEvent?.(event);\n }\n}\n\nexport { PermissionMode } from './types.js';\nexport type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';\nexport type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;MAoBa,KAAK,CAAA;AACN,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,eAAe;AACf,IAAA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AM,KAAK,MAAM,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE;AAC/D,gBAAA,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC;gBAC7C;YACJ;QACJ;IACJ;AAEA,IAAA,sBAAsB,CAAC,MAAc,EAAA;;AAEjC,QAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;AAClE,YAAA,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC7B,OAAO,SAAS,CAAC,MAAM;YAC3B;QACJ;AACA,QAAA,OAAO,IAAI;IACf;AAEQ,IAAA,SAAS,CAAC,KAAU,EAAA;QACxB,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;;YAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3E;QACA,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC;QAC/D,IAAI,cAAc,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,UAAU,EAAE;YAC7D,cAAc,CAAC,KAAK,CAAC,CAAC,KAAY,KAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CACjF;QACL;AACA,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"agent.js","sources":["../../src/agent.ts"],"sourcesContent":["import { query } from \"@anthropic-ai/claude-agent-sdk\";\nimport type { Task, ExecutionResult, PlanResult, AgentConfig } from './types.js';\nimport { TaskManager } from './task-manager.js';\nimport { PostHogAPIClient } from './posthog-api.js';\nimport { PostHogFileManager } from './file-manager.js';\nimport { GitManager } from './git-manager.js';\nimport { TemplateManager } from './template-manager.js';\nimport { ClaudeAdapter } from './adapters/claude/claude-adapter.js';\nimport type { ProviderAdapter } from './adapters/types.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { Logger } from './utils/logger.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { TaskProgressReporter } from './task-progress-reporter.js';\nimport { OpenAIExtractor, type ExtractedQuestion, type ExtractedQuestionWithAnswer } from './structured-extraction.js';\n\nexport class Agent {\n private workingDirectory: string;\n private onEvent?: (event: any) => void;\n private taskManager: TaskManager;\n private posthogAPI?: PostHogAPIClient;\n private fileManager: PostHogFileManager;\n private gitManager: GitManager;\n private templateManager: TemplateManager;\n private adapter: ProviderAdapter;\n private logger: Logger;\n private progressReporter: TaskProgressReporter;\n private promptBuilder: PromptBuilder;\n private extractor?: OpenAIExtractor;\n private mcpServers?: Record<string, any>;\n public debug: boolean;\n\n constructor(config: AgentConfig = {}) {\n this.workingDirectory = config.workingDirectory || process.cwd();\n this.onEvent = config.onEvent;\n this.debug = config.debug || false;\n\n // Build default PostHog MCP server configuration\n const posthogMcpUrl = config.posthogMcpUrl\n || process.env.POSTHOG_MCP_URL\n || 'https://mcp.posthog.com/mcp';\n\n // Add auth if API key provided\n const headers: Record<string, string> = {};\n if (config.posthogApiKey) {\n headers['Authorization'] = `Bearer ${config.posthogApiKey}`;\n }\n\n const defaultMcpServers = {\n posthog: {\n type: 'http' as const,\n url: posthogMcpUrl,\n ...(Object.keys(headers).length > 0 ? { headers } : {}),\n }\n };\n\n // Merge default PostHog MCP with user-provided servers (user config takes precedence)\n this.mcpServers = {\n ...defaultMcpServers,\n ...config.mcpServers\n };\n this.logger = new Logger({ debug: this.debug, prefix: '[PostHog Agent]' });\n this.taskManager = new TaskManager();\n // Hardcode Claude adapter for now - extensible for other providers later\n this.adapter = new ClaudeAdapter();\n\n this.fileManager = new PostHogFileManager(\n this.workingDirectory,\n this.logger.child('FileManager')\n );\n this.gitManager = new GitManager({\n repositoryPath: this.workingDirectory,\n logger: this.logger.child('GitManager')\n // TODO: Add author config from environment or config\n });\n this.templateManager = new TemplateManager();\n\n if (config.posthogApiUrl && config.posthogApiKey) {\n this.posthogAPI = new PostHogAPIClient({\n apiUrl: config.posthogApiUrl,\n apiKey: config.posthogApiKey,\n });\n }\n\n this.promptBuilder = new PromptBuilder({\n getTaskFiles: (taskId: string) => this.getTaskFiles(taskId),\n generatePlanTemplate: (vars) => this.templateManager.generatePlan(vars),\n posthogClient: this.posthogAPI,\n logger: this.logger.child('PromptBuilder')\n });\n this.progressReporter = new TaskProgressReporter(this.posthogAPI, this.logger);\n \n // Initialize OpenAI extractor if API key is available\n if (process.env.OPENAI_API_KEY) {\n this.extractor = new OpenAIExtractor(this.logger.child('OpenAIExtractor'));\n }\n }\n\n /**\n * Enable or disable debug logging\n */\n setDebug(enabled: boolean) {\n this.debug = enabled;\n this.logger.setDebug(enabled);\n }\n\n /**\n * Configure LLM gateway environment variables for Claude Code CLI\n */\n private async _configureLlmGateway(): Promise<void> {\n if (!this.posthogAPI) {\n return;\n }\n\n if (process.env.ANTHROPIC_BASE_URL && process.env.ANTHROPIC_AUTH_TOKEN) {\n return;\n }\n\n try {\n const gatewayUrl = await this.posthogAPI.getLlmGatewayUrl();\n const apiKey = this.posthogAPI.getApiKey();\n\n process.env.ANTHROPIC_BASE_URL = gatewayUrl;\n process.env.ANTHROPIC_AUTH_TOKEN = apiKey;\n\n this.logger.debug('Configured LLM gateway', { gatewayUrl });\n } catch (error) {\n this.logger.error('Failed to configure LLM gateway', error);\n throw error;\n }\n }\n\n // Adaptive task execution - 3 phases (research → plan → build)\n async runTask(taskOrId: Task | string, options: import('./types.js').TaskExecutionOptions = {}): Promise<void> {\n await this._configureLlmGateway();\n\n const task = typeof taskOrId === 'string' ? await this.fetchTask(taskOrId) : taskOrId;\n const cwd = options.repositoryPath || this.workingDirectory;\n const isCloudMode = options.isCloudMode ?? false;\n const taskSlug = (task as any).slug || task.id;\n\n this.logger.info('Starting adaptive task execution', { taskId: task.id, taskSlug, isCloudMode });\n\n // Initialize progress reporter for task run tracking (needed for PR attachment)\n await this.progressReporter.start(task.id, { totalSteps: 3 }); // 3 phases: research, plan, build\n this.emitEvent(this.adapter.createStatusEvent('run_started', { runId: this.progressReporter.runId }));\n\n // Phase 1: Branch check\n const existingBranch = await this.gitManager.getTaskBranch(taskSlug);\n if (!existingBranch) {\n this.logger.info('Creating task branch', { taskSlug });\n const branchName = `posthog/task-${taskSlug}`;\n await this.gitManager.createOrSwitchToBranch(branchName);\n this.emitEvent(this.adapter.createStatusEvent('branch_created', { branch: branchName }));\n \n // Initial commit\n await this.fileManager.ensureGitignore();\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Initialize task ${taskSlug}`, { allowEmpty: true });\n } else {\n await this.gitManager.commitChanges(`Initialize task ${taskSlug}`);\n }\n } else {\n this.logger.info('Switching to existing task branch', { branch: existingBranch });\n await this.gitManager.switchToBranch(existingBranch);\n }\n\n // Phase 2: Research\n const researchExists = await this.fileManager.readResearch(task.id);\n if (!researchExists) {\n this.logger.info('Starting research phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'research' }));\n \n // Run research agent\n const researchPrompt = await this.promptBuilder.buildResearchPrompt(task, cwd);\n const { RESEARCH_SYSTEM_PROMPT } = await import('./agents/research.js');\n const fullPrompt = RESEARCH_SYSTEM_PROMPT + '\\n\\n' + researchPrompt;\n \n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n let researchContent = '';\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) researchContent += c.text + '\\n';\n }\n }\n }\n\n // Write research.md\n if (researchContent.trim()) {\n await this.fileManager.writeResearch(task.id, researchContent.trim());\n this.logger.info('Research completed', { taskId: task.id });\n }\n\n // Commit research\n await this.gitManager.addAllPostHogFiles();\n \n // Extract questions using structured output and save to questions.json\n if (this.extractor) {\n try {\n this.logger.info('Extracting questions from research.md', { taskId: task.id });\n const questions = await this.extractQuestionsFromResearch(task.id, false);\n \n this.logger.info('Questions extracted successfully', { taskId: task.id, count: questions.length });\n \n // Save questions.json\n await this.fileManager.writeQuestions(task.id, {\n questions,\n answered: false,\n answers: null,\n });\n \n this.logger.info('Questions saved to questions.json', { taskId: task.id });\n \n // Emit event for Array to pick up (local mode)\n if (!isCloudMode) {\n this.emitEvent({\n type: 'artifact',\n ts: Date.now(),\n kind: 'research_questions',\n content: questions,\n });\n this.logger.info('Emitted research_questions artifact event', { taskId: task.id });\n }\n } catch (error) {\n this.logger.error('Failed to extract questions', { error: error instanceof Error ? error.message : String(error) });\n this.emitEvent({\n type: 'error',\n ts: Date.now(),\n message: `Failed to extract questions: ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n } else {\n this.logger.warn('OpenAI extractor not available (OPENAI_API_KEY not set), skipping question extraction');\n this.emitEvent({\n type: 'status',\n ts: Date.now(),\n phase: 'extraction_skipped',\n message: 'Question extraction skipped - OPENAI_API_KEY not configured',\n });\n }\n \n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Research phase for ${task.title}`);\n } else {\n await this.gitManager.commitChanges(`Research phase for ${task.title}`);\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'research' }));\n return; // Local mode: return to user\n }\n }\n\n // Phase 3: Auto-answer questions (cloud mode only)\n if (isCloudMode) {\n const questionsData = await this.fileManager.readQuestions(task.id);\n if (questionsData && !questionsData.answered) {\n this.logger.info('Auto-answering research questions', { taskId: task.id });\n \n // Extract questions with recommended answers using structured output\n if (this.extractor) {\n const questionsWithAnswers = await this.extractQuestionsFromResearch(task.id, true) as ExtractedQuestionWithAnswer[];\n \n // Save answers to questions.json\n await this.fileManager.writeQuestions(task.id, {\n questions: questionsWithAnswers.map(qa => ({\n id: qa.id,\n question: qa.question,\n options: qa.options,\n })),\n answered: true,\n answers: questionsWithAnswers.map(qa => ({\n questionId: qa.id,\n selectedOption: qa.recommendedAnswer,\n customInput: qa.justification,\n })),\n });\n \n this.logger.info('Auto-answers saved to questions.json', { taskId: task.id });\n await this.gitManager.addAllPostHogFiles();\n await this.gitManager.commitAndPush(`Answer research questions for ${task.title}`);\n } else {\n this.logger.warn('OpenAI extractor not available, skipping auto-answer');\n }\n }\n }\n\n // Phase 4: Plan\n const planExists = await this.readPlan(task.id);\n if (!planExists) {\n // Check if questions have been answered\n const questionsData = await this.fileManager.readQuestions(task.id);\n if (!questionsData || !questionsData.answered) {\n this.logger.info('Waiting for user answers to research questions');\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'research_questions' }));\n return; // Wait for user to answer questions\n }\n\n this.logger.info('Starting planning phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'planning' }));\n \n // Build context with research + questions + answers\n const research = await this.fileManager.readResearch(task.id);\n let researchContext = '';\n if (research) {\n researchContext += `## Research Analysis\\n\\n${research}\\n\\n`;\n }\n \n // Add questions and answers\n researchContext += `## Implementation Decisions\\n\\n`;\n const answers = questionsData.answers || [];\n for (const question of questionsData.questions) {\n const answer = answers.find((a: any) => a.questionId === question.id);\n \n researchContext += `### ${question.question}\\n\\n`;\n if (answer) {\n researchContext += `**Selected:** ${answer.selectedOption}\\n`;\n if (answer.customInput) {\n researchContext += `**Details:** ${answer.customInput}\\n`;\n }\n } else {\n this.logger.warn('No answer found for question', { questionId: question.id });\n researchContext += `**Selected:** Not answered\\n`;\n }\n researchContext += '\\n';\n }\n \n // Run planning agent with full context\n const planningPrompt = await this.promptBuilder.buildPlanningPrompt(task, cwd);\n const { PLANNING_SYSTEM_PROMPT } = await import('./agents/planning.js');\n const fullPrompt = PLANNING_SYSTEM_PROMPT + '\\n\\n' + planningPrompt + '\\n\\n' + researchContext;\n \n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n let planContent = '';\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) planContent += c.text + '\\n';\n }\n }\n }\n\n // Write plan.md\n if (planContent.trim()) {\n await this.writePlan(task.id, planContent.trim());\n this.logger.info('Plan completed', { taskId: task.id });\n }\n\n // Commit plan\n await this.gitManager.addAllPostHogFiles();\n if (isCloudMode) {\n await this.gitManager.commitAndPush(`Planning phase for ${task.title}`);\n } else {\n await this.gitManager.commitChanges(`Planning phase for ${task.title}`);\n this.emitEvent(this.adapter.createStatusEvent('phase_complete', { phase: 'planning' }));\n return; // Local mode: return to user\n }\n }\n\n // Phase 5: Build\n const latestRun = task.latest_run;\n const prExists = latestRun?.output && (latestRun.output as any).pr_url;\n \n if (!prExists) {\n this.logger.info('Starting build phase', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('phase_start', { phase: 'build' }));\n \n // Run execution agent\n const executionPrompt = await this.promptBuilder.buildExecutionPrompt(task, cwd);\n const { EXECUTION_SYSTEM_PROMPT } = await import('./agents/execution.js');\n const fullPrompt = EXECUTION_SYSTEM_PROMPT + '\\n\\n' + executionPrompt;\n \n const { PermissionMode } = await import('./types.js');\n const permissionMode = options.permissionMode || PermissionMode.ACCEPT_EDITS;\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode,\n settingSources: ['local'],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt: fullPrompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n for await (const message of response) {\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n const transformed = this.adapter.transform(message);\n if (transformed) {\n this.emitEvent(transformed);\n }\n }\n\n // Commit and push implementation\n // Stage ALL changes (not just .posthog/)\n const hasChanges = await this.gitManager.hasChanges();\n if (hasChanges) {\n await this.gitManager.addFiles(['.']); // Stage all changes\n await this.gitManager.commitChanges(`Implementation for ${task.title}`);\n \n // Push to origin\n const branchName = await this.gitManager.getCurrentBranch();\n await this.gitManager.pushBranch(branchName);\n \n this.logger.info('Implementation committed and pushed', { taskId: task.id });\n } else {\n this.logger.warn('No changes to commit in build phase', { taskId: task.id });\n }\n\n // Create PR\n const branchName = await this.gitManager.getCurrentBranch();\n const prUrl = await this.createPullRequest(task.id, branchName, task.title, task.description);\n this.logger.info('Pull request created', { taskId: task.id, prUrl });\n this.emitEvent(this.adapter.createStatusEvent('pr_created', { prUrl }));\n \n // Attach PR to task run\n try {\n await this.attachPullRequestToTask(task.id, prUrl, branchName);\n this.logger.info('PR attached to task successfully', { taskId: task.id, prUrl });\n } catch (error) {\n this.logger.warn('Could not attach PR to task', { error: error instanceof Error ? error.message : String(error) });\n }\n } else {\n this.logger.info('PR already exists, skipping build phase', { taskId: task.id });\n }\n\n // Phase 6: Complete\n await this.progressReporter.complete();\n this.logger.info('Task execution complete', { taskId: task.id });\n this.emitEvent(this.adapter.createStatusEvent('task_complete', { taskId: task.id }));\n }\n\n // Direct prompt execution - still supported for low-level usage\n async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {\n await this._configureLlmGateway();\n const baseOptions: Record<string, any> = {\n model: \"claude-sonnet-4-5-20250929\",\n cwd: options.repositoryPath || this.workingDirectory,\n permissionMode: (options.permissionMode as any) || \"default\",\n settingSources: [\"local\"],\n mcpServers: this.mcpServers,\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...(options.queryOverrides || {}) },\n });\n\n const results = [];\n for await (const message of response) {\n this.logger.debug('Received message in direct run', message);\n // Emit raw SDK event\n this.emitEvent(this.adapter.createRawSDKEvent(message));\n // Emit transformed event\n const transformedEvent = this.adapter.transform(message);\n if (transformedEvent) {\n this.emitEvent(transformedEvent);\n }\n results.push(message);\n }\n \n return { results };\n }\n \n // PostHog task operations\n async fetchTask(taskId: string): Promise<Task> {\n this.logger.debug('Fetching task from PostHog', { taskId });\n if (!this.posthogAPI) {\n const error = new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n return this.posthogAPI.fetchTask(taskId);\n }\n\n getPostHogClient(): PostHogAPIClient | undefined {\n return this.posthogAPI;\n }\n \n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n }): Promise<Task[]> {\n if (!this.posthogAPI) {\n throw new Error('PostHog API not configured. Provide posthogApiUrl and posthogApiKey in constructor.');\n }\n return this.posthogAPI.listTasks(filters);\n }\n \n // File system operations for task artifacts\n async writeTaskFile(taskId: string, fileName: string, content: string, type: 'plan' | 'context' | 'reference' | 'output' = 'reference'): Promise<void> {\n this.logger.debug('Writing task file', { taskId, fileName, type, contentLength: content.length });\n await this.fileManager.writeTaskFile(taskId, { name: fileName, content, type });\n }\n \n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n this.logger.debug('Reading task file', { taskId, fileName });\n return await this.fileManager.readTaskFile(taskId, fileName);\n }\n \n async getTaskFiles(taskId: string): Promise<any[]> {\n this.logger.debug('Getting task files', { taskId });\n const files = await this.fileManager.getTaskFiles(taskId);\n this.logger.debug('Found task files', { taskId, fileCount: files.length });\n return files;\n }\n \n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.info('Writing plan', { taskId, planLength: plan.length });\n await this.fileManager.writePlan(taskId, plan);\n }\n \n async readPlan(taskId: string): Promise<string | null> {\n this.logger.debug('Reading plan', { taskId });\n return await this.fileManager.readPlan(taskId);\n }\n\n async extractQuestionsFromResearch(taskId: string, includeAnswers: boolean = false): Promise<ExtractedQuestion[] | ExtractedQuestionWithAnswer[]> {\n this.logger.info('Extracting questions from research.md', { taskId, includeAnswers });\n \n if (!this.extractor) {\n throw new Error('OpenAI extractor not initialized. Set OPENAI_API_KEY environment variable.');\n }\n\n const researchContent = await this.fileManager.readResearch(taskId);\n if (!researchContent) {\n throw new Error('research.md not found for task ' + taskId);\n }\n\n if (includeAnswers) {\n return await this.extractor.extractQuestionsWithAnswers(researchContent);\n } else {\n return await this.extractor.extractQuestions(researchContent);\n }\n }\n\n // Git operations for task execution\n async createPlanningBranch(taskId: string): Promise<string> {\n this.logger.info('Creating planning branch', { taskId });\n const branchName = await this.gitManager.createTaskPlanningBranch(taskId);\n this.logger.debug('Planning branch created', { taskId, branchName });\n // Only create gitignore after we're on the new branch\n await this.fileManager.ensureGitignore();\n return branchName;\n }\n \n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n this.logger.info('Committing plan', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitPlan(taskId, taskTitle);\n this.logger.debug('Plan committed', { taskId, commitHash });\n return commitHash;\n }\n \n async createImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n this.logger.info('Creating implementation branch', { taskId, fromBranch: planningBranchName });\n const branchName = await this.gitManager.createTaskImplementationBranch(taskId, planningBranchName);\n this.logger.debug('Implementation branch created', { taskId, branchName });\n return branchName;\n }\n \n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n this.logger.info('Committing implementation', { taskId, taskTitle });\n const commitHash = await this.gitManager.commitImplementation(taskId, taskTitle, planSummary);\n this.logger.debug('Implementation committed', { taskId, commitHash });\n return commitHash;\n }\n\n async createPullRequest(taskId: string, branchName: string, taskTitle: string, taskDescription: string): Promise<string> {\n this.logger.info('Creating pull request', { taskId, branchName, taskTitle });\n\n // Build PR body\n const prBody = `## Task Details\n**Task ID**: ${taskId}\n**Description**: ${taskDescription}\n\n## Changes\nThis PR implements the changes described in the task.\n\nGenerated by PostHog Agent`;\n\n const prUrl = await this.gitManager.createPullRequest(\n branchName,\n taskTitle,\n prBody\n );\n\n this.logger.info('Pull request created', { taskId, prUrl });\n return prUrl;\n }\n\n async attachPullRequestToTask(taskId: string, prUrl: string, branchName?: string): Promise<void> {\n this.logger.info('Attaching PR to task run', { taskId, prUrl, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot attach PR to task.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n const updates: any = {\n output: { pr_url: prUrl }\n };\n if (branchName) {\n updates.branch = branchName;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, updates);\n this.logger.debug('PR attached to task run', { taskId, runId: this.progressReporter.runId, prUrl });\n }\n\n async updateTaskBranch(taskId: string, branchName: string): Promise<void> {\n this.logger.info('Updating task run branch', { taskId, branchName });\n\n if (!this.posthogAPI || !this.progressReporter.runId) {\n const error = new Error('PostHog API not configured or no active run. Cannot update branch.');\n this.logger.error('PostHog API not configured', error);\n throw error;\n }\n\n await this.posthogAPI.updateTaskRun(taskId, this.progressReporter.runId, { branch: branchName });\n this.logger.debug('Task run branch updated', { taskId, runId: this.progressReporter.runId, branchName });\n }\n\n // Execution management\n cancelTask(taskId: string): void {\n // Find the execution for this task and cancel it\n for (const [executionId, execution] of this.taskManager['executionStates']) {\n if (execution.taskId === taskId && execution.status === 'running') {\n this.taskManager.cancelExecution(executionId);\n break;\n }\n }\n }\n\n getTaskExecutionStatus(taskId: string): string | null {\n // Find the execution for this task\n for (const execution of this.taskManager['executionStates'].values()) {\n if (execution.taskId === taskId) {\n return execution.status;\n }\n }\n return null;\n }\n\n private emitEvent(event: any): void {\n if (this.debug && event.type !== 'token') {\n // Log all events except tokens (too verbose)\n this.logger.debug('Emitting event', { type: event.type, ts: event.ts });\n }\n const persistPromise = this.progressReporter.recordEvent(event);\n if (persistPromise && typeof persistPromise.then === 'function') {\n persistPromise.catch((error: Error) =>\n this.logger.debug('Failed to persist agent event', { message: error.message })\n );\n }\n this.onEvent?.(event);\n }\n}\n\nexport { PermissionMode } from './types.js';\nexport type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';\n"],"names":[],"mappings":";;;;;;;;;;;;;MAgBa,KAAK,CAAA;AACN,IAAA,gBAAgB;AAChB,IAAA,OAAO;AACP,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,UAAU;AACV,IAAA,eAAe;AACf,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,SAAS;AACT,IAAA,UAAU;AACX,IAAA,KAAK;AAEZ,IAAA,WAAA,CAAY,SAAsB,EAAE,EAAA;QAChC,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;AAChE,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO;QAC7B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK;;AAGlC,QAAA,MAAM,aAAa,GAAG,MAAM,CAAC;eACtB,OAAO,CAAC,GAAG,CAAC;AACZ,eAAA,6BAA6B;;QAGpC,MAAM,OAAO,GAA2B,EAAE;AAC1C,QAAA,IAAI,MAAM,CAAC,aAAa,EAAE;YACtB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,CAAC,aAAa,CAAA,CAAE;QAC/D;AAEA,QAAA,MAAM,iBAAiB,GAAG;AACtB,YAAA,OAAO,EAAE;AACL,gBAAA,IAAI,EAAE,MAAe;AACrB,gBAAA,GAAG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AAC,WAAW,CAAC;gBAC7C;YACJ;QACJ;IACJ;AAEA,IAAA,sBAAsB,CAAC,MAAc,EAAA;;AAEjC,QAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,EAAE;AAClE,YAAA,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC7B,OAAO,SAAS,CAAC,MAAM;YAC3B;QACJ;AACA,QAAA,OAAO,IAAI;IACf;AAEQ,IAAA,SAAS,CAAC,KAAU,EAAA;QACxB,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;;YAEtC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3E;QACA,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC;QAC/D,IAAI,cAAc,IAAI,OAAO,cAAc,CAAC,IAAI,KAAK,UAAU,EAAE;YAC7D,cAAc,CAAC,KAAK,CAAC,CAAC,KAAY,KAC9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CACjF;QACL;AACA,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACzB;AACH;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const EXECUTION_SYSTEM_PROMPT = "<context>\n You have access to the local repository files for fast read/write operations.\n You also have access to GitHub via the GitHub MCP server for additional repository operations.\n Work with local files for your main implementation, and use GitHub MCP for any additional repository queries.\n Commit changes to the repository regularly.\n</context>\n\n<role>\n PostHog AI Coding Agent \u2014 autonomously transform a ticket into a merge-ready pull request that follows existing project conventions.\n</role>\n\n<tools>\n Local file system (for main implementation work)\n PostHog MCP server (for PostHog operations)\n</tools>\n\n<constraints>\n - Follow existing style and patterns you discover in the repo.\n - Try not to add new external dependencies, only if needed.\n - Implement structured logging and error handling; never log secrets.\n - Avoid destructive shell commands.\n - ALWAYS create appropriate .gitignore files to exclude build artifacts, dependencies, and temporary files.\n</constraints>\n\n<checklist>\n - Created or updated .gitignore file with appropriate exclusions\n - Created dependency files (requirements.txt, package.json, etc.) with exact versions\n - Added clear setup/installation instructions to README.md\n - Code compiles and tests pass.\n - Added or updated tests.\n - Captured meaningful events with PostHog SDK.\n - Wrapped new logic in an PostHog feature flag.\n - Updated docs, readme or type hints if needed.\n - Verified no build artifacts or dependencies are being committed\n</checklist>\n\n<
|
|
1
|
+
export declare const EXECUTION_SYSTEM_PROMPT = "<context>\n You have access to the local repository files for fast read/write operations.\n You also have access to GitHub via the GitHub MCP server for additional repository operations.\n Work with local files for your main implementation, and use GitHub MCP for any additional repository queries.\n Commit changes to the repository regularly.\n</context>\n\n<role>\n PostHog AI Coding Agent \u2014 autonomously transform a ticket into a merge-ready pull request that follows existing project conventions.\n</role>\n\n<tools>\n Local file system (for main implementation work)\n PostHog MCP server (for PostHog operations)\n</tools>\n\n<constraints>\n - Follow existing style and patterns you discover in the repo.\n - Try not to add new external dependencies, only if needed.\n - Implement structured logging and error handling; never log secrets.\n - Avoid destructive shell commands.\n - ALWAYS create appropriate .gitignore files to exclude build artifacts, dependencies, and temporary files.\n</constraints>\n\n<checklist>\n - Created or updated .gitignore file with appropriate exclusions\n - Created dependency files (requirements.txt, package.json, etc.) with exact versions\n - Added clear setup/installation instructions to README.md\n - Code compiles and tests pass.\n - Added or updated tests.\n - Captured meaningful events with PostHog SDK.\n - Wrapped new logic in an PostHog feature flag.\n - Updated docs, readme or type hints if needed.\n - Verified no build artifacts or dependencies are being committed\n</checklist>\n\n<approach>\n- first make a plan and create a todo list\n- execute the todo list one by one\n- test the changes\n</approach>\n\n<output_format>\n Once finished respond with a summary of changes made\n</output_format>\n\n<thinking>\n Use this area as a private scratch-pad for step-by-step reasoning; erase before final output.\n</thinking>\n\n<task>\n Complete the ticket in a thoughtful step by step manner. Plan thoroughly and make sure to add logging and error handling as well as cover edge cases.\n</task>";
|
|
2
2
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -34,11 +34,11 @@ const EXECUTION_SYSTEM_PROMPT = `<context>
|
|
|
34
34
|
- Verified no build artifacts or dependencies are being committed
|
|
35
35
|
</checklist>
|
|
36
36
|
|
|
37
|
-
<
|
|
37
|
+
<approach>
|
|
38
38
|
- first make a plan and create a todo list
|
|
39
39
|
- execute the todo list one by one
|
|
40
40
|
- test the changes
|
|
41
|
-
</
|
|
41
|
+
</approach>
|
|
42
42
|
|
|
43
43
|
<output_format>
|
|
44
44
|
Once finished respond with a summary of changes made
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sources":["../../../src/agents/execution.ts"],"sourcesContent":["export const EXECUTION_SYSTEM_PROMPT = `<context>\n You have access to the local repository files for fast read/write operations.\n You also have access to GitHub via the GitHub MCP server for additional repository operations.\n Work with local files for your main implementation, and use GitHub MCP for any additional repository queries.\n Commit changes to the repository regularly.\n</context>\n\n<role>\n PostHog AI Coding Agent — autonomously transform a ticket into a merge-ready pull request that follows existing project conventions.\n</role>\n\n<tools>\n Local file system (for main implementation work)\n PostHog MCP server (for PostHog operations)\n</tools>\n\n<constraints>\n - Follow existing style and patterns you discover in the repo.\n - Try not to add new external dependencies, only if needed.\n - Implement structured logging and error handling; never log secrets.\n - Avoid destructive shell commands.\n - ALWAYS create appropriate .gitignore files to exclude build artifacts, dependencies, and temporary files.\n</constraints>\n\n<checklist>\n - Created or updated .gitignore file with appropriate exclusions\n - Created dependency files (requirements.txt, package.json, etc.) with exact versions\n - Added clear setup/installation instructions to README.md\n - Code compiles and tests pass.\n - Added or updated tests.\n - Captured meaningful events with PostHog SDK.\n - Wrapped new logic in an PostHog feature flag.\n - Updated docs, readme or type hints if needed.\n - Verified no build artifacts or dependencies are being committed\n</checklist>\n\n<
|
|
1
|
+
{"version":3,"file":"execution.js","sources":["../../../src/agents/execution.ts"],"sourcesContent":["export const EXECUTION_SYSTEM_PROMPT = `<context>\n You have access to the local repository files for fast read/write operations.\n You also have access to GitHub via the GitHub MCP server for additional repository operations.\n Work with local files for your main implementation, and use GitHub MCP for any additional repository queries.\n Commit changes to the repository regularly.\n</context>\n\n<role>\n PostHog AI Coding Agent — autonomously transform a ticket into a merge-ready pull request that follows existing project conventions.\n</role>\n\n<tools>\n Local file system (for main implementation work)\n PostHog MCP server (for PostHog operations)\n</tools>\n\n<constraints>\n - Follow existing style and patterns you discover in the repo.\n - Try not to add new external dependencies, only if needed.\n - Implement structured logging and error handling; never log secrets.\n - Avoid destructive shell commands.\n - ALWAYS create appropriate .gitignore files to exclude build artifacts, dependencies, and temporary files.\n</constraints>\n\n<checklist>\n - Created or updated .gitignore file with appropriate exclusions\n - Created dependency files (requirements.txt, package.json, etc.) with exact versions\n - Added clear setup/installation instructions to README.md\n - Code compiles and tests pass.\n - Added or updated tests.\n - Captured meaningful events with PostHog SDK.\n - Wrapped new logic in an PostHog feature flag.\n - Updated docs, readme or type hints if needed.\n - Verified no build artifacts or dependencies are being committed\n</checklist>\n\n<approach>\n- first make a plan and create a todo list\n- execute the todo list one by one\n- test the changes\n</approach>\n\n<output_format>\n Once finished respond with a summary of changes made\n</output_format>\n\n<thinking>\n Use this area as a private scratch-pad for step-by-step reasoning; erase before final output.\n</thinking>\n\n<task>\n Complete the ticket in a thoughtful step by step manner. Plan thoroughly and make sure to add logging and error handling as well as cover edge cases.\n</task>`;"],"names":[],"mappings":"AAAO,MAAM,uBAAuB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/src/git-manager.js
CHANGED
|
@@ -134,7 +134,7 @@ class GitManager {
|
|
|
134
134
|
const forceFlag = force ? '--force' : '';
|
|
135
135
|
await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);
|
|
136
136
|
}
|
|
137
|
-
// Utility methods for PostHog task
|
|
137
|
+
// Utility methods for PostHog task execution
|
|
138
138
|
async createTaskPlanningBranch(taskId, baseBranch) {
|
|
139
139
|
let branchName = `posthog/task-${taskId}-planning`;
|
|
140
140
|
let counter = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${p}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n await this.runGitCommand('add .posthog/');\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n let command = 'commit -m \"' + message.replace(/\"/g, '\\\\\"') + '\"';\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n // Utility methods for PostHog task workflow\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-planning`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-planning-${counter}`;\n counter++;\n }\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n // If no base branch specified, ensure we're on main/master\n if (!baseBranch) {\n baseBranch = await this.getDefaultBranch();\n await this.switchToBranch(baseBranch);\n\n // Check for uncommitted changes\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before running tasks.`);\n }\n }\n\n await this.createBranch(branchName, baseBranch); // Use createBranch instead of createOrSwitchToBranch for new branches\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-implementation`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-implementation-${counter}`;\n counter++;\n }\n\n const currentBranchBefore = await this.getCurrentBranch();\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: currentBranchBefore\n });\n\n // Implementation branch should branch from the specific planning branch\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n // Try to find the corresponding planning branch\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch; // Use current planning branch\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n // Fallback to default branch\n baseBranch = await this.getDefaultBranch();\n this.logger.debug('No planning branch found, using default', { baseBranch });\n await this.switchToBranch(baseBranch);\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch); // Create fresh branch from base\n\n const currentBranchAfter = await this.getCurrentBranch();\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: currentBranchAfter\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body \"${body.replace(/\"/g, '\\\\\"')}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n\n async getTaskBranch(taskSlug: string): Promise<string | null> {\n try {\n // Get all branches matching the task slug pattern\n const branches = await this.runGitCommand('branch --list --all');\n const branchPattern = `posthog/task-${taskSlug}`;\n \n // Look for exact match or with counter suffix\n const lines = branches.split('\\n').map(l => l.trim().replace(/^\\*\\s+/, ''));\n for (const line of lines) {\n const cleanBranch = line.replace('remotes/origin/', '');\n if (cleanBranch.startsWith(branchPattern)) {\n return cleanBranch;\n }\n }\n \n return null;\n } catch (error) {\n this.logger.debug('Failed to get task branch', { taskSlug, error });\n return null;\n }\n }\n\n async commitAndPush(message: string, options?: { allowEmpty?: boolean }): Promise<void> {\n const hasChanges = await this.hasStagedChanges();\n \n if (!hasChanges && !options?.allowEmpty) {\n this.logger.debug('No changes to commit, skipping');\n return;\n }\n\n let command = `commit -m \"${message.replace(/\"/g, '\\\\\"')}\"`;\n \n if (options?.allowEmpty) {\n command += ' --allow-empty';\n }\n\n const authorName = this.authorName;\n const authorEmail = this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n await this.runGitCommand(command);\n \n // Push to origin\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n \n this.logger.info('Committed and p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AAC,CAAA,CAAA,CAAG;AAE3D,QAAA,IAAI,OAAO,EAAE,UAAU,EAAE;YACvB,OAAO,IAAI,gBAAgB;QAC7B;AAEA,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU;AAClC,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW;AAEpC,QAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,YAAA,OAAO,IAAI,CAAA,WAAA,EAAc,UAAU,CAAA,EAAA,EAAK,WAAW,IAAI;QACzD;AAEA,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;;AAGjC,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;AACnD,QAAA,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AAEpC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IACtF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${p}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n await this.runGitCommand('add .posthog/');\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n let command = 'commit -m \"' + message.replace(/\"/g, '\\\\\"') + '\"';\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n // Utility methods for PostHog task execution\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-planning`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-planning-${counter}`;\n counter++;\n }\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n // If no base branch specified, ensure we're on main/master\n if (!baseBranch) {\n baseBranch = await this.getDefaultBranch();\n await this.switchToBranch(baseBranch);\n\n // Check for uncommitted changes\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before running tasks.`);\n }\n }\n\n await this.createBranch(branchName, baseBranch); // Use createBranch instead of createOrSwitchToBranch for new branches\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-implementation`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-implementation-${counter}`;\n counter++;\n }\n\n const currentBranchBefore = await this.getCurrentBranch();\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: currentBranchBefore\n });\n\n // Implementation branch should branch from the specific planning branch\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n // Try to find the corresponding planning branch\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch; // Use current planning branch\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n // Fallback to default branch\n baseBranch = await this.getDefaultBranch();\n this.logger.debug('No planning branch found, using default', { baseBranch });\n await this.switchToBranch(baseBranch);\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch); // Create fresh branch from base\n\n const currentBranchAfter = await this.getCurrentBranch();\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: currentBranchAfter\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body \"${body.replace(/\"/g, '\\\\\"')}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n\n async getTaskBranch(taskSlug: string): Promise<string | null> {\n try {\n // Get all branches matching the task slug pattern\n const branches = await this.runGitCommand('branch --list --all');\n const branchPattern = `posthog/task-${taskSlug}`;\n \n // Look for exact match or with counter suffix\n const lines = branches.split('\\n').map(l => l.trim().replace(/^\\*\\s+/, ''));\n for (const line of lines) {\n const cleanBranch = line.replace('remotes/origin/', '');\n if (cleanBranch.startsWith(branchPattern)) {\n return cleanBranch;\n }\n }\n \n return null;\n } catch (error) {\n this.logger.debug('Failed to get task branch', { taskSlug, error });\n return null;\n }\n }\n\n async commitAndPush(message: string, options?: { allowEmpty?: boolean }): Promise<void> {\n const hasChanges = await this.hasStagedChanges();\n \n if (!hasChanges && !options?.allowEmpty) {\n this.logger.debug('No changes to commit, skipping');\n return;\n }\n\n let command = `commit -m \"${message.replace(/\"/g, '\\\\\"')}\"`;\n \n if (options?.allowEmpty) {\n command += ' --allow-empty';\n }\n\n const authorName = this.authorName;\n const authorEmail = this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n await this.runGitCommand(command);\n \n // Push to origin\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n \n this.logger.info('Committed and pushed changes', { branch: currentBranch, message });\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF;IAEQ,MAAM,aAAa,CAAC,OAAe,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,CAAA,IAAA,EAAO,IAAI,CAAC,cAAc,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAC;AACnF,YAAA,OAAO,MAAM,CAAC,IAAI,EAAE;QACtB;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,CAAA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,QAAQ,EAAE,KAAK,EAAE,CAAC;AACnE,YAAA,OAAO,IAAI;QACb;IACF;AAEA,IAAA,MAAM,aAAa,CAAC,OAAe,EAAE,OAAkC,EAAA;AACrE,QAAA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;QAEhD,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;AACvC,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC;YACnD;QACF;AAEA,QAAA,IAAI,OAAO,GAAG,CAAA,WAAA,EAAc,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA,CAAA,CAAG;AAE3D,QAAA,IAAI,OAAO,EAAE,UAAU,EAAE;YACvB,OAAO,IAAI,gBAAgB;QAC7B;AAEA,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU;AAClC,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW;AAEpC,QAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,YAAA,OAAO,IAAI,CAAA,WAAA,EAAc,UAAU,CAAA,EAAA,EAAK,WAAW,IAAI;QACzD;AAEA,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;;AAGjC,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;AACnD,QAAA,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AAEpC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IACtF;AACD;;;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Task, TaskRun, LogEntry, PostHogAPIConfig, PostHogResource, UrlMention } from './types.js';
|
|
2
|
-
import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
|
|
3
2
|
export interface TaskRunUpdate {
|
|
4
3
|
status?: TaskRun["status"];
|
|
5
4
|
branch?: string | null;
|
|
@@ -25,21 +24,14 @@ export declare class PostHogAPIClient {
|
|
|
25
24
|
repository?: string;
|
|
26
25
|
organization?: string;
|
|
27
26
|
origin_product?: string;
|
|
28
|
-
workflow?: string;
|
|
29
|
-
current_stage?: string;
|
|
30
27
|
}): Promise<Task[]>;
|
|
31
28
|
updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
|
|
32
29
|
listTaskRuns(taskId: string): Promise<TaskRun[]>;
|
|
33
30
|
getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
|
|
34
31
|
createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>): Promise<TaskRun>;
|
|
35
32
|
updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
|
|
36
|
-
updateTaskRunStage(taskId: string, runId: string, stageId: string): Promise<TaskRun>;
|
|
37
|
-
progressTaskRun(taskId: string, runId: string, nextStageId?: string): Promise<TaskRun>;
|
|
38
33
|
setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun>;
|
|
39
34
|
appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun>;
|
|
40
|
-
fetchWorkflow(workflowId: string): Promise<WorkflowDefinition>;
|
|
41
|
-
listWorkflows(): Promise<WorkflowDefinition[]>;
|
|
42
|
-
listAgents(): Promise<AgentDefinition[]>;
|
|
43
35
|
/**
|
|
44
36
|
* Fetch error details from PostHog error tracking
|
|
45
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAkB,gBAAgB,EAAE,eAAe,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"pos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,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IASjE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAQhD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3D,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC,GACtG,OAAO,CAAC,OAAO,CAAC;IAQb,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC;IAQb,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5F;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BtF;;OAEG;IACG,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IAmC1E;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAkC3B"}
|
package/dist/src/posthog-api.js
CHANGED
|
@@ -108,24 +108,6 @@ class PostHogAPIClient {
|
|
|
108
108
|
body: JSON.stringify(payload),
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async updateTaskRunStage(taskId, runId, stageId) {
|
|
112
|
-
const teamId = await this.getTeamId();
|
|
113
|
-
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/update_stage/`, {
|
|
114
|
-
method: 'PATCH',
|
|
115
|
-
body: JSON.stringify({ current_stage: stageId }),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
async progressTaskRun(taskId, runId, nextStageId) {
|
|
119
|
-
const teamId = await this.getTeamId();
|
|
120
|
-
const payload = {};
|
|
121
|
-
if (nextStageId) {
|
|
122
|
-
payload.next_stage_id = nextStageId;
|
|
123
|
-
}
|
|
124
|
-
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/progress_run/`, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: JSON.stringify(payload),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
111
|
async setTaskRunOutput(taskId, runId, output) {
|
|
130
112
|
const teamId = await this.getTeamId();
|
|
131
113
|
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
|
|
@@ -140,20 +122,6 @@ class PostHogAPIClient {
|
|
|
140
122
|
body: JSON.stringify({ entries }),
|
|
141
123
|
});
|
|
142
124
|
}
|
|
143
|
-
// Workflow endpoints
|
|
144
|
-
async fetchWorkflow(workflowId) {
|
|
145
|
-
const teamId = await this.getTeamId();
|
|
146
|
-
return this.apiRequest(`/api/projects/${teamId}/workflows/${workflowId}/`);
|
|
147
|
-
}
|
|
148
|
-
async listWorkflows() {
|
|
149
|
-
const teamId = await this.getTeamId();
|
|
150
|
-
const response = await this.apiRequest(`/api/projects/${teamId}/workflows/`);
|
|
151
|
-
return response.results || [];
|
|
152
|
-
}
|
|
153
|
-
// Agent catalog exposure
|
|
154
|
-
async listAgents() {
|
|
155
|
-
return this.apiRequest(`/api/agents/`);
|
|
156
|
-
}
|
|
157
125
|
/**
|
|
158
126
|
* Fetch error details from PostHog error tracking
|
|
159
127
|
*/
|