Android File
Use the nine focused workspace tools:
find: inspect one path, list a directory, or find paths with a glob pattern
grep: search decoded text content
read: read text or extract supported document text
write: explicitly create, overwrite, or append text
edit: replace a verified text match
mkdir: create an empty directory
copy: copy a file or directory while preserving the source
move: move or rename a file or directory
delete: delete a file or directory only when the user explicitly requests removal
Discovery and inspection
Use find for path and metadata questions:
find(path=".") lists direct children.
find(path="README.md", max_depth=0) inspects one file.
find(path="app/src", pattern="**/*.kt", max_depth=12, kind="file") replaces glob.
find returns structured base and entries. It does not follow symbolic links. Check
truncated and truncation_reason before assuming the result is complete.
Use grep only for file contents. Directory grep detects every file independently; never pass
one encoding for a directory tree.
Reading and editing
- Inspect or locate paths with
find.
- Read the relevant range with
read; continue with both next_start_line and
next_start_column whenever the bounded response is truncated.
- Keep the returned
revision when concurrent modification is possible.
- Use
edit for a stable local replacement.
- Use
write only when creating or replacing complete content.
- Validate with
read or grep.
write.mode is required:
create: fail if the target exists
overwrite: replace the whole file with canonical UTF-8
append: preserve the existing charset and BOM
edit defaults to occurrence="unique". Use first or all only when that scope is intended.
Legacy text detected statistically requires an explicit encoding before append or edit.
Path mutations
- Prefer non-destructive operations. Unless the user's current request explicitly requires
deletion, do not call
delete. Do not delete files merely to tidy the workspace; leave them
intact and report them when needed.
- Use
mkdir for empty directories.
- Use
copy when the source must remain.
- Use
move for relocation and rename.
- Directory copy requires
recursive=true.
- Existing destinations are rejected unless
overwrite=true.
- Non-empty directory deletion requires
recursive=true.
Recursive delete, destination overwrite, and external shared-storage modification require user
confirmation. Cancellation performs no write.
Common calls
find(path=".", pattern="**/*.md", max_depth=4, kind="file")
read(path="README.md", start_line=1, max_lines=200)
grep(query="WorkspacePathResolver", path="app/src", file_glob="**/*.kt")
write(path="notes.md", text="...", mode="create")
edit(path="notes.md", find="old", replace="new", occurrence="unique")
mkdir(path="artifacts/output")
copy(source="report.md", destination="archive/report.md", create_parent=true)
move(source="draft.md", destination="final.md")
delete(path="scratch/old", recursive=true)
Failure recovery
path_outside_workspace: use the current workspace or shared://.
symbolic_link_not_allowed: use the real workspace path.
operation_limit_exceeded: split a large directory operation.
target_exists: choose another target or explicitly request overwrite.
file_changed: read again and retry with the new revision.
encoding_required_for_mutation: pass the verified legacy encoding.
move_recovery_required: inspect the reported source, destination, and backup paths before retrying.
confirmation_unavailable: open the app UI and retry.
1---2name: android-file3description: Operate workspace files with find, grep, read, write, edit, mkdir, copy, move, and delete, including structured results, encoding preservation, atomic text updates, sandbox limits, and permission recovery.4---5
6# Android File
7
8Use the nine focused workspace tools:
9
10- `find`: inspect one path, list a directory, or find paths with a glob pattern
11- `grep`: search decoded text content
12- `read`: read text or extract supported document text
13- `write`: explicitly create, overwrite, or append text
14- `edit`: replace a verified text match
15- `mkdir`: create an empty directory
16- `copy`: copy a file or directory while preserving the source
17- `move`: move or rename a file or directory
18- `delete`: delete a file or directory only when the user explicitly requests removal
19
20## Discovery and inspection
21
22Use `find` for path and metadata questions:
23
24- `find(path=".")` lists direct children.
25- `find(path="README.md", max_depth=0)` inspects one file.
26- `find(path="app/src", pattern="**/*.kt", max_depth=12, kind="file")` replaces glob.
27
28`find` returns structured `base` and `entries`. It does not follow symbolic links. Check
29`truncated` and `truncation_reason` before assuming the result is complete.
30
31Use `grep` only for file contents. Directory grep detects every file independently; never pass
32one `encoding` for a directory tree.
33
34## Reading and editing
35
361. Inspect or locate paths with `find`.
372. Read the relevant range with `read`; continue with both `next_start_line` and
38 `next_start_column` whenever the bounded response is truncated.
393. Keep the returned `revision` when concurrent modification is possible.
404. Use `edit` for a stable local replacement.
415. Use `write` only when creating or replacing complete content.
426. Validate with `read` or `grep`.
43
44`write.mode` is required:
45
46- `create`: fail if the target exists
47- `overwrite`: replace the whole file with canonical UTF-8
48- `append`: preserve the existing charset and BOM
49
50`edit` defaults to `occurrence="unique"`. Use `first` or `all` only when that scope is intended.
51Legacy text detected statistically requires an explicit `encoding` before append or edit.
52
53## Path mutations
54
55- Prefer non-destructive operations. Unless the user's current request explicitly requires
56 deletion, do not call `delete`. Do not delete files merely to tidy the workspace; leave them
57 intact and report them when needed.
58- Use `mkdir` for empty directories.
59- Use `copy` when the source must remain.
60- Use `move` for relocation and rename.
61- Directory copy requires `recursive=true`.
62- Existing destinations are rejected unless `overwrite=true`.
63- Non-empty directory deletion requires `recursive=true`.
64
65Recursive delete, destination overwrite, and external shared-storage modification require user
66confirmation. Cancellation performs no write.
67
68## Common calls
69
70- `find(path=".", pattern="**/*.md", max_depth=4, kind="file")`
71- `read(path="README.md", start_line=1, max_lines=200)`
72- `grep(query="WorkspacePathResolver", path="app/src", file_glob="**/*.kt")`
73- `write(path="notes.md", text="...", mode="create")`
74- `edit(path="notes.md", find="old", replace="new", occurrence="unique")`
75- `mkdir(path="artifacts/output")`
76- `copy(source="report.md", destination="archive/report.md", create_parent=true)`
77- `move(source="draft.md", destination="final.md")`
78- `delete(path="scratch/old", recursive=true)`
79
80## Failure recovery
81
82- `path_outside_workspace`: use the current workspace or `shared://`.
83- `symbolic_link_not_allowed`: use the real workspace path.
84- `operation_limit_exceeded`: split a large directory operation.
85- `target_exists`: choose another target or explicitly request overwrite.
86- `file_changed`: read again and retry with the new revision.
87- `encoding_required_for_mutation`: pass the verified legacy encoding.
88- `move_recovery_required`: inspect the reported source, destination, and backup paths before retrying.
89- `confirmation_unavailable`: open the app UI and retry.