From 4974b40bd5126cb4215580c0d066057a973f50d1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 16 Aug 2025 23:29:37 +0300 Subject: feat(lsp): code action to rewrite selection with instruction detection - Adds textDocument/codeAction handler that rewrites the selected range.\n- Instruction preference: strict ;text; marker first, then //, #, -- line comments, then single-line block comments (/* */ and ). Earliest in the selection wins.\n- Removes the matched instruction from the selection before sending to LLM.\n- README: document code action workflow and instruction formats. --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 40102e4..6cd0827 100644 --- a/README.md +++ b/README.md @@ -92,3 +92,42 @@ Ensure `OPENAI_API_KEY` is set in your environment. ### Environment - Only `OPENAI_API_KEY` is read from the environment when `provider` is `openai`. + +## Inline triggers + +Hexai supports inline trigger tags you can type in your code to request an +action from the LLM and then clean up the tag automatically. + +- `;text;`: Do what is written in `text`, then remove just the `;text;` marker. + - Strict form: no space after the first `;` and no space before the last `;`. + - An optional single space immediately after the closing `;` is also removed. + - Multiple markers per line are supported. + - Example: `// TODO ;rename this function to add;` removes only the marker. + +- `;;text;`: Do what is written in `text`, then remove the entire line. + - Strict form: no space after `;;` and no space before the closing `;`. + - Any line containing such a marker is deleted after processing. + - Example: + ``` + some() ;;extract helper; // this entire line is removed + ``` + +- Spaced variants such as `; text ;` or `;; spaced ;` are ignored. + +## Code actions + +Hexai provides a code action for working with the current selection in Helix: + +- Rewrite selection: Select code and invoke code actions. Hexai looks for the + first instruction inside the selection and rewrites the selection accordingly. + +Instruction sources (first one found wins): +- Strict marker: `;text;` (no space after first `;`, none before last `;`). +- Line comments: `// text`, `# text`, `-- text`. +- Single-line block comments: `/* text */`, ``. + +Notes: +- Only the earliest instruction in the selection is used; Hexai removes that + marker/comment from the selection before sending it to the LLM. +- The action returns only the transformed code and replaces exactly the + selected range. -- cgit v1.2.3