Declare a folder in the virtual project (no files created). This is a UI-level structure; it does not write files. Fails if a file with the same path exists. Args: folder_path: Folder path to declare. Returns: JSON string indicating creation or an error.
(ctx: RunContextWrapper[IDEContext], folder_path: str)
| 173 | |
| 174 | @function_tool |
| 175 | async def create_folder(ctx: RunContextWrapper[IDEContext], folder_path: str) -> str: |
| 176 | """Declare a folder in the virtual project (no files created). |
| 177 | |
| 178 | This is a UI-level structure; it does not write files. Fails if a file with |
| 179 | the same path exists. |
| 180 | |
| 181 | Args: |
| 182 | folder_path: Folder path to declare. |
| 183 | Returns: |
| 184 | JSON string indicating creation or an error. |
| 185 | """ |
| 186 | tool_id = f"tc_{len(ctx.context.events) + 1}" |
| 187 | args = {"folder_path": folder_path} |
| 188 | ctx.context.events.append( |
| 189 | { |
| 190 | "phase": "started", |
| 191 | "tool_id": tool_id, |
| 192 | "name": "create_folder", |
| 193 | "arguments": args, |
| 194 | } |
| 195 | ) |
| 196 | |
| 197 | # Folders are not tracked in project mapping; just emit event for UI |
| 198 | # But validate that it does not conflict with existing file |
| 199 | conflict = folder_path in ctx.context.project |
| 200 | if conflict: |
| 201 | output = { |
| 202 | "error": f"Conflicts with existing file: {folder_path}", |
| 203 | "folder_path": folder_path, |
| 204 | } |
| 205 | else: |
| 206 | output = {"folder_path": folder_path, "created": True} |
| 207 | |
| 208 | ctx.context.events.append( |
| 209 | { |
| 210 | "phase": "completed", |
| 211 | "tool_id": tool_id, |
| 212 | "name": "create_folder", |
| 213 | "output_data": output, |
| 214 | } |
| 215 | ) |
| 216 | return json.dumps(output) |
| 217 | |
| 218 | |
| 219 | @function_tool |
nothing calls this directly
no outgoing calls
no test coverage detected