Repository navigation
Conversation
| maker.variants = {''} | ||
| maker.make('opendirector = opendirector.cli:main') | ||
| (cli_bin / 'opendirector.cmd').unlink(missing_ok=True) | ||
| (cli_bin / 'opendirector.ps1').write_text( |
There was a problem hiding this comment.
PowerShell can reject this .ps1 launcher under Restricted, even for opendirector --help. Please keep the CLI usable under the existing execution policy and verify from the Windows Agent sandbox that --help works and a JSON pipeline preserves Chinese titles and prompts in project storage.
There was a problem hiding this comment.
Thanks for catching the .ps1 launcher issue. In 3b64793c, I stopped generating the .ps1 launcher and kept .opendirector-bin\opendirector.cmd as the Windows Agent CLI entry point. It starts Python with -X utf8 for Unicode readback. When OpenCode selects system Windows PowerShell 5.1, a private launcher sets UTF-8 in the process that sends the JSON.
I verified both cases you asked about from the Windows Agent shell:
-
Bare
opendirector --helpunderRestricted. WithRestrictedin effect, PowerShell 5.1 rejected a temporary.ps1withPSSecurityException. In that same process,Get-Command opendirectorresolved to.opendirector-bin\opendirector.cmd, andopendirector --helpprinted usage and exited0. -
Chinese titles and prompts through a plain JSON pipeline. The model piped literal Unicode JSON to
opendirector canvas create-generation --file -without setting any encoding variables. The Agent then ranopendirector project show. Both the CLI readback and an independent read from reopened project storage matched the original title (窗边的小猫 🐈 1) and two-line prompt, including𠮷, quotes, a literal?, and the newline. The saved text asset also matched the expected UTF-8 bytes exactly. No generation jobs were submitted.
Both end-to-end tests passed, one with bundled OpenCode 1.19.5 and one with standalone OpenCode 1.19.6. Each covered a fresh turn and a resumed turn with PYTHONUTF8=0 and PYTHONIOENCODING unset. The model responses were simulated. OpenCode, PowerShell 5.1, the CLI, and project storage were real. Nine additional CLI input and launcher tests passed, for 11 total.
I’ve updated the PR description with the test details and screenshots of the node before and after restarting the service and reopening the project. Ready for another look.
这个版本呢
14dc698 to
3b64793
Compare
Summary
On Windows PowerShell 5.1, piping JSON to
opendirector ... --file -encoded non-ASCII text as?before the CLI received it, so commands could succeed while saving corrupted Chinese titles. Reading Unicode back viaopendirector project showalso failed under default Windows Python stdout encodings..opendirector-bin/opendirector.cmdas the Windows Agent CLI entry point (compatible withRestrictedexecution policy) and invoke Python with-X utf8so CLI output preserves Unicode on readback.$OutputEncodingand[Console]::OutputEncodingto UTF-8 without a BOM inside that process—no prompt instructions, profile edits, or execution-policy changes needed.--file -) and--file <path>as strict UTF-8 with an optional BOM (utf-8-sig), rejecting invalid bytes before dispatching commands.Linked issue
Labels
Suggested labels:
type:bug,area:agent,area:harness,area:docs.Test plan
11 tests passed locally on Windows at commit
3b64793c. Two end-to-end tests covered bundled OpenCode1.19.5and standalone OpenCode1.19.6. Each ran a fresh turn and a resumed turn in the same Agent session, withPYTHONUTF8=0andPYTHONIOENCODINGunset. The model responses were simulated. OpenCode, Windows PowerShell 5.1, the CLI, and project storage were real.Run bare
opendirector --helpunderRestricted. In the Agent shell, PowerShell 5.1 blocked a temporary.ps1script withPSSecurityException. In that same process,Get-Command opendirectorresolved to.opendirector-bin\opendirector.cmd, andopendirector --helpprinted usage and exited0. These checks passed on both turns in both runtimes.Preserve Chinese titles and prompts through a plain JSON pipeline. The model piped literal Unicode JSON to
opendirector canvas create-generation --file -andopendirector asset write-text --file -without setting any encoding variables. The Agent then ranopendirector project show. The test located the node by ID and compared its title and two-line prompt with the original input. An independent read from reopened project storage confirmed the same values, including窗边的小猫 🐈 1,𠮷, quotes, a literal?, and the newline. The saved text asset matched the expected UTF-8 bytes exactly. The project recorded zero generation jobs.Verify CLI input and launcher behavior. Nine additional tests passed. They covered JSON from stdin and files with and without a UTF-8 BOM, including a file written by PowerShell 5.1 with
Set-Content -Encoding UTF8. They also verified that invalid UTF-8 was rejected before command dispatch, that the launcher preserved command behavior and exit codes, and that cancellation terminated the child PowerShell process.The two end-to-end cases are in
tests/test_native_runtime.py::test_real_opencode_windows_unicode_pipeline. The nine additional cases are intests/test_windows_powershell.py.Evidence that it works
Original reproduction and earlier revision
Web verification on this revision
In a manual web run, the Default Agent created 窗边的小猫 🐈 with the two-line prompt below (zero generation jobs). Both
opendirector project showand persisted storage matched verbatim:(Note: in this manual trace the model also set encoding variables before the pipe; the automated tests above verify the launcher when the model omits them and under enforced
Restricted.)After restarting the local web service and reopening the project, 窗边的小猫 🐈 and both prompt lines (including the
?) remained intact in the canvas and node editor:Provider verification
1.19.5and1.19.6), Windows PowerShell 5.1, CLI, and project storage.gpt-6.1-soland saved the node without calling an image provider (the original before/after screenshots usedgpt-6.1-solandgpt-image-2.5-flare).Bilingual UI