@morphllm/morphsdk 0.2.45 → 0.2.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-TVFGHXPE.js → chunk-3FTAIJBH.js} +4 -4
  3. package/dist/chunk-5JTJOQUX.js +283 -0
  4. package/dist/chunk-5JTJOQUX.js.map +1 -0
  5. package/dist/{chunk-ZRLEAPZV.js → chunk-76DJEQEP.js} +4 -4
  6. package/dist/{chunk-W3XLPMV3.js → chunk-7HS6YXA3.js} +21 -5
  7. package/dist/{chunk-W3XLPMV3.js.map → chunk-7HS6YXA3.js.map} +1 -1
  8. package/dist/chunk-7T7YOPJV.js +82 -0
  9. package/dist/chunk-7T7YOPJV.js.map +1 -0
  10. package/dist/chunk-CL45IWIU.js +105 -0
  11. package/dist/chunk-CL45IWIU.js.map +1 -0
  12. package/dist/chunk-D6OD3IST.js +70 -0
  13. package/dist/chunk-D6OD3IST.js.map +1 -0
  14. package/dist/{chunk-PEGZVGG4.js → chunk-G4AWE5A2.js} +4 -4
  15. package/dist/{chunk-OUEJ6XEO.js → chunk-GJU7UOFL.js} +4 -4
  16. package/dist/{chunk-Q7PDN7TS.js → chunk-GZMUGMOZ.js} +1 -1
  17. package/dist/{chunk-Q7PDN7TS.js.map → chunk-GZMUGMOZ.js.map} +1 -1
  18. package/dist/chunk-JYBVRF72.js +1 -0
  19. package/dist/{chunk-GDR65N2J.js → chunk-OXHGFHEU.js} +53 -26
  20. package/dist/chunk-OXHGFHEU.js.map +1 -0
  21. package/dist/{chunk-VBBJGWHY.js → chunk-P2XKFWFD.js} +2 -2
  22. package/dist/chunk-PABIV7X6.js +76 -0
  23. package/dist/chunk-PABIV7X6.js.map +1 -0
  24. package/dist/{chunk-GTOXMAF2.js → chunk-SWQPIKPY.js} +44 -3
  25. package/dist/chunk-SWQPIKPY.js.map +1 -0
  26. package/dist/chunk-TJIUA27P.js +94 -0
  27. package/dist/chunk-TJIUA27P.js.map +1 -0
  28. package/dist/{chunk-O5DA5V5S.js → chunk-UBX7QYBD.js} +4 -4
  29. package/dist/{chunk-X4CQ6D3G.js → chunk-UIZT3KVJ.js} +4 -4
  30. package/dist/{chunk-UYBIKZPM.js → chunk-UXYK7WZX.js} +2 -2
  31. package/dist/chunk-WETRQJGU.js +129 -0
  32. package/dist/chunk-WETRQJGU.js.map +1 -0
  33. package/dist/client-BGctTHu9.d.ts +318 -0
  34. package/dist/client.cjs +1885 -44
  35. package/dist/client.cjs.map +1 -1
  36. package/dist/client.d.ts +14 -110
  37. package/dist/client.js +28 -3
  38. package/dist/core-DxiUwyBe.d.ts +156 -0
  39. package/dist/git/client.cjs +52 -25
  40. package/dist/git/client.cjs.map +1 -1
  41. package/dist/git/client.d.ts +17 -8
  42. package/dist/git/client.js +1 -1
  43. package/dist/git/index.cjs +52 -25
  44. package/dist/git/index.cjs.map +1 -1
  45. package/dist/git/index.d.ts +1 -1
  46. package/dist/git/index.js +2 -2
  47. package/dist/git/types.cjs.map +1 -1
  48. package/dist/git/types.d.ts +20 -2
  49. package/dist/index.cjs +1964 -46
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.ts +8 -1
  52. package/dist/index.js +47 -5
  53. package/dist/tools/codebase_search/anthropic.js +2 -2
  54. package/dist/tools/codebase_search/index.js +9 -9
  55. package/dist/tools/codebase_search/openai.js +2 -2
  56. package/dist/tools/codebase_search/vercel.js +2 -2
  57. package/dist/tools/fastapply/anthropic.js +2 -2
  58. package/dist/tools/fastapply/index.js +7 -7
  59. package/dist/tools/fastapply/openai.js +2 -2
  60. package/dist/tools/fastapply/vercel.js +2 -2
  61. package/dist/tools/index.js +7 -7
  62. package/dist/tools/warp_grep/agent/config.cjs +80 -1
  63. package/dist/tools/warp_grep/agent/config.cjs.map +1 -1
  64. package/dist/tools/warp_grep/agent/config.js +1 -1
  65. package/dist/tools/warp_grep/agent/parser.cjs +43 -2
  66. package/dist/tools/warp_grep/agent/parser.cjs.map +1 -1
  67. package/dist/tools/warp_grep/agent/parser.js +1 -1
  68. package/dist/tools/warp_grep/agent/prompt.cjs +89 -45
  69. package/dist/tools/warp_grep/agent/prompt.cjs.map +1 -1
  70. package/dist/tools/warp_grep/agent/prompt.d.ts +1 -1
  71. package/dist/tools/warp_grep/agent/prompt.js +1 -1
  72. package/dist/tools/warp_grep/agent/runner.cjs +229 -49
  73. package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
  74. package/dist/tools/warp_grep/agent/runner.js +4 -4
  75. package/dist/tools/warp_grep/agent/types.js +0 -1
  76. package/dist/tools/warp_grep/anthropic.cjs +311 -83
  77. package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
  78. package/dist/tools/warp_grep/anthropic.d.ts +75 -12
  79. package/dist/tools/warp_grep/anthropic.js +21 -8
  80. package/dist/tools/warp_grep/index.cjs +415 -126
  81. package/dist/tools/warp_grep/index.cjs.map +1 -1
  82. package/dist/tools/warp_grep/index.d.ts +17 -4
  83. package/dist/tools/warp_grep/index.js +29 -21
  84. package/dist/tools/warp_grep/openai.cjs +314 -83
  85. package/dist/tools/warp_grep/openai.cjs.map +1 -1
  86. package/dist/tools/warp_grep/openai.d.ts +73 -29
  87. package/dist/tools/warp_grep/openai.js +21 -8
  88. package/dist/tools/warp_grep/providers/command.cjs +80 -1
  89. package/dist/tools/warp_grep/providers/command.cjs.map +1 -1
  90. package/dist/tools/warp_grep/providers/command.js +2 -2
  91. package/dist/tools/warp_grep/providers/local.cjs +80 -1
  92. package/dist/tools/warp_grep/providers/local.cjs.map +1 -1
  93. package/dist/tools/warp_grep/providers/local.js +2 -2
  94. package/dist/tools/warp_grep/vercel.cjs +291 -57
  95. package/dist/tools/warp_grep/vercel.cjs.map +1 -1
  96. package/dist/tools/warp_grep/vercel.d.ts +40 -19
  97. package/dist/tools/warp_grep/vercel.js +17 -8
  98. package/package.json +1 -1
  99. package/dist/chunk-AFEPUNAO.js +0 -15
  100. package/dist/chunk-AFEPUNAO.js.map +0 -1
  101. package/dist/chunk-GDR65N2J.js.map +0 -1
  102. package/dist/chunk-GTOXMAF2.js.map +0 -1
  103. package/dist/chunk-HKZB23U7.js +0 -85
  104. package/dist/chunk-HKZB23U7.js.map +0 -1
  105. package/dist/chunk-IQHKEIQX.js +0 -54
  106. package/dist/chunk-IQHKEIQX.js.map +0 -1
  107. package/dist/chunk-JKFVDM62.js +0 -45
  108. package/dist/chunk-JKFVDM62.js.map +0 -1
  109. package/dist/chunk-K6FQZZ2E.js +0 -104
  110. package/dist/chunk-K6FQZZ2E.js.map +0 -1
  111. package/dist/chunk-KL4YVZRF.js +0 -57
  112. package/dist/chunk-KL4YVZRF.js.map +0 -1
  113. package/dist/chunk-XYPMN4A3.js +0 -1
  114. /package/dist/{chunk-TVFGHXPE.js.map → chunk-3FTAIJBH.js.map} +0 -0
  115. /package/dist/{chunk-ZRLEAPZV.js.map → chunk-76DJEQEP.js.map} +0 -0
  116. /package/dist/{chunk-PEGZVGG4.js.map → chunk-G4AWE5A2.js.map} +0 -0
  117. /package/dist/{chunk-OUEJ6XEO.js.map → chunk-GJU7UOFL.js.map} +0 -0
  118. /package/dist/{chunk-XYPMN4A3.js.map → chunk-JYBVRF72.js.map} +0 -0
  119. /package/dist/{chunk-VBBJGWHY.js.map → chunk-P2XKFWFD.js.map} +0 -0
  120. /package/dist/{chunk-O5DA5V5S.js.map → chunk-UBX7QYBD.js.map} +0 -0
  121. /package/dist/{chunk-X4CQ6D3G.js.map → chunk-UIZT3KVJ.js.map} +0 -0
  122. /package/dist/{chunk-UYBIKZPM.js.map → chunk-UXYK7WZX.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 snippets based on a search query.
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 operate in exactly 3 rounds of tool exploration, followed by a final answer:
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
- 1. In each round, you can make MULTIPLE tool calls (up to 8) to search in parallel. All tool results will be returned together after each round.
33
- 2. After your third round of tool calls, your next turn MUST be a single call to the \`finish\` tool with all the context you have found.
34
- </workflow>
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
- <tool_calling>
37
- You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
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
- ### 1. \`analyse\` - Explore Directories
40
- Explore directory structure in a tree-like format.
41
- **Syntax:** \`analyse <path> [pattern]\`
42
- - \`<path>\`: Directory path to analyze (defaults to \`.\`)
43
- - \`[pattern]\`: Optional regex pattern to filter names
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
- For example:
46
+ Examples:
46
47
  \`\`\`
48
+ analyse .
47
49
  analyse src/api
48
- analyse . "test"
50
+ analyse . ".*\\.ts$"
51
+ analyse src "test.*"
49
52
  \`\`\`
50
53
 
51
- ### 2. \`read\` - Read File Contents
52
- Read entire files or specific line ranges.
53
- **Syntax:** \`read <path>[:start-end]\`
54
- - \`<path>\`: File path to read
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
- For example:
59
+ Examples:
58
60
  \`\`\`
59
61
  read src/main.py
60
- read src/database/connection.py:10-50
62
+ read src/db/conn.py:10-50
63
+ read package.json:1-20
61
64
  \`\`\`
62
65
 
63
- ### 3. \`grep\` - Search with Regex
64
- Search for regex patterns across files using ripgrep.
65
- **Syntax:** \`grep '<pattern>' <path>\`
66
- - \`'<pattern>'\`: Regex pattern (always wrap in single quotes)
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
- For example:
71
+ Examples:
70
72
  \`\`\`
71
- grep 'create_user' .
72
- grep 'import.*requests' src/api
73
- grep 'class\\\\s+AuthService' controllers/auth.py
73
+ grep 'class.*Service' src/
74
+ grep 'def authenticate' .
75
+ grep 'import.*from' src/components/
76
+ grep 'TODO' .
74
77
  \`\`\`
75
78
 
76
- ### 4. \`finish\` - Submit Final Answer
77
- Submit your findings when complete.
78
- **Syntax:** \`finish <file1:range1,range2...> [file2:range3...]\`
79
- - Provide file paths with colon-separated, comma-separated line ranges
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
- For example:
87
+ Examples:
82
88
  \`\`\`
83
- finish src/api/auth.py:25-50,75-80 src/models/user.py:10-15
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
- </tool_calling>
92
+ </tools>
86
93
 
87
94
  <strategy>
88
- - Use the \`analyse\`, \`grep\`, and \`read\` tools to gather information about the codebase.
89
- - Leverage the tools smartly to make full use of their potential
90
- - Make parallel tool calls within each round to investigate multiple paths or files efficiently
91
- - Be systematic and thorough within your 3-round limit
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
- - Only output tool calls themselves
96
- - Do not include explanatory text, reasoning, or commentary
97
- - Each tool call should be on its own line
98
- - After 3 rounds of exploration, call \`finish\` with all relevant code snippets you found
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 snippets based on a search query.\n\n<workflow>\nYou operate in exactly 3 rounds of tool exploration, followed by a final answer:\n\n1. In each round, you can make MULTIPLE tool calls (up to 8) to search in parallel. All tool results will be returned together after each round.\n2. After your third round of tool calls, your next turn MUST be a single call to the \\`finish\\` tool with all the context you have found.\n</workflow>\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n\n### 1. \\`analyse\\` - Explore Directories\nExplore directory structure in a tree-like format.\n**Syntax:** \\`analyse <path> [pattern]\\`\n- \\`<path>\\`: Directory path to analyze (defaults to \\`.\\`)\n- \\`[pattern]\\`: Optional regex pattern to filter names\n\nFor example:\n\\`\\`\\`\nanalyse src/api\nanalyse . \"test\"\n\\`\\`\\`\n\n### 2. \\`read\\` - Read File Contents\nRead entire files or specific line ranges.\n**Syntax:** \\`read <path>[:start-end]\\`\n- \\`<path>\\`: File path to read\n- \\`[:start-end]\\`: Optional 1-based, inclusive line range\n\nFor example:\n\\`\\`\\`\nread src/main.py\nread src/database/connection.py:10-50\n\\`\\`\\`\n\n### 3. \\`grep\\` - Search with Regex\nSearch for regex patterns across files using ripgrep.\n**Syntax:** \\`grep '<pattern>' <path>\\`\n- \\`'<pattern>'\\`: Regex pattern (always wrap in single quotes)\n- \\`<path>\\`: Directory or file to search (use \\`.\\` for the repo root)\n\nFor example:\n\\`\\`\\`\ngrep 'create_user' .\ngrep 'import.*requests' src/api\ngrep 'class\\\\\\\\s+AuthService' controllers/auth.py\n\\`\\`\\`\n\n### 4. \\`finish\\` - Submit Final Answer\nSubmit your findings when complete.\n**Syntax:** \\`finish <file1:range1,range2...> [file2:range3...]\\`\n- Provide file paths with colon-separated, comma-separated line ranges\n\nFor example:\n\\`\\`\\`\nfinish src/api/auth.py:25-50,75-80 src/models/user.py:10-15\n\\`\\`\\`\n</tool_calling>\n\n<strategy>\n- Use the \\`analyse\\`, \\`grep\\`, and \\`read\\` tools to gather information about the codebase.\n- Leverage the tools smartly to make full use of their potential\n- Make parallel tool calls within each round to investigate multiple paths or files efficiently\n- Be systematic and thorough within your 3-round limit\n</strategy>\n\n<output_format>\n- Only output tool calls themselves\n- Do not include explanatory text, reasoning, or commentary\n- Each tool call should be on its own line\n- After 3 rounds of exploration, call \\`finish\\` with all relevant code snippets you found\n</output_format>\n\nBegin your exploration now to find code relevant to the query.`;\n\nexport function getSystemPrompt(): string {\n\treturn SYSTEM_PROMPT;\n}\n\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;AA4EtB,SAAS,kBAA0B;AACzC,SAAO;AACR;","names":[]}
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 snippets based on a search query.\n\n<workflow>\nYou operate in exactly 3 rounds of tool exploration, followed by a final answer:\n\n1. In each round, you can make MULTIPLE tool calls (up to 8) to search in parallel. All tool results will be returned together after each round.\n2. After your third round of tool calls, your next turn MUST be a single call to the `finish` tool with all the context you have found.\n</workflow>\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n\n### 1. `analyse` - Explore Directories\nExplore directory structure in a tree-like format.\n**Syntax:** `analyse <path> [pattern]`\n- `<path>`: Directory path to analyze (defaults to `.`)\n- `[pattern]`: Optional regex pattern to filter names\n\nFor example:\n```\nanalyse src/api\nanalyse . \"test\"\n```\n\n### 2. `read` - Read File Contents\nRead entire files or specific line ranges.\n**Syntax:** `read <path>[:start-end]`\n- `<path>`: File path to read\n- `[:start-end]`: Optional 1-based, inclusive line range\n\nFor example:\n```\nread src/main.py\nread src/database/connection.py:10-50\n```\n\n### 3. `grep` - Search with Regex\nSearch for regex patterns across files using ripgrep.\n**Syntax:** `grep '<pattern>' <path>`\n- `'<pattern>'`: Regex pattern (always wrap in single quotes)\n- `<path>`: Directory or file to search (use `.` for the repo root)\n\nFor example:\n```\ngrep 'create_user' .\ngrep 'import.*requests' src/api\ngrep 'class\\\\s+AuthService' controllers/auth.py\n```\n\n### 4. `finish` - Submit Final Answer\nSubmit your findings when complete.\n**Syntax:** `finish <file1:range1,range2...> [file2:range3...]`\n- Provide file paths with colon-separated, comma-separated line ranges\n\nFor example:\n```\nfinish src/api/auth.py:25-50,75-80 src/models/user.py:10-15\n```\n</tool_calling>\n\n<strategy>\n- Use the `analyse`, `grep`, and `read` tools to gather information about the codebase.\n- Leverage the tools smartly to make full use of their potential\n- Make parallel tool calls within each round to investigate multiple paths or files efficiently\n- Be systematic and thorough within your 3-round limit\n</strategy>\n\n<output_format>\n- Only output tool calls themselves\n- Do not include explanatory text, reasoning, or commentary\n- Each tool call should be on its own line\n- After 3 rounds of exploration, call `finish` with all relevant code snippets you found\n</output_format>\n\nBegin your exploration now to find code relevant to the query.";
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 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SYSTEM_PROMPT,
3
3
  getSystemPrompt
4
- } from "../../../chunk-HKZB23U7.js";
4
+ } from "../../../chunk-WETRQJGU.js";
5
5
  import "../../../chunk-PZ5AY32C.js";
6
6
  export {
7
7
  SYSTEM_PROMPT,
@@ -40,84 +40,207 @@ var AGENT_CONFIG = {
40
40
  MAX_ROUNDS: 10,
41
41
  TIMEOUT_MS: 3e4
42
42
  };
43
- var DEFAULT_EXCLUDES = (process.env.MORPH_WARP_GREP_EXCLUDE || "").split(",").map((s) => s.trim()).filter(Boolean).concat(["node_modules", ".git", "dist", "build", ".cache", "venv", "target"]);
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 snippets based on a search query.
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 operate in exactly 3 rounds of tool exploration, followed by a final answer:
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
- 1. In each round, you can make MULTIPLE tool calls (up to 8) to search in parallel. All tool results will be returned together after each round.
53
- 2. After your third round of tool calls, your next turn MUST be a single call to the \`finish\` tool with all the context you have found.
54
- </workflow>
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
- <tool_calling>
57
- You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
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
- ### 1. \`analyse\` - Explore Directories
60
- Explore directory structure in a tree-like format.
61
- **Syntax:** \`analyse <path> [pattern]\`
62
- - \`<path>\`: Directory path to analyze (defaults to \`.\`)
63
- - \`[pattern]\`: Optional regex pattern to filter names
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
- For example:
145
+ Examples:
66
146
  \`\`\`
147
+ analyse .
67
148
  analyse src/api
68
- analyse . "test"
149
+ analyse . ".*\\.ts$"
150
+ analyse src "test.*"
69
151
  \`\`\`
70
152
 
71
- ### 2. \`read\` - Read File Contents
72
- Read entire files or specific line ranges.
73
- **Syntax:** \`read <path>[:start-end]\`
74
- - \`<path>\`: File path to read
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
- For example:
158
+ Examples:
78
159
  \`\`\`
79
160
  read src/main.py
80
- read src/database/connection.py:10-50
161
+ read src/db/conn.py:10-50
162
+ read package.json:1-20
81
163
  \`\`\`
82
164
 
83
- ### 3. \`grep\` - Search with Regex
84
- Search for regex patterns across files using ripgrep.
85
- **Syntax:** \`grep '<pattern>' <path>\`
86
- - \`'<pattern>'\`: Regex pattern (always wrap in single quotes)
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
- For example:
170
+ Examples:
90
171
  \`\`\`
91
- grep 'create_user' .
92
- grep 'import.*requests' src/api
93
- grep 'class\\\\s+AuthService' controllers/auth.py
172
+ grep 'class.*Service' src/
173
+ grep 'def authenticate' .
174
+ grep 'import.*from' src/components/
175
+ grep 'TODO' .
94
176
  \`\`\`
95
177
 
96
- ### 4. \`finish\` - Submit Final Answer
97
- Submit your findings when complete.
98
- **Syntax:** \`finish <file1:range1,range2...> [file2:range3...]\`
99
- - Provide file paths with colon-separated, comma-separated line ranges
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
- For example:
186
+ Examples:
102
187
  \`\`\`
103
- finish src/api/auth.py:25-50,75-80 src/models/user.py:10-15
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
- </tool_calling>
191
+ </tools>
106
192
 
107
193
  <strategy>
108
- - Use the \`analyse\`, \`grep\`, and \`read\` tools to gather information about the codebase.
109
- - Leverage the tools smartly to make full use of their potential
110
- - Make parallel tool calls within each round to investigate multiple paths or files efficiently
111
- - Be systematic and thorough within your 3-round limit
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
- - Only output tool calls themselves
116
- - Do not include explanatory text, reasoning, or commentary
117
- - Each tool call should be on its own line
118
- - After 3 rounds of exploration, call \`finish\` with all relevant code snippets you found
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.split(/\r?\n/).map((l) => l.trim());
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
- throw new LLMResponseParseError(`Line ${ctx.lineNumber}: Unsupported command '${cmd}'`);
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
- messages.push({ role: "user", content: formatted.join("\n") });
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];