@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.
- package/README.md +26 -65
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/src/adapters/types.d.ts +1 -1
- package/dist/src/agent.d.ts +5 -13
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +300 -187
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.d.ts +1 -1
- package/dist/src/agents/execution.js +2 -2
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/research.d.ts +2 -0
- package/dist/src/agents/research.d.ts.map +1 -0
- package/dist/src/agents/research.js +105 -0
- package/dist/src/agents/research.js.map +1 -0
- package/dist/src/file-manager.d.ts +19 -0
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +39 -0
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +4 -0
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +42 -1
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +0 -8
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +0 -32
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +1 -0
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +40 -0
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/structured-extraction.d.ts +22 -0
- package/dist/src/structured-extraction.d.ts.map +1 -0
- package/dist/src/structured-extraction.js +136 -0
- package/dist/src/structured-extraction.js.map +1 -0
- package/dist/src/task-progress-reporter.d.ts +0 -6
- package/dist/src/task-progress-reporter.d.ts.map +1 -1
- package/dist/src/task-progress-reporter.js +2 -26
- package/dist/src/task-progress-reporter.js.map +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +26 -4
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/types.d.ts +7 -4
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +0 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +5 -5
- package/src/adapters/types.ts +1 -1
- package/src/agent.ts +326 -195
- package/src/agents/execution.ts +2 -2
- package/src/agents/research.ts +103 -0
- package/src/file-manager.ts +64 -0
- package/src/git-manager.ts +53 -1
- package/src/posthog-api.ts +0 -40
- package/src/prompt-builder.ts +53 -0
- package/src/structured-extraction.ts +167 -0
- package/src/task-progress-reporter.ts +2 -34
- package/src/template-manager.ts +35 -5
- package/src/types.ts +8 -7
- package/dist/src/agent-registry.d.ts +0 -16
- package/dist/src/agent-registry.d.ts.map +0 -1
- package/dist/src/agent-registry.js +0 -56
- package/dist/src/agent-registry.js.map +0 -1
- package/dist/src/stage-executor.d.ts +0 -19
- package/dist/src/stage-executor.d.ts.map +0 -1
- package/dist/src/stage-executor.js +0 -135
- package/dist/src/stage-executor.js.map +0 -1
- package/dist/src/workflow-registry.d.ts +0 -11
- package/dist/src/workflow-registry.d.ts.map +0 -1
- package/dist/src/workflow-registry.js +0 -27
- package/dist/src/workflow-registry.js.map +0 -1
- package/dist/src/workflow-types.d.ts +0 -45
- package/dist/src/workflow-types.d.ts.map +0 -1
- package/src/agent-registry.ts +0 -59
- package/src/stage-executor.ts +0 -160
- package/src/workflow-registry.ts +0 -30
- package/src/workflow-types.ts +0 -52
package/dist/src/git-manager.js
CHANGED
|
@@ -134,7 +134,7 @@ class GitManager {
|
|
|
134
134
|
const forceFlag = force ? '--force' : '';
|
|
135
135
|
await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);
|
|
136
136
|
}
|
|
137
|
-
// Utility methods for PostHog task
|
|
137
|
+
// Utility methods for PostHog task execution
|
|
138
138
|
async createTaskPlanningBranch(taskId, baseBranch) {
|
|
139
139
|
let branchName = `posthog/task-${taskId}-planning`;
|
|
140
140
|
let counter = 1;
|
|
@@ -275,6 +275,47 @@ Generated by PostHog Agent`;
|
|
|
275
275
|
throw new Error(`Failed to create PR: ${error}`);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
+
async getTaskBranch(taskSlug) {
|
|
279
|
+
try {
|
|
280
|
+
// Get all branches matching the task slug pattern
|
|
281
|
+
const branches = await this.runGitCommand('branch --list --all');
|
|
282
|
+
const branchPattern = `posthog/task-${taskSlug}`;
|
|
283
|
+
// Look for exact match or with counter suffix
|
|
284
|
+
const lines = branches.split('\n').map(l => l.trim().replace(/^\*\s+/, ''));
|
|
285
|
+
for (const line of lines) {
|
|
286
|
+
const cleanBranch = line.replace('remotes/origin/', '');
|
|
287
|
+
if (cleanBranch.startsWith(branchPattern)) {
|
|
288
|
+
return cleanBranch;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
this.logger.debug('Failed to get task branch', { taskSlug, error });
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async commitAndPush(message, options) {
|
|
299
|
+
const hasChanges = await this.hasStagedChanges();
|
|
300
|
+
if (!hasChanges && !options?.allowEmpty) {
|
|
301
|
+
this.logger.debug('No changes to commit, skipping');
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
let command = `commit -m "${message.replace(/"/g, '\\"')}"`;
|
|
305
|
+
if (options?.allowEmpty) {
|
|
306
|
+
command += ' --allow-empty';
|
|
307
|
+
}
|
|
308
|
+
const authorName = this.authorName;
|
|
309
|
+
const authorEmail = this.authorEmail;
|
|
310
|
+
if (authorName && authorEmail) {
|
|
311
|
+
command += ` --author="${authorName} <${authorEmail}>"`;
|
|
312
|
+
}
|
|
313
|
+
await this.runGitCommand(command);
|
|
314
|
+
// Push to origin
|
|
315
|
+
const currentBranch = await this.getCurrentBranch();
|
|
316
|
+
await this.pushBranch(currentBranch);
|
|
317
|
+
this.logger.info('Committed and pushed changes', { branch: currentBranch, message });
|
|
318
|
+
}
|
|
278
319
|
}
|
|
279
320
|
|
|
280
321
|
export { GitManager };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${p}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n await this.runGitCommand('add .posthog/');\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n let command = 'commit -m \"' + message.replace(/\"/g, '\\\\\"') + '\"';\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n // Utility methods for PostHog task workflow\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-planning`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-planning-${counter}`;\n counter++;\n }\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n // If no base branch specified, ensure we're on main/master\n if (!baseBranch) {\n baseBranch = await this.getDefaultBranch();\n await this.switchToBranch(baseBranch);\n\n // Check for uncommitted changes\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before running tasks.`);\n }\n }\n\n await this.createBranch(branchName, baseBranch); // Use createBranch instead of createOrSwitchToBranch for new branches\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-implementation`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-implementation-${counter}`;\n counter++;\n }\n\n const currentBranchBefore = await this.getCurrentBranch();\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: currentBranchBefore\n });\n\n // Implementation branch should branch from the specific planning branch\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n // Try to find the corresponding planning branch\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch; // Use current planning branch\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n // Fallback to default branch\n baseBranch = await this.getDefaultBranch();\n this.logger.debug('No planning branch found, using default', { baseBranch });\n await this.switchToBranch(baseBranch);\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch); // Create fresh branch from base\n\n const currentBranchAfter = await this.getCurrentBranch();\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: currentBranchAfter\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body \"${body.replace(/\"/g, '\\\\\"')}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF;IAEQ,MAAM,aAAa,CAAC,OAAe,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,CAAA,IAAA,EAAO,IAAI,CAAC,cAAc,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAC;AACnF,YAAA,OAAO,MAAM,CAAC,IAAI,EAAE;QACtB;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC7D;IACF;IAEQ,MAAM,UAAU,C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AC,IAAI,EAAE,KAAK,CAAC,CAAA,UAAA,EAAa,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA,CAAA,CAAG;QAE1G,IAAI,UAAU,EAAE;AACd,YAAA,OAAO,IAAI,CAAA,QAAA,EAAW,UAAU,CAAA,CAAE;QACpC;AAEA,QAAA,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AAC5C,YAAA,OAAO,KAAK,CAAC,IAAI,EAAE;QACrB;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAA,CAAE,CAAC;QAClD;IACF;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${p}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n await this.runGitCommand('add .posthog/');\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n let command = 'commit -m \"' + message.replace(/\"/g, '\\\\\"') + '\"';\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n // Utility methods for PostHog task execution\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-planning`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-planning-${counter}`;\n counter++;\n }\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n // If no base branch specified, ensure we're on main/master\n if (!baseBranch) {\n baseBranch = await this.getDefaultBranch();\n await this.switchToBranch(baseBranch);\n\n // Check for uncommitted changes\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before running tasks.`);\n }\n }\n\n await this.createBranch(branchName, baseBranch); // Use createBranch instead of createOrSwitchToBranch for new branches\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-implementation`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-implementation-${counter}`;\n counter++;\n }\n\n const currentBranchBefore = await this.getCurrentBranch();\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: currentBranchBefore\n });\n\n // Implementation branch should branch from the specific planning branch\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n // Try to find the corresponding planning branch\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch; // Use current planning branch\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n // Fallback to default branch\n baseBranch = await this.getDefaultBranch();\n this.logger.debug('No planning branch found, using default', { baseBranch });\n await this.switchToBranch(baseBranch);\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch); // Create fresh branch from base\n\n const currentBranchAfter = await this.getCurrentBranch();\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: currentBranchAfter\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body \"${body.replace(/\"/g, '\\\\\"')}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n\n async getTaskBranch(taskSlug: string): Promise<string | null> {\n try {\n // Get all branches matching the task slug pattern\n const branches = await this.runGitCommand('branch --list --all');\n const branchPattern = `posthog/task-${taskSlug}`;\n \n // Look for exact match or with counter suffix\n const lines = branches.split('\\n').map(l => l.trim().replace(/^\\*\\s+/, ''));\n for (const line of lines) {\n const cleanBranch = line.replace('remotes/origin/', '');\n if (cleanBranch.startsWith(branchPattern)) {\n return cleanBranch;\n }\n }\n \n return null;\n } catch (error) {\n this.logger.debug('Failed to get task branch', { taskSlug, error });\n return null;\n }\n }\n\n async commitAndPush(message: string, options?: { allowEmpty?: boolean }): Promise<void> {\n const hasChanges = await this.hasStagedChanges();\n \n if (!hasChanges && !options?.allowEmpty) {\n this.logger.debug('No changes to commit, skipping');\n return;\n }\n\n let command = `commit -m \"${message.replace(/\"/g, '\\\\\"')}\"`;\n \n if (options?.allowEmpty) {\n command += ' --allow-empty';\n }\n\n const authorName = this.authorName;\n const authorEmail = this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n await this.runGitCommand(command);\n \n // Push to origin\n const currentBranch = await this.getCurrentBranch();\n await this.pushBranch(currentBranch);\n \n this.logger.info('Committed and pushed changes', { branch: currentBranch, message });\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF;IAEQ,MAAM,aAAa,CAAC,OAAe,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,CAAA,IAAA,EAAO,IAAI,CAAC,cAAc,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAC;AACnF,YAAA,OAAO,MAAM,CAAC,IAAI,EAAE;QACtB;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC7D;IACF;IAEQ,MAAM,UAAU,CAAC,OAAe,EAAA;AACtC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,S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AAE;QAEhD,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;AACvC,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC;YACnD;QACF;AAEA,QAAA,IAAI,OAAO,GAAG,CAAA,WAAA,EAAc,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA,CAAA,CAAG;AAE3D,QAAA,IAAI,OAAO,EAAE,UAAU,EAAE;YACvB,OAAO,IAAI,gBAAgB;QAC7B;AAEA,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU;AAClC,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW;AAEpC,QAAA,IAAI,UAAU,IAAI,WAAW,EAAE;AAC7B,YAAA,OAAO,IAAI,CAAA,WAAA,EAAc,UAAU,CAAA,EAAA,EAAK,WAAW,IAAI;QACzD;AAEA,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;;AAGjC,QAAA,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;AACnD,QAAA,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;AAEpC,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;IACtF;AACD;;;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Task, TaskRun, LogEntry, PostHogAPIConfig, PostHogResource, UrlMention } from './types.js';
|
|
2
|
-
import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
|
|
3
2
|
export interface TaskRunUpdate {
|
|
4
3
|
status?: TaskRun["status"];
|
|
5
4
|
branch?: string | null;
|
|
@@ -25,21 +24,14 @@ export declare class PostHogAPIClient {
|
|
|
25
24
|
repository?: string;
|
|
26
25
|
organization?: string;
|
|
27
26
|
origin_product?: string;
|
|
28
|
-
workflow?: string;
|
|
29
|
-
current_stage?: string;
|
|
30
27
|
}): Promise<Task[]>;
|
|
31
28
|
updateTask(taskId: string, updates: Partial<Task>): Promise<Task>;
|
|
32
29
|
listTaskRuns(taskId: string): Promise<TaskRun[]>;
|
|
33
30
|
getTaskRun(taskId: string, runId: string): Promise<TaskRun>;
|
|
34
31
|
createTaskRun(taskId: string, payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>): Promise<TaskRun>;
|
|
35
32
|
updateTaskRun(taskId: string, runId: string, payload: TaskRunUpdate): Promise<TaskRun>;
|
|
36
|
-
updateTaskRunStage(taskId: string, runId: string, stageId: string): Promise<TaskRun>;
|
|
37
|
-
progressTaskRun(taskId: string, runId: string, nextStageId?: string): Promise<TaskRun>;
|
|
38
33
|
setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun>;
|
|
39
34
|
appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun>;
|
|
40
|
-
fetchWorkflow(workflowId: string): Promise<WorkflowDefinition>;
|
|
41
|
-
listWorkflows(): Promise<WorkflowDefinition[]>;
|
|
42
|
-
listAgents(): Promise<AgentDefinition[]>;
|
|
43
35
|
/**
|
|
44
36
|
* Fetch error details from PostHog error tracking
|
|
45
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAkB,gBAAgB,EAAE,eAAe,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAkB,gBAAgB,EAAE,eAAe,EAAgB,UAAU,EAAE,MAAM,YAAY,CAAC;A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AK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK3D,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC,GACtG,OAAO,CAAC,OAAO,CAAC;IAQb,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,OAAO,CAAC;IAQb,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5F;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BtF;;OAEG;IACG,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC;IAmC1E;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAkC3B"}
|
package/dist/src/posthog-api.js
CHANGED
|
@@ -108,24 +108,6 @@ class PostHogAPIClient {
|
|
|
108
108
|
body: JSON.stringify(payload),
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async updateTaskRunStage(taskId, runId, stageId) {
|
|
112
|
-
const teamId = await this.getTeamId();
|
|
113
|
-
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/update_stage/`, {
|
|
114
|
-
method: 'PATCH',
|
|
115
|
-
body: JSON.stringify({ current_stage: stageId }),
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
async progressTaskRun(taskId, runId, nextStageId) {
|
|
119
|
-
const teamId = await this.getTeamId();
|
|
120
|
-
const payload = {};
|
|
121
|
-
if (nextStageId) {
|
|
122
|
-
payload.next_stage_id = nextStageId;
|
|
123
|
-
}
|
|
124
|
-
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/progress_run/`, {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
body: JSON.stringify(payload),
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
111
|
async setTaskRunOutput(taskId, runId, output) {
|
|
130
112
|
const teamId = await this.getTeamId();
|
|
131
113
|
return this.apiRequest(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {
|
|
@@ -140,20 +122,6 @@ class PostHogAPIClient {
|
|
|
140
122
|
body: JSON.stringify({ entries }),
|
|
141
123
|
});
|
|
142
124
|
}
|
|
143
|
-
// Workflow endpoints
|
|
144
|
-
async fetchWorkflow(workflowId) {
|
|
145
|
-
const teamId = await this.getTeamId();
|
|
146
|
-
return this.apiRequest(`/api/projects/${teamId}/workflows/${workflowId}/`);
|
|
147
|
-
}
|
|
148
|
-
async listWorkflows() {
|
|
149
|
-
const teamId = await this.getTeamId();
|
|
150
|
-
const response = await this.apiRequest(`/api/projects/${teamId}/workflows/`);
|
|
151
|
-
return response.results || [];
|
|
152
|
-
}
|
|
153
|
-
// Agent catalog exposure
|
|
154
|
-
async listAgents() {
|
|
155
|
-
return this.apiRequest(`/api/agents/`);
|
|
156
|
-
}
|
|
157
125
|
/**
|
|
158
126
|
* Fetch error details from PostHog error tracking
|
|
159
127
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type { Task, TaskRun, LogEntry, SupportingFile, PostHogAPIConfig, PostHogResource, ResourceType, UrlMention } from './types.js';\nimport type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';\n\ninterface PostHogApiResponse<T> {\n results?: T[];\n count?: number;\n next?: string | null;\n previous?: string | null;\n}\n\nexport interface TaskRunUpdate {\n status?: TaskRun[\"status\"];\n branch?: string | null;\n current_stage?: string | null;\n log?: LogEntry[];\n error_message?: string | null;\n output?: Record<string, unknown> | null;\n state?: Record<string, unknown>;\n}\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n private _teamId: number | null = null;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\") \n ? this.config.apiUrl.slice(0, -1) \n : this.config.apiUrl;\n return host;\n }\n\n private get headers(): Record<string, string> {\n return {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n private async apiRequest<T>(\n endpoint: string, \n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n \n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.headers,\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n async getTeamId(): Promise<number> {\n if (this._teamId !== null) {\n return this._teamId;\n }\n\n // Fetch user info to get team ID (following Array's pattern)\n const userResponse = await this.apiRequest<any>('/api/users/@me/');\n\n if (!userResponse.team?.id) {\n throw new Error('No team found for user');\n }\n\n const teamId = Number(userResponse.team.id);\n this._teamId = teamId;\n return teamId;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.config.apiKey;\n }\n\n async getLlmGatewayUrl(): Promise<string> {\n const teamId = await this.getTeamId();\n return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;\n }\n\n async fetchTask(taskId: string): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\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 const teamId = await this.getTeamId();\n const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);\n \n if (filters) {\n Object.entries(filters).forEach(([key, value]) => {\n if (value) url.searchParams.append(key, value);\n });\n }\n\n const response = await this.apiRequest<PostHogApiResponse<Task>>(\n url.pathname + url.search\n );\n \n return response.results || [];\n }\n\n async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // TaskRun methods\n async listTaskRuns(taskId: string): Promise<TaskRun[]> {\n const teamId = await this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<TaskRun>>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/`\n );\n return response.results || [];\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);\n }\n\n async createTaskRun(\n taskId: string,\n payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {\n method: \"POST\",\n body: JSON.stringify(payload || {}),\n });\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n });\n }\n\n async updateTaskRunStage(taskId: string, runId: string, stageId: string): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/update_stage/`, {\n method: 'PATCH',\n body: JSON.stringify({ current_stage: stageId }),\n });\n }\n\n async progressTaskRun(taskId: string, runId: string, nextStageId?: string): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n const payload: Record<string, string> = {};\n if (nextStageId) {\n payload.next_stage_id = nextStageId;\n }\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/progress_run/`, {\n method: 'POST',\n body: JSON.stringify(payload),\n });\n }\n\n async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {\n method: 'PATCH',\n body: JSON.stringify({ output }),\n });\n }\n\n async appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {\n method: 'POST',\n body: JSON.stringify({ entries }),\n });\n }\n\n // Workflow endpoints\n async fetchWorkflow(workflowId: string): Promise<WorkflowDefinition> {\n const teamId = await this.getTeamId();\n return this.apiRequest<WorkflowDefinition>(`/api/projects/${teamId}/workflows/${workflowId}/`);\n }\n\n async listWorkflows(): Promise<WorkflowDefinition[]> {\n const teamId = await this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<WorkflowDefinition>>(`/api/projects/${teamId}/workflows/`);\n return response.results || [];\n }\n\n // Agent catalog exposure\n async listAgents(): Promise<AgentDefinition[]> {\n return this.apiRequest<AgentDefinition[]>(`/api/agents/`);\n }\n\n /**\n * Fetch error details from PostHog error tracking\n */\n async fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource> {\n const teamId = projectId ? parseInt(projectId) : await this.getTeamId();\n \n try {\n const errorData = await this.apiRequest<any>(`/api/projects/${teamId}/error_tracking/${errorId}/`);\n \n // Format error details for agent consumption\n const content = this.formatErrorContent(errorData);\n \n return {\n type: 'error',\n id: errorId,\n url: `${this.baseUrl}/project/${teamId}/error_tracking/${errorId}`,\n title: errorData.exception_type || 'Unknown Error',\n content,\n metadata: {\n exception_type: errorData.exception_type,\n first_seen: errorData.first_seen,\n last_seen: errorData.last_seen,\n volume: errorData.volume,\n users_affected: errorData.users_affected,\n },\n };\n } catch (error) {\n throw new Error(`Failed to fetch error details for ${errorId}: ${error}`);\n }\n }\n\n /**\n * Generic resource fetcher by URL or ID\n */\n async fetchResourceByUrl(urlMention: UrlMention): Promise<PostHogResource> {\n switch (urlMention.type) {\n case 'error':\n if (!urlMention.id) {\n throw new Error('Error ID is required for error resources');\n }\n // Extract project ID from URL if available, otherwise use default team\n let projectId: string | undefined;\n if (urlMention.url) {\n const projectIdMatch = urlMention.url.match(/\\/project\\/(\\d+)\\//);\n projectId = projectIdMatch ? projectIdMatch[1] : undefined;\n }\n return this.fetchErrorDetails(urlMention.id, projectId);\n \n case 'experiment':\n case 'insight':\n case 'feature_flag':\n throw new Error(`Resource type '${urlMention.type}' not yet implemented`);\n \n case 'generic':\n // Return a minimal resource for generic URLs\n return {\n type: 'generic',\n id: '',\n url: urlMention.url,\n title: 'Generic Resource',\n content: `Generic resource: ${urlMention.url}`,\n metadata: {},\n };\n \n default:\n throw new Error(`Unknown resource type: ${urlMention.type}`);\n }\n }\n\n /**\n * Format error data for agent consumption\n */\n private formatErrorContent(errorData: any): string {\n const sections = [];\n \n if (errorData.exception_type) {\n sections.push(`**Error Type**: ${errorData.exception_type}`);\n }\n \n if (errorData.exception_message) {\n sections.push(`**Message**: ${errorData.exception_message}`);\n }\n \n if (errorData.stack_trace) {\n sections.push(`**Stack Trace**:\\n\\`\\`\\`\\n${errorData.stack_trace}\\n\\`\\`\\``);\n }\n \n if (errorData.volume) {\n sections.push(`**Volume**: ${errorData.volume} occurrences`);\n }\n \n if (errorData.users_affected) {\n sections.push(`**Users Affected**: ${errorData.users_affected}`);\n }\n \n if (errorData.first_seen && errorData.last_seen) {\n sections.push(`**First Seen**: ${errorData.first_seen}`);\n sections.push(`**Last Seen**: ${errorData.last_seen}`);\n }\n \n if (errorData.properties && Object.keys(errorData.properties).length > 0) {\n sections.push(`**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`);\n }\n \n return sections.join('\\n\\n');\n }\n}\n"],"names":[],"mappings":"MAoBa,gBAAgB,CAAA;AACnB,IAAA,MAAM;IACN,OAAO,GAAkB,IAAI;AAErC,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;AAC1C,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE;AAChC,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM;AACtB,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,OAAO;AACL,YAAA,eAAe,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,CAAE;AAC/C,YAAA,cAAc,EAAE,kBAAkB;SACnC;IACH;AAEQ,IAAA,MAAM,UAAU,CACtB,QAAgB,EAChB,UAAuB,EAAE,EAAA;QAEzB,MAAM,GAAG,GAAG,CAAA,EAAG,IAAI,CAAC,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAE;AAExC,QAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAA,GAAG,OAAO;AACV,YAAA,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,OAAO;gBACf,GAAG,OAAO,CAAC,OAAO;AACnB,aAAA;AACF,SAAA,CAAC;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MAAM,CAAA,YAAA,CAAc,CAAC;QAC9D;AAEA,QAAA,IAAI,SAAS,CAAC,cAAc,EAAE;YAC5B,QAAQ,CAAC,IAAI,CAAC,CAAA,oBAAA,EAAuB,SAAS,CAAC,cAAc,CAAA,CAAE,CAAC;QAClE;QAEA,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,SAAS,EAAE;YAC/C,QAAQ,CAAC,IAAI,CAAC,CAAA,gBAAA,EAAmB,SAAS,CAAC,UAAU,CAAA,CAAE,CAAC;YACxD,QAAQ,CAAC,IAAI,CAAC,CAAA,eAAA,EAAkB,SAAS,CAAC,SAAS,CAAA,CAAE,CAAC;QACxD;AAEA,QAAA,IAAI,SAAS,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;AACxE,YAAA,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,CAAE,CAAC;QACnF;AAEA,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type { Task, TaskRun, LogEntry, SupportingFile, PostHogAPIConfig, PostHogResource, ResourceType, UrlMention } from './types.js';\n\ninterface PostHogApiResponse<T> {\n results?: T[];\n count?: number;\n next?: string | null;\n previous?: string | null;\n}\n\nexport interface TaskRunUpdate {\n status?: TaskRun[\"status\"];\n branch?: string | null;\n current_stage?: string | null;\n log?: LogEntry[];\n error_message?: string | null;\n output?: Record<string, unknown> | null;\n state?: Record<string, unknown>;\n}\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n private _teamId: number | null = null;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\") \n ? this.config.apiUrl.slice(0, -1) \n : this.config.apiUrl;\n return host;\n }\n\n private get headers(): Record<string, string> {\n return {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n private async apiRequest<T>(\n endpoint: string, \n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n \n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.headers,\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n async getTeamId(): Promise<number> {\n if (this._teamId !== null) {\n return this._teamId;\n }\n\n // Fetch user info to get team ID (following Array's pattern)\n const userResponse = await this.apiRequest<any>('/api/users/@me/');\n\n if (!userResponse.team?.id) {\n throw new Error('No team found for user');\n }\n\n const teamId = Number(userResponse.team.id);\n this._teamId = teamId;\n return teamId;\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n\n getApiKey(): string {\n return this.config.apiKey;\n }\n\n async getLlmGatewayUrl(): Promise<string> {\n const teamId = await this.getTeamId();\n return `${this.baseUrl}/api/projects/${teamId}/llm_gateway`;\n }\n\n async fetchTask(taskId: string): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n }): Promise<Task[]> {\n const teamId = await this.getTeamId();\n const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);\n \n if (filters) {\n Object.entries(filters).forEach(([key, value]) => {\n if (value) url.searchParams.append(key, value);\n });\n }\n\n const response = await this.apiRequest<PostHogApiResponse<Task>>(\n url.pathname + url.search\n );\n \n return response.results || [];\n }\n\n async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n // TaskRun methods\n async listTaskRuns(taskId: string): Promise<TaskRun[]> {\n const teamId = await this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<TaskRun>>(\n `/api/projects/${teamId}/tasks/${taskId}/runs/`\n );\n return response.results || [];\n }\n\n async getTaskRun(taskId: string, runId: string): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`);\n }\n\n async createTaskRun(\n taskId: string,\n payload?: Partial<Omit<TaskRun, 'id' | 'task' | 'team' | 'created_at' | 'updated_at' | 'completed_at'>>\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/`, {\n method: \"POST\",\n body: JSON.stringify(payload || {}),\n });\n }\n\n async updateTaskRun(\n taskId: string,\n runId: string,\n payload: TaskRunUpdate\n ): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/`, {\n method: \"PATCH\",\n body: JSON.stringify(payload),\n });\n }\n\n async setTaskRunOutput(taskId: string, runId: string, output: Record<string, unknown>): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_output/`, {\n method: 'PATCH',\n body: JSON.stringify({ output }),\n });\n }\n\n async appendTaskRunLog(taskId: string, runId: string, entries: LogEntry[]): Promise<TaskRun> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/append_log/`, {\n method: 'POST',\n body: JSON.stringify({ entries }),\n });\n }\n\n /**\n * Fetch error details from PostHog error tracking\n */\n async fetchErrorDetails(errorId: string, projectId?: string): Promise<PostHogResource> {\n const teamId = projectId ? parseInt(projectId) : await this.getTeamId();\n \n try {\n const errorData = await this.apiRequest<any>(`/api/projects/${teamId}/error_tracking/${errorId}/`);\n \n // Format error details for agent consumption\n const content = this.formatErrorContent(errorData);\n \n return {\n type: 'error',\n id: errorId,\n url: `${this.baseUrl}/project/${teamId}/error_tracking/${errorId}`,\n title: errorData.exception_type || 'Unknown Error',\n content,\n metadata: {\n exception_type: errorData.exception_type,\n first_seen: errorData.first_seen,\n last_seen: errorData.last_seen,\n volume: errorData.volume,\n users_affected: errorData.users_affected,\n },\n };\n } catch (error) {\n throw new Error(`Failed to fetch error details for ${errorId}: ${error}`);\n }\n }\n\n /**\n * Generic resource fetcher by URL or ID\n */\n async fetchResourceByUrl(urlMention: UrlMention): Promise<PostHogResource> {\n switch (urlMention.type) {\n case 'error':\n if (!urlMention.id) {\n throw new Error('Error ID is required for error resources');\n }\n // Extract project ID from URL if available, otherwise use default team\n let projectId: string | undefined;\n if (urlMention.url) {\n const projectIdMatch = urlMention.url.match(/\\/project\\/(\\d+)\\//);\n projectId = projectIdMatch ? projectIdMatch[1] : undefined;\n }\n return this.fetchErrorDetails(urlMention.id, projectId);\n \n case 'experiment':\n case 'insight':\n case 'feature_flag':\n throw new Error(`Resource type '${urlMention.type}' not yet implemented`);\n \n case 'generic':\n // Return a minimal resource for generic URLs\n return {\n type: 'generic',\n id: '',\n url: urlMention.url,\n title: 'Generic Resource',\n content: `Generic resource: ${urlMention.url}`,\n metadata: {},\n };\n \n default:\n throw new Error(`Unknown resource type: ${urlMention.type}`);\n }\n }\n\n /**\n * Format error data for agent consumption\n */\n private formatErrorContent(errorData: any): string {\n const sections = [];\n \n if (errorData.exception_type) {\n sections.push(`**Error Type**: ${errorData.exception_type}`);\n }\n \n if (errorData.exception_message) {\n sections.push(`**Message**: ${errorData.exception_message}`);\n }\n \n if (errorData.stack_trace) {\n sections.push(`**Stack Trace**:\\n\\`\\`\\`\\n${errorData.stack_trace}\\n\\`\\`\\``);\n }\n \n if (errorData.volume) {\n sections.push(`**Volume**: ${errorData.volume} occurrences`);\n }\n \n if (errorData.users_affected) {\n sections.push(`**Users Affected**: ${errorData.users_affected}`);\n }\n \n if (errorData.first_seen && errorData.last_seen) {\n sections.push(`**First Seen**: ${errorData.first_seen}`);\n sections.push(`**Last Seen**: ${errorData.last_seen}`);\n }\n \n if (errorData.properties && Object.keys(errorData.properties).length > 0) {\n sections.push(`**Properties**: ${JSON.stringify(errorData.properties, null, 2)}`);\n }\n \n return sections.join('\\n\\n');\n }\n}\n"],"names":[],"mappings":"MAmBa,gBAAgB,CAAA;AACnB,IAAA,MAAM;IACN,OAAO,GAAkB,IAAI;AAErC,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;AAC1C,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE;AAChC,cAAE,IAAI,CAAC,MAAM,CAAC,MAAM;AACtB,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,OAAO;AACL,YAAA,eAAe,EAAE,CAAA,OAAA,EAAU,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA,CAAE;AAC/C,YAAA,cAAc,EAAE,kBAAkB;SACnC;IACH;AAEQ,IAAA,MAAM,UAAU,CACtB,QAAgB,EAChB,UAAuB,EAAE,EAAA;QAEzB,MAAM,GAAG,GAAG,CAAA,EAAG,IAAI,CAAC,OAAO,CAAA,EAAG,QAAQ,CAAA,CAAE;AAExC,QAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAA,GAAG,OAAO;AACV,YAAA,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AAA,oBAAA,EAAuB,SAAS,CAAC,cAAc,CAAA,CAAE,CAAC;QAClE;QAEA,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,SAAS,EAAE;YAC/C,QAAQ,CAAC,IAAI,CAAC,CAAA,gBAAA,EAAmB,SAAS,CAAC,UAAU,CAAA,CAAE,CAAC;YACxD,QAAQ,CAAC,IAAI,CAAC,CAAA,eAAA,EAAkB,SAAS,CAAC,SAAS,CAAA,CAAE,CAAC;QACxD;AAEA,QAAA,IAAI,SAAS,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;AACxE,YAAA,QAAQ,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,CAAE,CAAC;QACnF;AAEA,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC9B;AACD;;;;"}
|
|
@@ -42,6 +42,7 @@ export declare class PromptBuilder {
|
|
|
42
42
|
* Returns processed description and referenced file contents
|
|
43
43
|
*/
|
|
44
44
|
private processFileReferences;
|
|
45
|
+
buildResearchPrompt(task: Task, repositoryPath?: string): Promise<string>;
|
|
45
46
|
buildPlanningPrompt(task: Task, repositoryPath?: string): Promise<string>;
|
|
46
47
|
buildExecutionPrompt(task: Task, repositoryPath?: string): Promise<string>;
|
|
47
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C,MAAM,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W,iBAAiB;IAChC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,oBAAoB,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,aAAa,CAAC,EAAE;QAAE,kBAAkB,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,eAAe,CAAC,CAAA;KAAE,CAAC;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,oBAAoB,CAA4C;IACxE,OAAO,CAAC,aAAa,CAAC,CAAqC;IAC3D,OAAO,CAAC,MAAM,CAAS;gBAEX,IAAI,EAAE,iBAAiB;IAOnC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;YACW,eAAe;IAW7B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IA+B1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;OAEG;YACW,oBAAoB;IAqDlC;;;OAGG;YACW,qBAAqB;IAgC7B,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqDzE,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA+DzE,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA2DjF"}
|
|
@@ -165,6 +165,46 @@ class PromptBuilder {
|
|
|
165
165
|
}
|
|
166
166
|
return { description: processedDescription, referencedFiles };
|
|
167
167
|
}
|
|
168
|
+
async buildResearchPrompt(task, repositoryPath) {
|
|
169
|
+
// Process file references in description
|
|
170
|
+
const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(task.description, repositoryPath);
|
|
171
|
+
// Process URL references in description
|
|
172
|
+
const { description: processedDescription, referencedResources } = await this.processUrlReferences(descriptionAfterFiles);
|
|
173
|
+
let prompt = '';
|
|
174
|
+
prompt += `## Current Task\n\n**Task**: ${task.title}\n**Description**: ${processedDescription}`;
|
|
175
|
+
if (task.primary_repository) {
|
|
176
|
+
prompt += `\n**Repository**: ${task.primary_repository}`;
|
|
177
|
+
}
|
|
178
|
+
// Add referenced files from @ mentions
|
|
179
|
+
if (referencedFiles.length > 0) {
|
|
180
|
+
prompt += `\n\n## Referenced Files\n\n`;
|
|
181
|
+
for (const file of referencedFiles) {
|
|
182
|
+
prompt += `### ${file.path}\n\`\`\`\n${file.content}\n\`\`\`\n\n`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Add referenced resources from URL mentions
|
|
186
|
+
if (referencedResources.length > 0) {
|
|
187
|
+
prompt += `\n\n## Referenced Resources\n\n`;
|
|
188
|
+
for (const resource of referencedResources) {
|
|
189
|
+
prompt += `### ${resource.title} (${resource.type})\n**URL**: ${resource.url}\n\n${resource.content}\n\n`;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const taskFiles = await this.getTaskFiles(task.id);
|
|
194
|
+
const contextFiles = taskFiles.filter((f) => f.type === 'context' || f.type === 'reference');
|
|
195
|
+
if (contextFiles.length > 0) {
|
|
196
|
+
prompt += `\n\n## Supporting Files`;
|
|
197
|
+
for (const file of contextFiles) {
|
|
198
|
+
prompt += `\n\n### ${file.name} (${file.type})\n${file.content}`;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
this.logger.debug('No existing task files found for research', { taskId: task.id });
|
|
204
|
+
}
|
|
205
|
+
prompt += `\n\nPlease explore the codebase thoroughly and generate 3-5 clarifying questions that will help guide the implementation of this task. Use the \`create_plan\` tool to create a research.md artifact with your questions in the markdown format specified in your system prompt.`;
|
|
206
|
+
return prompt;
|
|
207
|
+
}
|
|
168
208
|
async buildPlanningPrompt(task, repositoryPath) {
|
|
169
209
|
// Process file references in description
|
|
170
210
|
const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(task.description, repositoryPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","sources":["../../src/prompt-builder.ts"],"sourcesContent":["import type { Task, UrlMention, PostHogResource } from './types.js';\nimport type { TemplateVariables } from './template-manager.js';\nimport { Logger } from './utils/logger.js';\nimport { promises as fs } from 'fs';\nimport { join } from 'path';\n\nexport interface PromptBuilderDeps {\n getTaskFiles: (taskId: string) => Promise<any[]>;\n generatePlanTemplate: (vars: TemplateVariables) => Promise<string>;\n posthogClient?: { fetchResourceByUrl: (mention: UrlMention) => Promise<PostHogResource> };\n logger?: Logger;\n}\n\nexport class PromptBuilder {\n private getTaskFiles: PromptBuilderDeps['getTaskFiles'];\n private generatePlanTemplate: PromptBuilderDeps['generatePlanTemplate'];\n private posthogClient?: PromptBuilderDeps['posthogClient'];\n private logger: Logger;\n\n constructor(deps: PromptBuilderDeps) {\n this.getTaskFiles = deps.getTaskFiles;\n this.generatePlanTemplate = deps.generatePlanTemplate;\n this.posthogClient = deps.posthogClient;\n this.logger = deps.logger || new Logger({ debug: false, prefix: '[PromptBuilder]' });\n }\n\n /**\n * Extract file paths from XML tags in description\n * Format: <file path=\"relative/path.ts\" />\n */\n private extractFilePaths(description: string): string[] {\n const fileTagRegex = /<file\\s+path=\"([^\"]+)\"\\s*\\/>/g;\n const paths: string[] = [];\n let match: RegExpExecArray | null;\n\n while ((match = fileTagRegex.exec(description)) !== null) {\n paths.push(match[1]);\n }\n\n return paths;\n }\n\n /**\n * Read file contents from repository\n */\n private async readFileContent(repositoryPath: string, filePath: string): Promise<string | null> {\n try {\n const fullPath = join(repositoryPath, filePath);\n const content = await fs.readFile(fullPath, 'utf8');\n return content;\n } catch (error) {\n this.logger.warn(`Failed to read referenced file: ${filePath}`, { error });\n return null;\n }\n }\n\n /**\n * Extract URL mentions from XML tags in description\n * Formats: <error id=\"...\" />, <experiment id=\"...\" />, <url href=\"...\" />\n */\n private extractUrlMentions(description: string): UrlMention[] {\n const mentions: UrlMention[] = [];\n \n // PostHog resource mentions: <error id=\"...\" />, <experiment id=\"...\" />, etc.\n const resourceRegex = /<(error|experiment|insight|feature_flag)\\s+id=\"([^\"]+)\"\\s*\\/>/g;\n let match: RegExpExecArray | null;\n\n while ((match = resourceRegex.exec(description)) !== null) {\n const [, type, id] = match;\n mentions.push({\n url: '', // Will be reconstructed if needed\n type: type as any,\n id,\n label: this.generateUrlLabel('', type as any),\n });\n }\n\n // Generic URL mentions: <url href=\"...\" />\n const urlRegex = /<url\\s+href=\"([^\"]+)\"\\s*\\/>/g;\n while ((match = urlRegex.exec(description)) !== null) {\n const [, url] = match;\n mentions.push({\n url,\n type: 'generic',\n label: this.generateUrlLabel(url, 'generic'),\n });\n }\n\n return mentions;\n }\n\n /**\n * Generate a display label for a URL mention\n */\n private generateUrlLabel(url: string, type: string): string {\n try {\n const urlObj = new URL(url);\n switch (type) {\n case 'error':\n const errorMatch = url.match(/error_tracking\\/([a-f0-9-]+)/);\n return errorMatch ? `Error ${errorMatch[1].slice(0, 8)}...` : 'Error';\n case 'experiment':\n const expMatch = url.match(/experiments\\/(\\d+)/);\n return expMatch ? `Experiment #${expMatch[1]}` : 'Experiment';\n case 'insight':\n return 'Insight';\n case 'feature_flag':\n return 'Feature Flag';\n default:\n return urlObj.hostname;\n }\n } catch {\n return 'URL';\n }\n }\n\n /**\n * Process URL references and fetch their content\n */\n private async processUrlReferences(\n description: string\n ): Promise<{ description: string; referencedResources: PostHogResource[] }> {\n const urlMentions = this.extractUrlMentions(description);\n const referencedResources: PostHogResource[] = [];\n\n if (urlMentions.length === 0 || !this.posthogClient) {\n return { description, referencedResources };\n }\n\n // Fetch all referenced resources\n for (const mention of urlMentions) {\n try {\n const resource = await this.posthogClient.fetchResourceByUrl(mention);\n referencedResources.push(resource);\n } catch (error) {\n this.logger.warn(`Failed to fetch resource from URL: ${mention.url}`, { error });\n // Add a placeholder resource for failed fetches\n referencedResources.push({\n type: mention.type,\n id: mention.id || '',\n url: mention.url,\n title: mention.label || 'Unknown Resource',\n content: `Failed to fetch resource from ${mention.url}: ${error}`,\n metadata: {},\n });\n }\n }\n\n // Replace URL tags with just the label for readability\n let processedDescription = description;\n for (const mention of urlMentions) {\n if (mention.type === 'generic') {\n // Generic URLs: <url href=\"...\" />\n const escapedUrl = mention.url.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n processedDescription = processedDescription.replace(\n new RegExp(`<url\\\\s+href=\"${escapedUrl}\"\\\\s*/>`, 'g'),\n `@${mention.label}`\n );\n } else {\n // PostHog resources: <error id=\"...\" />, <experiment id=\"...\" />, etc.\n const escapedType = mention.type.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const escapedId = mention.id ? mention.id.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') : '';\n processedDescription = processedDescription.replace(\n new RegExp(`<${escapedType}\\\\s+id=\"${escapedId}\"\\\\s*/>`, 'g'),\n `@${mention.label}`\n );\n }\n }\n\n return { description: processedDescription, referencedResources };\n }\n\n /**\n * Process description to extract file tags and read contents\n * Returns processed description and referenced file contents\n */\n private async processFileReferences(\n description: string,\n repositoryPath?: string\n ): Promise<{ description: string; referencedFiles: Array<{ path: string; content: string }> }> {\n const filePaths = this.extractFilePaths(description);\n const referencedFiles: Array<{ path: string; content: string }> = [];\n\n if (filePaths.length === 0 || !repositoryPath) {\n return { description, referencedFiles };\n }\n\n // Read all referenced files\n for (const filePath of filePaths) {\n const content = await this.readFileContent(repositoryPath, filePath);\n if (content !== null) {\n referencedFiles.push({ path: filePath, content });\n }\n }\n\n // Replace file tags with just the filename for readability\n let processedDescription = description;\n for (const filePath of filePaths) {\n const fileName = filePath.split('/').pop() || filePath;\n processedDescription = processedDescription.replace(\n new RegExp(`<file\\\\s+path=\"${filePath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}\"\\\\s*/>`, 'g'),\n `@${fileName}`\n );\n }\n\n return { description: processedDescription, referencedFiles };\n }\n\n async buildPlanningPrompt(task: Task, repositoryPath?: string): Promise<string> {\n // Process file references in description\n const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(\n task.description,\n repositoryPath\n );\n\n // Process URL references in description \n const { description: processedDescription, referencedResources } = await this.processUrlReferences(\n descriptionAfterFiles\n );\n\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${processedDescription}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n // Add referenced files from @ mentions\n if (referencedFiles.length > 0) {\n prompt += `\\n\\n## Referenced Files\\n\\n`;\n for (const file of referencedFiles) {\n prompt += `### ${file.path}\\n\\`\\`\\`\\n${file.content}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n // Add referenced resources from URL mentions\n if (referencedResources.length > 0) {\n prompt += `\\n\\n## Referenced Resources\\n\\n`;\n for (const resource of referencedResources) {\n prompt += `### ${resource.title} (${resource.type})\\n**URL**: ${resource.url}\\n\\n${resource.content}\\n\\n`;\n }\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');\n if (contextFiles.length > 0) {\n prompt += `\\n\\n## Supporting Files`;\n for (const file of contextFiles) {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n } catch (error) {\n this.logger.debug('No existing task files found for planning', { taskId: task.id });\n }\n\n const templateVariables = {\n task_id: task.id,\n task_title: task.title,\n task_description: processedDescription,\n date: new Date().toISOString().split('T')[0],\n repository: ((task as any).primary_repository || '') as string,\n };\n\n const planTemplate = await this.generatePlanTemplate(templateVariables);\n\n prompt += `\\n\\nPlease analyze the codebase and create a detailed implementation plan for this task. Use the following template structure for your plan:\\n\\n${planTemplate}\\n\\nFill in each section with specific, actionable information based on your analysis. Replace all placeholder content with actual details about this task.`;\n\n return prompt;\n }\n\n async buildExecutionPrompt(task: Task, repositoryPath?: string): Promise<string> {\n // Process file references in description\n const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(\n task.description,\n repositoryPath\n );\n\n // Process URL references in description \n const { description: processedDescription, referencedResources } = await this.processUrlReferences(\n descriptionAfterFiles\n );\n\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${processedDescription}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n // Add referenced files from @ mentions\n if (referencedFiles.length > 0) {\n prompt += `\\n\\n## Referenced Files\\n\\n`;\n for (const file of referencedFiles) {\n prompt += `### ${file.path}\\n\\`\\`\\`\\n${file.content}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n // Add referenced resources from URL mentions\n if (referencedResources.length > 0) {\n prompt += `\\n\\n## Referenced Resources\\n\\n`;\n for (const resource of referencedResources) {\n prompt += `### ${resource.title} (${resource.type})\\n**URL**: ${resource.url}\\n\\n${resource.content}\\n\\n`;\n }\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const hasPlan = taskFiles.some((f: any) => f.type === 'plan');\n if (taskFiles.length > 0) {\n prompt += `\\n\\n## Context and Supporting Information`;\n for (const file of taskFiles) {\n if (file.type === 'plan') {\n prompt += `\\n\\n### Execution Plan\\n${file.content}`;\n } else {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n }\n if (hasPlan) {\n prompt += `\\n\\nPlease implement the changes described in the execution plan above. Follow the plan step-by-step and make the necessary file modifications. You must actually edit files and make changes - do not just analyze or review.`;\n } else {\n prompt += `\\n\\nPlease implement the changes described in the task above. You must actually edit files and make changes - do not just analyze or review.`;\n }\n } catch (error) {\n this.logger.debug('No supporting files found for execution', { taskId: task.id });\n prompt +=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I,CAAC,OAAO,EAAE;oBAClE;gBACF;YACF;YACA,IAAI,OAAO,EAAE;gBACX,MAAM,IAAI,gOAAgO;YAC5O;iBAAO;gBACL,MAAM,IAAI,8IAA8I;YAC1J;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;YACjF,MAAM,IAAI,+DAA+D;QAC3E;AACA,QAAA,OAAO,MAAM;IACf;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sources":["../../src/prompt-builder.ts"],"sourcesContent":["import type { Task, UrlMention, PostHogResource } from './types.js';\nimport type { TemplateVariables } from './template-manager.js';\nimport { Logger } from './utils/logger.js';\nimport { promises as fs } from 'fs';\nimport { join } from 'path';\n\nexport interface PromptBuilderDeps {\n getTaskFiles: (taskId: string) => Promise<any[]>;\n generatePlanTemplate: (vars: TemplateVariables) => Promise<string>;\n posthogClient?: { fetchResourceByUrl: (mention: UrlMention) => Promise<PostHogResource> };\n logger?: Logger;\n}\n\nexport class PromptBuilder {\n private getTaskFiles: PromptBuilderDeps['getTaskFiles'];\n private generatePlanTemplate: PromptBuilderDeps['generatePlanTemplate'];\n private posthogClient?: PromptBuilderDeps['posthogClient'];\n private logger: Logger;\n\n constructor(deps: PromptBuilderDeps) {\n this.getTaskFiles = deps.getTaskFiles;\n this.generatePlanTemplate = deps.generatePlanTemplate;\n this.posthogClient = deps.posthogClient;\n this.logger = deps.logger || new Logger({ debug: false, prefix: '[PromptBuilder]' });\n }\n\n /**\n * Extract file paths from XML tags in description\n * Format: <file path=\"relative/path.ts\" />\n */\n private extractFilePaths(description: string): string[] {\n const fileTagRegex = /<file\\s+path=\"([^\"]+)\"\\s*\\/>/g;\n const paths: string[] = [];\n let match: RegExpExecArray | null;\n\n while ((match = fileTagRegex.exec(description)) !== null) {\n paths.push(match[1]);\n }\n\n return paths;\n }\n\n /**\n * Read file contents from repository\n */\n private async readFileContent(repositoryPath: string, filePath: string): Promise<string | null> {\n try {\n const fullPath = join(repositoryPath, filePath);\n const content = await fs.readFile(fullPath, 'utf8');\n return content;\n } catch (error) {\n this.logger.warn(`Failed to read referenced file: ${filePath}`, { error });\n return null;\n }\n }\n\n /**\n * Extract URL mentions from XML tags in description\n * Formats: <error id=\"...\" />, <experiment id=\"...\" />, <url href=\"...\" />\n */\n private extractUrlMentions(description: string): UrlMention[] {\n const mentions: UrlMention[] = [];\n \n // PostHog resource mentions: <error id=\"...\" />, <experiment id=\"...\" />, etc.\n const resourceRegex = /<(error|experiment|insight|feature_flag)\\s+id=\"([^\"]+)\"\\s*\\/>/g;\n let match: RegExpExecArray | null;\n\n while ((match = resourceRegex.exec(description)) !== null) {\n const [, type, id] = match;\n mentions.push({\n url: '', // Will be reconstructed if needed\n type: type as any,\n id,\n label: this.generateUrlLabel('', type as any),\n });\n }\n\n // Generic URL mentions: <url href=\"...\" />\n const urlRegex = /<url\\s+href=\"([^\"]+)\"\\s*\\/>/g;\n while ((match = urlRegex.exec(description)) !== null) {\n const [, url] = match;\n mentions.push({\n url,\n type: 'generic',\n label: this.generateUrlLabel(url, 'generic'),\n });\n }\n\n return mentions;\n }\n\n /**\n * Generate a display label for a URL mention\n */\n private generateUrlLabel(url: string, type: string): string {\n try {\n const urlObj = new URL(url);\n switch (type) {\n case 'error':\n const errorMatch = url.match(/error_tracking\\/([a-f0-9-]+)/);\n return errorMatch ? `Error ${errorMatch[1].slice(0, 8)}...` : 'Error';\n case 'experiment':\n const expMatch = url.match(/experiments\\/(\\d+)/);\n return expMatch ? `Experiment #${expMatch[1]}` : 'Experiment';\n case 'insight':\n return 'Insight';\n case 'feature_flag':\n return 'Feature Flag';\n default:\n return urlObj.hostname;\n }\n } catch {\n return 'URL';\n }\n }\n\n /**\n * Process URL references and fetch their content\n */\n private async processUrlReferences(\n description: string\n ): Promise<{ description: string; referencedResources: PostHogResource[] }> {\n const urlMentions = this.extractUrlMentions(description);\n const referencedResources: PostHogResource[] = [];\n\n if (urlMentions.length === 0 || !this.posthogClient) {\n return { description, referencedResources };\n }\n\n // Fetch all referenced resources\n for (const mention of urlMentions) {\n try {\n const resource = await this.posthogClient.fetchResourceByUrl(mention);\n referencedResources.push(resource);\n } catch (error) {\n this.logger.warn(`Failed to fetch resource from URL: ${mention.url}`, { error });\n // Add a placeholder resource for failed fetches\n referencedResources.push({\n type: mention.type,\n id: mention.id || '',\n url: mention.url,\n title: mention.label || 'Unknown Resource',\n content: `Failed to fetch resource from ${mention.url}: ${error}`,\n metadata: {},\n });\n }\n }\n\n // Replace URL tags with just the label for readability\n let processedDescription = description;\n for (const mention of urlMentions) {\n if (mention.type === 'generic') {\n // Generic URLs: <url href=\"...\" />\n const escapedUrl = mention.url.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n processedDescription = processedDescription.replace(\n new RegExp(`<url\\\\s+href=\"${escapedUrl}\"\\\\s*/>`, 'g'),\n `@${mention.label}`\n );\n } else {\n // PostHog resources: <error id=\"...\" />, <experiment id=\"...\" />, etc.\n const escapedType = mention.type.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const escapedId = mention.id ? mention.id.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&') : '';\n processedDescription = processedDescription.replace(\n new RegExp(`<${escapedType}\\\\s+id=\"${escapedId}\"\\\\s*/>`, 'g'),\n `@${mention.label}`\n );\n }\n }\n\n return { description: processedDescription, referencedResources };\n }\n\n /**\n * Process description to extract file tags and read contents\n * Returns processed description and referenced file contents\n */\n private async processFileReferences(\n description: string,\n repositoryPath?: string\n ): Promise<{ description: string; referencedFiles: Array<{ path: string; content: string }> }> {\n const filePaths = this.extractFilePaths(description);\n const referencedFiles: Array<{ path: string; content: string }> = [];\n\n if (filePaths.length === 0 || !repositoryPath) {\n return { description, referencedFiles };\n }\n\n // Read all referenced files\n for (const filePath of filePaths) {\n const content = await this.readFileContent(repositoryPath, filePath);\n if (content !== null) {\n referencedFiles.push({ path: filePath, content });\n }\n }\n\n // Replace file tags with just the filename for readability\n let processedDescription = description;\n for (const filePath of filePaths) {\n const fileName = filePath.split('/').pop() || filePath;\n processedDescription = processedDescription.replace(\n new RegExp(`<file\\\\s+path=\"${filePath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}\"\\\\s*/>`, 'g'),\n `@${fileName}`\n );\n }\n\n return { description: processedDescription, referencedFiles };\n }\n\n async buildResearchPrompt(task: Task, repositoryPath?: string): Promise<string> {\n // Process file references in description\n const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(\n task.description,\n repositoryPath\n );\n\n // Process URL references in description \n const { description: processedDescription, referencedResources } = await this.processUrlReferences(\n descriptionAfterFiles\n );\n\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${processedDescription}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n // Add referenced files from @ mentions\n if (referencedFiles.length > 0) {\n prompt += `\\n\\n## Referenced Files\\n\\n`;\n for (const file of referencedFiles) {\n prompt += `### ${file.path}\\n\\`\\`\\`\\n${file.content}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n // Add referenced resources from URL mentions\n if (referencedResources.length > 0) {\n prompt += `\\n\\n## Referenced Resources\\n\\n`;\n for (const resource of referencedResources) {\n prompt += `### ${resource.title} (${resource.type})\\n**URL**: ${resource.url}\\n\\n${resource.content}\\n\\n`;\n }\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');\n if (contextFiles.length > 0) {\n prompt += `\\n\\n## Supporting Files`;\n for (const file of contextFiles) {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n } catch (error) {\n this.logger.debug('No existing task files found for research', { taskId: task.id });\n }\n\n prompt += `\\n\\nPlease explore the codebase thoroughly and generate 3-5 clarifying questions that will help guide the implementation of this task. Use the \\`create_plan\\` tool to create a research.md artifact with your questions in the markdown format specified in your system prompt.`;\n\n return prompt;\n }\n\n async buildPlanningPrompt(task: Task, repositoryPath?: string): Promise<string> {\n // Process file references in description\n const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(\n task.description,\n repositoryPath\n );\n\n // Process URL references in description \n const { description: processedDescription, referencedResources } = await this.processUrlReferences(\n descriptionAfterFiles\n );\n\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${processedDescription}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n // Add referenced files from @ mentions\n if (referencedFiles.length > 0) {\n prompt += `\\n\\n## Referenced Files\\n\\n`;\n for (const file of referencedFiles) {\n prompt += `### ${file.path}\\n\\`\\`\\`\\n${file.content}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n // Add referenced resources from URL mentions\n if (referencedResources.length > 0) {\n prompt += `\\n\\n## Referenced Resources\\n\\n`;\n for (const resource of referencedResources) {\n prompt += `### ${resource.title} (${resource.type})\\n**URL**: ${resource.url}\\n\\n${resource.content}\\n\\n`;\n }\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');\n if (contextFiles.length > 0) {\n prompt += `\\n\\n## Supporting Files`;\n for (const file of contextFiles) {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n } catch (error) {\n this.logger.debug('No existing task files found for planning', { taskId: task.id });\n }\n\n const templateVariables = {\n task_id: task.id,\n task_title: task.title,\n task_description: processedDescription,\n date: new Date().toISOString().split('T')[0],\n repository: ((task as any).primary_repository || '') as string,\n };\n\n const planTemplate = await this.generatePlanTemplate(templateVariables);\n\n prompt += `\\n\\nPlease analyze the codebase and create a detailed implementation plan for this task. Use the following template structure for your plan:\\n\\n${planTemplate}\\n\\nFill in each section with specific, actionable information based on your analysis. Replace all placeholder content with actual details about this task.`;\n\n return prompt;\n }\n\n async buildExecutionPrompt(task: Task, repositoryPath?: string): Promise<string> {\n // Process file references in description\n const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(\n task.description,\n repositoryPath\n );\n\n // Process URL references in description \n const { description: processedDescription, referencedResources } = await this.processUrlReferences(\n descriptionAfterFiles\n );\n\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${processedDescription}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n // Add referenced files from @ mentions\n if (referencedFiles.length > 0) {\n prompt += `\\n\\n## Referenced Files\\n\\n`;\n for (const file of referencedFiles) {\n prompt += `### ${file.path}\\n\\`\\`\\`\\n${file.content}\\n\\`\\`\\`\\n\\n`;\n }\n }\n\n // Add referenced resources from URL mentions\n if (referencedResources.length > 0) {\n prompt += `\\n\\n## Referenced Resources\\n\\n`;\n for (const resource of referencedResources) {\n prompt += `### ${resource.title} (${resource.type})\\n**URL**: ${resource.url}\\n\\n${resource.content}\\n\\n`;\n }\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const hasPlan = taskFiles.some((f: any) => f.type === 'plan');\n if (taskFiles.length > 0) {\n prompt += `\\n\\n## Context and Supporting Information`;\n for (const file of taskFiles) {\n if (file.type === 'plan') {\n prompt += `\\n\\n### Execution Plan\\n${file.content}`;\n } else {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n }\n if (hasPlan) {\n prompt += `\\n\\nPlease implement the changes described in the execution plan above. Follow the plan step-by-step and make the necessary file modifications. You must actually edit files and make changes - do not just analyze or review.`;\n } else {\n prompt += `\\n\\nPlease implement the changes described in the task above. You must actually edit files and make changes - do not just analyze or review.`;\n }\n } catch (error) {\n this.logger.debug('No supporting files found for execution', { taskId: task.id });\n prompt += `\\n\\nPlease implement the changes described in the task above.`;\n }\n return prompt;\n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S,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD,YAAA,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAM,KAAK,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AAC7D,YAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;gBACxB,MAAM,IAAI,2CAA2C;AACrD,gBAAA,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;AAC5B,oBAAA,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;AACxB,wBAAA,MAAM,IAAI,CAAA,wBAAA,EAA2B,IAAI,CAAC,OAAO,EAAE;oBACrD;yBAAO;AACL,wBAAA,MAAM,IAAI,CAAA,QAAA,EAAW,IAAI,CAAC,IAAI,CAAA,EAAA,EAAK,IAAI,CAAC,IAAI,CAAA,GAAA,EAAM,IAAI,CAAC,OAAO,EAAE;oBAClE;gBACF;YACF;YACA,IAAI,OAAO,EAAE;gBACX,MAAM,IAAI,gOAAgO;YAC5O;iBAAO;gBACL,MAAM,IAAI,8IAA8I;YAC1J;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;YACjF,MAAM,IAAI,+DAA+D;QAC3E;AACA,QAAA,OAAO,MAAM;IACf;AACD;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Logger } from './utils/logger.js';
|
|
2
|
+
export interface ExtractedQuestion {
|
|
3
|
+
id: string;
|
|
4
|
+
question: string;
|
|
5
|
+
options: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface ExtractedQuestionWithAnswer extends ExtractedQuestion {
|
|
8
|
+
recommendedAnswer: string;
|
|
9
|
+
justification: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StructuredExtractor {
|
|
12
|
+
extractQuestions(researchContent: string): Promise<ExtractedQuestion[]>;
|
|
13
|
+
extractQuestionsWithAnswers(researchContent: string): Promise<ExtractedQuestionWithAnswer[]>;
|
|
14
|
+
}
|
|
15
|
+
export declare class OpenAIExtractor implements StructuredExtractor {
|
|
16
|
+
private client;
|
|
17
|
+
private logger;
|
|
18
|
+
constructor(logger?: Logger);
|
|
19
|
+
extractQuestions(researchContent: string): Promise<ExtractedQuestion[]>;
|
|
20
|
+
extractQuestionsWithAnswers(researchContent: string): Promise<ExtractedQuestionWithAnswer[]>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=structured-extraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-extraction.d.ts","sourceRoot":"","sources":["../../src/structured-extraction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAoDD,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxE,2BAA2B,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC;CAC9F;AAED,qBAAa,eAAgB,YAAW,mBAAmB;IACzD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAUrB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAyCvE,2BAA2B,CAC/B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,2BAA2B,EAAE,CAAC;CAwC1C"}
|