@morphllm/morphsdk 0.2.45 → 0.2.47
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 +1 -1
- package/dist/{chunk-TVFGHXPE.js → chunk-3FTAIJBH.js} +4 -4
- package/dist/{chunk-ZRLEAPZV.js → chunk-76DJEQEP.js} +4 -4
- package/dist/{chunk-W3XLPMV3.js → chunk-7HS6YXA3.js} +21 -5
- package/dist/{chunk-W3XLPMV3.js.map → chunk-7HS6YXA3.js.map} +1 -1
- package/dist/chunk-BLXC5R4W.js +82 -0
- package/dist/chunk-BLXC5R4W.js.map +1 -0
- package/dist/chunk-FA6UGPVL.js +105 -0
- package/dist/chunk-FA6UGPVL.js.map +1 -0
- package/dist/{chunk-PEGZVGG4.js → chunk-G4AWE5A2.js} +4 -4
- package/dist/{chunk-OUEJ6XEO.js → chunk-GJU7UOFL.js} +4 -4
- package/dist/{chunk-Q7PDN7TS.js → chunk-GZMUGMOZ.js} +1 -1
- package/dist/{chunk-Q7PDN7TS.js.map → chunk-GZMUGMOZ.js.map} +1 -1
- package/dist/chunk-JYBVRF72.js +1 -0
- package/dist/chunk-OOZSGWSK.js +70 -0
- package/dist/chunk-OOZSGWSK.js.map +1 -0
- package/dist/{chunk-GDR65N2J.js → chunk-OXHGFHEU.js} +53 -26
- package/dist/chunk-OXHGFHEU.js.map +1 -0
- package/dist/{chunk-VBBJGWHY.js → chunk-P2XKFWFD.js} +2 -2
- package/dist/chunk-RAKREIXE.js +76 -0
- package/dist/chunk-RAKREIXE.js.map +1 -0
- package/dist/chunk-SDI2FI6G.js +283 -0
- package/dist/chunk-SDI2FI6G.js.map +1 -0
- package/dist/{chunk-GTOXMAF2.js → chunk-SWQPIKPY.js} +44 -3
- package/dist/chunk-SWQPIKPY.js.map +1 -0
- package/dist/chunk-TJIUA27P.js +94 -0
- package/dist/chunk-TJIUA27P.js.map +1 -0
- package/dist/{chunk-O5DA5V5S.js → chunk-UBX7QYBD.js} +4 -4
- package/dist/{chunk-UYBIKZPM.js → chunk-UCWTZSW5.js} +3 -3
- package/dist/{chunk-X4CQ6D3G.js → chunk-UIZT3KVJ.js} +4 -4
- package/dist/chunk-WETRQJGU.js +129 -0
- package/dist/chunk-WETRQJGU.js.map +1 -0
- package/dist/{chunk-RSLIOCOE.js → chunk-XQIVYQD6.js} +3 -2
- package/dist/chunk-XQIVYQD6.js.map +1 -0
- package/dist/client-BGctTHu9.d.ts +318 -0
- package/dist/client.cjs +1886 -44
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +14 -110
- package/dist/client.js +28 -3
- package/dist/core-DxiUwyBe.d.ts +156 -0
- package/dist/git/client.cjs +52 -25
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.d.ts +17 -8
- package/dist/git/client.js +1 -1
- package/dist/git/index.cjs +52 -25
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.d.ts +1 -1
- package/dist/git/index.js +2 -2
- package/dist/git/types.cjs.map +1 -1
- package/dist/git/types.d.ts +20 -2
- package/dist/index.cjs +1965 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +47 -5
- package/dist/tools/codebase_search/anthropic.js +2 -2
- package/dist/tools/codebase_search/index.js +9 -9
- package/dist/tools/codebase_search/openai.js +2 -2
- package/dist/tools/codebase_search/vercel.js +2 -2
- package/dist/tools/fastapply/anthropic.js +2 -2
- package/dist/tools/fastapply/index.js +7 -7
- package/dist/tools/fastapply/openai.js +2 -2
- package/dist/tools/fastapply/vercel.js +2 -2
- package/dist/tools/index.js +7 -7
- package/dist/tools/warp_grep/agent/config.cjs +80 -1
- package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/config.js +1 -1
- package/dist/tools/warp_grep/agent/parser.cjs +43 -2
- package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/parser.js +1 -1
- package/dist/tools/warp_grep/agent/prompt.cjs +89 -45
- package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
- package/dist/tools/warp_grep/agent/prompt.js +1 -1
- package/dist/tools/warp_grep/agent/runner.cjs +229 -49
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +4 -4
- package/dist/tools/warp_grep/agent/types.js +0 -1
- package/dist/tools/warp_grep/anthropic.cjs +313 -84
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.d.ts +75 -12
- package/dist/tools/warp_grep/anthropic.js +22 -9
- package/dist/tools/warp_grep/index.cjs +417 -127
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.d.ts +17 -4
- package/dist/tools/warp_grep/index.js +30 -22
- package/dist/tools/warp_grep/openai.cjs +316 -84
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.d.ts +73 -29
- package/dist/tools/warp_grep/openai.js +22 -9
- package/dist/tools/warp_grep/providers/command.cjs +80 -1
- package/dist/tools/warp_grep/providers/command.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/command.js +2 -2
- package/dist/tools/warp_grep/providers/local.cjs +82 -2
- package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
- package/dist/tools/warp_grep/providers/local.js +3 -3
- package/dist/tools/warp_grep/utils/ripgrep.cjs +2 -1
- package/dist/tools/warp_grep/utils/ripgrep.cjs.map +1 -1
- package/dist/tools/warp_grep/utils/ripgrep.js +1 -1
- package/dist/tools/warp_grep/vercel.cjs +293 -58
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.d.ts +40 -19
- package/dist/tools/warp_grep/vercel.js +18 -9
- package/package.json +2 -1
- package/dist/chunk-AFEPUNAO.js +0 -15
- package/dist/chunk-AFEPUNAO.js.map +0 -1
- package/dist/chunk-GDR65N2J.js.map +0 -1
- package/dist/chunk-GTOXMAF2.js.map +0 -1
- package/dist/chunk-HKZB23U7.js +0 -85
- package/dist/chunk-HKZB23U7.js.map +0 -1
- package/dist/chunk-IQHKEIQX.js +0 -54
- package/dist/chunk-IQHKEIQX.js.map +0 -1
- package/dist/chunk-JKFVDM62.js +0 -45
- package/dist/chunk-JKFVDM62.js.map +0 -1
- package/dist/chunk-K6FQZZ2E.js +0 -104
- package/dist/chunk-K6FQZZ2E.js.map +0 -1
- package/dist/chunk-KL4YVZRF.js +0 -57
- package/dist/chunk-KL4YVZRF.js.map +0 -1
- package/dist/chunk-RSLIOCOE.js.map +0 -1
- package/dist/chunk-XYPMN4A3.js +0 -1
- /package/dist/{chunk-TVFGHXPE.js.map → chunk-3FTAIJBH.js.map} +0 -0
- /package/dist/{chunk-ZRLEAPZV.js.map → chunk-76DJEQEP.js.map} +0 -0
- /package/dist/{chunk-PEGZVGG4.js.map → chunk-G4AWE5A2.js.map} +0 -0
- /package/dist/{chunk-OUEJ6XEO.js.map → chunk-GJU7UOFL.js.map} +0 -0
- /package/dist/{chunk-XYPMN4A3.js.map → chunk-JYBVRF72.js.map} +0 -0
- /package/dist/{chunk-VBBJGWHY.js.map → chunk-P2XKFWFD.js.map} +0 -0
- /package/dist/{chunk-O5DA5V5S.js.map → chunk-UBX7QYBD.js.map} +0 -0
- /package/dist/{chunk-UYBIKZPM.js.map → chunk-UCWTZSW5.js.map} +0 -0
- /package/dist/{chunk-X4CQ6D3G.js.map → chunk-UIZT3KVJ.js.map} +0 -0
|
@@ -24,80 +24,124 @@ __export(prompt_exports, {
|
|
|
24
24
|
getSystemPrompt: () => getSystemPrompt
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(prompt_exports);
|
|
27
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find relevant code
|
|
27
|
+
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given query.
|
|
28
28
|
|
|
29
29
|
<workflow>
|
|
30
|
-
You
|
|
30
|
+
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
- Turn 1: Map the territory OR dive deep (based on query specificity)
|
|
33
|
+
- Turn 2-3: Refine based on findings
|
|
34
|
+
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
35
|
+
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
Remember, if the task feels easy to you, it is strongly desirable to call \`finish\` early using fewer turns, but quality over speed.
|
|
38
|
+
</workflow>
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
- \`
|
|
40
|
+
<tools>
|
|
41
|
+
### \`analyse <path> [pattern]\`
|
|
42
|
+
Directory tree or file search. Shows structure of a path, optionally filtered by regex pattern.
|
|
43
|
+
- \`path\`: Required. Directory or file path (use \`.\` for repo root)
|
|
44
|
+
- \`pattern\`: Optional regex to filter results
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
Examples:
|
|
46
47
|
\`\`\`
|
|
48
|
+
analyse .
|
|
47
49
|
analyse src/api
|
|
48
|
-
analyse . "
|
|
50
|
+
analyse . ".*\\.ts$"
|
|
51
|
+
analyse src "test.*"
|
|
49
52
|
\`\`\`
|
|
50
53
|
|
|
51
|
-
###
|
|
52
|
-
Read
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
- \`[:start-end]\`: Optional 1-based, inclusive line range
|
|
54
|
+
### \`read <path>[:start-end]\`
|
|
55
|
+
Read file contents. Line range is 1-based, inclusive.
|
|
56
|
+
- Returns numbered lines for easy reference
|
|
57
|
+
- Omit range to read entire file
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
Examples:
|
|
58
60
|
\`\`\`
|
|
59
61
|
read src/main.py
|
|
60
|
-
read src/
|
|
62
|
+
read src/db/conn.py:10-50
|
|
63
|
+
read package.json:1-20
|
|
61
64
|
\`\`\`
|
|
62
65
|
|
|
63
|
-
###
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
- \`<path>\`: Directory or file to search (use \`.\` for the repo root)
|
|
66
|
+
### \`grep '<pattern>' <path>\`
|
|
67
|
+
Ripgrep search. Finds pattern matches across files.
|
|
68
|
+
- \`'<pattern>'\`: Required. Regex pattern wrapped in single quotes
|
|
69
|
+
- \`<path>\`: Required. Directory or file to search (use \`.\` for repo root)
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
Examples:
|
|
70
72
|
\`\`\`
|
|
71
|
-
grep '
|
|
72
|
-
grep '
|
|
73
|
-
grep '
|
|
73
|
+
grep 'class.*Service' src/
|
|
74
|
+
grep 'def authenticate' .
|
|
75
|
+
grep 'import.*from' src/components/
|
|
76
|
+
grep 'TODO' .
|
|
74
77
|
\`\`\`
|
|
75
78
|
|
|
76
|
-
###
|
|
77
|
-
Submit
|
|
78
|
-
|
|
79
|
-
-
|
|
79
|
+
### \`finish <file1:ranges> [file2:ranges ...]\`
|
|
80
|
+
Submit final answer with all relevant code locations.
|
|
81
|
+
- Include generous line ranges\u2014don't be stingy with context
|
|
82
|
+
- Ranges are comma-separated: \`file.py:10-30,50-60\`
|
|
83
|
+
- ALWAYS include import statements at the top of files (usually lines 1-20)
|
|
84
|
+
- If code spans multiple files, include ALL of them
|
|
85
|
+
- Small files can be returned in full
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
Examples:
|
|
82
88
|
\`\`\`
|
|
83
|
-
finish src/
|
|
89
|
+
finish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45
|
|
90
|
+
finish src/index.ts:1-100
|
|
84
91
|
\`\`\`
|
|
85
|
-
</
|
|
92
|
+
</tools>
|
|
86
93
|
|
|
87
94
|
<strategy>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
**Before your first tool call, classify the query:**
|
|
96
|
+
|
|
97
|
+
| Query Type | Turn 1 Strategy | Early Finish? |
|
|
98
|
+
|------------|-----------------|---------------|
|
|
99
|
+
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |
|
|
100
|
+
| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |
|
|
101
|
+
| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |
|
|
102
|
+
|
|
103
|
+
**Parallel call patterns:**
|
|
104
|
+
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
105
|
+
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
106
|
+
- **Funnel**: 1 analyse + 7 greps\u2014orient and search simultaneously
|
|
107
|
+
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
92
108
|
</strategy>
|
|
93
109
|
|
|
94
110
|
<output_format>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
-
|
|
111
|
+
EVERY response MUST follow this exact format:
|
|
112
|
+
|
|
113
|
+
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
114
|
+
- Query classification (specific/conceptual/exploratory)
|
|
115
|
+
- Confidence estimate (can I finish in 1-2 turns?)
|
|
116
|
+
- This turn's parallel strategy
|
|
117
|
+
- What signals would let me finish early?
|
|
118
|
+
|
|
119
|
+
2. Then, output tool calls wrapped in \`<tool_call>...</tool_call>\` tags, one per line.
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
\`\`\`
|
|
123
|
+
<think>
|
|
124
|
+
This is a specific query about authentication. I'll grep for auth-related patterns.
|
|
125
|
+
High confidence I can finish in 2 turns if I find the auth module.
|
|
126
|
+
Strategy: Shotgun grep across likely directories.
|
|
127
|
+
</think>
|
|
128
|
+
<tool_call>grep 'authenticate' src/</tool_call>
|
|
129
|
+
<tool_call>grep 'login' src/</tool_call>
|
|
130
|
+
<tool_call>analyse src/auth</tool_call>
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
99
134
|
</output_format>
|
|
100
135
|
|
|
136
|
+
<finishing_requirements>
|
|
137
|
+
When calling \`finish\`:
|
|
138
|
+
- Include the import section (typically lines 1-20) of each file
|
|
139
|
+
- Include all function/class definitions that are relevant
|
|
140
|
+
- Include any type definitions, interfaces, or constants used
|
|
141
|
+
- Better to over-include than leave the user missing context
|
|
142
|
+
- If unsure about boundaries, include more rather than less
|
|
143
|
+
</finishing_requirements>
|
|
144
|
+
|
|
101
145
|
Begin your exploration now to find code relevant to the query.`;
|
|
102
146
|
function getSystemPrompt() {
|
|
103
147
|
return SYSTEM_PROMPT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../tools/warp_grep/agent/prompt.ts"],"sourcesContent":["export const SYSTEM_PROMPT = `You are a code search agent. Your task is to find relevant code
|
|
1
|
+
{"version":3,"sources":["../../../../tools/warp_grep/agent/prompt.ts"],"sourcesContent":["export const SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given query.\n\n<workflow>\nYou have exactly 4 turns. The 4th turn MUST be a \\`finish\\` call. Each turn allows up to 8 parallel tool calls.\n\n- Turn 1: Map the territory OR dive deep (based on query specificity)\n- Turn 2-3: Refine based on findings\n- Turn 4: MUST call \\`finish\\` with all relevant code locations\n- You MAY call \\`finish\\` early if confident—but never before at least 1 search turn.\n\nRemember, if the task feels easy to you, it is strongly desirable to call \\`finish\\` early using fewer turns, but quality over speed.\n</workflow>\n\n<tools>\n### \\`analyse <path> [pattern]\\`\nDirectory tree or file search. Shows structure of a path, optionally filtered by regex pattern.\n- \\`path\\`: Required. Directory or file path (use \\`.\\` for repo root)\n- \\`pattern\\`: Optional regex to filter results\n\nExamples:\n\\`\\`\\`\nanalyse .\nanalyse src/api\nanalyse . \".*\\\\.ts$\"\nanalyse src \"test.*\"\n\\`\\`\\`\n\n### \\`read <path>[:start-end]\\`\nRead file contents. Line range is 1-based, inclusive.\n- Returns numbered lines for easy reference\n- Omit range to read entire file\n\nExamples:\n\\`\\`\\`\nread src/main.py\nread src/db/conn.py:10-50\nread package.json:1-20\n\\`\\`\\`\n\n### \\`grep '<pattern>' <path>\\`\nRipgrep search. Finds pattern matches across files.\n- \\`'<pattern>'\\`: Required. Regex pattern wrapped in single quotes\n- \\`<path>\\`: Required. Directory or file to search (use \\`.\\` for repo root)\n\nExamples:\n\\`\\`\\`\ngrep 'class.*Service' src/\ngrep 'def authenticate' .\ngrep 'import.*from' src/components/\ngrep 'TODO' .\n\\`\\`\\`\n\n### \\`finish <file1:ranges> [file2:ranges ...]\\`\nSubmit final answer with all relevant code locations.\n- Include generous line ranges—don't be stingy with context\n- Ranges are comma-separated: \\`file.py:10-30,50-60\\`\n- ALWAYS include import statements at the top of files (usually lines 1-20)\n- If code spans multiple files, include ALL of them\n- Small files can be returned in full\n\nExamples:\n\\`\\`\\`\nfinish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45\nfinish src/index.ts:1-100\n\\`\\`\\`\n</tools>\n\n<strategy>\n**Before your first tool call, classify the query:**\n\n| Query Type | Turn 1 Strategy | Early Finish? |\n|------------|-----------------|---------------|\n| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |\n| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |\n| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |\n\n**Parallel call patterns:**\n- **Shotgun grep**: Same pattern, 8 different directories—fast coverage\n- **Variant grep**: 8 pattern variations (synonyms, naming conventions)—catches inconsistent codebases\n- **Funnel**: 1 analyse + 7 greps—orient and search simultaneously\n- **Deep read**: 8 reads on files you already identified—gather full context fast\n</strategy>\n\n<output_format>\nEVERY response MUST follow this exact format:\n\n1. First, wrap your reasoning in \\`<think>...</think>\\` tags containing:\n - Query classification (specific/conceptual/exploratory)\n - Confidence estimate (can I finish in 1-2 turns?)\n - This turn's parallel strategy\n - What signals would let me finish early?\n\n2. Then, output tool calls wrapped in \\`<tool_call>...</tool_call>\\` tags, one per line.\n\nExample:\n\\`\\`\\`\n<think>\nThis is a specific query about authentication. I'll grep for auth-related patterns.\nHigh confidence I can finish in 2 turns if I find the auth module.\nStrategy: Shotgun grep across likely directories.\n</think>\n<tool_call>grep 'authenticate' src/</tool_call>\n<tool_call>grep 'login' src/</tool_call>\n<tool_call>analyse src/auth</tool_call>\n\\`\\`\\`\n\nNo commentary outside \\`<think>\\`. No explanations after tool calls.\n</output_format>\n\n<finishing_requirements>\nWhen calling \\`finish\\`:\n- Include the import section (typically lines 1-20) of each file\n- Include all function/class definitions that are relevant\n- Include any type definitions, interfaces, or constants used\n- Better to over-include than leave the user missing context\n- If unsure about boundaries, include more rather than less\n</finishing_requirements>\n\nBegin your exploration now to find code relevant to the query.`;\n\nexport function getSystemPrompt(): string {\n\treturn SYSTEM_PROMPT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,gBAAgB;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;AAwHtB,SAAS,kBAA0B;AACzC,SAAO;AACR;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const SYSTEM_PROMPT = "You are a code search agent. Your task is to find relevant code
|
|
1
|
+
declare const SYSTEM_PROMPT = "You are a code search agent. Your task is to find all relevant code for a given query.\n\n<workflow>\nYou have exactly 4 turns. The 4th turn MUST be a `finish` call. Each turn allows up to 8 parallel tool calls.\n\n- Turn 1: Map the territory OR dive deep (based on query specificity)\n- Turn 2-3: Refine based on findings\n- Turn 4: MUST call `finish` with all relevant code locations\n- You MAY call `finish` early if confident\u2014but never before at least 1 search turn.\n\nRemember, if the task feels easy to you, it is strongly desirable to call `finish` early using fewer turns, but quality over speed.\n</workflow>\n\n<tools>\n### `analyse <path> [pattern]`\nDirectory tree or file search. Shows structure of a path, optionally filtered by regex pattern.\n- `path`: Required. Directory or file path (use `.` for repo root)\n- `pattern`: Optional regex to filter results\n\nExamples:\n```\nanalyse .\nanalyse src/api\nanalyse . \".*\\.ts$\"\nanalyse src \"test.*\"\n```\n\n### `read <path>[:start-end]`\nRead file contents. Line range is 1-based, inclusive.\n- Returns numbered lines for easy reference\n- Omit range to read entire file\n\nExamples:\n```\nread src/main.py\nread src/db/conn.py:10-50\nread package.json:1-20\n```\n\n### `grep '<pattern>' <path>`\nRipgrep search. Finds pattern matches across files.\n- `'<pattern>'`: Required. Regex pattern wrapped in single quotes\n- `<path>`: Required. Directory or file to search (use `.` for repo root)\n\nExamples:\n```\ngrep 'class.*Service' src/\ngrep 'def authenticate' .\ngrep 'import.*from' src/components/\ngrep 'TODO' .\n```\n\n### `finish <file1:ranges> [file2:ranges ...]`\nSubmit final answer with all relevant code locations.\n- Include generous line ranges\u2014don't be stingy with context\n- Ranges are comma-separated: `file.py:10-30,50-60`\n- ALWAYS include import statements at the top of files (usually lines 1-20)\n- If code spans multiple files, include ALL of them\n- Small files can be returned in full\n\nExamples:\n```\nfinish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45\nfinish src/index.ts:1-100\n```\n</tools>\n\n<strategy>\n**Before your first tool call, classify the query:**\n\n| Query Type | Turn 1 Strategy | Early Finish? |\n|------------|-----------------|---------------|\n| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |\n| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |\n| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |\n\n**Parallel call patterns:**\n- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage\n- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases\n- **Funnel**: 1 analyse + 7 greps\u2014orient and search simultaneously\n- **Deep read**: 8 reads on files you already identified\u2014gather full context fast\n</strategy>\n\n<output_format>\nEVERY response MUST follow this exact format:\n\n1. First, wrap your reasoning in `<think>...</think>` tags containing:\n - Query classification (specific/conceptual/exploratory)\n - Confidence estimate (can I finish in 1-2 turns?)\n - This turn's parallel strategy\n - What signals would let me finish early?\n\n2. Then, output tool calls wrapped in `<tool_call>...</tool_call>` tags, one per line.\n\nExample:\n```\n<think>\nThis is a specific query about authentication. I'll grep for auth-related patterns.\nHigh confidence I can finish in 2 turns if I find the auth module.\nStrategy: Shotgun grep across likely directories.\n</think>\n<tool_call>grep 'authenticate' src/</tool_call>\n<tool_call>grep 'login' src/</tool_call>\n<tool_call>analyse src/auth</tool_call>\n```\n\nNo commentary outside `<think>`. No explanations after tool calls.\n</output_format>\n\n<finishing_requirements>\nWhen calling `finish`:\n- Include the import section (typically lines 1-20) of each file\n- Include all function/class definitions that are relevant\n- Include any type definitions, interfaces, or constants used\n- Better to over-include than leave the user missing context\n- If unsure about boundaries, include more rather than less\n</finishing_requirements>\n\nBegin your exploration now to find code relevant to the query.";
|
|
2
2
|
declare function getSystemPrompt(): string;
|
|
3
3
|
|
|
4
4
|
export { SYSTEM_PROMPT, getSystemPrompt };
|
|
@@ -40,84 +40,207 @@ var AGENT_CONFIG = {
|
|
|
40
40
|
MAX_ROUNDS: 10,
|
|
41
41
|
TIMEOUT_MS: 3e4
|
|
42
42
|
};
|
|
43
|
-
var
|
|
43
|
+
var BUILTIN_EXCLUDES = [
|
|
44
|
+
// Version control
|
|
45
|
+
".git",
|
|
46
|
+
".svn",
|
|
47
|
+
".hg",
|
|
48
|
+
".bzr",
|
|
49
|
+
// Dependencies
|
|
50
|
+
"node_modules",
|
|
51
|
+
"bower_components",
|
|
52
|
+
".pnpm",
|
|
53
|
+
".yarn",
|
|
54
|
+
"vendor",
|
|
55
|
+
"packages",
|
|
56
|
+
"Pods",
|
|
57
|
+
".bundle",
|
|
58
|
+
// Python
|
|
59
|
+
"__pycache__",
|
|
60
|
+
".pytest_cache",
|
|
61
|
+
".mypy_cache",
|
|
62
|
+
".ruff_cache",
|
|
63
|
+
".venv",
|
|
64
|
+
"venv",
|
|
65
|
+
".tox",
|
|
66
|
+
".nox",
|
|
67
|
+
".eggs",
|
|
68
|
+
"*.egg-info",
|
|
69
|
+
// Build outputs
|
|
70
|
+
"dist",
|
|
71
|
+
"build",
|
|
72
|
+
"out",
|
|
73
|
+
"output",
|
|
74
|
+
"target",
|
|
75
|
+
"_build",
|
|
76
|
+
".next",
|
|
77
|
+
".nuxt",
|
|
78
|
+
".output",
|
|
79
|
+
".vercel",
|
|
80
|
+
".netlify",
|
|
81
|
+
// Cache directories
|
|
82
|
+
".cache",
|
|
83
|
+
".parcel-cache",
|
|
84
|
+
".turbo",
|
|
85
|
+
".nx",
|
|
86
|
+
".gradle",
|
|
87
|
+
// IDE/Editor
|
|
88
|
+
".idea",
|
|
89
|
+
".vscode",
|
|
90
|
+
".vs",
|
|
91
|
+
// Coverage
|
|
92
|
+
"coverage",
|
|
93
|
+
".coverage",
|
|
94
|
+
"htmlcov",
|
|
95
|
+
".nyc_output",
|
|
96
|
+
// Temporary
|
|
97
|
+
"tmp",
|
|
98
|
+
"temp",
|
|
99
|
+
".tmp",
|
|
100
|
+
".temp",
|
|
101
|
+
// Lock files
|
|
102
|
+
"package-lock.json",
|
|
103
|
+
"yarn.lock",
|
|
104
|
+
"pnpm-lock.yaml",
|
|
105
|
+
"bun.lockb",
|
|
106
|
+
"Cargo.lock",
|
|
107
|
+
"Gemfile.lock",
|
|
108
|
+
"poetry.lock",
|
|
109
|
+
// Binary/minified
|
|
110
|
+
"*.min.js",
|
|
111
|
+
"*.min.css",
|
|
112
|
+
"*.bundle.js",
|
|
113
|
+
"*.wasm",
|
|
114
|
+
"*.so",
|
|
115
|
+
"*.dll",
|
|
116
|
+
"*.pyc",
|
|
117
|
+
"*.map",
|
|
118
|
+
"*.js.map",
|
|
119
|
+
// Hidden directories catch-all
|
|
120
|
+
".*"
|
|
121
|
+
];
|
|
122
|
+
var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(BUILTIN_EXCLUDES);
|
|
44
123
|
var DEFAULT_MODEL = "morph-warp-grep";
|
|
45
124
|
|
|
46
125
|
// tools/warp_grep/agent/prompt.ts
|
|
47
|
-
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find relevant code
|
|
126
|
+
var SYSTEM_PROMPT = `You are a code search agent. Your task is to find all relevant code for a given query.
|
|
48
127
|
|
|
49
128
|
<workflow>
|
|
50
|
-
You
|
|
129
|
+
You have exactly 4 turns. The 4th turn MUST be a \`finish\` call. Each turn allows up to 8 parallel tool calls.
|
|
51
130
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
131
|
+
- Turn 1: Map the territory OR dive deep (based on query specificity)
|
|
132
|
+
- Turn 2-3: Refine based on findings
|
|
133
|
+
- Turn 4: MUST call \`finish\` with all relevant code locations
|
|
134
|
+
- You MAY call \`finish\` early if confident\u2014but never before at least 1 search turn.
|
|
55
135
|
|
|
56
|
-
|
|
57
|
-
|
|
136
|
+
Remember, if the task feels easy to you, it is strongly desirable to call \`finish\` early using fewer turns, but quality over speed.
|
|
137
|
+
</workflow>
|
|
58
138
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
- \`
|
|
139
|
+
<tools>
|
|
140
|
+
### \`analyse <path> [pattern]\`
|
|
141
|
+
Directory tree or file search. Shows structure of a path, optionally filtered by regex pattern.
|
|
142
|
+
- \`path\`: Required. Directory or file path (use \`.\` for repo root)
|
|
143
|
+
- \`pattern\`: Optional regex to filter results
|
|
64
144
|
|
|
65
|
-
|
|
145
|
+
Examples:
|
|
66
146
|
\`\`\`
|
|
147
|
+
analyse .
|
|
67
148
|
analyse src/api
|
|
68
|
-
analyse . "
|
|
149
|
+
analyse . ".*\\.ts$"
|
|
150
|
+
analyse src "test.*"
|
|
69
151
|
\`\`\`
|
|
70
152
|
|
|
71
|
-
###
|
|
72
|
-
Read
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
- \`[:start-end]\`: Optional 1-based, inclusive line range
|
|
153
|
+
### \`read <path>[:start-end]\`
|
|
154
|
+
Read file contents. Line range is 1-based, inclusive.
|
|
155
|
+
- Returns numbered lines for easy reference
|
|
156
|
+
- Omit range to read entire file
|
|
76
157
|
|
|
77
|
-
|
|
158
|
+
Examples:
|
|
78
159
|
\`\`\`
|
|
79
160
|
read src/main.py
|
|
80
|
-
read src/
|
|
161
|
+
read src/db/conn.py:10-50
|
|
162
|
+
read package.json:1-20
|
|
81
163
|
\`\`\`
|
|
82
164
|
|
|
83
|
-
###
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
- \`<path>\`: Directory or file to search (use \`.\` for the repo root)
|
|
165
|
+
### \`grep '<pattern>' <path>\`
|
|
166
|
+
Ripgrep search. Finds pattern matches across files.
|
|
167
|
+
- \`'<pattern>'\`: Required. Regex pattern wrapped in single quotes
|
|
168
|
+
- \`<path>\`: Required. Directory or file to search (use \`.\` for repo root)
|
|
88
169
|
|
|
89
|
-
|
|
170
|
+
Examples:
|
|
90
171
|
\`\`\`
|
|
91
|
-
grep '
|
|
92
|
-
grep '
|
|
93
|
-
grep '
|
|
172
|
+
grep 'class.*Service' src/
|
|
173
|
+
grep 'def authenticate' .
|
|
174
|
+
grep 'import.*from' src/components/
|
|
175
|
+
grep 'TODO' .
|
|
94
176
|
\`\`\`
|
|
95
177
|
|
|
96
|
-
###
|
|
97
|
-
Submit
|
|
98
|
-
|
|
99
|
-
-
|
|
178
|
+
### \`finish <file1:ranges> [file2:ranges ...]\`
|
|
179
|
+
Submit final answer with all relevant code locations.
|
|
180
|
+
- Include generous line ranges\u2014don't be stingy with context
|
|
181
|
+
- Ranges are comma-separated: \`file.py:10-30,50-60\`
|
|
182
|
+
- ALWAYS include import statements at the top of files (usually lines 1-20)
|
|
183
|
+
- If code spans multiple files, include ALL of them
|
|
184
|
+
- Small files can be returned in full
|
|
100
185
|
|
|
101
|
-
|
|
186
|
+
Examples:
|
|
102
187
|
\`\`\`
|
|
103
|
-
finish src/
|
|
188
|
+
finish src/auth.py:1-15,25-50,75-80 src/models/user.py:1-10,20-45
|
|
189
|
+
finish src/index.ts:1-100
|
|
104
190
|
\`\`\`
|
|
105
|
-
</
|
|
191
|
+
</tools>
|
|
106
192
|
|
|
107
193
|
<strategy>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
194
|
+
**Before your first tool call, classify the query:**
|
|
195
|
+
|
|
196
|
+
| Query Type | Turn 1 Strategy | Early Finish? |
|
|
197
|
+
|------------|-----------------|---------------|
|
|
198
|
+
| **Specific** (function name, error string, unique identifier) | 8 parallel greps on likely paths | Often by turn 2 |
|
|
199
|
+
| **Conceptual** (how does X work, where is Y handled) | analyse + 2-3 broad greps | Rarely early |
|
|
200
|
+
| **Exploratory** (find all tests, list API endpoints) | analyse at multiple depths | Usually needs 3 turns |
|
|
201
|
+
|
|
202
|
+
**Parallel call patterns:**
|
|
203
|
+
- **Shotgun grep**: Same pattern, 8 different directories\u2014fast coverage
|
|
204
|
+
- **Variant grep**: 8 pattern variations (synonyms, naming conventions)\u2014catches inconsistent codebases
|
|
205
|
+
- **Funnel**: 1 analyse + 7 greps\u2014orient and search simultaneously
|
|
206
|
+
- **Deep read**: 8 reads on files you already identified\u2014gather full context fast
|
|
112
207
|
</strategy>
|
|
113
208
|
|
|
114
209
|
<output_format>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
210
|
+
EVERY response MUST follow this exact format:
|
|
211
|
+
|
|
212
|
+
1. First, wrap your reasoning in \`<think>...</think>\` tags containing:
|
|
213
|
+
- Query classification (specific/conceptual/exploratory)
|
|
214
|
+
- Confidence estimate (can I finish in 1-2 turns?)
|
|
215
|
+
- This turn's parallel strategy
|
|
216
|
+
- What signals would let me finish early?
|
|
217
|
+
|
|
218
|
+
2. Then, output tool calls wrapped in \`<tool_call>...</tool_call>\` tags, one per line.
|
|
219
|
+
|
|
220
|
+
Example:
|
|
221
|
+
\`\`\`
|
|
222
|
+
<think>
|
|
223
|
+
This is a specific query about authentication. I'll grep for auth-related patterns.
|
|
224
|
+
High confidence I can finish in 2 turns if I find the auth module.
|
|
225
|
+
Strategy: Shotgun grep across likely directories.
|
|
226
|
+
</think>
|
|
227
|
+
<tool_call>grep 'authenticate' src/</tool_call>
|
|
228
|
+
<tool_call>grep 'login' src/</tool_call>
|
|
229
|
+
<tool_call>analyse src/auth</tool_call>
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
No commentary outside \`<think>\`. No explanations after tool calls.
|
|
119
233
|
</output_format>
|
|
120
234
|
|
|
235
|
+
<finishing_requirements>
|
|
236
|
+
When calling \`finish\`:
|
|
237
|
+
- Include the import section (typically lines 1-20) of each file
|
|
238
|
+
- Include all function/class definitions that are relevant
|
|
239
|
+
- Include any type definitions, interfaces, or constants used
|
|
240
|
+
- Better to over-include than leave the user missing context
|
|
241
|
+
- If unsure about boundaries, include more rather than less
|
|
242
|
+
</finishing_requirements>
|
|
243
|
+
|
|
121
244
|
Begin your exploration now to find code relevant to the query.`;
|
|
122
245
|
function getSystemPrompt() {
|
|
123
246
|
return SYSTEM_PROMPT;
|
|
@@ -130,13 +253,54 @@ var LLMResponseParseError = class extends Error {
|
|
|
130
253
|
this.name = "LLMResponseParseError";
|
|
131
254
|
}
|
|
132
255
|
};
|
|
256
|
+
var VALID_COMMANDS = ["analyse", "grep", "read", "finish"];
|
|
257
|
+
function preprocessText(text) {
|
|
258
|
+
let processed = text.replace(/<think>[\s\S]*?<\/think>/gi, "");
|
|
259
|
+
const openingTagRegex = /<tool_call>|<tool>/gi;
|
|
260
|
+
const closingTagRegex = /<\/tool_call>|<\/tool>/gi;
|
|
261
|
+
const openingMatches = processed.match(openingTagRegex) || [];
|
|
262
|
+
const closingMatches = processed.match(closingTagRegex) || [];
|
|
263
|
+
if (openingMatches.length > closingMatches.length) {
|
|
264
|
+
const lastClosingMatch = /<\/tool_call>|<\/tool>/gi;
|
|
265
|
+
let lastClosingIndex = -1;
|
|
266
|
+
let match;
|
|
267
|
+
while ((match = lastClosingMatch.exec(processed)) !== null) {
|
|
268
|
+
lastClosingIndex = match.index + match[0].length;
|
|
269
|
+
}
|
|
270
|
+
if (lastClosingIndex > 0) {
|
|
271
|
+
processed = processed.slice(0, lastClosingIndex);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const toolCallLines = [];
|
|
275
|
+
const toolTagRegex = /<tool_call>([\s\S]*?)<\/tool_call>|<tool>([\s\S]*?)<\/tool>/gi;
|
|
276
|
+
let tagMatch;
|
|
277
|
+
while ((tagMatch = toolTagRegex.exec(processed)) !== null) {
|
|
278
|
+
const content = (tagMatch[1] || tagMatch[2] || "").trim();
|
|
279
|
+
if (content) {
|
|
280
|
+
const lines = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l);
|
|
281
|
+
toolCallLines.push(...lines);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const allLines = processed.split(/\r?\n/).map((l) => l.trim());
|
|
285
|
+
for (const line of allLines) {
|
|
286
|
+
if (!line) continue;
|
|
287
|
+
if (line.startsWith("<")) continue;
|
|
288
|
+
const firstWord = line.split(/\s/)[0];
|
|
289
|
+
if (VALID_COMMANDS.includes(firstWord)) {
|
|
290
|
+
if (!toolCallLines.includes(line)) {
|
|
291
|
+
toolCallLines.push(line);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return toolCallLines;
|
|
296
|
+
}
|
|
133
297
|
var LLMResponseParser = class {
|
|
134
298
|
finishSpecSplitRe = /,(?=[^,\s]+:)/;
|
|
135
299
|
parse(text) {
|
|
136
300
|
if (typeof text !== "string") {
|
|
137
301
|
throw new TypeError("Command text must be a string.");
|
|
138
302
|
}
|
|
139
|
-
const lines = text
|
|
303
|
+
const lines = preprocessText(text);
|
|
140
304
|
const commands = [];
|
|
141
305
|
let finishAccumulator = null;
|
|
142
306
|
lines.forEach((line, idx) => {
|
|
@@ -159,7 +323,7 @@ var LLMResponseParser = class {
|
|
|
159
323
|
finishAccumulator = this.handleFinish(parts, ctx, finishAccumulator);
|
|
160
324
|
break;
|
|
161
325
|
default:
|
|
162
|
-
|
|
326
|
+
break;
|
|
163
327
|
}
|
|
164
328
|
});
|
|
165
329
|
if (finishAccumulator) {
|
|
@@ -701,7 +865,23 @@ async function runWarpGrep(config) {
|
|
|
701
865
|
}
|
|
702
866
|
}
|
|
703
867
|
if (formatted.length > 0) {
|
|
704
|
-
|
|
868
|
+
const turnsUsed = round;
|
|
869
|
+
const turnsRemaining = 4 - turnsUsed;
|
|
870
|
+
let turnMessage;
|
|
871
|
+
if (turnsRemaining === 0) {
|
|
872
|
+
turnMessage = `
|
|
873
|
+
|
|
874
|
+
[Turn ${turnsUsed}/4] This is your LAST turn. You MUST call the finish tool now.`;
|
|
875
|
+
} else if (turnsRemaining === 1) {
|
|
876
|
+
turnMessage = `
|
|
877
|
+
|
|
878
|
+
[Turn ${turnsUsed}/4] You have 1 turn remaining. Next turn you MUST call the finish tool.`;
|
|
879
|
+
} else {
|
|
880
|
+
turnMessage = `
|
|
881
|
+
|
|
882
|
+
[Turn ${turnsUsed}/4] You have ${turnsRemaining} turns remaining.`;
|
|
883
|
+
}
|
|
884
|
+
messages.push({ role: "user", content: formatted.join("\n") + turnMessage });
|
|
705
885
|
}
|
|
706
886
|
if (finishCalls.length) {
|
|
707
887
|
const fc = finishCalls[0];
|