Repository navigation
feat(agent): describe agent home layouts and try every transcript candidate #2657
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
da62c75
feat(agent): describe agent home layouts and try every transcript can…
hiddeco 383a233
fix(agent): find flat archived Codex rollouts outside ResolveSessionFile
hiddeco eb3c544
fix(cli): log an unavailable agent home during transcript discovery
hiddeco e782ec2
fix(agent): search Codex archives only beside a sessions store
hiddeco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package agent | ||
|
|
||
| import "path/filepath" | ||
|
|
||
| // HomeLayout describes where an agent keeps session transcripts beneath its | ||
| // per-user home directory. | ||
| type HomeLayout struct { | ||
| // Stores lists the session stores relative to the home, as | ||
| // slash-separated paths, with the store GetSessionDir resolves into | ||
| // first. A store may hold per-project subdirectories. | ||
| Stores []string | ||
| } | ||
|
|
||
| // StoresUnder returns the absolute session stores beneath home, in the order | ||
| // of l.Stores. | ||
| func (l HomeLayout) StoresUnder(home string) []string { | ||
| stores := make([]string, len(l.Stores)) | ||
| for i, store := range l.Stores { | ||
| stores[i] = filepath.Join(home, filepath.FromSlash(store)) | ||
| } | ||
| return stores | ||
| } | ||
|
|
||
| // StoreContaining returns the store beneath home that contains path, and | ||
| // reports whether there is one. The comparison is lexical and folds case on | ||
| // Windows. | ||
| func (l HomeLayout) StoreContaining(home, path string) (string, bool) { | ||
| for _, store := range l.StoresUnder(home) { | ||
| if pathHasDirPrefix(path, store) { | ||
| return store, true | ||
| } | ||
| } | ||
| return "", false | ||
| } | ||
|
|
||
| // HomeLayoutProvider is implemented by built-in agents that keep session | ||
| // transcripts in one or more stores beneath a per-user home directory, such as | ||
| // Codex's live and archived session stores beneath CODEX_HOME. | ||
| type HomeLayoutProvider interface { | ||
| Agent | ||
|
|
||
| // SessionHome returns the agent's active home directory, resolved from | ||
| // the same settings GetSessionDir uses but ignoring Entire's test | ||
| // overrides of the session directory. | ||
| SessionHome() (string, error) | ||
|
|
||
| // HomeLayout returns where the agent keeps sessions beneath its home. | ||
| HomeLayout() HomeLayout | ||
| } | ||
|
|
||
| // AsHomeLayoutProvider returns the agent as a HomeLayoutProvider if it is a | ||
| // built-in agent that implements the interface. | ||
| func AsHomeLayoutProvider(ag Agent) (HomeLayoutProvider, bool) { | ||
| return builtinCapability[HomeLayoutProvider](ag) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package agent_test | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/entireio/cli/cmd/entire/cli/agent" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestHomeLayout_StoresUnderAndStoreContaining(t *testing.T) { | ||
| t.Parallel() | ||
| home := filepath.Join(t.TempDir(), "home") | ||
| layout := agent.HomeLayout{Stores: []string{"sessions", "archived/sessions"}} | ||
| live := filepath.Join(home, "sessions") | ||
| archived := filepath.Join(home, "archived", "sessions") | ||
|
|
||
| assert.Equal(t, []string{live, archived}, layout.StoresUnder(home)) | ||
|
|
||
| for _, tc := range []struct { | ||
| path string | ||
| wantStore string | ||
| }{ | ||
| {path: live, wantStore: live}, | ||
| {path: filepath.Join(live, "2026", "10", "05", "rollout.jsonl"), wantStore: live}, | ||
| {path: filepath.Join(archived, "rollout.jsonl"), wantStore: archived}, | ||
| {path: filepath.Join(home, "sessions-other", "rollout.jsonl")}, | ||
| {path: filepath.Join(home, "config.toml")}, | ||
| {path: home}, | ||
| } { | ||
| store, ok := layout.StoreContaining(home, tc.path) | ||
| assert.Equal(t, tc.wantStore != "", ok, tc.path) | ||
| assert.Equal(t, tc.wantStore, store, tc.path) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.