Skip to content

Bug: _memory_workspace silently falls back to ~ when CWD has no .perseus/Β #143

@tcconnally

Description

@tcconnally

Severity: 🟑 Medium (UX footgun; silent wrong-workspace)

agora.py:8–14:

def _memory_workspace(args, cfg) -> Path:
    ...
    cwd = Path.cwd().resolve()
    if (cwd / ".perseus").exists():
        return cwd
    return Path.home().resolve()

Running perseus memory show from /tmp (or any non-Perseus directory) silently displays the home workspace's narrative β€” no warning, no log.

Suggested fix

def _memory_workspace(args, cfg) -> Path:
    raw = getattr(args, "workspace", None)
    if raw:
        return Path(raw).expanduser().resolve()
    cwd = Path.cwd().resolve()
    if (cwd / ".perseus").exists():
        return cwd
    for parent in cwd.parents:
        if (parent / ".perseus").exists():
            return parent
    home = Path.home().resolve()
    if (home / ".perseus").exists():
        print(f"⚠ No .perseus/ in {cwd}; using $HOME workspace ({home}).",
              file=sys.stderr)
        return home
    raise SystemExit(
        f"Not in a Perseus workspace and $HOME has no .perseus/. "
        f"Run with --workspace <path> or `cd` to a workspace."
    )

Acceptance criteria

  • Test from tmp_path with no .perseus/: command exits non-zero.
  • Test from a subdirectory of a workspace: walks up and finds the workspace.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions