@posthog/agent 1.10.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.
Files changed (77) hide show
  1. package/README.md +26 -65
  2. package/dist/index.d.ts +2 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/src/adapters/types.d.ts +1 -1
  5. package/dist/src/agent.d.ts +5 -13
  6. package/dist/src/agent.d.ts.map +1 -1
  7. package/dist/src/agent.js +300 -187
  8. package/dist/src/agent.js.map +1 -1
  9. package/dist/src/agents/execution.d.ts +1 -1
  10. package/dist/src/agents/execution.js +2 -2
  11. package/dist/src/agents/execution.js.map +1 -1
  12. package/dist/src/agents/research.d.ts +2 -0
  13. package/dist/src/agents/research.d.ts.map +1 -0
  14. package/dist/src/agents/research.js +105 -0
  15. package/dist/src/agents/research.js.map +1 -0
  16. package/dist/src/file-manager.d.ts +19 -0
  17. package/dist/src/file-manager.d.ts.map +1 -1
  18. package/dist/src/file-manager.js +39 -0
  19. package/dist/src/file-manager.js.map +1 -1
  20. package/dist/src/git-manager.d.ts +4 -0
  21. package/dist/src/git-manager.d.ts.map +1 -1
  22. package/dist/src/git-manager.js +42 -1
  23. package/dist/src/git-manager.js.map +1 -1
  24. package/dist/src/posthog-api.d.ts +0 -8
  25. package/dist/src/posthog-api.d.ts.map +1 -1
  26. package/dist/src/posthog-api.js +0 -32
  27. package/dist/src/posthog-api.js.map +1 -1
  28. package/dist/src/prompt-builder.d.ts +1 -0
  29. package/dist/src/prompt-builder.d.ts.map +1 -1
  30. package/dist/src/prompt-builder.js +40 -0
  31. package/dist/src/prompt-builder.js.map +1 -1
  32. package/dist/src/structured-extraction.d.ts +22 -0
  33. package/dist/src/structured-extraction.d.ts.map +1 -0
  34. package/dist/src/structured-extraction.js +136 -0
  35. package/dist/src/structured-extraction.js.map +1 -0
  36. package/dist/src/task-progress-reporter.d.ts +0 -6
  37. package/dist/src/task-progress-reporter.d.ts.map +1 -1
  38. package/dist/src/task-progress-reporter.js +2 -26
  39. package/dist/src/task-progress-reporter.js.map +1 -1
  40. package/dist/src/template-manager.d.ts.map +1 -1
  41. package/dist/src/template-manager.js +26 -4
  42. package/dist/src/template-manager.js.map +1 -1
  43. package/dist/src/types.d.ts +7 -4
  44. package/dist/src/types.d.ts.map +1 -1
  45. package/dist/src/types.js +0 -1
  46. package/dist/src/types.js.map +1 -1
  47. package/package.json +5 -5
  48. package/src/adapters/types.ts +1 -1
  49. package/src/agent.ts +326 -195
  50. package/src/agents/execution.ts +2 -2
  51. package/src/agents/research.ts +103 -0
  52. package/src/file-manager.ts +64 -0
  53. package/src/git-manager.ts +53 -1
  54. package/src/posthog-api.ts +0 -40
  55. package/src/prompt-builder.ts +53 -0
  56. package/src/structured-extraction.ts +167 -0
  57. package/src/task-progress-reporter.ts +2 -34
  58. package/src/template-manager.ts +35 -5
  59. package/src/types.ts +8 -7
  60. package/dist/src/agent-registry.d.ts +0 -16
  61. package/dist/src/agent-registry.d.ts.map +0 -1
  62. package/dist/src/agent-registry.js +0 -56
  63. package/dist/src/agent-registry.js.map +0 -1
  64. package/dist/src/stage-executor.d.ts +0 -19
  65. package/dist/src/stage-executor.d.ts.map +0 -1
  66. package/dist/src/stage-executor.js +0 -135
  67. package/dist/src/stage-executor.js.map +0 -1
  68. package/dist/src/workflow-registry.d.ts +0 -11
  69. package/dist/src/workflow-registry.d.ts.map +0 -1
  70. package/dist/src/workflow-registry.js +0 -27
  71. package/dist/src/workflow-registry.js.map +0 -1
  72. package/dist/src/workflow-types.d.ts +0 -45
  73. package/dist/src/workflow-types.d.ts.map +0 -1
  74. package/src/agent-registry.ts +0 -59
  75. package/src/stage-executor.ts +0 -160
  76. package/src/workflow-registry.ts +0 -30
  77. package/src/workflow-types.ts +0 -52
@@ -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';\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 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 const 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 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\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 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 // 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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;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,K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AAI,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<workflow>\n- first make a plan and create a todo list\n- execute the todo list one by one\n- test the changes\n</workflow>\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>";
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
- <workflow>
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
- </workflow>
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<workflow>\n- first make a plan and create a todo list\n- execute the todo list one by one\n- test the changes\n</workflow>\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export declare const RESEARCH_SYSTEM_PROMPT = "# PostHog AI Coding Agent - Research Mode\n\nYou are a PostHog AI Coding Agent operating in RESEARCH mode.\n\n## Your Role\n\nYou are a research agent that explores codebases to understand implementation context and generate clarifying questions for development tasks.\n\n## Important Constraints\n\n- **Read-Only Mode**: You can only read files, search code, and analyze the codebase\n- **No Modifications**: You cannot make any changes or edits to code files\n- **Research Focus**: Your goal is understanding and asking the right questions\n\n## Available Tools\n\n- File reading and exploration\n- Code search and analysis\n- Repository structure analysis\n- Documentation review\n- `create_plan` tool for creating your research artifact\n\n## Research Process\n\nWhen given a task, follow this systematic approach:\n\n1. **Codebase Analysis**\n - Explore the repository structure\n - Identify relevant files and components\n - Understand existing patterns and conventions\n - Review related code and dependencies\n - Look for similar implementations or patterns\n\n2. **Decision Point Identification**\n - Identify areas where implementation decisions need to be made\n - Find multiple viable approaches in the codebase\n - Note where user preferences would affect the implementation\n - Consider architectural or design pattern choices\n\n3. **Question Generation**\n - Generate 3-5 clarifying questions\n - Each question should offer 2-3 concrete options based on codebase analysis\n - Options should reference actual patterns/approaches found in the code\n - Always include option c) as \"Something else (please specify)\" for flexibility\n - Focus on high-impact decisions that affect the implementation approach\n\n## Output Format\n\nAfter completing your research, you MUST use the `create_plan` tool to create a research.md artifact with your questions.\n\nThe artifact MUST follow this EXACT markdown format (this is critical for parsing):\n\n```markdown\n# Research Questions\n\nBased on my analysis of the codebase, here are the key questions to guide implementation:\n\n## Question 1: [Question text - be specific and clear]\n\n**Options:**\n- a) [Concrete option based on existing pattern - reference specific files/components]\n- b) [Alternative approach based on another pattern - reference specific files/components] \n- c) Something else (please specify)\n\n## Question 2: [Next question - be specific and clear]\n\n**Options:**\n- a) [Option with specific code references]\n- b) [Alternative with specific code references]\n- c) Something else (please specify)\n\n## Question 3: [Continue with 3-5 questions total]\n\n**Options:**\n- a) [Option]\n- b) [Alternative]\n- c) Something else (please specify)\n```\n\n## CRITICAL FORMAT REQUIREMENTS\n\n- Use EXACTLY \"## Question N:\" format for question headers (h2 level, not h3)\n- Each question MUST be followed by \"**Options:**\" on its own line\n- Each option MUST start with \"- a)\", \"- b)\", \"- c)\", etc.\n- Always include \"c) Something else (please specify)\" as the last option\n- Do NOT add extra sections between questions\n- Keep context and analysis BEFORE the questions section, not mixed in\n\n## Important Requirements\n\n- Generate 2-5 questions (no more, no less)\n- Make options specific and reference actual code/patterns you find\n- Each question must have at least 2 concrete options plus \"Something else\"\n- Focus on architectural and implementation approach decisions\n- Reference specific files, components, or patterns in your options\n- Make sure the questions help guide a clear implementation path\n\n## Final Step\n\nOnce you have completed your research and identified the questions, use the `create_plan` tool to create the research.md artifact with the markdown content above. Do NOT use any other tools after creating the artifact.\n\nYour research should be thorough enough that the questions help clarify the user's preferences and guide the planning phase effectively.";
2
+ //# sourceMappingURL=research.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../../../src/agents/research.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,+6HAqGsG,CAAC"}
@@ -0,0 +1,105 @@
1
+ const RESEARCH_SYSTEM_PROMPT = `# PostHog AI Coding Agent - Research Mode
2
+
3
+ You are a PostHog AI Coding Agent operating in RESEARCH mode.
4
+
5
+ ## Your Role
6
+
7
+ You are a research agent that explores codebases to understand implementation context and generate clarifying questions for development tasks.
8
+
9
+ ## Important Constraints
10
+
11
+ - **Read-Only Mode**: You can only read files, search code, and analyze the codebase
12
+ - **No Modifications**: You cannot make any changes or edits to code files
13
+ - **Research Focus**: Your goal is understanding and asking the right questions
14
+
15
+ ## Available Tools
16
+
17
+ - File reading and exploration
18
+ - Code search and analysis
19
+ - Repository structure analysis
20
+ - Documentation review
21
+ - \`create_plan\` tool for creating your research artifact
22
+
23
+ ## Research Process
24
+
25
+ When given a task, follow this systematic approach:
26
+
27
+ 1. **Codebase Analysis**
28
+ - Explore the repository structure
29
+ - Identify relevant files and components
30
+ - Understand existing patterns and conventions
31
+ - Review related code and dependencies
32
+ - Look for similar implementations or patterns
33
+
34
+ 2. **Decision Point Identification**
35
+ - Identify areas where implementation decisions need to be made
36
+ - Find multiple viable approaches in the codebase
37
+ - Note where user preferences would affect the implementation
38
+ - Consider architectural or design pattern choices
39
+
40
+ 3. **Question Generation**
41
+ - Generate 3-5 clarifying questions
42
+ - Each question should offer 2-3 concrete options based on codebase analysis
43
+ - Options should reference actual patterns/approaches found in the code
44
+ - Always include option c) as "Something else (please specify)" for flexibility
45
+ - Focus on high-impact decisions that affect the implementation approach
46
+
47
+ ## Output Format
48
+
49
+ After completing your research, you MUST use the \`create_plan\` tool to create a research.md artifact with your questions.
50
+
51
+ The artifact MUST follow this EXACT markdown format (this is critical for parsing):
52
+
53
+ \`\`\`markdown
54
+ # Research Questions
55
+
56
+ Based on my analysis of the codebase, here are the key questions to guide implementation:
57
+
58
+ ## Question 1: [Question text - be specific and clear]
59
+
60
+ **Options:**
61
+ - a) [Concrete option based on existing pattern - reference specific files/components]
62
+ - b) [Alternative approach based on another pattern - reference specific files/components]
63
+ - c) Something else (please specify)
64
+
65
+ ## Question 2: [Next question - be specific and clear]
66
+
67
+ **Options:**
68
+ - a) [Option with specific code references]
69
+ - b) [Alternative with specific code references]
70
+ - c) Something else (please specify)
71
+
72
+ ## Question 3: [Continue with 3-5 questions total]
73
+
74
+ **Options:**
75
+ - a) [Option]
76
+ - b) [Alternative]
77
+ - c) Something else (please specify)
78
+ \`\`\`
79
+
80
+ ## CRITICAL FORMAT REQUIREMENTS
81
+
82
+ - Use EXACTLY "## Question N:" format for question headers (h2 level, not h3)
83
+ - Each question MUST be followed by "**Options:**" on its own line
84
+ - Each option MUST start with "- a)", "- b)", "- c)", etc.
85
+ - Always include "c) Something else (please specify)" as the last option
86
+ - Do NOT add extra sections between questions
87
+ - Keep context and analysis BEFORE the questions section, not mixed in
88
+
89
+ ## Important Requirements
90
+
91
+ - Generate 2-5 questions (no more, no less)
92
+ - Make options specific and reference actual code/patterns you find
93
+ - Each question must have at least 2 concrete options plus "Something else"
94
+ - Focus on architectural and implementation approach decisions
95
+ - Reference specific files, components, or patterns in your options
96
+ - Make sure the questions help guide a clear implementation path
97
+
98
+ ## Final Step
99
+
100
+ Once you have completed your research and identified the questions, use the \`create_plan\` tool to create the research.md artifact with the markdown content above. Do NOT use any other tools after creating the artifact.
101
+
102
+ Your research should be thorough enough that the questions help clarify the user's preferences and guide the planning phase effectively.`;
103
+
104
+ export { RESEARCH_SYSTEM_PROMPT };
105
+ //# sourceMappingURL=research.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"research.js","sources":["../../../src/agents/research.ts"],"sourcesContent":["export const RESEARCH_SYSTEM_PROMPT = `# PostHog AI Coding Agent - Research Mode\n\nYou are a PostHog AI Coding Agent operating in RESEARCH mode.\n\n## Your Role\n\nYou are a research agent that explores codebases to understand implementation context and generate clarifying questions for development tasks.\n\n## Important Constraints\n\n- **Read-Only Mode**: You can only read files, search code, and analyze the codebase\n- **No Modifications**: You cannot make any changes or edits to code files\n- **Research Focus**: Your goal is understanding and asking the right questions\n\n## Available Tools\n\n- File reading and exploration\n- Code search and analysis\n- Repository structure analysis\n- Documentation review\n- \\`create_plan\\` tool for creating your research artifact\n\n## Research Process\n\nWhen given a task, follow this systematic approach:\n\n1. **Codebase Analysis**\n - Explore the repository structure\n - Identify relevant files and components\n - Understand existing patterns and conventions\n - Review related code and dependencies\n - Look for similar implementations or patterns\n\n2. **Decision Point Identification**\n - Identify areas where implementation decisions need to be made\n - Find multiple viable approaches in the codebase\n - Note where user preferences would affect the implementation\n - Consider architectural or design pattern choices\n\n3. **Question Generation**\n - Generate 3-5 clarifying questions\n - Each question should offer 2-3 concrete options based on codebase analysis\n - Options should reference actual patterns/approaches found in the code\n - Always include option c) as \"Something else (please specify)\" for flexibility\n - Focus on high-impact decisions that affect the implementation approach\n\n## Output Format\n\nAfter completing your research, you MUST use the \\`create_plan\\` tool to create a research.md artifact with your questions.\n\nThe artifact MUST follow this EXACT markdown format (this is critical for parsing):\n\n\\`\\`\\`markdown\n# Research Questions\n\nBased on my analysis of the codebase, here are the key questions to guide implementation:\n\n## Question 1: [Question text - be specific and clear]\n\n**Options:**\n- a) [Concrete option based on existing pattern - reference specific files/components]\n- b) [Alternative approach based on another pattern - reference specific files/components] \n- c) Something else (please specify)\n\n## Question 2: [Next question - be specific and clear]\n\n**Options:**\n- a) [Option with specific code references]\n- b) [Alternative with specific code references]\n- c) Something else (please specify)\n\n## Question 3: [Continue with 3-5 questions total]\n\n**Options:**\n- a) [Option]\n- b) [Alternative]\n- c) Something else (please specify)\n\\`\\`\\`\n\n## CRITICAL FORMAT REQUIREMENTS\n\n- Use EXACTLY \"## Question N:\" format for question headers (h2 level, not h3)\n- Each question MUST be followed by \"**Options:**\" on its own line\n- Each option MUST start with \"- a)\", \"- b)\", \"- c)\", etc.\n- Always include \"c) Something else (please specify)\" as the last option\n- Do NOT add extra sections between questions\n- Keep context and analysis BEFORE the questions section, not mixed in\n\n## Important Requirements\n\n- Generate 2-5 questions (no more, no less)\n- Make options specific and reference actual code/patterns you find\n- Each question must have at least 2 concrete options plus \"Something else\"\n- Focus on architectural and implementation approach decisions\n- Reference specific files, components, or patterns in your options\n- Make sure the questions help guide a clear implementation path\n\n## Final Step\n\nOnce you have completed your research and identified the questions, use the \\`create_plan\\` tool to create the research.md artifact with the markdown content above. Do NOT use any other tools after creating the artifact.\n\nYour research should be thorough enough that the questions help clarify the user's preferences and guide the planning phase effectively.`;\n\n"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,6 +5,21 @@ export interface TaskFile {
5
5
  content: string;
6
6
  type: 'plan' | 'context' | 'reference' | 'output' | 'artifact';
7
7
  }
8
+ export interface QuestionData {
9
+ id: string;
10
+ question: string;
11
+ options: string[];
12
+ }
13
+ export interface AnswerData {
14
+ questionId: string;
15
+ selectedOption: string;
16
+ customInput?: string;
17
+ }
18
+ export interface QuestionsFile {
19
+ questions: QuestionData[];
20
+ answered: boolean;
21
+ answers: AnswerData[] | null;
22
+ }
8
23
  export declare class PostHogFileManager {
9
24
  private repositoryPath;
10
25
  private logger;
@@ -24,6 +39,10 @@ export declare class PostHogFileManager {
24
39
  readContext(taskId: string): Promise<string | null>;
25
40
  writeRequirements(taskId: string, requirements: string): Promise<void>;
26
41
  readRequirements(taskId: string): Promise<string | null>;
42
+ writeResearch(taskId: string, content: string): Promise<void>;
43
+ readResearch(taskId: string): Promise<string | null>;
44
+ writeQuestions(taskId: string, data: QuestionsFile): Promise<void>;
45
+ readQuestions(taskId: string): Promise<QuestionsFile | null>;
27
46
  getTaskFiles(taskId: string): Promise<SupportingFile[]>;
28
47
  ensureGitignore(): Promise<void>;
29
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file-manager.d.ts","sourceRoot":"","sources":["../../src/file-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;CAChE;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAS;gBAEX,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAKnD,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IAIjB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASlD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5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AAG,OAAO,CAAC,OAAO,CAAC;IAUrD,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBtD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIhD,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAInD,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIpD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBlE,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAU5D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA0BvD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAuBvC"}
@@ -129,6 +129,45 @@ class PostHogFileManager {
129
129
  async readRequirements(taskId) {
130
130
  return await this.readTaskFile(taskId, 'requirements.md');
131
131
  }
132
+ async writeResearch(taskId, content) {
133
+ this.logger.debug('Writing research', {
134
+ taskId,
135
+ contentLength: content.length,
136
+ contentPreview: content.substring(0, 200)
137
+ });
138
+ await this.writeTaskFile(taskId, {
139
+ name: 'research.md',
140
+ content: content,
141
+ type: 'artifact'
142
+ });
143
+ this.logger.info('Research file written', { taskId });
144
+ }
145
+ async readResearch(taskId) {
146
+ return await this.readTaskFile(taskId, 'research.md');
147
+ }
148
+ async writeQuestions(taskId, data) {
149
+ this.logger.debug('Writing questions', {
150
+ taskId,
151
+ questionCount: data.questions.length,
152
+ answered: data.answered,
153
+ });
154
+ await this.writeTaskFile(taskId, {
155
+ name: 'questions.json',
156
+ content: JSON.stringify(data, null, 2),
157
+ type: 'artifact'
158
+ });
159
+ this.logger.info('Questions file written', { taskId });
160
+ }
161
+ async readQuestions(taskId) {
162
+ try {
163
+ const content = await this.readTaskFile(taskId, 'questions.json');
164
+ return content ? JSON.parse(content) : null;
165
+ }
166
+ catch (error) {
167
+ this.logger.debug('Failed to parse questions.json', { error });
168
+ return null;
169
+ }
170
+ }
132
171
  async getTaskFiles(taskId) {
133
172
  const fileNames = await this.listTaskFiles(taskId);
134
173
  const files = [];
@@ -1 +1 @@
1
- {"version":3,"file":"file-manager.js","sources":["../../src/file-manager.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { join, dirname } from 'path';\nimport type { SupportingFile } from './types.js';\nimport { Logger } from './utils/logger.js';\n\nexport interface TaskFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output' | 'artifact';\n}\n\nexport class PostHogFileManager {\n private repositoryPath: string;\n private logger: Logger;\n\n constructor(repositoryPath: string, logger?: Logger) {\n this.repositoryPath = repositoryPath;\n this.logger = logger || new Logger({ debug: false, prefix: '[FileManager]' });\n }\n\n private getTaskDirectory(taskId: string): string {\n return join(this.repositoryPath, '.posthog', taskId);\n }\n\n private getTaskFilePath(taskId: string, fileName: string): string {\n return join(this.getTaskDirectory(taskId), fileName);\n }\n\n async ensureTaskDirectory(taskId: string): Promise<void> {\n const taskDir = this.getTaskDirectory(taskId);\n try {\n await fs.access(taskDir);\n } catch {\n await fs.mkdir(taskDir, { recursive: true });\n }\n }\n\n async writeTaskFile(taskId: string, file: TaskFile): Promise<void> {\n await this.ensureTaskDirectory(taskId);\n const filePath = this.getTaskFilePath(taskId, file.name);\n\n this.logger.debug('Writing task file', {\n filePath,\n contentLength: file.content.length,\n contentType: typeof file.content\n });\n\n await fs.writeFile(filePath, file.content, 'utf8');\n\n this.logger.debug('File written successfully', { filePath });\n }\n\n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n try {\n const filePath = this.getTaskFilePath(taskId, fileName);\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n }\n\n async listTaskFiles(taskId: string): Promise<string[]> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n const files = await fs.readdir(taskDir);\n return files.filter(file => !file.startsWith('.'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n }\n\n async deleteTaskFile(taskId: string, fileName: string): Promise<void> {\n try {\n const filePath = this.getTaskFilePath(taskId, fileName);\n await fs.unlink(filePath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n async taskDirectoryExists(taskId: string): Promise<boolean> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n await fs.access(taskDir);\n return true;\n } catch {\n return false;\n }\n }\n\n async cleanupTaskDirectory(taskId: string): Promise<void> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n await fs.rm(taskDir, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n // Convenience methods for common file types\n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.debug('Writing plan', {\n taskId,\n planLength: plan.length,\n contentPreview: plan.substring(0, 200)\n });\n\n await this.writeTaskFile(taskId, {\n name: 'plan.md',\n content: plan,\n type: 'plan'\n });\n\n this.logger.info('Plan file written', { taskId });\n }\n\n async readPlan(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'plan.md');\n }\n\n async writeContext(taskId: string, context: string): Promise<void> {\n await this.writeTaskFile(taskId, {\n name: 'context.md',\n content: context,\n type: 'context'\n });\n }\n\n async readContext(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'context.md');\n }\n\n async writeRequirements(taskId: string, requirements: string): Promise<void> {\n await this.writeTaskFile(taskId, {\n name: 'requirements.md',\n content: requirements,\n type: 'reference'\n });\n }\n\n async readRequirements(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'requirements.md');\n }\n\n async getTaskFiles(taskId: string): Promise<SupportingFile[]> {\n const fileNames = await this.listTaskFiles(taskId);\n const files: SupportingFile[] = [];\n \n for (const fileName of fileNames) {\n const content = await this.readTaskFile(taskId, fileName);\n if (content !== null) {\n // Determine type based on file name\n let type: SupportingFile['type'] = 'reference';\n if (fileName === 'plan.md') type = 'plan';\n else if (fileName === 'context.md') type = 'context';\n else if (fileName === 'requirements.md') type = 'reference';\n else if (fileName.startsWith('output_')) type = 'output';\n \n files.push({\n name: fileName,\n content,\n type,\n created_at: new Date().toISOString() // Could be enhanced with file stats\n });\n }\n }\n \n return files;\n }\n\n async ensureGitignore(): Promise<void> {\n const gitignorePath = join(this.repositoryPath, '.posthog', '.gitignore');\n const gitignoreContent = `# PostHog task artifacts - customize as needed\n# Exclude temporary files\n*/temp/\n*/cache/\n*/.env\n*/.secrets\n\n# Include plans and documentation by default\n!*/plan.md\n!*/context.md\n!*/requirements.md\n!*/README.md\n`;\n\n try {\n await fs.access(gitignorePath);\n } catch {\n await fs.mkdir(dirname(gitignorePath), { recursive: true });\n await fs.writeFile(gitignorePath, gitignoreContent, 'utf8');\n }\n }\n}\n"],"names":["fs"],"mappings":";;;;MAWa,kBAAkB,CAAA;AACrB,IAAA,cAAc;AACd,IAA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;oBAAE,IAAI,GAAG,QAAQ;gBAExD,KAAK,CAAC,IAAI,CAAC;AACT,oBAAA,IAAI,EAAE,QAAQ;oBACd,OAAO;oBACP,IAAI;oBACJ,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AACrC,iBAAA,CAAC;YACJ;QACF;AAEA,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,MAAM,eAAe,GAAA;AACnB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,YAAY,CAAC;AACzE,QAAA,MAAM,gBAAgB,GAAG,CAAA;;;;;;;;;;;;CAY5B;AAEG,QAAA,IAAI;AACF,YAAA,MAAMA,QAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAChC;AAAE,QAAA,MAAM;AACN,YAAA,MAAMA,QAAE,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YAC3D,MAAMA,QAAE,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,CAAC;QAC7D;IACF;AACD;;;;"}
1
+ {"version":3,"file":"file-manager.js","sources":["../../src/file-manager.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport { join, dirname } from 'path';\nimport type { SupportingFile } from './types.js';\nimport { Logger } from './utils/logger.js';\n\nexport interface TaskFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output' | 'artifact';\n}\n\nexport interface QuestionData {\n id: string;\n question: string;\n options: string[];\n}\n\nexport interface AnswerData {\n questionId: string;\n selectedOption: string;\n customInput?: string;\n}\n\nexport interface QuestionsFile {\n questions: QuestionData[];\n answered: boolean;\n answers: AnswerData[] | null;\n}\n\nexport class PostHogFileManager {\n private repositoryPath: string;\n private logger: Logger;\n\n constructor(repositoryPath: string, logger?: Logger) {\n this.repositoryPath = repositoryPath;\n this.logger = logger || new Logger({ debug: false, prefix: '[FileManager]' });\n }\n\n private getTaskDirectory(taskId: string): string {\n return join(this.repositoryPath, '.posthog', taskId);\n }\n\n private getTaskFilePath(taskId: string, fileName: string): string {\n return join(this.getTaskDirectory(taskId), fileName);\n }\n\n async ensureTaskDirectory(taskId: string): Promise<void> {\n const taskDir = this.getTaskDirectory(taskId);\n try {\n await fs.access(taskDir);\n } catch {\n await fs.mkdir(taskDir, { recursive: true });\n }\n }\n\n async writeTaskFile(taskId: string, file: TaskFile): Promise<void> {\n await this.ensureTaskDirectory(taskId);\n const filePath = this.getTaskFilePath(taskId, file.name);\n\n this.logger.debug('Writing task file', {\n filePath,\n contentLength: file.content.length,\n contentType: typeof file.content\n });\n\n await fs.writeFile(filePath, file.content, 'utf8');\n\n this.logger.debug('File written successfully', { filePath });\n }\n\n async readTaskFile(taskId: string, fileName: string): Promise<string | null> {\n try {\n const filePath = this.getTaskFilePath(taskId, fileName);\n return await fs.readFile(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return null;\n }\n throw error;\n }\n }\n\n async listTaskFiles(taskId: string): Promise<string[]> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n const files = await fs.readdir(taskDir);\n return files.filter(file => !file.startsWith('.'));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n }\n\n async deleteTaskFile(taskId: string, fileName: string): Promise<void> {\n try {\n const filePath = this.getTaskFilePath(taskId, fileName);\n await fs.unlink(filePath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n async taskDirectoryExists(taskId: string): Promise<boolean> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n await fs.access(taskDir);\n return true;\n } catch {\n return false;\n }\n }\n\n async cleanupTaskDirectory(taskId: string): Promise<void> {\n try {\n const taskDir = this.getTaskDirectory(taskId);\n await fs.rm(taskDir, { recursive: true, force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n // Convenience methods for common file types\n async writePlan(taskId: string, plan: string): Promise<void> {\n this.logger.debug('Writing plan', {\n taskId,\n planLength: plan.length,\n contentPreview: plan.substring(0, 200)\n });\n\n await this.writeTaskFile(taskId, {\n name: 'plan.md',\n content: plan,\n type: 'plan'\n });\n\n this.logger.info('Plan file written', { taskId });\n }\n\n async readPlan(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'plan.md');\n }\n\n async writeContext(taskId: string, context: string): Promise<void> {\n await this.writeTaskFile(taskId, {\n name: 'context.md',\n content: context,\n type: 'context'\n });\n }\n\n async readContext(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'context.md');\n }\n\n async writeRequirements(taskId: string, requirements: string): Promise<void> {\n await this.writeTaskFile(taskId, {\n name: 'requirements.md',\n content: requirements,\n type: 'reference'\n });\n }\n\n async readRequirements(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'requirements.md');\n }\n\n async writeResearch(taskId: string, content: string): Promise<void> {\n this.logger.debug('Writing research', {\n taskId,\n contentLength: content.length,\n contentPreview: content.substring(0, 200)\n });\n\n await this.writeTaskFile(taskId, {\n name: 'research.md',\n content: content,\n type: 'artifact'\n });\n\n this.logger.info('Research file written', { taskId });\n }\n\n async readResearch(taskId: string): Promise<string | null> {\n return await this.readTaskFile(taskId, 'research.md');\n }\n\n async writeQuestions(taskId: string, data: QuestionsFile): Promise<void> {\n this.logger.debug('Writing questions', {\n taskId,\n questionCount: data.questions.length,\n answered: data.answered,\n });\n\n await this.writeTaskFile(taskId, {\n name: 'questions.json',\n content: JSON.stringify(data, null, 2),\n type: 'artifact'\n });\n\n this.logger.info('Questions file written', { taskId });\n }\n\n async readQuestions(taskId: string): Promise<QuestionsFile | null> {\n try {\n const content = await this.readTaskFile(taskId, 'questions.json');\n return content ? JSON.parse(content) as QuestionsFile : null;\n } catch (error) {\n this.logger.debug('Failed to parse questions.json', { error });\n return null;\n }\n }\n\n async getTaskFiles(taskId: string): Promise<SupportingFile[]> {\n const fileNames = await this.listTaskFiles(taskId);\n const files: SupportingFile[] = [];\n \n for (const fileName of fileNames) {\n const content = await this.readTaskFile(taskId, fileName);\n if (content !== null) {\n // Determine type based on file name\n let type: SupportingFile['type'] = 'reference';\n if (fileName === 'plan.md') type = 'plan';\n else if (fileName === 'context.md') type = 'context';\n else if (fileName === 'requirements.md') type = 'reference';\n else if (fileName.startsWith('output_')) type = 'output';\n \n files.push({\n name: fileName,\n content,\n type,\n created_at: new Date().toISOString() // Could be enhanced with file stats\n });\n }\n }\n \n return files;\n }\n\n async ensureGitignore(): Promise<void> {\n const gitignorePath = join(this.repositoryPath, '.posthog', '.gitignore');\n const gitignoreContent = `# PostHog task artifacts - customize as needed\n# Exclude temporary files\n*/temp/\n*/cache/\n*/.env\n*/.secrets\n\n# Include plans and documentation by default\n!*/plan.md\n!*/context.md\n!*/requirements.md\n!*/README.md\n`;\n\n try {\n await fs.access(gitignorePath);\n } catch {\n await fs.mkdir(dirname(gitignorePath), { recursive: true });\n await fs.writeFile(gitignorePath, gitignoreContent, 'utf8');\n }\n }\n}\n"],"names":["fs"],"mappings":";;;;MA6Ba,kBAAkB,CAAA;AACrB,IAAA,cAAc;AACd,IAAA,MAAM;IAEd,WAAA,CAAY,cAAsB,EAAE,MAAe,EAAA;AACjD,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc;AACpC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAC/E;AAEQ,IAAA,gBAAgB,CAAC,MAAc,EAAA;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC;IACtD;IAEQ,eAAe,CAAC,MAAc,EAAE,QAAgB,EAAA;QACtD,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM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ACJ;QACF;AAEA,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,MAAM,eAAe,GAAA;AACnB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,EAAE,YAAY,CAAC;AACzE,QAAA,MAAM,gBAAgB,GAAG,CAAA;;;;;;;;;;;;CAY5B;AAEG,QAAA,IAAI;AACF,YAAA,MAAMA,QAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAChC;AAAE,QAAA,MAAM;AACN,YAAA,MAAMA,QAAE,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;YAC3D,MAAMA,QAAE,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,EAAE,MAAM,CAAC;QAC7D;IACF;AACD;;;;"}
@@ -45,5 +45,9 @@ export declare class GitManager {
45
45
  getCommitSha(ref?: string): Promise<string>;
46
46
  getCommitMessage(ref?: string): Promise<string>;
47
47
  createPullRequest(branchName: string, title: string, body: string, baseBranch?: string): Promise<string>;
48
+ getTaskBranch(taskSlug: string): Promise<string | null>;
49
+ commitAndPush(message: string, options?: {
50
+ allowEmpty?: boolean;
51
+ }): Promise<void>;
48
52
  }
49
53
  //# sourceMappingURL=git-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-manager.d.ts","sourceRoot":"","sources":["../../src/git-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,MAAM,WAAW,SAAS;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;CAC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