ek9_delete_file
Answers first: status (applied | ready | conflicts | would-fail), written and, on a refusal, referenceCount + referencingFiles[] before the per-site conflicts[]; edits[{file, type:delete, disposition}].
When to use it
You want a whole file gone - one call with path; a .ek9 file is refused while other files still reference its constructs, unless force:true. The refusal lists them as referencingFiles.
When not to use it
- Deleting ONE construct inside a file that has others you keep - use
ek9_safe_delete(symbol:'Name', per-construct reference check). - Relocating rather than removing the file — use
ek9_move_file. - Only wanting to KNOW the reference impact without deleting — use
ek9_query_references. - Deleting a whole directory — use
ek9_delete_directory(this tool rejects directories).
Details
Path must resolve inside the workspace root; directories are rejected — files only. For .ek9 files a per-construct reference sweep (same-file refs excluded) yields status:'conflicts' (kind 'file-has-external-references', with referenceCount and referencingFiles first) when external refs exist and force is false, or status:'would-fail' on a forced dry-run with wouldBeDiagnostics kind 'broken-reference-after-force-delete' (one per site); non-.ek9 files delete directly with no check. useTrash=true routes via the OS trash when supported, else falls back to permanent deletion with a 'trash-unsupported-fell-back-to-permanent' warning — otherwise deletion is irreversible unless version-controlled.
Arguments
| Argument | Type | Required | What it is |
|---|---|---|---|
force | boolean | When false (default), the .ek9 reference check refuses deletion if workspace references point at constructs in the file. When true, the deletion proceeds REGARDLESS of references — the response includes warnings listing every reference that will fail to resolve. | |
path | string | yes | File path: workspace-relative (preferred) or absolute inside the workspace. Must exist and be a file (directories: ek9_delete_directory). |
useTrash | boolean | When true AND the runtime supports trash semantics, the file is moved to the OS trash rather than permanently deleted. Falls back to permanent deletion with a warning otherwise. |
It also takes the arguments every tool takes.
Recorded calls
Real calls, recorded against small projects and checked on every build - a changed answer fails it.
Delete non ek9 file apply
Request
{
"path" : "NOTES.txt"
}
Response
{
"conflicts" : [ ],
"edits" : [ {
"disposition" : "permanent",
"file" : "NOTES.txt",
"type" : "delete"
} ],
"meta" : {
"serverMs" : "<timing>"
},
"risk" : {
"crossesModuleBoundary" : false,
"estimatedSeverity" : "trivial",
"fileCount" : 1,
"lineCount" : 0,
"touchesPublicApi" : false,
"touchesTests" : false
},
"status" : "applied",
"summary" : "Deleted NOTES.txt",
"workspaceHash" : "<workspace-hash>",
"wouldBeDiagnostics" : [ ],
"written" : true
}
Delete referenced ek9 file conflicts
Request
{
"dryRun" : true,
"path" : "seed.ek9"
}
Response
{
"conflicts" : [ {
"kind" : "file-has-external-references",
"message" : "Construct 'com.example.seed::seed' declared in seed.ek9 is referenced at caller.ek9:5 (function_reference)",
"reference" : {
"column" : 22,
"declaringSymbol" : "com.example.seed::seed",
"file" : "caller.ek9",
"kind" : "function_reference",
"line" : 5,
"module" : "com.example.caller",
"symbol" : "seed"
}
}, {
"kind" : "file-has-external-references",
"message" : "Construct 'com.example.seed::seed' declared in seed.ek9 is referenced at caller.ek9:9 (function_call)",
"reference" : {
"column" : 6,
"declaringSymbol" : "com.example.seed::seed",
"file" : "caller.ek9",
"kind" : "function_call",
"line" : 9,
"module" : "com.example.caller",
"symbol" : "seed()"
...
Cut short here: 22 more lines. The whole recorded call.
See also
- Show me in the IDE: New EK9 File, New Directory, Delete File, Delete Directory