[codefix]
Organizes TypeScript or JavaScript imports with TypeScript language-service edits.
Import cleanup should follow TypeScript project semantics instead of text sorting that can remove needed syntax or miss type-only imports.
The model can preview sorted, combined, or unused-import cleanup edits while preserving live document version guards.
Try it locally in the TGlider playground
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Workspace-relative or absolute file path. |
| applyChanges | boolean | No | Apply organize-import edits to live workspace state instead of returning preview only. |
| includeDiff | boolean | No | Include a unified diff in the response. |
| maxDiffChars | number | No | Maximum diff characters to return before truncating. |
| skipDestructiveCodeActions | boolean | No | Sort and combine imports without removing unused imports. |
Preview import organization edits
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "organize_imports",
"arguments": {
"filePath": "src/app.ts"
}
}
}Returns organize-import edits, preview diff metadata, live-document version state, and whether changes were applied.