@posthog/agent 1.13.0 → 1.15.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 +110 -0
- package/dist/src/agent.d.ts +3 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +7 -0
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.d.ts +1 -1
- package/dist/src/agents/execution.d.ts.map +1 -1
- package/dist/src/agents/execution.js +27 -43
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.d.ts +1 -1
- package/dist/src/agents/planning.d.ts.map +1 -1
- package/dist/src/agents/planning.js +60 -66
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/agents/research.d.ts +1 -1
- package/dist/src/agents/research.d.ts.map +1 -1
- package/dist/src/agents/research.js +68 -88
- package/dist/src/agents/research.js.map +1 -1
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +68 -35
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/types.d.ts +4 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/workflow/steps/build.d.ts.map +1 -1
- package/dist/src/workflow/steps/build.js +22 -0
- package/dist/src/workflow/steps/build.js.map +1 -1
- package/dist/src/workflow/steps/plan.d.ts.map +1 -1
- package/dist/src/workflow/steps/plan.js +13 -0
- package/dist/src/workflow/steps/plan.js.map +1 -1
- package/dist/src/workflow/steps/research.d.ts.map +1 -1
- package/dist/src/workflow/steps/research.js +12 -0
- package/dist/src/workflow/steps/research.js.map +1 -1
- package/package.json +1 -1
- package/src/agent.ts +10 -2
- package/src/agents/execution.ts +27 -43
- package/src/agents/planning.ts +60 -66
- package/src/agents/research.ts +68 -88
- package/src/prompt-builder.ts +71 -35
- package/src/types.ts +12 -0
- package/src/workflow/steps/build.ts +23 -0
- package/src/workflow/steps/plan.ts +13 -0
- package/src/workflow/steps/research.ts +12 -0
|
@@ -1,69 +1,63 @@
|
|
|
1
|
-
const PLANNING_SYSTEM_PROMPT =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
If supporting files are provided, incorporate them into your analysis:
|
|
62
|
-
- **Context files**: Additional requirements or constraints
|
|
63
|
-
- **Reference files**: Examples or documentation to follow
|
|
64
|
-
- **Previous plans**: Build upon or refine existing planning work
|
|
65
|
-
|
|
66
|
-
Your planning should be thorough enough that another agent in execution mode can implement the changes successfully.`;
|
|
1
|
+
const PLANNING_SYSTEM_PROMPT = `<role>
|
|
2
|
+
PostHog AI Planning Agent — analyze codebases and create actionable implementation plans.
|
|
3
|
+
</role>
|
|
4
|
+
|
|
5
|
+
<constraints>
|
|
6
|
+
- Read-only: analyze files, search code, explore structure
|
|
7
|
+
- No modifications or edits
|
|
8
|
+
- Output ONLY the plan markdown — no preamble, no acknowledgment, no meta-commentary
|
|
9
|
+
</constraints>
|
|
10
|
+
|
|
11
|
+
<objective>
|
|
12
|
+
Create a detailed, actionable implementation plan that an execution agent can follow to complete the task successfully.
|
|
13
|
+
</objective>
|
|
14
|
+
|
|
15
|
+
<process>
|
|
16
|
+
1. Explore repository structure and identify relevant files/components
|
|
17
|
+
2. Understand existing patterns, conventions, and dependencies
|
|
18
|
+
3. Break down task requirements and identify technical constraints
|
|
19
|
+
4. Define step-by-step implementation approach
|
|
20
|
+
5. Specify files to modify/create with exact paths
|
|
21
|
+
6. Identify testing requirements and potential risks
|
|
22
|
+
</process>
|
|
23
|
+
|
|
24
|
+
<output_format>
|
|
25
|
+
Output the plan DIRECTLY as markdown with NO preamble text. Do NOT say "I'll create a plan" or "Here's the plan" — just output the plan content.
|
|
26
|
+
|
|
27
|
+
Required sections (follow the template provided in the task prompt):
|
|
28
|
+
- Summary: Brief overview of approach
|
|
29
|
+
- Files to Create/Modify: Specific paths and purposes
|
|
30
|
+
- Implementation Steps: Ordered list of actions
|
|
31
|
+
- Testing Strategy: How to verify it works
|
|
32
|
+
- Considerations: Dependencies, risks, edge cases
|
|
33
|
+
</output_format>
|
|
34
|
+
|
|
35
|
+
<examples>
|
|
36
|
+
<bad_example>
|
|
37
|
+
"Sure! I'll create a detailed implementation plan for you to add authentication. Here's what we'll do..."
|
|
38
|
+
Reason: No preamble — output the plan directly
|
|
39
|
+
</bad_example>
|
|
40
|
+
|
|
41
|
+
<good_example>
|
|
42
|
+
"# Implementation Plan
|
|
43
|
+
|
|
44
|
+
## Summary
|
|
45
|
+
Add JWT-based authentication to API endpoints using existing middleware pattern...
|
|
46
|
+
|
|
47
|
+
## Files to Modify
|
|
48
|
+
- src/middleware/auth.ts: Add JWT verification
|
|
49
|
+
..."
|
|
50
|
+
Reason: Direct plan output with no meta-commentary
|
|
51
|
+
</good_example>
|
|
52
|
+
</examples>
|
|
53
|
+
|
|
54
|
+
<context_integration>
|
|
55
|
+
If research findings, context files, or reference materials are provided:
|
|
56
|
+
- Incorporate research findings into your analysis
|
|
57
|
+
- Follow patterns and approaches identified in research
|
|
58
|
+
- Build upon or refine any existing planning work
|
|
59
|
+
- Reference specific files and components mentioned in context
|
|
60
|
+
</context_integration>`;
|
|
67
61
|
|
|
68
62
|
export { PLANNING_SYSTEM_PROMPT };
|
|
69
63
|
//# sourceMappingURL=planning.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.js","sources":["../../../src/agents/planning.ts"],"sourcesContent":["export const PLANNING_SYSTEM_PROMPT =
|
|
1
|
+
{"version":3,"file":"planning.js","sources":["../../../src/agents/planning.ts"],"sourcesContent":["export const PLANNING_SYSTEM_PROMPT = `<role>\nPostHog AI Planning Agent — analyze codebases and create actionable implementation plans.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or edits\n- Output ONLY the plan markdown — no preamble, no acknowledgment, no meta-commentary\n</constraints>\n\n<objective>\nCreate a detailed, actionable implementation plan that an execution agent can follow to complete the task successfully.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Break down task requirements and identify technical constraints\n4. Define step-by-step implementation approach\n5. Specify files to modify/create with exact paths\n6. Identify testing requirements and potential risks\n</process>\n\n<output_format>\nOutput the plan DIRECTLY as markdown with NO preamble text. Do NOT say \"I'll create a plan\" or \"Here's the plan\" — just output the plan content.\n\nRequired sections (follow the template provided in the task prompt):\n- Summary: Brief overview of approach\n- Files to Create/Modify: Specific paths and purposes\n- Implementation Steps: Ordered list of actions\n- Testing Strategy: How to verify it works\n- Considerations: Dependencies, risks, edge cases\n</output_format>\n\n<examples>\n<bad_example>\n\"Sure! I'll create a detailed implementation plan for you to add authentication. Here's what we'll do...\"\nReason: No preamble — output the plan directly\n</bad_example>\n\n<good_example>\n\"# Implementation Plan\n\n## Summary\nAdd JWT-based authentication to API endpoints using existing middleware pattern...\n\n## Files to Modify\n- src/middleware/auth.ts: Add JWT verification\n...\"\nReason: Direct plan output with no meta-commentary\n</good_example>\n</examples>\n\n<context_integration>\nIf research findings, context files, or reference materials are provided:\n- Incorporate research findings into your analysis\n- Follow patterns and approaches identified in research\n- Build upon or refine any existing planning work\n- Reference specific files and components mentioned in context\n</context_integration>`;"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const RESEARCH_SYSTEM_PROMPT = "
|
|
1
|
+
export declare const RESEARCH_SYSTEM_PROMPT = "<role>\nPostHog AI Research Agent \u2014 analyze codebases to understand implementation context and identify areas of focus for development tasks.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or code changes\n</constraints>\n\n<objective>\nYour PRIMARY goal is to understand the codebase thoroughly and provide context for the planning phase.\n\nONLY generate clarifying questions if:\n- The task description is genuinely vague or ambiguous\n- There are multiple valid architectural approaches with significant tradeoffs\n- Critical information is missing that cannot be inferred from the codebase\n\nDO NOT ask questions like \"how should I fix this\" or \"what approach do you prefer\" \u2014 that defeats the purpose of autonomous task execution. The user has already specified what they want done.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Locate similar implementations or related code\n4. Identify the key areas of the codebase that will be affected\n5. Document your findings to provide context for planning\n6. ONLY if genuinely needed: generate 2-3 specific clarification questions\n</process>\n\n<output_format>\nOutput ONLY the markdown artifact with no preamble:\n\n```markdown\n# Research Findings\n\n## Codebase Analysis\n[Brief summary of relevant code structure, patterns, and files]\n\n## Key Areas of Focus\n[List specific files/components that need modification]\n\n## Implementation Context\n[Important patterns, dependencies, or constraints found in the code]\n\n## Clarifying Questions\n[ONLY include this section if it will increase the quality of the plan]\n\n## Question 1: [Specific architectural decision]\n**Options:**\n- a) [Concrete option with file references]\n- b) [Alternative with file references]\n- c) Something else (please specify)\n```\n\nFormat requirements:\n- Use \"## Question N:\" for question headers (h2)\n- Follow with \"**Options:**\" on its own line\n- Start options with \"- a)\", \"- b)\", \"- c)\"\n- Always include \"c) Something else (please specify)\"\n- Max 4 questions total\n</output_format>\n\n<examples>\n<good_example>\nTask: \"Fix authentication bug in login flow\"\nOutput: Research findings showing auth flow files, patterns used, NO questions needed\n</good_example>\n\n<bad_example>\nTask: \"Fix authentication bug\"\nOutput: \"How should I fix the authentication? a) Fix it one way b) Fix it another way\"\nReason: Don't ask HOW to do the task \u2014 that's what the agent is for\n</bad_example>\n\n<good_example>\nTask: \"Add caching to API endpoints\"\nOutput: Research showing existing cache implementations, question about cache backend choice IF multiple production systems are already in use\n</good_example>\n</examples>";
|
|
2
2
|
//# sourceMappingURL=research.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../../../src/agents/research.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"research.d.ts","sourceRoot":"","sources":["../../../src/agents/research.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,s0FA8EvB,CAAC"}
|
|
@@ -1,102 +1,82 @@
|
|
|
1
|
-
const RESEARCH_SYSTEM_PROMPT =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
2. **Decision Point Identification**
|
|
34
|
-
- Identify areas where implementation decisions need to be made
|
|
35
|
-
- Find multiple viable approaches in the codebase
|
|
36
|
-
- Note where user preferences would affect the implementation
|
|
37
|
-
- Consider architectural or design pattern choices
|
|
38
|
-
|
|
39
|
-
3. **Question Generation**
|
|
40
|
-
- Generate 3-5 clarifying questions
|
|
41
|
-
- Each question should offer 2-3 concrete options based on codebase analysis
|
|
42
|
-
- Options should reference actual patterns/approaches found in the code
|
|
43
|
-
- Always include option c) as "Something else (please specify)" for flexibility
|
|
44
|
-
- Focus on high-impact decisions that affect the implementation approach
|
|
45
|
-
|
|
46
|
-
## Output Format
|
|
47
|
-
|
|
48
|
-
The artifact MUST follow this EXACT markdown format (this is critical for parsing):
|
|
1
|
+
const RESEARCH_SYSTEM_PROMPT = `<role>
|
|
2
|
+
PostHog AI Research Agent — analyze codebases to understand implementation context and identify areas of focus for development tasks.
|
|
3
|
+
</role>
|
|
4
|
+
|
|
5
|
+
<constraints>
|
|
6
|
+
- Read-only: analyze files, search code, explore structure
|
|
7
|
+
- No modifications or code changes
|
|
8
|
+
</constraints>
|
|
9
|
+
|
|
10
|
+
<objective>
|
|
11
|
+
Your PRIMARY goal is to understand the codebase thoroughly and provide context for the planning phase.
|
|
12
|
+
|
|
13
|
+
ONLY generate clarifying questions if:
|
|
14
|
+
- The task description is genuinely vague or ambiguous
|
|
15
|
+
- There are multiple valid architectural approaches with significant tradeoffs
|
|
16
|
+
- Critical information is missing that cannot be inferred from the codebase
|
|
17
|
+
|
|
18
|
+
DO NOT ask questions like "how should I fix this" or "what approach do you prefer" — that defeats the purpose of autonomous task execution. The user has already specified what they want done.
|
|
19
|
+
</objective>
|
|
20
|
+
|
|
21
|
+
<process>
|
|
22
|
+
1. Explore repository structure and identify relevant files/components
|
|
23
|
+
2. Understand existing patterns, conventions, and dependencies
|
|
24
|
+
3. Locate similar implementations or related code
|
|
25
|
+
4. Identify the key areas of the codebase that will be affected
|
|
26
|
+
5. Document your findings to provide context for planning
|
|
27
|
+
6. ONLY if genuinely needed: generate 2-3 specific clarification questions
|
|
28
|
+
</process>
|
|
29
|
+
|
|
30
|
+
<output_format>
|
|
31
|
+
Output ONLY the markdown artifact with no preamble:
|
|
49
32
|
|
|
50
33
|
\`\`\`markdown
|
|
51
|
-
# Research
|
|
52
|
-
|
|
53
|
-
Based on my analysis of the codebase, here are the key questions to guide implementation:
|
|
54
|
-
|
|
55
|
-
## Question 1: [Question text - be specific and clear]
|
|
34
|
+
# Research Findings
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- b) [Alternative approach based on another pattern - reference specific files/components]
|
|
60
|
-
- c) Something else (please specify)
|
|
36
|
+
## Codebase Analysis
|
|
37
|
+
[Brief summary of relevant code structure, patterns, and files]
|
|
61
38
|
|
|
62
|
-
##
|
|
39
|
+
## Key Areas of Focus
|
|
40
|
+
[List specific files/components that need modification]
|
|
63
41
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- b) [Alternative with specific code references]
|
|
67
|
-
- c) Something else (please specify)
|
|
42
|
+
## Implementation Context
|
|
43
|
+
[Important patterns, dependencies, or constraints found in the code]
|
|
68
44
|
|
|
69
|
-
##
|
|
45
|
+
## Clarifying Questions
|
|
46
|
+
[ONLY include this section if it will increase the quality of the plan]
|
|
70
47
|
|
|
48
|
+
## Question 1: [Specific architectural decision]
|
|
71
49
|
**Options:**
|
|
72
|
-
- a) [
|
|
73
|
-
- b) [Alternative]
|
|
50
|
+
- a) [Concrete option with file references]
|
|
51
|
+
- b) [Alternative with file references]
|
|
74
52
|
- c) Something else (please specify)
|
|
75
53
|
\`\`\`
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
55
|
+
Format requirements:
|
|
56
|
+
- Use "## Question N:" for question headers (h2)
|
|
57
|
+
- Follow with "**Options:**" on its own line
|
|
58
|
+
- Start options with "- a)", "- b)", "- c)"
|
|
59
|
+
- Always include "c) Something else (please specify)"
|
|
60
|
+
- Max 4 questions total
|
|
61
|
+
</output_format>
|
|
62
|
+
|
|
63
|
+
<examples>
|
|
64
|
+
<good_example>
|
|
65
|
+
Task: "Fix authentication bug in login flow"
|
|
66
|
+
Output: Research findings showing auth flow files, patterns used, NO questions needed
|
|
67
|
+
</good_example>
|
|
68
|
+
|
|
69
|
+
<bad_example>
|
|
70
|
+
Task: "Fix authentication bug"
|
|
71
|
+
Output: "How should I fix the authentication? a) Fix it one way b) Fix it another way"
|
|
72
|
+
Reason: Don't ask HOW to do the task — that's what the agent is for
|
|
73
|
+
</bad_example>
|
|
74
|
+
|
|
75
|
+
<good_example>
|
|
76
|
+
Task: "Add caching to API endpoints"
|
|
77
|
+
Output: Research showing existing cache implementations, question about cache backend choice IF multiple production systems are already in use
|
|
78
|
+
</good_example>
|
|
79
|
+
</examples>`;
|
|
100
80
|
|
|
101
81
|
export { RESEARCH_SYSTEM_PROMPT };
|
|
102
82
|
//# sourceMappingURL=research.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research.js","sources":["../../../src/agents/research.ts"],"sourcesContent":["export const RESEARCH_SYSTEM_PROMPT =
|
|
1
|
+
{"version":3,"file":"research.js","sources":["../../../src/agents/research.ts"],"sourcesContent":["export const RESEARCH_SYSTEM_PROMPT = `<role>\nPostHog AI Research Agent — analyze codebases to understand implementation context and identify areas of focus for development tasks.\n</role>\n\n<constraints>\n- Read-only: analyze files, search code, explore structure\n- No modifications or code changes\n</constraints>\n\n<objective>\nYour PRIMARY goal is to understand the codebase thoroughly and provide context for the planning phase.\n\nONLY generate clarifying questions if:\n- The task description is genuinely vague or ambiguous\n- There are multiple valid architectural approaches with significant tradeoffs\n- Critical information is missing that cannot be inferred from the codebase\n\nDO NOT ask questions like \"how should I fix this\" or \"what approach do you prefer\" — that defeats the purpose of autonomous task execution. The user has already specified what they want done.\n</objective>\n\n<process>\n1. Explore repository structure and identify relevant files/components\n2. Understand existing patterns, conventions, and dependencies\n3. Locate similar implementations or related code\n4. Identify the key areas of the codebase that will be affected\n5. Document your findings to provide context for planning\n6. ONLY if genuinely needed: generate 2-3 specific clarification questions\n</process>\n\n<output_format>\nOutput ONLY the markdown artifact with no preamble:\n\n\\`\\`\\`markdown\n# Research Findings\n\n## Codebase Analysis\n[Brief summary of relevant code structure, patterns, and files]\n\n## Key Areas of Focus\n[List specific files/components that need modification]\n\n## Implementation Context\n[Important patterns, dependencies, or constraints found in the code]\n\n## Clarifying Questions\n[ONLY include this section if it will increase the quality of the plan]\n\n## Question 1: [Specific architectural decision]\n**Options:**\n- a) [Concrete option with file references]\n- b) [Alternative with file references]\n- c) Something else (please specify)\n\\`\\`\\`\n\nFormat requirements:\n- Use \"## Question N:\" for question headers (h2)\n- Follow with \"**Options:**\" on its own line\n- Start options with \"- a)\", \"- b)\", \"- c)\"\n- Always include \"c) Something else (please specify)\"\n- Max 4 questions total\n</output_format>\n\n<examples>\n<good_example>\nTask: \"Fix authentication bug in login flow\"\nOutput: Research findings showing auth flow files, patterns used, NO questions needed\n</good_example>\n\n<bad_example>\nTask: \"Fix authentication bug\"\nOutput: \"How should I fix the authentication? a) Fix it one way b) Fix it another way\"\nReason: Don't ask HOW to do the task — that's what the agent is for\n</bad_example>\n\n<good_example>\nTask: \"Add caching to API endpoints\"\nOutput: Research showing existing cache implementations, question about cache backend choice IF multiple production systems are already in use\n</good_example>\n</examples>`;\n\n"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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,WAAW,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;
|
|
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,WAAW,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;IA2DzE,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4EzE,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA0EjF"}
|
|
@@ -168,35 +168,43 @@ class PromptBuilder {
|
|
|
168
168
|
async buildResearchPrompt(task, repositoryPath) {
|
|
169
169
|
// Process file references in description
|
|
170
170
|
const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(task.description, repositoryPath);
|
|
171
|
-
// Process URL references in description
|
|
171
|
+
// Process URL references in description
|
|
172
172
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(descriptionAfterFiles);
|
|
173
|
-
let prompt = '';
|
|
174
|
-
prompt +=
|
|
173
|
+
let prompt = '<task>\n';
|
|
174
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
175
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
175
176
|
if (task.primary_repository) {
|
|
176
|
-
prompt +=
|
|
177
|
+
prompt += `<repository>${task.primary_repository}</repository>\n`;
|
|
177
178
|
}
|
|
179
|
+
prompt += '</task>\n';
|
|
178
180
|
// Add referenced files from @ mentions
|
|
179
181
|
if (referencedFiles.length > 0) {
|
|
180
|
-
prompt +=
|
|
182
|
+
prompt += '\n<referenced_files>\n';
|
|
181
183
|
for (const file of referencedFiles) {
|
|
182
|
-
prompt +=
|
|
184
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
183
185
|
}
|
|
186
|
+
prompt += '</referenced_files>\n';
|
|
184
187
|
}
|
|
185
188
|
// Add referenced resources from URL mentions
|
|
186
189
|
if (referencedResources.length > 0) {
|
|
187
|
-
prompt +=
|
|
190
|
+
prompt += '\n<referenced_resources>\n';
|
|
188
191
|
for (const resource of referencedResources) {
|
|
189
|
-
prompt +=
|
|
192
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
193
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
194
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
195
|
+
prompt += '</resource>\n';
|
|
190
196
|
}
|
|
197
|
+
prompt += '</referenced_resources>\n';
|
|
191
198
|
}
|
|
192
199
|
try {
|
|
193
200
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
194
201
|
const contextFiles = taskFiles.filter((f) => f.type === 'context' || f.type === 'reference');
|
|
195
202
|
if (contextFiles.length > 0) {
|
|
196
|
-
prompt +=
|
|
203
|
+
prompt += '\n<supporting_files>\n';
|
|
197
204
|
for (const file of contextFiles) {
|
|
198
|
-
prompt +=
|
|
205
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
199
206
|
}
|
|
207
|
+
prompt += '</supporting_files>\n';
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
catch (error) {
|
|
@@ -207,35 +215,43 @@ class PromptBuilder {
|
|
|
207
215
|
async buildPlanningPrompt(task, repositoryPath) {
|
|
208
216
|
// Process file references in description
|
|
209
217
|
const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(task.description, repositoryPath);
|
|
210
|
-
// Process URL references in description
|
|
218
|
+
// Process URL references in description
|
|
211
219
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(descriptionAfterFiles);
|
|
212
|
-
let prompt = '';
|
|
213
|
-
prompt +=
|
|
220
|
+
let prompt = '<task>\n';
|
|
221
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
222
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
214
223
|
if (task.primary_repository) {
|
|
215
|
-
prompt +=
|
|
224
|
+
prompt += `<repository>${task.primary_repository}</repository>\n`;
|
|
216
225
|
}
|
|
226
|
+
prompt += '</task>\n';
|
|
217
227
|
// Add referenced files from @ mentions
|
|
218
228
|
if (referencedFiles.length > 0) {
|
|
219
|
-
prompt +=
|
|
229
|
+
prompt += '\n<referenced_files>\n';
|
|
220
230
|
for (const file of referencedFiles) {
|
|
221
|
-
prompt +=
|
|
231
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
222
232
|
}
|
|
233
|
+
prompt += '</referenced_files>\n';
|
|
223
234
|
}
|
|
224
235
|
// Add referenced resources from URL mentions
|
|
225
236
|
if (referencedResources.length > 0) {
|
|
226
|
-
prompt +=
|
|
237
|
+
prompt += '\n<referenced_resources>\n';
|
|
227
238
|
for (const resource of referencedResources) {
|
|
228
|
-
prompt +=
|
|
239
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
240
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
241
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
242
|
+
prompt += '</resource>\n';
|
|
229
243
|
}
|
|
244
|
+
prompt += '</referenced_resources>\n';
|
|
230
245
|
}
|
|
231
246
|
try {
|
|
232
247
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
233
248
|
const contextFiles = taskFiles.filter((f) => f.type === 'context' || f.type === 'reference');
|
|
234
249
|
if (contextFiles.length > 0) {
|
|
235
|
-
prompt +=
|
|
250
|
+
prompt += '\n<supporting_files>\n';
|
|
236
251
|
for (const file of contextFiles) {
|
|
237
|
-
prompt +=
|
|
252
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
238
253
|
}
|
|
254
|
+
prompt += '</supporting_files>\n';
|
|
239
255
|
}
|
|
240
256
|
}
|
|
241
257
|
catch (error) {
|
|
@@ -249,57 +265,74 @@ class PromptBuilder {
|
|
|
249
265
|
repository: (task.primary_repository || ''),
|
|
250
266
|
};
|
|
251
267
|
const planTemplate = await this.generatePlanTemplate(templateVariables);
|
|
252
|
-
prompt +=
|
|
268
|
+
prompt += '\n<instructions>\n';
|
|
269
|
+
prompt += 'Analyze the codebase and create a detailed implementation plan. Use the template structure below, filling each section with specific, actionable information.\n';
|
|
270
|
+
prompt += '</instructions>\n\n';
|
|
271
|
+
prompt += '<plan_template>\n';
|
|
272
|
+
prompt += planTemplate;
|
|
273
|
+
prompt += '\n</plan_template>';
|
|
253
274
|
return prompt;
|
|
254
275
|
}
|
|
255
276
|
async buildExecutionPrompt(task, repositoryPath) {
|
|
256
277
|
// Process file references in description
|
|
257
278
|
const { description: descriptionAfterFiles, referencedFiles } = await this.processFileReferences(task.description, repositoryPath);
|
|
258
|
-
// Process URL references in description
|
|
279
|
+
// Process URL references in description
|
|
259
280
|
const { description: processedDescription, referencedResources } = await this.processUrlReferences(descriptionAfterFiles);
|
|
260
|
-
let prompt = '';
|
|
261
|
-
prompt +=
|
|
281
|
+
let prompt = '<task>\n';
|
|
282
|
+
prompt += `<title>${task.title}</title>\n`;
|
|
283
|
+
prompt += `<description>${processedDescription}</description>\n`;
|
|
262
284
|
if (task.primary_repository) {
|
|
263
|
-
prompt +=
|
|
285
|
+
prompt += `<repository>${task.primary_repository}</repository>\n`;
|
|
264
286
|
}
|
|
287
|
+
prompt += '</task>\n';
|
|
265
288
|
// Add referenced files from @ mentions
|
|
266
289
|
if (referencedFiles.length > 0) {
|
|
267
|
-
prompt +=
|
|
290
|
+
prompt += '\n<referenced_files>\n';
|
|
268
291
|
for (const file of referencedFiles) {
|
|
269
|
-
prompt +=
|
|
292
|
+
prompt += `<file path="${file.path}">\n\`\`\`\n${file.content}\n\`\`\`\n</file>\n`;
|
|
270
293
|
}
|
|
294
|
+
prompt += '</referenced_files>\n';
|
|
271
295
|
}
|
|
272
296
|
// Add referenced resources from URL mentions
|
|
273
297
|
if (referencedResources.length > 0) {
|
|
274
|
-
prompt +=
|
|
298
|
+
prompt += '\n<referenced_resources>\n';
|
|
275
299
|
for (const resource of referencedResources) {
|
|
276
|
-
prompt +=
|
|
300
|
+
prompt += `<resource type="${resource.type}" url="${resource.url}">\n`;
|
|
301
|
+
prompt += `<title>${resource.title}</title>\n`;
|
|
302
|
+
prompt += `<content>${resource.content}</content>\n`;
|
|
303
|
+
prompt += '</resource>\n';
|
|
277
304
|
}
|
|
305
|
+
prompt += '</referenced_resources>\n';
|
|
278
306
|
}
|
|
279
307
|
try {
|
|
280
308
|
const taskFiles = await this.getTaskFiles(task.id);
|
|
281
309
|
const hasPlan = taskFiles.some((f) => f.type === 'plan');
|
|
282
310
|
if (taskFiles.length > 0) {
|
|
283
|
-
prompt +=
|
|
311
|
+
prompt += '\n<context>\n';
|
|
284
312
|
for (const file of taskFiles) {
|
|
285
313
|
if (file.type === 'plan') {
|
|
286
|
-
prompt +=
|
|
314
|
+
prompt += `<plan>\n${file.content}\n</plan>\n`;
|
|
287
315
|
}
|
|
288
316
|
else {
|
|
289
|
-
prompt +=
|
|
317
|
+
prompt += `<file name="${file.name}" type="${file.type}">\n${file.content}\n</file>\n`;
|
|
290
318
|
}
|
|
291
319
|
}
|
|
320
|
+
prompt += '</context>\n';
|
|
292
321
|
}
|
|
322
|
+
prompt += '\n<instructions>\n';
|
|
293
323
|
if (hasPlan) {
|
|
294
|
-
prompt +=
|
|
324
|
+
prompt += 'Implement the changes described in the execution plan. Follow the plan step-by-step and make the necessary file modifications.\n';
|
|
295
325
|
}
|
|
296
326
|
else {
|
|
297
|
-
prompt +=
|
|
327
|
+
prompt += 'Implement the changes described in the task. Make the necessary file modifications to complete the task.\n';
|
|
298
328
|
}
|
|
329
|
+
prompt += '</instructions>';
|
|
299
330
|
}
|
|
300
331
|
catch (error) {
|
|
301
332
|
this.logger.debug('No supporting files found for execution', { taskId: task.id });
|
|
302
|
-
prompt +=
|
|
333
|
+
prompt += '\n<instructions>\n';
|
|
334
|
+
prompt += 'Implement the changes described in the task.\n';
|
|
335
|
+
prompt += '</instructions>';
|
|
303
336
|
}
|
|
304
337
|
return prompt;
|
|
305
338
|
}
|