Skip to content

Conversation

@chezsmithy
Copy link
Contributor

@chezsmithy chezsmithy commented Nov 11, 2025

Description

I'd noticed that due to TTY specific requirements it wasn't possible to launch the continue CLI locally from the vscode or intelliJ terminal tools. This change allows that to work when the cli is launched in headless mode. This unlocks headless sub agents to be used locally.

I've included a couple of sample prompts in this PR as well which can now unlock running background and foreground subagents.

Nice use cases include launching prettier, or code cleanup tasks in the background while you keep coding. Or perhaps kicking off the generation of tests in a separate agent context off of the main context in the extension.

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • I've read the contributing guide
  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

Added new headless tests.


Summary by cubic

Removes the TTY requirement when running the CLI in headless mode (-p), so it works in VSCode/IntelliJ terminals, Docker, and CI without hanging. This enables local headless sub-agents and clean non-interactive runs.

  • New Features
    • Headless mode never initializes the TUI; skips stdin when a prompt is supplied (even after flags) and shows clear errors if missing, except when using --resume or --fork.
    • TTY detection and safeguards added to prevent TUI in TTY-less environments and test raw-mode support; Ink now receives explicit stdio streams.
    • Logger and stdin handling updated for TTY-less runs; supports FORCE_NO_TTY and sets UTF-8 encoding.
    • Docs added for TTY-less usage (README + spec) and new e2e tests for TTY-less/headless behavior.
    • New sample prompts to launch sub-agents in background or foreground.

Written for commit 45cace7. Summary will update automatically on new commits.

@chezsmithy chezsmithy requested a review from a team as a code owner November 11, 2025 21:48
@chezsmithy chezsmithy requested review from tingwai and removed request for a team November 11, 2025 21:48
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 11, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 issues found across 11 files

Prompt for AI agents (all 7 issues)

Understand the root cause of the following 7 issues and fix them.


<file name=".continue/prompts/sub-agent-foreground.md">

<violation number="1" location=".continue/prompts/sub-agent-foreground.md:9">
Please correct the typo in this user-facing instruction so it reads &quot;foreground&quot; instead of &quot;forground&quot;.</violation>
</file>

<file name=".continue/prompts/sub-agent-background.md">

<violation number="1" location=".continue/prompts/sub-agent-background.md:11">
Wrap the interpolated prompt in shell-safe quoting before passing it to `cn -p` so multi-word prompts stay intact and user input cannot break into additional shell commands.</violation>
</file>

<file name="extensions/cli/src/commands/chat.ts">

<violation number="1" location="extensions/cli/src/commands/chat.ts:449">
Throwing whenever `prompt` is falsy breaks headless runs that rely on `--prompt` or `--agent`: we combine those sources immediately afterwards, so these valid flows now fail. Please only reject when none of the prompt sources are provided.</violation>
</file>

<file name="extensions/cli/src/util/cli.ts">

<violation number="1" location="extensions/cli/src/util/cli.ts:56">
Treating --agent as supplying a prompt makes headless runs with piped stdin (e.g. `echo &quot;review&quot; | cn -p --agent …`) drop the input because `readStdinSync` now bails early.</violation>
</file>

<file name="extensions/cli/src/util/stdin.ts">

<violation number="1" location="extensions/cli/src/util/stdin.ts:24">
`hasSuppliedPrompt()` only checks the argument immediately following `-p/--print`, so commands like `cn -p --config my.yaml &quot;Prompt&quot;` still fall through to blocking stdin reads even though a prompt is supplied; the new guard reintroduces the hang you’re trying to remove.</violation>
</file>

<file name="extensions/cli/spec/tty-less-support.md">

<violation number="1" location="extensions/cli/spec/tty-less-support.md:101">
This bullet claims headless logger output is line-buffered, but configureHeadlessMode() only adjusts stdout/stderr encoding and never changes buffering, so the documentation is inaccurate.</violation>

<violation number="2" location="extensions/cli/spec/tty-less-support.md:102">
Nothing in the logger configuration currently disables progress indicators, so this documentation line overstates what the implementation does.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

chezsmithy and others added 2 commits November 11, 2025 18:57
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

chezsmithy and others added 4 commits November 11, 2025 19:20
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files (reviewed changes from recent commits).

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="extensions/cli/src/commands/chat.ts">

<violation number="1" location="extensions/cli/src/commands/chat.ts:449">
Allowing `--agent` to bypass the headless prompt guard means agents without a prompt still trigger the interactive `question()` call and hang in TTY-less headless runs. Please keep rejecting headless executions until some actual prompt text is available.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 6 files (reviewed changes from recent commits).

2 issues found across 6 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="extensions/cli/src/util/cli.ts">

<violation number="1" location="extensions/cli/src/util/cli.ts:60">
`--agent` takes a slug argument, but since it is missing from `flagsWithValues`, its slug is misidentified as the prompt and `hasSuppliedPrompt()` still returns true—stdin is skipped even though no prompt was supplied. Please add `--agent` to the value-skipping set so the flag’s argument isn’t mistaken for a prompt.</violation>
</file>

<file name="extensions/cli/src/util/cli.test.ts">

<violation number="1" location="extensions/cli/src/util/cli.test.ts:103">
The logic for determining if a prompt is supplied via `--agent` is inconsistent across files. The new test in `cli.test.ts` asserts that `hasSuppliedPrompt()` is true for `--agent`, but the implementation and comments in `cli.ts` imply it should be false, leading to hangs in headless mode.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

chezsmithy and others added 10 commits November 11, 2025 20:02
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@chezsmithy
Copy link
Contributor Author

This should be ready for review. The failures in the binary and jetbrains tests are unexpected. Appears maybe the package-lock in the binary directory needs to be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant