s/ls, ollie-tmp-path

This commit is contained in:
Levi Neely 2026-04-17 13:05:23 +02:00
parent 9cf6ba8d51
commit 231e9ebcc5
3 changed files with 12 additions and 4 deletions

View File

@ -609,8 +609,8 @@ func (s *Server) read(cs *connState, fc *plan9.Fcall) *plan9.Fcall {
}
}
// s/new and s/idx are served from the session store.
if path == "/s/new" || path == "/s/idx" {
// s/new, s/idx, and s/ls are served from the session store.
if path == "/s/new" || path == "/s/idx" || path == "/s/ls" {
plog.Debug("Tread path=%q offset=%d count=%d", path, fc.Offset, fc.Count)
content, err := s.sessionStore.Get(pathBase(path))
if err != nil {
@ -1503,6 +1503,8 @@ func (s *Server) makeStat(path string) plan9.Dir {
default:
if path == "/backends" || path == "/help" || path == "/s/idx" {
mode = 0444
} else if path == "/s/ls" {
mode = 0555
} else if path == "/s/new" {
mode = 0666
} else if strings.HasPrefix(path, "/a/") {
@ -1592,7 +1594,7 @@ func (s *Server) makeStat(path string) plan9.Dir {
// that check stat before reading (cat, 9pfuse, etc.) see non-zero size.
if dir.Length == 0 && !isDir {
switch {
case path == "/s/new" || path == "/s/idx":
case path == "/s/new" || path == "/s/idx" || path == "/s/ls":
if content, err := s.sessionStore.Get(base); err == nil {
dir.Length = uint64(len(content))
}

View File

@ -17,6 +17,7 @@ func (s *SessionStore) List() ([]os.DirEntry, error) {
entries := []os.DirEntry{
syntheticEntry("new", 0666),
syntheticEntry("idx", 0444),
syntheticEntry("ls", 0555),
}
s.srv.mu.RLock()
for id := range s.srv.sessions {
@ -32,6 +33,8 @@ func (s *SessionStore) Stat(name string) (os.FileInfo, error) {
return &syntheticFileInfo{name: "new", mode: 0666}, nil
case "idx":
return &syntheticFileInfo{name: "idx", mode: 0444}, nil
case "ls":
return &syntheticFileInfo{name: "ls", mode: 0555}, nil
}
s.srv.mu.RLock()
_, ok := s.srv.sessions[name]
@ -48,6 +51,8 @@ func (s *SessionStore) Get(name string) ([]byte, error) {
return []byte("name=\ncwd=\nbackend=\nmodel=\nagent=\n"), nil
case "idx":
return s.index(), nil
case "ls":
return []byte("#!/usr/bin/env bash\ncat ${OLLIE:-$HOME/mnt/ollie}/s/idx\n"), nil
}
return nil, fmt.Errorf("%s: not a readable file", name)
}

View File

@ -148,7 +148,8 @@ func ensureEnv() {
"OLLIE_SKILLS_PATH": filepath.Join(home, ".config", "ollie", "skills"),
"OLLIE_PLAN_PATH": filepath.Join(home, ".config", "ollie", "planning"),
"OLLIE_MEMORY_PATH": filepath.Join(home, ".config", "ollie", "memory"),
"OLLIE_TMP_PATH": filepath.Join(home, ".local", "share", "ollie", "tmp"),
"OLLIE_TMP_PATH": filepath.Join(home, ".local", "share", "ollie", "tmp"),
"OLLIE_TRANSCRIPT_PATH": filepath.Join(home, ".config", "ollie", "transcript"),
}
for k, v := range defaults {
if os.Getenv(k) == "" {