summaryrefslogtreecommitdiff
path: root/continuedev/src
diff options
context:
space:
mode:
Diffstat (limited to 'continuedev/src')
-rw-r--r--continuedev/src/continuedev/core/policy.py2
-rw-r--r--continuedev/src/continuedev/server/session_manager.py4
-rw-r--r--continuedev/src/continuedev/steps/README.md50
3 files changed, 53 insertions, 3 deletions
diff --git a/continuedev/src/continuedev/core/policy.py b/continuedev/src/continuedev/core/policy.py
index 1000f0f4..05f03bdc 100644
--- a/continuedev/src/continuedev/core/policy.py
+++ b/continuedev/src/continuedev/core/policy.py
@@ -40,7 +40,7 @@ def parse_custom_command(inp: str, config: ContinueConfig) -> Union[None, Step]:
return None
-class DemoPolicy(Policy):
+class DefaultPolicy(Policy):
ran_code_last: bool = False
def next(self, config: ContinueConfig, history: History) -> Step:
diff --git a/continuedev/src/continuedev/server/session_manager.py b/continuedev/src/continuedev/server/session_manager.py
index 90172a4e..20219273 100644
--- a/continuedev/src/continuedev/server/session_manager.py
+++ b/continuedev/src/continuedev/server/session_manager.py
@@ -7,7 +7,7 @@ import json
from ..libs.util.paths import getSessionFilePath, getSessionsFolderPath
from ..models.filesystem_edit import FileEditWithFullContents
from ..libs.constants.main import CONTINUE_SESSIONS_FOLDER
-from ..core.policy import DemoPolicy
+from ..core.policy import DefaultPolicy
from ..core.main import FullState
from ..core.autopilot import Autopilot
from .ide_protocol import AbstractIdeProtocolServer
@@ -65,7 +65,7 @@ class SessionManager:
full_state = FullState(**json.load(f))
autopilot = await DemoAutopilot.create(
- policy=DemoPolicy(), ide=ide, full_state=full_state)
+ policy=DefaultPolicy(), ide=ide, full_state=full_state)
session_id = session_id or str(uuid4())
ide.session_id = session_id
session = Session(session_id=session_id, autopilot=autopilot)
diff --git a/continuedev/src/continuedev/steps/README.md b/continuedev/src/continuedev/steps/README.md
new file mode 100644
index 00000000..12073835
--- /dev/null
+++ b/continuedev/src/continuedev/steps/README.md
@@ -0,0 +1,50 @@
+# Steps
+
+Steps are the composable unit of action in Continue. They define a `run` method which has access to the entire `ContinueSDK`, allowing you to take actions inside the IDE, call language models, and more. In this folder you can find a number of good examples.
+
+## How to write a step
+
+a. Start by creating a subclass of `Step`
+
+You should first consider what will be the parameters of your recipe. These are defined as attributes in the Pydantic class. For example, if you wanted a "filepath" attribute that would look like this:
+
+```python
+class HelloWorldStep(Step):
+ filepath: str
+ ...
+```
+
+b. Next, write the `run` method
+
+This method takes the ContinueSDK as a parameter, giving you all the tools you need to write your steps (if it's missing something, let us know, we'll add it!). You can write any code inside the run method; this is what will happen when your step is run, line for line. As an example, here's a step that will open a file and append "Hello World!":
+
+```python
+class HelloWorldStep(Step):
+ filepath: str
+
+ async def run(self, sdk: ContinueSDK):
+ await sdk.ide.setFileOpen(self.filepath)
+ await sdk.append_to_file(self.filepath, "Hello World!")
+```
+
+c. Finally, every Step is displayed with a description of what it has done
+
+If you'd like to override the default description of your step, which is just the class name, then implement the `describe` method. You can:
+
+- Return a static string
+- Store state in a class attribute (prepend with a double underscore, which signifies (through Pydantic) that this is not a parameter for the Step, just internal state) during the run method, and then grab this in the describe method.
+- Use state in conjunction with the `models` parameter of the describe method to autogenerate a description with a language model. For example, if you'd used an attribute called `__code_written` to store a string representing some code that was written, you could implement describe as `return models.gpt35.complete(f"{self.\_\_code_written}\n\nSummarize the changes made in the above code.")`.
+
+Here's an example:
+
+```python
+class HelloWorldStep(Step):
+ filepath: str
+
+ async def run(self, sdk: ContinueSDK):
+ await sdk.ide.setFileOpen(self.filepath)
+ await sdk.append_to_file(self.filepath, "Hello World!")
+
+ def describe(self, models: Models):
+ return f"Appended 'Hello World!' to {self.filepath}"
+```