Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Run with resume session #153

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .goosehints
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
This is a python CLI app that uses UV. Read CONTRIBUTING.md for information on how to build and test it as needed.
Some key concepts are that it is run as a command line interface, dependes on the "ai-exchange" package, and has the concept of toolkits which are ways that its behavior can be extended. Look in src/goose and tests.
Once the user has UV installed it should be able to be used effectively along with uvx to run tasks as needed

Some key concepts are that it is run as a command line interface, dependes on the "ai-exchange" package (which is in packages/exchange in this repo), and has the concept of toolkits which are ways that its behavior can be extended. Look in src/goose and tests.

Assume the user has UV installed and ensure uv is used to run any python related commands.

To run tests:

uv sync && uv run pytest tests -m 'not integration'
michaelneale marked this conversation as resolved.
Show resolved Hide resolved

ideally after each cyange
michaelneale marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ Now you are interacting with Goose in conversational sessions - think of it as l
> [!TIP]
> You can place a `.goosehints` text file in any directory you launch goose from to give it some background info for new sessions in plain language (eg how to test, what instructions to read to get started or just tell it to read the README!) You can also put a global one `~/.config/goose/.goosehints` if you like for always loaded hints personal to you.

### Running a goose tasks (one off)

You can run goose to do things just as a one off, such as tidying up, and then exiting:

```sh
goose run instructions.md
```

This will run until completion as best it can. You can also pass `--resume-session` and it will re-use the first session it finds for context
michaelneale marked this conversation as resolved.
Show resolved Hide resolved


#### Exit the session

Expand Down
11 changes: 9 additions & 2 deletions src/goose/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,22 @@ def session_resume(name: Optional[str], profile: str, log_level: str) -> None:
@click.argument("message_file", required=False, type=click.Path(exists=True))
@click.option("--profile")
@click.option("--log-level", type=LOG_CHOICE, default="INFO")
def run(message_file: Optional[str], profile: str, log_level: str) -> None:
@click.option("--resume-session", is_flag=True, help="Resume the last session if available")
def run(message_file: Optional[str], profile: str, log_level: str, resume_session: bool = False) -> None:
"""Run a single-pass session with a message from a markdown input file"""
if message_file:
with open(message_file, "r") as f:
initial_message = f.read()
else:
initial_message = click.get_text_stream("stdin").read()

session = Session(profile=profile, log_level=log_level)
if resume_session:
session_files = get_session_files()
if session_files:
name = list(session_files.keys())[0]
session = Session(name=name, profile=profile, log_level=log_level)
else:
session = Session(profile=profile, log_level=log_level)
session.single_pass(initial_message=initial_message)


Expand Down