Skip to content

Commit

Permalink
feat: Run with resume session (block#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale authored Oct 16, 2024
1 parent 8cf7b9f commit 5fc0c3a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
14 changes: 12 additions & 2 deletions .goosehints
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
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:

```sh
uv sync && uv run pytest tests -m 'not integration'
```

ideally after each change
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


#### 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 @@ -207,15 +207,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

0 comments on commit 5fc0c3a

Please sign in to comment.