Skip to content

Add terminal command entrypoints for LSPRAG workflows#7

Open
Huang-Xuwei wants to merge 2 commits intoTHU-WingTecher:mainfrom
Huang-Xuwei:main
Open

Add terminal command entrypoints for LSPRAG workflows#7
Huang-Xuwei wants to merge 2 commits intoTHU-WingTecher:mainfrom
Huang-Xuwei:main

Conversation

@Huang-Xuwei
Copy link
Contributor

Summary

This PR adds terminal-accessible entrypoints for core LSPRAG workflows, so they no longer depend on opening the Command Palette in VS Code.

Specifically, this change introduces CLI support for:

  • testing LLM connectivity
  • generating unit tests from a file/function target
  • printing the current LSPRAG configuration

These CLI commands are designed to reuse the existing extension behavior as much as possible, instead of creating a separate implementation path.

Motivation

LSPRAG previously exposed its main workflows only through VS Code commands such as:

  • LSPRAG: Test LLM
  • LSPRAG: Generate Unit Test
  • LSPRAG: Show Current Settings

That made scripting, automation, remote usage, and terminal-first debugging harder than necessary. This PR adds a terminal path for those workflows so they can be invoked directly from the workspace root.

Changes

New CLI commands

Added terminal commands for:

  • npm run test:llm
  • npm run generate:cli -- --file <path> --function <name>
  • npm run show:settings

Shared command logic

Refactored command implementations so the CLI path reuses existing extension logic where possible.

  • generate:cli reuses the extension command path instead of introducing a separate generator implementation
  • show:settings and the VS Code command now share the same settings summary formatter

CLI host and VS Code test integration

For generate:cli, the PR adds a VS Code test-host bridge so terminal execution can still use:

  • document symbols
  • semantic tokens
  • language server features
  • the existing generation pipeline

WSL / Remote robustness improvements

The terminal generation path now handles several environment-specific issues that prevented the VS Code test instance from loading language extensions correctly:

  • isolates the spawned VS Code process from VSCODE_* remote CLI state
  • syncs required language extensions into the test profile
  • clears stale .obsolete extension removal markers
  • allows configurable VS Code test versions, defaulting to stable

Better CLI validation and errors

Improved terminal UX by failing earlier and with clearer messages:

  • validates LLM configuration before launching the test host
  • reports missing provider-specific credentials directly in terminal
  • when a target function name is not found, prints available callable names in the file
  • corrected misleading CLI examples to use actual callable symbols from the fixture

Files added / updated

Main additions

  • src/cli/testLLM.ts
  • src/cli/generateUnitTest.ts
  • src/cli/showSettings.ts
  • src/llmHealthcheck.ts
  • src/currentSettings.ts
  • src/commands/generateUnitTestCommand.ts
  • src/test/generateCliHost.ts

Main updates

  • src/extension.ts
  • src/invokeLLM.ts
  • src/config.ts
  • src/test/runTest.ts
  • src/test/runExperiment.ts
  • package.json
  • README.md

Usage

Examples:

npm run test:llm
npm run show:settings
npm run generate:cli -- --file src/test/fixtures/python/calculator.py --function compute

Validation

Validated locally:

  • TypeScript compilation passes
  • terminal settings command works
  • terminal generate flow now reaches the extension/LSP pipeline correctly
  • missing LLM credentials are reported before generation starts

Notes

Full end-to-end generation still requires a valid configured LLM provider, for example:

  • DEEPSEEK_API_KEY
  • OPENAI_API_KEY
  • or LOCAL_LLM_URL for local/Ollama usage

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.

1 participant