summaryrefslogtreecommitdiff
path: root/continuedev
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-23 12:38:46 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-23 12:38:46 -0700
commit5ffe03c3ee0dc160999a03d4efd50735cff5cdcf (patch)
treefe9c81ac462604b09056981af931ff0fa977a7af /continuedev
parent32f9cc3412270cd906b5270cce8ccefc76165421 (diff)
downloadsncontinue-5ffe03c3ee0dc160999a03d4efd50735cff5cdcf.tar.gz
sncontinue-5ffe03c3ee0dc160999a03d4efd50735cff5cdcf.tar.bz2
sncontinue-5ffe03c3ee0dc160999a03d4efd50735cff5cdcf.zip
documentation
Diffstat (limited to 'continuedev')
-rw-r--r--continuedev/README.md22
-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
4 files changed, 70 insertions, 8 deletions
diff --git a/continuedev/README.md b/continuedev/README.md
index 528cf75a..d3ead8ec 100644
--- a/continuedev/README.md
+++ b/continuedev/README.md
@@ -1,19 +1,29 @@
# Continue PyPI Package
-This package contains the [Continue](https://github.com/continuedev.com/continue) server and core classes needed to build your own recipes.
+This package contains the [Continue](https://github.com/continuedev/continue) server and core classes needed to build your own recipes.
Continue is a Python library for automating repetitive sequences of software development tasks using language models. Using our VS Code extension, you can build, run, and refine these recipes as they natively interact with your codebase. Read the docs [here](https://continue.dev/docs) or download the VS Code extension [here](https://marketplace.visualstudio.com/items?itemName=Continue.continue).
## Continue Server
-The Continue server acts as a bridge between the Continue React app and your IDE, running your recipes and acting on the codebase.
+The Continue server acts as a bridge between the Continue React app and your IDE, running your recipes and acting on the codebase.
Start it by running the following commands:
+
1. `cd continuedev`
2. Make sure packages are installed with `poetry install`
-3. `poetry shell`
+ - If poetry is not installed, you can install with
+ ```bash
+ curl -sSL https://install.python-poetry.org | python3 -
+ ```
+ (official instructions [here](https://python-poetry.org/docs/#installing-with-the-official-installer))
+3. `poetry shell` to activate the virtual environment
4. `cd ..`
-5. `python3 -m continuedev.src.continuedev.server.main`
+5. `python3 -m continuedev.src.continuedev.server.main` to start the server
+
+Once you've validated that this works, you'll often want to use a debugger, in which case we've provided a launch configuration for VS Code in `.vscode/launch.json`. To start the debugger in VS Code, ensure that the workspace directory is the root of the `continue` repo, then press F5.
+
+> Note: To start the debugger, you'll have to select the poetry Python interpreter (`/path-to-poetry-venv/bin/python3`) in the bottom right of the VS Code window. If you don't see this, you may have to install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python).
## Scripts
@@ -29,6 +39,8 @@ See the `src/continuedev/libs/steps` folder for examples of writing a Continue s
Open a [new GitHub Issue](https://github.com/continuedev/continue/issues/new) or comment on [an existing one](https://github.com/continuedev/continue/issues). Let us know what you would like to contribute, and we will help you make it happen!
+For more a more detailed contributing guide, see [CONTRIBUTING.md](../CONTRIBUTING.md).
+
## Install from source
#### 1. Clone this repo
@@ -60,4 +72,4 @@ cd continue/extension/scripts && python3 install_from_source.py
- [Continue GUI README](./extension/react-app/): learn about the React app that lets users interact with the server and is placed adjacent to the text editor in any suppported IDE
- [Schema README](./schema): learn about the JSON Schema types generated from Pydantic models, which we use across the `continuedev/` and `extension/` directories
- [Continue Docs README](./docs): learn how our [docs](https://continue.dev/docs) are written and built
-- [How to debug the VS Code Extension README](./extension/src/README.md): learn how to set up the VS Code extension, so you can debug it \ No newline at end of file
+- [How to debug the VS Code Extension README](./extension/src/README.md): learn how to set up the VS Code extension, so you can debug it
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}"
+```