| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Parse OpenCode sessions from the official opencode export JSON and emit the same normalized report as Copilot CLI and Claude Code. -Format OpenCode accepts either -SessionId (shells out to opencode session list + opencode export) or -EventsFile (a saved export JSON, format-sniffed). Includes OpenCode tool-name normalization, skill and task (subagent) detection, and cache-token reporting. README skill/tool tables updated to reflect OpenCode. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Thanks for adding OpenCode support. I did not find malware-like or destructive behavior: there is no transcript exfiltration, persistence, privilege change, unexpected file deletion, or shell injection in this change.
I am requesting changes for four concrete correctness and safety gaps. The first two can run an unrequested executable or generate a report from the wrong private session; the other two make failures hard to diagnose and leave the new parser unprotected against regressions. Please address all four inline comments before merging.
Sorry, something went wrong.
| if ($session -and -not $detectedFormat) { $detectedFormat = 'ClaudeCode' } | ||
| } | ||
| if (-not $session) { | ||
| $session = Find-OpenCodeSessionById -Id $SessionId |
There was a problem hiding this comment.
The documentation says OpenCode is opt-in, but this fallback launches the PATH-resolved opencode executable whenever an ID is not found in Copilot or Claude.
For example:
.\Analyze-Session.ps1 -SessionId "missing-session"currently does this:
Search Copilot -> not found
Search Claude -> not found
Run `opencode session list --format json`
Please remove the implicit OpenCode fallback and invoke OpenCode only when the caller explicitly supplies -Format OpenCode. This is surprising process execution, even though the argument handling itself is not vulnerable to shell injection.
Sorry, something went wrong.
| [string]$EventsFile, | ||
| [string]$OutputFile, | ||
| [ValidateSet('Copilot', 'ClaudeCode')] | ||
| [ValidateSet('Copilot', 'ClaudeCode', 'OpenCode')] |
There was a problem hiding this comment.
Please add cross-parameter validation for OpenCode.
Today this command:
.\Analyze-Session.ps1 -Format OpenCodefalls through to the no-input default, selects the latest Copilot or Claude transcript, and can generate a report for that unrelated session.
It should terminate immediately with something like:
OpenCode requires either -SessionId or -EventsFile.
Please require one of those inputs whenever -Format OpenCode is selected.
Sorry, something went wrong.
| if (-not $cli) { return $null } | ||
| $json = & $cli session list --format json 2>$null | ||
| if ($LASTEXITCODE -ne 0 -or -not $json) { return $null } | ||
| try { $sessions = ($json -join "`n") | ConvertFrom-Json } catch { return $null } |
There was a problem hiding this comment.
This path collapses several distinct failures into the later “session ID was not found” message:
| Actual problem | Reported result |
|---|---|
| opencode is not installed | Session ID not found |
| session list exits nonzero | Session ID not found |
| Output is empty or invalid JSON | Session ID not found |
| The ID genuinely does not exist | Session ID not found |
Please preserve the actionable cause. One simple approach is to skip the session list preflight after explicit OpenCode selection, call Invoke-OpenCodeExport directly, and let its missing-CLI, export, and JSON diagnostics surface. Otherwise, throw distinct errors here.
Sorry, something went wrong.
| # ----------------------------------------------------------------------------- | ||
| # OpenCode parser | ||
| # ----------------------------------------------------------------------------- | ||
| function Parse-OpenCodeEvents { |
There was a problem hiding this comment.
Please add a fixture-backed smoke test for this new parser rather than leaving the OpenCode export contract untested.
For example, commit a small synthetic export containing info.id, an assistant modelID, cache/output token counts, a bash tool, a task tool, and an errored tool. Then run:
.\Analyze-Session.ps1 -EventsFile .\fixtures\opencode.jsonwithout -Format, and assert that the report contains:
Harness: OpenCode
Session ID: ses_test
Model: example-model
Output/cache token totals
Normalized shell and agent tools
The errored tool in build/tooling analysis
That exercises format sniffing and the most failure-prone normalization paths, not just the happy-path parser entry point.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description
winui-session-report can now analyze OpenCode sessions in addition to GitHub Copilot CLI and Claude Code. It parses the official opencode export JSON and emits the same normalized markdown report.
-Format OpenCode accepts two inputs:
OpenCode exposes no "current session" environment variable, so its sessions are only analyzed when explicitly requested via -Format OpenCode (no auto-detect). Subagents are spawn-only: the task tool is reported as an agent dispatch with no recursive child-session export, matching Copilot behavior. Existing Copilot/Claude parsers are unchanged.
Related Issue
Part of #149
Type of Change
Affected area
Checklist
Screenshots / Demo
Additional Notes
Base branch is staging.
AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.