diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/docs/walkthroughs/headless-mode.md | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/docs/docs/walkthroughs/headless-mode.md b/docs/docs/walkthroughs/headless-mode.md index 92382d77..d4f90264 100644 --- a/docs/docs/walkthroughs/headless-mode.md +++ b/docs/docs/walkthroughs/headless-mode.md @@ -5,23 +5,32 @@ To use headless mode: 1. `pip install continuedev` (using a virtual environment is recommended) -2. Create a config file (see the [`ContinueConfig` Reference](../reference/config.md) for all options) that includes the [Policy](../customization/other-configuration.md#custom-policies) you want to run -3. Import `continuedev` and call `start_headless_session` with either the path to your config file, or an instance of `ContinueConfig` +2. Import `continuedev` and call `run_step_headless` with the `Step` you would like to run Example: +Say you have the following file (`/path/to/file.py`): + ```python -from continuedev.headless import start_headless_session -from continuedev.core.config import ContinueConfig -from continuedev.core.models import Models -import asyncio - -config = ContinueConfig( - models=Models(...), - override_policy=MyPolicy() -) -asyncio.run(start_headless_session(config)) +def say_hello(name: str): + print(f"Hello, {name}") +``` + +and this function is imported and used in multiple places throughout your codebase. But the name parameter is new, and you need to change the function call everywhere it is used. You can use the script below to edit all usages of the function in your codebase: -# Alternatively, pass the path to a config file -asyncio.run(start_headless_session("/path/to/config.py")) +```python +from continuedev.headless import run_step_headless +from continuedev.models.main import Position, PositionInFile +from continuedev.plugins.steps.refactor import RefactorReferencesStep + +step = RefactorReferencesStep( + user_input="", + symbol_location=PositionInFile( + filepath="/path/to/file.py", + position=Position(line=0, character=5), + ), +) +run_step_headless(step=step) ``` + +Here we use Continue's built-in `RefactorReferencesStep`. By passing it the location (filepath and position) of the symbol (function, variable, etc.) that we want to update, Continue will automatically find all references to that symbol and prompt an LLM to make the edit requested in the `user_input` field. |