{"id":26304781,"url":"https://github.com/cablehead/anthropic-text-editor","last_synced_at":"2025-05-12T18:43:23.111Z","repository":{"id":282048585,"uuid":"944343462","full_name":"cablehead/anthropic-text-editor","owner":"cablehead","description":"A micro-CLI to apply tool calls from Anthropic for their text_editor_20250124 built-in computer use tool","archived":false,"fork":false,"pushed_at":"2025-03-12T14:17:33.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T14:48:10.066Z","etag":null,"topics":["ai","anthropic","anthropic-claude","claude","cli","file-manipulation","rust","text-editor","tool-calls"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cablehead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-07T07:22:42.000Z","updated_at":"2025-03-12T14:17:36.000Z","dependencies_parsed_at":"2025-03-12T14:48:12.302Z","dependency_job_id":"b889ec49-72cf-4c05-9bf5-86daa52f247c","html_url":"https://github.com/cablehead/anthropic-text-editor","commit_stats":null,"previous_names":["cablehead/anthropic-text-editor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fanthropic-text-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fanthropic-text-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fanthropic-text-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fanthropic-text-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cablehead","download_url":"https://codeload.github.com/cablehead/anthropic-text-editor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243630361,"owners_count":20322280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","anthropic","anthropic-claude","claude","cli","file-manipulation","rust","text-editor","tool-calls"],"created_at":"2025-03-15T08:18:40.303Z","updated_at":"2025-03-15T08:18:40.743Z","avatar_url":"https://github.com/cablehead.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anthropic Text Editor\n\nA Rust implementation of Anthropic's text editor tool for Claude, based on the\n[Python implementation](https://github.com/anthropics/anthropic-quickstarts/blob/main/computer-use-demo/computer_use_demo/tools/edit.py).\n\nThis implements the `text_editor_20250124` tool described in the\n[Anthropic documentation](https://docs.anthropic.com/en/docs/agents-and-tools/computer-use#understand-anthropic-defined-tools).\n\n## Overview\n\nThis CLI tool provides file system operations for Claude to view, create, and\nedit files. It communicates through a JSON protocol over stdin/stdout.\n\n## Install\n\n```bash\ncargo install --locked anthropic-text-editor\n```\n\n## Supported Commands\n\n- **view**: View file contents with line numbers (like `cat -n`) or directory listings\n- **create**: Create a new file with provided content\n- **str_replace**: Replace a specific string in a file (supports multiple replacements and regex patterns)\n- **insert**: Insert text at a specific line in a file\n- **delete**: Delete a range of lines from a file\n\n## Unsupported Commands\n\n- **undo_edit**: Unlike the Python implementation, this command is not supported\n  in the Rust version.\n\n  The CLI is designed to be run by a wrapper that handles versioning through\n  git. When Claude makes edits to files, the wrapper should commit those changes\n  with git, allowing for easy version control and the ability to undo changes\n  through git rather than through the editor itself. This simplifies the tool\n  implementation while providing more robust version control.\n\n## JSON Protocol\n\nThe CLI expects input in JSON format on stdin and produces JSON output on\nstdout:\n\n### Input Format\n\n```json\n{\n  \"input\": {\n    \"command\": \"view|create|str_replace|insert|delete\",\n    \"path\": \"/absolute/path/to/file\",\n    \"view_range\": [1, 10], // Optional, for view command on files\n    \"max_depth\": 3, // Optional, for view command on directories (defaults to 3)\n    \"old_str\": \"text to replace\", // Required for str_replace\n    \"new_str\": \"replacement text\", // Optional for str_replace, required for insert\n    \"allow_multi\": true, // Optional, for str_replace to allow multiple replacements\n    \"use_regex\": true, // Optional, for str_replace to use regex pattern matching\n    \"delete_range\": [1, 5], // Required for delete, specifies line range to remove\n    \"insert_line\": 5, // Required for insert\n    \"file_text\": \"content\" // Required for create\n  }\n}\n```\n\n### Output Format\n\n```json\n{\n  \"content\": \"result of the operation\",\n  \"is_error\": true // Present only on error\n}\n```\n\nFor the `view` command on files, the output includes line numbers:\n\n```\n\"content\": \"Here's the result of running `cat -n` on /path/to/file.txt:\\n     1\\tLine 1\\n     2\\tLine 2\\n     3\\tLine 3\\n\"\n```\n\n## Usage\n\n```\ncat input.json | anthropic-text-editor\n```\n\n### Quick Examples\n\n```bash\n# View a file\necho '{\"input\":{\"command\":\"view\",\"path\":\"/path/to/file.txt\"}}' | anthropic-text-editor\n\n# Create a new file\necho '{\"input\":{\"command\":\"create\",\"path\":\"/path/to/new.txt\",\"file_text\":\"Hello world\"}}' | anthropic-text-editor\n\n# Replace text in a file\necho '{\"input\":{\"command\":\"str_replace\",\"path\":\"/path/to/file.txt\",\"old_str\":\"foo\",\"new_str\":\"bar\"}}' | anthropic-text-editor\n```\n\n### Example: Adding Content to README\n\nHere's a meta example that shows how to use the tool to modify this README:\n\n```json\n{\n  \"input\": {\n    \"command\": \"str_replace\",\n    \"path\": \"/path/to/README.md\",\n    \"old_str\": \"## Usage\\n\\n```\\ncat input.json | anthropic-text-editor\\n```\",\n    \"new_str\": \"## Usage\\n\\n```\\ncat input.json | anthropic-text-editor\\n```\\n\\n### Quick Examples\\n\\n```bash\\n# View a file\\necho '{\\\"input\\\":{\\\"command\\\":\\\"view\\\",\\\"path\\\":\\\"/path/to/file.txt\\\"}}' | anthropic-text-editor\\n\\n# Create a new file\\necho '{\\\"input\\\":{\\\"command\\\":\\\"create\\\",\\\"path\\\":\\\"/path/to/new.txt\\\",\\\"file_text\\\":\\\"Hello world\\\"}}' | anthropic-text-editor\\n\\n# Replace text in a file\\necho '{\\\"input\\\":{\\\"command\\\":\\\"str_replace\\\",\\\"path\\\":\\\"/path/to/file.txt\\\",\\\"old_str\\\":\\\"foo\\\",\\\"new_str\\\":\\\"bar\\\"}}' | anthropic-text-editor\\n```\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fanthropic-text-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcablehead%2Fanthropic-text-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fanthropic-text-editor/lists"}