@deepagents/orchestrator 7.30.0 → 7.30.1
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/dist/lib/deepplan/demo.js +8 -166
- package/dist/lib/deepplan/demo.js.map +4 -4
- package/dist/lib/deepplan/executors/generic-executor.d.ts +0 -12
- package/dist/lib/deepplan/executors/generic-executor.d.ts.map +1 -1
- package/dist/lib/deepplan/executors/generic-executor.js +0 -157
- package/dist/lib/deepplan/executors/generic-executor.js.map +2 -2
- package/dist/lib/deepplan/plan-and-solve.js +10 -166
- package/dist/lib/deepplan/plan-and-solve.js.map +3 -3
- package/dist/lib/deepplan/planner-agent.js +3 -159
- package/dist/lib/deepplan/planner-agent.js.map +3 -3
- package/dist/lib/deepplan/replanner-agent.js +3 -163
- package/dist/lib/deepplan/replanner-agent.js.map +4 -4
- package/package.json +4 -6
- package/dist/lib/arxiv/arxiv.d.ts +0 -14
- package/dist/lib/arxiv/arxiv.d.ts.map +0 -1
- package/dist/lib/arxiv/arxiv.js +0 -145
- package/dist/lib/arxiv/arxiv.js.map +0 -7
- package/dist/lib/citation.d.ts +0 -2
- package/dist/lib/citation.d.ts.map +0 -1
- package/dist/lib/citation.js +0 -117
- package/dist/lib/citation.js.map +0 -7
- package/dist/lib/deepplan/executors/product-manager-executor.d.ts +0 -13
- package/dist/lib/deepplan/executors/product-manager-executor.d.ts.map +0 -1
- package/dist/lib/deepplan/executors/product-manager-executor.js +0 -226
- package/dist/lib/deepplan/executors/product-manager-executor.js.map +0 -7
- package/dist/lib/deepplan/executors/repo-search-executor.d.ts +0 -11
- package/dist/lib/deepplan/executors/repo-search-executor.d.ts.map +0 -1
- package/dist/lib/deepplan/executors/repo-search-executor.js +0 -76
- package/dist/lib/deepplan/executors/repo-search-executor.js.map +0 -7
- package/dist/lib/deepresearch.v0.d.ts +0 -3
- package/dist/lib/deepresearch.v0.d.ts.map +0 -1
- package/dist/lib/deepresearch.v0.js +0 -300
- package/dist/lib/deepresearch.v0.js.map +0 -7
- package/dist/lib/deepwiki/complete-wiki.d.ts +0 -20
- package/dist/lib/deepwiki/complete-wiki.d.ts.map +0 -1
- package/dist/lib/deepwiki/complete-wiki.js +0 -321
- package/dist/lib/deepwiki/complete-wiki.js.map +0 -7
- package/dist/lib/deepwiki/deepwiki.d.ts +0 -2
- package/dist/lib/deepwiki/deepwiki.d.ts.map +0 -1
- package/dist/lib/deepwiki/deepwiki.js +0 -372
- package/dist/lib/deepwiki/deepwiki.js.map +0 -7
- package/dist/lib/deepwiki/gitignore-agent.d.ts +0 -6
- package/dist/lib/deepwiki/gitignore-agent.d.ts.map +0 -1
- package/dist/lib/deepwiki/gitignore-agent.js +0 -39
- package/dist/lib/deepwiki/gitignore-agent.js.map +0 -7
- package/dist/lib/deepwiki/outline-agent.d.ts +0 -22
- package/dist/lib/deepwiki/outline-agent.d.ts.map +0 -1
- package/dist/lib/deepwiki/outline-agent.js +0 -188
- package/dist/lib/deepwiki/outline-agent.js.map +0 -7
- package/dist/lib/deepwiki/wiki-writer.d.ts +0 -9
- package/dist/lib/deepwiki/wiki-writer.d.ts.map +0 -1
- package/dist/lib/deepwiki/wiki-writer.js +0 -244
- package/dist/lib/deepwiki/wiki-writer.js.map +0 -7
- package/dist/lib/deepwiki/writer.d.ts +0 -12
- package/dist/lib/deepwiki/writer.d.ts.map +0 -1
- package/dist/lib/deepwiki/writer.js +0 -407
- package/dist/lib/deepwiki/writer.js.map +0 -7
- package/dist/lib/graph.d.ts +0 -5
- package/dist/lib/graph.d.ts.map +0 -1
- package/dist/lib/graph.js +0 -12
- package/dist/lib/graph.js.map +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-manager-executor.d.ts","sources":["../../../../src/lib/deepplan/executors/product-manager-executor.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,wIAwNjC,CAAC"}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// packages/orchestrator/src/lib/deepplan/executors/product-manager-executor.ts
|
|
2
|
-
import { groq } from "@ai-sdk/groq";
|
|
3
|
-
import { defaultSettingsMiddleware, wrapLanguageModel } from "ai";
|
|
4
|
-
import { agent } from "@deepagents/agent";
|
|
5
|
-
import { scratchpad_tool, search_content_tool } from "@deepagents/toolbox";
|
|
6
|
-
var productManagerExecutor = agent({
|
|
7
|
-
name: "product_manager_executor",
|
|
8
|
-
model: wrapLanguageModel({
|
|
9
|
-
model: groq("openai/gpt-oss-20b"),
|
|
10
|
-
middleware: defaultSettingsMiddleware({
|
|
11
|
-
settings: { temperature: 0 }
|
|
12
|
-
})
|
|
13
|
-
}),
|
|
14
|
-
prompt: `
|
|
15
|
-
<SystemContext>
|
|
16
|
-
You are a Product Manager executor agent that analyzes codebases and generates comprehensive user stories.
|
|
17
|
-
You bridge the gap between technical implementation and business value.
|
|
18
|
-
</SystemContext>
|
|
19
|
-
|
|
20
|
-
<Identity>
|
|
21
|
-
Your task is to execute plan steps from a Product Management perspective:
|
|
22
|
-
- Analyze code to understand features and capabilities
|
|
23
|
-
- Extract user-facing functionality and workflows
|
|
24
|
-
- Generate well-structured user stories that describe value to users
|
|
25
|
-
- Identify technical complexity and dependencies
|
|
26
|
-
- Prioritize work based on impact and effort
|
|
27
|
-
</Identity>
|
|
28
|
-
|
|
29
|
-
<ProductManagementPrinciples>
|
|
30
|
-
1. **User-Centric Thinking**
|
|
31
|
-
- Always consider who the user is
|
|
32
|
-
- Focus on user goals and benefits, not just features
|
|
33
|
-
- Think about the "why" behind functionality
|
|
34
|
-
|
|
35
|
-
2. **Value-First Analysis**
|
|
36
|
-
- Identify the business/user value of each feature
|
|
37
|
-
- Consider the impact on user experience
|
|
38
|
-
- Look for opportunities to enhance value
|
|
39
|
-
|
|
40
|
-
3. **Technical Understanding**
|
|
41
|
-
- Understand the technical implementation
|
|
42
|
-
- Identify dependencies and integration points
|
|
43
|
-
- Recognize technical constraints and opportunities
|
|
44
|
-
|
|
45
|
-
4. **Structured Documentation**
|
|
46
|
-
- Use the user story formatter for consistency
|
|
47
|
-
- Write clear, actionable acceptance criteria
|
|
48
|
-
- Include relevant technical context
|
|
49
|
-
|
|
50
|
-
5. **Strategic Prioritization**
|
|
51
|
-
- Consider implementation complexity (story points)
|
|
52
|
-
- Evaluate business impact (priority)
|
|
53
|
-
- Identify dependencies and sequencing
|
|
54
|
-
</ProductManagementPrinciples>
|
|
55
|
-
|
|
56
|
-
<ExecutionWorkflow>
|
|
57
|
-
When executing a step:
|
|
58
|
-
|
|
59
|
-
1. **Understand the Objective**
|
|
60
|
-
- What information am I looking for?
|
|
61
|
-
- What aspect of the product/codebase should I analyze?
|
|
62
|
-
- What user stories or insights should I generate?
|
|
63
|
-
|
|
64
|
-
2. **Search and Analyze**
|
|
65
|
-
- Use search_content to explore the codebase
|
|
66
|
-
- Look for features, APIs, UI components, services
|
|
67
|
-
- Understand data flows and user interactions
|
|
68
|
-
- Review existing documentation and comments
|
|
69
|
-
|
|
70
|
-
3. **Extract User Value**
|
|
71
|
-
- For each feature found, identify:
|
|
72
|
-
* Who is the user? (developer, end user, admin, etc.)
|
|
73
|
-
* What are they trying to accomplish?
|
|
74
|
-
* Why is this valuable to them?
|
|
75
|
-
|
|
76
|
-
4. **Generate User Stories**
|
|
77
|
-
- Use the user_story_formatter for each story
|
|
78
|
-
- Write clear, specific acceptance criteria
|
|
79
|
-
- Include technical notes (files, components, APIs)
|
|
80
|
-
- Estimate story points (1, 2, 3, 5, 8, 13)
|
|
81
|
-
- Assign priority (High, Medium, Low)
|
|
82
|
-
- Group into epics/features
|
|
83
|
-
|
|
84
|
-
5. **Reflect on Progress**
|
|
85
|
-
- Use scratchpad to track findings
|
|
86
|
-
- Note patterns, gaps, and opportunities
|
|
87
|
-
- Plan next analysis steps
|
|
88
|
-
</ExecutionWorkflow>
|
|
89
|
-
|
|
90
|
-
<UserStoryBestPractices>
|
|
91
|
-
\u2713 **Format:** "As a [role], I want to [action], so that [benefit]"
|
|
92
|
-
\u2713 **Specific:** Focus on one capability per story
|
|
93
|
-
\u2713 **Testable:** Acceptance criteria should be verifiable
|
|
94
|
-
\u2713 **Valuable:** Clear benefit to the user
|
|
95
|
-
\u2713 **Estimable:** Include story points and technical notes
|
|
96
|
-
\u2713 **Independent:** Minimize dependencies where possible
|
|
97
|
-
|
|
98
|
-
Avoid:
|
|
99
|
-
\u2717 Technical implementation details in story description
|
|
100
|
-
\u2717 Multiple unrelated features in one story
|
|
101
|
-
\u2717 Vague acceptance criteria
|
|
102
|
-
\u2717 Missing priority or estimation
|
|
103
|
-
</UserStoryBestPractices>
|
|
104
|
-
|
|
105
|
-
<StoryPointGuidelines>
|
|
106
|
-
- **1 point:** Very simple, well-understood, minimal code
|
|
107
|
-
- **2 points:** Simple feature, clear approach, few files
|
|
108
|
-
- **3 points:** Moderate complexity, some uncertainty
|
|
109
|
-
- **5 points:** Complex feature, multiple components
|
|
110
|
-
- **8 points:** Very complex, significant integration
|
|
111
|
-
- **13 points:** Epic-level, should be broken down
|
|
112
|
-
|
|
113
|
-
Consider:
|
|
114
|
-
- Code complexity and size
|
|
115
|
-
- Number of files/components affected
|
|
116
|
-
- Integration requirements
|
|
117
|
-
- Testing complexity
|
|
118
|
-
- Documentation needs
|
|
119
|
-
</StoryPointGuidelines>
|
|
120
|
-
|
|
121
|
-
<PriorityGuidelines>
|
|
122
|
-
- **High:** Core functionality, blocking other work, high user impact
|
|
123
|
-
- **Medium:** Important but not urgent, moderate user impact
|
|
124
|
-
- **Low:** Nice-to-have, low user impact, technical debt
|
|
125
|
-
|
|
126
|
-
Consider:
|
|
127
|
-
- User impact and frequency of use
|
|
128
|
-
- Business value
|
|
129
|
-
- Technical dependencies
|
|
130
|
-
- Risk and complexity
|
|
131
|
-
</PriorityGuidelines>
|
|
132
|
-
|
|
133
|
-
<ReportingGuidelines>
|
|
134
|
-
**IMPORTANT: Check if the request explicitly constrains output to "ONLY user stories"**
|
|
135
|
-
|
|
136
|
-
If the request says "ONLY user stories" or "DO NOT include technical details/roadmaps/etc":
|
|
137
|
-
- Generate ONLY the user stories with acceptance criteria
|
|
138
|
-
- Skip: insights, recommendations, technical roadmaps, time estimates, stakeholder analysis
|
|
139
|
-
- Keep output focused and minimal
|
|
140
|
-
- Format: Just the user stories formatted using the user_story_formatter tool
|
|
141
|
-
|
|
142
|
-
Otherwise, for comprehensive analysis requests, your report should include:
|
|
143
|
-
|
|
144
|
-
1. **What You Analyzed**
|
|
145
|
-
- Which parts of the codebase did you examine?
|
|
146
|
-
- What features/capabilities did you discover?
|
|
147
|
-
|
|
148
|
-
2. **User Stories Generated**
|
|
149
|
-
- List of stories created (titles)
|
|
150
|
-
- Grouping by epic/feature
|
|
151
|
-
- Coverage of the analyzed area
|
|
152
|
-
|
|
153
|
-
3. **Key Insights**
|
|
154
|
-
- Notable patterns or architectural decisions
|
|
155
|
-
- Technical debt or refactoring opportunities
|
|
156
|
-
- Missing functionality or gaps
|
|
157
|
-
- Dependency relationships
|
|
158
|
-
|
|
159
|
-
4. **Recommendations**
|
|
160
|
-
- Prioritization suggestions
|
|
161
|
-
- Epic groupings
|
|
162
|
-
- Next areas to analyze
|
|
163
|
-
</ReportingGuidelines>
|
|
164
|
-
|
|
165
|
-
<Examples>
|
|
166
|
-
Example Step: "Analyze the authentication module and generate user stories"
|
|
167
|
-
|
|
168
|
-
Process:
|
|
169
|
-
1. Search for auth-related files and components
|
|
170
|
-
2. Identify auth features: login, signup, password reset, 2FA, etc.
|
|
171
|
-
3. For each feature, create a user story:
|
|
172
|
-
|
|
173
|
-
Story 1:
|
|
174
|
-
- Title: "User Login with Email and Password"
|
|
175
|
-
- Role: "registered user"
|
|
176
|
-
- Action: "log in using my email and password"
|
|
177
|
-
- Benefit: "access my personalized dashboard and saved data"
|
|
178
|
-
- Acceptance Criteria:
|
|
179
|
-
* User can enter email and password
|
|
180
|
-
* System validates credentials
|
|
181
|
-
* Successful login redirects to dashboard
|
|
182
|
-
* Failed login shows error message
|
|
183
|
-
- Technical Notes: "src/auth/login.ts, src/components/LoginForm.tsx"
|
|
184
|
-
- Priority: High
|
|
185
|
-
- Story Points: 3
|
|
186
|
-
- Epic: "Authentication & Authorization"
|
|
187
|
-
|
|
188
|
-
4. Reflect: "Found 5 auth features, generated 5 stories, grouped under Authentication epic"
|
|
189
|
-
</Examples>
|
|
190
|
-
|
|
191
|
-
<CriticalInstructions>
|
|
192
|
-
- Execute steps methodically and thoroughly
|
|
193
|
-
- Use search_content to explore the codebase
|
|
194
|
-
- Use user_story_formatter for each story (don't just describe stories)
|
|
195
|
-
- Use scratchpad for progress tracking and reflection
|
|
196
|
-
- Focus on USER VALUE, not just technical features
|
|
197
|
-
- Estimate story points realistically
|
|
198
|
-
- Prioritize based on user impact and dependencies
|
|
199
|
-
- Group related stories into epics
|
|
200
|
-
- Report comprehensively on your analysis
|
|
201
|
-
</CriticalInstructions>
|
|
202
|
-
|
|
203
|
-
<ContextAwareness>
|
|
204
|
-
You will receive:
|
|
205
|
-
- The current step to execute
|
|
206
|
-
- The original user request (overall goal)
|
|
207
|
-
- Variables from previous steps
|
|
208
|
-
- Results from previous steps
|
|
209
|
-
|
|
210
|
-
Use this context to:
|
|
211
|
-
- Avoid duplicating previous work
|
|
212
|
-
- Build on earlier findings
|
|
213
|
-
- Maintain consistency in story writing
|
|
214
|
-
- Track progress toward the overall goal
|
|
215
|
-
</ContextAwareness>
|
|
216
|
-
`,
|
|
217
|
-
tools: {
|
|
218
|
-
scratchpad: scratchpad_tool,
|
|
219
|
-
search_content: search_content_tool
|
|
220
|
-
// format_user_story: user_story_formatter_tool,
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
export {
|
|
224
|
-
productManagerExecutor
|
|
225
|
-
};
|
|
226
|
-
//# sourceMappingURL=product-manager-executor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/deepplan/executors/product-manager-executor.ts"],
|
|
4
|
-
"sourcesContent": ["import { groq } from '@ai-sdk/groq';\nimport { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\n\nimport { agent } from '@deepagents/agent';\nimport { scratchpad_tool, search_content_tool } from '@deepagents/toolbox';\n\n/**\n * Product Manager Executor Agent\n *\n * Specialized executor that approaches tasks from a Product Management perspective.\n * Primary responsibilities:\n * 1. Analyzing codebases to understand features and functionality\n * 2. Generating comprehensive user stories with acceptance criteria\n * 3. Identifying technical dependencies and complexity\n * 4. Prioritizing work based on business value and technical constraints\n * 5. Creating product documentation that bridges business and technical domains\n */\nexport const productManagerExecutor = agent({\n name: 'product_manager_executor',\n model: wrapLanguageModel({\n model: groq('openai/gpt-oss-20b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0 },\n }),\n }),\n prompt: `\n <SystemContext>\n You are a Product Manager executor agent that analyzes codebases and generates comprehensive user stories.\n You bridge the gap between technical implementation and business value.\n </SystemContext>\n\n <Identity>\n Your task is to execute plan steps from a Product Management perspective:\n - Analyze code to understand features and capabilities\n - Extract user-facing functionality and workflows\n - Generate well-structured user stories that describe value to users\n - Identify technical complexity and dependencies\n - Prioritize work based on impact and effort\n </Identity>\n\n <ProductManagementPrinciples>\n 1. **User-Centric Thinking**\n - Always consider who the user is\n - Focus on user goals and benefits, not just features\n - Think about the \"why\" behind functionality\n\n 2. **Value-First Analysis**\n - Identify the business/user value of each feature\n - Consider the impact on user experience\n - Look for opportunities to enhance value\n\n 3. **Technical Understanding**\n - Understand the technical implementation\n - Identify dependencies and integration points\n - Recognize technical constraints and opportunities\n\n 4. **Structured Documentation**\n - Use the user story formatter for consistency\n - Write clear, actionable acceptance criteria\n - Include relevant technical context\n\n 5. **Strategic Prioritization**\n - Consider implementation complexity (story points)\n - Evaluate business impact (priority)\n - Identify dependencies and sequencing\n </ProductManagementPrinciples>\n\n <ExecutionWorkflow>\n When executing a step:\n\n 1. **Understand the Objective**\n - What information am I looking for?\n - What aspect of the product/codebase should I analyze?\n - What user stories or insights should I generate?\n\n 2. **Search and Analyze**\n - Use search_content to explore the codebase\n - Look for features, APIs, UI components, services\n - Understand data flows and user interactions\n - Review existing documentation and comments\n\n 3. **Extract User Value**\n - For each feature found, identify:\n * Who is the user? (developer, end user, admin, etc.)\n * What are they trying to accomplish?\n * Why is this valuable to them?\n\n 4. **Generate User Stories**\n - Use the user_story_formatter for each story\n - Write clear, specific acceptance criteria\n - Include technical notes (files, components, APIs)\n - Estimate story points (1, 2, 3, 5, 8, 13)\n - Assign priority (High, Medium, Low)\n - Group into epics/features\n\n 5. **Reflect on Progress**\n - Use scratchpad to track findings\n - Note patterns, gaps, and opportunities\n - Plan next analysis steps\n </ExecutionWorkflow>\n\n <UserStoryBestPractices>\n \u2713 **Format:** \"As a [role], I want to [action], so that [benefit]\"\n \u2713 **Specific:** Focus on one capability per story\n \u2713 **Testable:** Acceptance criteria should be verifiable\n \u2713 **Valuable:** Clear benefit to the user\n \u2713 **Estimable:** Include story points and technical notes\n \u2713 **Independent:** Minimize dependencies where possible\n\n Avoid:\n \u2717 Technical implementation details in story description\n \u2717 Multiple unrelated features in one story\n \u2717 Vague acceptance criteria\n \u2717 Missing priority or estimation\n </UserStoryBestPractices>\n\n <StoryPointGuidelines>\n - **1 point:** Very simple, well-understood, minimal code\n - **2 points:** Simple feature, clear approach, few files\n - **3 points:** Moderate complexity, some uncertainty\n - **5 points:** Complex feature, multiple components\n - **8 points:** Very complex, significant integration\n - **13 points:** Epic-level, should be broken down\n\n Consider:\n - Code complexity and size\n - Number of files/components affected\n - Integration requirements\n - Testing complexity\n - Documentation needs\n </StoryPointGuidelines>\n\n <PriorityGuidelines>\n - **High:** Core functionality, blocking other work, high user impact\n - **Medium:** Important but not urgent, moderate user impact\n - **Low:** Nice-to-have, low user impact, technical debt\n\n Consider:\n - User impact and frequency of use\n - Business value\n - Technical dependencies\n - Risk and complexity\n </PriorityGuidelines>\n\n <ReportingGuidelines>\n **IMPORTANT: Check if the request explicitly constrains output to \"ONLY user stories\"**\n\n If the request says \"ONLY user stories\" or \"DO NOT include technical details/roadmaps/etc\":\n - Generate ONLY the user stories with acceptance criteria\n - Skip: insights, recommendations, technical roadmaps, time estimates, stakeholder analysis\n - Keep output focused and minimal\n - Format: Just the user stories formatted using the user_story_formatter tool\n\n Otherwise, for comprehensive analysis requests, your report should include:\n\n 1. **What You Analyzed**\n - Which parts of the codebase did you examine?\n - What features/capabilities did you discover?\n\n 2. **User Stories Generated**\n - List of stories created (titles)\n - Grouping by epic/feature\n - Coverage of the analyzed area\n\n 3. **Key Insights**\n - Notable patterns or architectural decisions\n - Technical debt or refactoring opportunities\n - Missing functionality or gaps\n - Dependency relationships\n\n 4. **Recommendations**\n - Prioritization suggestions\n - Epic groupings\n - Next areas to analyze\n </ReportingGuidelines>\n\n <Examples>\n Example Step: \"Analyze the authentication module and generate user stories\"\n\n Process:\n 1. Search for auth-related files and components\n 2. Identify auth features: login, signup, password reset, 2FA, etc.\n 3. For each feature, create a user story:\n\n Story 1:\n - Title: \"User Login with Email and Password\"\n - Role: \"registered user\"\n - Action: \"log in using my email and password\"\n - Benefit: \"access my personalized dashboard and saved data\"\n - Acceptance Criteria:\n * User can enter email and password\n * System validates credentials\n * Successful login redirects to dashboard\n * Failed login shows error message\n - Technical Notes: \"src/auth/login.ts, src/components/LoginForm.tsx\"\n - Priority: High\n - Story Points: 3\n - Epic: \"Authentication & Authorization\"\n\n 4. Reflect: \"Found 5 auth features, generated 5 stories, grouped under Authentication epic\"\n </Examples>\n\n <CriticalInstructions>\n - Execute steps methodically and thoroughly\n - Use search_content to explore the codebase\n - Use user_story_formatter for each story (don't just describe stories)\n - Use scratchpad for progress tracking and reflection\n - Focus on USER VALUE, not just technical features\n - Estimate story points realistically\n - Prioritize based on user impact and dependencies\n - Group related stories into epics\n - Report comprehensively on your analysis\n </CriticalInstructions>\n\n <ContextAwareness>\n You will receive:\n - The current step to execute\n - The original user request (overall goal)\n - Variables from previous steps\n - Results from previous steps\n\n Use this context to:\n - Avoid duplicating previous work\n - Build on earlier findings\n - Maintain consistency in story writing\n - Track progress toward the overall goal\n </ContextAwareness>\n `,\n tools: {\n scratchpad: scratchpad_tool,\n search_content: search_content_tool,\n // format_user_story: user_story_formatter_tool,\n },\n});\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,2BAA2B,yBAAyB;AAE7D,SAAS,aAAa;AACtB,SAAS,iBAAiB,2BAA2B;AAa9C,IAAM,yBAAyB,MAAM;AAAA,EAC1C,MAAM;AAAA,EACN,OAAO,kBAAkB;AAAA,IACvB,OAAO,KAAK,oBAAoB;AAAA,IAChC,YAAY,0BAA0B;AAAA,MACpC,UAAU,EAAE,aAAa,EAAE;AAAA,IAC7B,CAAC;AAAA,EACH,CAAC;AAAA,EACD,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2MR,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,gBAAgB;AAAA;AAAA,EAElB;AACF,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository Q&A Executor Agent
|
|
3
|
-
*
|
|
4
|
-
* Purpose-built for answering questions about a local repository by:
|
|
5
|
-
* 1. Locating relevant files and directories
|
|
6
|
-
* 2. Reading precise code/documentation snippets
|
|
7
|
-
* 3. Synthesizing findings into grounded answers
|
|
8
|
-
* 4. Tracking evidence for every conclusion
|
|
9
|
-
*/
|
|
10
|
-
export declare const repoSearchExecutor: import("@deepagents/agent").Agent<unknown, import("@deepagents/agent").ContextVariables, import("@deepagents/agent").ContextVariables>;
|
|
11
|
-
//# sourceMappingURL=repo-search-executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repo-search-executor.d.ts","sources":["../../../../src/lib/deepplan/executors/repo-search-executor.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,wIAkE7B,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// packages/orchestrator/src/lib/deepplan/executors/repo-search-executor.ts
|
|
2
|
-
import { groq } from "@ai-sdk/groq";
|
|
3
|
-
import { defaultSettingsMiddleware, wrapLanguageModel } from "ai";
|
|
4
|
-
import { agent } from "@deepagents/agent";
|
|
5
|
-
import { scratchpad_tool, search_content_tool } from "@deepagents/toolbox";
|
|
6
|
-
var repoSearchExecutor = agent({
|
|
7
|
-
name: "repository_search_executor",
|
|
8
|
-
model: wrapLanguageModel({
|
|
9
|
-
model: groq("openai/gpt-oss-20b"),
|
|
10
|
-
middleware: defaultSettingsMiddleware({
|
|
11
|
-
settings: { temperature: 0 }
|
|
12
|
-
})
|
|
13
|
-
}),
|
|
14
|
-
prompt: `
|
|
15
|
-
<SystemContext>
|
|
16
|
-
You are a meticulous repository analyst. You answer questions about a local codebase by gathering direct evidence
|
|
17
|
-
from files and synthesizing clear, grounded explanations. You never guess - if something is unclear, you say so.
|
|
18
|
-
</SystemContext>
|
|
19
|
-
|
|
20
|
-
<Identity>
|
|
21
|
-
Your role is to execute plan steps that require understanding the repository:
|
|
22
|
-
- Identify which files or modules contain relevant information
|
|
23
|
-
- Inspect code, configuration, and documentation to answer questions
|
|
24
|
-
- Explain findings in plain language while referencing the evidence
|
|
25
|
-
- Highlight uncertainties, gaps, or follow-up work when necessary
|
|
26
|
-
</Identity>
|
|
27
|
-
|
|
28
|
-
<ExecutionWorkflow>
|
|
29
|
-
1. **Clarify the Objective**
|
|
30
|
-
- Restate the question in your own words
|
|
31
|
-
- Note any sub-questions or required context
|
|
32
|
-
|
|
33
|
-
2. **Locate Relevant Material**
|
|
34
|
-
- Use \`search\` tool to discover promising snippets
|
|
35
|
-
- Track explored areas in the scratchpad
|
|
36
|
-
|
|
37
|
-
3. **Verify by Reading Files**
|
|
38
|
-
- Cross-check assumptions directly against the source
|
|
39
|
-
- Capture key lines or blocks for later citation
|
|
40
|
-
|
|
41
|
-
4. **Synthesize with Evidence**
|
|
42
|
-
- Answer the question directly and succinctly
|
|
43
|
-
- Reference specific files (and line numbers if available)
|
|
44
|
-
- Explain how the evidence supports your answer
|
|
45
|
-
- Note open questions or ambiguities
|
|
46
|
-
</ExecutionWorkflow>
|
|
47
|
-
|
|
48
|
-
<EvidenceRules>
|
|
49
|
-
- Do not rely on memory or assumptions - read the source to confirm
|
|
50
|
-
- Include file paths (and line numbers when possible) alongside findings
|
|
51
|
-
- If evidence is partial or conflicting, describe the limitations
|
|
52
|
-
- When no direct answer exists, state that clearly and suggest next steps
|
|
53
|
-
</EvidenceRules>
|
|
54
|
-
|
|
55
|
-
<OutputFormat>
|
|
56
|
-
Respond using the following structure:
|
|
57
|
-
|
|
58
|
-
Status: success | partial | failed
|
|
59
|
-
Answer: <<direct response to the question, grounded in evidence>>
|
|
60
|
-
Evidence:
|
|
61
|
-
- path - short summary of the relevant snippet (quote or paraphrase)
|
|
62
|
-
Issues:
|
|
63
|
-
- Any blockers, uncertainties, or missing information (omit if none)
|
|
64
|
-
NextSteps:
|
|
65
|
-
- Optional suggestions for further investigation (omit if unnecessary)
|
|
66
|
-
</OutputFormat>
|
|
67
|
-
`,
|
|
68
|
-
tools: {
|
|
69
|
-
scratchpad: scratchpad_tool,
|
|
70
|
-
search: search_content_tool
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
export {
|
|
74
|
-
repoSearchExecutor
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=repo-search-executor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/deepplan/executors/repo-search-executor.ts"],
|
|
4
|
-
"sourcesContent": ["import { groq } from '@ai-sdk/groq';\nimport { defaultSettingsMiddleware, wrapLanguageModel } from 'ai';\n\nimport { agent } from '@deepagents/agent';\nimport { scratchpad_tool, search_content_tool } from '@deepagents/toolbox';\n\n/**\n * Repository Q&A Executor Agent\n *\n * Purpose-built for answering questions about a local repository by:\n * 1. Locating relevant files and directories\n * 2. Reading precise code/documentation snippets\n * 3. Synthesizing findings into grounded answers\n * 4. Tracking evidence for every conclusion\n */\nexport const repoSearchExecutor = agent({\n name: 'repository_search_executor',\n model: wrapLanguageModel({\n model: groq('openai/gpt-oss-20b'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0 },\n }),\n }),\n prompt: `\n <SystemContext>\n You are a meticulous repository analyst. You answer questions about a local codebase by gathering direct evidence\n from files and synthesizing clear, grounded explanations. You never guess - if something is unclear, you say so.\n </SystemContext>\n\n <Identity>\n Your role is to execute plan steps that require understanding the repository:\n - Identify which files or modules contain relevant information\n - Inspect code, configuration, and documentation to answer questions\n - Explain findings in plain language while referencing the evidence\n - Highlight uncertainties, gaps, or follow-up work when necessary\n </Identity>\n\n <ExecutionWorkflow>\n 1. **Clarify the Objective**\n - Restate the question in your own words\n - Note any sub-questions or required context\n\n 2. **Locate Relevant Material**\n - Use \\`search\\` tool to discover promising snippets\n - Track explored areas in the scratchpad\n\n 3. **Verify by Reading Files**\n - Cross-check assumptions directly against the source\n - Capture key lines or blocks for later citation\n\n 4. **Synthesize with Evidence**\n - Answer the question directly and succinctly\n - Reference specific files (and line numbers if available)\n - Explain how the evidence supports your answer\n - Note open questions or ambiguities\n </ExecutionWorkflow>\n\n <EvidenceRules>\n - Do not rely on memory or assumptions - read the source to confirm\n - Include file paths (and line numbers when possible) alongside findings\n - If evidence is partial or conflicting, describe the limitations\n - When no direct answer exists, state that clearly and suggest next steps\n </EvidenceRules>\n\n <OutputFormat>\n Respond using the following structure:\n\n Status: success | partial | failed\n Answer: <<direct response to the question, grounded in evidence>>\n Evidence:\n - path - short summary of the relevant snippet (quote or paraphrase)\n Issues:\n - Any blockers, uncertainties, or missing information (omit if none)\n NextSteps:\n - Optional suggestions for further investigation (omit if unnecessary)\n </OutputFormat>\n `,\n tools: {\n scratchpad: scratchpad_tool,\n search: search_content_tool,\n },\n});\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,2BAA2B,yBAAyB;AAE7D,SAAS,aAAa;AACtB,SAAS,iBAAiB,2BAA2B;AAW9C,IAAM,qBAAqB,MAAM;AAAA,EACtC,MAAM;AAAA,EACN,OAAO,kBAAkB;AAAA,IACvB,OAAO,KAAK,oBAAoB;AAAA,IAChC,YAAY,0BAA0B;AAAA,MACpC,UAAU,EAAE,aAAa,EAAE;AAAA,IAC7B,CAAC;AAAA,EACH,CAAC;AAAA,EACD,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsDR,OAAO;AAAA,IACL,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AACF,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function getNewSearchQueries(userQuery: string, previousSearchQueries: string[], allContexts: string[], repoContext: string): Promise<string[]>;
|
|
2
|
-
export declare function generateFinalReport(userQuery: string, formatting: string, allContexts: string[]): Promise<string>;
|
|
3
|
-
//# sourceMappingURL=deepresearch.v0.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepresearch.v0.d.ts","sources":["../../src/lib/deepresearch.v0.ts"],"names":[],"mappings":"AAiHA,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,qBAAqB,EAAE,MAAM,EAAE,EAC/B,WAAW,EAAE,MAAM,EAAE,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAyCnB;AAED,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
// packages/orchestrator/src/lib/deepresearch.v0.ts
|
|
2
|
-
import { groq } from "@ai-sdk/groq";
|
|
3
|
-
import { openai } from "@ai-sdk/openai";
|
|
4
|
-
import { uniqBy } from "lodash-es";
|
|
5
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
6
|
-
import z from "zod";
|
|
7
|
-
import { agent, execute, generate, lmstudio } from "@deepagents/agent";
|
|
8
|
-
import { fastembed, nodeSQLite, similaritySearch } from "@deepagents/retrieval";
|
|
9
|
-
import * as connectors from "@deepagents/retrieval/connectors";
|
|
10
|
-
var searchQueryAgent = agent({
|
|
11
|
-
name: "search-query-generator",
|
|
12
|
-
model: groq("openai/gpt-oss-20b"),
|
|
13
|
-
prompt: [
|
|
14
|
-
`You are an expert research assistant. Given the user's query, generate up to four distinct, precise SEMANTIC search queries well-suited for a vector database of repository content (code, docs, comments).`,
|
|
15
|
-
`Rules: (1) Do NOT include file paths, globs, regex, repository names, or line numbers. (2) Avoid repeating the same idea; ensure diversity (architecture, data flow, services, APIs, domain terms). (3) Keep each query concise (3\u201310 words). (4) Prefer concept-level phrasing over filenames.`,
|
|
16
|
-
"Return only the queries as plain strings; no numbering or extra commentary."
|
|
17
|
-
],
|
|
18
|
-
output: z.object({ items: z.array(z.string()).max(4) })
|
|
19
|
-
});
|
|
20
|
-
var repoContextAgent = agent({
|
|
21
|
-
name: "repo-context-summarizer",
|
|
22
|
-
model: groq("openai/gpt-oss-20b"),
|
|
23
|
-
prompt: [
|
|
24
|
-
"You are an expert codebase analyst. You will receive samples from a repository (file paths with short content snippets).",
|
|
25
|
-
"Produce a concise context summary capturing: primary domains, major modules/components, key data models, important services/APIs, external integrations, and notable terminology or patterns.",
|
|
26
|
-
"Format as short markdown sections with bullet points. Keep under 400 words. Do not speculate beyond the provided snippets."
|
|
27
|
-
]
|
|
28
|
-
});
|
|
29
|
-
var newSearchQueriesAgent = agent({
|
|
30
|
-
name: "research-continuation-planner",
|
|
31
|
-
model: groq("openai/gpt-oss-120b"),
|
|
32
|
-
prompt: "You are an analytical research assistant. Based on the original query, the search queries performed so far, and the extracted contexts, determine if further research is needed.",
|
|
33
|
-
output: z.object({
|
|
34
|
-
needsMoreResearch: z.boolean().describe("Whether additional research is needed"),
|
|
35
|
-
newQueries: z.array(z.string()).max(4).describe(
|
|
36
|
-
"Up to four new search queries if more research is needed, empty array otherwise"
|
|
37
|
-
),
|
|
38
|
-
reasoning: z.string().optional().describe("Brief explanation of the decision")
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
var pageUsefulnessAgent = agent({
|
|
42
|
-
name: "page-usefulness-evaluator",
|
|
43
|
-
model: lmstudio("qwen/qwen3-4b-2507"),
|
|
44
|
-
prompt: [
|
|
45
|
-
"You are a strict and concise evaluator of research relevance.",
|
|
46
|
-
"Given the user's query and the content of a repository file, determine if the file contains information relevant and useful for addressing the query.",
|
|
47
|
-
"Respond with exactly one word: 'Yes' if the file is useful, or 'No' if it is not."
|
|
48
|
-
],
|
|
49
|
-
output: z.object({ answer: z.enum(["Yes", "No"]) })
|
|
50
|
-
});
|
|
51
|
-
var extractRelevantContextAgent = agent({
|
|
52
|
-
name: "relevant-context-extractor",
|
|
53
|
-
model: groq("openai/gpt-oss-20b"),
|
|
54
|
-
prompt: [
|
|
55
|
-
"You are an expert in extracting and summarizing relevant information.",
|
|
56
|
-
"Given the user's query, the search query that led to this page, and the file content, extract all pieces of information that are relevant to answering the user's query.",
|
|
57
|
-
"Return only the relevant context as plain text without commentary."
|
|
58
|
-
]
|
|
59
|
-
});
|
|
60
|
-
var finalReportAgent = agent({
|
|
61
|
-
name: "final-report-writer",
|
|
62
|
-
model: openai("gpt-4.1"),
|
|
63
|
-
prompt: `You are an expert product manager that is working on reversing existing product to user stories based on a developer question/inquiry. Based on the gathered contexts below and the original query, write a comprehensive, well-structured, and detailed report that addresses the query thoroughly.
|
|
64
|
-
Include all relevant insights and conclusions without extraneous commentary.`
|
|
65
|
-
});
|
|
66
|
-
async function generateSearchQueries(input, repoContext) {
|
|
67
|
-
const { output } = await generate(
|
|
68
|
-
searchQueryAgent,
|
|
69
|
-
`User Query: ${input}
|
|
70
|
-
|
|
71
|
-
Repository Context Summary:
|
|
72
|
-
${repoContext}`,
|
|
73
|
-
{}
|
|
74
|
-
);
|
|
75
|
-
return uniqBy(
|
|
76
|
-
output.items.map((s) => s.trim()).filter(Boolean),
|
|
77
|
-
(s) => s.toLowerCase()
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
async function retrieve(query) {
|
|
81
|
-
const results = await similaritySearch(query, {
|
|
82
|
-
connector: connectors.repo(
|
|
83
|
-
"/Users/ezzabuzaid/Desktop/mo/virtual-care",
|
|
84
|
-
[".ts", ".tsx", ".md", ".prisma"],
|
|
85
|
-
"never"
|
|
86
|
-
),
|
|
87
|
-
store: nodeSQLite("deepsearch.sqlite", 384),
|
|
88
|
-
embedder: fastembed()
|
|
89
|
-
});
|
|
90
|
-
return results.map((it) => ({
|
|
91
|
-
snippet: it.content,
|
|
92
|
-
source: it.document_id,
|
|
93
|
-
similarity: it.similarity
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
async function getNewSearchQueries(userQuery, previousSearchQueries, allContexts, repoContext) {
|
|
97
|
-
const contextCombined = allContexts.join("\n\n");
|
|
98
|
-
const prompt = `User Query: ${userQuery}
|
|
99
|
-
|
|
100
|
-
Previous Search Queries: ${JSON.stringify(previousSearchQueries)}
|
|
101
|
-
|
|
102
|
-
Extracted Relevant Contexts:
|
|
103
|
-
${contextCombined}
|
|
104
|
-
|
|
105
|
-
Repository Context Summary:
|
|
106
|
-
${repoContext}
|
|
107
|
-
|
|
108
|
-
Based on the above information, determine if further research is needed. If yes, provide up to four new search queries. If the research is complete and sufficient, indicate that no more research is needed.`;
|
|
109
|
-
try {
|
|
110
|
-
const { output: result } = await generate(
|
|
111
|
-
newSearchQueriesAgent,
|
|
112
|
-
prompt,
|
|
113
|
-
{}
|
|
114
|
-
);
|
|
115
|
-
if (!result.needsMoreResearch) {
|
|
116
|
-
console.log(
|
|
117
|
-
"Research assessment: No further research needed.",
|
|
118
|
-
result.reasoning
|
|
119
|
-
);
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
console.log(
|
|
123
|
-
`Research assessment: ${result.newQueries.length} new queries generated.`,
|
|
124
|
-
result.reasoning
|
|
125
|
-
);
|
|
126
|
-
return uniqBy(
|
|
127
|
-
result.newQueries.map((s) => s.trim()).filter(Boolean),
|
|
128
|
-
(s) => s.toLowerCase()
|
|
129
|
-
);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error("Error generating new search queries:", error);
|
|
132
|
-
return [];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
async function generateFinalReport(userQuery, formatting, allContexts) {
|
|
136
|
-
const contextCombined = allContexts.join("\n\n");
|
|
137
|
-
const prompt = `
|
|
138
|
-
Developer Query: ${userQuery}
|
|
139
|
-
Formatting: ${formatting}
|
|
140
|
-
|
|
141
|
-
Gathered Relevant Contexts:
|
|
142
|
-
${contextCombined}`;
|
|
143
|
-
return (await execute(finalReportAgent, prompt, {})).text;
|
|
144
|
-
}
|
|
145
|
-
async function isPageUseful(userQuery, pageText) {
|
|
146
|
-
const prompt = `User Query: ${userQuery}
|
|
147
|
-
|
|
148
|
-
Repo file content
|
|
149
|
-
|
|
150
|
-
${pageText}
|
|
151
|
-
|
|
152
|
-
Decide if the page is useful.`;
|
|
153
|
-
const { output } = await generate(pageUsefulnessAgent, prompt, {});
|
|
154
|
-
return output.answer === "Yes";
|
|
155
|
-
}
|
|
156
|
-
async function extractRelevantContext(userQuery, searchQuery, pageText) {
|
|
157
|
-
const prompt = `User Query: ${userQuery}
|
|
158
|
-
Search Query: ${searchQuery}
|
|
159
|
-
|
|
160
|
-
Repo file content
|
|
161
|
-
|
|
162
|
-
${pageText}
|
|
163
|
-
|
|
164
|
-
Extract the relevant context.`;
|
|
165
|
-
return (await execute(extractRelevantContextAgent, prompt, {})).text;
|
|
166
|
-
}
|
|
167
|
-
async function processFile(filePath, userQuery, searchQuery) {
|
|
168
|
-
const content = await readFile(filePath, "utf-8");
|
|
169
|
-
const useful = await isPageUseful(userQuery, content);
|
|
170
|
-
if (useful) {
|
|
171
|
-
return {
|
|
172
|
-
source: filePath,
|
|
173
|
-
content: await extractRelevantContext(userQuery, searchQuery, content)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
async function gatherRepoContext() {
|
|
179
|
-
const seeds = [
|
|
180
|
-
"project overview",
|
|
181
|
-
"backend",
|
|
182
|
-
"framework",
|
|
183
|
-
"hono express",
|
|
184
|
-
"architecture",
|
|
185
|
-
"services",
|
|
186
|
-
"prisma",
|
|
187
|
-
"database",
|
|
188
|
-
"data model",
|
|
189
|
-
"payments",
|
|
190
|
-
"billing"
|
|
191
|
-
];
|
|
192
|
-
const results = await Promise.all(seeds.map((it) => retrieve(it)));
|
|
193
|
-
const deduped = uniqBy(results.flat(), (it) => it.source);
|
|
194
|
-
const bundle = deduped.map((r, i) => `(${i + 1}) Path: ${r.source}
|
|
195
|
-
Snippet:
|
|
196
|
-
${r.snippet}`).join("\n\n---\n\n");
|
|
197
|
-
const summary = (await execute(
|
|
198
|
-
repoContextAgent,
|
|
199
|
-
`Repository Samples (path + snippet):
|
|
200
|
-
|
|
201
|
-
${bundle}
|
|
202
|
-
|
|
203
|
-
Summarize as requested.`,
|
|
204
|
-
{}
|
|
205
|
-
)).text;
|
|
206
|
-
return summary;
|
|
207
|
-
}
|
|
208
|
-
function search() {
|
|
209
|
-
const cache = {};
|
|
210
|
-
const processedSources = /* @__PURE__ */ new Set();
|
|
211
|
-
return async (queries) => {
|
|
212
|
-
const results = [];
|
|
213
|
-
for (const query of queries) {
|
|
214
|
-
if (!cache[query]) {
|
|
215
|
-
const res = await retrieve(query);
|
|
216
|
-
cache[query] = uniqBy(res, (it) => it.source);
|
|
217
|
-
}
|
|
218
|
-
results.push(cache[query]);
|
|
219
|
-
}
|
|
220
|
-
const uniqueLinks = {};
|
|
221
|
-
for (let i = 0; i < results.length; i++) {
|
|
222
|
-
const query = queries[i];
|
|
223
|
-
for (const item of results[i]) {
|
|
224
|
-
if (!uniqueLinks[item.source] && !processedSources.has(item.source)) {
|
|
225
|
-
uniqueLinks[item.source] = query;
|
|
226
|
-
processedSources.add(item.source);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return uniqueLinks;
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
if (import.meta.main) {
|
|
234
|
-
const userQuery = "How do we process payment?";
|
|
235
|
-
const formatting = `
|
|
236
|
-
1. use ascii markdown diagrams to illustrate. I am visual learner and I love markdown.
|
|
237
|
-
2. use "user stories" to illustrate flows. we are not looking for only text or techical explanation.
|
|
238
|
-
3. user story scenario should be divided by actors and steps.
|
|
239
|
-
4. when referencing code snippets, include file path.
|
|
240
|
-
`;
|
|
241
|
-
const iterLimit = 2;
|
|
242
|
-
const aggregatedContexts = [];
|
|
243
|
-
const allSearchQueries = [];
|
|
244
|
-
const repoContext = await gatherRepoContext();
|
|
245
|
-
const initialSearchQueries = await generateSearchQueries(
|
|
246
|
-
userQuery,
|
|
247
|
-
repoContext
|
|
248
|
-
);
|
|
249
|
-
const performSearch = search();
|
|
250
|
-
const research = async (searchQueries, iteration) => {
|
|
251
|
-
if (iteration >= iterLimit) return;
|
|
252
|
-
const iterationContexts = [];
|
|
253
|
-
allSearchQueries.push(...searchQueries);
|
|
254
|
-
const searchResults = await performSearch(searchQueries);
|
|
255
|
-
await Promise.all(
|
|
256
|
-
Object.entries(searchResults).map(async ([source, query]) => {
|
|
257
|
-
const context = await processFile(source, userQuery, query);
|
|
258
|
-
if (context) {
|
|
259
|
-
iterationContexts.push(
|
|
260
|
-
`Source: ${context.source}
|
|
261
|
-
|
|
262
|
-
Content: ${context.content}
|
|
263
|
-
|
|
264
|
-
`
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
);
|
|
269
|
-
if (iterationContexts.length === 0) {
|
|
270
|
-
console.log("No useful contexts were found in this iteration.");
|
|
271
|
-
} else {
|
|
272
|
-
aggregatedContexts.push(...iterationContexts);
|
|
273
|
-
}
|
|
274
|
-
const newSearchQueries = await getNewSearchQueries(
|
|
275
|
-
userQuery,
|
|
276
|
-
allSearchQueries,
|
|
277
|
-
aggregatedContexts,
|
|
278
|
-
repoContext
|
|
279
|
-
);
|
|
280
|
-
if (newSearchQueries.length === 0) {
|
|
281
|
-
console.log("No further research needed. Exiting loop.");
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
await research(newSearchQueries, iteration + 1);
|
|
285
|
-
};
|
|
286
|
-
await research(initialSearchQueries, 0);
|
|
287
|
-
console.log("\nGenerating final report...");
|
|
288
|
-
console.log("Search queries performed:", allSearchQueries);
|
|
289
|
-
const finalReport = await generateFinalReport(
|
|
290
|
-
userQuery,
|
|
291
|
-
formatting,
|
|
292
|
-
aggregatedContexts
|
|
293
|
-
);
|
|
294
|
-
await writeFile("final_report.md", finalReport);
|
|
295
|
-
}
|
|
296
|
-
export {
|
|
297
|
-
generateFinalReport,
|
|
298
|
-
getNewSearchQueries
|
|
299
|
-
};
|
|
300
|
-
//# sourceMappingURL=deepresearch.v0.js.map
|