Skip to content

fix: CLI --help trailing newline & headless run in non-git directories#28627

Closed
sw33tgum wants to merge 2 commits into
anomalyco:devfrom
sw33tgum:fix-cli-issues
Closed

fix: CLI --help trailing newline & headless run in non-git directories#28627
sw33tgum wants to merge 2 commits into
anomalyco:devfrom
sw33tgum:fix-cli-issues

Conversation

@sw33tgum
Copy link
Copy Markdown

Summary

Two bug fixes:

  1. CLI --help lacks trailing newline #28606--help output lacks trailing newline, causing the next shell prompt to appear on the same line. Fixed by ensuring show() always appends EOL when the output doesn't already end with one.

  2. opencode run exits silently with no output in a non-git directory (GLM 5.1) #28605opencode run exits silently with no output in a non-git directory. Root cause: Project.fromDirectory returns {worktree: "/", sandbox: "/"} when no .git directory is found. This makes containsPath() treat all files outside ctx.directory as external, triggering external_directory permission requests that are auto-rejected in headless mode. Fixed by using directory (the actual working directory) instead of "/" as the project root boundary.

Changes

  • packages/opencode/src/index.ts: show() now ensures trailing newline via endsWith(EOL) check.
  • packages/opencode/src/project/project.ts: fromDirectory returns {worktree: directory, sandbox: directory} instead of {worktree: "/", sandbox: "/"} when no .git is present.

Closes #28606, closes #28605

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found some related PRs that address similar issues. Here are the relevant ones (excluding the current PR #28627):

Potential Related PRs:

  1. PR fix(cli): add newline to help output #28622fix(cli): add newline to help output

    • Addresses the same --help trailing newline issue
  2. PR fix: add trailing newline to help output #26374fix: add trailing newline to help output

    • Also addresses the trailing newline problem in help output (older related fix)
  3. PR fix(permission): worktree-relative paths fall back to directory in non-git projects #26694fix(permission): worktree-relative paths fall back to directory in non-git projects

    • Addresses the non-git project issue with external_directory permission handling, which is directly related to the second bug fix in this PR

Note: PR #28622 appears to be a recent PR targeting the same --help trailing newline bug. You may want to review whether this PR (#28627) is consolidating both fixes or if #28622 should be closed in favor of this one.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 21, 2026
@github-actions github-actions Bot closed this May 21, 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.

CLI --help lacks trailing newline opencode run exits silently with no output in a non-git directory (GLM 5.1)

1 participant