mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
The `/bug` command tests in `slashCommandProcessor.test.ts` were flaky due to inconsistent CLI versioning.
This commit:
- Implements a flexible, top-level mock for `getCliVersion` that can be overridden per test.
- Sets a default mock value for `/bug` command tests via `beforeEach`.
- Overrides the mock in one test case requiring a specific version ('test-version').
- Ensures the test's helper `getExpectedUrl` receives the correct explicit version.
- Aligns the expected CLI version in the custom bug URL test with the default mock.
These changes ensure consistent CLI versioning in tests, resolving flakiness.
#1071
Gemini CLI
This package contains the core command-line interface for Gemini CLI.
Setup
- Get a Gemini API Key: Obtain your API key from Google AI Studio: https://aistudio.google.com/app/apikey
- Set Environment Variable: Set the
GEMINI_API_KEYenvironment variable to your obtained key. You can do this temporarily in your current shell session:Or add it to your shell's configuration file (likeexport GEMINI_API_KEY="YOUR_API_KEY"~/.bashrc,~/.zshrc, or~/.profile) for persistence:Replaceecho 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc # Or your preferred shell config file source ~/.bashrc # Reload the config"YOUR_API_KEY"with your actual key.
Building
To build only the CLI package, navigate to this directory (packages/cli) and run:
npm run build
This command executes the TypeScript compiler (tsc) as defined in this package's package.json. Ensure dependencies have been installed from the root directory (npm install) first.
Running
To start the Gemini CLI directly from this directory:
npm start
This command executes node dist/gemini.js as defined in this package's package.json.
Debugging
To debug the CLI application using VS Code:
- Start the CLI in debug mode from this directory (
packages/cli):This command runsnpm run debugnode --inspect-brk dist/gemini.js, pausing execution until a debugger attaches. - In VS Code (opened at the root of the monorepo), use the "Attach" launch configuration (found in
.vscode/launch.json). This configuration is set up to attach to the Node.js process listening on port 9229, which is the default port used by--inspect-brk.