Skip to content

Add oc session ls|rm, PowerShell login docs, Windows test fix - #62

Merged
only-cli merged 3 commits into
only-cli:mainfrom
Chagas74:gena/session-ls-rm
Sep 16, 2026
Merged

only-cli merged 3 commits into
only-cli:mainfrom
Chagas74:gena/session-ls-rm

Conversation

@Chagas74

Copy link
Copy Markdown

Implements the planned \session ls|rm\ commands and two doc gaps found while adapting oc for a Windows agent setup.

Added

  • \oc session ls\ lists saved sessions (name, url, title; --json\ supported,
    o saved sessions\ when empty)
  • \oc session rm [name]\ forgets a session — saved page plus cookies, the same promise \oc logout\ makes (defaults to --session, refuses path-like names)
  • Tests for ls/rm in \ ests/cli.test.js\ (empty store, listing, rm by name/flag incl. cookie sidecar, invalid name, usage)

Docs

  • PowerShell equivalent for cookie login in README + skill (\printf\ does not exist on Windows)
  • State location on Windows (%USERPROFILE%\.only-cli, \OC_HOME) in README + skill + \session ls|rm\ in llms.txt
  • CHANGELOG entry under Unreleased

Fixed

  • Test harness resolves the binary with \ ileURLToPath\ (\URL.pathname\ breaks on Windows paths with spaces/drive letters) in cli, cli-auth, distill tests

Validation

  • Full suite: 221 pass, 1 fail — the cookies \chmod 0600\ test, which fails identically on a pristine checkout on Windows (pre-existing, untouched by this PR)

Dan Chagas and others added 2 commits September 13, 2026 21:35
… removed

`oc login --session work` writes a jar and no page, and `session ls` only
enumerated pages, so an agent auditing leftover logins was told there were
none while a live credential sat on disk. ls now lists a name when it has a
page, a jar, or both, and marks jars with `[cookies]` (a `cookies` field in
`--json`), since without that an agent told to drop logged-in sessions cannot
tell which to rm.

clearSession and clearCookieJar swallowed every unlink error, so `session rm`
printed "forgot session" and exited 0 on a read-only directory, a directory
named like a page, or a typo. Both now ignore only ENOENT and report whether
they removed anything; rm fails with "no such session" when neither did.
logout keeps its silent exit 0. Both commands share one forgetSession helper,
so the next per-session artifact cannot be forgotten by one and not the other.

A name ending in `.cookies` saved its page at the path of the shorter name's
jar, so `rm x` deleted session `x.cookies` and ls hid it: assertSafeName now
rejects the suffix. ls also uses the same name check as rm (so `..json` and
directories no longer list as sessions rm cannot remove), and the sidecar
suffix is one exported constant shared with cookies.js.

Copy edits to the new README, SKILL, and CHANGELOG prose; the CHANGELOG now
says only the CLI tests run on Windows, since the cookie file-mode test still
fails there.
@only-cli

Copy link
Copy Markdown
Owner

Thanks for this PR, @Chagas74! session ls|rm fills a real gap, and the PowerShell login docs plus the fileURLToPath harness fix are welcome too.

I reviewed it and pushed one follow-up commit (b990662) onto your branch rather than round-tripping, since the fixes were mechanical. Please glance over it and shout if anything looks off:

  • session ls now lists cookie-only sessions. oc login --session work writes a jar and no page, so the listing said no saved sessions while a live credential sat on disk. Sessions holding a jar are marked [cookies] in text and get a cookies field in --json.
  • session rm no longer reports success unconditionally. clearSession/clearCookieJar swallowed every unlink error, so a read-only directory or a typo like rm wrok printed forgot session with exit 0. They now ignore only ENOENT, and rm fails with no such session when nothing was removed. logout keeps its silent exit 0. Both share one forgetSession helper.
  • Names ending in .cookies are rejected. Session x.cookies saved its page at x.cookies.json, the path of x's jar, so rm x deleted it and ls hid it.
  • ls uses the same name check as rm and skips non-files, so a stray ..json or a directory named like a page is no longer listed as something rm cannot remove. The sidecar suffix is one exported constant shared by session.js and cookies.js.
  • Docs: light copy edits, and the CHANGELOG now says only the CLI tests run on Windows, since the cookie file-mode test still fails there.

Tests added for each of the above; the full suite passes locally.

oc session ls|rm, and reddit.com read through its feeds; see CHANGELOG.
@only-cli
only-cli merged commit 23eafd1 into only-cli:main Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants