feat(dx): codelens sessions command — view install session log, rotation, --json/--raw (closes #64 phase-2)#137
Merged
Conversation
…ion, --json/--raw (closes #64 phase-2)
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Summary
Implements Phase 2 of issue #64 —
codelens sessionscommand for viewing install session logs.(Supersedes the closed PR — that PR was based on the Phase 1 branch
feat/issue-64-doctor-phase-1, which got deleted when PR #132 was merged. This PR is rebased directly ontomainand contains only the Phase 2 commit.)sessionsreads the install-session log thatsetup.shappends to on every run, and displays the last N sessions in a human-readable format (or JSON for programmatic access). This is the "what happened last time I ran setup?" debugging tool.Depends on #132 (Phase 1, MERGED) — Phase 2's dispatcher changes build on Phase 1's
_doctor_printed_textpattern (now generalized to also cover_sessions_printed_text).Files
New:
scripts/commands/sessions.py— full sessions command: read JSON sidecar (fallback to MD parsing),--entries N,--raw,--json,--config-dir, automatic rotation when log exceeds 1 MB (keep last 50)tests/test_sessions.py— 24 tests covering JSON sidecar reading, MD fallback,--entriesfiltering,--json/--rawoutput modes, rotation (over-threshold + idempotent),setup.shintegration (real subprocess), CLI smokeModified:
setup.sh— appends a Markdown + JSON session entry on every run. Captures: timestamp, duration, Python/OS/arch, agents detected (Claude Code, Cursor, Continue), deps installed, warnings, errors, exit code. UsesCODELENS_CONFIG_DIRenv var for test isolation.scripts/codelens.py— dispatcher generalized to handle both_doctor_printed_textand_sessions_printed_textsignals (so sessions doesn't double-print)README.md,SKILL.md,SKILL-QUICK.md,pyproject.toml,skill.json,scripts/graph_model.py— auto-synced bypython3 scripts/sync_command_count.py --applyto reflect 68 → 69Session log format
~/.codelens/session.md(Markdown, human-readable):~/.codelens/session.json(JSON sidecar, programmatic access):[ { "timestamp": "2026-06-28T09:14:31Z", "duration_sec": 16, "exit_code": 0, "python": "3.12.13", "os": "Linux", "arch": "x86_64", "agents_detected": ["claude-code"], "deps_installed": ["tree-sitter", "tree-sitter-html", ...], "warnings": "watchdog install failed", "errors": null, "title": "setup" } ]Key design decisions
sessionsinvocation — no cron job needed.--entries 0means "all". Default is 5 (matches the issue spec). Most-recent-first display order.--jsonprints just the sessions array (not the full result dict) sojqcan pipe cleanly.--config-dirfor test isolation. Tests usetmp_path+--config-dirso they never touch the user's real~/.codelens/.setup.shwrites both formats. Markdown for--rawreading, JSON for--jsonprogrammatic access.CODELENS_CONFIG_DIRenv var. Lets tests override the default~/.codelens/location.sessionsnever writes sessions — onlysetup.shwrites them.Acceptance criteria
codelens sessionsshows last 5 install sessions by default--entries Ncontrols how many sessions to show (0 = all)--jsonproduces valid JSON array for programmatic access--rawprints the Markdown log verbatim--config-diroverrides default~/.codelens/setup.shappends a session entry on every run (both MD and JSON)sync_command_count.py --applyrun — all docs reflect 69 commands(Phases 3–4 of #64 —
install.sh --dry-run/--self-test/--uninstall,codelens upgrade— are out of scope for this Phase 2 PR.)Test results
tests/test_sessions.py— all passtests/test_doctor.py, 32 tests) — still pass (no regression)setup.shintegration tests verify the script actually writes session entries (subprocess test, not mocked)Closes #64 (phase-2).