1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# An agent that makes a full commit in the background
# Plans
# Write code
# Reviews code
# Cleans up
# It's important that agents are configurable, because people need to be able to specify
# which hooks they want to run. Specific linter, run tests, etc.
# And all of this can be easily specified in the Policy.
from textwrap import dedent
from typing import Literal
from ...core.config import ContinueConfig
from ...core.main import History, Policy, Step
from ...core.observation import TextObservation
from ...core.sdk import ContinueSDK
class PlanStep(Step):
user_input: str
_prompt = dedent(
"""\
You were given the following instructions: "{user_input}".
Create a plan for how you will complete the task.
Here are relevant files:
{relevant_files}
Your plan will include:
1. A high-level description of how you are going to accomplish the task
2. A list of which files you will edit
3. A description of what you will change in each file
"""
)
async def run(self, sdk: ContinueSDK):
plan = await sdk.models.default.complete(
self._prompt.format(
{"user_input": self.user_input, "relevant_files": "TODO"}
)
)
return TextObservation(text=plan)
class WriteCommitStep(Step):
async def run(self, sdk: ContinueSDK):
pass
class ReviewCodeStep(Step):
async def run(self, sdk: ContinueSDK):
pass
class CleanupStep(Step):
async def run(self, sdk: ContinueSDK):
pass
class CommitPolicy(Policy):
user_input: str
current_step: Literal["plan", "write", "review", "cleanup"] = "plan"
def next(self, config: ContinueConfig, history: History) -> Step:
if history.get_current() is None:
return (
PlanStep(user_input=self.user_input)
>> WriteCommitStep()
>> ReviewCodeStep()
>> CleanupStep()
)
|