Skip to content

feat: Implement true non-interactive mode for -p/--prompt flag#255

Open
liciciyi wants to merge 4 commits into
lessweb:mainfrom
liciciyi:main
Open

feat: Implement true non-interactive mode for -p/--prompt flag#255
liciciyi wants to merge 4 commits into
lessweb:mainfrom
liciciyi:main

Conversation

@liciciyi

Copy link
Copy Markdown

Summary

This PR implements a true non-interactive mode for the -p/--prompt flag, similar to Claude Code's --print mode. Instead of rendering the TUI interface, the CLI now outputs pure text responses and exits automatically.

Changes

Core Implementation (packages/cli/src/cli.tsx)

  • Added runNonInteractiveMode() function that bypasses Ink/React UI entirely
  • Uses SessionManager directly to process prompts
  • Outputs only the LLM response as plain text to stdout
  • Handles errors gracefully with stderr output and proper exit codes
  • Imports necessary types and functions from @vegamo/deepcode-core

Behavior

Before:

$ deepcode -p "hello"
[Shows full TUI with banner, status bar, etc.]
[User must manually exit]

After:

$ deepcode -p "hello"
Hello! I'm Deep Code, an interactive CLI tool designed to help you with software engineering tasks.
...
[Auto-exits with code 0]

Testing & Verification

All Tests Pass ✅

  • Core package: 255/255 tests passed
  • CLI package: 253/254 tests passed (1 skipped)
  • UI package: 49/49 tests passed
  • Total: 557/558 tests passed

Build Verification ✅

  • TypeScript type checking: Passed
  • ESLint: Passed
  • Prettier formatting: Passed
  • Full build: Successful

Functional Testing ✅

  • Non-interactive mode works correctly
  • Pure text output without ANSI escape codes
  • Auto-exit after response confirmed
  • Exit code 0 on success verified
  • Error handling tested

Use Cases

This feature enables:

  • Scripting and automation workflows
  • Integration with other CLI tools
  • Quick queries without entering interactive mode
  • CI/CD pipeline integration

Related Issues

Fixes Issue #252: Make -p flag exit after response

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added/updated and passing
  • Documentation updated (help text reflects new behavior)
  • No breaking changes to existing functionality

qorzj added 4 commits July 24, 2026 22:02
- Add shouldExitAfterInitialPromptRef to track initial prompt from -p flag
- Auto-exit when LLM response completes (busy becomes false)
- Update help text to clarify non-interactive behavior
- Fixes issue lessweb#252 where -p still entered interactive mode
Implement pure text output mode (like Claude Code's --print) when using
the -p or --prompt flag. Instead of rendering the TUI, the CLI now:
- Skips Ink/React UI entirely
- Uses SessionManager directly to process the prompt
- Outputs only the LLM response as plain text to stdout
- Exits immediately after response with proper exit code

Changes:
- Add runNonInteractiveMode() function in cli.tsx
- Import SessionManager and related types from core
- Detect -p flag early and route to non-interactive mode
- Handle errors gracefully with stderr output and non-zero exit codes

Verification:
- All tests pass (557/558, 1 skipped)
- Type checking, linting, and formatting all pass
- npm link works correctly
- Non-interactive mode outputs clean text without ANSI codes
- Auto-exit after response confirmed
- Exit code 0 on success verified
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.

2 participants