diff options
Diffstat (limited to 'server/continuedev/plugins/policies/commit.py')
-rw-r--r-- | server/continuedev/plugins/policies/commit.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/server/continuedev/plugins/policies/commit.py b/server/continuedev/plugins/policies/commit.py new file mode 100644 index 00000000..2fa43676 --- /dev/null +++ b/server/continuedev/plugins/policies/commit.py @@ -0,0 +1,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() + ) |