block / goose

Goose is a developer agent that operates from your command line to help you do the boring stuff.
https://block.github.io/goose/
Apache License 2.0
225 stars 36 forks source link

[cli] Resume session (interactive and headless) with -r #308

Closed jsibbison-square closed 3 days ago

jsibbison-square commented 4 days ago

Adds the ability to add -r to the session or run command and it will resume an existing session.

Implemented in this PR

Decided not to persist image contents in the session file.

Example persisted file:

{"role":"user","created":1732240977,"content":[{"text":"whoami on system"}]}$
{"role":"assistant","created":1732240979,"content":[{"id":"call_LbNlmTScMggwvCKJf4vjEFgg","tool_name":"DeveloperSystem__bash","arguments":{"command":"whoami"}}]}$
{"role":"user","created":1732240979,"content":[{"id":"call_LbNlmTScMggwvCKJf4vjEFgg","tool_results":[{"type":"Text","text":"## Output\n\n```\njsibbison\n\n```\n"}]}]}$
{"role":"assistant","created":1732240980,"content":[{"text":"You are currently logged in as the user `jsibbison`."}]}$
{"role":"user","created":1732240988,"content":[{"text":"add a quip  at the start of test.md"}]}$
{"role":"assistant","created":1732240990,"content":[{"id":"call_heUw4l1o2sqOkoCTXhN11Gop","tool_name":"DeveloperSystem__bash","arguments":{"command":"touch test.md"}}]}$
{"role":"user","created":1732240990,"content":[{"id":"call_heUw4l1o2sqOkoCTXhN11Gop","tool_results":[{"type":"Text","text":"## Output\n\n```\n\n```\n"}]}]}$
{"role":"assistant","created":1732240991,"content":[{"id":"call_rBoiou9vVfmcbMsNthEm3wCg","tool_name":"DeveloperSystem__text_editor","arguments":{"command":"insert","insert_line":1,"new_str":"\"The early bird might get the worm, but the second mouse gets the cheese.\"","path":"test.md"}}]}$
{"role":"user","created":1732240991,"content":[{"id":"call_rBoiou9vVfmcbMsNthEm3wCg","tool_results":[{"type":"Text","text":"{\"error\": \"Invalid parameters: You must view '/Users/jsibbison/Development/goosies/rust-goose/test.md' before editing it\"}"}]}]}$
{"role":"assistant","created":1732240993,"content":[{"id":"call_ToHvjk3HtP2R963C9Bkl2MTK","tool_name":"DeveloperSystem__text_editor","arguments":{"command":"view","path":"test.md"}}]}$
{"role":"user","created":1732240993,"content":[{"id":"call_ToHvjk3HtP2R963C9Bkl2MTK","tool_results":[{"type":"Text","text":"The file content for /Users/jsibbison/Development/goosies/rust-goose/test.md is now available in the system status.","audience":["assistant"]},{"type":"Text","text":"### /Users/jsibbison/Development/goosies/rust-goose/test.md\n```markdown\nWhy don't programmers like nature?\n\nBecause it has too many bugs... just like their code-\n\n```\n","audience":["user"],"priority":0.0}]}]}$
{"role":"assistant","created":1732240995,"content":[{"id":"call_iQxDd8pvKg92KTXQphqepUnr","tool_name":"DeveloperSystem__text_editor","arguments":{"command":"insert","insert_line":1,"new_str":"\"The early bird might get the worm, but the second mouse gets the cheese.\"\n\n","path":"test.md"}}]}$
{"role":"user","created":1732240995,"content":[{"id":"call_iQxDd8pvKg92KTXQphqepUnr","tool_results":[{"type":"Text","text":"Successfully inserted text","audience":["assistant"]},{"type":"Text","text":"### /Users/jsibbison/Development/goosies/rust-goose/test.md\n@1\n```md\n\"The early bird might get the worm, but the second mouse gets the cheese.\"\n\n\n```\n","audience":["user"],"priority":0.0}]}]}$
{"role":"assistant","created":1732240997,"content":[{"text":"I've added the quip to the start of `test.md`. Here's the current content:\n\n```\n\"The early bird might get the worm, but the second mouse gets the cheese.\"\n\nWhy don't programmers like nature?\n\nBecause it has too many bugs... just like their code!\n```"}]}$