Skip to content
Draft
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
607cbef
feat: base SDK changes
PyContriver Nov 20, 2025
d11da5d
feat: add missing dependencies for Google SDK
PyContriver Nov 20, 2025
6f94032
feat: add Google provider constants to lightspeed.ts
PyContriver Nov 20, 2025
2d3ef2f
feat: add ansibleContext and js-yaml dependency
PyContriver Nov 20, 2025
ed7f7f2
fix: lightspeed settings
PyContriver Nov 20, 2025
2b93e67
fix: update dict file
PyContriver Nov 20, 2025
f49c1a7
adding tests
kaushiki069 Nov 20, 2025
f84eb5d
updating constants
kaushiki069 Nov 20, 2025
1a0267a
updating tests
kaushiki069 Nov 20, 2025
ac6dfe5
adding outline generator tests
kaushiki069 Nov 21, 2025
621fc01
removing file types from constants
kaushiki069 Nov 21, 2025
a9f2fcd
lint fix
kaushiki069 Nov 24, 2025
189d87d
include new tests in coverage
kaushiki069 Nov 24, 2025
cc8066d
dep fix
kaushiki069 Nov 24, 2025
071e5cf
docs preflight fix
kaushiki069 Nov 24, 2025
9381a80
fix: lint
PyContriver Nov 25, 2025
8f1346f
fix: eslint lint
PyContriver Nov 25, 2025
ec54215
fix: deps
PyContriver Nov 25, 2025
30cf59d
fix: yarn.locl
PyContriver Nov 25, 2025
473d5ff
fix: yarn.lock conflicts
PyContriver Nov 25, 2025
89951e5
Merge branch 'main' into google-sdk-base
PyContriver Nov 25, 2025
ece4358
update ci and resolve
kaushiki069 Nov 25, 2025
4531f78
fix lint
kaushiki069 Nov 25, 2025
cf9443b
combining the steps to avoid duplicate flags
kaushiki069 Nov 25, 2025
5116b4a
using a wider glob
kaushiki069 Nov 25, 2025
507565f
Merge branch 'main' into google-sdk-base
anusshukla Nov 26, 2025
e41d66e
Merge remote-tracking branch 'upstream/main' into google-sdk-base
kaushiki069 Nov 27, 2025
bb87e44
Merge branch 'main' into google-sdk-base
kaushiki069 Nov 27, 2025
21b02d6
Merge branch 'main' into google-sdk-base
kaushiki069 Nov 27, 2025
c1b0239
Merge branch 'main' into google-sdk-base
kaushiki069 Nov 27, 2025
dee5cd6
Merge branch 'main' into google-sdk-base
kaushiki069 Nov 27, 2025
b347213
fix: sonar
PyContriver Nov 28, 2025
774e1cf
feat: webview changes
PyContriver Dec 1, 2025
8e74e76
fix: deps class
PyContriver Dec 1, 2025
a919999
updating changes
kaushiki069 Dec 1, 2025
fb224f7
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2025
cc6b5cb
lint fixes
kaushiki069 Dec 1, 2025
c8c9c2f
fixing lint in one file
kaushiki069 Dec 1, 2025
fc244fe
fixing lint errors
kaushiki069 Dec 1, 2025
74b6789
update lint
kaushiki069 Dec 1, 2025
4d20675
flint fixes
kaushiki069 Dec 1, 2025
7d875c2
removing duplicates
kaushiki069 Dec 1, 2025
d480d57
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 1, 2025
2fe66e9
increase vsix limit
kaushiki069 Dec 1, 2025
65fcae5
updating package.json
kaushiki069 Dec 1, 2025
df03fb9
removing redundant pieces
kaushiki069 Dec 1, 2025
a51168c
Merge remote-tracking branch 'upstream/main' into webviews_integratio…
kaushiki069 Dec 2, 2025
5ffa4a8
trial to fix ui tests
kaushiki069 Dec 2, 2025
2e09b61
trial fix for ui tests
kaushiki069 Dec 2, 2025
4a32186
trial fixes for failing ui tests
kaushiki069 Dec 2, 2025
26f6ebb
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2025
ff61181
reverting extra pieces
kaushiki069 Dec 2, 2025
1cf2abd
reducing timeout and reverting excess changes
kaushiki069 Dec 2, 2025
b9ca368
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2025
948fd92
changing back to 30
kaushiki069 Dec 2, 2025
6d51f8e
fix ui failure
kaushiki069 Dec 2, 2025
a8598a8
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2025
598fa66
fix feedback ui test
kaushiki069 Dec 3, 2025
e51c7a4
Merge branch 'main' into webviews_integration_main
kaushiki069 Dec 3, 2025
ac95046
lint fixes
kaushiki069 Dec 3, 2025
95d4de7
removing redundant test files
kaushiki069 Dec 3, 2025
cd9b660
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 3, 2025
28c5609
adding back contentmatches test
kaushiki069 Dec 3, 2025
5a36057
Update Role gen test
tanwigeetika1618 Dec 3, 2025
1fa4b43
Add ui tests for playbook gen via llm provider
tanwigeetika1618 Dec 3, 2025
18df294
Merge branch 'main' into webviews_integration_main
PyContriver Dec 4, 2025
f02d6b9
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2025
dfb129f
fix: yarn.lock
PyContriver Dec 4, 2025
46bcb8e
align changes
kaushiki069 Dec 4, 2025
ff649f0
chore: auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2025
43178a4
Merge branch 'main' into webviews_integration_main
kaushiki069 Dec 4, 2025
00040aa
Merge remote-tracking branch 'origin/main' into webviews_integration_…
kaushiki069 Dec 5, 2025
4217eaa
update vitest
kaushiki069 Dec 5, 2025
ce1c379
updating feedback name
kaushiki069 Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Infiles
KUBEDOCK
Konflux
LIGHTSPEED
LLMPROVIDER
Lightspeed
Lightspeed's
Maciążek
Expand All @@ -38,6 +39,7 @@ codeclimate
codespell
contentmatch
contentmatches
contentmatching
coreutils
cpython
dedupe
Expand All @@ -47,6 +49,7 @@ devspaces
eslintcache
extest
fqcn
genai
githubcli
haaaad
highlightjs
Expand All @@ -61,6 +64,7 @@ libonig
libssh
lightspeed
lineinfile
llmprovider
maxlength
microdnf
mocharc
Expand All @@ -71,6 +75,7 @@ mymodule
mynamespace
myorg
myproject
myrole
nocolor
noheading
norecursedirs
Expand Down
2 changes: 2 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ignores:
- "@types/vscode" # determined by (package.json).engines.vscode
- "@vscode/test-electron" # used by @vscode/test-cli
- "@vscode/vsce"
- "@vitest/coverage-v8" # used by vitest.config.ts coverage provider
- cypress-multi-reporters
- depcheck
- electron
Expand All @@ -23,3 +24,4 @@ ignores:
- vscode
- webpack-cli
- yarn-audit-fix
- "@typescript-eslint/eslint-plugin" # used by eslint.config.mjs
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ jobs:
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
with:
name: unit
files: ./**/coverage/unit/*cobertura-coverage.xml
files: ./**/coverage/unit/**/*cobertura-coverage.xml
flags: unit
disable_search: true
fail_ci_if_error: true
Expand Down
1 change: 1 addition & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ tasks:
- out/coverage/unit/lcov.info
cmds:
- npm run unit-tests
- npm run unit-tests-vitest-coverage
interactive: true
package:
desc: Package extension
Expand Down
55 changes: 46 additions & 9 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,53 @@ any level (User, Remote, Workspace and/or Folder).

## Lightspeed Configuration

- `ansible.lightspeed.enabled`: Enable Ansible Lightspeed.
- `ansible.lightspeed.URL`: URL for Ansible Lightspeed.
- `ansible.lightspeed.suggestions.enabled`: Enable Ansible Lightspeed with
watsonx Code Assistant inline suggestions.
### Core Settings

- `ansible.lightspeed.enabled`: Enable/disable Ansible Lightspeed.
- `ansible.lightspeed.provider`: Select AI provider (`wca`, `openai`, `google`, `custom`).
- `wca`: Red Hat Ansible Lightspeed with IBM watsonx Code Assistant (default)
- `openai`: Direct OpenAI API access
- `google`: Google Gemini API access
- `custom`: Custom OpenAI-compatible API

- `ansible.lightspeed.apiEndpoint`: API endpoint URL for the selected provider.
- For WCA: `https://c.ai.ansible.redhat.com` (default)
- For OpenAI: `https://api.openai.com/v1`
- For Google: `https://generativelanguage.googleapis.com/v1beta`
- For Custom: Your custom API endpoint

- `ansible.lightspeed.modelName`: Model name/ID to use.
- For WCA: Model ID override (optional, for commercial users)
- For LLM providers: Required model identifier (e.g., `gpt-4`, `gemini-2.5-flash`)

- `ansible.lightspeed.apiKey`: API key for LLM providers.
- Not used for WCA (uses OAuth2 authentication)
- Required for `openai`, `google`, and `custom` providers

- `ansible.lightspeed.timeout`: Request timeout in milliseconds (default: 30000).

### Inline Suggestions

- `ansible.lightspeed.suggestions.enabled`: Enable inline suggestions.
- Note: Currently only supported with WCA provider

- `ansible.lightspeed.suggestions.waitWindow`: Delay (in milliseconds) prior to
sending an inline suggestion request to Ansible Lightspeed with watsonx Code
Assistant.
- `ansible.lightspeed.modelIdOverride`: Model ID to override your organization's
default model. This setting is only applicable to commercial users with an
Ansible Lightspeed seat assignment.
sending an inline suggestion request.

### Advanced Settings

- `ansible.lightspeed.customHeaders`: Custom HTTP headers for LLM providers (JSON object).
- Example: `{"Custom-Header": "value"}`
- Not used for WCA

### Backward Compatibility

The following legacy settings are still supported for backward compatibility:

- `ansible.lightspeed.URL`: Mapped to `ansible.lightspeed.apiEndpoint`
- `ansible.lightspeed.modelIdOverride`: Mapped to `ansible.lightspeed.modelName`

See [LLM Provider Documentation](llm-providers.md) for detailed setup instructions and examples.

## Completion & Language Server Settings

Expand Down
238 changes: 238 additions & 0 deletions docs/llm-providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# LLM Provider Support for Ansible Lightspeed

The Ansible VS Code extension supports multiple LLM providers including Red Hat's Ansible Lightspeed with watsonx Code Assistant (WCA) and Google Gemini for Ansible code generation and assistance.

## Supported Features

When using LLM providers, the following Ansible Lightspeed features are available:

**Supported in Phase 1:**

- Playbook Generation
- Role Generation
- Interactive Chat (if provider supports it)

**Not Supported in Phase 1:**

- Inline Task Suggestions
- Content Source Matching

## Supported Providers

### Google Gemini

Direct access to Google Gemini models.

**Configuration:**

- Provider: `google`
- API Endpoint: `https://generativelanguage.googleapis.com/v1beta` (⚠️ **fixed, not configurable**)
- API Key: Your Google AI API key (starts with `AIza`)
- Model Name: e.g., `gemini-2.5-flash`, `gemini-1.5-pro`

> **Note:** For Google provider, the API endpoint is automatically set and cannot be changed.
## Setup Instructions

### Method 1: Guided Configuration (Recommended)

1. Open the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`)
2. Run: `Ansible Lightspeed: Configure LLM Provider`
3. Select your desired provider from the list (Google or WCA)
4. Enter the required configuration details when prompted
5. Test the connection when prompted

### Quick Provider Selection

1. Open VS Code Settings (`Ctrl+,` / `Cmd+,`)
2. Search for "Ansible Lightspeed Provider"
3. Select from the dropdown: `WCA` or `Google`
4. Configure the required settings based on your selection

### Method 2: Manual Configuration

1. Open VS Code Settings (`Ctrl+,` / `Cmd+,`)
2. Search for "Ansible Lightspeed"
3. Configure the following settings:

**For Google Gemini:**

```json
{
"ansible.lightspeed.enabled": true,
"ansible.lightspeed.provider": "google",
// apiEndpoint is automatically set (not configurable)
"ansible.lightspeed.apiKey": "your-google-api-key",
"ansible.lightspeed.modelName": "gemini-2.5-flash"
}
```

**For WCA (default):**

```json
{
"ansible.lightspeed.enabled": true,
"ansible.lightspeed.provider": "wca",
"ansible.lightspeed.apiEndpoint": "https://c.ai.ansible.redhat.com"
}
```

### Method 3: Workspace Configuration

Add to your workspace `.vscode/settings.json`:

```json
{
"ansible.lightspeed.enabled": true,
"ansible.lightspeed.provider": "google",
// apiEndpoint is automatically set (not configurable)
"ansible.lightspeed.apiKey": "${env:GOOGLE_API_KEY}",
"ansible.lightspeed.modelName": "gemini-2.5-flash"
}
```

## Configuration Settings

| Setting | Description | Default | Applicable To |
| ------------------------------------ | ----------------------------------- | ------------------------------------- | ----------------------- |
| `ansible.lightspeed.enabled` | Enable/disable Ansible Lightspeed | `true` | All providers |
| `ansible.lightspeed.provider` | Provider selection | `wca` | All providers |
| `ansible.lightspeed.apiEndpoint` | API endpoint URL | `https://c.ai.ansible.redhat.com` | **WCA only** |
| `ansible.lightspeed.modelName` | Model name/ID to use | `""` | All providers |
| `ansible.lightspeed.apiKey` | API key for authentication | `""` | Google only (not WCA) |
| `ansible.lightspeed.timeout` | Request timeout in milliseconds | `30000` | All providers |
| `ansible.lightspeed.customHeaders` | Custom HTTP headers (JSON object) | `{}` | Third-party only |

## Usage

Once configured, LLM providers work seamlessly with existing Ansible Lightspeed features:

### Playbook Generation

1. Right-click in an Ansible file
2. Select "Generate Ansible Playbook with Lightspeed"
3. Enter your requirements
4. The configured LLM provider will generate the playbook

### Role Generation

1. Right-click in an Ansible file
2. Select "Generate Ansible Role with Lightspeed"
3. Enter your requirements
4. The configured LLM provider will generate the role structure

### Interactive Chat

1. Open the Ansible Lightspeed panel
2. Use the chat interface to ask Ansible-related questions
3. The LLM provider will provide Ansible-specific assistance

## Provider Management Commands

Access these commands via the Command Palette (`Ctrl+Shift+P` / `Cmd+Shift+P`):

- `Ansible Lightspeed: Configure LLM Provider` - Guided setup
- `Ansible Lightspeed: Test Provider Connection` - Verify connectivity
- `Ansible Lightspeed: Show Provider Status` - View current configuration
- `Ansible Lightspeed: Switch Provider` - Change between WCA and LLM providers

## Switching Between Providers

You can easily switch between providers using the dropdown:

1. **Open Settings:** `Ctrl+,` / `Cmd+,`
2. **Search:** "Ansible Lightspeed Provider"
3. **Select:** Choose from the dropdown (`WCA` or `Google`)
4. **Configure:** Update `apiKey` and `modelName` as needed for the selected provider

**Or use the Command Palette:**

1. `Ctrl+Shift+P` / `Cmd+Shift+P`
2. Run: `Ansible Lightspeed: Switch Provider`
3. Select your desired provider from the list

## Security Considerations

**Important Security Notes:**

1. **API Key Storage:** API keys are stored in VS Code settings. Consider using environment variables for sensitive keys.

2. **Data Privacy:** When using LLM providers, your Ansible code and prompts are sent to external services. Review each provider's privacy policy.

3. **Workspace Settings:** For team projects, avoid committing API keys to version control. Use environment variables or user-specific settings.

4. **Network Security:** Ensure your network allows HTTPS connections to the provider endpoints.

## Troubleshooting

### Connection Issues

1. **Test Connection:**

```text
Command Palette > Ansible Lightspeed: Test Provider Connection
```

2. **Check API Key:** Ensure your API key is valid and has sufficient credits/quota

3. **Verify Endpoint:** Confirm the API endpoint URL is correct

4. **Network Access:** Check firewall/proxy settings

### Common Error Messages

| Error | Solution |
| ------------------------- | -------------------------------------------------- |
| "Authentication failed" | Check your API key |
| "Rate limit exceeded" | Wait and try again, or check your quota |
| "Request timeout" | Increase timeout setting or check network |
| "Model not found" | Verify the model name is correct for your provider |

### Debug Information

Enable debug logging by setting:

```json
{
"ansible.lightspeed.debug": true
}
```

Check the "Ansible Support" output channel for detailed logs.

## Model Recommendations

### For Code Generation

- **Google:** `gemini-2.5-flash` or `gemini-1.5-pro`

### For Chat/Explanations

- **Google:** `gemini-2.5-flash` (fast and cost-effective)

## Limitations

1. **Phase 1 Limitations:**
- No inline task suggestions
- No content source matching
- Limited to playbook and role generation

2. **Provider-Specific:**
- Rate limits vary by provider
- Model capabilities differ
- Costs vary by usage

3. **Authentication:**
- No Red Hat SSO integration
- No Ansible Automation Platform subscription validation

## Support

For issues with LLM provider integration:

1. Check this documentation
2. Test your provider configuration
3. Review the troubleshooting section
4. File an issue on the [Ansible VS Code Extension repository](https://github.com/ansible/vscode-ansible/issues)

For provider-specific issues (API keys, billing, model availability), contact your provider's support directly.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ nav:
- index: mcp/README.md
- API Reference: mcp/api.md
- Configuration: configuration.md
- LLM Providers: llm-providers.md
- Developer Guide:
- development/index.md
- development/contributing.md
Expand Down
Loading
Loading